浏览代码

Merge pull request #144 from Unity-Technologies/Branch_CopyDepthPostOpaque

Made a copy of the depth buffer after all opaque so that it can be read during the transparent pass.
/Branch_Batching2
GitHub 8 年前
当前提交
055563fb
共有 3 个文件被更改,包括 61 次插入34 次删除
  1. 46
      Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipeline.asset
  2. 45
      Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipeline.cs
  3. 4
      Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderVariables.hlsl

46
Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipeline.asset


m_Script: {fileID: 11500000, guid: d440c0deec24a2f478b3e9021cb66c29, type: 3}
m_Name: HDRenderPipeline
m_EditorClassIdentifier:
m_CommonSettings:
m_ShadowMaxDistance: 1000
m_ShadowCascadeCount: 4
m_ShadowCascadeSplit0: 0.05
m_ShadowCascadeSplit1: 0.2
m_ShadowCascadeSplit2: 0.3
m_SssProfileStdDev1: {r: 0.3, g: 0.3, b: 0.3, a: 0}
m_SssProfileStdDev2: {r: 1, g: 1, b: 1, a: 0}
m_SssProfileLerpWeight: 0.5
m_SssBilateralScale: 0.1
m_SkyParameters: {fileID: 0}
displayDebug: 1
displayShadowDebug: 1
shadowDebugParameters:
displayMaterialDebug: 1
displayRenderingDebug: 1
displayLightingDebug: 1
materialDebugParameters:
debugViewMaterial: 0
lightingDebugParameters:
visualizationMode: 0
visualizeShadowMapIndex: 0
shadowDebugMode: 0
shadowMapIndex: 0
lightingDebugMode: 0
overrideSmoothness: 0
overrideSmoothnessValue: 0.78
debugLightingAlbedo: {r: 0.53676474, g: 0.53676474, b: 0.53676474, a: 1}
renderingDebugParametrs:
displayOpaqueObjects: 1
displayTransparentObjects: 1
enableDistortion: 0
renderingParameters:
useForwardRenderingOnly: 0
useDepthPrepass: 0
m_ShadowSettings:
enabled: 1
shadowAtlasWidth: 4096

directionalLightCascades: {x: 0.05, y: 0.2, z: 0.3}
m_SssParameters:
profiles: []
bilateralScale: 0.1
localSssParameters: {fileID: 0}
m_CommonSettings:
m_ShadowMaxDistance: 1000
m_ShadowCascadeCount: 4
m_ShadowCascadeSplit0: 0.05
m_ShadowCascadeSplit1: 0.2
m_ShadowCascadeSplit2: 0.3
m_SkyParameters: {fileID: 0}

45
Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipeline.cs


readonly int m_CameraSubsurfaceBuffer;
readonly int m_CameraFilteringBuffer;
readonly int m_CameraDepthStencilBuffer;
readonly int m_CameraDepthStencilBufferCopy; // This is temporary, we will need to provide the correct opaque depth buffer to transparent without needing a copy
readonly int m_CameraStencilBuffer;
readonly int m_VelocityBuffer;
readonly int m_DistortionBuffer;

readonly RenderTargetIdentifier m_CameraSubsurfaceBufferRT;
readonly RenderTargetIdentifier m_CameraFilteringBufferRT;
readonly RenderTargetIdentifier m_CameraDepthStencilBufferRT;
readonly RenderTargetIdentifier m_CameraDepthStencilBufferCopyRT;
// 'm_CameraStencilBufferRT' is a temporary copy of the stencil buffer and should be removed
// once we are able to read from the depth buffer and perform the stencil test simultaneously.
readonly RenderTargetIdentifier m_CameraStencilBufferRT;

