PDA

View Full Version : Lighting & blending



nk
05-22-2004, 12:16 AM
I have a scene where I draw some polygons against a black background with transparency and I use for this
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA)
Everything works fine, my polygons are transparent, but now I want to add and ligting to my scene:
glEnable(GL_COLOR_MATERIAL);
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT);

GLfloat lmodel_ambient[] = { 1, 1, 1 , 1 };
glLightModelfv(GL_LIGHT_MODEL_AMBIENT,lmodel_ambie nt);
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
glEnable(GL_LIGHTING);

At this point I loose all the transparency on objects. Why?
There is any possibility to have transparent object & light?

05-22-2004, 12:33 AM
You set ambient light to brightest white ??? Not the best way to have nice lighting :)

It is possible to have lighting and transparency, there should be not problems.

What color/texture do you specify for your objects ?

nk
05-22-2004, 07:30 AM
I use glColor4ub(128,128,230,128) and no textures(this will be a next step); also I generate normalized normals to polygons.
With model_ambient[] = { 1, 1, 1 , 1 } the polygons have exactly the same color as before(without lignting enabled) but the are not transparent anymore.
Any change into the light values turns the polygons color to the light color and also the transparency disappears(if i choose {1,0,0,1), the polygons became red).
I tried to change the values of the light but the polygons remains opaque. What is strange is that the polygons's color remain the same even if I use
glColor4ub(128,128,230,0). In this case in my opinion the polygons should not be visible.