Jump to content

  • Log In with Google      Sign In   
  • Create Account


Alpha-Test and Forward+ Rendering (Z-prepass questions)

  • You cannot reply to this topic
5 replies to this topic

#1 lipsryme   Members   -  Reputation: 1005

Like
0Likes
Like

Posted 09 August 2014 - 12:27 PM

I'm currently trying to get the Z-Prepass to work on alpha tested geometry. I've looked at the sample "TiledLighting" from the AMD SDK and saw that they seperate alpha tested from the regular opaque geometry during the prepass (They do opaque first, then all alpha tested). Is there any reason why ? I'm also wondering why in their alpha tested prepass shader they output the (float4) DiffuseMap color using SV_TARGET.

 

The prepass shader looks like the following:

float4 RenderSceneAlphaTestOnlyPS( VS_OUTPUT_POSITION_AND_TEX Input ) : SV_TARGET
{ 
    float4 DiffuseTex = g_TxDiffuse.Sample( g_Sampler, Input.TextureUV );
    float fAlpha = DiffuseTex.a;
    if( fAlpha < g_fAlphaTest ) discard;
    return DiffuseTex;
}


Sponsor:

#2 MJP   Moderators   -  Reputation: 10832

Like
1Likes
Like

Posted 09 August 2014 - 06:51 PM

Alpha-tested geometry tends to mess up z-buffer compression and hierarchical z representations. So usually you want to render it after your "normal" opaques, so that the normal geometry can get the benefit of full-speed depth testing.

 

As for why they return a color from their pixel shader...I have no idea. In our engine we use a void return type for our alpha-tested depth-only pixel shader.


Edited by MJP, 09 August 2014 - 06:52 PM.


#3 kalle_h   Members   -  Reputation: 1336

Like
0Likes
Like

Posted 10 August 2014 - 05:21 AM

Alpha-tested geometry tends to mess up z-buffer compression and hierarchical z representations. So usually you want to render it after your "normal" opaques, so that the normal geometry can get the benefit of full-speed depth testing.

 

As for why they return a color from their pixel shader...I have no idea. In our engine we use a void return type for our alpha-tested depth-only pixel shader.

 

Could it be beneficial to skip z prepass for alpha tested geometry compleatly to avoid that z-buffer compression mess ups?



#4 lipsryme   Members   -  Reputation: 1005

Like
1Likes
Like

Posted 10 August 2014 - 07:17 AM

 

Alpha-tested geometry tends to mess up z-buffer compression and hierarchical z representations. So usually you want to render it after your "normal" opaques, so that the normal geometry can get the benefit of full-speed depth testing.

 

As for why they return a color from their pixel shader...I have no idea. In our engine we use a void return type for our alpha-tested depth-only pixel shader.

 

Could it be beneficial to skip z prepass for alpha tested geometry compleatly to avoid that z-buffer compression mess ups?

 

The issue here is you can't since you need the depth information for light culling in the compute shader.

By the way it seems they have alpha-to-coverage enabled in the AMD sample so maybe the color return type has something to do with that ?


Edited by lipsryme, 10 August 2014 - 07:18 AM.


#5 MJP   Moderators   -  Reputation: 10832

Like
0Likes
Like

Posted 10 August 2014 - 02:49 PM

 

 

Alpha-tested geometry tends to mess up z-buffer compression and hierarchical z representations. So usually you want to render it after your "normal" opaques, so that the normal geometry can get the benefit of full-speed depth testing.

 

As for why they return a color from their pixel shader...I have no idea. In our engine we use a void return type for our alpha-tested depth-only pixel shader.

 

Could it be beneficial to skip z prepass for alpha tested geometry compleatly to avoid that z-buffer compression mess ups?

 

The issue here is you can't since you need the depth information for light culling in the compute shader.

By the way it seems they have alpha-to-coverage enabled in the AMD sample so maybe the color return type has something to do with that ?

 

 

Indeed, plus you'll want the full depth buffer so that you can avoid overdraw for occluded pixels.

If they're using alpha to coverage, then that explains it since it will use the alpha channel being output by the pixel shader to determine the coverage value. However you can also do alpha to coverage right in the pixel shader if you want, by outputting SV_Coverage.



#6 David_Lee   Members   -  Reputation: 323

Like
0Likes
Like

Posted 11 August 2014 - 01:15 AM

Alpha-tested geometry tends to mess up z-buffer compression and hierarchical z representations. So usually you want to render it after your "normal" opaques, so that the normal geometry can get the benefit of full-speed depth testing.
&nbsp;
As for why they return a color from their pixel shader...I have no idea. In our engine we use a void return type for our alpha-tested depth-only pixel shader.

As i know, alpha-test will disable the hierarchical z and early z, usually we get all the alpha test geometry together, but is there better to render all alpha test geometry first and then normal opaques? i thought it is better for opaques to do early z, am i right?


Edited by David_Lee, 11 August 2014 - 02:38 AM.






PARTNERS