|
|
|
|
|
|
Pass |
|
|
|
{ |
|
|
|
Name "ShadowCaster" |
|
|
|
Tags{"LightMode" = "ShadowCaster"} |
|
|
|
|
|
|
|
ZWrite On ZTest LEqual |
|
|
|
|
|
|
HLSLPROGRAM |
|
|
|
// Required to compile gles 2.0 with standard srp library |
|
|
|
#pragma prefer_hlslcc gles |
|
|
|
#pragma exclude_renderers d3d11_9x |
|
|
|
#pragma target 2.0 |
|
|
|
|
|
|
|
//-------------------------------------- |
|
|
|
|
|
|
#include "CoreRP/ShaderLibrary/Color.hlsl" |
|
|
|
|
|
|
|
${Graph} |
|
|
|
struct VertexOutput |
|
|
|
{ |
|
|
|
float2 uv : TEXCOORD0; |
|
|
|
float4 clipPos : SV_POSITION; |
|
|
|
}; |
|
|
|
|
|
|
|
float4 ShadowPassVertex(GraphVertexInput v) : SV_POSITION |
|
|
|
{ |
|
|
|
VertexOutput ShadowPassVertex(GraphVertexInput v) |
|
|
|
{ |
|
|
|
VertexOutput o; |
|
|
|
UNITY_SETUP_INSTANCE_ID(v); |
|
|
|
|
|
|
|
// Vertex transformations performed by graph |
|
|
|
${VertexShader} |
|
|
|
VertexDescriptionInputs vdi = (VertexDescriptionInputs)0; |
|
|
|
|
|
|
VertexDescription vd = PopulateVertexData(vdi); |
|
|
|
v.vertex.xyz = vd.Position; |
|
|
|
|
|
|
|
float3 positionWS = TransformObjectToWorld(v.vertex.xyz); |
|
|
|
o.uv = uv1; |
|
|
|
|
|
|
|
float3 positionWS = TransformObjectToWorld(v.vertex.xyz); |
|
|
|
float3 normalWS = TransformObjectToWorldDir(v.normal); |
|
|
|
|
|
|
|
float invNdotL = 1.0 - saturate(dot(_LightDirection, normalWS)); |
|
|
|
|
|
|
// _ShadowBias.x sign depens on if platform has reversed z buffer |
|
|
|
clipPos.z += _ShadowBias.x; |
|
|
|
|
|
|
|
#if defined(UNITY_REVERSED_Z) |
|
|
|
clipPos.z = min(clipPos.z, 1.0); |
|
|
|
#else |
|
|
|
clipPos.z = max(clipPos.z, 0.0); |
|
|
|
#endif |
|
|
|
return clipPos; |
|
|
|
} |
|
|
|
#if UNITY_REVERSED_Z |
|
|
|
clipPos.z = min(clipPos.z, clipPos.w * UNITY_NEAR_CLIP_VALUE); |
|
|
|
#else |
|
|
|
clipPos.z = max(clipPos.z, clipPos.w * UNITY_NEAR_CLIP_VALUE); |
|
|
|
#endif |
|
|
|
o.clipPos = clipPos; |
|
|
|
|
|
|
|
return o; |
|
|
|
} |
|
|
|
|
|
|
|
half4 ShadowPassFragment() : SV_TARGET |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
Pass |
|
|
|
{ |
|
|
|
Name "DepthOnly" |
|
|
|
Tags{"LightMode" = "DepthOnly"} |
|
|
|
|
|
|
|
ZWrite On |
|
|
|
|
|
|
HLSLPROGRAM |
|
|
|
// Required to compile gles 2.0 with standard srp library |
|
|
|
#pragma prefer_hlslcc gles |
|
|
|
#pragma exclude_renderers d3d11_9x |
|
|
|
|
|
|
|
//-------------------------------------- |
|
|
|
// GPU Instancing |
|
|
|
#pragma multi_compile_instancing |
|
|
|
|
|
|
|
#pragma vertex vert |
|
|
|
#pragma fragment frag |
|
|
|
|
|
|
|
|
|
|
#include "CoreRP/ShaderLibrary/Color.hlsl" |
|
|
|
|
|
|
|
${Graph} |
|
|
|
float4 vert(GraphVertexInput v) : SV_POSITION |
|
|
|
struct VertexOutput |
|
|
|
{ |
|
|
|
float2 uv : TEXCOORD0; |
|
|
|
float4 clipPos : SV_POSITION; |
|
|
|
}; |
|
|
|
|
|
|
|
VertexOutput vert(GraphVertexInput v) |
|
|
|
// Vertex transformations performed by graph |
|
|
|
VertexOutput o = (VertexOutput)0; |
|
|
|
UNITY_SETUP_INSTANCE_ID(v); |
|
|
|
|
|
|
|
// Vertex transformations performed by graph |
|
|
|
${VertexShader} |
|
|
|
VertexDescriptionInputs vdi = (VertexDescriptionInputs)0; |
|
|
|
|
|
|
|
|
|
|
v.vertex.xyz = vd.Position; |
|
|
|
|
|
|
|
return TransformObjectToHClip(v.vertex.xyz); |
|
|
|
|
|
|
|
o.uv = uv1; |
|
|
|
o.clipPos = TransformObjectToHClip(v.vertex.xyz); |
|
|
|
return o; |
|
|
|
} |
|
|
|
|
|
|
|
half4 frag() : SV_TARGET |
|
|
|
|
|
|
// This pass it not used during regular rendering, only for lightmap baking. |
|
|
|
Pass |
|
|
|
{ |
|
|
|
Name "Meta" |
|
|
|
Tags{"LightMode" = "Meta"} |
|
|
|
|
|
|
|
Cull Off |
|
|
|