Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interpret negative alpha in shapes and waveforms as full intensity #781

Merged

Conversation

dpw13
Copy link
Collaborator

@dpw13 dpw13 commented Feb 16, 2024

Mostly fixes xtramartin(186).

@dpw13
Copy link
Collaborator Author

dpw13 commented Feb 17, 2024

image

@kblaschke
Copy link
Member

kblaschke commented Feb 17, 2024

It's not actually DirectX doing something different or wrong here, but the way how Milkdrop converts/passes the color into the vertex data. Milkdrop converts the float value times 255 to int and then masks away all bits except the last eight and assigns each color plus alpha to a 32-bit unsigned int representing an 8-bit RGBA color value:

                    v[0].Diffuse = 
                        ((((int)(*pState->m_shape[i].var_pf_a * 255 * alpha_mult)) & 0xFF) << 24) |
                        ((((int)(*pState->m_shape[i].var_pf_r * 255)) & 0xFF) << 16) |
                        ((((int)(*pState->m_shape[i].var_pf_g * 255)) & 0xFF) <<  8) |
                        ((((int)(*pState->m_shape[i].var_pf_b * 255)) & 0xFF)      );

This conversion will actually result in a sawtooth curve. We could perform a similar calculation to match the original code as closely as possible. In projectM's vertex attributes, each color is a float, and if you render negative color values, you'll always get black.

@dpw13 dpw13 force-pushed the dev/dwagner-negative-alpha branch 2 times, most recently from b8456eb to 3db4e28 Compare February 19, 2024 20:51
@kblaschke kblaschke added this to the 4.1 milestone Feb 21, 2024
@kblaschke kblaschke merged commit 0c27e81 into projectM-visualizer:master Feb 21, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

2 participants