Jump to content
  • Advertisement
Sign in to follow this  
Armterla

The problem about MRT/Alpha Test/Deferred Shading

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

Hi. Problem is : How to use alpha test in MRT.in deferred shading. What i have done : 1.MRT0's alpha channal is filled with the texture's alpha. 2.MRT1-MRT3 is fill with other data i needed. How the Direct3D execute alpha test ? It use MRT0's alpha channel default? When I use the ATI RenderMonkey to demonstrate it, the result is usage MRT0's alpha channel to alpha test. When I use the C++ and myself engine. The alpha test can't be executed.Why? Thanks

Share this post


Link to post
Share on other sites
Advertisement
Or mean that :
If I use MRT in engine. I can't usage alpha test. Must realize the alpha test manual?

Like this(In pixel shader) ?

#define GLOBAL_ALPHA_REF_BIAS (0.1F / 255.0F)

float c_GlobalAlphaRef : register(...);

void main(in float2 itc : TEXCOORD0,
in float idepth : TEXCOORD1,
out float4 ocr0 : COLOR0,
out float4 ocr1 : COLOR1,
out float4 ocr2 : COLOR2,
out float4 ocr3 : COLOR3,
out float odepth : DEPTH)
{
float4 cr = tex2D(texture, itc);

odepth = idepth * sign(cr.a - c_GlobalAlphaRef - GLOBAL_ALPHA_REF_BIAS);
}

Thanks

Share this post


Link to post
Share on other sites
I see something!

Alpha test: Comparison will happen with oC0. If the comparison fails, the pixel test is terminated for all render targets. (Comefrom D3D9 SDK).

But why my alpha test have any effect?

Thanks

[Edited by - Armterla on December 1, 2008 7:23:38 PM]

Share this post


Link to post
Share on other sites
You likely have an HDR render target. Many cards can only blend to a few (if any) FP formats. You must do a query for POSTPIXELSHADERBLENDING, which even though testing isn't blending, is still part of what is or isn't supported.

        if (SUCCEEDED(m_pD3D->CheckDeviceFormat(m_nAdapter, D3DDEVTYPE_HAL, dispfmt, use|D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING, D3DRTYPE_TEXTURE, checkfmt)))
nSupport |= EFormatSupport_RT_PostShaderBlend;



You can perform an alphatest in your shader though, using clip, which is how most HDR renderers probably handle alphatest. As a bonus, since you're not outputting the alpha anymore, you now have one more data element available for later passes.

Share this post


Link to post
Share on other sites
Thanks for your best answers.

You means that:

void ps_main(
...
out float4 ocr0 : COLOR0
...)
{
...
...
clip(ocr0.a - c_GlobalAlphaRef);
...
}

Share this post


Link to post
Share on other sites
Yes, that should work... but instead of clipping against the output value, you can clip against a temporary variable. This opens up the alpha component of render target 0 to hold some other data. Deferred renderers are always trying to squeeze more and more info into a limited number of outputs. Using clip allows you to use the alpha output for something else.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!