浏览代码

Unify SetupIntermediateResourcesSingle + SetupInter'ResourcesStereo

The code was mostly doing the same thing, but stereo was being left behind as features were added to SetupIntermediateResourcesSingle.  No longer!

There is some follow-up work to do.  Not all targets being allocated respect RenderScale. And we could probably cache off our generated RenderTextureDescriptor.
/lwrp-xr-sssm-DrawProc
Robert Srinivasiah 7 年前
当前提交
187beb91
共有 1 个文件被更改,包括 22 次插入42 次删除
  1. 64
      ScriptableRenderPipeline/LightweightPipeline/LWRP/LightweightPipeline.cs

64
ScriptableRenderPipeline/LightweightPipeline/LWRP/LightweightPipeline.cs


SetupShadowReceiverConstants(cmd, visibleLights[lightData.mainLightIndex]);
SetShadowCollectPassKeywords(cmd, visibleLights[lightData.mainLightIndex], ref lightData);
// TODO: Support RenderScale for the SSSM target. Should probably move allocation elsewhere, or at
// least propogate RenderTextureDescriptor generation
if (LightweightUtils.HasFlag(frameRenderingConfiguration, FrameRenderingConfiguration.Stereo))
{
var desc = XRSettings.eyeTextureDesc;

m_CurrCameraColorRT = BuiltinRenderTextureType.CameraTarget;
if (LightweightUtils.HasFlag(renderingConfig, FrameRenderingConfiguration.IntermediateTexture))
{
if (LightweightUtils.HasFlag(renderingConfig, FrameRenderingConfiguration.Stereo))
SetupIntermediateResourcesStereo(cmd, renderingConfig, msaaSamples);
else
SetupIntermediateResourcesSingle(cmd, renderingConfig, msaaSamples);
}
SetupIntermediateRenderTextures(cmd, renderingConfig, msaaSamples);
private void SetupIntermediateResourcesSingle(CommandBuffer cmd, FrameRenderingConfiguration renderingConfig, int msaaSamples)
private void SetupIntermediateRenderTextures(CommandBuffer cmd, FrameRenderingConfiguration renderingConfig, int msaaSamples)
RenderTextureDescriptor baseDesc;
if (LightweightUtils.HasFlag(renderingConfig, FrameRenderingConfiguration.Stereo))
baseDesc = XRSettings.eyeTextureDesc;
else
baseDesc = new RenderTextureDescriptor(m_CurrCamera.pixelWidth, m_CurrCamera.pixelHeight);
int rtWidth = (int)((float)m_CurrCamera.pixelWidth * renderScale);
int rtHeight = (int)((float)m_CurrCamera.pixelHeight * renderScale);
baseDesc.width = (int)((float)baseDesc.width * renderScale);
baseDesc.height = (int)((float)baseDesc.height * renderScale);
// TODO: Might be worth caching baseDesc for allocation of other targets (Screen-space Shadow Map?)
RenderTextureDescriptor depthRTDesc = new RenderTextureDescriptor(rtWidth, rtHeight, RenderTextureFormat.Depth, kDepthStencilBufferBits);
var depthRTDesc = baseDesc;
depthRTDesc.colorFormat = RenderTextureFormat.Depth;
depthRTDesc.depthBufferBits = kDepthStencilBufferBits;
cmd.GetTemporaryRT(CameraRenderTargetID.depth, depthRTDesc, FilterMode.Bilinear);
if (LightweightUtils.HasFlag(renderingConfig, FrameRenderingConfiguration.DepthCopy))

RenderTextureDescriptor colorRTDesc = new RenderTextureDescriptor(rtWidth, rtHeight, m_ColorFormat, kDepthStencilBufferBits);
var colorRTDesc = baseDesc;
colorRTDesc.colorFormat = m_ColorFormat;
colorRTDesc.depthBufferBits = kDepthStencilBufferBits; // TODO: does the color RT always need depth?
colorRTDesc.sRGB = true;
colorRTDesc.msaaSamples = msaaSamples;
colorRTDesc.enableRandomWrite = false;

// color RT to blit the effect.
if (m_RequireCopyColor)
cmd.GetTemporaryRT(CameraRenderTargetID.copyColor, colorRTDesc, FilterMode.Point);
}
private void SetupIntermediateResourcesStereo(CommandBuffer cmd, FrameRenderingConfiguration renderingConfig, int msaaSamples)
{
// TODO: support renderscale
// TODO: merge with SetupIntermediateResourcesSingle
var rtDesc = XRSettings.eyeTextureDesc;
if (m_RequireDepthTexture)
{
var depthRTDesc = rtDesc;
depthRTDesc.colorFormat = RenderTextureFormat.Depth;
depthRTDesc.depthBufferBits = kDepthStencilBufferBits;
//RenderTextureDescriptor depthRTDesc = new RenderTextureDescriptor(rtWidth, rtHeight, RenderTextureFormat.Depth, kDepthStencilBufferBits);
cmd.GetTemporaryRT(CameraRenderTargetID.depth, depthRTDesc, FilterMode.Bilinear);
if (LightweightUtils.HasFlag(renderingConfig, FrameRenderingConfiguration.DepthCopy))
cmd.GetTemporaryRT(CameraRenderTargetID.depthCopy, depthRTDesc, FilterMode.Bilinear);
}
//RenderTextureDescriptor rtDesc = new RenderTextureDescriptor();
rtDesc.sRGB = true;
rtDesc.colorFormat = m_ColorFormat;
rtDesc.msaaSamples = msaaSamples;
cmd.GetTemporaryRT(CameraRenderTargetID.color, rtDesc, FilterMode.Bilinear);
if (m_RequireCopyColor)
cmd.GetTemporaryRT(CameraRenderTargetID.copyColor, rtDesc, FilterMode.Point);
}
private void SetupShaderConstants(List<VisibleLight> visibleLights, ref ScriptableRenderContext context, ref LightData lightData)

正在加载...
取消
保存