I am trying to achieve additive blending with point sprites. When the sprites overlap, all I get is solid red, when I expect to get a smooth blend from red->yellow->white. My sprite texture has all four channels set equal, with portions being white and others transparent.
I set up blending as such:
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE);
My fragment shader is as follows:
vec4 texCol = texture(pointsprite, gl_PointCoord);
colorOut = vec4(texCol.rgb * vec4(ocolor, 1.0).rgb, texCol.a);
Where pointsprite
is a sampler2D and ocolor
is `(1.0, 0.0, 0.0)
My background is cleared as
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
I have tried some of the various methods suggested in this question, none offering any results. I can verify my alpha channel is correctly loaded from my image into my texture.
EDIT: Missed mentioning that my intention is for clusters of point sprites with the same pigment (red) to additive blend to yellow and white.
GL_ONE
doesn't say to swap the color channels. You would need to experiment with GL_SRC_COLOR but it will probably be difficult to get the effect you want. Unfortunately fragment shaders don't make it easy to access previously rendered fragments -- except via framebuffer. \$\endgroup\$