Trying to add some fog, No effect

Started by
5 comments, last by Gorax 18 years, 10 months ago
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){} };
Advertisement
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)
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?
Here you'll find a simple example of fog in OpenGL.
Sweet, got it up and running... still not quite sure what I was doing wrong. code looks alot like what I had.

Thanks
just a friendly tip: make sure you construct your CFOG object within a valid and active OpenGL context..
"I am a donut! Ask not how many tris/batch, but rather how many batches/frame!" -- Matthias Wloka & Richard Huddy, (GDC, DirectX 9 Performance)

http://www.silvermace.com/ -- My personal website
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. ;)

This topic is closed to new replies.

Advertisement