@@ -1716,6 +1716,7 @@ class ExecuteCaptureActionsPassData
17161716 public IEnumerator < Action < RenderTargetIdentifier , CommandBuffer > > recorderCaptureActions ;
17171717 public Vector2 viewportScale ;
17181718 public Material blitMaterial ;
1719+ public Rect viewportSize ;
17191720 }
17201721
17211722 internal void ExecuteCaptureActions ( RenderGraph renderGraph , TextureHandle input )
@@ -1726,14 +1727,16 @@ internal void ExecuteCaptureActions(RenderGraph renderGraph, TextureHandle input
17261727 using ( var builder = renderGraph . AddRenderPass < ExecuteCaptureActionsPassData > ( "Execute Capture Actions" , out var passData ) )
17271728 {
17281729 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+
17311733 passData . blitMaterial = HDUtils . GetBlitMaterial ( inputDesc . dimension ) ;
17321734 passData . recorderCaptureActions = m_RecorderCaptureActions ;
17331735 passData . input = builder . ReadTexture ( input ) ;
1736+ passData . viewportSize = finalViewport ;
17341737 // We need to blit to an intermediate texture because input resolution can be bigger than the camera resolution
17351738 // 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 )
17371740 { colorFormat = inputDesc . colorFormat , name = "TempCaptureActions" } ) ;
17381741
17391742 builder . SetRenderFunc (
@@ -1744,6 +1747,7 @@ internal void ExecuteCaptureActions(RenderGraph renderGraph, TextureHandle input
17441747 mpb . SetVector ( HDShaderIDs . _BlitScaleBias , data . viewportScale ) ;
17451748 mpb . SetFloat ( HDShaderIDs . _BlitMipLevel , 0 ) ;
17461749 ctx . cmd . SetRenderTarget ( data . tempTexture ) ;
1750+ ctx . cmd . SetViewport ( data . viewportSize ) ;
17471751 ctx . cmd . DrawProcedural ( Matrix4x4 . identity , data . blitMaterial , 0 , MeshTopology . Triangles , 3 , 1 , mpb ) ;
17481752
17491753 for ( data . recorderCaptureActions . Reset ( ) ; data . recorderCaptureActions . MoveNext ( ) ; )
0 commit comments