Advertisement

Tutorial 22 + fog

Started by December 28, 2002 01:05 PM
20 comments, last by C Lund 22 years, 2 months ago
JonoX wrote:

"i have no problems in adding the fog tut to the bumpmap one. looks fine! make shore your fog color and your glClearColor() are the same."

They are! And the fog looks fine when the bumpmapping is turned off. It''s only when the bumps are turned on that things go bad.

"make shore everything has the same values a the tuts inclueding the same objects. i noticed you have changed the object so the problem might be there some were??"

Possible I guess, but not likely. The first change I made was fog, and even then it wouldn''t work properly. I''d be interested in seeing how you implemented the fog.

C Lund
C Lund
you can dl my source at
http://blueboy.htmlplanet.com. you will need the textures in the data direcory from lesson 22 for it to work. unfortunetaly i could not upload it all in a zip.
hope this helps.


- Jono AH
- JonoRule #1: If you build it, they will come -- to hack and cheat.
Advertisement
JonoX wrote:

"you can dl my source at
http://blueboy.htmlplanet.com. you will need the textures in the data direcory from lesson 22 for it to work."

I have my own tetxtures. All I wanted was to see how the fog was implemented. I''ve downloaded the code now. Thanks.

"hope this helps."

So do I. I''ll report back when I''ve had a chance to try it out. Again, thanks.

C Lund
C Lund
JonoX: I''ve looked at your code now. Afaik you''ve done the exact same thing I''ve done - as far as the fog is concerned. But I''ve noticed two things about your code: The fog is a neutral grey and the density is only 0.15. At those settings the fog looks just fine in my app too.

Could you try running your code with:

GLfloat fogColor[4]= {0.3f, 0.5f, 0.7f, 1.0f};
glFogf(GL_FOG_DENSITY, 1.00f);

- and then see what happens? BTW: The fog seems to work better with multitexturing on.

I wonder if this: GLfloat Gray[] = { 0.5f, 0.5f, 0.5f, 1.0f }; might have something to do with the problem...

C Lund
C Lund
Just do the fog in another pass... On another note, why are you people using emboss? It''s obsolete...

Death of one is a tragedy, death of a million is just a statistic.
If at first you don't succeed, redefine success.
I tried posting this already, but the server seems to have choked on it. So now you know why there might be two of this article..

python_regious wrote:

"Just do the fog in another pass..."

Being a newbie, I ask: How does one do that? Run through all the polies yet another time?

" On another note, why are you people using emboss? It''s obsolete..."

Are you referring to dot3? I intend to look at that later. But my initial objections to it is that it seems to make everything look like brushed steel with a faint tint of color (too shiny iow), and that it needs a third texture (the purple/cyan one). How does one make that texture?

C Lund
C Lund
Advertisement
you do 2 passes to draw the embross bumpmapping, right? that means your data gets.. added if i remember correctly (glBlendFunc(GL_ONE,GL_ONE)) and each pass you do fog => you get 2 fogs added together (and the colors, wich should get combined by the blending equation gets first manipulated by the fogequation and are not useable anymore for the blending => the embross fucks up)

if you use multitexturing, and only need 1 pass, it all will work okay. if you _CANT_, you have to fog _AFTER_ you have evaluated your equation. that means first draw the whole thing, and then, yes, draw the fog over the scene == draw the whole geometry again, this time linear interpolation, like that: glBlendFunc(GL_ONE,GL_ONE_MINUS_SRC_COLOR);

and then you get what you want..


all you do is math. quite complicated sometimes, till you get trained on whats going on actually..

fog(a) + fog(b) != fog(a+b)..

you want the second one, but you have the first one.. so you have to add first (blendfunc(one,one)), and then mix it with the fog in an additional pass..

i hope it helps..

"take a look around" - limp bizkit
www.google.com
If that's not the help you're after then you're going to have to explain the problem better than what you have. - joanusdmentia

My Page davepermen.net | My Music on Bandcamp and on Soundcloud

yes. i see the problem now.
the fog is 'drawn' by blending the fog colour with whaterver is being drawn.
So when is the corect time to draw the fog?? well not when the first bumpmap is drawn and certanly not the second time it is drawn. but if its drawn when the texture is been embosed by the bumpmaps the fog will endup being embosed to!

python_regious is right. the fog should be done in another pass.

so how do you fog in another pass?? got me.

what realy needs to be done is to emboss the texture separetly and then apply it to the object with fog enabled. that is.. build the emboss map and blend it with the base texture in _an_off_screen_buffer_ then make a texture from that and use it to draw the object!

what is done in tut22 is a hack and dose not work with fog.

so how dose one render an embosed/bumped texture to an off screen buffer and use it as a texture? (theres an idea for a tutorial NeHe.. cant wait to see you try and explane it! sorry just sliped out.)
there is some info at http://developer.nvidia.com/view.asp?IO=gdc_oglrtt that should help lots in getting started. mabe you would use an ortho projection to emboss or something while looking straight at the texture then use it as a map?? maby it would be beter to use perspective and an enviroment map?? i really dont know. your on your own now and playing with the bigger boys!!! so how dose it feel?

ps. the fog density should not be 1.0 as this is 100% fog and you should not be able to see anything realy.


- Jono AH

[edited by - jonox on January 2, 2003 8:59:06 PM]
- JonoRule #1: If you build it, they will come -- to hack and cheat.
davepermen wrote:

"if you use multitexturing, and only need 1 pass, it all will work okay. if you _CANT_, you have to fog _AFTER_ you have evaluated your equation. that means first draw the whole thing, and then, yes, draw the fog over the scene == draw the whole geometry again, this time linear interpolation, like that: glBlendFunc(GL_ONE,GL_ONE_MINUS_SRC_COLOR);"

I''ve added the following pass:

glEnable( GL_FOG );
glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
glBindTexture( GL_TEXTURE_2D, texture[ filter ] );
glBlendFunc(GL_ONE,GL_ONE_MINUS_SRC_COLOR);
glEnable( GL_LIGHTING );
[self doPolyhedron]; //where the polys are drawn

This is a step in the right direction, but I''m not there yet. There is fog, but it''s washed out and doesn''t seem to care about fog density or the distance of the object from the camera. Apparently it just washes the textures with the fog color and that''s that.

On a slightly different note: Where can I find an explanation of the various glBlendFunc() calls - pref in layman''s terms?

C Lund
C Lund
JonoX wrote:

"what realy needs to be done is to emboss the texture separetly and then apply it to the object with fog enabled. that is.. build the emboss map and blend it with the base texture in _an_off_screen_buffer_ then make a texture from that and use it to draw the object!"

Sounds complicated, but maybe it isn''t. Perhaps it''s just time for me to start looking at dot3...

"ps. the fog density should not be 1.0 as this is 100% fog and you should not be able to see anything realy."

I know, but it helps show off what''s wrong with my app..

C Lund
C Lund

This topic is closed to new replies.

Advertisement