public Matrix4x4 projMatrix ;
public Matrix4x4 nonJitteredProjMatrix ;
public Vector4 worldSpaceCameraPos ;
public float detViewMatrix ;
public Vector4 screenSize ;
public Frustum frustum ;
public Vector4 [ ] frustumPlaneEquations ;
projMatrix = gpuProj ;
nonJitteredProjMatrix = gpuNonJitteredProj ;
cameraPos = pos ;
detViewMatrix = viewMatrix . determinant ;
if ( ShaderConfig . s_CameraRelativeRendering ! = 0 )
{
// What constants in UnityPerPass need updating for stereo considerations?
// _ViewProjMatrix - It is used directly for generating tesselation factors. This should be the same
// across both eyes for consistency, and to keep shadow-generation eye-independent
// _DetViewMatrix - Used for isFrontFace determination, should be the same for both eyes. There is the scenario
// where there might be multi-eye sets that are divergent enough where this assumption is not valid,
// but that's a future problem
// _InvProjParam - Intention was for generating linear depths, but not currently used. Will need to be stereo-ized if
// actually needed.
// _FrustumPlanes - Also used for generating tesselation factors. Should be fine to use the combined stereo VP
viewMatrix = stereoCombinedViewMatrix ;
var stereoCombinedProjMatrix = cullingParams . cullStereoProj ;
projMatrix = GL . GetGPUProjectionMatrix ( stereoCombinedProjMatrix , true ) ;
detViewMatrix = viewMatrix . determinant ;
frustum = Frustum . Create ( viewProjMatrix , true , true ) ;
cmd . SetGlobalMatrix ( HDShaderIDs . _NonJitteredViewProjMatrix , nonJitteredViewProjMatrix ) ;
cmd . SetGlobalMatrix ( HDShaderIDs . _PrevViewProjMatrix , prevViewProjMatrix ) ;
cmd . SetGlobalVector ( HDShaderIDs . _WorldSpaceCameraPos , worldSpaceCameraPos ) ;
cmd . SetGlobalFloat ( HDShaderIDs . _DetViewMatrix , detViewMatrix ) ;
cmd . SetGlobalVector ( HDShaderIDs . _ScreenSize , screenSize ) ;
cmd . SetGlobalVector ( HDShaderIDs . _ScreenToTargetScale , doubleBufferedViewportScale ) ;
cmd . SetGlobalVector ( HDShaderIDs . _ZBufferParams , zBufferParams ) ;