View Full Version : Fog and texture probs? Anyone feel like testing this?

05-08-2001, 06:55 PM

I did a little screen saver afew people seem to be having problems that I can't work out. I wondered if anyone would know why, or has similar probs?

I've used black fog to fade objects off into the distance but I've got a guy with a geForce card saying that it isn't happening at all. I haven't got anything special, just turning on the fog before drawing the objects and turning it off afterwards.

And I've got another dude saying that the 2nd texture on the rings (the writing) isn't visible when he runs it with his Voodoo3. All I've done to draw the textures it blended them on with the GL_EUQAL depth test.

If anyone wants to try it out and let me know its available from:

Any ideas would be greatly appreciated.


05-08-2001, 07:10 PM
I just ran it on my ****-box work PC, and the fog is not working. The writing on the rings can be seen though...


05-08-2001, 07:10 PM
I just ran it on my ****-box work PC, and the fog is not working. The writing on the rings can be seen though...


05-08-2001, 07:16 PM

What kind of vid card has it got?

Anyone know why fog wouldn't work on some cards?

05-08-2001, 08:44 PM
Worked fine on my TNT using latest official driver release and Win98, AMD K6-III.

05-09-2001, 01:04 AM
Ran it on my Win98/GeForce2 GTS 64MB and it worked fine - although the fog had a hard boundary i.e. rings would pop into and out of view as though they passed the zFar boundary. Is that how it was supposed to look?

05-09-2001, 01:20 AM
Nope not at all. They dont disappear til they're beyond the darkest part of the fog... Yet they seem to on geforce cards??

How does it work on some cards and not others??

05-09-2001, 02:24 AM
No fog here too..,
GeForce 2 mx, 32 mb

Maybe driver problems ?

05-09-2001, 02:34 AM
Wierd as.

Ok, how would you guys with Geforce cards do fog?

05-10-2001, 05:22 AM
Hey... I've been using that screensaver for the last couple of weeks or so. I grabbed it off your site when they had the link to it on the main page here.

I've got a GeForce 256, and I haven't seen any fog effects. I've also run it on my computer at work (A wonderful Trident 3D card using the default MS implementation of OpenGL, woo hoo!), and on my laptop (Some crap chip by a company nobody has ever heard of.) I didn't notice fog on any of them. The writing seems to work on them all, though.

Post some code for how you setup your fogging parameters. It might help us figure out what's going on.

05-11-2001, 02:14 AM
I've had abit of feedback and it seems to work for TNT/TNT2 cards but not much else. (which is what I've got).

This worries me alittle tho, why would something standard like this work on one card and not another? Obviously somethings wrong, but to fix it may mean to break it on TNT2 cards??

Anyone with a geforce will to do a test of another version for me?

Thanks for the help so far.

05-11-2001, 02:24 AM
yeah, sure, post a link and i will test it.
Don't you wanna post the source where you setup your fog ?


05-11-2001, 02:31 AM
Sorry here it is:

GLfloat fogcolor[4] = {0.0, 0.0, 0.0, 1.0};
float FogDensity = 0.5f;

glFogfv(GL_FOG_COLOR, fogcolor);
glFogf(GL_FOG_DENSITY, FogDensity);
glFogf(GL_FOG_START, -85.0f);
glFogf(GL_FOG_END, -95.0f);

Then I just enable it. Any probs with that?

I changed the start and end to negative numbers because positive numbers didnt seem to do anything, altho I've always used positive numbers before (as far as I remember). But I suddenly thought that could be the problem? But if its gotta be positive, why doesnt that work on my TNT2 card?

I seem to be going in circles! http://www.opengl.org/discussion_boards/ubb/smile.gif

05-11-2001, 03:00 AM
I'd be guessing that negative FOG_START & FOG_END might be giving you the problems. I've never seen negative numbers for these before (maybe someone else has?). The red & blue books don't say you can't have negatives but sort of imply you can't - default values are 0 & 1 respectively anyway. Try a glGet for FOG_START and FOG_END after you set up the fog. I'd be interested to see the results. At a guess, they may be clamped to non-negative values in which case you'd get 0 for both and your linear fog equation would be (end - z)/(end - start) = -z/0 = not good!

BTW, your setting up of the fog isn't between glBegin()/glEnd() is it? Just eliminating the obvious http://www.opengl.org/discussion_boards/ubb/smile.gif

