比较提交

...
此合并请求有变更与目标分支冲突。
/ScriptableRenderPipeline/HDRenderPipeline/Camera/HDCamera.cs
/ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipelineAsset.asset
/ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs
/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.cs
/ScriptableRenderPipeline/HDRenderPipeline/Lighting/Volumetrics/VolumetricLighting.cs
/ScriptableRenderPipeline/HDRenderPipeline/Sky/SkyManager.cs
/ScriptableRenderPipeline/HDRenderPipeline/Editor/HDRenderPipelineInspector.Styles.cs
/ScriptableRenderPipeline/HDRenderPipeline/Editor/HDRenderPipelineInspector.cs

3 次代码提交

作者 SHA1 备注 提交日期
Robert Srinivasiah 27b4f37f WIP of RT prototype 7 年前
Robert Srinivasiah 1cae2f94 Add master stereo disable switch to HDRP 7 年前
Robert Srinivasiah 7998bfa7 Merge remote-tracking branch 'origin/master' into xr-hdrp 7 年前
共有 9 个文件被更改,包括 199 次插入60 次删除
  1. 1
      ScriptableRenderPipeline/HDRenderPipeline/Editor/HDRenderPipelineInspector.Styles.cs
  2. 4
      ScriptableRenderPipeline/HDRenderPipeline/Editor/HDRenderPipelineInspector.cs
  3. 24
      ScriptableRenderPipeline/HDRenderPipeline/Camera/HDCamera.cs
  4. 197
      ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs
  5. 3
      ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipelineAsset.asset
  6. 11
      ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.cs
  7. 8
      ScriptableRenderPipeline/HDRenderPipeline/Lighting/Volumetrics/VolumetricLighting.cs
  8. 1
      ScriptableRenderPipeline/HDRenderPipeline/Sky/SkyManager.cs
  9. 10
      SampleScenes/HDTest/GraphicTest/Common/Prefabs/Refraction ThinPlane Clear Dragon.prefab.meta

1
ScriptableRenderPipeline/HDRenderPipeline/Editor/HDRenderPipelineInspector.Styles.cs


public readonly GUIContent useForwardRenderingOnly = new GUIContent("Use Forward Rendering Only");
public readonly GUIContent useDepthPrepassWithDeferredRendering = new GUIContent("Use Depth Prepass with Deferred rendering");
public readonly GUIContent renderAlphaTestOnlyInDeferredPrepass = new GUIContent("Alpha Test Only");
public readonly GUIContent disableStereoPaths = new GUIContent("Disable Stereo Paths");
// Texture Settings
public readonly GUIContent textureSettings = new GUIContent("Texture Settings");

4
ScriptableRenderPipeline/HDRenderPipeline/Editor/HDRenderPipelineInspector.cs


SerializedProperty m_RenderingUseForwardOnly;
SerializedProperty m_RenderingUseDepthPrepass;
SerializedProperty m_RenderingUseDepthPrepassAlphaTestOnly;
SerializedProperty m_RenderingDisableStereoPaths;
// Subsurface Scattering Settings
SerializedProperty m_SubsurfaceScatteringSettings;

m_RenderingUseForwardOnly = properties.Find(x => x.renderingSettings.useForwardRenderingOnly);
m_RenderingUseDepthPrepass = properties.Find(x => x.renderingSettings.useDepthPrepassWithDeferredRendering);
m_RenderingUseDepthPrepassAlphaTestOnly = properties.Find(x => x.renderingSettings.renderAlphaTestOnlyInDeferredPrepass);
m_RenderingDisableStereoPaths = properties.Find(x => x.renderingSettings.disableStereoPaths);
// Subsurface Scattering Settings
m_SubsurfaceScatteringSettings = properties.Find(x => x.sssSettings);

EditorGUI.indentLevel--;
}
}
EditorGUILayout.PropertyField(m_RenderingDisableStereoPaths, s_Styles.disableStereoPaths);
EditorGUI.indentLevel--;
}

24
ScriptableRenderPipeline/HDRenderPipeline/Camera/HDCamera.cs


