View Full Version : Dark Texture Mapping

04-15-2001, 06:29 PM

I have been working on a simple 3d game with a team of programmers. One of them has written our texture mapping methods using the tutorials found at NeHe. When we actuall run the game the textures seem to reset color values so everything gets darker. I have lighting turned off as well as material properties. I noticed that there was a post a while ago with the same problem but the solution is not immediately clear to me. Would we need to be using GL_REPLACE instead of GL_MODULATE in the texturing code. If you need to see code let me know.

Thanks for the help.

04-15-2001, 09:23 PM
Here's the deal-

If you have a texture defined with GL_MODULATE, it will blend with the material color. This has the effect of dimming down the texture if you use anything other than White as your material. If you have lights then the texture will appear to be lit due to the modulation with the material which gets shaded by the light source.

If you use White materials at all times, or make sure that you don't have the color set to anything other than white when you render your texture, and you don't have lights, then it should not dim one bit, but you probably would be better off if you don't need lighting to go with a GL_REPLACE. GL_DECAL is fine if your texture doesn't have any transparent areas, if it does, you will see through to the material color.

Check your code, you may find a glColor somewhere that is setting the Color. Since OpenGL is a State machine, that color will persist until you change it.

04-16-2001, 06:39 AM
The problem is not with the texture becoming dimmer. It always looks correct. The problem is for example if all of my other polygons are white they become the backgroud color of the texture map.

For example I am drawing a jeep object for my game. It has several textured polygons and several colored polygons. If I set all of the colors of the polygon to white they become the green of the jeep. If I set them to another color they become a shade of the green. The lighting is disabled so I know it is not that, and I have checked and I am setting the color right before I draw the polygons. Everything looks normal when I disable texturing, but if it is enabled it dims everything other than the texture. I wonder if it is something in my hardware.

04-16-2001, 06:43 PM
I have found the problem. On NeHe's site it doesn't mention that everytime you want to do a texture map you need to enable it before that polygon and then disable it after that polygon. We were enabling it before we drew all the polygons and this was giving us wierd results.

04-16-2001, 06:47 PM
As a performance note, it would be more efficient to enable texturing once and then draw all the textured polygons, then disable it and draw the untextured ones.

04-16-2001, 07:14 PM
Thanks for the note. I was curious about other ways to speed it up as well. The problem with doing that is we have created objects for each enemy and obstacle in our game. So we just created a draw function for each of them and we have no knowledge of the other objects in the field. Would it still be faster to create two draw functions, one for textures on the object and one without and run through two for loops. http://www.opengl.org/discussion_boards/ubb/smile.gif