PDA

View Full Version : point sprites and fragment shaders



thinks
01-05-2005, 09:12 AM
I have come across a problem with point sprites and fragment shaders that I would like to share. First of all, here's my code:


***Fragment shader***

uniform sampler2D testTexture;

void main( void )
{
gl_FragColor = gl_Color*texture2D( testTexture, v_texCoord );

}The weird thing is, that if v_texCoord is NOT defined (as above) the program works, but I get an error. As soon as I define it to be anything my point sprites are not shown on the screen.


glTexEnvi(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE);Is done in my main app.

There is info about point sprites here (http://oss.sgi.com/projects/ogl-sample/registry/ARB/point_sprite.txt)

I find it hard to understand how varying data from a vertex shader could be interpolated across a point. Is there any defined behaviour for this?

zed
01-07-2005, 12:37 PM
im pretty sure u need to write to this
gl_PointSize = X
in the vertex shader
also stick this in somewhere
glEnable( GL_VERTEX_PROGRAM_POINT_SIZE_ARB );

Chuck0
01-07-2005, 06:19 PM
Originally posted by thinks:
I have come across a problem with point

I find it hard to understand how varying data from a vertex shader could be interpolated across a point. Is there any defined behaviour for this?if your vertex program passes something to the fragment program through an interpolator it stays constant for every fragment of the point. only if texcoord replacement is enabled the specified texture coordinate is being interpolated over the point (ignoring everything you pass as this coordinate to the gpu)

thinks
01-10-2005, 02:04 AM
The solution was to use the built in texture coordinates, gl_TexCoord[0].st. In fact this is not entirely true either. What I used was gl_TexCoord[0], without .st. This seems to be a bug. I was told that my program should not compile with this sort of code. Isn't gl_TexCoord[0] a vec4? Doesn't texture2D want vec2?