{
m_Owner = owner;
m_CameraColorBuffer = Shader.PropertyToID("_CameraColorTexture");
m_CameraSubsurfaceBuffer = Shader.PropertyToID("_CameraSubsurfaceTexture");
m_CameraFilteringBuffer = Shader.PropertyToID("_CameraFilteringBuffer");
m_CameraDepthStencilBuffer = Shader.PropertyToID("_CameraDepthTexture");
m_CameraStencilBuffer = Shader.PropertyToID("_CameraStencilTexture");
m_CameraColorBuffer = Shader.PropertyToID("_CameraColorTexture");
m_CameraSubsurfaceBuffer = Shader.PropertyToID("_CameraSubsurfaceTexture");
m_CameraFilteringBuffer = Shader.PropertyToID("_CameraFilteringBuffer");
m_CameraDepthStencilBuffer = Shader.PropertyToID("_CameraDepthTexture");
m_CameraDepthStencilBufferCopy = Shader.PropertyToID("_CameraDepthTextureCopy");
m_CameraStencilBuffer = Shader.PropertyToID("_CameraStencilTexture");
m_CameraColorBufferRT = new RenderTargetIdentifier(m_CameraColorBuffer);
m_CameraSubsurfaceBufferRT = new RenderTargetIdentifier(m_CameraSubsurfaceBuffer);
m_CameraFilteringBufferRT = new RenderTargetIdentifier(m_CameraFilteringBuffer);
m_CameraDepthStencilBufferRT = new RenderTargetIdentifier(m_CameraDepthStencilBuffer);
m_CameraStencilBufferRT = new RenderTargetIdentifier(m_CameraStencilBuffer);
m_CameraColorBufferRT = new RenderTargetIdentifier(m_CameraColorBuffer);
m_CameraSubsurfaceBufferRT = new RenderTargetIdentifier(m_CameraSubsurfaceBuffer);
m_CameraFilteringBufferRT = new RenderTargetIdentifier(m_CameraFilteringBuffer);
m_CameraDepthStencilBufferRT = new RenderTargetIdentifier(m_CameraDepthStencilBuffer);
m_CameraDepthStencilBufferCopyRT = new RenderTargetIdentifier(m_CameraDepthStencilBufferCopy);
m_CameraStencilBufferRT = new RenderTargetIdentifier(m_CameraStencilBuffer);
m_DebugViewMaterialGBuffer = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/DebugViewMaterialGBuffer");

// Material that are always forward are unlit and complex (Like Hair) and don't require sorting, so it is ok to split them.
RenderForward(cullResults, camera, renderContext, true); // Render deferred or forward opaque
RenderForwardOnlyOpaque(cullResults, camera, renderContext);
// 'm_CameraDepthStencilBufferCopyRT' is a temporary copy of the depth textureand should be removed
// once we are able to read from the depth buffer during transparent pass.
using (new Utilities.ProfilingSample("Copy depth-stencil buffer after all opaque", renderContext))
{
var cmd = new CommandBuffer();
cmd.CopyTexture(m_CameraDepthStencilBufferRT, m_CameraDepthStencilBufferCopyRT);
renderContext.ExecuteCommandBuffer(cmd);
cmd.Dispose();
}
RenderSky(hdCamera, renderContext);

int w = camera.pixelWidth;
int h = camera.pixelHeight;
cmd.GetTemporaryRT(m_CameraColorBuffer, w, h, 0, FilterMode.Point, RenderTextureFormat.ARGBHalf, RenderTextureReadWrite.Linear, 1, true); // Enable UAV
cmd.GetTemporaryRT(m_CameraSubsurfaceBuffer, 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
cmd.GetTemporaryRT(m_CameraDepthStencilBuffer, w, h, 24, FilterMode.Point, RenderTextureFormat.Depth);
cmd.GetTemporaryRT(m_CameraStencilBuffer, w, h, 24, FilterMode.Point, RenderTextureFormat.Depth);
cmd.GetTemporaryRT(m_CameraColorBuffer, w, h, 0, FilterMode.Point, RenderTextureFormat.ARGBHalf, RenderTextureReadWrite.Linear, 1, true); // Enable UAV
cmd.GetTemporaryRT(m_CameraSubsurfaceBuffer, 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
cmd.GetTemporaryRT(m_CameraDepthStencilBuffer, w, h, 24, FilterMode.Point, RenderTextureFormat.Depth);
cmd.GetTemporaryRT(m_CameraDepthStencilBufferCopy, w, h, 24, FilterMode.Point, RenderTextureFormat.Depth);
cmd.GetTemporaryRT(m_CameraStencilBuffer, w, h, 24, FilterMode.Point, RenderTextureFormat.Depth);
if (!m_Owner.renderingParameters.ShouldUseForwardRenderingOnly())
{

4
Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderVariables.hlsl


float4 unity_SHC;
CBUFFER_END
// Use the regular depth camera texture sampler for sampling this: sampler_CameraDepthTexture
TEXTURE2D_FLOAT(_CameraDepthTextureCopy);
SAMPLER2D(sampler_CameraDepthTextureCopy);
// Main lightmap
TEXTURE2D(unity_Lightmap);
SAMPLER2D(samplerunity_Lightmap);

正在加载...
取消
保存