-
Shader - Using gl_LightModel.ambient => no alpha (transparency)
Hello,
I'm trying to replicate fixed functionality for directional lighting in a fragment shader.
My opengl code uses glColor and glColorMaterial.
I have some double sided transparent faces (same color on the 2 sides).
It works well except when using gl_LightModel.ambient : in this case "transparent" faces are almost entirely opaque or opaque.
Here is the ambient calculation (fragment shader) :
vec4 Iamb = gl_LightModel.ambient * gl_FrontMaterial.ambient + gl_LightSource[0].ambient * gl_FrontMaterial.ambient;
I have found this post http://www.opengl.org/discussion_boa...=1#post1163265 :
the alpha component in the fixed function pipeline always comes from the diffuse part of the primary color's lighting calculation (OpenGL 2.1 spec chapter 2.14 page 63)
So I added this in my code : Iamb.a = gl_FrontMaterial.diffuse.a;
And it works well.
I have also tried to add this at the end : gl_FragColor.a = gl_FrontMaterial.diffuse.a;
I gives another "good" result. (not the same as previously - the specular light is different not the transparency)
How to compute the alpha component to have the correct result (same as with the fixed functions) ?
Thanks.
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