Texture Stages and alpha blending

Started by
2 comments, last by ET3D 15 years, 4 months ago
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.
Advertisement
// Color = texture color * diffuse colorpDev->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);pDev->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);pDev->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);// Alpha = texture alpha * diffuse alphapDev->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);
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.

My free book on Direct3D: "The Direct3D Graphics Pipeline"
My blog on programming, vintage computing, music, politics, etc.: Legalize Adulthood!

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.

This topic is closed to new replies.

Advertisement