Point sprite color with vertex shader issue
I'm currently changing code from the fixed function methods to use a vertex shader. I have a simple firework particle system with verts that use a position and a DWORD color. I randomized the color and things worked fine, but now with the shader, I'm only getting a white and a blue color. The shader is quite simple:
VS_OUTPUT output = (VS_OUTPUT)0;
input.position.w = 1.0f;
output.position = mul(input.position, ViewProjMatrix);
output.color = input.color;
return output;
What might the problem be? Should I create a pixel shader and pass the color through it as well? Does a render state need to be changed? I've tried disabling/enabling textures to no effect. Any thoughts would be welcome.
If you don't have a pixel shader bound to the pipeline, then whatever you output through the color semantic should get interpolated and rasterized just like in the fixed function setup, IIRC.
Do you have a per-vertex color attribute in your input vertex data? Try setting it to all 1's in the vertex shader to see if you can get a texture color to be applied to the sprite.
Do you have a per-vertex color attribute in your input vertex data? Try setting it to all 1's in the vertex shader to see if you can get a texture color to be applied to the sprite.
It would seem my problem was that i was outputting the color as an int, rather than as a vector. Why would this be though? When using fixed function FVFs, my color was a DWORD, which worked fine, so I simply tried to pass that through my vertex shader. Something about using a shader made it expect a four float setup instead, even though I specified it as an int?
Yes, that's the standard way that a color is output - each of the four components range from [0.0:1.0], and the fourth component is the alpha channel.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement