Jump to content
  • Advertisement
Sign in to follow this  
Malder1

How to draw RenderTarget texture with custom alpha intensity?

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

I have RenderTarget texture X8R8G8B8. I need to draw it (as a quad) with customizable value of alpha intensity (which will be changed from 255 to 0 in series of frames). In other words - dissolving. I tried: SetTextureStageState( 0, D3DTSS_COLORARG0, D3DTA_DIFFUSE) and combination of texture stage parameters but it worked fine only on NVIDIA video cards. And texture draws as opaque on INTEL and ATI video cards. Please write me correct way how to realize it without pixel/vertex shaders in DirectX 8.1 p.s. I found only one really working anywhere variant via D3DTOP_BLENDFACTORALPHA but it set alpha for whole triangle, but I need to set different values of alpha for 3 tops of triangle separately. [Edited by - Malder1 on September 23, 2005 1:10:59 PM]

Share this post


Link to post
Share on other sites
Advertisement
You could try to simply construct 4 vertices of format (XYZ|DIFFUSE) in memory and draw with Draw(Indexed)PrimtiveUP(). The diffuse would be updated directly every frame as your aplication pleases.

I think the overhead of callin *UP version would be meaningless, since it's only 4 vertices. The amount of vertex data being send to the GPU every frame is nothing compared to the metadata of any one call of Draw*.
But that would have to be tested to be sure.

As for the actual parameters:

SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);

SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE);
SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_TEXTURE);
SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
//or, if you don't care about your texture's alpha
SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);

// Set alpha blending to (SRCALPHA, INVSRCALPHA), or (SRCALPHA, ZERO)



(I may not remember the exact constants, since I stopped using fixed pipeline a short while ago.)

Cheers.
~def

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!