您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
280 行
7.7 KiB
280 行
7.7 KiB
Pass
|
|
{
|
|
Name "ShadowCaster"
|
|
Tags{"LightMode" = "ShadowCaster"}
|
|
|
|
ZWrite On ZTest LEqual
|
|
|
|
// Material options generated by graph
|
|
${Culling}
|
|
HLSLPROGRAM
|
|
// Required to compile gles 2.0 with standard srp library
|
|
#pragma prefer_hlslcc gles
|
|
#pragma exclude_renderers d3d11_9x
|
|
#pragma target 2.0
|
|
|
|
//--------------------------------------
|
|
// GPU Instancing
|
|
#pragma multi_compile_instancing
|
|
|
|
#pragma vertex ShadowPassVertex
|
|
#pragma fragment ShadowPassFragment
|
|
|
|
// Defines generated by graph
|
|
${Defines}
|
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
|
|
|
|
${Graph}
|
|
struct VertexOutput
|
|
{
|
|
float2 uv : TEXCOORD0;
|
|
float4 clipPos : SV_POSITION;
|
|
// Interpolators defined by graph
|
|
${VertexOutputStruct}
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
float3 _LightDirection;
|
|
|
|
VertexOutput ShadowPassVertex(GraphVertexInput v)
|
|
{
|
|
VertexOutput o;
|
|
UNITY_SETUP_INSTANCE_ID(v);
|
|
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
|
|
|
// Vertex transformations performed by graph
|
|
${VertexShader}
|
|
VertexDescriptionInputs vdi = (VertexDescriptionInputs)0;
|
|
|
|
// Vertex description inputs defined by graph
|
|
${VertexShaderDescriptionInputs}
|
|
VertexDescription vd = PopulateVertexData(vdi);
|
|
v.vertex.xyz = vd.Position;
|
|
|
|
// Vertex shader outputs defined by graph
|
|
${VertexShaderOutputs}
|
|
|
|
float3 positionWS = TransformObjectToWorld(v.vertex.xyz);
|
|
float3 normalWS = TransformObjectToWorldNormal(v.normal);
|
|
|
|
float4 clipPos = TransformWorldToHClip(ApplyShadowBias(positionWS, normalWS, _LightDirection));
|
|
|
|
#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(VertexOutput IN ${FaceSign}) : SV_TARGET
|
|
{
|
|
UNITY_SETUP_INSTANCE_ID(IN);
|
|
|
|
// Pixel transformations performed by graph
|
|
${PixelShader}
|
|
SurfaceDescriptionInputs surfaceInput = (SurfaceDescriptionInputs)0;
|
|
|
|
// Surface description inputs defined by graph
|
|
${PixelShaderSurfaceInputs}
|
|
SurfaceDescription surf = PopulateSurfaceData(surfaceInput);
|
|
|
|
float3 Albedo = float3(0.5, 0.5, 0.5);
|
|
float3 Emission = 0;
|
|
float Alpha = 1;
|
|
float AlphaClipThreshold = 0;
|
|
|
|
// Surface description remap performed by graph
|
|
${PixelShaderSurfaceRemap}
|
|
#if _AlphaClip
|
|
clip(Alpha - AlphaClipThreshold);
|
|
#endif
|
|
return 0;
|
|
}
|
|
|
|
ENDHLSL
|
|
}
|
|
|
|
Pass
|
|
{
|
|
Name "DepthOnly"
|
|
Tags{"LightMode" = "DepthOnly"}
|
|
|
|
ZWrite On
|
|
ColorMask 0
|
|
|
|
// Material options generated by graph
|
|
${Culling}
|
|
HLSLPROGRAM
|
|
// Required to compile gles 2.0 with standard srp library
|
|
#pragma prefer_hlslcc gles
|
|
#pragma exclude_renderers d3d11_9x
|
|
#pragma target 2.0
|
|
|
|
//--------------------------------------
|
|
// GPU Instancing
|
|
#pragma multi_compile_instancing
|
|
|
|
#pragma vertex vert
|
|
#pragma fragment frag
|
|
|
|
// Defines generated by graph
|
|
${Defines}
|
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
|
|
|
|
${Graph}
|
|
struct VertexOutput
|
|
{
|
|
float2 uv : TEXCOORD0;
|
|
float4 clipPos : SV_POSITION;
|
|
// Interpolators defined by graph
|
|
${VertexOutputStruct}
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
UNITY_VERTEX_OUTPUT_STEREO
|
|
};
|
|
|
|
VertexOutput vert(GraphVertexInput v)
|
|
{
|
|
VertexOutput o = (VertexOutput)0;
|
|
UNITY_SETUP_INSTANCE_ID(v);
|
|
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
|
|
|
// Vertex transformations performed by graph
|
|
${VertexShader}
|
|
VertexDescriptionInputs vdi = (VertexDescriptionInputs)0;
|
|
|
|
// Vertex description inputs defined by graph
|
|
${VertexShaderDescriptionInputs}
|
|
VertexDescription vd = PopulateVertexData(vdi);
|
|
v.vertex.xyz = vd.Position;
|
|
|
|
// Vertex shader outputs defined by graph
|
|
${VertexShaderOutputs}
|
|
o.clipPos = TransformObjectToHClip(v.vertex.xyz);
|
|
return o;
|
|
}
|
|
|
|
half4 frag(VertexOutput IN ${FaceSign}) : SV_TARGET
|
|
{
|
|
UNITY_SETUP_INSTANCE_ID(IN);
|
|
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(IN);
|
|
|
|
// Pixel transformations performed by graph
|
|
${PixelShader}
|
|
SurfaceDescriptionInputs surfaceInput = (SurfaceDescriptionInputs)0;
|
|
|
|
// Surface description inputs defined by graph
|
|
${PixelShaderSurfaceInputs}
|
|
SurfaceDescription surf = PopulateSurfaceData(surfaceInput);
|
|
|
|
float3 Albedo = float3(0.5, 0.5, 0.5);
|
|
float3 Emission = 0;
|
|
float Alpha = 1;
|
|
float AlphaClipThreshold = 0;
|
|
|
|
// Surface description remap performed by graph
|
|
${PixelShaderSurfaceRemap}
|
|
#if _AlphaClip
|
|
clip(Alpha - AlphaClipThreshold);
|
|
#endif
|
|
return 0;
|
|
}
|
|
ENDHLSL
|
|
}
|
|
|
|
// This pass it not used during regular rendering, only for lightmap baking.
|
|
Pass
|
|
{
|
|
Name "Meta"
|
|
Tags{"LightMode" = "Meta"}
|
|
|
|
Cull Off
|
|
|
|
HLSLPROGRAM
|
|
// Required to compile gles 2.0 with standard srp library
|
|
#pragma prefer_hlslcc gles
|
|
#pragma exclude_renderers d3d11_9x
|
|
#pragma target 2.0
|
|
|
|
#pragma vertex vert
|
|
#pragma fragment frag
|
|
|
|
float4 _MainTex_ST;
|
|
|
|
// Defines generated by graph
|
|
${Defines}
|
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/MetaInput.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
|
|
|
|
#pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
|
|
|
${Graph}
|
|
struct VertexOutput
|
|
{
|
|
float2 uv : TEXCOORD0;
|
|
float4 clipPos : SV_POSITION;
|
|
// Interpolators defined by graph
|
|
${VertexOutputStruct}
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
UNITY_VERTEX_OUTPUT_STEREO
|
|
};
|
|
|
|
VertexOutput vert(GraphVertexInput v)
|
|
{
|
|
VertexOutput o = (VertexOutput)0;
|
|
UNITY_SETUP_INSTANCE_ID(v);
|
|
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
|
|
|
// Vertex transformations performed by graph
|
|
${VertexShader}
|
|
|
|
// Vertex shader outputs defined by graph
|
|
${VertexShaderOutputs}
|
|
o.clipPos = MetaVertexPosition(v.vertex, uv1, uv1, unity_LightmapST, unity_DynamicLightmapST);
|
|
return o;
|
|
}
|
|
|
|
half4 frag(VertexOutput IN ${FaceSign}) : SV_TARGET
|
|
{
|
|
UNITY_SETUP_INSTANCE_ID(IN);
|
|
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(IN);
|
|
|
|
// Pixel transformations performed by graph
|
|
${PixelShader}
|
|
SurfaceDescriptionInputs surfaceInput = (SurfaceDescriptionInputs)0;
|
|
|
|
// Surface description inputs defined by graph
|
|
${PixelShaderSurfaceInputs}
|
|
SurfaceDescription surf = PopulateSurfaceData(surfaceInput);
|
|
|
|
float3 Albedo = float3(0.5, 0.5, 0.5);
|
|
float3 Emission = 0;
|
|
float Alpha = 1;
|
|
float AlphaClipThreshold = 0;
|
|
|
|
// Surface description remap performed by graph
|
|
${PixelShaderSurfaceRemap}
|
|
#if _AlphaClip
|
|
clip(Alpha - AlphaClipThreshold);
|
|
#endif
|
|
|
|
MetaInput metaInput = (MetaInput)0;
|
|
metaInput.Albedo = Albedo;
|
|
metaInput.Emission = Emission;
|
|
|
|
return MetaFragment(metaInput);
|
|
}
|
|
ENDHLSL
|
|
}
|