浏览代码

HDCamera cleanup

/stochastic_alpha_test
Thomas 7 年前
当前提交
bdea54df
共有 1 个文件被更改,包括 33 次插入29 次删除
  1. 62
      ScriptableRenderPipeline/HDRenderPipeline/Camera/HDCamera.cs

62
ScriptableRenderPipeline/HDRenderPipeline/Camera/HDCamera.cs


get { return nonJitteredProjMatrix * viewMatrix; }
}
public bool isFirstFrame
{
get { return m_FirstFrame; }
}
// Always true for cameras that just got added to the pool - needed for previous matrices to
// avoid one-frame jumps/hiccups with temporal effects (motion blur, TAA...)
public bool isFirstFrame { get; private set; }
get { var p = projMatrix; return new Vector4(p.m20 / (p.m00 * p.m23), p.m21 / (p.m11 * p.m23), -1.0f / p.m23, (-p.m22 + p.m20 * p.m02 / p.m00 + p.m21 * p.m12 / p.m11) / p.m23); }
get
{
var p = projMatrix;
return new Vector4(
p.m20 / (p.m00 * p.m23),
p.m21 / (p.m11 * p.m23),
-1f / p.m23,
(-p.m22 + p.m20 * p.m02 / p.m00 + p.m21 * p.m12 / p.m11) / p.m23
);
}
}
// View-projection matrix from the previous frame.

// happen, but you never know...
int m_LastFrameActive;
// Always true for cameras that just got added to the pool - needed for previous matrices to
// avoid one-frame jumps/hiccups with temporal effects (motion blur, TAA...)
bool m_FirstFrame;
static Dictionary<Camera, HDCamera> s_Cameras = new Dictionary<Camera, HDCamera>();
static List<Camera> s_Cleanup = new List<Camera>(); // Recycled to reduce GC pressure
public HDCamera(Camera cam)
{

bool taaEnabled = camera.cameraType == CameraType.Game
&& CoreUtils.IsTemporalAntialiasingActive(postProcessLayer);
Matrix4x4 nonJitteredCameraProj = camera.projectionMatrix;
Matrix4x4 cameraProj = taaEnabled
var nonJitteredCameraProj = camera.projectionMatrix;
var cameraProj = taaEnabled
Matrix4x4 gpuProj = GL.GetGPUProjectionMatrix(cameraProj, true); // Had to change this from 'false'
Matrix4x4 gpuView = camera.worldToCameraMatrix;
Matrix4x4 gpuNonJitteredProj = GL.GetGPUProjectionMatrix(nonJitteredCameraProj, true);
var gpuProj = GL.GetGPUProjectionMatrix(cameraProj, true); // Had to change this from 'false'
var gpuView = camera.worldToCameraMatrix;
var gpuNonJitteredProj = GL.GetGPUProjectionMatrix(nonJitteredCameraProj, true);
Vector3 pos = camera.transform.position;
var pos = camera.transform.position;
if (ShaderConfig.s_CameraRelativeRendering != 0)
{

Matrix4x4 gpuVP = gpuNonJitteredProj * gpuView;
var gpuVP = gpuNonJitteredProj * gpuView;
if (m_FirstFrame)
if (isFirstFrame)
{
prevCameraPos = pos;
prevViewProjMatrix = gpuVP;

prevViewProjMatrix = nonJitteredViewProjMatrix;
}
m_FirstFrame = false;
isFirstFrame = false;
}
viewMatrix = gpuView;

screenSize = new Vector4(camera.pixelWidth, camera.pixelHeight, 1.0f / camera.pixelWidth, 1.0f / camera.pixelHeight);
Plane[] planes = GeometryUtility.CalculateFrustumPlanes(viewProjMatrix);
var planes = GeometryUtility.CalculateFrustumPlanes(viewProjMatrix);
for (int i = 0; i < 6; i++)
{

public void Reset()
{
m_LastFrameActive = -1;
m_FirstFrame = true;
isFirstFrame = true;
static Dictionary<Camera, HDCamera> m_Cameras = new Dictionary<Camera, HDCamera>();
static List<Camera> m_Cleanup = new List<Camera>(); // Recycled to reduce GC pressure
if (!m_Cameras.TryGetValue(camera, out hdcam))
if (!s_Cameras.TryGetValue(camera, out hdcam))
m_Cameras.Add(camera, hdcam);
s_Cameras.Add(camera, hdcam);
}
hdcam.Update(postProcessLayer);

{
int frameCheck = Time.frameCount - 1;
foreach (var kvp in m_Cameras)
foreach (var kvp in s_Cameras)
m_Cleanup.Add(kvp.Key);
s_Cleanup.Add(kvp.Key);
foreach (var cam in m_Cleanup)
m_Cameras.Remove(cam);
foreach (var cam in s_Cleanup)
s_Cameras.Remove(cam);
m_Cleanup.Clear();
s_Cleanup.Clear();
}
public void SetupGlobalParams(CommandBuffer cmd)

正在加载...
取消
保存