@@ -1716,6 +1716,7 @@ class ExecuteCaptureActionsPassData
1716
1716
public IEnumerator < Action < RenderTargetIdentifier , CommandBuffer > > recorderCaptureActions ;
1717
1717
public Vector2 viewportScale ;
1718
1718
public Material blitMaterial ;
1719
+ public Rect viewportSize ;
1719
1720
}
1720
1721
1721
1722
internal void ExecuteCaptureActions ( RenderGraph renderGraph , TextureHandle input )
@@ -1726,14 +1727,16 @@ internal void ExecuteCaptureActions(RenderGraph renderGraph, TextureHandle input
1726
1727
using ( var builder = renderGraph . AddRenderPass < ExecuteCaptureActionsPassData > ( "Execute Capture Actions" , out var passData ) )
1727
1728
{
1728
1729
var inputDesc = renderGraph . GetTextureDesc ( input ) ;
1729
- var rtHandleScale = RTHandles . rtHandleProperties . rtHandleScale ;
1730
- passData . viewportScale = new Vector2 ( rtHandleScale . x , rtHandleScale . y ) ;
1730
+ var targetSize = RTHandles . rtHandleProperties . currentRenderTargetSize ;
1731
+ passData . viewportScale = new Vector2 ( targetSize . x / finalViewport . width , targetSize . y / finalViewport . height ) ;
1732
+
1731
1733
passData . blitMaterial = HDUtils . GetBlitMaterial ( inputDesc . dimension ) ;
1732
1734
passData . recorderCaptureActions = m_RecorderCaptureActions ;
1733
1735
passData . input = builder . ReadTexture ( input ) ;
1736
+ passData . viewportSize = finalViewport ;
1734
1737
// We need to blit to an intermediate texture because input resolution can be bigger than the camera resolution
1735
1738
// Since recorder does not know about this, we need to send a texture of the right size.
1736
- passData . tempTexture = builder . CreateTransientTexture ( new TextureDesc ( actualWidth , actualHeight )
1739
+ passData . tempTexture = builder . CreateTransientTexture ( new TextureDesc ( ( int ) finalViewport . width , ( int ) finalViewport . height )
1737
1740
{ colorFormat = inputDesc . colorFormat , name = "TempCaptureActions" } ) ;
1738
1741
1739
1742
builder . SetRenderFunc (
@@ -1744,6 +1747,7 @@ internal void ExecuteCaptureActions(RenderGraph renderGraph, TextureHandle input
1744
1747
mpb . SetVector ( HDShaderIDs . _BlitScaleBias , data . viewportScale ) ;
1745
1748
mpb . SetFloat ( HDShaderIDs . _BlitMipLevel , 0 ) ;
1746
1749
ctx . cmd . SetRenderTarget ( data . tempTexture ) ;
1750
+ ctx . cmd . SetViewport ( data . viewportSize ) ;
1747
1751
ctx . cmd . DrawProcedural ( Matrix4x4 . identity , data . blitMaterial , 0 , MeshTopology . Triangles , 3 , 1 , mpb ) ;
1748
1752
1749
1753
for ( data . recorderCaptureActions . Reset ( ) ; data . recorderCaptureActions . MoveNext ( ) ; )
0 commit comments