PDA

View Full Version : strange lighting ...not in original texture



06-30-2003, 10:30 AM
Is there any reason why a texture copied using glCopyTexImage would automatically appear with what look like specular highlights, even though the original image to be copied had no such lighting? How can I override this lighting. It seems that when i say:

GLfloat ambientLight[] = {1.0f, 1.0f, 1.0f, 1.0f};

and later,
glEnable(GL_LIGHTING);
glLightfv(GL_LIGHT1, GL_AMBIENT, ambientLight);
glEnable(GL_LIGHT1);

It still has no effect on the automatic lighting (that I'm trying to avoid). Any help would be appreciated! Thanks.

errno
06-30-2003, 10:28 PM
you try to copy texture without lighting effect, why don't you disable lighting ???
assuming you have good reasons to do that, to avoid specular effects on the rendered entity, you can simply change the its material:
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, black);
if you want to avoid also diffuse lighting add:
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, black);
of course black is:
float black[4]={0.0, 0.0, 0.0, 0.0};

you can also tune lighting parameters to disable specular effect but i think it is easier to change material.

just a question, in your post, your code talk about GL_LIGHT1. does your GL_LIGHT0 is enabled ??? if so, maybe your problem come from that.

automatic lighting ??? there is no automatic lighting in opengl.

Relic
07-01-2003, 01:01 AM
Texture defualt environment is set to GL_MODULATE, primary colors (the lit geometry) modulate the texture color.
To disable lighting effects on textured geometry either disable lighting and set all colors to white (faster) or set texture environment to GL_DECAL (simpler).

Yoyo, when using alpha with lighting the alpha value is taken from the diffuse material. To avoid headaches black should be set as (0, 0, 0, 1) or you might get transparent geometry.

errno
07-01-2003, 04:08 AM
the alpha come from diffuse material, only diffuse material ???
so we can't make an object transparent where specular hightlight is ...

07-01-2003, 10:59 AM
Thanks for all of your responses. Unfortunately, even if I go through and individually diable(GL_LIGHTi) (for i 0 to 7), the instant that I enable just one light source, say ambient, defined to be the brightest possible, such that

GLfloat ambient[] = {1,1,1,1};

the gray/bright splotches return! I've tried a few different things with my code, and i'm beginning to think that the weirdness has to do with the way i'm copying my Texture Image and then expecting it to show up mapped onto my rectangle. For instance, if my background consists of just white vertical lines, my copied image will appear to have a repeating pattern of say, two vertical white lines with the appropriate (and expected) brightness and then there will be say two gray ones, and then two even darker than those. If the Rectangle is small enough that the lines are forced to repeat themselves, then i'll get a continous pattern of miscolored lines. Does this make sense and does it seem like something could be wrong with the way I set my viewport before and after I copy?

My code here says:

glViewport(0,0,256,256);
glCopyTexImage2D(GL_TEXTURE_2D,0, GL_RGBA8, 0, 0, 256, 256);
glViewport(x, y, 640, 480);

Thanks!

07-01-2003, 11:03 AM
P.S..I did try calling
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, black) and glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, black). And, I also tried setting the texture environment from GL_MODULATE to both GL_DECAL and GL_REPLACE. Neither of these seemed to help my problem.

Relic
07-02-2003, 12:08 AM
Originally posted by yoyo:
the alpha come from diffuse material, only diffuse material ???
so we can't make an object transparent where specular hightlight is ...

You can. The alpha values at places where a specular highlight also gets the diffuse alpha (read the spec chapter 2.13.1 Lighting).

harsman
07-02-2003, 01:17 AM
A screenshot (or even better an exe) would be helpful. I'm not sure what you're describing is specular highlights.

errno
07-02-2003, 02:53 AM
that is not the main topic of the thread. i don't try to obtain this effect. i just say that because it went on my mind.
maybe i don't understand well the specification but if alpha is shared between diffuse and specular componments, you can't make an object transparent ONLY where the specular spot is.
am i wrong ???