using System.Collections.Generic;
using UnityEngine.Rendering;
using UnityEngine.Rendering.PostProcessing;
using UnityEngine.XR;
namespace UnityEngine.Experimental.Rendering.HDPipeline
{

public Matrix4x4 projMatrix;
public Matrix4x4 nonJitteredProjMatrix;
public Vector4 screenSize;
public Vector2 textureSize;
public RenderTextureDescriptor rtDesc;
public bool stereoActive;
public Camera camera;
public Matrix4x4 viewProjMatrix

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

projMatrix = gpuProj;
nonJitteredProjMatrix = gpuNonJitteredProj;
cameraPos = pos;
screenSize = new Vector4(camera.pixelWidth, camera.pixelHeight, 1.0f / camera.pixelWidth, 1.0f / camera.pixelHeight);
if (stereoEnabled == true)
{
screenSize = new Vector4(XRSettings.eyeTextureWidth, XRSettings.eyeTextureHeight, 1.0f / XRSettings.eyeTextureWidth, 1.0f / XRSettings.eyeTextureHeight);
rtDesc = XRSettings.eyeTextureDesc;
}
else
{
screenSize = new Vector4(camera.pixelWidth, camera.pixelHeight, 1.0f / camera.pixelWidth, 1.0f / camera.pixelHeight);
rtDesc = new RenderTextureDescriptor(camera.pixelWidth, camera.pixelHeight);
}
textureSize = new Vector4(rtDesc.width, rtDesc.height);
stereoActive = stereoEnabled;
GeometryUtility.CalculateFrustumPlanes(viewProjMatrix, frustumPlanes);

}
// 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 = false)
{
HDCamera hdcam;

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

197
ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs


public bool useForwardRenderingOnly; // TODO: Currently there is no way to strip the extra forward shaders generated by the shaders compiler, so we can switch dynamically.
public bool useDepthPrepassWithDeferredRendering;
public bool renderAlphaTestOnlyInDeferredPrepass;
public bool disableStereoPaths;
// We have to fall back to forward-only rendering when scene view is using wireframe rendering mode --
// as rendering everything in wireframe + deferred do not play well together

for (int index = 0; index < gbufferCount; index++)
{
cmd.GetTemporaryRT(m_IDs[index], width, height, 0, FilterMode.Point, m_Formats[index], m_sRGBWrites[index]);
}
}
public void InitGBuffers(RenderTextureDescriptor rtDesc, CommandBuffer cmd)
{
rtDesc.depthBufferBits = 0;
for (int index = 0; index < gbufferCount; index++)
{
rtDesc.colorFormat = m_Formats[index];
rtDesc.sRGB = (m_sRGBWrites[index] != RenderTextureReadWrite.Linear);
// maybe turn off AA if requested
cmd.GetTemporaryRT(m_IDs[index], rtDesc, FilterMode.Point);
}
}

}
}
public void GetTempRT(CommandBuffer cmd, int widthOverride = 0, int heightOverride = 0)
{
}
public HDRenderPipeline(HDRenderPipelineAsset asset)
{
m_Asset = asset;

};
#endif
void CreateDepthStencilBuffer(Camera camera)
//void CreateDepthStencilBuffer(Camera camera)
void CreateDepthStencilBuffer(HDCamera hdCam)
m_CameraDepthStencilBuffer = new RenderTexture(camera.pixelWidth, camera.pixelHeight, 24, RenderTextureFormat.Depth);
var localDesc = hdCam.rtDesc;
//m_CameraDepthStencilBuffer = new RenderTexture(camera.pixelWidth, camera.pixelHeight, 24, RenderTextureFormat.Depth);
localDesc.colorFormat = RenderTextureFormat.Depth;
localDesc.depthBufferBits = 24;
// enable SRGB?
m_CameraDepthStencilBuffer = new RenderTexture(localDesc);
m_CameraDepthStencilBuffer.filterMode = FilterMode.Point;
m_CameraDepthStencilBuffer.Create();
m_CameraDepthStencilBufferRT = new RenderTargetIdentifier(m_CameraDepthStencilBuffer);

if (m_CameraDepthBufferCopy != null)
m_CameraDepthBufferCopy.Release();
m_CameraDepthBufferCopy = new RenderTexture(camera.pixelWidth, camera.pixelHeight, 24, RenderTextureFormat.Depth);
//m_CameraDepthBufferCopy = new RenderTexture(camera.pixelWidth, camera.pixelHeight, 24, RenderTextureFormat.Depth);
m_CameraDepthBufferCopy = new RenderTexture(localDesc);
m_CameraDepthBufferCopy.filterMode = FilterMode.Point;
m_CameraDepthBufferCopy.Create();
m_CameraDepthBufferCopyRT = new RenderTargetIdentifier(m_CameraDepthBufferCopy);

