Jump to content
  • Advertisement
Sign in to follow this  
Asheh

Texture Stages and alpha blending

This topic is 3669 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

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
Advertisement

// 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
Sign in to follow this  

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!