@@ -1456,6 +1456,7 @@ class DownsampleDepthForLowResPassData
14561456 public float downsampleScale ;
14571457 public Material downsampleDepthMaterial ;
14581458 public TextureHandle depthTexture ;
1459+ public TextureHandle depthPyramidTexture ;
14591460 public TextureHandle downsampledDepthBuffer ;
14601461 public Rect viewport ;
14611462
@@ -1499,11 +1500,9 @@ void DownsampleDepthForLowResTransparency(RenderGraph renderGraph, HDCamera hdCa
14991500 passData . computesMip1OfAtlas = computeMip1OfPyramid ;
15001501 passData . downsampleScale = hdCamera . lowResScale ;
15011502 passData . viewport = hdCamera . lowResViewport ;
1502- passData . depthTexture = builder . ReadTexture ( output . depthPyramidTexture ) ;
1503+ passData . depthTexture = builder . ReadTexture ( output . resolvedDepthBuffer ) ;
15031504 if ( computeMip1OfPyramid )
1504- {
1505- passData . depthTexture = builder . WriteTexture ( passData . depthTexture ) ;
1506- }
1505+ passData . depthPyramidTexture = builder . WriteTexture ( output . depthPyramidTexture ) ;
15071506
15081507 passData . downsampledDepthBuffer = builder . UseDepthBuffer ( renderGraph . CreateTexture (
15091508 new TextureDesc ( Vector2 . one * hdCamera . lowResScale , true , true ) { depthBufferBits = DepthBits . Depth32 , name = "LowResDepthBuffer" } ) , DepthAccess . Write ) ;
@@ -1514,20 +1513,27 @@ void DownsampleDepthForLowResTransparency(RenderGraph renderGraph, HDCamera hdCa
15141513 if ( data . computesMip1OfAtlas )
15151514 {
15161515 data . downsampleDepthMaterial . SetVector ( HDShaderIDs . _DstOffset , new Vector4 ( data . mip0Offset . x , data . mip0Offset . y , 0.0f , 0.0f ) ) ;
1517- context . cmd . SetRandomWriteTarget ( 1 , data . depthTexture ) ;
1516+ context . cmd . SetRandomWriteTarget ( 1 , data . depthPyramidTexture ) ;
15181517 }
15191518
15201519 if ( data . useGatherDownsample )
15211520 {
15221521 float downsampleScaleInv = 1.0f / data . downsampleScale ;
15231522 RenderTexture srcTexture = data . depthTexture ;
15241523 RenderTexture destTexture = data . downsampledDepthBuffer ;
1525- float uvScaleX = ( ( float ) destTexture . width / ( float ) srcTexture . width ) * downsampleScaleInv ;
1526- float uvScaleY = ( ( float ) destTexture . height / ( float ) srcTexture . height ) * downsampleScaleInv ;
1524+ float uvScaleX = 1.0f ;
1525+ float uvScaleY = 1.0f ;
1526+ if ( ! DynamicResolutionHandler . instance . HardwareDynamicResIsEnabled ( ) )
1527+ {
1528+ uvScaleX = ( ( float ) destTexture . width / ( float ) srcTexture . width ) * downsampleScaleInv ;
1529+ uvScaleY = ( ( float ) destTexture . height / ( float ) srcTexture . height ) * downsampleScaleInv ;
1530+ }
1531+
15271532 data . downsampleDepthMaterial . SetVector ( HDShaderIDs . _ScaleBias , new Vector4 ( uvScaleX , uvScaleY , 0.0f , 0.0f ) ) ;
15281533 }
15291534
15301535 context . cmd . SetViewport ( data . viewport ) ;
1536+ context . cmd . SetGlobalTexture ( HDShaderIDs . _SourceDownsampleDepth , data . depthTexture ) ;
15311537 context . cmd . DrawProcedural ( Matrix4x4 . identity , data . downsampleDepthMaterial , 0 , MeshTopology . Triangles , 3 , 1 , null ) ;
15321538
15331539 if ( data . computesMip1OfAtlas )
0 commit comments