@@ -802,12 +802,39 @@ void CustomRender(ScriptableRenderContext context, HDCamera camera)
802802
803803 if ( camera . camera . targetTexture )
804804 {
805+ // When rendering to texture (or to camera bridge) we don't need to flip the image.
806+ // If this matrix was used for the game view, then the image would appear flipped, hense the name of the variable.
805807 m_ShaderVariablesGlobalCB . _ViewProjMatrix = m_ViewProjMatrixFlipped ;
806808 ConstantBuffer . PushGlobal ( cmd , m_ShaderVariablesGlobalCB , HDShaderIDs . _ShaderVariablesGlobal ) ;
807809 cmd . Blit ( null , camera . camera . targetTexture , m_Material , m_Material . FindPass ( "ForwardOnly" ) ) ;
810+
811+ var recorderCaptureActions = CameraCaptureBridge . GetCaptureActions ( camera . camera ) ;
812+ if ( recorderCaptureActions != null )
813+ {
814+ for ( recorderCaptureActions . Reset ( ) ; recorderCaptureActions . MoveNext ( ) ; )
815+ {
816+ recorderCaptureActions . Current ( camera . camera . targetTexture , cmd ) ;
817+ }
818+ }
808819 }
809820 else
810821 {
822+ var recorderCaptureActions = CameraCaptureBridge . GetCaptureActions ( camera . camera ) ;
823+
824+ if ( recorderCaptureActions != null )
825+ {
826+ m_ShaderVariablesGlobalCB . _ViewProjMatrix = m_ViewProjMatrixFlipped ;
827+ cmd . SetInvertCulling ( true ) ;
828+ ConstantBuffer . PushGlobal ( cmd , m_ShaderVariablesGlobalCB , HDShaderIDs . _ShaderVariablesGlobal ) ;
829+ cmd . Blit ( null , BuiltinRenderTextureType . CameraTarget , m_Material , m_Material . FindPass ( "ForwardOnly" ) ) ;
830+ for ( recorderCaptureActions . Reset ( ) ; recorderCaptureActions . MoveNext ( ) ; )
831+ {
832+ recorderCaptureActions . Current ( BuiltinRenderTextureType . CameraTarget , cmd ) ;
833+ }
834+ cmd . SetInvertCulling ( false ) ;
835+ }
836+
837+ // When we render directly to game view, we render the image flipped up-side-down, like other HDRP cameras
811838 m_ShaderVariablesGlobalCB . _ViewProjMatrix = m_ViewProjMatrix ;
812839 ConstantBuffer . PushGlobal ( cmd , m_ShaderVariablesGlobalCB , HDShaderIDs . _ShaderVariablesGlobal ) ;
813840 cmd . Blit ( null , BuiltinRenderTextureType . CameraTarget , m_Material , m_Material . FindPass ( "ForwardOnly" ) ) ;
0 commit comments