Trying to get ambience on purely transparent polygons

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
CuteAlien
Admin
Posts: 9670
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Trying to get ambience on purely transparent polygons

Post by CuteAlien »

Not sure if this is possible, because i failed so far doing it, but maybe someone has an idea:
I have a model with material type EMT_TRANSPARENT_ALPHA_CHANNEL. My textures have pixels where the r,g,b compontent is set to 0, so only the alpha component should be used. I'd like it to be shown with the color of the current ambient light, but slightly transparent (depending on the value of the alpha channel). Transparence itself does worked and so did ambience on non-transparent areas, but i couldn't get it to use the ambient color at transparent positions. Has someone of you done something similar already and can help me?
Baal Cadar
Posts: 377
Joined: Fri Oct 28, 2005 10:28 am
Contact:

Post by Baal Cadar »

Well, actually this should work with EMT_TRANSPARENT_ALPHA_CHANNEL, Material ambient set to white and the texture set to all white instead of all black.

Else this can be done easily with a pixel shader.
For instance GLSL (from the top of my head, might contain errors):

Code: Select all

uniform sampler2D alpha_tex;
void main()
{
    vec4 t = texture2D(alpha_tex, gl_TexCoord[0].st);
    gl_FragColor.rgb = gl_LightModel.ambient.rgb;
    gl_FragColor.a = t.a
}
Maybe I don't just understand you correctly. Provide pictures for what you want and what you get instead.
CuteAlien
Admin
Posts: 9670
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Thanks, that worked. I checked my code after that again and found out that my ambience colors where inverted when loading the .obj file and it does work now also in my code :)
hybrid

Post by hybrid »

Yes, obj files have inverted colors. Use my objmtl.patch to fix this problem.
CuteAlien
Admin
Posts: 9670
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

hybrid wrote:Yes, obj files have inverted colors. Use my objmtl.patch to fix this problem.
Hm, i've posted to that already in the other thread ;). Somehowthe patch works for me only if i remove the part where the colors are inverted.
hybrid

Post by hybrid »

:lol: Oh, it was you :lol:
Ok, so maybe I have to change it then, and check if my example models were wrong?!
Post Reply