PDA

View Full Version : fog in an orthographic projection



DJ Tricky S
08-25-2000, 11:32 AM
I have an app where I use a 3-D orthographic view which I want fogged linearly based on z, which ranges from 0.0 to 1.0. The code I have written works as desired on nVidia and Matrox hardware, but on 3dfx hardware everything in the scene is rendered as though it was fogged the maximum amount (ie, everything is flat grey), and on the ATI Rage128 there is no fogging at all. I feel it must be some error in how I have setup the orthographic projection. The viewing volume I want is w/ dimensions of width & height matching my window dimensions, and a depth range of 0.0 to 1.0 (near to far clip planes). So, I'm setting things up like this:

GLfloat fog_color[]= {0.75, 0.75, 0.75, 1.0};

glFogi(GL_FOG_MODE, GL_LINEAR);
glFogfv(GL_FOG_COLOR, fog_color);
glFogf(GL_FOG_START, 0.f);
glFogf(GL_FOG_END, 1.f);
glEnable(GL_FOG);

glViewport(0, 0, width, height);
glDepthRange(0.f, 1.f);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.f, width, height, 0.f, 0.f, 1.f)); // width & height are my window dimensions
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

... drawing code follows

As I said, this works as desired on everything I have tested it on other than ATI (Rage128 specifically) and 3dfx (Voodoo3 & Voodoo5 specifically). Any ideas what might be the problem here? Any suggestions apreciated!

Bob
08-26-2000, 01:54 AM
If it doesn't work on a few implementations (ATI's and 3Dfx's), then i think it's about the drivers. As far as I can see, you are not doing anything wrong, at least not in the piece of code you posted.

Try updated drivers or so.

Don't Disturb
08-26-2000, 12:10 PM
Yeah, GL_LINEAR fog goes funny for no reason sometimes, but its the drivers fault.
Experimenting with different minimum and maximum distances might get it working properly, don't know why.

foobar
08-28-2000, 01:43 PM
I noticed on some 3Dfx cards that fog only works with face culling enabled and on the voodoo3 only works on the back faces!!! It worked on the first set of drivers failed on the second and messed up again on the third!!!