if (m_CameraStencilBufferCopy != null)
m_CameraStencilBufferCopy.Release();
m_CameraStencilBufferCopy = new RenderTexture(camera.pixelWidth, camera.pixelHeight, 0, RenderTextureFormat.R8, RenderTextureReadWrite.Linear); // DXGI_FORMAT_R8_UINT is not supported by Unity
//m_CameraStencilBufferCopy = new RenderTexture(camera.pixelWidth, camera.pixelHeight, 0, RenderTextureFormat.R8, RenderTextureReadWrite.Linear); // DXGI_FORMAT_R8_UINT is not supported by Unity
localDesc.colorFormat = RenderTextureFormat.R8;
localDesc.sRGB = false;
localDesc.depthBufferBits = 0;
m_CameraStencilBufferCopy = new RenderTexture(localDesc); // DXGI_FORMAT_R8_UINT is not supported by Unity
m_CameraStencilBufferCopy.filterMode = FilterMode.Point;
m_CameraStencilBufferCopy.Create();
m_CameraStencilBufferCopyRT = new RenderTargetIdentifier(m_CameraStencilBufferCopy);

m_HTile.Release();
// We use 8x8 tiles in order to match the native GCN HTile as closely as possible.
m_HTile = new RenderTexture((camera.pixelWidth + 7) / 8, (camera.pixelHeight + 7) / 8, 0, RenderTextureFormat.R8, RenderTextureReadWrite.Linear); // DXGI_FORMAT_R8_UINT is not supported by Unity
//m_HTile = new RenderTexture((camera.pixelWidth + 7) / 8, (camera.pixelHeight + 7) / 8, 0, RenderTextureFormat.R8, RenderTextureReadWrite.Linear); // DXGI_FORMAT_R8_UINT is not supported by Unity
localDesc.colorFormat = RenderTextureFormat.R8;
localDesc.sRGB = false;
localDesc.depthBufferBits = 0;
localDesc.width = (localDesc.width + 7) / 8;
localDesc.height = (localDesc.height + 7) / 8;
m_HTile = new RenderTexture(localDesc); // DXGI_FORMAT_R8_UINT is not supported by Unity
m_HTile.filterMode = FilterMode.Point;
m_HTile.enableRandomWrite = true;
m_HTile.Create();

}
void Resize(Camera camera)
void Resize(HDCamera hdCam)
{
// TODO: Detect if renderdoc just load and force a resize in this case, as often renderdoc require to realloc resource.

m_SkyManager.skySettings = skySettingsToUse;
m_SkyManager.Resize(camera.nearClipPlane, camera.farClipPlane); // TODO: Also a bad naming, here we just want to realloc texture if skyparameters change (useful for lookdev)
m_SkyManager.Resize(hdCam.camera.nearClipPlane, hdCam.camera.farClipPlane); // TODO: Also a bad naming, here we just want to realloc texture if skyparameters change (useful for lookdev)
int camTexWidth = (int)hdCam.textureSize.x;
int camTexHeight = (int)hdCam.textureSize.y;
bool resolutionChanged = camera.pixelWidth != m_CurrentWidth || camera.pixelHeight != m_CurrentHeight;
//bool resolutionChanged = hdCam.camera.pixelWidth != m_CurrentWidth || hdCam.camera.pixelHeight != m_CurrentHeight;
bool resolutionChanged = camTexWidth != m_CurrentWidth || camTexHeight != m_CurrentHeight;
CreateDepthStencilBuffer(camera);
CreateDepthStencilBuffer(hdCam); // XRTODO
//CreateDepthStencilBuffer(hdCam.camera);
if (resolutionChanged || m_LightLoop.NeedResize())
{

m_LightLoop.AllocResolutionDependentBuffers(camera.pixelWidth, camera.pixelHeight);
//m_LightLoop.AllocResolutionDependentBuffers(hdCam.camera.pixelWidth, hdCam.camera.pixelHeight);
// XRTODO: pass in descriptor
//m_LightLoop.AllocResolutionDependentBuffers(camTexWidth, camTexWidth);
m_LightLoop.AllocResolutionDependentBuffers((int)hdCam.screenSize.x, (int)hdCam.screenSize.y);
CreateVolumetricLightingBuffers(camera.pixelWidth, camera.pixelHeight);
CreateVolumetricLightingBuffers(camTexWidth, camTexHeight); // XRTODO: fix up for XR
//CreateVolumetricLightingBuffers(hdCam.camera.pixelWidth, hdCam.camera.pixelHeight);
m_CurrentWidth = camera.pixelWidth;
m_CurrentHeight = camera.pixelHeight;
//m_CurrentWidth = hdCam.camera.pixelWidth;
//m_CurrentHeight = hdCam.camera.pixelHeight;
m_CurrentWidth = camTexWidth;
m_CurrentHeight = camTexHeight;
}
public void PushGlobalParams(HDCamera hdCamera, CommandBuffer cmd, SubsurfaceScatteringSettings sssParameters)

m_FrameCount = Time.frameCount;
}
bool stereoEnabled = UnityEngine.XR.XRSettings.isDeviceActive && !m_Asset.renderingSettings.disableStereoPaths;
if (stereoEnabled)
{
m_VolumetricLightingEnabled = false; // XRTODO: Implement VL
}
var mainProfilingSample = new ProfilingSample(cmd, "HDRP");
foreach (var material in m_MaterialList)
material.RenderInit(cmd);

