Skip to main content
gamedev.net
🔒 Locked

multipass problem

Started by WesleyWu 2 replies 400+ views
Original Post
WesleyWu
WesleyWu
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.
Namethatnobodyelsetook
Namethatnobodyelsetook
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.
WesleyWu
WesleyWu
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.
Namethatnobodyelsetook
Namethatnobodyelsetook
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.