Fog problem

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
gogo
Posts: 65
Joined: Tue Apr 15, 2008 1:04 am

Fog problem

Post by gogo »

This is fog effect test. I set fog over nodes, and succeeded. But look at ground and background. Background must be hided by the fog according to natural rule, too. Only nodes were being hided and oddly rendered white.
I would like the effect that nodes disappear into the fog and appear from the fog naturally. Can I do so? How likely?

1-near
Image
2-distant
Image
3-far more distant
Image
Last edited by gogo on Fri Jul 18, 2008 11:41 pm, edited 1 time in total.
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

You need to apply fog to all the nodes which you want fog to affect... so your terrain there should have fog applied. the fog on the characters does look a bit strange though...
Image Image Image
gogo
Posts: 65
Joined: Tue Apr 15, 2008 1:04 am

Q

Post by gogo »

Hi, JP.
Indeed fog can be applied to a normal mesh.

Code: Select all

mesh->setMaterialFlag(EMF_FOG_ENABLE, true);	
However ITerrainSceneNode does not have "setMaterialFlag", so fog cannot be applied about terrain.
My code to create terrain is:

Code: Select all

ITerrainSceneNode* terrain = smgr->addTerrainSceneNode( 
		"terrain.bmp",
		0,										// parent node
		-1,										// node id
		vector3df(-400.f, 0.f, -400.f),			// position
		vector3df(0.f, 0.f, 0.f),			// rotation
		vector3df(4.f, 0.1f, 4.f),		// scale
		SColor ( 255, 255, 255, 255 ),	// vertexColor,
		5,										// maxLOD
		ETPS_17,							// patchSize
		4										// smoothFactor
		);
	terrain->setMaterialTexture(0, driver->getTexture("terrain_texture.bmp"));
	terrain->setMaterialType(EMT_DETAIL_MAP);
	terrain->setMaterialFlag(EMF_LIGHTING, false);
That is the reason why I am at a loss.
Last edited by gogo on Fri Jul 18, 2008 2:42 pm, edited 1 time in total.
Xplod
Posts: 32
Joined: Sat Mar 29, 2008 5:48 pm
Contact:

Post by Xplod »

What shadows have to do with terrains ?

To enable fog on your nodes, just do node->setMaterialFlag(EMF_FOG_ENABLE, true); (or EMF_FOG_ENABLED, I don't remember exactly).


Edit : Sorry, I just saw your edit.

So, do something like :

Code: Select all


for (i = 0; i < node->getMaterialCount(); i++)
{
node->getMaterial(i).FogEnabled = true;
}

Or something like that, I'm not at home so I can't check.
I'm Ouverta on the chat |
Project leader/Lead Developer of Ouverta project.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: Q

Post by hybrid »

gogo wrote: However ITerrainSceneNode does not have "setMaterialFlag", so fog cannot be applied about terrain.

Code: Select all

terrain->setMaterialFlag(EMF_LIGHTING, false);
Ehh, what now? Of course terrain has the setMaterialFlag, because it's an ISceneNode...
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

He's even using setMaterialFlag in the code he posted :lol:
Image Image Image
gogo
Posts: 65
Joined: Tue Apr 15, 2008 1:04 am

Uh, oh

Post by gogo »

Ah, oh. I was misundrstanding so much. It is right what you say.
I was able to accomplish my objective. Now I'm thinking how to make the fog itself. Advise plz.
Image
Image
Image
Image
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Now it just looks like your skybox isn't affected by the fog, which it just isn't because that doesn't make much sense. The skybox is your horizon and if you've got thick fog going off into the distance you won't see the horizon so you can just get rid of your skybox and change the colour in driver->beginScene() to the colour of you fog.

Your tree leaves also don't seem to be getting fog, not sure why that would be though, unless they're a different node to the trunk?
Image Image Image
Post Reply