1442 lines
55 KiB
GLSL

// Made with Amplify Shader Editor v1.9.9.4
// Available at the Unity Asset Store - http://u3d.as/y3X
Shader "Mingle/Floor/White Horizon"
{
Properties
{
[HideInInspector] _AlphaCutoff("Alpha Cutoff ", Range(0, 1)) = 0.5
[HideInInspector] _EmissionColor("Emission Color", Color) = (1,1,1,1)
_BaseMap( "BaseMap", 2D ) = "white" {}
_Radius( "Radius", Range( 0, 1 ) ) = 1
_Smoothness( "Smoothness", Range( 0.01, 1 ) ) = 0.5
[HideInInspector] _texcoord( "", 2D ) = "white" {}
[ToggleOff] _SpecularHighlights("Specular Highlights", Float) = 1.0
[ToggleOff] _EnvironmentReflections("Environment Reflections", Float) = 1.0
[ToggleUI] _ReceiveShadows("Receive Shadows", Float) = 1.0
[HideInInspector] _QueueOffset("_QueueOffset", Float) = 0
[HideInInspector] _QueueControl("_QueueControl", Float) = -1
[HideInInspector][NoScaleOffset] unity_Lightmaps("unity_Lightmaps", 2DArray) = "" {}
[HideInInspector][NoScaleOffset] unity_LightmapsInd("unity_LightmapsInd", 2DArray) = "" {}
[HideInInspector][NoScaleOffset] unity_ShadowMasks("unity_ShadowMasks", 2DArray) = "" {}
// NiloToon Screen Space Outline
_ScreenSpaceOutlineIntensity("Screen Space Outline Intensity", Range(0,1)) = 1
[HDR]_ScreenSpaceOutlineColor("Screen Space Outline Color", Color) = (1,1,1,1)
_ScreenSpaceOutlineWidth("Screen Space Outline Width", Float) = 1
}
SubShader
{
Tags { "RenderPipeline"="UniversalPipeline" "RenderType"="Opaque" "UniversalMaterialType"="Lit" "Queue"="Geometry" "IgnoreProjector"="True" }
Cull Back
ZWrite On
ZTest LEqual
Offset 0 , 0
AlphaToMask Off
LOD 300
HLSLINCLUDE
#pragma target 3.0
#pragma prefer_hlslcc gles
// GPU Instancing not available in WebGL
// #pragma exclude_renderers gles //
ENDHLSL
Pass
{
Name "Forward"
Tags { "LightMode"="UniversalForwardOnly" }
Blend One Zero, One Zero
ZWrite On
ZTest LEqual
Offset 0 , 0
ColorMask RGBA
HLSLPROGRAM
#define _NORMAL_DROPOFF_TS 1
#pragma shader_feature_local_fragment _RECEIVE_SHADOWS_OFF
#pragma shader_feature_local_fragment _SPECULARHIGHLIGHTS_OFF
#pragma shader_feature_local_fragment _ENVIRONMENTREFLECTIONS_OFF
#pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION
#pragma multi_compile_instancing
#pragma multi_compile _ LOD_FADE_CROSSFADE
#define ASE_VERSION 19904
#define ASE_SRP_VERSION 170200
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN
#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
#pragma multi_compile _ EVALUATE_SH_MIXED EVALUATE_SH_VERTEX
#pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS
#pragma multi_compile_fragment _ _REFLECTION_PROBE_BLENDING
#pragma multi_compile_fragment _ _REFLECTION_PROBE_BOX_PROJECTION
#pragma multi_compile_fragment _ _REFLECTION_PROBE_ATLAS
#pragma multi_compile_fragment _ _SHADOWS_SOFT _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH
#pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3
#pragma multi_compile _ _LIGHT_LAYERS
#pragma multi_compile_fragment _ _LIGHT_COOKIES
#pragma multi_compile _ _CLUSTER_LIGHT_LOOP
#pragma multi_compile _ LIGHTMAP_SHADOW_MIXING
#pragma multi_compile _ SHADOWS_SHADOWMASK
#pragma multi_compile _ DIRLIGHTMAP_COMBINED
#pragma multi_compile _ LIGHTMAP_ON
#pragma multi_compile _ LIGHTMAP_BICUBIC_SAMPLING
#pragma multi_compile _ DYNAMICLIGHTMAP_ON
#pragma multi_compile _ USE_LEGACY_LIGHTMAPS
#pragma vertex vert
#pragma fragment frag
#if defined(_SPECULAR_SETUP) && defined(_SPECULAR_COLOR)
#define _SPECULAR_COLOR 1
#endif
#define SHADERPASS SHADERPASS_FORWARD
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl"
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Fog.hlsl"
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ProbeVolumeVariants.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl"
#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/Input.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureStack.hlsl"
#include_with_pragmas "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRenderingKeywords.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRendering.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/DebugMipmapStreamingMacros.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Shadows.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DBuffer.hlsl"
#include "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/ShaderPass.hlsl"
#if defined(LOD_FADE_CROSSFADE)
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/LODCrossFade.hlsl"
#endif
// NiloToon Screen Space Outline Support
// Note: Include NiloToon's utility files for screen space outline functionality
#if defined(_NILOTOON_GLOBAL_ENABLE_SCREENSPACE_OUTLINE)
#include "../../../../../../NiloToonURP/ShaderLibrary/NiloUtilityHLSL/NiloAllUtilIncludes.hlsl"
#endif
#define ASE_NEEDS_TEXTURE_COORDINATES0
#define ASE_NEEDS_FRAG_TEXTURE_COORDINATES0
#if defined(ASE_EARLY_Z_DEPTH_OPTIMIZE) && (SHADER_TARGET >= 45)
#define ASE_SV_DEPTH SV_DepthLessEqual
#define ASE_SV_POSITION_QUALIFIERS linear noperspective centroid
#else
#define ASE_SV_DEPTH SV_Depth
#define ASE_SV_POSITION_QUALIFIERS
#endif
struct Attributes
{
float4 positionOS : POSITION;
half3 normalOS : NORMAL;
half4 tangentOS : TANGENT;
float4 texcoord : TEXCOORD0;
#if defined(LIGHTMAP_ON) || defined(ASE_NEEDS_TEXTURE_COORDINATES1)
float4 texcoord1 : TEXCOORD1;
#endif
#if defined(DYNAMICLIGHTMAP_ON) || defined(ASE_NEEDS_TEXTURE_COORDINATES2)
float4 texcoord2 : TEXCOORD2;
#endif
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct PackedVaryings
{
ASE_SV_POSITION_QUALIFIERS float4 positionCS : SV_POSITION;
float3 positionWS : TEXCOORD0;
half3 normalWS : TEXCOORD1;
float4 tangentWS : TEXCOORD2;
float4 lightmapUVOrVertexSH : TEXCOORD3;
#if defined(ASE_FOG) || defined(_ADDITIONAL_LIGHTS_VERTEX)
half4 fogFactorAndVertexLight : TEXCOORD4;
#endif
#if defined(DYNAMICLIGHTMAP_ON)
float2 dynamicLightmapUV : TEXCOORD5;
#endif
#if defined(USE_APV_PROBE_OCCLUSION)
float4 probeOcclusion : TEXCOORD6;
#endif
float4 screenPos : TEXCOORD11; // NiloToon screen pos
float4 ase_texcoord7 : TEXCOORD7;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
CBUFFER_START(UnityPerMaterial)
float4 _BaseMap_ST;
float _Smoothness;
float _Radius;
// NiloToon Screen Space Outline
float _ScreenSpaceOutlineIntensity;
half3 _ScreenSpaceOutlineColor;
float _ScreenSpaceOutlineWidth;
float _Surface;
CBUFFER_END
// NiloToon Global Uniforms
float _NiloToonGlobalEnviMinimumShader;
float4 _NiloToonGlobalEnviShadowBorderTintColor;
float3 _NiloToonGlobalEnviGITintColor;
float3 _NiloToonGlobalEnviGIAddColor;
float4 _NiloToonGlobalEnviGIOverride;
float4 _NiloToonGlobalEnviAlbedoOverrideColor;
float4 _NiloToonGlobalEnviSurfaceColorResultOverrideColor;
float _GlobalScreenSpaceOutlineIntensityForEnvi;
float _GlobalScreenSpaceOutlineWidthMultiplierForEnvi;
float _GlobalScreenSpaceOutlineNormalsSensitivityOffsetForEnvi;
float _GlobalScreenSpaceOutlineDepthSensitivityOffsetForEnvi;
float _GlobalScreenSpaceOutlineDepthSensitivityDistanceFadeoutStrengthForEnvi;
half3 _GlobalScreenSpaceOutlineTintColorForEnvi;
float _CurrentCameraFOV;
#ifdef SCENEPICKINGPASS
float4 _SelectionID;
#endif
#ifdef SCENESELECTIONPASS
int _ObjectId;
int _PassValue;
#endif
sampler2D _BaseMap;
PackedVaryings VertexFunction( Attributes input )
{
PackedVaryings output = (PackedVaryings)0;
UNITY_SETUP_INSTANCE_ID(input);
UNITY_TRANSFER_INSTANCE_ID(input, output);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
output.ase_texcoord7.xy = input.texcoord.xy;
//setting value to unused interpolator channels and avoid initialization warnings
output.ase_texcoord7.zw = 0;
VertexPositionInputs vertexInput = GetVertexPositionInputs( input.positionOS.xyz );
VertexNormalInputs normalInput = GetVertexNormalInputs( input.normalOS, input.tangentOS );
output.positionCS = vertexInput.positionCS;
output.positionWS = vertexInput.positionWS;
output.normalWS = normalInput.normalWS;
real sign = input.tangentOS.w * GetOddNegativeScale();
half4 tangentWS = half4(normalInput.tangentWS.xyz, sign);
output.tangentWS = tangentWS;
OUTPUT_LIGHTMAP_UV( input.texcoord1, unity_LightmapST, output.lightmapUVOrVertexSH.xy );
#if defined(DYNAMICLIGHTMAP_ON)
output.dynamicLightmapUV = input.texcoord2.xy * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw;
#endif
OUTPUT_SH4(vertexInput.positionWS, output.normalWS.xyz, GetWorldSpaceNormalizeViewDir(vertexInput.positionWS), output.lightmapUVOrVertexSH.xyz, output.probeOcclusion);
half3 vertexLight = VertexLighting( vertexInput.positionWS, normalInput.normalWS );
half fogFactor = 0;
#if !defined(_FOG_FRAGMENT)
fogFactor = ComputeFogFactor( vertexInput.positionCS.z );
#endif
#if defined(ASE_FOG) || defined(_ADDITIONAL_LIGHTS_VERTEX)
output.fogFactorAndVertexLight = half4(fogFactor, vertexLight);
#endif
// NiloToon screen pos
output.screenPos = ComputeScreenPos(output.positionCS);
return output;
}
#if defined(ASE_TESSELLATION)
struct VertexControl
{
float4 positionOS : INTERNALTESSPOS;
half3 normalOS : NORMAL;
half4 tangentOS : TANGENT;
float4 texcoord : TEXCOORD0;
float4 texcoord1 : TEXCOORD1;
float4 texcoord2 : TEXCOORD2;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct TessellationFactors
{
float edge[3] : SV_TessFactor;
float inside : SV_InsideTessFactor;
};
VertexControl vert ( Attributes input )
{
VertexControl output;
UNITY_SETUP_INSTANCE_ID(input);
UNITY_TRANSFER_INSTANCE_ID(input, output);
output.positionOS = input.positionOS;
output.normalOS = input.normalOS;
output.tangentOS = input.tangentOS;
output.texcoord = input.texcoord;
output.texcoord1 = input.texcoord1;
output.texcoord2 = input.texcoord2;
return output;
}
TessellationFactors TessellationFunction (InputPatch<VertexControl,3> input)
{
TessellationFactors output;
float4 tf = 1;
float tessValue = _TessValue; float tessMin = _TessMin; float tessMax = _TessMax;
float edgeLength = _TessEdgeLength; float tessMaxDisp = _TessMaxDisp;
#if defined(ASE_FIXED_TESSELLATION)
tf = FixedTess( tessValue );
#elif defined(ASE_DISTANCE_TESSELLATION)
tf = DistanceBasedTess(input[0].positionOS, input[1].positionOS, input[2].positionOS, tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), _WorldSpaceCameraPos );
#elif defined(ASE_LENGTH_TESSELLATION)
tf = EdgeLengthBasedTess(input[0].positionOS, input[1].positionOS, input[2].positionOS, edgeLength, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams );
#elif defined(ASE_LENGTH_CULL_TESSELLATION)
tf = EdgeLengthBasedTessCull(input[0].positionOS, input[1].positionOS, input[2].positionOS, edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams, unity_CameraWorldClipPlanes );
#endif
output.edge[0] = tf.x; output.edge[1] = tf.y; output.edge[2] = tf.z; output.inside = tf.w;
return output;
}
[domain("tri")]
[partitioning("fractional_odd")]
[outputtopology("triangle_cw")]
[patchconstantfunc("TessellationFunction")]
[outputcontrolpoints(3)]
VertexControl HullFunction(InputPatch<VertexControl, 3> patch, uint id : SV_OutputControlPointID)
{
return patch[id];
}
[domain("tri")]
PackedVaryings DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
{
Attributes output = (Attributes) 0;
output.positionOS = patch[0].positionOS * bary.x + patch[1].positionOS * bary.y + patch[2].positionOS * bary.z;
output.normalOS = patch[0].normalOS * bary.x + patch[1].normalOS * bary.y + patch[2].normalOS * bary.z;
output.tangentOS = patch[0].tangentOS * bary.x + patch[1].tangentOS * bary.y + patch[2].tangentOS * bary.z;
output.texcoord = patch[0].texcoord * bary.x + patch[1].texcoord * bary.y + patch[2].texcoord * bary.z;
output.texcoord1 = patch[0].texcoord1 * bary.x + patch[1].texcoord1 * bary.y + patch[2].texcoord1 * bary.z;
output.texcoord2 = patch[0].texcoord2 * bary.x + patch[1].texcoord2 * bary.y + patch[2].texcoord2 * bary.z;
#if defined(ASE_PHONG_TESSELLATION)
float3 pp[3];
for (int i = 0; i < 3; ++i)
pp[i] = output.positionOS.xyz - patch[i].normalOS * (dot(output.positionOS.xyz, patch[i].normalOS) - dot(patch[i].positionOS.xyz, patch[i].normalOS));
float phongStrength = _TessPhongStrength;
output.positionOS.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * output.positionOS.xyz;
#endif
UNITY_TRANSFER_INSTANCE_ID(patch[0], output);
return VertexFunction(output);
}
#else
PackedVaryings vert ( Attributes input )
{
return VertexFunction( input );
}
#endif
half4 frag ( PackedVaryings input
#if defined( ASE_DEPTH_WRITE_ON )
,out float outputDepth : ASE_SV_DEPTH
#endif
#ifdef _WRITE_RENDERING_LAYERS
, out uint outRenderingLayers : SV_Target1
#endif
) : SV_Target
{
UNITY_SETUP_INSTANCE_ID(input);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
#if defined( _SURFACE_TYPE_TRANSPARENT )
const bool isTransparent = true;
#else
const bool isTransparent = false;
#endif
#if defined(LOD_FADE_CROSSFADE)
LODFadeCrossFade( input.positionCS );
#endif
#if defined(MAIN_LIGHT_CALCULATE_SHADOWS)
float4 shadowCoord = TransformWorldToShadowCoord( input.positionWS );
#else
float4 shadowCoord = float4(0, 0, 0, 0);
#endif
float renormFactor = 1.0 / max( FLT_MIN, length( input.normalWS ) );
float3 PositionWS = input.positionWS;
float3 ViewDirWS = GetWorldSpaceNormalizeViewDir( PositionWS );
float4 ShadowCoord = shadowCoord;
float4 ScreenPosNorm = float4( GetNormalizedScreenSpaceUV( input.positionCS ), input.positionCS.zw );
float4 ClipPos = ComputeClipSpacePosition( ScreenPosNorm.xy, input.positionCS.z ) * input.positionCS.w;
float4 ScreenPos = ComputeScreenPos( ClipPos );
float3 TangentWS = input.tangentWS.xyz * renormFactor;
float3 BitangentWS = cross( input.normalWS, input.tangentWS.xyz ) * input.tangentWS.w * renormFactor;
float3 NormalWS = input.normalWS * renormFactor;
float2 temp_cast_0 = (2.0).xx;
float2 temp_cast_1 = (-1.0).xx;
float2 texCoord12 = input.ase_texcoord7.xy * temp_cast_0 + temp_cast_1;
float smoothstepResult13 = smoothstep( _Radius , ( _Radius - _Smoothness ) , length( texCoord12 ));
float2 uv_BaseMap = input.ase_texcoord7.xy * _BaseMap_ST.xy + _BaseMap_ST.zw;
float layeredBlendVar18 = smoothstepResult13;
float4 layeredBlend18 = ( lerp( float4( 1,1,1,1 ),tex2D( _BaseMap, uv_BaseMap ) , layeredBlendVar18 ) );
float3 BaseColor = float3(0.5, 0.5, 0.5);
float3 Normal = float3(0, 0, 1);
float3 Specular = 0.5;
float Metallic = 0;
float Smoothness = 0.5;
float Occlusion = 1;
float3 Emission = layeredBlend18.rgb;
float Alpha = 1;
float AlphaClipThreshold = 0.5;
#if defined( ASE_DEPTH_WRITE_ON )
float DeviceDepth = ClipPos.z;
#endif
#if defined( _ALPHATEST_ON )
AlphaDiscard( Alpha, AlphaClipThreshold );
#endif
#if defined(MAIN_LIGHT_CALCULATE_SHADOWS) && defined(ASE_CHANGES_WORLD_POS)
ShadowCoord = TransformWorldToShadowCoord( PositionWS );
#endif
// NiloToon: albedo override
BaseColor = lerp(BaseColor, _NiloToonGlobalEnviAlbedoOverrideColor.rgb, _NiloToonGlobalEnviAlbedoOverrideColor.a);
InputData inputData = (InputData)0;
inputData.positionWS = PositionWS;
inputData.positionCS = float4( input.positionCS.xy, ClipPos.zw / ClipPos.w );
inputData.normalizedScreenSpaceUV = ScreenPosNorm.xy;
inputData.viewDirectionWS = ViewDirWS;
inputData.shadowCoord = ShadowCoord;
#ifdef _NORMALMAP
#if _NORMAL_DROPOFF_TS
inputData.normalWS = TransformTangentToWorld(Normal, half3x3(TangentWS, BitangentWS, NormalWS));
#elif _NORMAL_DROPOFF_OS
inputData.normalWS = TransformObjectToWorldNormal(Normal);
#elif _NORMAL_DROPOFF_WS
inputData.normalWS = Normal;
#endif
inputData.normalWS = NormalizeNormalPerPixel(inputData.normalWS);
#else
inputData.normalWS = NormalWS;
#endif
#ifdef ASE_FOG
inputData.fogCoord = InitializeInputDataFog(float4(inputData.positionWS, 1.0), input.fogFactorAndVertexLight.x);
#endif
#ifdef _ADDITIONAL_LIGHTS_VERTEX
inputData.vertexLighting = input.fogFactorAndVertexLight.yzw;
#endif
float3 SH = input.lightmapUVOrVertexSH.xyz;
#if defined(DYNAMICLIGHTMAP_ON)
inputData.bakedGI = SAMPLE_GI(input.lightmapUVOrVertexSH.xy, input.dynamicLightmapUV.xy, SH, inputData.normalWS);
inputData.shadowMask = SAMPLE_SHADOWMASK(input.lightmapUVOrVertexSH.xy);
#elif !defined(LIGHTMAP_ON) && (defined(PROBE_VOLUMES_L1) || defined(PROBE_VOLUMES_L2))
inputData.bakedGI = SAMPLE_GI( SH, GetAbsolutePositionWS(inputData.positionWS),
inputData.normalWS,
inputData.viewDirectionWS,
input.positionCS.xy,
input.probeOcclusion,
inputData.shadowMask );
#else
inputData.bakedGI = SAMPLE_GI(input.lightmapUVOrVertexSH.xy, SH, inputData.normalWS);
inputData.shadowMask = SAMPLE_SHADOWMASK(input.lightmapUVOrVertexSH.xy);
#endif
// NiloToon: GI edit and override
inputData.bakedGI = inputData.bakedGI * _NiloToonGlobalEnviGITintColor + _NiloToonGlobalEnviGIAddColor;
inputData.bakedGI = lerp(inputData.bakedGI, _NiloToonGlobalEnviGIOverride.rgb, _NiloToonGlobalEnviGIOverride.a);
SurfaceData surfaceData;
surfaceData.albedo = BaseColor;
surfaceData.metallic = saturate(Metallic);
surfaceData.specular = Specular;
surfaceData.smoothness = saturate(Smoothness),
surfaceData.occlusion = Occlusion,
surfaceData.emission = Emission,
surfaceData.alpha = saturate(Alpha);
surfaceData.normalTS = Normal;
surfaceData.clearCoatMask = 0;
surfaceData.clearCoatSmoothness = 1;
#if defined(_DBUFFER)
ApplyDecalToSurfaceData(input.positionCS, surfaceData, inputData);
#endif
half4 color = UniversalFragmentPBR( inputData, surfaceData);
// NiloToon: Shadow border tint color
#if defined(SHADOWS_SHADOWMASK) && defined(LIGHTMAP_ON)
half4 nilotoonShadowMask = inputData.shadowMask;
#elif !defined (LIGHTMAP_ON)
half4 nilotoonShadowMask = unity_ProbesOcclusion;
#else
half4 nilotoonShadowMask = half4(1, 1, 1, 1);
#endif
Light mainLight = GetMainLight(inputData.shadowCoord, inputData.positionWS, nilotoonShadowMask);
float isShadowEdge = 1-abs(mainLight.shadowAttenuation-0.5)*2;
color.rgb = lerp(color.rgb, color.rgb * _NiloToonGlobalEnviShadowBorderTintColor.rgb, isShadowEdge * _NiloToonGlobalEnviShadowBorderTintColor.a);
// NiloToon: global surface color result override
color.rgb = lerp(color.rgb, _NiloToonGlobalEnviSurfaceColorResultOverrideColor.rgb, _NiloToonGlobalEnviSurfaceColorResultOverrideColor.a);
// NiloToon: Screen space outline
#if _NILOTOON_GLOBAL_ENABLE_SCREENSPACE_OUTLINE
if(_Surface == 0)
{
float2 SV_POSITIONxy = input.positionCS.xy;
float finalOutlineWidth = _ScreenSpaceOutlineWidth * _GlobalScreenSpaceOutlineWidthMultiplierForEnvi;
float finalNormalsSensitivity = max(0,1 + _GlobalScreenSpaceOutlineNormalsSensitivityOffsetForEnvi);
float finalDepthSensitivity = max(0,1 + _GlobalScreenSpaceOutlineDepthSensitivityOffsetForEnvi);
float selfLinearDepth = abs(mul(UNITY_MATRIX_V, float4(input.positionWS,1)).z);
finalDepthSensitivity *= 0.35;
float isScreenSpaceOutlineArea = IsScreenSpaceOutline(
SV_POSITIONxy,
finalOutlineWidth,
finalDepthSensitivity,
finalNormalsSensitivity,
selfLinearDepth,
_GlobalScreenSpaceOutlineDepthSensitivityDistanceFadeoutStrengthForEnvi,
_CurrentCameraFOV,
inputData.viewDirectionWS);
isScreenSpaceOutlineArea *= _GlobalScreenSpaceOutlineIntensityForEnvi * _ScreenSpaceOutlineIntensity;
color.rgb = lerp(color.rgb, color.rgb * _GlobalScreenSpaceOutlineTintColorForEnvi * _ScreenSpaceOutlineColor.rgb, isScreenSpaceOutlineArea);
}
#endif
color.rgb = MixFog(color.rgb, inputData.fogCoord);
color.a = OutputAlpha(color.a, IsSurfaceTypeTransparent(_Surface));
#if defined( ASE_DEPTH_WRITE_ON )
outputDepth = DeviceDepth;
#endif
#ifdef _WRITE_RENDERING_LAYERS
outRenderingLayers = GetMeshRenderingLayer();
#endif
return color;
}
ENDHLSL
}
Pass
{
Name "ShadowCaster"
Tags { "LightMode"="ShadowCaster" }
ZWrite On
ZTest LEqual
AlphaToMask Off
ColorMask 0
HLSLPROGRAM
#define _NORMAL_DROPOFF_TS 1
#pragma multi_compile_instancing
#pragma multi_compile _ LOD_FADE_CROSSFADE
#define ASE_VERSION 19904
#define ASE_SRP_VERSION 170200
#pragma multi_compile_vertex _ _CASTING_PUNCTUAL_LIGHT_SHADOW
#pragma vertex vert
#pragma fragment frag
#define SHADERPASS SHADERPASS_SHADOWCASTER
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
#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"
#if defined(LOD_FADE_CROSSFADE)
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/LODCrossFade.hlsl"
#endif
struct Attributes
{
float4 positionOS : POSITION;
float3 normalOS : NORMAL;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct PackedVaryings
{
float4 positionCS : SV_POSITION;
float4 clipPosV : TEXCOORD0;
#if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
float3 positionWS : TEXCOORD1;
#endif
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
CBUFFER_START(UnityPerMaterial)
float4 _BaseMap_ST;
float _Smoothness;
float _Radius;
float _ScreenSpaceOutlineIntensity;
half3 _ScreenSpaceOutlineColor;
float _ScreenSpaceOutlineWidth;
float _Surface;
CBUFFER_END
float3 _LightDirection;
float3 _LightPosition;
PackedVaryings VertexFunction( Attributes input )
{
PackedVaryings output;
UNITY_SETUP_INSTANCE_ID(input);
UNITY_TRANSFER_INSTANCE_ID(input, output);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO( output );
float3 positionWS = TransformObjectToWorld( input.positionOS.xyz );
float3 normalWS = TransformObjectToWorldNormal( input.normalOS );
#if _CASTING_PUNCTUAL_LIGHT_SHADOW
float3 lightDirectionWS = normalize(_LightPosition - positionWS);
#else
float3 lightDirectionWS = _LightDirection;
#endif
float4 positionCS = TransformWorldToHClip(ApplyShadowBias(positionWS, normalWS, lightDirectionWS));
#if UNITY_REVERSED_Z
positionCS.z = min(positionCS.z, UNITY_NEAR_CLIP_VALUE);
#else
positionCS.z = max(positionCS.z, UNITY_NEAR_CLIP_VALUE);
#endif
#if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
output.positionWS = positionWS;
#endif
output.positionCS = positionCS;
output.clipPosV = positionCS;
return output;
}
#if defined(ASE_TESSELLATION)
struct VertexControl
{
float4 positionOS : INTERNALTESSPOS;
float3 normalOS : NORMAL;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct TessellationFactors
{
float edge[3] : SV_TessFactor;
float inside : SV_InsideTessFactor;
};
VertexControl vert ( Attributes input )
{
VertexControl output;
UNITY_SETUP_INSTANCE_ID(input);
UNITY_TRANSFER_INSTANCE_ID(input, output);
output.positionOS = input.positionOS;
output.normalOS = input.normalOS;
return output;
}
TessellationFactors TessellationFunction (InputPatch<VertexControl,3> input)
{
TessellationFactors output;
float4 tf = 1;
float tessValue = _TessValue; float tessMin = _TessMin; float tessMax = _TessMax;
float edgeLength = _TessEdgeLength; float tessMaxDisp = _TessMaxDisp;
#if defined(ASE_FIXED_TESSELLATION)
tf = FixedTess( tessValue );
#elif defined(ASE_DISTANCE_TESSELLATION)
tf = DistanceBasedTess(input[0].positionOS, input[1].positionOS, input[2].positionOS, tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), _WorldSpaceCameraPos );
#elif defined(ASE_LENGTH_TESSELLATION)
tf = EdgeLengthBasedTess(input[0].positionOS, input[1].positionOS, input[2].positionOS, edgeLength, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams );
#elif defined(ASE_LENGTH_CULL_TESSELLATION)
tf = EdgeLengthBasedTessCull(input[0].positionOS, input[1].positionOS, input[2].positionOS, edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams, unity_CameraWorldClipPlanes );
#endif
output.edge[0] = tf.x; output.edge[1] = tf.y; output.edge[2] = tf.z; output.inside = tf.w;
return output;
}
[domain("tri")]
[partitioning("fractional_odd")]
[outputtopology("triangle_cw")]
[patchconstantfunc("TessellationFunction")]
[outputcontrolpoints(3)]
VertexControl HullFunction(InputPatch<VertexControl, 3> patch, uint id : SV_OutputControlPointID)
{
return patch[id];
}
[domain("tri")]
PackedVaryings DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
{
Attributes output = (Attributes) 0;
output.positionOS = patch[0].positionOS * bary.x + patch[1].positionOS * bary.y + patch[2].positionOS * bary.z;
output.normalOS = patch[0].normalOS * bary.x + patch[1].normalOS * bary.y + patch[2].normalOS * bary.z;
#if defined(ASE_PHONG_TESSELLATION)
float3 pp[3];
for (int i = 0; i < 3; ++i)
pp[i] = output.positionOS.xyz - patch[i].normalOS * (dot(output.positionOS.xyz, patch[i].normalOS) - dot(patch[i].positionOS.xyz, patch[i].normalOS));
float phongStrength = _TessPhongStrength;
output.positionOS.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * output.positionOS.xyz;
#endif
UNITY_TRANSFER_INSTANCE_ID(patch[0], output);
return VertexFunction(output);
}
#else
PackedVaryings vert ( Attributes input )
{
return VertexFunction( input );
}
#endif
half4 frag(PackedVaryings input ) : SV_TARGET
{
UNITY_SETUP_INSTANCE_ID( input );
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX( input );
#if defined(LOD_FADE_CROSSFADE)
LODFadeCrossFade( input.positionCS );
#endif
#if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
float3 PositionWS = input.positionWS;
#endif
float4 ShadowCoord = float4( 0, 0, 0, 0 );
float4 ClipPos = input.clipPosV;
float4 ScreenPos = ComputeScreenPos( input.clipPosV );
float Alpha = 1;
float AlphaClipThreshold = 0.5;
#if defined(_ALPHATEST_ON)
AlphaDiscard( Alpha, AlphaClipThreshold );
#endif
return 0;
}
ENDHLSL
}
Pass
{
Name "DepthOnly"
Tags { "LightMode"="DepthOnly" }
ZWrite On
ColorMask R
AlphaToMask Off
HLSLPROGRAM
#define _NORMAL_DROPOFF_TS 1
#pragma multi_compile_instancing
#pragma multi_compile _ LOD_FADE_CROSSFADE
#define ASE_VERSION 19904
#define ASE_SRP_VERSION 170200
#pragma vertex vert
#pragma fragment frag
#define SHADERPASS SHADERPASS_DEPTHONLY
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
#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"
#if defined(LOD_FADE_CROSSFADE)
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/LODCrossFade.hlsl"
#endif
struct Attributes
{
float4 positionOS : POSITION;
float3 normalOS : NORMAL;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct PackedVaryings
{
float4 positionCS : SV_POSITION;
float4 clipPosV : TEXCOORD0;
#if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
float3 positionWS : TEXCOORD1;
#endif
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
CBUFFER_START(UnityPerMaterial)
float4 _BaseMap_ST;
float _Smoothness;
float _Radius;
float _ScreenSpaceOutlineIntensity;
half3 _ScreenSpaceOutlineColor;
float _ScreenSpaceOutlineWidth;
float _Surface;
CBUFFER_END
PackedVaryings VertexFunction( Attributes input )
{
PackedVaryings output;
UNITY_SETUP_INSTANCE_ID(input);
UNITY_TRANSFER_INSTANCE_ID(input, output);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
float3 positionWS = TransformObjectToWorld( input.positionOS.xyz );
float4 positionCS = TransformWorldToHClip( positionWS );
#if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
output.positionWS = positionWS;
#endif
output.positionCS = positionCS;
output.clipPosV = positionCS;
return output;
}
#if defined(ASE_TESSELLATION)
struct VertexControl
{
float4 positionOS : INTERNALTESSPOS;
float3 normalOS : NORMAL;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct TessellationFactors
{
float edge[3] : SV_TessFactor;
float inside : SV_InsideTessFactor;
};
VertexControl vert ( Attributes input )
{
VertexControl output;
UNITY_SETUP_INSTANCE_ID(input);
UNITY_TRANSFER_INSTANCE_ID(input, output);
output.positionOS = input.positionOS;
output.normalOS = input.normalOS;
return output;
}
TessellationFactors TessellationFunction (InputPatch<VertexControl,3> input)
{
TessellationFactors output;
float4 tf = 1;
float tessValue = _TessValue; float tessMin = _TessMin; float tessMax = _TessMax;
float edgeLength = _TessEdgeLength; float tessMaxDisp = _TessMaxDisp;
#if defined(ASE_FIXED_TESSELLATION)
tf = FixedTess( tessValue );
#elif defined(ASE_DISTANCE_TESSELLATION)
tf = DistanceBasedTess(input[0].positionOS, input[1].positionOS, input[2].positionOS, tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), _WorldSpaceCameraPos );
#elif defined(ASE_LENGTH_TESSELLATION)
tf = EdgeLengthBasedTess(input[0].positionOS, input[1].positionOS, input[2].positionOS, edgeLength, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams );
#elif defined(ASE_LENGTH_CULL_TESSELLATION)
tf = EdgeLengthBasedTessCull(input[0].positionOS, input[1].positionOS, input[2].positionOS, edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams, unity_CameraWorldClipPlanes );
#endif
output.edge[0] = tf.x; output.edge[1] = tf.y; output.edge[2] = tf.z; output.inside = tf.w;
return output;
}
[domain("tri")]
[partitioning("fractional_odd")]
[outputtopology("triangle_cw")]
[patchconstantfunc("TessellationFunction")]
[outputcontrolpoints(3)]
VertexControl HullFunction(InputPatch<VertexControl, 3> patch, uint id : SV_OutputControlPointID)
{
return patch[id];
}
[domain("tri")]
PackedVaryings DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
{
Attributes output = (Attributes) 0;
output.positionOS = patch[0].positionOS * bary.x + patch[1].positionOS * bary.y + patch[2].positionOS * bary.z;
output.normalOS = patch[0].normalOS * bary.x + patch[1].normalOS * bary.y + patch[2].normalOS * bary.z;
#if defined(ASE_PHONG_TESSELLATION)
float3 pp[3];
for (int i = 0; i < 3; ++i)
pp[i] = output.positionOS.xyz - patch[i].normalOS * (dot(output.positionOS.xyz, patch[i].normalOS) - dot(patch[i].positionOS.xyz, patch[i].normalOS));
float phongStrength = _TessPhongStrength;
output.positionOS.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * output.positionOS.xyz;
#endif
UNITY_TRANSFER_INSTANCE_ID(patch[0], output);
return VertexFunction(output);
}
#else
PackedVaryings vert ( Attributes input )
{
return VertexFunction( input );
}
#endif
half4 frag(PackedVaryings input ) : SV_TARGET
{
UNITY_SETUP_INSTANCE_ID(input);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
#if defined(LOD_FADE_CROSSFADE)
LODFadeCrossFade( input.positionCS );
#endif
#if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
float3 PositionWS = input.positionWS;
#endif
float4 ShadowCoord = float4( 0, 0, 0, 0 );
float4 ClipPos = input.clipPosV;
float4 ScreenPos = ComputeScreenPos( input.clipPosV );
float Alpha = 1;
float AlphaClipThreshold = 0.5;
#if defined(_ALPHATEST_ON)
AlphaDiscard( Alpha, AlphaClipThreshold );
#endif
return 0;
}
ENDHLSL
}
Pass
{
Name "DepthNormals"
Tags { "LightMode"="DepthNormalsOnly" }
ZWrite On
ZTest LEqual
HLSLPROGRAM
#define _NORMAL_DROPOFF_TS 1
#pragma multi_compile_instancing
#pragma multi_compile _ LOD_FADE_CROSSFADE
#define ASE_VERSION 19904
#define ASE_SRP_VERSION 170200
#pragma vertex vert
#pragma fragment frag
#define SHADERPASS SHADERPASS_DEPTHNORMALS
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
#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"
#if defined(LOD_FADE_CROSSFADE)
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/LODCrossFade.hlsl"
#endif
struct Attributes
{
float4 positionOS : POSITION;
float3 normalOS : NORMAL;
float4 tangentOS : TANGENT;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct PackedVaryings
{
float4 positionCS : SV_POSITION;
float4 clipPosV : TEXCOORD0;
float3 normalWS : TEXCOORD1;
#if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
float3 positionWS : TEXCOORD2;
#endif
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
CBUFFER_START(UnityPerMaterial)
float4 _BaseMap_ST;
float _Smoothness;
float _Radius;
float _ScreenSpaceOutlineIntensity;
half3 _ScreenSpaceOutlineColor;
float _ScreenSpaceOutlineWidth;
float _Surface;
CBUFFER_END
PackedVaryings VertexFunction( Attributes input )
{
PackedVaryings output;
UNITY_SETUP_INSTANCE_ID(input);
UNITY_TRANSFER_INSTANCE_ID(input, output);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
float3 positionWS = TransformObjectToWorld( input.positionOS.xyz );
float3 normalWS = TransformObjectToWorldNormal( input.normalOS );
float4 positionCS = TransformWorldToHClip( positionWS );
#if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
output.positionWS = positionWS;
#endif
output.positionCS = positionCS;
output.clipPosV = positionCS;
output.normalWS = normalWS;
return output;
}
#if defined(ASE_TESSELLATION)
struct VertexControl
{
float4 positionOS : INTERNALTESSPOS;
float3 normalOS : NORMAL;
float4 tangentOS : TANGENT;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct TessellationFactors
{
float edge[3] : SV_TessFactor;
float inside : SV_InsideTessFactor;
};
VertexControl vert ( Attributes input )
{
VertexControl output;
UNITY_SETUP_INSTANCE_ID(input);
UNITY_TRANSFER_INSTANCE_ID(input, output);
output.positionOS = input.positionOS;
output.normalOS = input.normalOS;
output.tangentOS = input.tangentOS;
return output;
}
TessellationFactors TessellationFunction (InputPatch<VertexControl,3> input)
{
TessellationFactors output;
float4 tf = 1;
float tessValue = _TessValue; float tessMin = _TessMin; float tessMax = _TessMax;
float edgeLength = _TessEdgeLength; float tessMaxDisp = _TessMaxDisp;
#if defined(ASE_FIXED_TESSELLATION)
tf = FixedTess( tessValue );
#elif defined(ASE_DISTANCE_TESSELLATION)
tf = DistanceBasedTess(input[0].positionOS, input[1].positionOS, input[2].positionOS, tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), _WorldSpaceCameraPos );
#elif defined(ASE_LENGTH_TESSELLATION)
tf = EdgeLengthBasedTess(input[0].positionOS, input[1].positionOS, input[2].positionOS, edgeLength, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams );
#elif defined(ASE_LENGTH_CULL_TESSELLATION)
tf = EdgeLengthBasedTessCull(input[0].positionOS, input[1].positionOS, input[2].positionOS, edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams, unity_CameraWorldClipPlanes );
#endif
output.edge[0] = tf.x; output.edge[1] = tf.y; output.edge[2] = tf.z; output.inside = tf.w;
return output;
}
[domain("tri")]
[partitioning("fractional_odd")]
[outputtopology("triangle_cw")]
[patchconstantfunc("TessellationFunction")]
[outputcontrolpoints(3)]
VertexControl HullFunction(InputPatch<VertexControl, 3> patch, uint id : SV_OutputControlPointID)
{
return patch[id];
}
[domain("tri")]
PackedVaryings DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
{
Attributes output = (Attributes) 0;
output.positionOS = patch[0].positionOS * bary.x + patch[1].positionOS * bary.y + patch[2].positionOS * bary.z;
output.normalOS = patch[0].normalOS * bary.x + patch[1].normalOS * bary.y + patch[2].normalOS * bary.z;
output.tangentOS = patch[0].tangentOS * bary.x + patch[1].tangentOS * bary.y + patch[2].tangentOS * bary.z;
#if defined(ASE_PHONG_TESSELLATION)
float3 pp[3];
for (int i = 0; i < 3; ++i)
pp[i] = output.positionOS.xyz - patch[i].normalOS * (dot(output.positionOS.xyz, patch[i].normalOS) - dot(patch[i].positionOS.xyz, patch[i].normalOS));
float phongStrength = _TessPhongStrength;
output.positionOS.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * output.positionOS.xyz;
#endif
UNITY_TRANSFER_INSTANCE_ID(patch[0], output);
return VertexFunction(output);
}
#else
PackedVaryings vert ( Attributes input )
{
return VertexFunction( input );
}
#endif
half4 frag(PackedVaryings input ) : SV_TARGET
{
UNITY_SETUP_INSTANCE_ID(input);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
#if defined(LOD_FADE_CROSSFADE)
LODFadeCrossFade( input.positionCS );
#endif
#if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
float3 PositionWS = input.positionWS;
#endif
float4 ShadowCoord = float4( 0, 0, 0, 0 );
float4 ClipPos = input.clipPosV;
float4 ScreenPos = ComputeScreenPos( input.clipPosV );
float Alpha = 1;
float AlphaClipThreshold = 0.5;
#if defined(_ALPHATEST_ON)
AlphaDiscard( Alpha, AlphaClipThreshold );
#endif
float3 normalWS = input.normalWS;
return half4(NormalizeNormalPerPixel(normalWS), 0.0);
}
ENDHLSL
}
Pass
{
Name "Meta"
Tags { "LightMode"="Meta" }
Cull Off
HLSLPROGRAM
#define _NORMAL_DROPOFF_TS 1
#pragma multi_compile_instancing
#define ASE_VERSION 19904
#define ASE_SRP_VERSION 170200
#pragma vertex vert
#pragma fragment frag
#pragma shader_feature EDITOR_VISUALIZATION
#define SHADERPASS SHADERPASS_META
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
#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.universal/ShaderLibrary/MetaInput.hlsl"
#define ASE_NEEDS_TEXTURE_COORDINATES0
#define ASE_NEEDS_FRAG_TEXTURE_COORDINATES0
struct Attributes
{
float4 positionOS : POSITION;
float3 normalOS : NORMAL;
float4 texcoord : TEXCOORD0;
float4 texcoord1 : TEXCOORD1;
float4 texcoord2 : TEXCOORD2;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct PackedVaryings
{
float4 positionCS : SV_POSITION;
#if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
float3 positionWS : TEXCOORD0;
#endif
float4 ase_texcoord1 : TEXCOORD1;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
CBUFFER_START(UnityPerMaterial)
float4 _BaseMap_ST;
float _Smoothness;
float _Radius;
float _ScreenSpaceOutlineIntensity;
half3 _ScreenSpaceOutlineColor;
float _ScreenSpaceOutlineWidth;
float _Surface;
CBUFFER_END
sampler2D _BaseMap;
PackedVaryings VertexFunction( Attributes input )
{
PackedVaryings output;
UNITY_SETUP_INSTANCE_ID(input);
UNITY_TRANSFER_INSTANCE_ID(input, output);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
output.ase_texcoord1.xy = input.texcoord.xy;
//setting value to unused interpolator channels and avoid initialization warnings
output.ase_texcoord1.zw = 0;
float3 positionWS = TransformObjectToWorld( input.positionOS.xyz );
#if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
output.positionWS = positionWS;
#endif
output.positionCS = UnityMetaVertexPosition( input.positionOS.xyz, input.texcoord1.xy, input.texcoord2.xy );
return output;
}
#if defined(ASE_TESSELLATION)
struct VertexControl
{
float4 positionOS : INTERNALTESSPOS;
float3 normalOS : NORMAL;
float4 texcoord : TEXCOORD0;
float4 texcoord1 : TEXCOORD1;
float4 texcoord2 : TEXCOORD2;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct TessellationFactors
{
float edge[3] : SV_TessFactor;
float inside : SV_InsideTessFactor;
};
VertexControl vert ( Attributes input )
{
VertexControl output;
UNITY_SETUP_INSTANCE_ID(input);
UNITY_TRANSFER_INSTANCE_ID(input, output);
output.positionOS = input.positionOS;
output.normalOS = input.normalOS;
output.texcoord = input.texcoord;
output.texcoord1 = input.texcoord1;
output.texcoord2 = input.texcoord2;
return output;
}
TessellationFactors TessellationFunction (InputPatch<VertexControl,3> input)
{
TessellationFactors output;
float4 tf = 1;
float tessValue = _TessValue; float tessMin = _TessMin; float tessMax = _TessMax;
float edgeLength = _TessEdgeLength; float tessMaxDisp = _TessMaxDisp;
#if defined(ASE_FIXED_TESSELLATION)
tf = FixedTess( tessValue );
#elif defined(ASE_DISTANCE_TESSELLATION)
tf = DistanceBasedTess(input[0].positionOS, input[1].positionOS, input[2].positionOS, tessValue, tessMin, tessMax, GetObjectToWorldMatrix(), _WorldSpaceCameraPos );
#elif defined(ASE_LENGTH_TESSELLATION)
tf = EdgeLengthBasedTess(input[0].positionOS, input[1].positionOS, input[2].positionOS, edgeLength, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams );
#elif defined(ASE_LENGTH_CULL_TESSELLATION)
tf = EdgeLengthBasedTessCull(input[0].positionOS, input[1].positionOS, input[2].positionOS, edgeLength, tessMaxDisp, GetObjectToWorldMatrix(), _WorldSpaceCameraPos, _ScreenParams, unity_CameraWorldClipPlanes );
#endif
output.edge[0] = tf.x; output.edge[1] = tf.y; output.edge[2] = tf.z; output.inside = tf.w;
return output;
}
[domain("tri")]
[partitioning("fractional_odd")]
[outputtopology("triangle_cw")]
[patchconstantfunc("TessellationFunction")]
[outputcontrolpoints(3)]
VertexControl HullFunction(InputPatch<VertexControl, 3> patch, uint id : SV_OutputControlPointID)
{
return patch[id];
}
[domain("tri")]
PackedVaryings DomainFunction(TessellationFactors factors, OutputPatch<VertexControl, 3> patch, float3 bary : SV_DomainLocation)
{
Attributes output = (Attributes) 0;
output.positionOS = patch[0].positionOS * bary.x + patch[1].positionOS * bary.y + patch[2].positionOS * bary.z;
output.normalOS = patch[0].normalOS * bary.x + patch[1].normalOS * bary.y + patch[2].normalOS * bary.z;
output.texcoord = patch[0].texcoord * bary.x + patch[1].texcoord * bary.y + patch[2].texcoord * bary.z;
output.texcoord1 = patch[0].texcoord1 * bary.x + patch[1].texcoord1 * bary.y + patch[2].texcoord1 * bary.z;
output.texcoord2 = patch[0].texcoord2 * bary.x + patch[1].texcoord2 * bary.y + patch[2].texcoord2 * bary.z;
#if defined(ASE_PHONG_TESSELLATION)
float3 pp[3];
for (int i = 0; i < 3; ++i)
pp[i] = output.positionOS.xyz - patch[i].normalOS * (dot(output.positionOS.xyz, patch[i].normalOS) - dot(patch[i].positionOS.xyz, patch[i].normalOS));
float phongStrength = _TessPhongStrength;
output.positionOS.xyz = phongStrength * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-phongStrength) * output.positionOS.xyz;
#endif
UNITY_TRANSFER_INSTANCE_ID(patch[0], output);
return VertexFunction(output);
}
#else
PackedVaryings vert ( Attributes input )
{
return VertexFunction( input );
}
#endif
half4 frag(PackedVaryings input ) : SV_TARGET
{
UNITY_SETUP_INSTANCE_ID(input);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
#if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
float3 PositionWS = input.positionWS;
#endif
float4 ShadowCoord = float4( 0, 0, 0, 0 );
float2 temp_cast_0 = (2.0).xx;
float2 temp_cast_1 = (-1.0).xx;
float2 texCoord12 = input.ase_texcoord1.xy * temp_cast_0 + temp_cast_1;
float smoothstepResult13 = smoothstep( _Radius , ( _Radius - _Smoothness ) , length( texCoord12 ));
float2 uv_BaseMap = input.ase_texcoord1.xy * _BaseMap_ST.xy + _BaseMap_ST.zw;
float layeredBlendVar18 = smoothstepResult13;
float4 layeredBlend18 = ( lerp( float4( 1,1,1,1 ),tex2D( _BaseMap, uv_BaseMap ) , layeredBlendVar18 ) );
float3 BaseColor = float3(0.5, 0.5, 0.5);
float3 Emission = layeredBlend18.rgb;
float Alpha = 1;
float AlphaClipThreshold = 0.5;
#if defined(_ALPHATEST_ON)
AlphaDiscard( Alpha, AlphaClipThreshold );
#endif
MetaInput metaInput = (MetaInput)0;
metaInput.Albedo = BaseColor;
metaInput.Emission = Emission;
return UnityMetaFragment(metaInput);
}
ENDHLSL
}
}
CustomEditor "UnityEditor.ShaderGraphUnlitGUI"
FallBack "Hidden/Shader Graph/FallbackError"
Fallback Off
}
/*ASEBEGIN
Version=19904
Node;AmplifyShaderEditor.RangedFloatNode, AmplifyShaderEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null;10;-1408,-32;Inherit;False;Constant;_1;-1;0;0;Create;True;0;0;0;False;0;False;-1;0;0;0;0;1;FLOAT;0
Node;AmplifyShaderEditor.RangedFloatNode, AmplifyShaderEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null;11;-1408,-112;Inherit;False;Constant;_2;2;0;0;Create;True;0;0;0;False;0;False;2;0;0;0;0;1;FLOAT;0
Node;AmplifyShaderEditor.TextureCoordinatesNode, AmplifyShaderEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null;12;-1280,-112;Inherit;False;0;-1;2;3;2;SAMPLER2D;;False;0;FLOAT2;1,1;False;1;FLOAT2;0,0;False;5;FLOAT2;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
Node;AmplifyShaderEditor.RangedFloatNode, AmplifyShaderEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null;7;-1280,80;Inherit;False;Property;_Smoothness;Smoothness;2;0;Create;True;0;0;0;False;0;False;0.5;0.5;0.01;1;0;1;FLOAT;0
Node;AmplifyShaderEditor.SimpleSubtractOpNode, AmplifyShaderEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null;8;-992,48;Inherit;False;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0
Node;AmplifyShaderEditor.LengthOpNode, AmplifyShaderEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null;9;-992,-16;Inherit;False;1;0;FLOAT2;0,0;False;1;FLOAT;0
Node;AmplifyShaderEditor.RangedFloatNode, AmplifyShaderEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null;6;-1280,16;Inherit;False;Property;_Radius;Radius;1;0;Create;True;0;0;0;False;0;False;1;1;0;1;0;1;FLOAT;0
Node;AmplifyShaderEditor.SmoothstepOpNode, AmplifyShaderEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null;13;-864,0;Inherit;True;3;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;1;False;1;FLOAT;0
Node;AmplifyShaderEditor.SamplerNode, AmplifyShaderEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null;5;-944,-240;Inherit;True;Property;_BaseMap;BaseMap;0;0;Create;True;0;0;0;False;0;False;-1;None;None;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;False;8;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;6;FLOAT;0;False;7;SAMPLERSTATE;;False;6;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4;FLOAT3;5
Node;AmplifyShaderEditor.LayeredBlendNode, AmplifyShaderEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null;18;-624,-240;Inherit;False;6;0;FLOAT;0;False;1;COLOR;1,1,1,1;False;2;COLOR;1,1,1,1;False;3;FLOAT;0;False;4;FLOAT;0;False;5;FLOAT;0;False;1;COLOR;0
Node;AmplifyShaderEditor.TemplateMultiPassMasterNode, AmplifyShaderEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null;1;-352,-120.4;Float;False;False;-1;3;UnityEditor.ShaderGraphUnlitGUI;300;14;New Amplify Shader;2534d4d29a40afc46a3cc49af189fcb4;True;ShadowCaster;0;1;ShadowCaster;0;False;False;False;False;False;False;False;False;False;False;False;False;True;0;False;;False;True;0;False;;False;False;False;False;False;False;False;False;False;False;False;True;1;False;;True;3;False;;True;True;0;False;;0;False;;True;5;RenderPipeline=UniversalPipeline;RenderType=Opaque=RenderType;UniversalMaterialType=Lit;Queue=Geometry=Queue=0;IgnoreProjector=True;True;2;True;11;d3d11;glcore;gles3;metal;vulkan;xboxone;xboxseries;playstation;ps4;ps5;switch;0;False;False;False;False;False;False;False;False;False;False;False;False;True;0;False;;False;False;False;True;False;False;False;False;0;False;;False;False;False;False;False;False;False;False;False;True;1;False;;True;3;False;;False;True;1;LightMode=ShadowCaster;False;False;0;;0;0;Standard;0;False;0
Node;AmplifyShaderEditor.TemplateMultiPassMasterNode, AmplifyShaderEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null;2;-352,-87.39999;Float;False;False;-1;3;UnityEditor.ShaderGraphUnlitGUI;300;14;New Amplify Shader;2534d4d29a40afc46a3cc49af189fcb4;True;DepthOnly;0;2;DepthOnly;0;False;False;False;False;False;False;False;False;False;False;False;False;True;0;False;;False;True;0;False;;False;False;False;False;False;False;False;False;False;False;False;True;1;False;;True;3;False;;True;True;0;False;;0;False;;True;5;RenderPipeline=UniversalPipeline;RenderType=Opaque=RenderType;UniversalMaterialType=Lit;Queue=Geometry=Queue=0;IgnoreProjector=True;True;2;True;11;d3d11;glcore;gles3;metal;vulkan;xboxone;xboxseries;playstation;ps4;ps5;switch;0;False;False;False;False;False;False;False;False;False;False;False;False;True;0;False;;False;False;False;True;True;False;False;False;0;False;;False;False;False;False;False;False;False;False;False;True;1;False;;False;False;True;1;LightMode=DepthOnly;False;False;0;;0;0;Standard;0;False;0
Node;AmplifyShaderEditor.TemplateMultiPassMasterNode, AmplifyShaderEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null;3;-352,-54.39999;Float;False;False;-1;3;UnityEditor.ShaderGraphUnlitGUI;300;14;New Amplify Shader;2534d4d29a40afc46a3cc49af189fcb4;True;DepthNormals;0;3;DepthNormals;0;False;False;False;False;False;False;False;False;False;False;False;False;True;0;False;;False;True;0;False;;False;False;False;False;False;False;False;False;False;False;False;True;1;False;;True;3;False;;True;True;0;False;;0;False;;True;5;RenderPipeline=UniversalPipeline;RenderType=Opaque=RenderType;UniversalMaterialType=Lit;Queue=Geometry=Queue=0;IgnoreProjector=True;True;2;True;11;d3d11;glcore;gles3;metal;vulkan;xboxone;xboxseries;playstation;ps4;ps5;switch;0;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;1;False;;True;3;False;;False;True;1;LightMode=DepthNormalsOnly;False;False;0;;0;0;Standard;0;False;0
Node;AmplifyShaderEditor.TemplateMultiPassMasterNode, AmplifyShaderEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null;4;-352,-21.39999;Float;False;False;-1;3;UnityEditor.ShaderGraphUnlitGUI;300;14;New Amplify Shader;2534d4d29a40afc46a3cc49af189fcb4;True;Meta;0;4;Meta;0;False;False;False;False;False;False;False;False;False;False;False;False;True;0;False;;False;True;0;False;;False;False;False;False;False;False;False;False;False;False;False;True;1;False;;True;3;False;;True;True;0;False;;0;False;;True;5;RenderPipeline=UniversalPipeline;RenderType=Opaque=RenderType;UniversalMaterialType=Lit;Queue=Geometry=Queue=0;IgnoreProjector=True;True;2;True;11;d3d11;glcore;gles3;metal;vulkan;xboxone;xboxseries;playstation;ps4;ps5;switch;0;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;2;False;;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;1;LightMode=Meta;False;False;0;;0;0;Standard;0;False;0
Node;AmplifyShaderEditor.TemplateMultiPassMasterNode, AmplifyShaderEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null;0;-352,-352;Float;False;True;-1;3;UnityEditor.ShaderGraphUnlitGUI;300;14;Mingle/Floor/White Horizon;2534d4d29a40afc46a3cc49af189fcb4;True;Forward;0;0;Forward;10;False;False;False;False;False;False;False;False;False;False;False;False;True;0;False;;False;True;0;False;;False;False;False;False;False;False;False;False;False;False;False;True;1;False;;True;3;False;;True;True;0;False;;0;False;;True;5;RenderPipeline=UniversalPipeline;RenderType=Opaque=RenderType;UniversalMaterialType=Lit;Queue=Geometry=Queue=0;IgnoreProjector=True;True;2;True;11;d3d11;glcore;gles3;metal;vulkan;xboxone;xboxseries;playstation;ps4;ps5;switch;0;False;True;1;1;False;;0;False;;1;1;False;;0;False;;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;True;True;True;True;0;False;;False;False;False;False;False;False;False;True;False;0;False;;255;False;;255;False;;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;False;True;1;False;;True;3;False;;True;True;0;False;;0;False;;True;1;LightMode=UniversalForwardOnly;False;False;0;;0;0;Standard;14;Workflow;1;0;Surface;0;0; Blend;0;0;Two Sided;1;0;Alpha Clipping;0;0;Fragment Normal Space;0;0;Cast Shadows;1;0;Receive Shadows;2;0;Specular Highlights;2;0;Environment Reflections;2;0;Receive SSAO;1;0;GPU Instancing;1;0;LOD CrossFade;1;0;NiloToon Screen Space Outline;0;0;0;5;True;True;True;True;True;False;;False;0
WireConnection;12;0;11;0
WireConnection;12;1;10;0
WireConnection;8;0;6;0
WireConnection;8;1;7;0
WireConnection;9;0;12;0
WireConnection;13;0;9;0
WireConnection;13;1;6;0
WireConnection;13;2;8;0
WireConnection;18;0;13;0
WireConnection;18;2;5;0
WireConnection;0;2;18;0
ASEEND*/
//CHKSM=2BD7053C0628F168A0CD2BFDD6E819C4CD45A937