Julien Ignace
7 年前
当前提交
427df3eb
共有 8 个文件被更改,包括 233 次插入 和 0 次删除
-
55ScriptableRenderPipeline/HDRenderPipeline/HDRP/MRTBufferManager.cs
-
11ScriptableRenderPipeline/HDRenderPipeline/HDRP/MRTBufferManager.cs.meta
-
35ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Decal/DBufferManager.cs
-
11ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Decal/DBufferManager.cs.meta
-
42ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/GBufferManager.cs
-
11ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/GBufferManager.cs.meta
-
59ScriptableRenderPipeline/HDRenderPipeline/HDRP/RenderPipelineResources/CopyDepthBuffer.shader
-
9ScriptableRenderPipeline/HDRenderPipeline/HDRP/RenderPipelineResources/CopyDepthBuffer.shader.meta
|
|||
using UnityEngine.Rendering; |
|||
|
|||
namespace UnityEngine.Experimental.Rendering.HDPipeline |
|||
{ |
|||
public abstract class MRTBufferManager |
|||
{ |
|||
protected int m_BufferCount; |
|||
protected RenderTargetIdentifier[] m_RTIDs; |
|||
protected RTHandle[] m_RTs; |
|||
protected int[] m_TextureShaderIDs; |
|||
|
|||
public MRTBufferManager(int maxBufferCount) |
|||
{ |
|||
m_BufferCount = maxBufferCount; |
|||
m_RTIDs = new RenderTargetIdentifier[maxBufferCount]; |
|||
m_RTs = new RTHandle[maxBufferCount]; |
|||
m_TextureShaderIDs = new int[maxBufferCount]; |
|||
} |
|||
|
|||
public RenderTargetIdentifier[] GetBuffersRTI() |
|||
{ |
|||
// nameID can change from one frame to another depending on the msaa flag so so we need to update this array to be sure it's up to date.
|
|||
for (int i = 0; i < m_BufferCount; ++i) |
|||
{ |
|||
m_RTIDs[i] = m_RTs[i].nameID; |
|||
} |
|||
return m_RTIDs; |
|||
} |
|||
|
|||
public RTHandle GetBuffer(int index) |
|||
{ |
|||
Debug.Assert(index < m_BufferCount); |
|||
return m_RTs[index]; |
|||
} |
|||
|
|||
public abstract void CreateBuffers(); |
|||
|
|||
public void BindBufferAsTextures(CommandBuffer cmd) |
|||
{ |
|||
for (int i = 0; i < m_BufferCount; ++i) |
|||
{ |
|||
cmd.SetGlobalTexture(m_TextureShaderIDs[i], m_RTs[i]); |
|||
} |
|||
} |
|||
|
|||
public void DestroyBuffers() |
|||
{ |
|||
for (int i = 0; i < m_BufferCount; ++i) |
|||
{ |
|||
RTHandle.Release(m_RTs[i]); |
|||
m_RTs[i] = null; |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 8a1cfa206308c414989b3240a61bc7ef |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine.Rendering; |
|||
|
|||
namespace UnityEngine.Experimental.Rendering.HDPipeline |
|||
{ |
|||
public class DBufferManager : MRTBufferManager |
|||
{ |
|||
public int vsibleDecalCount { get; set; } |
|||
|
|||
public DBufferManager() |
|||
: base(Decal.GetMaterialDBufferCount()) |
|||
{ |
|||
Debug.Assert(m_BufferCount <= 4); |
|||
} |
|||
|
|||
public override void CreateBuffers() |
|||
{ |
|||
RenderTextureFormat[] rtFormat; |
|||
bool[] sRGBFlags; |
|||
Decal.GetMaterialDBufferDescription(out rtFormat, out sRGBFlags); |
|||
|
|||
for (int dbufferIndex = 0; dbufferIndex < m_BufferCount; ++dbufferIndex) |
|||
{ |
|||
m_RTs[dbufferIndex] = RTHandle.Alloc(Vector2.one, colorFormat: rtFormat[dbufferIndex], sRGB: sRGBFlags[dbufferIndex], filterMode: FilterMode.Point); |
|||
m_RTIDs[dbufferIndex] = m_RTs[dbufferIndex].nameID; |
|||
m_TextureShaderIDs[dbufferIndex] = HDShaderIDs._DBufferTexture[dbufferIndex]; |
|||
} |
|||
} |
|||
|
|||
public void PushGlobalParams(CommandBuffer cmd) |
|||
{ |
|||
cmd.SetGlobalInt(HDShaderIDs._EnableDBuffer, vsibleDecalCount > 0 ? 1 : 0); |
|||
BindBufferAsTextures(cmd); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 9335119d0dd7cc748a67cfcc6f1040ab |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine.Rendering; |
|||
|
|||
namespace UnityEngine.Experimental.Rendering.HDPipeline |
|||
{ |
|||
public class GBufferManager : MRTBufferManager |
|||
{ |
|||
int m_GBufferCount = 0; |
|||
bool m_EnableShadowMask = false; |
|||
RenderPipelineMaterial m_DeferredMaterial; |
|||
|
|||
public GBufferManager(RenderPipelineMaterial deferredMaterial, bool enableBakeShadowMask) |
|||
: base(deferredMaterial.GetMaterialGBufferCount() + (enableBakeShadowMask ? 1 : 0)) |
|||
{ |
|||
Debug.Assert(m_BufferCount <= 8); |
|||
|
|||
m_DeferredMaterial = deferredMaterial; |
|||
m_GBufferCount = deferredMaterial.GetMaterialGBufferCount(); |
|||
m_EnableShadowMask = enableBakeShadowMask; |
|||
} |
|||
|
|||
public override void CreateBuffers() |
|||
{ |
|||
RenderTextureFormat[] rtFormat; |
|||
bool[] sRGBFlags; |
|||
m_DeferredMaterial.GetMaterialGBufferDescription(out rtFormat, out sRGBFlags); |
|||
|
|||
for (int gbufferIndex = 0; gbufferIndex < m_GBufferCount; ++gbufferIndex) |
|||
{ |
|||
m_RTs[gbufferIndex] = RTHandle.Alloc(Vector2.one, colorFormat: rtFormat[gbufferIndex], sRGB: sRGBFlags[gbufferIndex], filterMode: FilterMode.Point); |
|||
m_RTIDs[gbufferIndex] = m_RTs[gbufferIndex].nameID; |
|||
m_TextureShaderIDs[gbufferIndex] = HDShaderIDs._GBufferTexture[gbufferIndex]; |
|||
} |
|||
|
|||
if (m_EnableShadowMask) |
|||
{ |
|||
m_RTs[m_GBufferCount] = RTHandle.Alloc(Vector2.one, colorFormat: Builtin.GetShadowMaskBufferFormat(), sRGB: Builtin.GetShadowMask_sRGBFlag(), filterMode: FilterMode.Point); |
|||
m_RTIDs[m_GBufferCount] = new RenderTargetIdentifier(m_RTs[m_GBufferCount]); |
|||
m_TextureShaderIDs[m_GBufferCount] = HDShaderIDs._ShadowMaskTexture; |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: fd31fc09c5f088f43ac4c8e0065ed56c |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
Shader "Hidden/HDRenderPipeline/CopyDepthBuffer" |
|||
{ |
|||
HLSLINCLUDE |
|||
|
|||
|
|||
|
|||
ENDHLSL |
|||
|
|||
SubShader |
|||
{ |
|||
Pass |
|||
{ |
|||
Name "Copy Depth" |
|||
|
|||
Cull Off |
|||
ZTest Always |
|||
ZWrite On |
|||
Blend Off |
|||
|
|||
HLSLPROGRAM |
|||
#pragma target 4.5 |
|||
#pragma only_renderers d3d11 ps4 xboxone vulkan metal |
|||
#pragma fragment Frag |
|||
#pragma vertex Vert |
|||
// #pragma enable_d3d11_debug_symbols |
|||
|
|||
#include "CoreRP/ShaderLibrary/Common.hlsl" |
|||
#include "../ShaderVariables.hlsl" |
|||
|
|||
TEXTURE2D(_InputDepthTexture); |
|||
|
|||
struct Attributes |
|||
{ |
|||
uint vertexID : SV_VertexID; |
|||
}; |
|||
|
|||
struct Varyings |
|||
{ |
|||
float4 positionCS : SV_Position; |
|||
}; |
|||
|
|||
Varyings Vert(Attributes input) |
|||
{ |
|||
Varyings output; |
|||
output.positionCS = GetFullScreenTriangleVertexPosition(input.vertexID); |
|||
return output; |
|||
} |
|||
|
|||
float Frag(Varyings input) : SV_Depth |
|||
{ |
|||
PositionInputs posInputs = GetPositionInput(input.positionCS, _ScreenSize.zw); |
|||
return LOAD_TEXTURE2D(_InputDepthTexture, posInputs.positionSS).x; |
|||
} |
|||
|
|||
ENDHLSL |
|||
} |
|||
} |
|||
Fallback Off |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 42dfcc8fe803ece4096c58630689982f |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue