Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Chaucer

dx8.1 pixel shader blend only alpha

This topic is 5493 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''m currently using directx8.1 and ps1.3. I''m able to blend 2 textures using the following shader: ps.1.3 tex t0 tex t1 mul r1, t0, v0.rgb mad r0, t1, v0.rgb, r1 using this fvf: struct VERTEX { D3DXVECTOR3 position; D3DCOLOR diffuse; float tu, tv; float tu2, tv2; float tu3, tv3; }; #define D3DFVF_VERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX3) where v0 is my diffuse and rgb and alpha each contain a weighted value for how much to blend. My problem is that, as you can see, I''m not using the alpha weight. isntead I use rgb for both. This works fine until i comment out the part in my code where i add the weight to the alpha component. If there is no alpha, then there is no blending. Is this the correct behavior? Shouldn''t I be able to blend on just the rgb component? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
Can you show all pixel shader code with the comment part?
Have your textures alpha chanel?

Share this post


Link to post
Share on other sites
My textures don''t have an alpha channel so I''m using vertex alpha. My shader code, with comments, is this:

ps.1.3

tex t0 //texture 1
tex t1 //texture 2

//multiply texture1 by weight1 (diffuse rgb value)
mul r1, t0, v0.rgb

//multiply texture2 by weight1 (diffuse rgb value) and add to current
mad r0, t1, v0.rgb, r1

Share this post


Link to post
Share on other sites
Your pixel shader has normal behavior.
Remember, result of calculation is clamped [0..1].

Share this post


Link to post
Share on other sites
I don''t understand. Why can''t I blend using only the rgb component? Why is the alpha component needed?

Share this post


Link to post
Share on other sites

  • 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!