OpenGL: Does texture and plain color react differently to ambient light?

This is a pretty old problem that I encountered with the OpenGL application.

I have a rather complicated model, some polygons in it are not textured and painted using a simple color with glColor (), while others are textured. Some textures have the same color as non-textured polygons, and there should be no visible seam between them.

The problem is that when you turn on the external component of the light source, a seam appears between the two types of polygons.

see this image: http://www.shiny.co.il/shooshx/colorBug2.png

The left image is without ambient light, and the right image is with ambient light (0,2,0,2,0,2).

The RGB value for the color on the texture is identical to the RGB value of the color edges. Alpha textures are set everywhere 1.0.

To shade the texture, I use GL_MODULATE.

Can anyone think of a reason why this will happen and a possible solution?

+4
source share
1 answer

You note that you set the color with glColor() , so I assume GL_COLOR_MATERIAL on? What setting are you using for glColorMaterial() ? In this case, it must be GL_AMBIENT_AND_DIFFUSE , so calling glColor() affects the surrounding color as well as the diffuse color. (This is the default value.)

You can also try setting all the colors of the materials to white (with glMaterial() ) before displaying the edges drawn by the texture. With some settings (don’t remember which ones), the texture itself is modulated with the current color.

Hope this helps, or at least points to a useful direction.

+2
source

Source: https://habr.com/ru/post/1276906/


All Articles