|
|
|
|
|
|
// happen, but you never know...
|
|
|
|
int m_LastFrameActive; |
|
|
|
|
|
|
|
int m_FrameID; // i % 2^24
|
|
|
|
int m_FrameID_TAA; // i % 8
|
|
|
|
|
|
|
|
static Dictionary<Camera, HDCamera> s_Cameras = new Dictionary<Camera, HDCamera>(); |
|
|
|
static List<Camera> s_Cleanup = new List<Camera>(); // Recycled to reduce GC pressure
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
m_LastFrameActive = Time.frameCount; |
|
|
|
|
|
|
|
int k = Time.renderedFrameCount; |
|
|
|
m_FrameID = k & ((1 << 24) - 1); |
|
|
|
m_FrameID_TAA = k & 7; |
|
|
|
} |
|
|
|
|
|
|
|
public void Reset() |
|
|
|
|
|
|
cmd.SetGlobalVector(HDShaderIDs._ScreenSize, screenSize); |
|
|
|
cmd.SetGlobalMatrix(HDShaderIDs._PrevViewProjMatrix, prevViewProjMatrix); |
|
|
|
cmd.SetGlobalVectorArray(HDShaderIDs._FrustumPlanes, frustumPlaneEquations); |
|
|
|
cmd.SetGlobalFloat(HDShaderIDs._FrameID, m_FrameID); // TODO: SetGlobalInt()
|
|
|
|
cmd.SetGlobalFloat(HDShaderIDs._FrameID_TAA, m_FrameID_TAA); // TODO: SetGlobalInt()
|
|
|
|
} |
|
|
|
|
|
|
|
// Does not modify global settings. Used for shadows, low res. rendering, etc.
|
|
|
|
|
|
|
material.SetVector(HDShaderIDs._ScreenSize, screenSize); |
|
|
|
material.SetMatrix(HDShaderIDs._PrevViewProjMatrix, prevViewProjMatrix); |
|
|
|
material.SetVectorArray(HDShaderIDs._FrustumPlanes, frustumPlaneEquations); |
|
|
|
material.SetInt(HDShaderIDs._FrameID, m_FrameID); |
|
|
|
material.SetInt(HDShaderIDs._FrameID_TAA, m_FrameID_TAA); |
|
|
|
} |
|
|
|
|
|
|
|
public void SetupComputeShader(ComputeShader cs, CommandBuffer cmd) |
|
|
|
|
|
|
cmd.SetComputeVectorParam(cs, HDShaderIDs._ScreenParams, Shader.GetGlobalVector(HDShaderIDs._ScreenParams)); |
|
|
|
cmd.SetComputeVectorParam(cs, HDShaderIDs._ZBufferParams, Shader.GetGlobalVector(HDShaderIDs._ZBufferParams)); |
|
|
|
cmd.SetComputeVectorParam(cs, HDShaderIDs._WorldSpaceCameraPos, Shader.GetGlobalVector(HDShaderIDs._WorldSpaceCameraPos)); |
|
|
|
cmd.SetComputeIntParam(cs, HDShaderIDs._FrameID, m_FrameID); |
|
|
|
cmd.SetComputeIntParam(cs, HDShaderIDs._FrameID_TAA, m_FrameID_TAA); |
|
|
|
} |
|
|
|
} |
|
|
|
} |