Sign in to follow this  
PaganX

Trying to add some fog, No effect

Recommended Posts

PaganX    128
I threw this together quickly to test out fog in my scene. I get no errors but I also get no effect. Its my understanding that when I CFOG Fog, it should automaticly set defaults and add the fog. Any ideas what I am doing wrong? PFNGLFOGCOORDFEXTPROC glFogCoordfEXT; class CFOG { public: float Density; float Range[2]; float Color[4]; int Type; bool bOn; CFOG(void) { glFogCoordfEXT= ( PFNGLFOGCOORDFEXTPROC )wglGetProcAddress( "glFogCoordfEXT" ); glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FOG_COORDINATE_EXT); Color[0] = 0.0f; Color[1] = 0.0f; Color[2] = 0.0f; Color[3] = 1.0f; Range[0] = 0.001f; Range[1] = 100.0f; Density = 1.0f; Type = GL_EXP2; glEnable(GL_FOG); glFogi(GL_FOG_MODE , Type); glFogfv(GL_FOG_COLOR, Color); glFogf(GL_FOG_DENSITY, Density); glFogf(GL_FOG_START , Range[0]); glFogf(GL_FOG_END , Range[1]); glHint(GL_FOG_HINT , GL_NICEST); MessageBox(NULL, "SetUp", "FOG", MB_OK); } ~CFOG(void){} };

Share this post


Link to post
Share on other sites
zedzeek    529
for each vertice u need top supply a fogcoord as well
personally i wouldnt recommend glFogCoordfEXT;
its useless
what r u trying to do standard fog doesnt need it (its more for volumetric fog + even then its fucked u have to have your scene reasonably tesselated + have to do all the math yourself)

Share this post


Link to post
Share on other sites
PaganX    128
I guess what I am going for is the most basic and easiest fog to set up. Rather new to OpenGl, I am not even sure of what options I have. What method would you suggest?

Share this post


Link to post
Share on other sites
PaganX    128
Sweet, got it up and running... still not quite sure what I was doing wrong. code looks alot like what I had.

Thanks

Share this post


Link to post
Share on other sites
Gorax    202
Quote:
Original post by zedzeek
for each vertice u need top supply a fogcoord as well
personally i wouldnt recommend glFogCoordfEXT;
its useless
what r u trying to do standard fog doesnt need it (its more for volumetric fog + even then its fucked u have to have your scene reasonably tesselated + have to do all the math yourself)


A few things:
- Try to learn English, it makes reading things a lot easier on us.
- Avoid swearing where possible.
- Yes, you have to do the math yourself, but unless you don't pay much attention, you'll miss the fact that you *can* use glFogCoordFEXT to do more than volumetric fog, but you'll also need a vertex shader.

I've personally used it in my heightmap test app for the effect of volumetric fog, but I also wanted to use it for making everything foggy when you were in the fog (so things don't look stupid). At first, I hard-coded it (immediate mode has its uses), then I implemented it again, modifying vertex arrays, but it was painfully slow (I was able to increase the number of points of the terrain I drew, so updating them took a lot longer). Finally I implemented a vertex shader to do the job of making things foggy. At first, it was simple, just accept the fog from the program and set the depth from that. I had a few issues working out how I was going to calculate the fog depth for each vertex while under the fog using the ARB vertex program language, but then I stumbled upon Cg and my problems were solved.

Finally, for basic fog that envelops everything, you'd be better off not using glFogCoordFEXT, since you can get the same effect without having to resort to using shaders. ;)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this