浏览代码

Enable stereo RenderTexture paths

HDCamera manages the main descriptor, so make sure we create it correctly.
The pyramids need a bit of tweaking as well.
/feature-ReflectionProbeFit
Robert Srinivasiah 7 年前
当前提交
b777d288
共有 2 个文件被更改,包括 12 次插入12 次删除
  1. 8
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Camera/HDCamera.cs
  2. 16
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipeline.cs

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


Reset();
}
public void Update(PostProcessLayer postProcessLayer)
public void Update(PostProcessLayer postProcessLayer, bool stereoEnabled)
{
// If TAA is enabled projMatrix will hold a jittered projection matrix. The original,
// non-jittered projection matrix can be accessed via nonJitteredProjMatrix.

m_LastFrameActive = Time.frameCount;
RenderTextureDescriptor tempDesc;
if (false) // pass in FrameSettings.enablestereo
if (stereoEnabled)
{
screenSize = new Vector4(XRSettings.eyeTextureWidth, XRSettings.eyeTextureHeight, 1.0f / XRSettings.eyeTextureWidth, 1.0f / XRSettings.eyeTextureHeight);
tempDesc = XRSettings.eyeTextureDesc;

}
// Grab the HDCamera tied to a given Camera and update it.
public static HDCamera Get(Camera camera, PostProcessLayer postProcessLayer)
public static HDCamera Get(Camera camera, PostProcessLayer postProcessLayer, bool stereoEnabled)
{
HDCamera hdcam;

s_Cameras.Add(camera, hdcam);
}
hdcam.Update(postProcessLayer);
hdcam.Update(postProcessLayer, stereoEnabled);
return hdcam;
}

16
ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipeline.cs


}
var postProcessLayer = camera.GetComponent<PostProcessLayer>();
var hdCamera = HDCamera.Get(camera, postProcessLayer);
var hdCamera = HDCamera.Get(camera, postProcessLayer, m_FrameSettings.enableStereo);
Resize(hdCamera);

}
ConfigureForShadowMask(enableBakeShadowMask, cmd);
InitAndClearBuffer(hdCamera, enableBakeShadowMask, cmd);
InitAndClearBuffer(hdCamera, enableBakeShadowMask, cmd, m_FrameSettings.enableStereo);
RenderDepthPrepass(m_CullResults, hdCamera, renderContext, cmd);

}
}
void InitAndClearBuffer(HDCamera hdCamera, bool enableBakeShadowMask, CommandBuffer cmd)
void InitAndClearBuffer(HDCamera hdCamera, bool enableBakeShadowMask, CommandBuffer cmd, bool stereoEnabled)
{
using (new ProfilingSample(cmd, "InitAndClearBuffer", GetSampler(CustomSamplerId.InitAndClearBuffer)))
{

// Color and depth pyramids
m_GaussianPyramidColorBufferDesc = BuildPyramidDescriptor(hdCamera, PyramidType.Color);
m_GaussianPyramidColorBufferDesc = BuildPyramidDescriptor(hdCamera, PyramidType.Color, stereoEnabled);
m_DepthPyramidBufferDesc = BuildPyramidDescriptor(hdCamera, PyramidType.Depth);
m_DepthPyramidBufferDesc = BuildPyramidDescriptor(hdCamera, PyramidType.Depth, stereoEnabled);
cmd.ReleaseTemporaryRT(m_DepthPyramidBuffer);
cmd.GetTemporaryRT(m_DepthPyramidBuffer, m_DepthPyramidBufferDesc, FilterMode.Trilinear);

Depth = 1
}
static RenderTextureDescriptor BuildPyramidDescriptor(HDCamera hdCamera, PyramidType pyramidType )
static RenderTextureDescriptor BuildPyramidDescriptor(HDCamera hdCamera, PyramidType pyramidType, bool stereoEnabled)
{
var desc = hdCamera.renderTextureDesc;
desc.colorFormat = (pyramidType == PyramidType.Color) ? RenderTextureFormat.ARGBHalf : RenderTextureFormat.RFloat;

var pyramidSize = CalculatePyramidSize((int)hdCamera.screenSize.x, (int)hdCamera.screenSize.y);
// Gotta plug-in proper stereo bits from frame settings?
if (false /*hdCamera.stereoEnabled*/ && (desc.dimension != TextureDimension.Tex2DArray))
if (stereoEnabled && (desc.dimension != TextureDimension.Tex2DArray))
widthModifier = 2; // double-wide
desc.width = pyramidSize * widthModifier;

正在加载...
取消
保存