PDA

View Full Version : Shaders, Fog and Multipasses rendering



Bumper
09-29-2004, 02: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)

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

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

Bumper
09-29-2004, 11: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.

dorbie
09-30-2004, 10: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.