Sign in to follow this  
Asheh

Texture Stages and alpha blending

Recommended Posts

Hi, Im using the FFP for rendering currently before I impliment shaders into my particle system. I have found them pretty confusing can anyone tell me how I have diffuse and a texture and blend them so that the diffuse alpha can fade a particle in/out? trust this makes sense. Ash.

Share this post


Link to post
Share on other sites

// Color = texture color * diffuse color
pDev->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
pDev->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
pDev->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
// Alpha = texture alpha * diffuse alpha
pDev->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
pDev->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
pDev->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);

pDev->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
pDev->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);

Share this post


Link to post
Share on other sites
One of the other MVPs fed you a fish. Here's how you catch your own fish.

First, take a look at my pipeline poster so that you understand how data flows through the pipeline and the organization of each texture stage.

Next, read Chapter 11 Basic Texturing from my book to get all the nitty gritty details on the texturing portion of the pipeline.

Share this post


Link to post
Share on other sites
And here's yet another answer. :)

What you need is an alpha value that changes over time, and use that with alpha blending. (I assume you know how to set up alpha blending.) Where to store this alpha depends on how you draw your particles. Assuming you're updating a vertex buffer each frame with the particles' positions, you can also store the value in the vertex, for example in the diffuse colour. That'd then lead you to the texture stages posted by Namethatnobodyelsetook.

Really, I'd suggest that you use pixel shaders. While it can be argued that the fixed function vertex pipeline is easier than vertex shaders, since it's more conceptual, the fixed function pixel pipeline is just a cumbersome way to write a simple calculation, and pixel shaders provide a much more convenient way to do that.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this