Fog reversed

Jack000

05-03-2010 05:50:57

Hi guys

I tried to make some fog with:
mCaelumSystem->setManageSceneFog(true);
mCaelumSystem->setSceneFogDensityMultiplier(0.008f);


but it seems that the fog is reversed:


any idea how to fix this? I'm using ogre 1.7 from svn and the new terrain system.

also, the sun is too bright by default, so I made my own sun:
Caelum::SpriteSun* sun = new Caelum::SpriteSun(mSceneMgr,mSceneMgr->getRootSceneNode());

sun->setBodyColour (Ogre::ColourValue(1, 1, 1, 1));
sun->setSpecularMultiplier(Ogre::ColourValue(.2, .2, .2, 1));
sun->setLightColour(Ogre::ColourValue(1, 1, 1, 1));

sun->getMainLight()->setCastShadows(true);

mCaelumSystem->setSun(sun);


but now the sun is too dim... even when I set all the colours to (1,1,1,1)

thanks for any tips!

Jack000

05-03-2010 06:18:50

oh, and I think this has something to do with the new terrain system. All my other loaded meshes display fog correctly, it's only reversed for the terrain..

I tried initializing caelum before and after the terrain code, but it made no difference.

HookerBoots

18-01-2011 15:43:50

did you ever find a solution for this? I ask because I'm having the same issue.

*EDIT*
Nevermind, I ended up changing the FOG_EXP2 in caelum to FOG_LINEAR, and it works. Though not sure about the density part,
kinda didn't test with any density to it, but I digress.
*END EDIT*

monah

18-02-2011 20:09:48

I have the same problem. Who knows how to fix this error?

tdev

22-03-2011 08:44:08

did you ever find a solution for this? I ask because I'm having the same issue.

*EDIT*
Nevermind, I ended up changing the FOG_EXP2 in caelum to FOG_LINEAR, and it works. Though not sure about the density part,
kinda didn't test with any density to it, but I digress.
*END EDIT*

merged that into the latest version

cdleonard

22-03-2011 19:02:08

did you ever find a solution for this? I ask because I'm having the same issue.

*EDIT*
Nevermind, I ended up changing the FOG_EXP2 in caelum to FOG_LINEAR, and it works. Though not sure about the density part,
kinda didn't test with any density to it, but I digress.
*END EDIT*

merged that into the latest version

I don't think this fix is correct.

First of all the look of this fixed-function fog setting can vary based on scene materials. If it works better in your scene with fog set to FOG_LINEAR than FOG_EXP2 I think it would be better to just setManageSceneFog(false) and manage fog on your own. This way you get full control.

If you want to change the value set by CaelumSystem to FOG_LINEAR you should at least provide a fog mode property so the old behavior can be restored if so desired. Arguably the old behavior should be the default unless a changelog notice is provided somewhere.

Right now setManageSceneFog(true) is documented to use FOG_EXP2 so the patch contradicts documentation. If somebody upgrades he will see the same scene is rendered differently for no apparent reason. This might make people scratch their heads angrily. I used to have a lot of problem with that.

Other than this it's great to see somebody pick this up again!

tdev

22-03-2011 19:19:32

did you ever find a solution for this? I ask because I'm having the same issue.

*EDIT*
Nevermind, I ended up changing the FOG_EXP2 in caelum to FOG_LINEAR, and it works. Though not sure about the density part,
kinda didn't test with any density to it, but I digress.
*END EDIT*

merged that into the latest version

I don't think this fix is correct.

First of all the look of this fixed-function fog setting can vary based on scene materials. If it works better in your scene with fog set to FOG_LINEAR than FOG_EXP2 I think it would be better to just setManageSceneFog(false) and manage fog on your own. This way you get full control.

If you want to change the value set by CaelumSystem to FOG_LINEAR you should at least provide a fog mode property so the old behavior can be restored if so desired. Arguably the old behavior should be the default unless a changelog notice is provided somewhere.

Right now setManageSceneFog(true) is documented to use FOG_EXP2 so the patch contradicts documentation. If somebody upgrades he will see the same scene is rendered differently for no apparent reason. This might make people scratch their heads angrily. I used to have a lot of problem with that.

Other than this it's great to see somebody pick this up again!

thanks for the feedback, will revert :)

tdev

23-03-2011 08:19:10

so, i improved the caelum fog capabilties a bit (http://code.google.com/p/caelum/source/ ... 7430eb739#)

the problem i have now is that the linear fog seems to blend nicely over everything except the new terrain :-\
[attachment=1]screenshot_1.jpg[/attachment]
with code:

Real farclip = mCamera->getFarClipDistance();
mCaelumSystem->setManageSceneFog(Ogre::FOG_LINEAR);
mCaelumSystem->setManageSceneFogStart(farclip * 0.7f);
mCaelumSystem->setManageSceneFogEnd(farclip * 0.9f);


in non-caelum mode the linear fog works well:
[attachment=0]screenshot_2.jpg[/attachment]

so im wondering what the problem could be. Also notice the weird color change where the fog should be in picture 1 ... :\

tdev

23-03-2011 14:21:59

fixed it myself. advice to others:

1) make sure fog is initialized _before_ loading any terrain (as the terrain might choose different shaders depending on those settings)
2) make sure you initiate the correct mode before loading any terrain
3) after loading a caelum script you should update the sub-components once before loading any terrain

improved caelum so that upon setManageSceneFog() the correct mode is set immediately.