浏览代码

Fixed history buffer binding

/main
Frédéric Vauchelles 7 年前
当前提交
12acef66
共有 3 个文件被更改,包括 49 次插入9 次删除
  1. 6
      ScriptableRenderPipeline/Core/CoreRP/Textures/RTHandleSystem.RTHandle.cs
  2. 10
      ScriptableRenderPipeline/Core/CoreRP/Textures/RTHandleSystem.cs
  3. 42
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipeline.cs

6
ScriptableRenderPipeline/Core/CoreRP/Textures/RTHandleSystem.RTHandle.cs


internal Vector2 scaleFactor = Vector2.one;
internal ScaleFunc scaleFunc;
public bool useScaling { get; internal set; }
public bool useScaling { get; internal set; }
public Vector2Int referenceSize {get; internal set; }
public RenderTexture rt
{

{
var refRT = m_RTs[(int)RTCategory.MSAA];
Debug.Assert(refRT != null);
var scaledSize = GetScaledSize(new Vector2Int(m_Owner.maxWidthRegular, m_Owner.maxHeightRegular));
referenceSize = new Vector2Int(m_Owner.maxWidthRegular, m_Owner.maxHeightRegular);
var scaledSize = GetScaledSize(referenceSize);
var newRT = new RenderTexture(scaledSize.x, scaledSize.y, refRT.depth, refRT.format, refRT.sRGB ? RenderTextureReadWrite.sRGB : RenderTextureReadWrite.Linear)
{

10
ScriptableRenderPipeline/Core/CoreRP/Textures/RTHandleSystem.cs


continue;
var rt = rth.m_RTs[i];
var scaledSize = rth.GetScaledSize(new Vector2Int(m_MaxWidths[i], m_MaxHeights[i]));
rth.referenceSize = new Vector2Int(m_MaxWidths[i], m_MaxHeights[i]);
var scaledSize = rth.GetScaledSize(rth.referenceSize);
scaledSize = Vector2Int.Max(Vector2Int.one, scaledSize);
var enableMSAA = i == (int)RTCategory.MSAA;

if (enableMSAA)
rt.antiAliasing = (int)m_ScaledRTCurrentMSAASamples;
rt.width = scaledSize.x;
rt.height = scaledSize.y;
rt.name = CoreUtils.GetRenderTargetAutoName(
rt.width,

for (int i = 0, c = m_AutoSizedRTsArray.Length; i < c; ++i)
{
var rth = m_AutoSizedRTsArray[i];
rth.referenceSize = maxSize;
var rt = rth.m_RTs[(int)category];
// This can happen if you create a RTH for MSAA. By default we only create the MSAA version of the target.

rt.Release();
Vector2Int scaledSize = rth.GetScaledSize(maxSize);
var scaledSize = rth.GetScaledSize(maxSize);
rt.width = Mathf.Max(scaledSize.x, 1);
rt.height = Mathf.Max(scaledSize.y, 1);

42
ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipeline.cs


var previousDepthPyramidRT = hdCamera.GetPreviousFrameRT((int)HDCameraFrameHistoryType.DepthPyramid);
if (previousDepthPyramidRT != null)
{
cmd.SetGlobalVector(HDShaderIDs._DepthPyramidSize, new Vector4(
previousDepthPyramidRT.referenceSize.x,
previousDepthPyramidRT.referenceSize.y,
1f / previousDepthPyramidRT.referenceSize.x,
1f / previousDepthPyramidRT.referenceSize.y
));
cmd.SetGlobalVector(HDShaderIDs._DepthPyramidScale, new Vector4(
previousDepthPyramidRT.referenceSize.x / (float)previousDepthPyramidRT.rt.width,
previousDepthPyramidRT.referenceSize.y / (float)previousDepthPyramidRT.rt.height,
Mathf.Log(Mathf.Min(previousDepthPyramidRT.rt.width, previousDepthPyramidRT.rt.height), 2),
0.0f
));
}
{
cmd.SetGlobalVector(HDShaderIDs._ColorPyramidSize, new Vector4(
previousColorPyramidRT.referenceSize.x,
previousColorPyramidRT.referenceSize.y,
1f / previousColorPyramidRT.referenceSize.x,
1f / previousColorPyramidRT.referenceSize.y
));
cmd.SetGlobalVector(HDShaderIDs._ColorPyramidScale, new Vector4(
previousColorPyramidRT.referenceSize.x / (float)previousColorPyramidRT.rt.width,
previousColorPyramidRT.referenceSize.y / (float)previousColorPyramidRT.rt.height,
Mathf.Log(Mathf.Min(previousColorPyramidRT.rt.width, previousColorPyramidRT.rt.height), 2),
0.0f
));
}
}
}

m_DebugScreenSpaceTracingData.GetData(m_DebugScreenSpaceTracingDataArray);
var data = m_DebugScreenSpaceTracingDataArray[0];
m_CurrentDebugDisplaySettings.screenSpaceTracingDebugData = data;
// Assign -1 in tracing model to notifiy we took the data.
// When debugging in forward, we want only the first time the pixel is drawn
data.tracingModel = (Lit.SSRayModel)(-1);
m_DebugScreenSpaceTracingDataArray[0] = data;
m_DebugScreenSpaceTracingData.SetData(m_DebugScreenSpaceTracingDataArray);
}
} // For each camera
}

{
case ForwardPass.Opaque:
{
var bindIndex = 0;
// In case of forward SSS we will bind all the required target. It is up to the shader to write into it or not.
if (m_FrameSettings.enableSubsurfaceScattering)
{

}
HDUtils.SetRenderTarget(cmd, hdCamera, m_MRTWithSSS, m_CameraDepthStencilBuffer);
bindIndex += m_MRTWithSSS.Length;
++bindIndex;
}
m_ForwardAndForwardOnlyPassNames[0] = m_ForwardOnlyPassNames[0] =

if (debugSSTThisPass)
{
cmd.SetGlobalBuffer(HDShaderIDs._DebugScreenSpaceTracingData, m_DebugScreenSpaceTracingData);
cmd.SetRandomWriteTarget(bindIndex, m_DebugScreenSpaceTracingData);
cmd.SetRandomWriteTarget(7, m_DebugScreenSpaceTracingData);
}
RenderOpaqueRenderList(cullResults, camera, renderContext, cmd, passNames, m_currentRendererConfigurationBakedLighting);
if (debugSSTThisPass)

if (debugSSTThisPass)
{
cmd.SetGlobalBuffer(HDShaderIDs._DebugScreenSpaceTracingData, m_DebugScreenSpaceTracingData);
cmd.SetRandomWriteTarget(1, m_DebugScreenSpaceTracingData);
cmd.SetRandomWriteTarget(7, m_DebugScreenSpaceTracingData);
}
RenderTransparentRenderList(cullResults, camera, renderContext, cmd, m_AllTransparentPassNames, m_currentRendererConfigurationBakedLighting, pass == ForwardPass.PreRefraction ? HDRenderQueue.k_RenderQueue_PreRefraction : HDRenderQueue.k_RenderQueue_Transparent);
if (debugSSTThisPass)

正在加载...
取消
保存