[Newbie] Colouring, Lighting, Texturing

Greetings again, and thanks for the help provided so far.

I come again with some questions, this time concerning interaction between colors, lights and texturing.

I’ve been piling up the various tutorials at NeHe on the framework of the one in the “how to get started with jogl” in this very forum, and so far it’s been fine. One problem I’ve found has come up when mixing textured and untextured polygons.

I made the colored pyramid and cube in the solid tutorial, and then decided to texture that same cube. At first, it would work but make the pyramid colored weird. So I thought of disabling the textures when the pyramid was being drawn and reenabling them for the cube, and it worked:

Then I did the lights and filters demo, which adds various filtered textures and, more importantly, lights, to the scene. This time, the trick of enabling and disabling hasn’t been enough. If lights are on, it will look like this:

I did put some normals on the pyramid faces to get that reaction to the light (not sure if they’re ok, probably wrong) otherwise it’d come out as if lights didn’t touch the pyramid, but when I disable the lights, the colors appear just fine (mind that this happens because, as I said, I disable textures when drawing the pyramid and reenable them for the cube):

So, I believe there is some interaction between the textures, the lights and the colors, but I haven’t been able to figure out a way to unbundle that. More importantly, I get the feeling that enable-disable isn’t good programming, but then again I’m new to all this, so the answer might just be in front of my eyes and I just can’t see. What do you make of it?

Thanks for your time in advance.

You probably need to use the function
glTexEnv() to control how the colors from
the lights are combined with the colors
from the texture.

[quote]You probably need to use the function
glTexEnv() to control how the colors from
the lights are combined with the colors
from the texture.
[/quote]
Thank you. I will look it up in the reference book (it’s too bad that the javadoc for jogl is still in embryo form, though it’s certainly of help sometimtes).

If you enable GL_COLOR_MATERIAL your vertex colors should work for the pyramid as well.

[quote]If you enable GL_COLOR_MATERIAL your vertex colors should work for the pyramid as well.
[/quote]
Thank you sir, once again you were most useful. That did the trick.

Guess next thing I’ll look into is how to texture triangles, just so that the poor thing doesn’t feel left out. ^^

Why not load models instead? That way it’ll be the artists problem :slight_smile:

Lot’s of free model resources on the internet too.
I have some classes to easily load/display models of various format if you’re interested.

It’s just that I’m still learning everything from scratch, so…I don’t even know what a model is. ^^;
It will probably come in handy for what I have to do, though. If it is not complicated, could you give me a brief explanation, or otherwise point me to one?

As an example of how I don’t know the way things work, after enabling GL_COLOR_MATERIAL, lights work and colors show up (if I understand correctly, the material is what determines how a surface reflects lights, and the constant above enables management of such a property in terms of fill color and not just textures?), but I notice the light is a lot brighter everywhere. My guess would be that the pyramid is reflecting light and diffusing it, but I notice that this light is brighter even on the other side of the cube (see image below), so this brightness increase is not directional. If the behaviour before enabling GL_COLOR_MATERIAL is to be considered the default, then I wonder what exactly causes this variation.

(this picture does have shadows, they just are less evident. Check the right face of the cube)