Jump to content
  • Advertisement
Sign in to follow this  
TechnoCore

Renderstates for smoke

This topic is 4711 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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 :)

Share this post


Link to post
Share on other sites
Advertisement
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
PouncingAnt: Glad it works !
ReaVeR-Andrey: Yes i finally saw that, but since my game is more or less top-down rts-style, it took me a while to see that.

Thanks all
// TC

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!