-
GLSL: why is alpha value modifying RGB??
Hi,
I want to use a texture as a 2D vec4 array, without alpha effects, but I'm running into this problem where the sampled R,G, and B values are modified by the alpha value:
// to test, all colors in the texture image are (1,0,0,0.5)
vec4 color = texture2D(texture0,coords.st);
// result: color = (0.5,0,0,0.5)
--------------------------------------
// all colors in the texture image are (0,1,0,0.75)
vec4 color = texture2D(texture0,coords.st);
// result: color = (0,0.75,0,0.75)
--------------------------------------
what I want is the result to be the same as what I set in the texture image, not with the R,G, and B values modified.
Anyone have any ideas?
-
Member
Regular Contributor
it's called blending and it is enabled by default. if you want pure output color while writing to alpha channel, you call glDisable(GL_BLEND); before rendering. and you call glEnable(GL_BLEND) if you want blending enabled again.
i think, you need to read some beginners OpenGL literature, it's not really an advanced question.
-
it makes no difference if i disable blending or not, the result is the same.
So if I disable blending and I still have the same issue is this still a beginner question?
-
Member
Regular Contributor
where does this texture come from? if it's color is mixed with black(or whatever was in the background) using alpha value, it must be you using it as a framebuffer attachment and rendering to it with blending enabled. alpha-blending happens when texture is being rendered to, not when you are sampling it. so the problem lies at the stage, where that particular texture is filled.
Last edited by Nowhere-01; 07-16-2013 at 11:30 AM.
-
Thanks Nowhere-01. I think maybe my problem has to do with premultiplication by alpha values possibly done in AWTTextureIO.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules