Felipe Lira
7 年前
当前提交
05b422c1
共有 11 个文件被更改,包括 163 次插入 和 40 次删除
-
55ScriptableRenderPipeline/LightweightPipeline/LWRP/LightweightPipeline.cs
-
9ScriptableRenderPipeline/LightweightPipeline/LWRP/LightweightPipelineCore.cs
-
2ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/DepthCopy.hlsl
-
8ScriptableRenderPipeline/LightweightPipeline/LWRP/Passes.meta
-
78ScriptableRenderPipeline/LightweightPipeline/LWRP/Passes/DepthOnlyPass.cs
-
11ScriptableRenderPipeline/LightweightPipeline/LWRP/Passes/DepthOnlyPass.cs.meta
-
29ScriptableRenderPipeline/LightweightPipeline/LWRP/Passes/ScriptableRenderPass.cs
-
11ScriptableRenderPipeline/LightweightPipeline/LWRP/Passes/ScriptableRenderPass.cs.meta
-
0/ScriptableRenderPipeline/LightweightPipeline/LWRP/Passes/LightweightShadowPass.cs.meta
-
0/ScriptableRenderPipeline/LightweightPipeline/LWRP/Passes/LightweightShadowPass.cs
|
|||
fileFormatVersion: 2 |
|||
guid: c2a16f045b3148e4f9d0d62614a81a61 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine.Rendering; |
|||
|
|||
namespace UnityEngine.Experimental.Rendering.LightweightPipeline |
|||
{ |
|||
public class DepthOnlyPass : ScriptableRenderPass |
|||
{ |
|||
public int depthTextureID { get; private set; } |
|||
public RenderTargetIdentifier depthTexture { get; private set; } |
|||
|
|||
const string kProfilerTag = "Depth Prepass Setup"; |
|||
const string kCommandBufferTag = "Depth Prepass"; |
|||
int kDepthBufferBits = 32; |
|||
bool m_Disposed; |
|||
FilterRenderersSettings m_FilterSettings; |
|||
|
|||
public DepthOnlyPass(RenderTextureFormat[] inputColorAttachments, RenderTextureFormat inputDepthAttachment) : |
|||
base(inputColorAttachments, inputDepthAttachment) |
|||
{ |
|||
RegisterShaderPassName("DepthOnly"); |
|||
depthTextureID = Shader.PropertyToID("_CameraDepthTexture"); |
|||
depthTexture = new RenderTargetIdentifier(depthTextureID); |
|||
|
|||
m_Disposed = true; |
|||
m_FilterSettings = new FilterRenderersSettings(true) |
|||
{ |
|||
renderQueueRange = RenderQueueRange.opaque |
|||
}; |
|||
} |
|||
|
|||
public override void BindSurface(CommandBuffer cmd, RenderTextureDescriptor attachmentDescriptor, int samples) |
|||
{ |
|||
attachmentDescriptor.colorFormat = depthAttachment; |
|||
attachmentDescriptor.depthBufferBits = kDepthBufferBits; |
|||
|
|||
if (samples > 1) |
|||
{ |
|||
attachmentDescriptor.bindMS = samples > 1; |
|||
attachmentDescriptor.msaaSamples = samples; |
|||
} |
|||
|
|||
cmd.GetTemporaryRT(depthTextureID, attachmentDescriptor, FilterMode.Point); |
|||
m_Disposed = false; |
|||
} |
|||
|
|||
public override void Execute(ScriptableRenderContext context, Camera camera, ref CullResults cullResults, bool stereoRendering) |
|||
{ |
|||
CommandBuffer cmd = CommandBufferPool.Get(kCommandBufferTag); |
|||
using (new ProfilingSample(cmd, kProfilerTag)) |
|||
{ |
|||
int depthSlice = LightweightPipeline.GetRenderTargetDepthSlice(stereoRendering); |
|||
CoreUtils.SetRenderTarget(cmd, depthTexture, ClearFlag.Depth, 0, CubemapFace.Unknown, depthSlice); |
|||
context.ExecuteCommandBuffer(cmd); |
|||
cmd.Clear(); |
|||
|
|||
var opaqueDrawSettings = new DrawRendererSettings(camera, m_ShaderPassNames[0]); |
|||
opaqueDrawSettings.sorting.flags = SortFlags.CommonOpaque; |
|||
|
|||
if (stereoRendering) |
|||
{ |
|||
context.StartMultiEye(camera); |
|||
context.DrawRenderers(cullResults.visibleRenderers, ref opaqueDrawSettings, m_FilterSettings); |
|||
context.StopMultiEye(camera); |
|||
} |
|||
else |
|||
context.DrawRenderers(cullResults.visibleRenderers, ref opaqueDrawSettings, m_FilterSettings); |
|||
} |
|||
cmd.SetGlobalTexture(depthTextureID, depthTexture); |
|||
context.ExecuteCommandBuffer(cmd); |
|||
CommandBufferPool.Release(cmd); |
|||
} |
|||
|
|||
public override void Dispose(CommandBuffer cmd) |
|||
{ |
|||
if (!m_Disposed) |
|||
cmd.ReleaseTemporaryRT(depthTextureID); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 2b327960b30da614ca5f44f2fef0137a |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections.Generic; |
|||
using UnityEngine.Rendering; |
|||
|
|||
namespace UnityEngine.Experimental.Rendering.LightweightPipeline |
|||
{ |
|||
public abstract class ScriptableRenderPass |
|||
{ |
|||
public ScriptableRenderPass(RenderTextureFormat[] inputColorAttachments, RenderTextureFormat inputDepthAttachment) |
|||
{ |
|||
colorAttachments = inputColorAttachments; |
|||
depthAttachment = inputDepthAttachment; |
|||
} |
|||
|
|||
public abstract void BindSurface(CommandBuffer cmd, RenderTextureDescriptor attachmentDescriptor, int samples); |
|||
|
|||
public abstract void Execute(ScriptableRenderContext context, Camera camera, ref CullResults cullResults, bool stereoRendering); |
|||
|
|||
public abstract void Dispose(CommandBuffer cmd); |
|||
|
|||
public RenderTextureFormat[] colorAttachments { get; set; } |
|||
public RenderTextureFormat depthAttachment { get; set; } |
|||
protected List<ShaderPassName> m_ShaderPassNames = new List<ShaderPassName>(); |
|||
|
|||
public void RegisterShaderPassName(string passName) |
|||
{ |
|||
m_ShaderPassNames.Add(new ShaderPassName(passName)); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: edba24b6007b9dd41824b4656ed8ebcf |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue