浏览代码

Add _FrustumParams to UnityPerView

/main
Evgenii Golubev 6 年前
当前提交
ef6c6a3e
共有 3 个文件被更改,包括 13 次插入1 次删除
  1. 7
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Camera/HDCamera.cs
  2. 1
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDStringConstants.cs
  3. 6
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/ShaderVariables.hlsl

7
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Camera/HDCamera.cs


public uint taaFrameIndex;
public Vector2 taaFrameRotation;
public Vector4 depthBufferParams;
public Vector4 frustumParams;
public PostProcessRenderContext postprocessRenderContext;

depthBufferParams = new Vector4(1 - f/n, f/n, 1/f - 1/n, 1/n);
}
float orthoHeight = camera.orthographic ? 2 * camera.orthographicSize : 0;
float orthoWidth = orthoHeight * camera.aspect;
frustumParams = new Vector4(n, f, orthoWidth, orthoHeight);
frustum = Frustum.Create(viewProjMatrix, depth_0_1, reverseZ);
// Left, right, top, bottom, near, far.

cmd.SetGlobalVector(HDShaderIDs._ScreenSize, screenSize);
cmd.SetGlobalVector(HDShaderIDs._ScreenToTargetScale, scaleBias);
cmd.SetGlobalVector(HDShaderIDs._DepthBufferParams, depthBufferParams);
cmd.SetGlobalVector(HDShaderIDs._InvProjParam, invProjParam);
cmd.SetGlobalVector(HDShaderIDs._FrustumParams, frustumParams);
cmd.SetGlobalVector(HDShaderIDs._TaaFrameRotation, taaFrameRotation);
cmd.SetGlobalVectorArray(HDShaderIDs._FrustumPlanes, frustumPlaneEquations);
}

1
ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDStringConstants.cs


public static readonly int _InvViewProjMatrix = Shader.PropertyToID("_InvViewProjMatrix");
public static readonly int _DetViewMatrix = Shader.PropertyToID("_DetViewMatrix");
public static readonly int _DepthBufferParams = Shader.PropertyToID("_DepthBufferParams");
public static readonly int _FrustumParams = Shader.PropertyToID("_FrustumParams");
public static readonly int _InvProjParam = Shader.PropertyToID("_InvProjParam");
public static readonly int _ScreenSize = Shader.PropertyToID("_ScreenSize");
public static readonly int _ScreenToTargetScale = Shader.PropertyToID("_ScreenToTargetScale");

6
ScriptableRenderPipeline/HDRenderPipeline/HDRP/ShaderVariables.hlsl


// w = 1/f
float4 _DepthBufferParams;
// x = near plane
// y = far plane
// z = orthographic camera's width (0 if perspective)
// w = orthographic camera's height (0 if perspective)
float4 _FrustumParams;
// TAA Frame Index ranges from 0 to 7. This gives you two rotations per cycle.
float4 _TaaFrameRotation; // { sin(taaFrame * PI/2), cos(taaFrame * PI/2), 0, 0 }

正在加载...
取消
保存