浏览代码

Added stereo rendering support to CopyDepth shaders.

/main
Aleksandr Kirillov 7 年前
当前提交
3e54545d
共有 3 个文件被更改,包括 39 次插入15 次删除
  1. 44
      ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/DepthCopy.hlsl
  2. 4
      ScriptableRenderPipeline/LightweightPipeline/LWRP/Shaders/LightweightCopyDepth.shader
  3. 6
      ScriptableRenderPipeline/LightweightPipeline/LWRP/Shaders/LightweightCopyDepthMSAA.shader

44
ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/DepthCopy.hlsl


{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct VertexOutput

UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
UNITY_SETUP_INSTANCE_ID(i);
UNITY_TRANSFER_INSTANCE_ID(i, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
#if MSAA_DEPTH
Texture2DMS<float> _CameraDepthTexture;
#if defined(UNITY_STEREO_INSTANCING_ENABLED) || defined(UNITY_STEREO_MULTIVIEW_ENABLED)
#define USE_ARRAY_TEXTURE 1
#endif
#ifdef MSAA_DEPTH
#ifdef USE_ARRAY_TEXTURE
Texture2DMSArray<float> _CameraDepthTexture;
#else
Texture2DMS<float> _CameraDepthTexture;
#endif
TEXTURE2D(_CameraDepthTexture);
#ifdef USE_ARRAY_TEXTURE
TEXTURE2D_ARRAY(_CameraDepthTexture);
#else
TEXTURE2D(_CameraDepthTexture);
#endif
#if MSAA_DEPTH
#ifdef MSAA_DEPTH
int2 coord = int2(uv * _CameraDepthTexture_TexelSize.zw);
int samples = (int)_SampleCount;
#if UNITY_REVERSED_Z

#endif
for (int i = 0; i < samples; ++i)
outDepth = DEPTH_OP(LOAD_TEXTURE2D_MSAA(_CameraDepthTexture, coord, i), outDepth);
#ifdef USE_ARRAY_TEXTURE
outDepth = DEPTH_OP(LOAD_TEXTURE2D_ARRAY_MSAA(_CameraDepthTexture, uv, unity_StereoEyeIndex, i), outDepth);
#else
outDepth = DEPTH_OP(LOAD_TEXTURE2D_MSAA(_CameraDepthTexture, uv, i), outDepth);
#endif
return SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, sampler_CameraDepthTexture, uv);
#ifdef USE_ARRAY_TEXTURE
return SAMPLE_TEXTURE2D_ARRAY(_CameraDepthTexture, sampler_CameraDepthTexture, uv, unity_StereoEyeIndex).r;
#else
return SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, sampler_CameraDepthTexture, uv);
#endif
}
float frag(VertexOutput i) : SV_Depth
{
UNITY_SETUP_INSTANCE_ID(i);
return SampleDepth(i.uv);
}
#endif // LIGHTWEIGHT_DEPTH_COPY_INCLUDED

4
ScriptableRenderPipeline/LightweightPipeline/LWRP/Shaders/LightweightCopyDepth.shader


#include "LWRP/ShaderLibrary/DepthCopy.hlsl"
float frag(VertexOutput i) : SV_Depth
{
return SampleDepth(i.uv);
}
ENDHLSL
}
}

6
ScriptableRenderPipeline/LightweightPipeline/LWRP/Shaders/LightweightCopyDepthMSAA.shader


SubShader
{
Tags { "RenderType" = "Opaque" "RenderPipeline" = "LightiweightPipeline"}
Tags { "RenderType" = "Opaque" "RenderPipeline" = "LightweightPipeline"}
Pass
{

#include "LWRP/ShaderLibrary/DepthCopy.hlsl"
float frag(VertexOutput i) : SV_Depth
{
return SampleDepth(i.uv);
}
ENDHLSL
}
}
正在加载...
取消
保存