浏览代码
Added a shader that resolves a MSAA depth RT to execute on platforms that support tex2dms.
Added a shader that resolves a MSAA depth RT to execute on platforms that support tex2dms.
The only setup when we can skip depth copy and depth prepass is postfx + no screen-space shadows + no MSAA./main
Aleksandr Kirillov
7 年前
当前提交
34562958
共有 6 个文件被更改,包括 126 次插入 和 9 次删除
-
6ScriptableRenderPipeline/LightweightPipeline/LWRP/Data/LightweightPipelineAsset.cs
-
3ScriptableRenderPipeline/LightweightPipeline/LWRP/Data/LightweightPipelineResources.asset
-
3ScriptableRenderPipeline/LightweightPipeline/LWRP/Data/LightweightPipelineResources.cs
-
43ScriptableRenderPipeline/LightweightPipeline/LWRP/LightweightPipeline.cs
-
71ScriptableRenderPipeline/LightweightPipeline/LWRP/Shaders/LightweightCopyDepthMSAA.shader
-
9ScriptableRenderPipeline/LightweightPipeline/LWRP/Shaders/LightweightCopyDepthMSAA.shader.meta
|
|||
Shader "Hidden/LightweightPipeline/CopyDepthMSAA" |
|||
{ |
|||
Properties |
|||
{ |
|||
[HideInInspector] _SampleCount("MSAA sample count", Float) = 1.0 |
|||
} |
|||
|
|||
SubShader |
|||
{ |
|||
Tags { "RenderType" = "Opaque" "RenderPipeline" = "LightiweightPipeline"} |
|||
|
|||
Pass |
|||
{ |
|||
ZTest Always ZWrite On ColorMask 0 |
|||
|
|||
HLSLPROGRAM |
|||
// Required to compile gles 2.0 with standard srp library |
|||
#pragma prefer_hlslcc gles |
|||
#pragma exclude_renderers d3d11_9x |
|||
#pragma vertex vert |
|||
#pragma fragment frag |
|||
|
|||
#pragma require msaatex |
|||
|
|||
#include "LWRP/ShaderLibrary/Core.hlsl" |
|||
|
|||
Texture2DMS<float> _CameraDepthTexture; |
|||
float _SampleCount; |
|||
float4 _CameraDepthTexture_TexelSize; |
|||
|
|||
struct VertexInput |
|||
{ |
|||
float4 vertex : POSITION; |
|||
float2 uv : TEXCOORD0; |
|||
}; |
|||
|
|||
struct VertexOutput |
|||
{ |
|||
float4 position : SV_POSITION; |
|||
float2 uv : TEXCOORD0; |
|||
}; |
|||
|
|||
VertexOutput vert(VertexInput i) |
|||
{ |
|||
VertexOutput o; |
|||
o.uv = i.uv; |
|||
o.position = TransformObjectToHClip(i.vertex.xyz); |
|||
return o; |
|||
} |
|||
|
|||
float frag(VertexOutput i) : SV_Depth |
|||
{ |
|||
int2 coord = int2(i.uv * _CameraDepthTexture_TexelSize.zw); |
|||
int samples = (int)_SampleCount; |
|||
#if UNITY_REVERSED_Z |
|||
float outDepth = 1.0; |
|||
#define DEPTH_OP min |
|||
#else |
|||
float outDepth = 0.0; |
|||
#define DEPTH_OP max |
|||
#endif |
|||
|
|||
for (int i = 0; i < samples; ++i) |
|||
outDepth = DEPTH_OP(LOAD_TEXTURE2D_MSAA(_CameraDepthTexture, coord, i), outDepth); |
|||
|
|||
return outDepth; |
|||
} |
|||
ENDHLSL |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 3aaf3bbc87e49413fa5019b840757406 |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue