Page 1 of 1

Fog creation

Posted: Tue Dec 21, 2004 11:43 am
by databandit
hi,
can someone please give me some fog creation source code . . .
thanks


-zubair-

Posted: Tue Dec 21, 2004 6:48 pm
by bal
driver->setFog(...);

is enough, of course with the appropriated parameters (http://irrlicht.sourceforge.net/docu/cl ... r.html#a33)

Posted: Thu Dec 23, 2004 7:27 pm
by Dogs
YourNode->setMaterialFlag(EMF_FOG_ENABLE,true);
driver->setFog(SColor(0,30,30,30),true, 0,1300);
driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true);

Try something like this.. :)

Posted: Fri Dec 24, 2004 12:18 am
by RayOfAsh
Dogs wrote:YourNode->setMaterialFlag(EMF_FOG_ENABLE,true);
driver->setFog(SColor(0,30,30,30),true, 0,1300);
driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true);

Try something like this.. :)
Ok, sorry to jump in on this. I tried that and it crashed:

Code: Select all

// Fog
	irr::scene::IAnimatedMeshSceneNode* nodeFog; //Sets its node.
	nodeFog->setMaterialFlag(EMF_FOG_ENABLE,true); 
	driver->setFog(SColor(0,30,30,30),true, 0,1300); 
	driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true); 

No errors or anything, just, CRASH!

Posted: Fri Dec 24, 2004 12:55 pm
by Dogs
Well you dont nead to create a fognode but rather add the fog to a node that you have allready...

For example when I add fog to my levels I chose something like my terrian or if its an inside level i chose the building and attach the fog to that node..
For example lets say I used a bsp for my level... the code is below..



//load bsp level//

device->getFileSystem()->addZipFileArchive("../../media/whatever.pk3");

scene::IAnimatedMesh* mesh = smgr->getMesh("../../media/whatever.bsp");
scene::ISceneNode* node = 0;


if (mesh)
node = smgr->addOctTreeSceneNode(mesh->getMesh(0));

// fog // Apply this to the node you want fog ///

node->setMaterialFlag(EMF_FOG_ENABLE,true);
driver->setFog(SColor(0,30,30,30),true, 0,1300);
driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true);


I dont know the rest of your code but there could be reasons like where you placed this code that would also cause crashes....

Posted: Wed Dec 29, 2004 7:12 pm
by Dogs
I was just browsing around and read over my post here and just saw that i made a mistake in my code..
Well its really not a mistake but could cause problems for sure..


driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true);


This line here enables 32 bit textures and if this line is placed improperly in your code then it can cause crashes yes...

But I always use this line to enable 32 bit textuers as they look much much better...
Try it with your skyboxes... :)

Posted: Wed Feb 16, 2005 5:56 am
by Hijacker
Dogs wrote: node->setMaterialFlag(EMF_FOG_ENABLE,true);
driver->setFog(SColor(0,30,30,30),true, 0,1300);
driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true);
I`ve done something like that on my own. Result: NO FOG :(
Than I found this topic and use your code(adapted to my source)
The result is NO FOG!!!
The other code is just for application creation and loading 3ds model.
Could anybody explain that?

Posted: Thu Feb 17, 2005 3:06 pm
by deprecated
Using Linux, OpenGL, I have a similar problem...

Whenever I turn on fog, it only gets applied to the ground, basically as a % opacity of the chosen color.

So, in other words, everytime I turn fog on, the ground will turn grey (at 100% or so)

Used the examples on the forum with no luck... Can fog be used with heightmaps or just bsp and such? (which I dont use / havent tried...)

Anyone else have similar problems?