Anyway, great screensaver (besides the fog http://www.opengl.org/discussion_boards/ubb/smile.gif )

[This message has been edited by ffish (edited 05-11-2001).]

05-11-2001, 03:13 AM

As I said, I don't remember using negative numbers before, but positive numbers just dont seem to work for me, so I didn't notice anything wrong!

I've put a version up with positive numbers, and it doesn't work for me (and I hate it without the fog, it looks awful).

If anyone would like to try it out and let me know if it works for them its available here: http://www.UselessCreations.com/lotr/LOTR3Dtest.zip


And thanks!

05-11-2001, 04:14 AM
Ok, now I'm really confused:

Just playing round with this and it seems that the rings are not effected by + fog values, yet the writing that floatin around is only effected by + values. The opposite?!

And I changed the func that draw each ring to draw a triangle in the middle of the ring. Simple enuff. And the triangle IS effected by the + values, yet the rest of the ring isnt?

HELP! How/why does this happen?

If you can answer this I'll have your baby.


Please note: Thankfully, thats medically impossible.

05-11-2001, 04:46 AM
That one from 2 posts above works fine for me regarding the rings and fog. The writing, well, the writing is affected, but I don't know if it's by your fog. Sometimes when the rings are coming in from -z to +z, the rings fade in from the fog and it takes a while for the writing to appear, like it sounds it happens on your card.

_But_ sometimes the same effect happens when rings go from +z to -z and +y into the viewing frustum - it takes a while for the writing to appear. So I'm guessing that the fog is working fine but there is something slow about your texture binding? Maybe someone else will comment on how it looks on their machine.

Hope that helps.

05-11-2001, 06:19 AM
I'm at work at the moment so I can't test it on my GeForce 256, but the fog works on the default MS implementation of OpenGL now. Can't tell if the text is affected because it runs so slow that the text seems to get messed up (the movement is very jumpy and not nearly as smooth as when run on my GeForce at home), but it did that before too.

One other note, I think fog density is only use with the exponential fog formulas so using that in your code probably isn't having any effect.

05-11-2001, 06:22 AM
One more thought, what drivers are you using with your TNT2 card? It seems really strange that it would work with negative start/end values, but not positive.

05-11-2001, 01:25 PM
i wrote a demo recently ( not yet posted on my site, no time http://www.opengl.org/discussion_boards/ubb/smile.gif ) using the nv_fog_.. extension (i forget the name) anyway negative numbers are ok for the standard fog i believe they use a fabs(fog) to get the density.
about the problems , are u by chance doing any sort of blending.
i believe fog becomes before blending in the pixel pipeline, which can lead to unwanted effects

05-11-2001, 04:22 PM
The text should fade onto the rings as they fall. If thats whats happenin' then its working fine!

But I still dont geddit. I just downloaded n installed the latest driver from the nvidia website and I still get the same problem.

So I tried to think where I've used fog before. And I used it in UselessTelnet to make the text in the Star Wars scroller fade off into the distance. So I cranked it up to test it and it WORKS!

So it must be something to do with how I draw the rings? Which is just a call to DrawElements.. with some blending for the text etc. But as I said afew posts ago, if I draw a triangle in the middle of the ring it IS effected, but the rings themselfs arnt.

I'm confused!

05-12-2001, 01:24 AM
i gather then you're using blending for the text. what modes are u using, GL_ONE + fog is a nono unless your fog is colour (0,0,0,0) ie black. try that or try a different blending mode for your text eg GL_SRC_ALPHA

05-12-2001, 09:22 PM
Yup, already using that for blending. And that bit seems to work?

But I think I've fixed it, altho I'm not at all impressed with the fix cos it doesn't fix it it avoids it.

I rewrote the damn thing using display lists instead of glDrawElements and it seems to work fine!

Is anyone willing to test? Its up at: http://www.UselessCreations.com/lotr

I really, really, really want to know tho why when I draw using glDrawElements the fog only works using negative values? Now that I'm using display lists the positive values work fine!?!? And the frame rate is alot higher http://www.opengl.org/discussion_boards/ubb/smile.gif

Can anyone explain this?? Please??

Thanks alot!

05-12-2001, 10:17 PM
Fog, writing, everything working alright AFAIK. fps much better too.

05-13-2001, 04:34 PM
Thanks dude! Great stuff.

But whyyyyyyy? http://www.opengl.org/discussion_boards/ubb/smile.gif

05-13-2001, 06:20 PM
Can't say unless you give us all your code to play with http://www.opengl.org/discussion_boards/ubb/smile.gif I've never experienced problems with glDrawElements like that before.

05-14-2001, 03:26 AM
Well thats fair enuff. But I swear I'm not doing anything special. I'm filling arrays with data, then setting the pointers, and calling glDrawElements. Theres not much that can go wrong is there?

Specially that would cause wierd-ass fog value reversal!

Thanks for the help tho. Much appreciated!

05-14-2001, 03:45 AM
Dunno, maybe Matt or Cass will read this and have some tips for you.