|
|
|
|
|
|
|
|
|
|
HLSLINCLUDE |
|
|
|
|
|
|
|
//#pragma enable_d3d11_debug_symbols |
|
|
|
|
|
|
|
//Keep compiler quiet about Shadows.hlsl. |
|
|
|
#include "CoreRP/ShaderLibrary/Common.hlsl" |
|
|
|
#include "CoreRP/ShaderLibrary/EntityLighting.hlsl" |
|
|
|
|
|
|
TEXTURE2D(_CameraDepthTexture); |
|
|
|
SAMPLER(sampler_CameraDepthTexture); |
|
|
|
#endif |
|
|
|
//struct FragInfo |
|
|
|
//{ |
|
|
|
// uint eyeIndex; |
|
|
|
// half4 pos; |
|
|
|
// half4 texcoord; |
|
|
|
//}; |
|
|
|
//AppendStructuredBuffer<FragInfo> FragInfoAppendBuffer; |
|
|
|
|
|
|
|
struct VertexInput |
|
|
|
{ |
|
|
|
|
|
|
{ |
|
|
|
half4 pos : SV_POSITION; |
|
|
|
half4 texcoord : TEXCOORD0; |
|
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID |
|
|
|
//UNITY_VERTEX_INPUT_INSTANCE_ID |
|
|
|
#if defined(UNITY_STEREO_INSTANCING_ENABLED) |
|
|
|
//uint testSlice : SV_RenderTargetArrayIndex; |
|
|
|
#endif |
|
|
|
}; |
|
|
|
|
|
|
|
Interpolators Vertex(VertexInput i) |
|
|
|
|
|
|
UNITY_TRANSFER_INSTANCE_ID(i, o); |
|
|
|
//UNITY_TRANSFER_INSTANCE_ID(i, o); |
|
|
|
#if defined(UNITY_STEREO_INSTANCING_ENABLED) |
|
|
|
//o.stereoEyeIndex = 1; |
|
|
|
#endif |
|
|
|
o.pos = TransformObjectToHClip(i.vertex.xyz); |
|
|
|
|
|
|
|
float4 projPos = o.pos * 0.5; |
|
|
|
|
|
|
// Doesn't seem like saturate messes anything up here... |
|
|
|
o.texcoord.xy = UnityStereoTransformScreenSpaceTex(i.texcoord.xy); |
|
|
|
o.texcoord.zw = projPos.xy; |
|
|
|
|
|
|
|
|
|
|
half Fragment(Interpolators i) : SV_Target |
|
|
|
{ |
|
|
|
UNITY_SETUP_INSTANCE_ID(i); |
|
|
|
//UNITY_SETUP_INSTANCE_ID(i); |
|
|
|
|
|
|
|
//FragInfo debugInfo; |
|
|
|
//debugInfo.eyeIndex = unity_StereoEyeIndex; |
|
|
|
//debugInfo.pos = i.pos; |
|
|
|
//debugInfo.texcoord = i.texcoord; |
|
|
|
//FragInfoAppendBuffer.Append(debugInfo); |
|
|
|
|
|
|
|
// TODO |
|
|
|
// declare texture correctly as tex2darray |
|
|
|
|
|
|
float deviceDepth = SAMPLE_TEXTURE2D_ARRAY(_CameraDepthTexture, sampler_CameraDepthTexture, i.texcoord.xy, unity_StereoEyeIndex).r; |
|
|
|
//float deviceDepth = SAMPLE_TEXTURE2D_ARRAY(_CameraDepthTexture, sampler_CameraDepthTexture, i.texcoord.xy, unity_StereoEyeIndex).r; |
|
|
|
//deviceDepth = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, sampler_CameraDepthTexture, i.texcoord.xy); |
|
|
|
float deviceDepth = SAMPLE_TEXTURE2D_ARRAY(_CameraDepthTexture, sampler_CameraDepthTexture, i.texcoord.xy, 0).r; |
|
|
|
#else |
|
|
|
float deviceDepth = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, sampler_CameraDepthTexture, i.texcoord.xy); |
|
|
|
#endif |
|
|
|
|
|
|
//Fetch shadow coordinates for cascade. |
|
|
|
float4 coords = ComputeScreenSpaceShadowCoords(wpos); |
|
|
|
|
|
|
|
return SampleShadowmap(coords); |
|
|
|
//return SampleShadowmap(coords); |
|
|
|
//return deviceDepth; |
|
|
|
return i.texcoord.x; |
|
|
|
//return unity_StereoEyeIndex; |
|
|
|
} |
|
|
|
|
|
|
|
ENDHLSL |
|
|
|