# gl_PointCoord Discolors Point

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

## Recommended Posts

I have a radial gradient of this particle texture I'm trying to put onto my particle's points via GL_POINTS. I've enabled GL_POINT_SPRITE, and I've also setup GL_COORD_REPLACE for the texture environment for GL_POINT_SPRITE. For some reason, I keep getting the results shown in the screenshot I have attached to this post.

Here are my vertex and fragment shaders:

// vertex shader
attribute vec4 a_position;
attribute vec4 a_color;
varying vec4 v_color;
uniform mat4 u_clipMat;
void main()
{
v_color = a_color;
gl_PointSize = 64.0;
gl_Position = u_clipMat * a_position;
}

varying vec4 v_color;
uniform sampler2D u_texture;
void main()
{
gl_FragColor = texture2D(u_texture, gl_PointCoord) * v_color;
}



I have seriously been at this for hours. I've also tried different textures (32-bit RGBA textures that are used with 3D models), and I keep getting the same results. It seems that if I set texture2D to a specific vec2() coord, and multiply it by v_color, I'll get the same results if I have gl_PointCoord mentioned ANYWHERE in the shader at all. I could even declare a vec2 that I don't even use anywhere in the shader to gl_PointCoord, and it'd still yield the results in the screenshot unless I remove it. Once removed, it'll render the 1 texel from my texture multiplied by v_color with no discoloration. Also, if I set gl_FragColor to texture2D(u_texture, gl_PointCoord), and not multiply it by v_color, sometimes I get a textured point with no discoloration. Also, I can set gl_FragColor.a to the alpha in my texture, then set red, green, and blue to some random literal in the shader directly, but as soon as I start setting gl_FragColor's components to v_color at all, then I get the same discoloration shown at the bottom. Also, if I just set gl_FragColor to v_color, and do not mention gl_PointCoord AT ALL, I get the solid v_color with no discoloration.

Edited by Vincent_M

• 17
• 11
• 12
• 9
• 49
• ### Forum Statistics

• Total Topics
631394
• Total Posts
2999755
×