PDA

View Full Version : Point sprite with GLSL?



LangFox
01-22-2007, 04:59 PM
glspec20 says:


If a vertex shader is active and vertex program point size mode is enabled,
then the derived point size is taken from the (potentially clipped) shader builtin
gl_PointSize and clamped to the implementation-dependent point size range.

If a vertex shader is active and vertex program point size mode is disabled,
then the derived point size is taken from the point size state as specified by the
PointSize command. In this case no distance attenuation is performed.
I think it means the point's size will change against the distance when the vertex shader and vertex program point size are both enabled. It's not true, however, in my programm. Anyone met this problem before?

ehart
01-22-2007, 05:51 PM
I think you have it backwards. It is saying that if you have a vertex shader enabled, and you do not have GL_VERTEX_PROGRAM_POINT_SIZE enabled, it will use the value supplied to glPointSize. If you have program point size enabled, then you specify the point size to be whatever you want in you program, by writing to gl_PointSize.

-Evan

LangFox
01-23-2007, 04:53 PM
Well, "gl_PointSize" is the built-in vertex shader variable, "PointSize command" is glPointSize from the fixed pipleline.

But what I concerned is, when vertex shader actived and GL_VERTEX_PROGRAM_POINT_SIZE enabled, the closer to view the point sprites, the smaller the particle is... Shouldn't it be the closer the bigger?

screenshot:
far - http://olz.photo.qq.com/?file=BCCC4690C254DE3071759BCC95BA5066F7773AD0DF10 17BC9230BB417A758791

near - http://ol7.photo.qq.com/?file=8F88924D6EED3016E7F17600CCD2B4EFDD2009844080 FC3AB9298358BE019010

Korval
01-23-2007, 05:39 PM
But what I concerned is, when vertex shader actived and GL_VERTEX_PROGRAM_POINT_SIZE enabled, the closer to view the point sprites, the smaller the particle is... Shouldn't it be the closer the bigger? Are you sure it's actually getting smaller (your links don't work)? It's easy to mistake something getting smaller for something that's staying the same size when the world around it is getting bigger.

vince
01-23-2007, 07:41 PM
Having a vertex shader and GL_VERTEX_PROGRAM_POINT_SIZE enabled is not enough to get a light point attenuation with the distance. What that means is you can then set the size to the value you want using gl_PointSize. If you want an attenuation, you have to reduce gl_PointSize with the distance yourself in the vertex shader. That's pretty much what ehart was saying...

LangFox
01-24-2007, 04:14 PM
Actually, yes, it is the same size.

Thanks vince, that's what I am worrying about: I have to calculate the size with the distance myself...What a pity!!