Question

I am looking at some sample code in a book that creates a jittered antialiasing effect by repeatedly rendering a scene (at different offsets) onto a offscreen texture, then using that texture to repeatedly draw a quad in the main view with some blend stuff set up.

To accumulate the color "correctly", the code is setting the color like so:

glColor4f(f, f, f, 1);

where f is 1.0/number_of_samples, and then binding the offscreen texture and rendering it.

Since textures come with their own color and alpha data, what is the effect (mathematically and intuitively) that setting the overall "color" in advance achieves?

Thanks.

Was it helpful?

Solution

The default texture environment is GL_MODULATE, this means that the vertex color (set with glColor) is multiplied with the texture color.

So, mathematically, it does:

fragmentColor = texColor / numberOfSamples (alpha = 1.0)

Hope that explains it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top