浏览代码
Merge pull request #1244 from Unity-Technologies/lw/depth_copy_vr_support
Merge pull request #1244 from Unity-Technologies/lw/depth_copy_vr_support
Lw/depth copy vr support/main
GitHub
7 年前
当前提交
15d94d6d
共有 17 个文件被更改,包括 162 次插入 和 167 次删除
-
15ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/API/D3D11.hlsl
-
11ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/API/GLCore.hlsl
-
1ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/API/GLES2.hlsl
-
1ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/API/GLES3.hlsl
-
15ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/API/Metal.hlsl
-
15ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/API/PSSL.hlsl
-
15ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/API/Vulkan.hlsl
-
15ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/API/XBoxOne.hlsl
-
5ScriptableRenderPipeline/LightweightPipeline/LWRP/Data/LightweightPipelineAsset.cs
-
1ScriptableRenderPipeline/LightweightPipeline/LWRP/Data/LightweightPipelineResources.asset
-
1ScriptableRenderPipeline/LightweightPipeline/LWRP/Data/LightweightPipelineResources.cs
-
32ScriptableRenderPipeline/LightweightPipeline/LWRP/LightweightPipeline.cs
-
34ScriptableRenderPipeline/LightweightPipeline/LWRP/Shaders/LightweightCopyDepth.shader
-
81ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/DepthCopy.hlsl
-
9ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/DepthCopy.hlsl.meta
-
69ScriptableRenderPipeline/LightweightPipeline/LWRP/Shaders/LightweightCopyDepthMSAA.shader
-
9ScriptableRenderPipeline/LightweightPipeline/LWRP/Shaders/LightweightCopyDepthMSAA.shader.meta
|
|||
#ifndef LIGHTWEIGHT_DEPTH_COPY_INCLUDED |
|||
#define LIGHTWEIGHT_DEPTH_COPY_INCLUDED |
|||
|
|||
#include "LWRP/ShaderLibrary/Core.hlsl" |
|||
|
|||
struct VertexInput |
|||
{ |
|||
float4 vertex : POSITION; |
|||
float2 uv : TEXCOORD0; |
|||
UNITY_VERTEX_INPUT_INSTANCE_ID |
|||
}; |
|||
|
|||
struct VertexOutput |
|||
{ |
|||
float4 position : SV_POSITION; |
|||
float2 uv : TEXCOORD0; |
|||
UNITY_VERTEX_INPUT_INSTANCE_ID |
|||
UNITY_VERTEX_OUTPUT_STEREO |
|||
}; |
|||
|
|||
VertexOutput vert(VertexInput i) |
|||
{ |
|||
VertexOutput o; |
|||
UNITY_SETUP_INSTANCE_ID(i); |
|||
UNITY_TRANSFER_INSTANCE_ID(i, o); |
|||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); |
|||
o.uv = i.uv; |
|||
o.position = TransformObjectToHClip(i.vertex.xyz); |
|||
return o; |
|||
} |
|||
|
|||
#if defined(UNITY_STEREO_INSTANCING_ENABLED) || defined(UNITY_STEREO_MULTIVIEW_ENABLED) |
|||
#define DEPTH_TEXTURE_MS Texture2DMSArray |
|||
#define DEPTH_TEXTURE(name) TEXTURE2D_ARRAY(name) |
|||
#define LOAD(uv, sampleIndex) LOAD_TEXTURE2D_ARRAY_MSAA(_CameraDepthTexture, uv, unity_StereoEyeIndex, sampleIndex) |
|||
#define SAMPLE(uv) SAMPLE_TEXTURE2D_ARRAY(_CameraDepthTexture, sampler_CameraDepthTexture, uv, unity_StereoEyeIndex).r |
|||
#else |
|||
#define DEPTH_TEXTURE_MS Texture2DMS |
|||
#define DEPTH_TEXTURE(name) TEXTURE2D(name) |
|||
#define LOAD(uv, sampleIndex) LOAD_TEXTURE2D_MSAA(_CameraDepthTexture, uv, sampleIndex) |
|||
#define SAMPLE(uv) SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, sampler_CameraDepthTexture, uv) |
|||
#endif |
|||
|
|||
#ifdef _MSAA_DEPTH |
|||
DEPTH_TEXTURE_MS<float> _CameraDepthTexture; |
|||
float _SampleCount; |
|||
float4 _CameraDepthTexture_TexelSize; |
|||
#else |
|||
DEPTH_TEXTURE(_CameraDepthTexture); |
|||
SAMPLER(sampler_CameraDepthTexture); |
|||
#endif |
|||
|
|||
float SampleDepth(float2 uv) |
|||
{ |
|||
#ifdef _MSAA_DEPTH |
|||
int2 coord = int2(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(uv, i), outDepth); |
|||
|
|||
return outDepth; |
|||
#else |
|||
return SAMPLE(uv); |
|||
#endif |
|||
} |
|||
|
|||
float frag(VertexOutput i) : SV_Depth |
|||
{ |
|||
UNITY_SETUP_INSTANCE_ID(i); |
|||
return SampleDepth(i.uv); |
|||
} |
|||
|
|||
#endif // LIGHTWEIGHT_DEPTH_COPY_INCLUDED |
|
|||
fileFormatVersion: 2 |
|||
guid: 971e7c84ed6bc40fc95bdbb2e008013f |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
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 |
|||
#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