Hey,
I’m writing fallback shaders for my game.
I am totally pulling my hair out on how to achieve fogging when rendering using multiple passes.
I use a simple blendmap shader. In CG, I just sample 3 different textures, and two blendmaps, and calculate the final color.
On fixed function pipeline hardware, I do this using 3 passes, where I use the hardware’s blending functionality to achieve the same result.
Works great!
But how to deal with fogging? Fogg every pass? Fog only the last pass? all options you have are “wrong”.
I’ve been trying to work out the craziest ways to get fog to work, and have reached a point where I can do the fogging, but only to black,grays white.
as a last “fogpass”, do this:
Pass {
Fog{
Mode Linear
Color [_FogColor]
Range [_GlobalFogStart], [_GlobalFogEnd]
}
Blend One OneMinusSrcColor
SetTexture [_NotATexture] {
ConstantColor (0,0,0,0)
Combine constant
}
}
This basically outputs black as a fragment, which gets fogged to a white/gray/black color (r=g=b). the result of the fogging operation gets blended:
grayfoggedfragment * 1 + (1-grayfoggedfragment) * whateverwasintheframebuffer.
Unfortunately, I see no way to make this work for colors where r=g=b is not true.
If only the fog operation would also fog the alpha channel, life would be so simple.
So now I’m looking at alternatives. A rendertesxture comes to mind. I am a bit reluctant to go there, but that might be prejudice. I want to support old hardware cards. Does anybody have any realworld experience using rendertextures in dx7 hardware land?
Does it work? Is it unusably slow?
Should I stop worrying?
My game does not have a lot of triangles on screen at the same time, so I can live with a performance hit. I cannot live with tons of people turning out not to have rendertextures after all, or them not really working in this or that circumstance.
On a sidenote: I cannot believe the internet is not full with people trying to figure out how to achieve correct fog while rendering multiple passes.
Hoping for somebody with a brilliant idea, or somebody who tried rendertextures in a real game before and got positive results on dx7 level hardware.
Thanks, Lucas