Page 1 of 1

[SOLVED] Transparency and fire

Posted: Mon Mar 06, 2006 6:46 pm
by Amt0571
Hello,

I have managed to load a 3d environment using my3d format in Irrlicht.

I created a window in the 3d model, so in 3D Studio I set the glass material opacity to 30%, and in Irrlicht it appears transparent, but depending on the angle, the color changes slightly as you can see in this screenshot:

http://i22.photobucket.com/albums/b339/ ... window.jpg

I've trying to fix it but after some hours I'm at the same point, can anyone tell me what I'm doing wrong?


In the same scene I created a fire using the same code (copy/paste) from the SpecialFX tutorial, but depending on the angle it sometimes appears black as can be seen on this screenshot:

http://i22.photobucket.com/albums/b339/Amt0571/fire.jpg

I'm sure that it's not my graphics card, since I tested it on two computers with different cards. By the way, I'm using OpenGL.

Thanks in advance :)

Posted: Tue Mar 07, 2006 10:18 am
by bearSoft
the color changes slightly as you can see in this screenshot:
eh the first got a sky.. the scond does not!
thats more than slightly!
if u look at the egde of the windowf rame , then the colors are actually very close in both img.
It is the part where the sky 'blend in' that are different

..perhaps the no-sky img is taken just outside the far-distance for the scene??

does the skybox disapear in some posisteion in ur game?

Posted: Tue Mar 07, 2006 10:07 pm
by Guest
There's no sky and no skybox... just a black background, nothing else.

Thanks a lot :)

Posted: Tue Mar 07, 2006 10:09 pm
by Amt0571
Sorry, that guest was me...

Posted: Wed Mar 08, 2006 9:58 am
by bearSoft
neh.. when i cranked my light on my monitor up to 90% i could see a blueish color on the 'black'...
so.. both -are- the same but apear so different..
I have NO idea why
sorry :(

Hi

Posted: Wed Mar 08, 2006 12:06 pm
by r3i
For window: have you tried to set the material flag EMF_LIGHTING off?
For Fire: Maybe you lost the texture: try to control it using an ITexture pointer and chack in every loop: maybe something goes wrong.

Posted: Wed Mar 08, 2006 4:29 pm
by Amt0571
I finally managed to solve the fire problem, it was caused by some unnecessary code from the collision tutorial that I accidentally forgot to delete. That code I think switched on and off the EMF_LIGHTING flag.

I'm going to try if the window problem is also related with EMF_LIGHTING.

Thanks to all!

Posted: Wed Mar 08, 2006 4:33 pm
by r3i
Good work! Take us updated and if you solve the question, please edit this post adding "[SOLVED]" :D

Posted: Wed Mar 08, 2006 5:33 pm
by Guest
Ok, I found the window problem is somehow related to the particle system (the fire).

The code I'm using for the fire is exactly the same used in the SpecialFX tutorial. I found that the problem is related to this line:

ps->setMaterialType(video::EMT_TRANSPARENT_VERTEX_ALPHA);

If I delete or comment this line, the window appears fine, but the fire appears without transparency. On the other hand, if I use this line, the fire is ok, but I have the window problem...

The whole code for the particle system is this one:

scene::IParticleSystemSceneNode* ps = 0;
ps = smgr->addParticleSystemSceneNode(false);
ps->setPosition(core::vector3df(2996,295,-524));
ps->setScale(core::vector3df(2,2,2));
ps->setParticleSize(core::dimension2d<f32>(20.0f, 20.0f));
scene::IParticleEmitter* em = ps->createBoxEmitter(
core::aabbox3d<f32>(-7,0,-7,7,1,7),
core::vector3df(0.0f,0.06f,0.0f),
80,100,
video::SColor(0,255,255,255), video::SColor(0,255,255,255),
800,2000);
ps->setEmitter(em);
em->drop();
scene::IParticleAffector* paf =
ps->createFadeOutParticleAffector();
ps->addAffector(paf);
paf->drop();
ps->setMaterialFlag(video::EMF_LIGHTING, false);
ps->setMaterialTexture(0, driver->getTexture("./data/fire.bmp"));
ps->setMaterialType(video::EMT_TRANSPARENT_VERTEX_ALPHA);

Thanks again :D

Posted: Wed Mar 08, 2006 6:23 pm
by Guest
Solved :)

I suppose there must be a better solution, but in the end I replaced "ps->setMaterialType(video::EMT_TRANSPARENT_VERTEX_ALPHA);" with "ps->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR );" and it worked.

The result is very similar, and the window problems go away :D