Renderstates for smoke
Im having troube comming up with the renderstates for smoke in my particle engine, using directx 9.
All I can manage to get, is either dark and blocky smoke, or nicelooking alpha blended but additive light smoke. I want it to be dark, like when oil is burning.
Can someone help me ?
/TC :)
Hmm, something in the back of my brain says SRC_ALPHA, INV_SRC_ALPHA is what you want, but you will probably need to depth sort your smoke particles to make it work.
-Mezz
-Mezz
Try a subtractive blend, which should do the opposite of additive blending (the more particles you have, the blacker the patch of smoke). This might give you the effect your looking for, so you may as well give it a try.
I think subtractive is applied by using D3DBLEND_ZERO, D3DBLEND_INVSRCCOLOR, but I cant be sure as I am away from a code machine at the moment.
Spree
I think subtractive is applied by using D3DBLEND_ZERO, D3DBLEND_INVSRCCOLOR, but I cant be sure as I am away from a code machine at the moment.
Spree
SpreeTree: Seems like its working! (D3DBLEND_ZERO, D3DBLEND_INVSRCCOLOR) get e nice dark smoke. Though they are popping out of existance... but i guess its just this particular effect that doesn't blend the particles towards 0 alfa.
Gotta try it some more.
Mezz: Sort particles? Oh lord... that will be painful.
thanks!
/T
Gotta try it some more.
Mezz: Sort particles? Oh lord... that will be painful.
thanks!
/T
D3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_DESTCOLOR ); D3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
(Using a greyscale bitmap that had a gradient of white -> black from the outside edge to the middle)
These are the states I used. I happened to have the source in front of me when I read the forum topic ;)
Yeah, I needed to do some ordering with it. Though I found that using D3DBLEND_ZERO as the source blend was a complete disaster. Hope this is of some help.
Also, if anyone could spare a few moments of thought: My method of using sprites goes completely to shambles if I try using fog ;) Any hints, anyone?
(Using a greyscale bitmap that had a gradient of white -> black from the outside edge to the middle)
These are the states I used. I happened to have the source in front of me when I read the forum topic ;)
Yeah, I needed to do some ordering with it. Though I found that using D3DBLEND_ZERO as the source blend was a complete disaster. Hope this is of some help.
Also, if anyone could spare a few moments of thought: My method of using sprites goes completely to shambles if I try using fog ;) Any hints, anyone?
PouncingAnt:
I just tried this now:
m_textureStateCache->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_ZERO );
m_textureStateCache->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCCOLOR );
with a texture gradient black->lightlight from outside to centre.
As far as i can see it works, (without sorting)
Im gonna look a bit more at it... maybe i will have problems somewhere...
thanks!
/T
I just tried this now:
m_textureStateCache->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_ZERO );
m_textureStateCache->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCCOLOR );
with a texture gradient black->lightlight from outside to centre.
As far as i can see it works, (without sorting)
Im gonna look a bit more at it... maybe i will have problems somewhere...
thanks!
/T
ah, so I'm using the wrong gradient with the wrong blending :) I'll try your technique right away!
EDIT: Yeap. Works like a dream.. However, my fog still doesnt like it. *resumes testing*
EDIT2: Thanks again for the correct blending technique! I can disable fog and make my sprites more invisible the further away they are. Shoulda thought of that instantly, really.
[Edited by - PouncingAnt on July 19, 2005 9:56:04 AM]
EDIT: Yeap. Works like a dream.. However, my fog still doesnt like it. *resumes testing*
EDIT2: Thanks again for the correct blending technique! I can disable fog and make my sprites more invisible the further away they are. Shoulda thought of that instantly, really.
[Edited by - PouncingAnt on July 19, 2005 9:56:04 AM]
In order to display transparent objects correctly they should be sorted: first to be drawn are those farther away from the viewer.
Imagine a situation: you're drawing a big transparent object nearby and a small object a bit further ( ar any situation where nearer object is transparent partially occludes farter object ). If you draw the big object first, it will fill the z-buffer with correct values. Then the second object will not be visible at all because of the z-buffer.
Imagine a situation: you're drawing a big transparent object nearby and a small object a bit further ( ar any situation where nearer object is transparent partially occludes farter object ). If you draw the big object first, it will fill the z-buffer with correct values. Then the second object will not be visible at all because of the z-buffer.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement