0
101 Jan 01, 2014 at 10:36 graphics

I write some codes but I don’t really get it. Help!!

Device->SetRenderState(D3DRS_ALPHABLENDENABLE, true);  //Open alpha blending
Device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);  //Source factor
Device->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA);  //Destination factor
Device->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE); //blending parameter 1
Device->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE); //blending parameter 2
Device->SetTextureStageState(0, D3DTSS_ALPHAARG0, D3DTA_CONSTANT); //blending parameter 3
Device->SetTextureStageState(0, D3DTSS_ALPHAOP,D3DTOP_MODULATE);  //parameter 1 times blending parameter 2


Questions:

1. The factor D3DBLEND_SRCALPHA is (as, as, as, as). I don’t understand why isn’t it (rs, gs, bs, as). What does it mean by (as, as, as, as)? Does it use alpha value to displace other colors’ values? I don’t think it does. So what does it mean?
2. The factor D3DBLEND_SRCALPHA is (as, as, as, as). Does it blend any color channel or it just blend alpha channel?
3. What is separate blending?
4. Can I set my own blending factor for D3DRS_DESTBLEND and D3DRS_SRCBLEND?
5. I don’t understand the calculation about D3DTOP_MODULATE. MSDN said arg1 multiply arg2 but how? My texture(D3DTA_TEXTURE) has a 255 value of alpha and the alpha in vertex(D3DTA_DIFFUSE) has a value of 255. How does it multiply to get 255 (cause the result is opaque)? Also, how do they multiply 64 by 255 to get 64? Any full calculation?
6. I want to multiply arg1, arg2 and arg3 together. I want to blend the alpha of my texture with the vertex alpha and the constant alpha. Can I do that?

Help!!!! Also, thank you !!!!!!