Jump to content
  • Advertisement

Archived

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

WesleyWu

multipass problem

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

New to multipass technology. I have some problems in implementing such algorithms. 1. According to D3D Documentations, a multipass algorithm should set SRCBLEND and DESTBLEND. But it didn''t mention how to do that. Can anyone tell me how to set the blending mode in D3D when doing multipass? 2. Since vertices have several set of texture coordinates, how to let the hardware know which set to associate with certain texture stages? Say I want to use the (u2,v2) in the second pass. But if I set the second texture to the texture stage 0, I will only get those rendered with the (u1,v1) coordinates, not (u2,v2). I got puzzled. Thanx in advance for any good comment.

Share this post


Link to post
Share on other sites
Advertisement
1 cannot be answered. There isn''t any one specific setting, which is why you have to set it. It depends on how you want the two passes to be mixed.

D3DRS_SRCBLEND determines what to multiply the new color by.
D3DRS_DESTBLEND determines what to multiply the old color by.
D3DRS_BLENDOP determines how to mix the two values.

A standard set of blending for multipass:

D3DRS_BLENDOP = D3DBLENDOP_ADD
D3DRS_SRCBLEND = D3DBLEND_ONE
D3DRS_DESTBLEND = D3DBLEND_ONE
ie: (newcolor * 1) + (oldcolor * 1)

You could use alpha to mix between old and new

D3DRS_BLENDOP = D3DBLENDOP_ADD
D3DRS_SRCBLEND = D3DBLEND_SRCALPHA
D3DRS_DESTBLEND = D3DBLEND_INVSRCALPHA
ie: (newcolor * newalpha) + (oldcolor * (1-newalpha))


2. To select which texture coordinates to use, use D3DTSS_TEXTURECOORDINDEX. Or, if you''re using shaders, just move different data into the texture registers.

Share this post


Link to post
Share on other sites
Thank you.

I fixed the first problem by setting TEXTUREINDEX you''ve mentioned. And I fixed the first problem by setting SRCBLEND to DESTCOLOR and DESTBLEND to ZERO with ALPHABLENDINGENABLE on.

I am curious about that why I have to set ALPHABLENDINGENABLE to true to blend two passes. Otherwise it doesn''t work.

Share this post


Link to post
Share on other sites
Ok, so you''re modulating the two passes (new * old). The reason you need to enable alphablending is because that''s what tells D3D to read the old values, and apply blending, before writing the new values. Ignore that it says ''alpha''blendenable, as you''re not using alpha. Just think of it as ''blendenable''.

Also, if you''re using fog, be aware that with many blending modes you might apply fog twice if you don''t disable it in one of your passes.

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!