return Matrix4x4 . Transpose ( worldToViewMatrix . transpose * viewSpaceRasterTransform ) ;
}
private static void SetViewportAndClear ( CommandBuffer cmd , HDCamera camera , RTHandle buffer , ClearFlag clearFlag , Color clearColor )
{
// Clearing a partial viewport currently does not go through the hardware clear.
// Instead it goes through a quad rendered with a specific shader.
// When enabling wireframe mode in the scene view, unfortunately it overrides this shader thus breaking every clears.
// That's why in the editor we don't set the viewport before clearing (it's set to full screen by the previous SetRenderTarget) but AFTER so that we benefit from un-bugged hardware clear.
// We consider that the small loss in performance is acceptable in the editor.
// A refactor of wireframe is needed before we can fix this properly (with not doing anything!)
#if !UNITY_EDITOR
SetViewport ( cmd , camera , buffer ) ;
#endif
CoreUtils . ClearRenderTarget ( cmd , clearFlag , clearColor ) ;
#if UNITY_EDITOR
SetViewport ( cmd , camera , buffer ) ;
#endif
}
SetViewport ( cmd , camera , buffer ) ;
CoreUtils . ClearRenderTarget ( cmd , clearFlag , clearColor ) ;
SetViewportAndClear ( cmd , camera , buffer , clearFlag , clearColor ) ;
}
public static void SetRenderTarget ( CommandBuffer cmd , HDCamera camera , RTHandle buffer , ClearFlag clearFlag = ClearFlag . None , int miplevel = 0 , CubemapFace cubemapFace = CubemapFace . Unknown , int depthSlice = 0 )
public static void SetRenderTarget ( CommandBuffer cmd , HDCamera camera , RTHandle colorBuffer , RTHandle depthBuffer , ClearFlag clearFlag , Color clearColor , int miplevel = 0 , CubemapFace cubemapFace = CubemapFace . Unknown , int depthSlice = 0 )
{
CoreUtils . SetRenderTarget ( cmd , colorBuffer , depthBuffer , miplevel , cubemapFace , depthSlice ) ;
SetViewport ( cmd , camera , colorBuffer ) ;
CoreUtils . ClearRenderTarget ( cmd , clearFlag , clearColor ) ;
SetViewportAndClear ( cmd , camera , colorBuffer , clearFlag , clearColor ) ;
}
public static void SetRenderTarget ( CommandBuffer cmd , HDCamera camera , RenderTargetIdentifier [ ] colorBuffers , RTHandle depthBuffer )
public static void SetRenderTarget ( CommandBuffer cmd , HDCamera camera , RenderTargetIdentifier [ ] colorBuffers , RTHandle depthBuffer , ClearFlag clearFlag = ClearFlag . None )
{
CoreUtils . SetRenderTarget ( cmd , colorBuffers , depthBuffer ) ; // Don't clear here, viewport needs to be set before we do.
SetViewport ( cmd , camera , depthBuffer ) ;
CoreUtils . ClearRenderTarget ( cmd , clearFlag , CoreUtils . clearColorAllBlack ) ;
SetViewportAndClear ( cmd , camera , depthBuffer , clearFlag , CoreUtils . clearColorAllBlack ) ;
}
public static void SetRenderTarget ( CommandBuffer cmd , HDCamera camera , RenderTargetIdentifier [ ] colorBuffers , RTHandle depthBuffer , ClearFlag clearFlag , Color clearColor )