• Advertisement
Sign in to follow this  

[SOLVED] XNA Point Sprite woes

This topic is 2938 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
Sign in to follow this  

  • Advertisement