What does setting the GL color do before performing the texture mapping operation?

I look at some example code in a book that creates the effect of smoothing jitter, repeatedly rendering the scene (at different offsets) on an off-screen texture, then using this texture to repeatedly draw a quad in the main view with some mixture of the material created.

To accumulate the color "correctly", the code sets the color as follows:

glColor4f(f, f, f, 1);

where f is 1.0/number_of_samplesand then binds the external texture and its rendering.

Since textures come with their own color and alpha data, what is the effect (mathematically and intuitively) that allows you to pre-set the overall “color”?

Thank.

+3
source share
1 answer

The default texture environment is GL_MODULATE, which means that the vertex color (specified with glColor) is multiplied by the texture color.

So mathematically this does:

fragmentColor = texColor / numberOfSamples (alpha = 1.0)

Hope this explains.

+5
source

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


All Articles