UpdateCommonSettings();
ScriptableCullingParameters cullingParams;
if (!CullResults.GetCullingParameters(camera, out cullingParams))
//if (!CullResults.GetCullingParameters(camera, out cullingParams))
if (!CullResults.GetCullingParameters(camera, stereoEnabled, out cullingParams))
{
renderContext.Submit();
return;

CullResults.Cull(ref cullingParams, renderContext,ref m_CullResults);
Resize(camera);
var postProcessLayer = camera.GetComponent<PostProcessLayer>();
var hdCamera = HDCamera.Get(camera, postProcessLayer, stereoEnabled);
renderContext.SetupCameraProperties(camera);
Resize(hdCamera);
var postProcessLayer = camera.GetComponent<PostProcessLayer>();
var hdCamera = HDCamera.Get(camera, postProcessLayer);
//renderContext.SetupCameraProperties(camera);
renderContext.SetupCameraProperties(camera, stereoEnabled);
//var postProcessLayer = camera.GetComponent<PostProcessLayer>();
//var hdCamera = HDCamera.Get(camera, postProcessLayer);
PushGlobalParams(hdCamera, cmd, sssSettings);
// TODO: Find a correct place to bind these material textures

using (new ProfilingSample(cmd, "Forward"))
{
// TODO: BUG Shouldn't this be after InitAndClearBuffer? m_CameraColorBufferRT isn't set yet...
// I guess this might work because of how identifiers work, but it looks janky
CoreUtils.SetRenderTarget(cmd, m_CameraColorBufferRT, m_CameraDepthStencilBufferRT, ClearFlag.Color | ClearFlag.Depth);
RenderOpaqueRenderList(m_CullResults, camera, renderContext, cmd, HDShaderPassNames.s_ForwardName);
RenderTransparentRenderList(m_CullResults, camera, renderContext, cmd, HDShaderPassNames.s_ForwardName);

// In both forward and deferred, everything opaque should have been rendered at this point so we can safely copy the depth buffer for later processing.
CopyDepthBufferIfNeeded(cmd);
RenderPyramidDepth(camera, cmd, renderContext, FullScreenDebugMode.DepthPyramid);
//RenderPyramidDepth(camera, cmd, renderContext, FullScreenDebugMode.DepthPyramid);
RenderPyramidDepth(hdCamera, cmd, renderContext, FullScreenDebugMode.DepthPyramid);
// Required for the SSS and the shader feature classification pass.
PrepareAndBindStencilTexture(cmd);

if (settings.IsEnabledAndSupported(null))
{
// XRTODO: Fix
// MSVO doesn't work for XR currently
cmd.GetTemporaryRT(HDShaderIDs._AmbientOcclusionTexture, new RenderTextureDescriptor(camera.pixelWidth, camera.pixelHeight, RenderTextureFormat.R8, 0)
{
sRGB = false,

m_LightLoop.PrepareLightsForGPU(m_ShadowSettings, m_CullResults, camera);
m_LightLoop.RenderShadows(renderContext, cmd, m_CullResults);
cmd.GetTemporaryRT(m_DeferredShadowBuffer, camera.pixelWidth, camera.pixelHeight, 0, FilterMode.Point, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear, 1 , true);
//cmd.GetTemporaryRT(m_DeferredShadowBuffer, camera.pixelWidth, camera.pixelHeight, 0, FilterMode.Point, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear, 1 , true);
cmd.GetTemporaryRT(m_DeferredShadowBuffer, (int)hdCamera.textureSize.x, (int)hdCamera.textureSize.y, 0, FilterMode.Point, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear, 1 , true);
renderContext.SetupCameraProperties(camera); // Need to recall SetupCameraProperties after m_ShadowPass.Render
//renderContext.SetupCameraProperties(camera); // Need to recall SetupCameraProperties after m_ShadowPass.Render
renderContext.SetupCameraProperties(camera, stereoEnabled); // Need to recall SetupCameraProperties after m_ShadowPass.Render
// XRTODO: Big time fix :p
m_LightLoop.BuildGPULightLists(camera, cmd, m_CameraDepthStencilBufferRT, GetStencilTexture());
}

RenderForward(m_CullResults, camera, renderContext, cmd, ForwardPass.PreRefraction);
RenderForwardError(m_CullResults, camera, renderContext, cmd, ForwardPass.PreRefraction);
RenderGaussianPyramidColor(camera, cmd, renderContext, FullScreenDebugMode.PreRefractionColorPyramid);
//RenderGaussianPyramidColor(camera, cmd, renderContext, FullScreenDebugMode.PreRefractionColorPyramid);
// XRTODO: Properly fix
RenderGaussianPyramidColor(hdCamera, cmd, renderContext, FullScreenDebugMode.PreRefractionColorPyramid);
// Render all type of transparent forward (unlit, lit, complex (hair...)) to keep the sorting between transparent objects.
RenderForward(m_CullResults, camera, renderContext, cmd, ForwardPass.Transparent);

// XRTODO: Should this be gated my m_VolumetricLightingEnabled?
VolumetricLightingPass(hdCamera, cmd);
PushFullScreenDebugTexture(cmd, m_CameraColorBuffer, camera, renderContext, FullScreenDebugMode.NanTracker);

{
RenderVelocity(m_CullResults, hdCamera, renderContext, cmd); // Note we may have to render velocity earlier if we do temporalAO, temporal volumetric etc... Mean we will not take into account forward opaque in case of deferred rendering ?
RenderGaussianPyramidColor(camera, cmd, renderContext, FullScreenDebugMode.FinalColorPyramid);
//RenderGaussianPyramidColor(camera, cmd, renderContext, FullScreenDebugMode.FinalColorPyramid);
RenderGaussianPyramidColor(hdCamera, cmd, renderContext, FullScreenDebugMode.FinalColorPyramid);
AccumulateDistortion(m_CullResults, camera, renderContext, cmd);
AccumulateDistortion(m_CullResults, hdCamera, renderContext, cmd);
RenderDistortion(cmd, m_Asset.renderPipelineResources);
RenderPostProcesses(camera, cmd, postProcessLayer);

cmd.SetRenderTarget(BuiltinRenderTextureType.CameraTarget, m_CameraDepthStencilBufferRT);
#endif
if (stereoEnabled)
renderContext.StereoEndRender(camera);
mainProfilingSample.Dispose();
renderContext.ExecuteCommandBuffer(cmd);
CommandBufferPool.Release(cmd);
renderContext.Submit();

renderContext.DrawRenderers(cull.visibleRenderers, ref drawSettings, filterSettings, stateBlock.Value);
}
void AccumulateDistortion(CullResults cullResults, Camera camera, ScriptableRenderContext renderContext, CommandBuffer cmd)
//void AccumulateDistortion(CullResults cullResults, Camera camera, ScriptableRenderContext renderContext, CommandBuffer cmd)
void AccumulateDistortion(CullResults cullResults, HDCamera camera, ScriptableRenderContext renderContext, CommandBuffer cmd)
{
if (!m_CurrentDebugDisplaySettings.renderingDebugSettings.enableDistortion)
return;

int w = camera.pixelWidth;
int h = camera.pixelHeight;
//int w = camera.pixelWidth;
//int h = camera.pixelHeight;
// XRTODO: proper fix
int w = (int)camera.textureSize.x;
int h = (int)camera.textureSize.y;
cmd.GetTemporaryRT(m_DistortionBuffer, w, h, 0, FilterMode.Point, Builtin.GetDistortionBufferFormat(), Builtin.GetDistortionBufferReadWrite());
cmd.SetRenderTarget(m_DistortionBufferRT, m_CameraDepthStencilBufferRT);

RenderTransparentRenderList(cullResults, camera, renderContext, cmd, HDShaderPassNames.s_DistortionVectorsName, preRefractionQueue:true);
RenderTransparentRenderList(cullResults, camera, renderContext, cmd, HDShaderPassNames.s_DistortionVectorsName);
//RenderTransparentRenderList(cullResults, camera, renderContext, cmd, HDShaderPassNames.s_DistortionVectorsName, preRefractionQueue:true);
//RenderTransparentRenderList(cullResults, camera, renderContext, cmd, HDShaderPassNames.s_DistortionVectorsName);
RenderTransparentRenderList(cullResults, camera.camera, renderContext, cmd, HDShaderPassNames.s_DistortionVectorsName, preRefractionQueue: true);
RenderTransparentRenderList(cullResults, camera.camera, renderContext, cmd, HDShaderPassNames.s_DistortionVectorsName);
}
}

cmd.SetComputeTextureParam(m_SubsurfaceScatteringCS, m_SubsurfaceScatteringKernel, HDShaderIDs._CameraFilteringBuffer, m_CameraFilteringBufferRT);
// Perform the SSS filtering pass which fills 'm_CameraFilteringBufferRT'.
// TODO: If stereo get supported, has to be performed over both eyes
cmd.DispatchCompute(m_SubsurfaceScatteringCS, m_SubsurfaceScatteringKernel, ((int)hdCamera.screenSize.x + 15) / 16, ((int)hdCamera.screenSize.y + 15) / 16, 1);
cmd.SetGlobalTexture(HDShaderIDs._IrradianceSource, m_CameraFilteringBufferRT); // Cannot set a RT on a material

// If the flag hasn't been set yet on this camera, motion vectors will skip a frame.
hdcam.camera.depthTextureMode |= DepthTextureMode.MotionVectors | DepthTextureMode.Depth;
int w = (int)hdcam.screenSize.x;
int h = (int)hdcam.screenSize.y;
// XRTODO: proper fix
int w = (int)hdcam.textureSize.x;
int h = (int)hdcam.textureSize.y;
m_CameraMotionVectorsMaterial.SetVector(HDShaderIDs._CameraPosDiff, hdcam.prevCameraPos - hdcam.cameraPos);

}
}
void RenderGaussianPyramidColor(Camera camera, CommandBuffer cmd, ScriptableRenderContext renderContext, FullScreenDebugMode debugMode)
void RenderGaussianPyramidColor(HDCamera camera, CommandBuffer cmd, ScriptableRenderContext renderContext, FullScreenDebugMode debugMode)
{
if (!m_CurrentDebugDisplaySettings.renderingDebugSettings.enableGaussianPyramid)
return;

int w = camera.pixelWidth;
int h = camera.pixelHeight;
//int w = camera.pixelWidth;
//int h = camera.pixelHeight;
int w = (int)camera.textureSize.x;
int h = (int)camera.textureSize.y;
int size = CalculatePyramidSize(w, h);
// The gaussian pyramid compute works in blocks of 8x8 so make sure the last lod has a

}
}
void RenderPyramidDepth(Camera camera, CommandBuffer cmd, ScriptableRenderContext renderContext, FullScreenDebugMode debugMode)
void RenderPyramidDepth(HDCamera camera, CommandBuffer cmd, ScriptableRenderContext renderContext, FullScreenDebugMode debugMode)
{
if (!m_CurrentDebugDisplaySettings.renderingDebugSettings.enableGaussianPyramid)
return;

int w = camera.pixelWidth;
int h = camera.pixelHeight;
// TODO: This code should be turned into a method to be shared with InitAndClearBuffer
// where the output depth pyramid is allocated
//int w = camera.pixelWidth;
//int h = camera.pixelHeight;
int w = (int)camera.textureSize.x;
int h = (int)camera.textureSize.y;
int size = CalculatePyramidSize(w, h);
// The gaussian pyramid compute works in blocks of 8x8 so make sure the last lod has a

cmd.SetGlobalVector(HDShaderIDs._DepthPyramidMipSize, new Vector4(size, size, lodCount, 0));
// XRTODO: Fix
cmd.GetTemporaryRT(HDShaderIDs._DepthPyramidMips[0], size, size, 0, FilterMode.Bilinear, RenderTextureFormat.RFloat, RenderTextureReadWrite.Linear, 1, true);
m_GPUCopy.SampleCopyChannel_xyzw2x(cmd, GetDepthTexture(), HDShaderIDs._DepthPyramidMips[0], new Vector2(size, size));
cmd.CopyTexture(HDShaderIDs._DepthPyramidMips[0], 0, 0, m_DepthPyramidBuffer, 0, 0);

{
mipSize >>= 1;
// XRTODO: Fix
cmd.GetTemporaryRT(HDShaderIDs._DepthPyramidMips[i + 1], mipSize, mipSize, 0, FilterMode.Bilinear, RenderTextureFormat.RFloat, RenderTextureReadWrite.Linear, 1, true);
cmd.SetComputeTextureParam(m_DepthPyramidCS, m_DepthPyramidKernel, "_Source", HDShaderIDs._DepthPyramidMips[i]);
cmd.SetComputeTextureParam(m_DepthPyramidCS, m_DepthPyramidKernel, "_Result", HDShaderIDs._DepthPyramidMips[i + 1]);

if (debugMode == m_CurrentDebugDisplaySettings.fullScreenDebugMode)
{
m_FullScreenDebugPushed = true; // We need this flag because otherwise if no fullscreen debug is pushed, when we render the result in RenderDebug the temporary RT will not exist.
// XRTODO: Fix
cb.GetTemporaryRT(m_DebugFullScreenTempRT, camera.pixelWidth, camera.pixelHeight, 0, FilterMode.Point, RenderTextureFormat.ARGBHalf, RenderTextureReadWrite.Linear);
cb.Blit(textureID, m_DebugFullScreenTempRT);
}

if (debugMode == m_CurrentDebugDisplaySettings.fullScreenDebugMode)
{
m_FullScreenDebugPushed = true; // We need this flag because otherwise if no fullscreen debug is pushed, when we render the result in RenderDebug the temporary RT will not exist.
// XRTODO: Fix
cmd.GetTemporaryRT(m_DebugFullScreenTempRT, width >> mipIndex, height >> mipIndex, 0, FilterMode.Point, RenderTextureFormat.RFloat, RenderTextureReadWrite.Linear);
cmd.CopyTexture(textureID, 0, mipIndex, m_DebugFullScreenTempRT, 0, 0);
}

// Then overlays
float x = 0;
float overlayRatio = m_CurrentDebugDisplaySettings.debugOverlayRatio;
// XRTODO: Maybe this stays, gotta fix
//float overlaySize = Math.Min(camera.camera.pixelHeight, camera.camera.pixelWidth) * overlayRatio;
float overlaySize = Math.Min(camera.camera.pixelHeight, camera.camera.pixelWidth) * overlayRatio;
float y = camera.camera.pixelHeight - overlaySize;

// Also we manage ourself the HDR format, here allocating fp16 directly.
// With scriptable render loop we can allocate temporary RT in a command buffer, they will not be release with ExecuteCommandBuffer
// These temporary surface are release automatically at the end of the scriptable render pipeline if not release explicitly
int w = camera.camera.pixelWidth;
int h = camera.camera.pixelHeight;
//int w = camera.camera.pixelWidth;
//int h = camera.camera.pixelHeight;
int w = (int)camera.textureSize.x;
int h = (int)camera.textureSize.y;
cmd.GetTemporaryRT(m_CameraColorBuffer, w, h, 0, FilterMode.Point, RenderTextureFormat.ARGBHalf, RenderTextureReadWrite.Linear, 1, true); // Enable UAV
cmd.GetTemporaryRT(m_CameraSssDiffuseLightingBuffer, w, h, 0, FilterMode.Point, RenderTextureFormat.RGB111110Float, RenderTextureReadWrite.Linear, 1, true); // Enable UAV
cmd.GetTemporaryRT(m_CameraFilteringBuffer, w, h, 0, FilterMode.Point, RenderTextureFormat.RGB111110Float, RenderTextureReadWrite.Linear, 1, true); // Enable UAV
var localDesc = camera.rtDesc;
//cmd.GetTemporaryRT(m_CameraColorBuffer, w, h, 0, FilterMode.Point, RenderTextureFormat.ARGBHalf, RenderTextureReadWrite.Linear, 1, true); // Enable UAV
//cmd.GetTemporaryRT(m_CameraSssDiffuseLightingBuffer, w, h, 0, FilterMode.Point, RenderTextureFormat.RGB111110Float, RenderTextureReadWrite.Linear, 1, true); // Enable UAV
//cmd.GetTemporaryRT(m_CameraFilteringBuffer, w, h, 0, FilterMode.Point, RenderTextureFormat.RGB111110Float, RenderTextureReadWrite.Linear, 1, true); // Enable UAV
localDesc.colorFormat = RenderTextureFormat.ARGBHalf;
localDesc.depthBufferBits = 0;
localDesc.sRGB = false;
localDesc.msaaSamples = 1;
localDesc.enableRandomWrite = true;
cmd.GetTemporaryRT(m_CameraColorBuffer, localDesc, FilterMode.Point); // Enable UAV
localDesc.colorFormat = RenderTextureFormat.RGB111110Float;
cmd.GetTemporaryRT(m_CameraSssDiffuseLightingBuffer, localDesc, FilterMode.Point); // Enable UAV
cmd.GetTemporaryRT(m_CameraFilteringBuffer, localDesc, FilterMode.Point); // Enable UAV
// XRTODO: Fix this up for stereo
int s = CalculatePyramidSize(w, h);
m_GaussianPyramidColorBufferDesc.width = s;
m_GaussianPyramidColorBufferDesc.height = s;

3
ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipelineAsset.asset


m_RenderPipelineResources: {fileID: 11400000, guid: 42086e81f4f0c724f96f7f09cc995354,
type: 2}
renderingSettings:
useForwardRenderingOnly: 0
useForwardRenderingOnly: 1
disableStereoPaths: 0
sssSettings: {fileID: 11400000, guid: 873499ce7a6f749408981f512a9683f7, type: 2}
tileSettings:
enableTileAndCluster: 1

11
ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.cs


return 8 * (1 << k_Log2NumClusters); // total footprint for all layers of the tile (measured in light index entries)
}
// XRTODO: Plumb this for stereo. First pass will be to double the tiles,
// second pass will be to unify the tiles
public void AllocResolutionDependentBuffers(int width, int height)
{
var nrTilesX = (width + LightDefinitions.s_TileSizeFptl - 1) / LightDefinitions.s_TileSizeFptl;

public void RenderDeferredDirectionalShadow(HDCamera hdCamera, RenderTargetIdentifier deferredShadowRT, RenderTargetIdentifier depthTexture, CommandBuffer cmd)
{
// TODO: Should this be disabled for forward?
if (m_CurrentSunLight == null)
return;

cmd.SetComputeTextureParam(deferredDirectionalShadowComputeShader, s_deferredDirectionalShadowKernel, HDShaderIDs._MainDepthTexture, depthTexture);
int deferredShadowTileSize = 16; // Must match DeferreDirectionalShadow.compute
int numTilesX = (hdCamera.camera.pixelWidth + (deferredShadowTileSize - 1)) / deferredShadowTileSize;
int numTilesY = (hdCamera.camera.pixelHeight + (deferredShadowTileSize - 1)) / deferredShadowTileSize;
//int numTilesX = (hdCamera.camera.pixelWidth + (deferredShadowTileSize - 1)) / deferredShadowTileSize;
//int numTilesY = (hdCamera.camera.pixelHeight + (deferredShadowTileSize - 1)) / deferredShadowTileSize;
// XRTODO: Proper fix
int numTilesX = ((int)hdCamera.textureSize.x + (deferredShadowTileSize - 1)) / deferredShadowTileSize;
int numTilesY = ((int)hdCamera.textureSize.y + (deferredShadowTileSize - 1)) / deferredShadowTileSize;
cmd.DispatchCompute(deferredDirectionalShadowComputeShader, s_deferredDirectionalShadowKernel, numTilesX, numTilesY, 1);
}

8
ScriptableRenderPipeline/HDRenderPipeline/Lighting/Volumetrics/VolumetricLighting.cs


ComputeShader m_VolumetricLightingCS { get { return m_Asset.renderPipelineResources.volumetricLightingCS; } }
// XRTODO: Fix up for XR buffers, probably just add more slices
void CreateVolumetricLightingBuffers(int width, int height)
{
if (m_VolumetricLightingBufferAccumulated != null)

void VolumetricLightingPass(HDCamera hdCamera, CommandBuffer cmd)
{
// XRTODO: Disable for now...
if (hdCamera.stereoActive)
return;
if (!SetGlobalVolumeProperties(m_VolumetricLightingEnabled, cmd, m_VolumetricLightingCS)) { return; }
using (new ProfilingSample(cmd, "VolumetricLighting"))

m_LightLoop.PushGlobalParams(hdCamera.camera, cmd, m_VolumetricLightingCS, volumetricLightingKernel, true);
cmd.SetComputeIntParam(m_VolumetricLightingCS, HDShaderIDs._UseTileLightList, 0);
cmd.DispatchCompute(m_VolumetricLightingCS, volumetricLightingKernel, ((int)hdCamera.screenSize.x + 15) / 16, ((int)hdCamera.screenSize.y + 15) / 16, 1);
//cmd.DispatchCompute(m_VolumetricLightingCS, volumetricLightingKernel, ((int)hdCamera.screenSize.x + 15) / 16, ((int)hdCamera.screenSize.y + 15) / 16, 1);
cmd.DispatchCompute(m_VolumetricLightingCS, volumetricLightingKernel, ((int)hdCamera.textureSize.x + 15) / 16, ((int)hdCamera.textureSize.y + 15) / 16, 1);
}
}
} // class HDRenderPipeline

1
ScriptableRenderPipeline/HDRenderPipeline/Sky/SkyManager.cs


public void Resize(float nearPlane, float farPlane)
{
// XRTODO: Maybe consider two sets of skyboxes for each camera eye?
// When loading RenderDoc, RenderTextures will go null
RebuildTextures(skySettings);
RebuildSkyMatrices(nearPlane, farPlane);

10
SampleScenes/HDTest/GraphicTest/Common/Prefabs/Refraction ThinPlane Clear Dragon.prefab.meta


fileFormatVersion: 2
guid: 9281ce26c9326594ebf339a7749d1382
timeCreated: 1507017860
licenseType: Pro
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 100100000
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存