PDA

View Full Version : OpenGL : Clipping GL_FOG to a region...



savage
31-08-2008, 11:26 PM
Hi all,
Does anyone out there have a simple demo that shows how to clip GL_FOG to a rectangular region? Or point me in the right direction.

Thanks.

waran
01-09-2008, 02:32 PM
You could create a stencil mask revealing the "clipped" area.

Then you render two times, with and without FOG using the correct
stecil mode.

savage
02-09-2008, 08:27 AM
Thanks for the reply.

Unfortunately I just realised that the problem is actually the difference between DirectX and OpenGL near/far values.

Do you, or anyone else, know how to convert from DirectX near/far fog values to OpenGL start/end values?

Luuk van Venrooij
02-09-2008, 08:56 PM
The calculations for fog in D3D and OGL are exactly the same when it comes to the fixed function pipeline. I use the exact same values for both the d3d and ogl at work.

savage
04-09-2008, 11:26 PM
Do the same values for for LINEAR FOG? Do you have to set things up differently in OpengL compared to Direct3D? In the Mac Port I'm working on, the D3D values just don't look right on the Mac.

How do you hanlde Fog Density across both APIs then?