@@ -1456,6 +1456,7 @@ class DownsampleDepthForLowResPassData
1456
1456
public float downsampleScale ;
1457
1457
public Material downsampleDepthMaterial ;
1458
1458
public TextureHandle depthTexture ;
1459
+ public TextureHandle depthPyramidTexture ;
1459
1460
public TextureHandle downsampledDepthBuffer ;
1460
1461
public Rect viewport ;
1461
1462
@@ -1499,11 +1500,9 @@ void DownsampleDepthForLowResTransparency(RenderGraph renderGraph, HDCamera hdCa
1499
1500
passData . computesMip1OfAtlas = computeMip1OfPyramid ;
1500
1501
passData . downsampleScale = hdCamera . lowResScale ;
1501
1502
passData . viewport = hdCamera . lowResViewport ;
1502
- passData . depthTexture = builder . ReadTexture ( output . depthPyramidTexture ) ;
1503
+ passData . depthTexture = builder . ReadTexture ( output . resolvedDepthBuffer ) ;
1503
1504
if ( computeMip1OfPyramid )
1504
- {
1505
- passData . depthTexture = builder . WriteTexture ( passData . depthTexture ) ;
1506
- }
1505
+ passData . depthPyramidTexture = builder . WriteTexture ( output . depthPyramidTexture ) ;
1507
1506
1508
1507
passData . downsampledDepthBuffer = builder . UseDepthBuffer ( renderGraph . CreateTexture (
1509
1508
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
1514
1513
if ( data . computesMip1OfAtlas )
1515
1514
{
1516
1515
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 ) ;
1518
1517
}
1519
1518
1520
1519
if ( data . useGatherDownsample )
1521
1520
{
1522
1521
float downsampleScaleInv = 1.0f / data . downsampleScale ;
1523
1522
RenderTexture srcTexture = data . depthTexture ;
1524
1523
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
+
1527
1532
data . downsampleDepthMaterial . SetVector ( HDShaderIDs . _ScaleBias , new Vector4 ( uvScaleX , uvScaleY , 0.0f , 0.0f ) ) ;
1528
1533
}
1529
1534
1530
1535
context . cmd . SetViewport ( data . viewport ) ;
1536
+ context . cmd . SetGlobalTexture ( HDShaderIDs . _SourceDownsampleDepth , data . depthTexture ) ;
1531
1537
context . cmd . DrawProcedural ( Matrix4x4 . identity , data . downsampleDepthMaterial , 0 , MeshTopology . Triangles , 3 , 1 , null ) ;
1532
1538
1533
1539
if ( data . computesMip1OfAtlas )
0 commit comments