Sign in to follow this  

[SOLVED] XNA Point Sprite woes

Recommended Posts

Solved - Apparently you have to set scaling parameters for point sprites in the shader ie: pass P0 { VertexShader = compile vs_1_1 VertexShader(); PixelShader = compile ps_2_0 RotatingPixelShader(); POINTSCALEENABLE= TRUE; POINTSCALE_A = 0.0f; POINTSCALE_B = 0.0f; POINTSCALE_C = 1.0f; POINTSIZE_MIN = 10.0f; POINTSIZE_MAX = 100.0f; } So I finished my point sprite particle system but I have a weird issue. As the point sprites get closer to the camera they shrink, and as they get further away, they grow. Obviously this is reverse behavior, but I have no idea what would cause this. I calculate the final point size in my shader using this function:

// Vertex shader helper for computing the size of a particle.
float ComputeParticleSize(float4 projectedPosition, float randomValue, 
                          float normalizedAge)
    // Apply a random factor to make each particle a slightly different size.
    float startSize = lerp(StartSize.x, StartSize.y, randomValue);
    float endSize = lerp(EndSize.x, EndSize.y, randomValue);
    // Compute the actual size based on the age of the particle.
    float size = lerp(startSize, endSize, normalizedAge);
    // Project the size into screen coordinates.
    return size * Projection._m11 / projectedPosition.w * ViewportHeight / 2;

Normalized age is just the particles currentAge / timeSinceCreation randomValue is just a way to keep the particle sizes a little unique I really would like to stick with point sprites because they're nice and simple, so if anyone has any ideas for why this would happen, I would love to hear them. Thanks Diginerd [Edited by - diginerd on February 9, 2010 3:19:44 PM]

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this