View Full Version : Shaders, Fog and Multipasses rendering

09-29-2004, 01:45 PM
I am making a terrain demo.
I render the terrain in 6 passes (for 6 textures).
The first pass draw texture 1.
The other passes draw texture 2-6 over the previous one using blend func (one, one).

I use a vertex and a pixel shader to blend my terrain textures..

But my problem is that I dont know how make the fog working when there are multiple rendering pass and blend (one, one).

Please help if you have any idea ?? may be adding a 7th pass for the fog but I dont know how it is possible..

(PS: My fog work well when I render all the 6 textures in one pass in a vertex/pixel shader)

09-29-2004, 06:36 PM
You'll have to use a pass just to do fog.

09-29-2004, 07:44 PM
Have you tried just enabling Fog for your first pass (or perhaps for your last pass)?

09-29-2004, 10:15 PM
It works now.
I used glBlendFunc(GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA) and I write the fog color and alpha in the pixelshader.

I cant enable for just for the first or last patch since the passes are blended together.

09-30-2004, 09:35 AM
The point is you add an *extra* pass at the end. With GL_ONE, GL_ONE blend fog cannot work unless your fog color is black.