使用shader graph翻译到代码可以使用连线工具快速制作效果并转换为代码,如果你对shader的“贴心/详细”报错,以及提示不完善等等问题感到恼火,这个方式或许可以一定程度上缓解以上问题。
本次使用的三个shader graph资源:https://download.csdn.net/download/qq_55895529/88489974?spm=1001.2014.3001.5503
首先这里有一个这样效果的shader graph
参数如下
赋值shader graph的代码,代码非常多且其中有很多个pass,取其第一个pass的内容。
Shader "Shader Graphs/LightFlow"
{
Properties
{
_FresnelPower("FresnelPower", Float) = 1
_EmissionColor("EmissionColor", Color) = (0.2783019, 0.7026262, 1, 0)
_EmissionColorIntensity("EmissionColorIntensity", Float) = 12
[NoScaleOffset]_FlowMap("FlowMap", 2D) = "white" {}
_FlowScroll("FlowScroll", Vector) = (0.1, 0.1, 0, 0)
_FlowMapUVTiling("FlowMapUVTiling", Vector) = (1, 1, 0, 0)
_FlowMapUVOffset("FlowMapUVOffset", Vector) = (0, 0, 0, 0)
_FlowMapUVTimeSpeed("FlowMapUVTimeSpeed", Float) = 6
_FlowMapIntensity("FlowMapIntensity", Float) = 1
_FlowScrollPeriod("FlowScrollPeriod", Float) = 5
[NoScaleOffset]_FlowSampleTexture("FlowSampleTexture", 2D) = "white" {}
_FlowSampleScale("FlowSampleScale", Float) = 0
_FlowPower("FlowPower", Float) = 1
_FlowStepV2("FlowStepV2", Vector) = (0, 1, 0, 0)
_FlowLightIntensity("FlowLightIntensity", Float) = 1
_DepthMulti("DepthMulti", Float) = 1
_DepthColor("DepthColor", Color) = (1, 1, 1, 0)
_DepthStepV2("DepthStepV2", Vector) = (0.2, 1, 0, 0)
_DepthIntensity("DepthIntensity", Float) = 1
[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) = "" {}
}
SubShader
{
Tags
{
"RenderPipeline"="UniversalPipeline"
"RenderType"="Transparent"
"UniversalMaterialType" = "Lit"
"Queue"="Transparent"
"DisableBatching"="False"
"ShaderGraphShader"="true"
"ShaderGraphTargetId"="UniversalLitSubTarget"
}
Pass
{
Name "Universal Forward"
Tags
{
"LightMode" = "UniversalForward"
}
// Render State
Cull Back
Blend One OneMinusSrcAlpha, One OneMinusSrcAlpha
ZTest LEqual
ZWrite Off
// Debug
//
// --------------------------------------------------
// Pass
HLSLPROGRAM
// Pragmas
#pragma target 2.0
#pragma multi_compile_instancing
#pragma multi_compile_fog
#pragma instancing_options renderinglayer
#pragma vertex vert
#pragma fragment frag
// Keywords
#pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION
#pragma multi_compile _ LIGHTMAP_ON
#pragma multi_compile _ DYNAMICLIGHTMAP_ON
#pragma multi_compile _ DIRLIGHTMAP_COMBINED
#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_fragment _ _ADDITIONAL_LIGHT_SHADOWS
#pragma multi_compile_fragment _ _REFLECTION_PROBE_BLENDING
#pragma multi_compile_fragment _ _REFLECTION_PROBE_BOX_PROJECTION
#pragma multi_compile_fragment _ _SHADOWS_SOFT
#pragma multi_compile _ LIGHTMAP_SHADOW_MIXING
#pragma multi_compile _ SHADOWS_SHADOWMASK
#pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3
#pragma multi_compile_fragment _ _LIGHT_LAYERS
#pragma multi_compile_fragment _ DEBUG_DISPLAY
#pragma multi_compile_fragment _ _LIGHT_COOKIES
#pragma multi_compile _ _FORWARD_PLUS
// GraphKeywords:
// Defines
#define _NORMALMAP 1
#define _NORMAL_DROPOFF_TS 1
#define ATTRIBUTES_NEED_NORMAL
#define ATTRIBUTES_NEED_TANGENT
#define ATTRIBUTES_NEED_TEXCOORD0
#define ATTRIBUTES_NEED_TEXCOORD1
#define ATTRIBUTES_NEED_TEXCOORD2
#define VARYINGS_NEED_POSITION_WS
#define VARYINGS_NEED_NORMAL_WS
#define VARYINGS_NEED_TANGENT_WS
#define VARYINGS_NEED_TEXCOORD0
#define VARYINGS_NEED_FOG_AND_VERTEX_LIGHT
#define VARYINGS_NEED_SHADOW_COORD
#define FEATURES_GRAPH_VERTEX
/* WARNING: $splice Could not find named fragment 'PassInstancing' */
#define SHADERPASS SHADERPASS_FORWARD
#define _FOG_FRAGMENT 1
#define _SURFACE_TYPE_TRANSPARENT 1
#define _ALPHAPREMULTIPLY_ON 1
#define REQUIRE_DEPTH_TEXTURE
/* WARNING: $splice Could not find named fragment 'DotsInstancingVars' */
// custom interpolator pre-include
/* WARNING: $splice Could not find named fragment 'sgci_CustomInterpolatorPreInclude' */
// Includes
#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 "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 "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"
// --------------------------------------------------
// Structs and Packing
// custom interpolators pre packing
/* WARNING: $splice Could not find named fragment 'CustomInterpolatorPrePacking' */
struct Attributes
{
float3 positionOS : POSITION;
float3 normalOS : NORMAL;
float4 tangentOS : TANGENT;
float4 uv0 : TEXCOORD0;
float4 uv1 : TEXCOORD1;
float4 uv2 : TEXCOORD2;
#if UNITY_ANY_INSTANCING_ENABLED
uint instanceID : INSTANCEID_SEMANTIC;
#endif
};
struct Varyings
{
float4 positionCS : SV_POSITION;
float3 positionWS;
float3 normalWS;
float4 tangentWS;
float4 texCoord0;
#if defined(LIGHTMAP_ON)
float2 staticLightmapUV;
#endif
#if defined(DYNAMICLIGHTMAP_ON)
float2 dynamicLightmapUV;
#endif
#if !defined(LIGHTMAP_ON)
float3 sh;
#endif
float4 fogFactorAndVertexLight;
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
float4 shadowCoord;
#endif
#if UNITY_ANY_INSTANCING_ENABLED
uint instanceID : CUSTOM_INSTANCE_ID;
#endif
#if (defined(UNITY_STEREO_MULTIVIEW_ENABLED)) || (defined(UNITY_STEREO_INSTANCING_ENABLED) && (defined(SHADER_API_GLES3) || defined(SHADER_API_GLCORE)))
uint stereoTargetEyeIndexAsBlendIdx0 : BLENDINDICES0;
#endif
#if (defined(UNITY_STEREO_INSTANCING_ENABLED))
uint stereoTargetEyeIndexAsRTArrayIdx : SV_RenderTargetArrayIndex;
#endif
#if defined(SHADER_STAGE_FRAGMENT) && defined(VARYINGS_NEED_CULLFACE)
FRONT_FACE_TYPE cullFace : FRONT_FACE_SEMANTIC;
#endif
};
struct SurfaceDescriptionInputs
{
float3 WorldSpaceNormal;
float3 TangentSpaceNormal;
float3 WorldSpacePosition;
float4 ScreenPosition;
float2 NDCPosition;
float2 PixelPosition;
float4 uv0;
float3 TimeParameters;
};
struct VertexDescriptionInputs
{
float3 ObjectSpaceNormal;
float3 ObjectSpaceTangent;
float3 ObjectSpacePosition;
};
struct PackedVaryings
{
float4 positionCS : SV_POSITION;
#if defined(LIGHTMAP_ON)
float2 staticLightmapUV : INTERP0;
#endif
#if defined(DYNAMICLIGHTMAP_ON)
float2 dynamicLightmapUV : INTERP1;
#endif
#if !defined(LIGHTMAP_ON)
float3 sh : INTERP2;
#endif
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
float4 shadowCoord : INTERP3;
#endif
float4 tangentWS : INTERP4;
float4 texCoord0 : INTERP5;
float4 fogFactorAndVertexLight : INTERP6;
float3 positionWS : INTERP7;
float3 normalWS : INTERP8;
#if UNITY_ANY_INSTANCING_ENABLED
uint instanceID : CUSTOM_INSTANCE_ID;
#endif
#if (defined(UNITY_STEREO_MULTIVIEW_ENABLED)) || (defined(UNITY_STEREO_INSTANCING_ENABLED) && (defined(SHADER_API_GLES3) || defined(SHADER_API_GLCORE)))
uint stereoTargetEyeIndexAsBlendIdx0 : BLENDINDICES0;
#endif
#if (defined(UNITY_STEREO_INSTANCING_ENABLED))
uint stereoTargetEyeIndexAsRTArrayIdx : SV_RenderTargetArrayIndex;
#endif
#if defined(SHADER_STAGE_FRAGMENT) && defined(VARYINGS_NEED_CULLFACE)
FRONT_FACE_TYPE cullFace : FRONT_FACE_SEMANTIC;
#endif
};
PackedVaryings PackVaryings (Varyings input)
{
PackedVaryings output;
ZERO_INITIALIZE(PackedVaryings, output);
output.positionCS = input.positionCS;
#if defined(LIGHTMAP_ON)
output.staticLightmapUV = input.staticLightmapUV;
#endif
#if defined(DYNAMICLIGHTMAP_ON)
output.dynamicLightmapUV = input.dynamicLightmapUV;
#endif
#if !defined(LIGHTMAP_ON)
output.sh = input.sh;
#endif
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
output.shadowCoord = input.shadowCoord;
#endif
output.tangentWS.xyzw = input.tangentWS;
output.texCoord0.xyzw = input.texCoord0;
output.fogFactorAndVertexLight.xyzw = input.fogFactorAndVertexLight;
output.positionWS.xyz = input.positionWS;
output.normalWS.xyz = input.normalWS;
#if UNITY_ANY_INSTANCING_ENABLED
output.instanceID = input.instanceID;
#endif
#if (defined(UNITY_STEREO_MULTIVIEW_ENABLED)) || (defined(UNITY_STEREO_INSTANCING_ENABLED) && (defined(SHADER_API_GLES3) || defined(SHADER_API_GLCORE)))
output.stereoTargetEyeIndexAsBlendIdx0 = input.stereoTargetEyeIndexAsBlendIdx0;
#endif
#if (defined(UNITY_STEREO_INSTANCING_ENABLED))
output.stereoTargetEyeIndexAsRTArrayIdx = input.stereoTargetEyeIndexAsRTArrayIdx;
#endif
#if defined(SHADER_STAGE_FRAGMENT) && defined(VARYINGS_NEED_CULLFACE)
output.cullFace = input.cullFace;
#endif
return output;
}
Varyings UnpackVaryings (PackedVaryings input)
{
Varyings output;
output.positionCS = input.positionCS;
#if defined(LIGHTMAP_ON)
output.staticLightmapUV = input.staticLightmapUV;
#endif
#if defined(DYNAMICLIGHTMAP_ON)
output.dynamicLightmapUV = input.dynamicLightmapUV;
#endif
#if !defined(LIGHTMAP_ON)
output.sh = input.sh;
#endif
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
output.shadowCoord = input.shadowCoord;
#endif
output.tangentWS = input.tangentWS.xyzw;
output.texCoord0 = input.texCoord0.xyzw;
output.fogFactorAndVertexLight = input.fogFactorAndVertexLight.xyzw;
output.positionWS = input.positionWS.xyz;
output.normalWS = input.normalWS.xyz;
#if UNITY_ANY_INSTANCING_ENABLED
output.instanceID = input.instanceID;
#endif
#if (defined(UNITY_STEREO_MULTIVIEW_ENABLED)) || (defined(UNITY_STEREO_INSTANCING_ENABLED) && (defined(SHADER_API_GLES3) || defined(SHADER_API_GLCORE)))
output.stereoTargetEyeIndexAsBlendIdx0 = input.stereoTargetEyeIndexAsBlendIdx0;
#endif
#if (defined(UNITY_STEREO_INSTANCING_ENABLED))
output.stereoTargetEyeIndexAsRTArrayIdx = input.stereoTargetEyeIndexAsRTArrayIdx;
#endif
#if defined(SHADER_STAGE_FRAGMENT) && defined(VARYINGS_NEED_CULLFACE)
output.cullFace = input.cullFace;
#endif
return output;
}
// --------------------------------------------------
// Graph
// Graph Properties
CBUFFER_START(UnityPerMaterial)
float _FresnelPower;
float4 _EmissionColor;
float _EmissionColorIntensity;
float4 _FlowMap_TexelSize;
float2 _FlowScroll;
float _FlowMapIntensity;
float _FlowScrollPeriod;
float4 _FlowSampleTexture_TexelSize;
float _FlowMapUVTimeSpeed;
float2 _FlowMapUVTiling;
float2 _FlowMapUVOffset;
float _FlowSampleScale;
float _FlowPower;
float2 _FlowStepV2;
float _FlowLightIntensity;
float _DepthMulti;
float4 _DepthColor;
float2 _DepthStepV2;
float _DepthIntensity;
CBUFFER_END
// Object and Global properties
SAMPLER(SamplerState_Linear_Repeat);
TEXTURE2D(_FlowMap);
SAMPLER(sampler_FlowMap);
TEXTURE2D(_FlowSampleTexture);
SAMPLER(sampler_FlowSampleTexture);
static Gradient _FlowGradient = {0,4,2,{float4(1,1,1,0),float4(0.5676471,0.5676471,0.5676471,0.1088273),float4(0.09179813,0.09179813,0.09179813,0.3882353),float4(0,0,0,1),float4(0,0,0,0),float4(0,0,0,0),float4(0,0,0,0),float4(0,0,0,0)},{float2(1,0),float2(1,0.9941252),float2(0,0),float2(0,0),float2(0,0),float2(0,0),float2(0,0),float2(0,0)}};
// Graph Includes
// GraphIncludes:
// -- Property used by ScenePickingPass
#ifdef SCENEPICKINGPASS
float4 _SelectionID;
#endif
// -- Properties used by SceneSelectionPass
#ifdef SCENESELECTIONPASS
int _ObjectId;
int _PassValue;
#endif
// Graph Functions
void Unity_SceneDepth_Eye_float(float4 UV, out float Out)
{
if (unity_OrthoParams.w == 1.0)
{
Out = LinearEyeDepth(ComputeWorldSpacePosition(UV.xy, SHADERGRAPH_SAMPLE_SCENE_DEPTH(UV.xy), UNITY_MATRIX_I_VP), UNITY_MATRIX_V);
}
else
{
Out = LinearEyeDepth(SHADERGRAPH_SAMPLE_SCENE_DEPTH(UV.xy), _ZBufferParams);
}
}
void Unity_Subtract_float(float A, float B, out float Out)
{
Out = A - B;
}
void Unity_Multiply_float_float(float A, float B, out float Out)
{
Out = A * B;
}
void Unity_Smoothstep_float(float Edge1, float Edge2, float In, out float Out)
{
Out = smoothstep(Edge1, Edge2, In);
}
void Unity_OneMinus_float(float In, out float Out)
{
Out = 1 - In;
}
void Unity_Multiply_float4_float4(float4 A, float4 B, out float4 Out)
{
Out = A * B;
}
void Unity_ViewVectorWorld_float(out float3 Out, float3 WorldSpacePosition)
{
Out = _WorldSpaceCameraPos.xyz - GetAbsolutePositionWS(WorldSpacePosition);
if(!IsPerspectiveProjection())
{
Out = GetViewForwardDir() * dot(Out, GetViewForwardDir());
}
}
void Unity_FresnelEffect_float(float3 Normal, float3 ViewDir, float Power, out float Out)
{
Out = pow((1.0 - saturate(dot(normalize(Normal), normalize(ViewDir)))), Power);
}
void Unity_Multiply_float2_float2(float2 A, float2 B, out float2 Out)
{
Out = A * B;
}
void Unity_Add_float2(float2 A, float2 B, out float2 Out)
{
Out = A + B;
}
void Unity_TilingAndOffset_float(float2 UV, float2 Tiling, float2 Offset, out float2 Out)
{
Out = UV * Tiling + Offset;
}
void Unity_Sine_float(float In, out float Out)
{
Out = sin(In);
}
void Unity_Remap_float(float In, float2 InMinMax, float2 OutMinMax, out float Out)
{
Out = OutMinMax.x + (In - InMinMax.x) * (OutMinMax.y - OutMinMax.x) / (InMinMax.y - InMinMax.x);
}
void Unity_Subtract_float2(float2 A, float2 B, out float2 Out)
{
Out = A - B;
}
void Unity_Modulo_float(float A, float B, out float Out)
{
Out = fmod(A, B);
}
void Unity_Divide_float(float A, float B, out float Out)
{
Out = A / B;
}
void Unity_Add_float(float A, float B, out float Out)
{
Out = A + B;
}
void Unity_Fraction_float(float In, out float Out)
{
Out = frac(In);
}
void Unity_Absolute_float(float In, out float Out)
{
Out = abs(In);
}
struct Bindings_FlowMapComputeUV_b1858d7f2791c414298ed47e2e3f717e_float
{
};
void SG_FlowMapComputeUV_b1858d7f2791c414298ed47e2e3f717e_float(float2 Vector2_757F6EF1, float Vector1_256D31BE, UnityTexture2D Texture2D_D3BF77EA, float Vector1_A59487A9, float Vector1_E97BA3AA, Bindings_FlowMapComputeUV_b1858d7f2791c414298ed47e2e3f717e_float IN, out float4 FlowUV_1, out float FlowBlend_2)
{
UnityTexture2D _Property_12afeca0b4bd0e8aaf84eff19e23a7b0_Out_0_Texture2D = Texture2D_D3BF77EA;
float2 _Property_f626684d371df489a93083c22f3de1a5_Out_0_Vector2 = Vector2_757F6EF1;
float4 _SampleTexture2D_6e29147e1196f5808465d10667ad2270_RGBA_0_Vector4 = SAMPLE_TEXTURE2D(_Property_12afeca0b4bd0e8aaf84eff19e23a7b0_Out_0_Texture2D.tex, _Property_12afeca0b4bd0e8aaf84eff19e23a7b0_Out_0_Texture2D.samplerstate, _Property_12afeca0b4bd0e8aaf84eff19e23a7b0_Out_0_Texture2D.GetTransformedUV(_Property_f626684d371df489a93083c22f3de1a5_Out_0_Vector2) );
float _SampleTexture2D_6e29147e1196f5808465d10667ad2270_R_4_Float = _SampleTexture2D_6e29147e1196f5808465d10667ad2270_RGBA_0_Vector4.r;
float _SampleTexture2D_6e29147e1196f5808465d10667ad2270_G_5_Float = _SampleTexture2D_6e29147e1196f5808465d10667ad2270_RGBA_0_Vector4.g;
float _SampleTexture2D_6e29147e1196f5808465d10667ad2270_B_6_Float = _SampleTexture2D_6e29147e1196f5808465d10667ad2270_RGBA_0_Vector4.b;
float _SampleTexture2D_6e29147e1196f5808465d10667ad2270_A_7_Float = _SampleTexture2D_6e29147e1196f5808465d10667ad2270_RGBA_0_Vector4.a;
float2 _Vector2_f45149b78027d18080baee8eb55d854a_Out_0_Vector2 = float2(_SampleTexture2D_6e29147e1196f5808465d10667ad2270_R_4_Float, _SampleTexture2D_6e29147e1196f5808465d10667ad2270_G_5_Float);
float2 _Subtract_35aaef109b28f48e801b1c670e698dfe_Out_2_Vector2;
Unity_Subtract_float2(_Vector2_f45149b78027d18080baee8eb55d854a_Out_0_Vector2, float2(0.5, 0.5), _Subtract_35aaef109b28f48e801b1c670e698dfe_Out_2_Vector2);
float _Property_e695513a7da1328d92aea68fc091fb19_Out_0_Float = Vector1_256D31BE;
float _Float_b5ff70f6e93b678c847451cc544ed0b4_Out_0_Float = _Property_e695513a7da1328d92aea68fc091fb19_Out_0_Float;
float _Property_7a8b02f4996a56868fb0ca6b9a9b882a_Out_0_Float = Vector1_E97BA3AA;
float _Float_600aaabbcbd1c982a996455358dec002_Out_0_Float = _Property_7a8b02f4996a56868fb0ca6b9a9b882a_Out_0_Float;
float _Modulo_512541825030d9848ce707a439911565_Out_2_Float;
Unity_Modulo_float(_Float_b5ff70f6e93b678c847451cc544ed0b4_Out_0_Float, _Float_600aaabbcbd1c982a996455358dec002_Out_0_Float, _Modulo_512541825030d9848ce707a439911565_Out_2_Float);
float _Divide_2f7acfa94f38c88298da6a811d547831_Out_2_Float;
Unity_Divide_float(_Modulo_512541825030d9848ce707a439911565_Out_2_Float, _Float_600aaabbcbd1c982a996455358dec002_Out_0_Float, _Divide_2f7acfa94f38c88298da6a811d547831_Out_2_Float);
float _Subtract_7ef077b72d167686882e6e5874f160cb_Out_2_Float;
Unity_Subtract_float(_Divide_2f7acfa94f38c88298da6a811d547831_Out_2_Float, 0.5, _Subtract_7ef077b72d167686882e6e5874f160cb_Out_2_Float);
float2 _Multiply_58ebd45ca4381686a7669d77e4874c78_Out_2_Vector2;
Unity_Multiply_float2_float2(_Subtract_35aaef109b28f48e801b1c670e698dfe_Out_2_Vector2, (_Subtract_7ef077b72d167686882e6e5874f160cb_Out_2_Float.xx), _Multiply_58ebd45ca4381686a7669d77e4874c78_Out_2_Vector2);
float _Split_da95b013444996819c06049409092727_R_1_Float = _Multiply_58ebd45ca4381686a7669d77e4874c78_Out_2_Vector2[0];
float _Split_da95b013444996819c06049409092727_G_2_Float = _Multiply_58ebd45ca4381686a7669d77e4874c78_Out_2_Vector2[1];
float _Split_da95b013444996819c06049409092727_B_3_Float = 0;
float _Split_da95b013444996819c06049409092727_A_4_Float = 0;
float _Add_8e78678dcb2d9b83ac3cdfde6e1c63d6_Out_2_Float;
Unity_Add_float(_Divide_2f7acfa94f38c88298da6a811d547831_Out_2_Float, 0.5, _Add_8e78678dcb2d9b83ac3cdfde6e1c63d6_Out_2_Float);
float _Fraction_43ff66980c796f8b8171f50ca65c0a02_Out_1_Float;
Unity_Fraction_float(_Add_8e78678dcb2d9b83ac3cdfde6e1c63d6_Out_2_Float, _Fraction_43ff66980c796f8b8171f50ca65c0a02_Out_1_Float);
float _Subtract_d316fe917ca2f780ab66d88cf6d3c03f_Out_2_Float;
Unity_Subtract_float(_Fraction_43ff66980c796f8b8171f50ca65c0a02_Out_1_Float, 0.5, _Subtract_d316fe917ca2f780ab66d88cf6d3c03f_Out_2_Float);
float2 _Multiply_f56cfccf7b7b818e97d6a8e15a7aef32_Out_2_Vector2;
Unity_Multiply_float2_float2(_Subtract_35aaef109b28f48e801b1c670e698dfe_Out_2_Vector2, (_Subtract_d316fe917ca2f780ab66d88cf6d3c03f_Out_2_Float.xx), _Multiply_f56cfccf7b7b818e97d6a8e15a7aef32_Out_2_Vector2);
float _Split_cb3fa13ec0af8f84bb0b69101f08049b_R_1_Float = _Multiply_f56cfccf7b7b818e97d6a8e15a7aef32_Out_2_Vector2[0];
float _Split_cb3fa13ec0af8f84bb0b69101f08049b_G_2_Float = _Multiply_f56cfccf7b7b818e97d6a8e15a7aef32_Out_2_Vector2[1];
float _Split_cb3fa13ec0af8f84bb0b69101f08049b_B_3_Float = 0;
float _Split_cb3fa13ec0af8f84bb0b69101f08049b_A_4_Float = 0;
float4 _Vector4_6dfbc2d49b15b987b51748ce6f211729_Out_0_Vector4 = float4(_Split_da95b013444996819c06049409092727_R_1_Float, _Split_da95b013444996819c06049409092727_G_2_Float, _Split_cb3fa13ec0af8f84bb0b69101f08049b_R_1_Float, _Split_cb3fa13ec0af8f84bb0b69101f08049b_G_2_Float);
float _Property_3358989d4d4bd884a260e327c253c01d_Out_0_Float = Vector1_A59487A9;
float4 _Multiply_d2f61a5ca3776183bec4d554e5b8b01a_Out_2_Vector4;
Unity_Multiply_float4_float4(_Vector4_6dfbc2d49b15b987b51748ce6f211729_Out_0_Vector4, (_Property_3358989d4d4bd884a260e327c253c01d_Out_0_Float.xxxx), _Multiply_d2f61a5ca3776183bec4d554e5b8b01a_Out_2_Vector4);
float _Absolute_49473ff78b4ab4898c23f6aca7e5abc8_Out_1_Float;
Unity_Absolute_float(_Subtract_7ef077b72d167686882e6e5874f160cb_Out_2_Float, _Absolute_49473ff78b4ab4898c23f6aca7e5abc8_Out_1_Float);
float _Add_fedade66ca30bb87b404227126d29fb8_Out_2_Float;
Unity_Add_float(_Absolute_49473ff78b4ab4898c23f6aca7e5abc8_Out_1_Float, _Absolute_49473ff78b4ab4898c23f6aca7e5abc8_Out_1_Float, _Add_fedade66ca30bb87b404227126d29fb8_Out_2_Float);
FlowUV_1 = _Multiply_d2f61a5ca3776183bec4d554e5b8b01a_Out_2_Vector4;
FlowBlend_2 = _Add_fedade66ca30bb87b404227126d29fb8_Out_2_Float;
}
void Unity_Lerp_float4(float4 A, float4 B, float4 T, out float4 Out)
{
Out = lerp(A, B, T);
}
struct Bindings_FlowMapSampleTexture_e2dd025b49c90924ba82331e75f4f6d3_float
{
};
void SG_FlowMapSampleTexture_e2dd025b49c90924ba82331e75f4f6d3_float(float2 Vector2_D40A70E2, UnityTexture2D Texture2D_D8F21547, float Vector1_622C85C8, float4 Vector4_47B5E1AC, float Vector1_690BDC86, Bindings_FlowMapSampleTexture_e2dd025b49c90924ba82331e75f4f6d3_float IN, out float4 Output_1)
{
UnityTexture2D _Property_a6f54a9b2fff238ca633046bb59dbe66_Out_0_Texture2D = Texture2D_D8F21547;
float2 _Property_cf1bf4e5383c2d86b9142f6b95c20609_Out_0_Vector2 = Vector2_D40A70E2;
float4 _Property_d5b989c4a1a7fb80afc767d18d1a0787_Out_0_Vector4 = Vector4_47B5E1AC;
float _Property_ac3315480438b28b861ac3367b3e28bb_Out_0_Float = Vector1_622C85C8;
float4 _Multiply_d299cee76e0b1c848fc940d3dce32a5a_Out_2_Vector4;
Unity_Multiply_float4_float4(_Property_d5b989c4a1a7fb80afc767d18d1a0787_Out_0_Vector4, (_Property_ac3315480438b28b861ac3367b3e28bb_Out_0_Float.xxxx), _Multiply_d299cee76e0b1c848fc940d3dce32a5a_Out_2_Vector4);
float _Split_1240e3f604c5d281b126eec74487f9b0_R_1_Float = _Multiply_d299cee76e0b1c848fc940d3dce32a5a_Out_2_Vector4[0];
float _Split_1240e3f604c5d281b126eec74487f9b0_G_2_Float = _Multiply_d299cee76e0b1c848fc940d3dce32a5a_Out_2_Vector4[1];
float _Split_1240e3f604c5d281b126eec74487f9b0_B_3_Float = _Multiply_d299cee76e0b1c848fc940d3dce32a5a_Out_2_Vector4[2];
float _Split_1240e3f604c5d281b126eec74487f9b0_A_4_Float = _Multiply_d299cee76e0b1c848fc940d3dce32a5a_Out_2_Vector4[3];
float2 _Vector2_f9de6077ba40bd88b07864832813cbe3_Out_0_Vector2 = float2(_Split_1240e3f604c5d281b126eec74487f9b0_R_1_Float, _Split_1240e3f604c5d281b126eec74487f9b0_G_2_Float);
float2 _Add_71d4b12f3eb95b87a7211985cdfe678f_Out_2_Vector2;
Unity_Add_float2(_Property_cf1bf4e5383c2d86b9142f6b95c20609_Out_0_Vector2, _Vector2_f9de6077ba40bd88b07864832813cbe3_Out_0_Vector2, _Add_71d4b12f3eb95b87a7211985cdfe678f_Out_2_Vector2);
float4 _SampleTexture2D_f47db634ba36788da7515ba76a8c53ee_RGBA_0_Vector4 = SAMPLE_TEXTURE2D(_Property_a6f54a9b2fff238ca633046bb59dbe66_Out_0_Texture2D.tex, _Property_a6f54a9b2fff238ca633046bb59dbe66_Out_0_Texture2D.samplerstate, _Property_a6f54a9b2fff238ca633046bb59dbe66_Out_0_Texture2D.GetTransformedUV(_Add_71d4b12f3eb95b87a7211985cdfe678f_Out_2_Vector2) );
float _SampleTexture2D_f47db634ba36788da7515ba76a8c53ee_R_4_Float = _SampleTexture2D_f47db634ba36788da7515ba76a8c53ee_RGBA_0_Vector4.r;
float _SampleTexture2D_f47db634ba36788da7515ba76a8c53ee_G_5_Float = _SampleTexture2D_f47db634ba36788da7515ba76a8c53ee_RGBA_0_Vector4.g;
float _SampleTexture2D_f47db634ba36788da7515ba76a8c53ee_B_6_Float = _SampleTexture2D_f47db634ba36788da7515ba76a8c53ee_RGBA_0_Vector4.b;
float _SampleTexture2D_f47db634ba36788da7515ba76a8c53ee_A_7_Float = _SampleTexture2D_f47db634ba36788da7515ba76a8c53ee_RGBA_0_Vector4.a;
float2 _Vector2_2144951d61921a8e972312b71153c5a3_Out_0_Vector2 = float2(_Split_1240e3f604c5d281b126eec74487f9b0_B_3_Float, _Split_1240e3f604c5d281b126eec74487f9b0_A_4_Float);
float2 _Add_4a60620e593e1c89b555deb965969fc6_Out_2_Vector2;
Unity_Add_float2(_Property_cf1bf4e5383c2d86b9142f6b95c20609_Out_0_Vector2, _Vector2_2144951d61921a8e972312b71153c5a3_Out_0_Vector2, _Add_4a60620e593e1c89b555deb965969fc6_Out_2_Vector2);
float4 _SampleTexture2D_bcd8e9ca12108486b49b737afb37d4ae_RGBA_0_Vector4 = SAMPLE_TEXTURE2D(_Property_a6f54a9b2fff238ca633046bb59dbe66_Out_0_Texture2D.tex, _Property_a6f54a9b2fff238ca633046bb59dbe66_Out_0_Texture2D.samplerstate, _Property_a6f54a9b2fff238ca633046bb59dbe66_Out_0_Texture2D.GetTransformedUV(_Add_4a60620e593e1c89b555deb965969fc6_Out_2_Vector2) );
float _SampleTexture2D_bcd8e9ca12108486b49b737afb37d4ae_R_4_Float = _SampleTexture2D_bcd8e9ca12108486b49b737afb37d4ae_RGBA_0_Vector4.r;
float _SampleTexture2D_bcd8e9ca12108486b49b737afb37d4ae_G_5_Float = _SampleTexture2D_bcd8e9ca12108486b49b737afb37d4ae_RGBA_0_Vector4.g;
float _SampleTexture2D_bcd8e9ca12108486b49b737afb37d4ae_B_6_Float = _SampleTexture2D_bcd8e9ca12108486b49b737afb37d4ae_RGBA_0_Vector4.b;
float _SampleTexture2D_bcd8e9ca12108486b49b737afb37d4ae_A_7_Float = _SampleTexture2D_bcd8e9ca12108486b49b737afb37d4ae_RGBA_0_Vector4.a;
float _Property_bc3b1163e67f208d9e80d603c30cd338_Out_0_Float = Vector1_690BDC86;
float4 _Lerp_b3b66ddcf5dd5a8d92ee855390003585_Out_3_Vector4;
Unity_Lerp_float4(_SampleTexture2D_f47db634ba36788da7515ba76a8c53ee_RGBA_0_Vector4, _SampleTexture2D_bcd8e9ca12108486b49b737afb37d4ae_RGBA_0_Vector4, (_Property_bc3b1163e67f208d9e80d603c30cd338_Out_0_Float.xxxx), _Lerp_b3b66ddcf5dd5a8d92ee855390003585_Out_3_Vector4);
Output_1 = _Lerp_b3b66ddcf5dd5a8d92ee855390003585_Out_3_Vector4;
}
void Unity_Power_float(float A, float B, out float Out)
{
Out = pow(A, B);
}
void Unity_Clamp_float(float In, float Min, float Max, out float Out)
{
Out = clamp(In, Min, Max);
}
void Unity_SampleGradientV1_float(Gradient Gradient, float Time, out float4 Out)
{
float3 color = Gradient.colors[0].rgb;
[unroll]
for (int c = 1; c < Gradient.colorsLength; c++)
{
float colorPos = saturate((Time - Gradient.colors[c - 1].w) / (Gradient.colors[c].w - Gradient.colors[c - 1].w)) * step(c, Gradient.colorsLength - 1);
color = lerp(color, Gradient.colors[c].rgb, lerp(colorPos, step(0.01, colorPos), Gradient.type));
}
#ifdef UNITY_COLORSPACE_GAMMA
color = LinearToSRGB(color);
#endif
float alpha = Gradient.alphas[0].x;
[unroll]
for (int a = 1; a < Gradient.alphasLength; a++)
{
float alphaPos = saturate((Time - Gradient.alphas[a - 1].y) / (Gradient.alphas[a].y - Gradient.alphas[a - 1].y)) * step(a, Gradient.alphasLength - 1);
alpha = lerp(alpha, Gradient.alphas[a].x, lerp(alphaPos, step(0.01, alphaPos), Gradient.type));
}
Out = float4(color, alpha);
}
void Unity_Add_float4(float4 A, float4 B, out float4 Out)
{
Out = A + B;
}
// Custom interpolators pre vertex
/* WARNING: $splice Could not find named fragment 'CustomInterpolatorPreVertex' */
// Graph Vertex
struct VertexDescription
{
float3 Position;
float3 Normal;
float3 Tangent;
};
VertexDescription VertexDescriptionFunction(VertexDescriptionInputs IN)
{
VertexDescription description = (VertexDescription)0;
description.Position = IN.ObjectSpacePosition;
description.Normal = IN.ObjectSpaceNormal;
description.Tangent = IN.ObjectSpaceTangent;
return description;
}
// Custom interpolators, pre surface
#ifdef FEATURES_GRAPH_VERTEX
Varyings CustomInterpolatorPassThroughFunc(inout Varyings output, VertexDescription input)
{
return output;
}
#define CUSTOMINTERPOLATOR_VARYPASSTHROUGH_FUNC
#endif
// Graph Pixel
struct SurfaceDescription
{
float3 BaseColor;
float3 NormalTS;
float3 Emission;
float Metallic;
float Smoothness;
float Occlusion;
float Alpha;
};
SurfaceDescription SurfaceDescriptionFunction(SurfaceDescriptionInputs IN)
{
SurfaceDescription surface = (SurfaceDescription)0;
float4 _Property_92dd2a559068480386af593f00f151d7_Out_0_Vector4 = _DepthColor;
float2 _Property_d91c3481100f423fbdd1f6e9783e38c2_Out_0_Vector2 = _DepthStepV2;
float _Split_b779cedc2ea6487fb4f9214b48e0bc5e_R_1_Float = _Property_d91c3481100f423fbdd1f6e9783e38c2_Out_0_Vector2[0];
float _Split_b779cedc2ea6487fb4f9214b48e0bc5e_G_2_Float = _Property_d91c3481100f423fbdd1f6e9783e38c2_Out_0_Vector2[1];
float _Split_b779cedc2ea6487fb4f9214b48e0bc5e_B_3_Float = 0;
float _Split_b779cedc2ea6487fb4f9214b48e0bc5e_A_4_Float = 0;
float _SceneDepth_ba91d96d2eec4939b0980265178ed484_Out_1_Float;
Unity_SceneDepth_Eye_float(float4(IN.NDCPosition.xy, 0, 0), _SceneDepth_ba91d96d2eec4939b0980265178ed484_Out_1_Float);
float4 _ScreenPosition_9e90ecf9de164b968a51e70347e3bf8f_Out_0_Vector4 = IN.ScreenPosition;
float _Split_87399b79efe14582a87f892f8e08fc0f_R_1_Float = _ScreenPosition_9e90ecf9de164b968a51e70347e3bf8f_Out_0_Vector4[0];
float _Split_87399b79efe14582a87f892f8e08fc0f_G_2_Float = _ScreenPosition_9e90ecf9de164b968a51e70347e3bf8f_Out_0_Vector4[1];
float _Split_87399b79efe14582a87f892f8e08fc0f_B_3_Float = _ScreenPosition_9e90ecf9de164b968a51e70347e3bf8f_Out_0_Vector4[2];
float _Split_87399b79efe14582a87f892f8e08fc0f_A_4_Float = _ScreenPosition_9e90ecf9de164b968a51e70347e3bf8f_Out_0_Vector4[3];
float _Subtract_610e8040f4e2458b9c85d5f2925705ab_Out_2_Float;
Unity_Subtract_float(_SceneDepth_ba91d96d2eec4939b0980265178ed484_Out_1_Float, _Split_87399b79efe14582a87f892f8e08fc0f_A_4_Float, _Subtract_610e8040f4e2458b9c85d5f2925705ab_Out_2_Float);
float _Property_e6a8285829014d14add18c35bfd56dce_Out_0_Float = _DepthMulti;
float _Multiply_aa1c45c2759746c1804ce1635f1263b1_Out_2_Float;
Unity_Multiply_float_float(_Subtract_610e8040f4e2458b9c85d5f2925705ab_Out_2_Float, _Property_e6a8285829014d14add18c35bfd56dce_Out_0_Float, _Multiply_aa1c45c2759746c1804ce1635f1263b1_Out_2_Float);
float _Smoothstep_49ca25ba5d07468c9ad21c24e4ca50ea_Out_3_Float;
Unity_Smoothstep_float(_Split_b779cedc2ea6487fb4f9214b48e0bc5e_R_1_Float, _Split_b779cedc2ea6487fb4f9214b48e0bc5e_G_2_Float, _Multiply_aa1c45c2759746c1804ce1635f1263b1_Out_2_Float, _Smoothstep_49ca25ba5d07468c9ad21c24e4ca50ea_Out_3_Float);
float _OneMinus_ffa0949bbd3647d58c20abe6c2ffe611_Out_1_Float;
Unity_OneMinus_float(_Smoothstep_49ca25ba5d07468c9ad21c24e4ca50ea_Out_3_Float, _OneMinus_ffa0949bbd3647d58c20abe6c2ffe611_Out_1_Float);
float4 _Multiply_b2c71afab442495c955d5fdcf9b4a905_Out_2_Vector4;
Unity_Multiply_float4_float4(_Property_92dd2a559068480386af593f00f151d7_Out_0_Vector4, (_OneMinus_ffa0949bbd3647d58c20abe6c2ffe611_Out_1_Float.xxxx), _Multiply_b2c71afab442495c955d5fdcf9b4a905_Out_2_Vector4);
float _Property_363cf2c969164697a5bf2ad68f546cad_Out_0_Float = _DepthIntensity;
float4 _Multiply_5eca845358aa46e7b61899bbca1bce04_Out_2_Vector4;
Unity_Multiply_float4_float4(_Multiply_b2c71afab442495c955d5fdcf9b4a905_Out_2_Vector4, (_Property_363cf2c969164697a5bf2ad68f546cad_Out_0_Float.xxxx), _Multiply_5eca845358aa46e7b61899bbca1bce04_Out_2_Vector4);
float _Property_6397a769a8574b39b4230648ac4105b6_Out_0_Float = _EmissionColorIntensity;
float4 _Property_50868c08e1d74894bb4a435796be888c_Out_0_Vector4 = _EmissionColor;
float3 _ViewVector_4c692cda303542c4967151d8d5237b4d_Out_0_Vector3;
Unity_ViewVectorWorld_float(_ViewVector_4c692cda303542c4967151d8d5237b4d_Out_0_Vector3, IN.WorldSpacePosition);
float _Property_8005ec0bab5e47198d7ccef0571844ad_Out_0_Float = _FresnelPower;
float _FresnelEffect_af887c7096f74986be5681f9170eaf86_Out_3_Float;
Unity_FresnelEffect_float(IN.WorldSpaceNormal, _ViewVector_4c692cda303542c4967151d8d5237b4d_Out_0_Vector3, _Property_8005ec0bab5e47198d7ccef0571844ad_Out_0_Float, _FresnelEffect_af887c7096f74986be5681f9170eaf86_Out_3_Float);
float4 _Multiply_eabe548ed12845ab83a9fd95203242f2_Out_2_Vector4;
Unity_Multiply_float4_float4(_Property_50868c08e1d74894bb4a435796be888c_Out_0_Vector4, (_FresnelEffect_af887c7096f74986be5681f9170eaf86_Out_3_Float.xxxx), _Multiply_eabe548ed12845ab83a9fd95203242f2_Out_2_Vector4);
float4 _Multiply_96af206c0ae141799e368fc69ca783ed_Out_2_Vector4;
Unity_Multiply_float4_float4((_Property_6397a769a8574b39b4230648ac4105b6_Out_0_Float.xxxx), _Multiply_eabe548ed12845ab83a9fd95203242f2_Out_2_Vector4, _Multiply_96af206c0ae141799e368fc69ca783ed_Out_2_Vector4);
float _Property_462096fd2b1343bba90008332ecd03fe_Out_0_Float = _FlowLightIntensity;
Gradient _Property_ec7e9d16566748cd91ba9cbf6883031b_Out_0_Gradient = _FlowGradient;
float2 _Property_120a2e4c8b2d40998de8874195479a6b_Out_0_Vector2 = _FlowStepV2;
float _Split_735f90aed11c47d39ba570897410fb85_R_1_Float = _Property_120a2e4c8b2d40998de8874195479a6b_Out_0_Vector2[0];
float _Split_735f90aed11c47d39ba570897410fb85_G_2_Float = _Property_120a2e4c8b2d40998de8874195479a6b_Out_0_Vector2[1];
float _Split_735f90aed11c47d39ba570897410fb85_B_3_Float = 0;
float _Split_735f90aed11c47d39ba570897410fb85_A_4_Float = 0;
float4 _UV_359e16ff543d41eebb9bdf81b6f07b34_Out_0_Vector4 = IN.uv0;
float2 _Property_4fe4d5af571c4987b5b0d9cf4be0367e_Out_0_Vector2 = _FlowScroll;
float2 _Multiply_39c5d1bc6ca94dbfa09c51360f18c4e4_Out_2_Vector2;
Unity_Multiply_float2_float2((IN.TimeParameters.x.xx), _Property_4fe4d5af571c4987b5b0d9cf4be0367e_Out_0_Vector2, _Multiply_39c5d1bc6ca94dbfa09c51360f18c4e4_Out_2_Vector2);
float2 _Add_f952dda9d9e1436b85fc9d82886cf7da_Out_2_Vector2;
Unity_Add_float2((_UV_359e16ff543d41eebb9bdf81b6f07b34_Out_0_Vector4.xy), _Multiply_39c5d1bc6ca94dbfa09c51360f18c4e4_Out_2_Vector2, _Add_f952dda9d9e1436b85fc9d82886cf7da_Out_2_Vector2);
UnityTexture2D _Property_ff6b2c22ec8345478696d3b6c427abb4_Out_0_Texture2D = UnityBuildTexture2DStructNoScale(_FlowSampleTexture);
float _Property_1a535972a68a460f99ad413d73c98996_Out_0_Float = _FlowSampleScale;
float2 _Property_8864b440b477417f8fc33b09f87b500b_Out_0_Vector2 = _FlowMapUVTiling;
float2 _Property_87f4c9aa397a4e6394afba1f1c30e05c_Out_0_Vector2 = _FlowMapUVOffset;
float2 _TilingAndOffset_2974021bf739409fa86375dcfd413ec3_Out_3_Vector2;
Unity_TilingAndOffset_float(_Add_f952dda9d9e1436b85fc9d82886cf7da_Out_2_Vector2, _Property_8864b440b477417f8fc33b09f87b500b_Out_0_Vector2, _Property_87f4c9aa397a4e6394afba1f1c30e05c_Out_0_Vector2, _TilingAndOffset_2974021bf739409fa86375dcfd413ec3_Out_3_Vector2);
float _Property_6aced146005949ebb92f8fac22641553_Out_0_Float = _FlowMapUVTimeSpeed;
float _Multiply_1259429c13974c9f842f8e1c3e7ee72e_Out_2_Float;
Unity_Multiply_float_float(IN.TimeParameters.x, _Property_6aced146005949ebb92f8fac22641553_Out_0_Float, _Multiply_1259429c13974c9f842f8e1c3e7ee72e_Out_2_Float);
float _Sine_ab7f5b80ead245f7bcbb1c388ea5b38c_Out_1_Float;
Unity_Sine_float(_Multiply_1259429c13974c9f842f8e1c3e7ee72e_Out_2_Float, _Sine_ab7f5b80ead245f7bcbb1c388ea5b38c_Out_1_Float);
float _Remap_c1a1dd7bfe044dd7a21d02a5485843bb_Out_3_Float;
Unity_Remap_float(_Sine_ab7f5b80ead245f7bcbb1c388ea5b38c_Out_1_Float, float2 (-1, 1), float2 (0, 1), _Remap_c1a1dd7bfe044dd7a21d02a5485843bb_Out_3_Float);
UnityTexture2D _Property_216dfc7955fa44a89f63318b4556d5b4_Out_0_Texture2D = UnityBuildTexture2DStructNoScale(_FlowMap);
float _Property_0943ab742b0d4f598683aaf7c03ecb85_Out_0_Float = _FlowMapIntensity;
float _Property_87ab54ffef784b0c9dffbcfa4a1668cc_Out_0_Float = _FlowScrollPeriod;
Bindings_FlowMapComputeUV_b1858d7f2791c414298ed47e2e3f717e_float _FlowMapComputeUV_6f53dc442b654044baf264d5fa7ef473;
float4 _FlowMapComputeUV_6f53dc442b654044baf264d5fa7ef473_FlowUV_1_Vector4;
float _FlowMapComputeUV_6f53dc442b654044baf264d5fa7ef473_FlowBlend_2_Float;
SG_FlowMapComputeUV_b1858d7f2791c414298ed47e2e3f717e_float(_TilingAndOffset_2974021bf739409fa86375dcfd413ec3_Out_3_Vector2, _Remap_c1a1dd7bfe044dd7a21d02a5485843bb_Out_3_Float, _Property_216dfc7955fa44a89f63318b4556d5b4_Out_0_Texture2D, _Property_0943ab742b0d4f598683aaf7c03ecb85_Out_0_Float, _Property_87ab54ffef784b0c9dffbcfa4a1668cc_Out_0_Float, _FlowMapComputeUV_6f53dc442b654044baf264d5fa7ef473, _FlowMapComputeUV_6f53dc442b654044baf264d5fa7ef473_FlowUV_1_Vector4, _FlowMapComputeUV_6f53dc442b654044baf264d5fa7ef473_FlowBlend_2_Float);
Bindings_FlowMapSampleTexture_e2dd025b49c90924ba82331e75f4f6d3_float _FlowMapSampleTexture_3dd8dd55db974ca0a8c4b4da2eb9cf47;
float4 _FlowMapSampleTexture_3dd8dd55db974ca0a8c4b4da2eb9cf47_Output_1_Vector4;
SG_FlowMapSampleTexture_e2dd025b49c90924ba82331e75f4f6d3_float(_Add_f952dda9d9e1436b85fc9d82886cf7da_Out_2_Vector2, _Property_ff6b2c22ec8345478696d3b6c427abb4_Out_0_Texture2D, _Property_1a535972a68a460f99ad413d73c98996_Out_0_Float, _FlowMapComputeUV_6f53dc442b654044baf264d5fa7ef473_FlowUV_1_Vector4, _FlowMapComputeUV_6f53dc442b654044baf264d5fa7ef473_FlowBlend_2_Float, _FlowMapSampleTexture_3dd8dd55db974ca0a8c4b4da2eb9cf47, _FlowMapSampleTexture_3dd8dd55db974ca0a8c4b4da2eb9cf47_Output_1_Vector4);
float _Split_adc013464c5f4332bd62947b723bff38_R_1_Float = _FlowMapSampleTexture_3dd8dd55db974ca0a8c4b4da2eb9cf47_Output_1_Vector4[0];
float _Split_adc013464c5f4332bd62947b723bff38_G_2_Float = _FlowMapSampleTexture_3dd8dd55db974ca0a8c4b4da2eb9cf47_Output_1_Vector4[1];
float _Split_adc013464c5f4332bd62947b723bff38_B_3_Float = _FlowMapSampleTexture_3dd8dd55db974ca0a8c4b4da2eb9cf47_Output_1_Vector4[2];
float _Split_adc013464c5f4332bd62947b723bff38_A_4_Float = _FlowMapSampleTexture_3dd8dd55db974ca0a8c4b4da2eb9cf47_Output_1_Vector4[3];
float _Property_78e899a5ccdb458e9b6d8d92849868be_Out_0_Float = _FlowPower;
float _Power_cf0a8e06b90141b6a690112705bc2afd_Out_2_Float;
Unity_Power_float(_Split_adc013464c5f4332bd62947b723bff38_A_4_Float, _Property_78e899a5ccdb458e9b6d8d92849868be_Out_0_Float, _Power_cf0a8e06b90141b6a690112705bc2afd_Out_2_Float);
float _Clamp_1eeb4e7f2ad94cfe9f312704cc811e76_Out_3_Float;
Unity_Clamp_float(_Power_cf0a8e06b90141b6a690112705bc2afd_Out_2_Float, 0, 1, _Clamp_1eeb4e7f2ad94cfe9f312704cc811e76_Out_3_Float);
float _Smoothstep_75716964573444d3951458dd27e4ea80_Out_3_Float;
Unity_Smoothstep_float(_Split_735f90aed11c47d39ba570897410fb85_R_1_Float, _Split_735f90aed11c47d39ba570897410fb85_G_2_Float, _Clamp_1eeb4e7f2ad94cfe9f312704cc811e76_Out_3_Float, _Smoothstep_75716964573444d3951458dd27e4ea80_Out_3_Float);
float4 _SampleGradient_f2d370ec8b61441e945f287a037192d0_Out_2_Vector4;
Unity_SampleGradientV1_float(_Property_ec7e9d16566748cd91ba9cbf6883031b_Out_0_Gradient, _Smoothstep_75716964573444d3951458dd27e4ea80_Out_3_Float, _SampleGradient_f2d370ec8b61441e945f287a037192d0_Out_2_Vector4);
float4 _Multiply_bee969da130243efa78bb41da784514c_Out_2_Vector4;
Unity_Multiply_float4_float4((_Property_462096fd2b1343bba90008332ecd03fe_Out_0_Float.xxxx), _SampleGradient_f2d370ec8b61441e945f287a037192d0_Out_2_Vector4, _Multiply_bee969da130243efa78bb41da784514c_Out_2_Vector4);
float4 _Multiply_00a771f16f8a4bb59bbb5ece381987df_Out_2_Vector4;
Unity_Multiply_float4_float4(_Multiply_96af206c0ae141799e368fc69ca783ed_Out_2_Vector4, _Multiply_bee969da130243efa78bb41da784514c_Out_2_Vector4, _Multiply_00a771f16f8a4bb59bbb5ece381987df_Out_2_Vector4);
float4 _Multiply_853e25a196654e1eb01a47206d672dbe_Out_2_Vector4;
Unity_Multiply_float4_float4(_Multiply_5eca845358aa46e7b61899bbca1bce04_Out_2_Vector4, _Multiply_00a771f16f8a4bb59bbb5ece381987df_Out_2_Vector4, _Multiply_853e25a196654e1eb01a47206d672dbe_Out_2_Vector4);
float4 _Add_5fefd3d829874fa88aa751b7db99ae75_Out_2_Vector4;
Unity_Add_float4(_Multiply_853e25a196654e1eb01a47206d672dbe_Out_2_Vector4, _Multiply_00a771f16f8a4bb59bbb5ece381987df_Out_2_Vector4, _Add_5fefd3d829874fa88aa751b7db99ae75_Out_2_Vector4);
surface.BaseColor = IsGammaSpace() ? float3(1, 1, 1) : SRGBToLinear(float3(1, 1, 1));
surface.NormalTS = IN.TangentSpaceNormal;
surface.Emission = (_Add_5fefd3d829874fa88aa751b7db99ae75_Out_2_Vector4.xyz);
surface.Metallic = 0;
surface.Smoothness = 0.5;
surface.Occlusion = 1;
surface.Alpha = 1;
return surface;
}
// --------------------------------------------------
// Build Graph Inputs
#ifdef HAVE_VFX_MODIFICATION
#define VFX_SRP_ATTRIBUTES Attributes
#define VFX_SRP_VARYINGS Varyings
#define VFX_SRP_SURFACE_INPUTS SurfaceDescriptionInputs
#endif
VertexDescriptionInputs BuildVertexDescriptionInputs(Attributes input)
{
VertexDescriptionInputs output;
ZERO_INITIALIZE(VertexDescriptionInputs, output);
output.ObjectSpaceNormal = input.normalOS;
output.ObjectSpaceTangent = input.tangentOS.xyz;
output.ObjectSpacePosition = input.positionOS;
return output;
}
SurfaceDescriptionInputs BuildSurfaceDescriptionInputs(Varyings input)
{
SurfaceDescriptionInputs output;
ZERO_INITIALIZE(SurfaceDescriptionInputs, output);
#ifdef HAVE_VFX_MODIFICATION
#if VFX_USE_GRAPH_VALUES
uint instanceActiveIndex = asuint(UNITY_ACCESS_INSTANCED_PROP(PerInstance, _InstanceActiveIndex));
/* WARNING: $splice Could not find named fragment 'VFXLoadGraphValues' */
#endif
/* WARNING: $splice Could not find named fragment 'VFXSetFragInputs' */
#endif
// must use interpolated tangent, bitangent and normal before they are normalized in the pixel shader.
float3 unnormalizedNormalWS = input.normalWS;
const float renormFactor = 1.0 / length(unnormalizedNormalWS);
output.WorldSpaceNormal = renormFactor * input.normalWS.xyz; // we want a unit length Normal Vector node in shader graph
output.TangentSpaceNormal = float3(0.0f, 0.0f, 1.0f);
output.WorldSpacePosition = input.positionWS;
output.ScreenPosition = ComputeScreenPos(TransformWorldToHClip(input.positionWS), _ProjectionParams.x);
#if UNITY_UV_STARTS_AT_TOP
output.PixelPosition = float2(input.positionCS.x, (_ProjectionParams.x < 0) ? (_ScaledScreenParams.y - input.positionCS.y) : input.positionCS.y);
#else
output.PixelPosition = float2(input.positionCS.x, (_ProjectionParams.x > 0) ? (_ScaledScreenParams.y - input.positionCS.y) : input.positionCS.y);
#endif
output.NDCPosition = output.PixelPosition.xy / _ScaledScreenParams.xy;
output.NDCPosition.y = 1.0f - output.NDCPosition.y;
output.uv0 = input.texCoord0;
output.TimeParameters = _TimeParameters.xyz; // This is mainly for LW as HD overwrite this value
#if defined(SHADER_STAGE_FRAGMENT) && defined(VARYINGS_NEED_CULLFACE)
#define BUILD_SURFACE_DESCRIPTION_INPUTS_OUTPUT_FACESIGN output.FaceSign = IS_FRONT_VFACE(input.cullFace, true, false);
#else
#define BUILD_SURFACE_DESCRIPTION_INPUTS_OUTPUT_FACESIGN
#endif
#undef BUILD_SURFACE_DESCRIPTION_INPUTS_OUTPUT_FACESIGN
return output;
}
// --------------------------------------------------
// Main
#include "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/Varyings.hlsl"
#include "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/PBRForwardPass.hlsl"
// --------------------------------------------------
// Visual Effect Vertex Invocations
#ifdef HAVE_VFX_MODIFICATION
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/VisualEffectVertex.hlsl"
#endif
ENDHLSL
}
}
}
这里面一共有三个主要的方法,正常来说shadergraph翻译出来的代码只有一个主要的方法,方法名称为:SurfaceDescriptionFunction
这个方法中包含了所有的计算流程,这里面有三个主要是因为这个shader graph的计算中使用了两个sub graph,也就是说相当于是三个shader graph,所以有三个方法
两个sub graph方法分别为SG_FlowMapComputeUV_b1858d7f2791c414298ed47e2e3f717e_float和SG_FlowMapSampleTexture_e2dd025b49c90924ba82331e75f4f6d3_float,这里简称为FlowMapComputeUV和FlowMapSampleTexture,一个是为了计算流动图的uv,一个是根据计算出的uv采样流动图。
分别翻译一下这三个主要方法,把复杂的变量名称替换为熟悉易读的名称。
Shader "Translate/LightFlowCull"
{
Properties
{
_FresnelPower("FresnelPower", Float) = 1
_EmissionColor("EmissionColor", Color) = (0.2783019, 0.7026262, 1, 0)
_EmissionColorIntensity("EmissionColorIntensity", Float) = 12
[NoScaleOffset]_FlowMap("FlowMap", 2D) = "white" {}
_FlowScroll("FlowScroll", Vector) = (0.1, 0.1, 0, 0)
_FlowMapUVTiling("FlowMapUVTiling", Vector) = (1, 1, 0, 0)
_FlowMapUVOffset("FlowMapUVOffset", Vector) = (0, 0, 0, 0)
_FlowMapUVTimeSpeed("FlowMapUVTimeSpeed", Float) = 6
_FlowMapIntensity("FlowMapIntensity", Float) = 1
_FlowScrollPeriod("FlowScrollPeriod", Float) = 5
[NoScaleOffset]_FlowSampleTexture("FlowSampleTexture", 2D) = "white" {}
_FlowSampleScale("FlowSampleScale", Float) = 0
_FlowPower("FlowPower", Float) = 1
_FlowStepV2("FlowStepV2", Vector) = (0, 1, 0, 0)
_FlowLightIntensity("FlowLightIntensity", Float) = 1
_DepthMulti("DepthMulti", Float) = 1
_DepthColor("DepthColor", Color) = (1, 1, 1, 0)
_DepthStepV2("DepthStepV2", Vector) = (0.2, 1, 0, 0)
_DepthIntensity("DepthIntensity", Float) = 1
[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) = "" {}
}
SubShader
{
Tags
{
"RenderPipeline"="UniversalPipeline"
"RenderType"="Transparent"
"UniversalMaterialType" = "Lit"
"Queue"="Transparent"
"DisableBatching"="False"
"ShaderGraphShader"="true"
"ShaderGraphTargetId"="UniversalLitSubTarget"
}
Pass
{
Name "Universal Forward"
Tags
{
"LightMode" = "UniversalForward"
}
// Render State
Cull Back
Blend One OneMinusSrcAlpha, One OneMinusSrcAlpha
ZTest LEqual
ZWrite Off
// Debug
//
// --------------------------------------------------
// Pass
HLSLPROGRAM
// Pragmas
#pragma target 2.0
#pragma multi_compile_instancing
#pragma multi_compile_fog
#pragma instancing_options renderinglayer
#pragma vertex vert
#pragma fragment frag
// Keywords
#pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION
#pragma multi_compile _ LIGHTMAP_ON
#pragma multi_compile _ DYNAMICLIGHTMAP_ON
#pragma multi_compile _ DIRLIGHTMAP_COMBINED
#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_fragment _ _ADDITIONAL_LIGHT_SHADOWS
#pragma multi_compile_fragment _ _REFLECTION_PROBE_BLENDING
#pragma multi_compile_fragment _ _REFLECTION_PROBE_BOX_PROJECTION
#pragma multi_compile_fragment _ _SHADOWS_SOFT
#pragma multi_compile _ LIGHTMAP_SHADOW_MIXING
#pragma multi_compile _ SHADOWS_SHADOWMASK
#pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3
#pragma multi_compile_fragment _ _LIGHT_LAYERS
#pragma multi_compile_fragment _ DEBUG_DISPLAY
#pragma multi_compile_fragment _ _LIGHT_COOKIES
#pragma multi_compile _ _FORWARD_PLUS
// GraphKeywords:
// Defines
#define _NORMALMAP 1
#define _NORMAL_DROPOFF_TS 1
#define ATTRIBUTES_NEED_NORMAL
#define ATTRIBUTES_NEED_TANGENT
#define ATTRIBUTES_NEED_TEXCOORD0
#define ATTRIBUTES_NEED_TEXCOORD1
#define ATTRIBUTES_NEED_TEXCOORD2
#define VARYINGS_NEED_POSITION_WS
#define VARYINGS_NEED_NORMAL_WS
#define VARYINGS_NEED_TANGENT_WS
#define VARYINGS_NEED_TEXCOORD0
#define VARYINGS_NEED_FOG_AND_VERTEX_LIGHT
#define VARYINGS_NEED_SHADOW_COORD
#define FEATURES_GRAPH_VERTEX
/* WARNING: $splice Could not find named fragment 'PassInstancing' */
#define SHADERPASS SHADERPASS_FORWARD
#define _FOG_FRAGMENT 1
#define _SURFACE_TYPE_TRANSPARENT 1
#define _ALPHAPREMULTIPLY_ON 1
#define REQUIRE_DEPTH_TEXTURE
/* WARNING: $splice Could not find named fragment 'DotsInstancingVars' */
// custom interpolator pre-include
/* WARNING: $splice Could not find named fragment 'sgci_CustomInterpolatorPreInclude' */
// Includes
#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 "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 "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"
// --------------------------------------------------
// Structs and Packing
// custom interpolators pre packing
/* WARNING: $splice Could not find named fragment 'CustomInterpolatorPrePacking' */
struct Attributes
{
float3 positionOS : POSITION;
float3 normalOS : NORMAL;
float4 tangentOS : TANGENT;
float4 uv0 : TEXCOORD0;
float4 uv1 : TEXCOORD1;
float4 uv2 : TEXCOORD2;
#if UNITY_ANY_INSTANCING_ENABLED
uint instanceID : INSTANCEID_SEMANTIC;
#endif
};
struct Varyings
{
float4 positionCS : SV_POSITION;
float3 positionWS;
float3 normalWS;
float4 tangentWS;
float4 texCoord0;
#if defined(LIGHTMAP_ON)
float2 staticLightmapUV;
#endif
#if defined(DYNAMICLIGHTMAP_ON)
float2 dynamicLightmapUV;
#endif
#if !defined(LIGHTMAP_ON)
float3 sh;
#endif
float4 fogFactorAndVertexLight;
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
float4 shadowCoord;
#endif
#if UNITY_ANY_INSTANCING_ENABLED
uint instanceID : CUSTOM_INSTANCE_ID;
#endif
#if (defined(UNITY_STEREO_MULTIVIEW_ENABLED)) || (defined(UNITY_STEREO_INSTANCING_ENABLED) && (defined(SHADER_API_GLES3) || defined(SHADER_API_GLCORE)))
uint stereoTargetEyeIndexAsBlendIdx0 : BLENDINDICES0;
#endif
#if (defined(UNITY_STEREO_INSTANCING_ENABLED))
uint stereoTargetEyeIndexAsRTArrayIdx : SV_RenderTargetArrayIndex;
#endif
#if defined(SHADER_STAGE_FRAGMENT) && defined(VARYINGS_NEED_CULLFACE)
FRONT_FACE_TYPE cullFace : FRONT_FACE_SEMANTIC;
#endif
};
struct SurfaceDescriptionInputs
{
float3 WorldSpaceNormal;
float3 TangentSpaceNormal;
float3 WorldSpacePosition;
float4 ScreenPosition;
float2 NDCPosition;
float2 PixelPosition;
float4 uv0;
float3 TimeParameters;
};
struct VertexDescriptionInputs
{
float3 ObjectSpaceNormal;
float3 ObjectSpaceTangent;
float3 ObjectSpacePosition;
};
struct PackedVaryings
{
float4 positionCS : SV_POSITION;
#if defined(LIGHTMAP_ON)
float2 staticLightmapUV : INTERP0;
#endif
#if defined(DYNAMICLIGHTMAP_ON)
float2 dynamicLightmapUV : INTERP1;
#endif
#if !defined(LIGHTMAP_ON)
float3 sh : INTERP2;
#endif
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
float4 shadowCoord : INTERP3;
#endif
float4 tangentWS : INTERP4;
float4 texCoord0 : INTERP5;
float4 fogFactorAndVertexLight : INTERP6;
float3 positionWS : INTERP7;
float3 normalWS : INTERP8;
#if UNITY_ANY_INSTANCING_ENABLED
uint instanceID : CUSTOM_INSTANCE_ID;
#endif
#if (defined(UNITY_STEREO_MULTIVIEW_ENABLED)) || (defined(UNITY_STEREO_INSTANCING_ENABLED) && (defined(SHADER_API_GLES3) || defined(SHADER_API_GLCORE)))
uint stereoTargetEyeIndexAsBlendIdx0 : BLENDINDICES0;
#endif
#if (defined(UNITY_STEREO_INSTANCING_ENABLED))
uint stereoTargetEyeIndexAsRTArrayIdx : SV_RenderTargetArrayIndex;
#endif
#if defined(SHADER_STAGE_FRAGMENT) && defined(VARYINGS_NEED_CULLFACE)
FRONT_FACE_TYPE cullFace : FRONT_FACE_SEMANTIC;
#endif
};
PackedVaryings PackVaryings (Varyings input)
{
PackedVaryings output;
ZERO_INITIALIZE(PackedVaryings, output);
output.positionCS = input.positionCS;
#if defined(LIGHTMAP_ON)
output.staticLightmapUV = input.staticLightmapUV;
#endif
#if defined(DYNAMICLIGHTMAP_ON)
output.dynamicLightmapUV = input.dynamicLightmapUV;
#endif
#if !defined(LIGHTMAP_ON)
output.sh = input.sh;
#endif
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
output.shadowCoord = input.shadowCoord;
#endif
output.tangentWS.xyzw = input.tangentWS;
output.texCoord0.xyzw = input.texCoord0;
output.fogFactorAndVertexLight.xyzw = input.fogFactorAndVertexLight;
output.positionWS.xyz = input.positionWS;
output.normalWS.xyz = input.normalWS;
#if UNITY_ANY_INSTANCING_ENABLED
output.instanceID = input.instanceID;
#endif
#if (defined(UNITY_STEREO_MULTIVIEW_ENABLED)) || (defined(UNITY_STEREO_INSTANCING_ENABLED) && (defined(SHADER_API_GLES3) || defined(SHADER_API_GLCORE)))
output.stereoTargetEyeIndexAsBlendIdx0 = input.stereoTargetEyeIndexAsBlendIdx0;
#endif
#if (defined(UNITY_STEREO_INSTANCING_ENABLED))
output.stereoTargetEyeIndexAsRTArrayIdx = input.stereoTargetEyeIndexAsRTArrayIdx;
#endif
#if defined(SHADER_STAGE_FRAGMENT) && defined(VARYINGS_NEED_CULLFACE)
output.cullFace = input.cullFace;
#endif
return output;
}
Varyings UnpackVaryings (PackedVaryings input)
{
Varyings output;
output.positionCS = input.positionCS;
#if defined(LIGHTMAP_ON)
output.staticLightmapUV = input.staticLightmapUV;
#endif
#if defined(DYNAMICLIGHTMAP_ON)
output.dynamicLightmapUV = input.dynamicLightmapUV;
#endif
#if !defined(LIGHTMAP_ON)
output.sh = input.sh;
#endif
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
output.shadowCoord = input.shadowCoord;
#endif
output.tangentWS = input.tangentWS.xyzw;
output.texCoord0 = input.texCoord0.xyzw;
output.fogFactorAndVertexLight = input.fogFactorAndVertexLight.xyzw;
output.positionWS = input.positionWS.xyz;
output.normalWS = input.normalWS.xyz;
#if UNITY_ANY_INSTANCING_ENABLED
output.instanceID = input.instanceID;
#endif
#if (defined(UNITY_STEREO_MULTIVIEW_ENABLED)) || (defined(UNITY_STEREO_INSTANCING_ENABLED) && (defined(SHADER_API_GLES3) || defined(SHADER_API_GLCORE)))
output.stereoTargetEyeIndexAsBlendIdx0 = input.stereoTargetEyeIndexAsBlendIdx0;
#endif
#if (defined(UNITY_STEREO_INSTANCING_ENABLED))
output.stereoTargetEyeIndexAsRTArrayIdx = input.stereoTargetEyeIndexAsRTArrayIdx;
#endif
#if defined(SHADER_STAGE_FRAGMENT) && defined(VARYINGS_NEED_CULLFACE)
output.cullFace = input.cullFace;
#endif
return output;
}
// --------------------------------------------------
// Graph
// Graph Properties
CBUFFER_START(UnityPerMaterial)
float _FresnelPower;
float4 _EmissionColor;
float _EmissionColorIntensity;
float4 _FlowMap_TexelSize;
float2 _FlowScroll;
float _FlowMapIntensity;
float _FlowScrollPeriod;
float4 _FlowSampleTexture_TexelSize;
float _FlowMapUVTimeSpeed;
float2 _FlowMapUVTiling;
float2 _FlowMapUVOffset;
float _FlowSampleScale;
float _FlowPower;
float2 _FlowStepV2;
float _FlowLightIntensity;
float _DepthMulti;
float4 _DepthColor;
float2 _DepthStepV2;
float _DepthIntensity;
CBUFFER_END
// Object and Global properties
SAMPLER(SamplerState_Linear_Repeat);
TEXTURE2D(_FlowMap);
SAMPLER(sampler_FlowMap);
TEXTURE2D(_FlowSampleTexture);
SAMPLER(sampler_FlowSampleTexture);
static Gradient _FlowGradient = {0,4,2,{float4(1,1,1,0),float4(0.5676471,0.5676471,0.5676471,0.1088273),float4(0.09179813,0.09179813,0.09179813,0.3882353),float4(0,0,0,1),float4(0,0,0,0),float4(0,0,0,0),float4(0,0,0,0),float4(0,0,0,0)},{float2(1,0),float2(1,0.9941252),float2(0,0),float2(0,0),float2(0,0),float2(0,0),float2(0,0),float2(0,0)}};
// Graph Includes
// GraphIncludes:
// -- Property used by ScenePickingPass
#ifdef SCENEPICKINGPASS
float4 _SelectionID;
#endif
// -- Properties used by SceneSelectionPass
#ifdef SCENESELECTIONPASS
int _ObjectId;
int _PassValue;
#endif
// Graph Functions
void Unity_SceneDepth_Eye_float(float4 UV, out float Out)
{
if (unity_OrthoParams.w == 1.0)
{
Out = LinearEyeDepth(ComputeWorldSpacePosition(UV.xy, SHADERGRAPH_SAMPLE_SCENE_DEPTH(UV.xy), UNITY_MATRIX_I_VP), UNITY_MATRIX_V);
}
else
{
Out = LinearEyeDepth(SHADERGRAPH_SAMPLE_SCENE_DEPTH(UV.xy), _ZBufferParams);
}
}
void Unity_Subtract_float(float A, float B, out float Out)
{
Out = A - B;
}
void Unity_Multiply_float_float(float A, float B, out float Out)
{
Out = A * B;
}
void Unity_Smoothstep_float(float Edge1, float Edge2, float In, out float Out)
{
Out = smoothstep(Edge1, Edge2, In);
}
void Unity_OneMinus_float(float In, out float Out)
{
Out = 1 - In;
}
void Unity_Multiply_float4_float4(float4 A, float4 B, out float4 Out)
{
Out = A * B;
}
void Unity_ViewVectorWorld_float(out float3 Out, float3 WorldSpacePosition)
{
Out = _WorldSpaceCameraPos.xyz - GetAbsolutePositionWS(WorldSpacePosition);
if(!IsPerspectiveProjection())
{
Out = GetViewForwardDir() * dot(Out, GetViewForwardDir());
}
}
void Unity_FresnelEffect_float(float3 Normal, float3 ViewDir, float Power, out float Out)
{
Out = pow((1.0 - saturate(dot(normalize(Normal), normalize(ViewDir)))), Power);
}
void Unity_Multiply_float2_float2(float2 A, float2 B, out float2 Out)
{
Out = A * B;
}
void Unity_Add_float2(float2 A, float2 B, out float2 Out)
{
Out = A + B;
}
void Unity_TilingAndOffset_float(float2 UV, float2 Tiling, float2 Offset, out float2 Out)
{
Out = UV * Tiling + Offset;
}
void Unity_Sine_float(float In, out float Out)
{
Out = sin(In);
}
void Unity_Remap_float(float In, float2 InMinMax, float2 OutMinMax, out float Out)
{
Out = OutMinMax.x + (In - InMinMax.x) * (OutMinMax.y - OutMinMax.x) / (InMinMax.y - InMinMax.x);
}
void Unity_Subtract_float2(float2 A, float2 B, out float2 Out)
{
Out = A - B;
}
void Unity_Modulo_float(float A, float B, out float Out)
{
Out = fmod(A, B);
}
void Unity_Divide_float(float A, float B, out float Out)
{
Out = A / B;
}
void Unity_Add_float(float A, float B, out float Out)
{
Out = A + B;
}
void Unity_Fraction_float(float In, out float Out)
{
Out = frac(In);
}
void Unity_Absolute_float(float In, out float Out)
{
Out = abs(In);
}
struct Bindings_FlowMapComputeUV_float
{
};
void FlowMapComputeUV(float2 UV, float Time, UnityTexture2D FlowMap, float FlowIntensity, float Period, Bindings_FlowMapComputeUV_float IN, out float4 FlowUV, out float FlowBlend)
{
float4 FlowMapSample = SAMPLE_TEXTURE2D(FlowMap.tex, FlowMap.samplerstate, FlowMap.GetTransformedUV(UV));
float2 FlowMapSampleRG = float2(FlowMapSample.r, FlowMapSample.g);
float2 SubtractOut_Vector2;
Unity_Subtract_float2(FlowMapSampleRG, float2(0.5, 0.5), SubtractOut_Vector2);
float ModuloOut_Float;
Unity_Modulo_float(Time, Period, ModuloOut_Float);
float DivideOut_Float;
Unity_Divide_float(ModuloOut_Float, Period, DivideOut_Float);
float SubtractOut_Float;
Unity_Subtract_float(DivideOut_Float, 0.5, SubtractOut_Float);
float2 MultiplyOut_Vector2;
Unity_Multiply_float2_float2(SubtractOut_Vector2, (SubtractOut_Float.xx), MultiplyOut_Vector2);
float AddOut_Float;
Unity_Add_float(DivideOut_Float, 0.5, AddOut_Float);
float FractionOut_Float;
Unity_Fraction_float(AddOut_Float, FractionOut_Float);
float SubtractOut_Float1;
Unity_Subtract_float(FractionOut_Float, 0.5, SubtractOut_Float1);
float2 MultiplyOut_Vector21;
Unity_Multiply_float2_float2(SubtractOut_Vector2, (SubtractOut_Float1.xx), MultiplyOut_Vector21);
float4 Vector4Out_Vector4 = float4(MultiplyOut_Vector2[0], MultiplyOut_Vector2[1], MultiplyOut_Vector21[0], MultiplyOut_Vector21[1]);
float4 MultiplyOut_Vector4;
Unity_Multiply_float4_float4(Vector4Out_Vector4, (FlowIntensity.xxxx), MultiplyOut_Vector4);
float AbsoluteOut_Float;
Unity_Absolute_float(SubtractOut_Float, AbsoluteOut_Float);
float AddOut_Float1;
Unity_Add_float(AbsoluteOut_Float, AbsoluteOut_Float, AddOut_Float1);
FlowUV = MultiplyOut_Vector4;
FlowBlend = AddOut_Float1;
}
void Unity_Lerp_float4(float4 A, float4 B, float4 T, out float4 Out)
{
Out = lerp(A, B, T);
}
struct Bindings_FlowMapSampleTexture_float
{
};
void FlowMapSampleTexture(float2 UV, UnityTexture2D SampleTexture, float FlowSampleScale, float4 FlowMapUV, float FlowBlend, Bindings_FlowMapSampleTexture_float IN, out float4 Output)
{
float4 MultiplyOut_Vector4;
Unity_Multiply_float4_float4(FlowMapUV, (FlowSampleScale.xxxx), MultiplyOut_Vector4);
float2 Vector2Out_Vector2 = float2(MultiplyOut_Vector4[0], MultiplyOut_Vector4[1]);
float2 AddOut_Vector2;
Unity_Add_float2(UV, Vector2Out_Vector2, AddOut_Vector2);
float4 SampleTexture2DRGBA = SAMPLE_TEXTURE2D(SampleTexture.tex, SampleTexture.samplerstate, SampleTexture.GetTransformedUV(AddOut_Vector2) );
float2 Vector2Out_Vector21 = float2(MultiplyOut_Vector4[2], MultiplyOut_Vector4[3]);
float2 AddOut_Vector21;
Unity_Add_float2(UV, Vector2Out_Vector21, AddOut_Vector21);
float4 SampleTexture2DRGBA1 = SAMPLE_TEXTURE2D(SampleTexture.tex, SampleTexture.samplerstate, SampleTexture.GetTransformedUV(AddOut_Vector21) );
float4 LerpOut_Vector4;
Unity_Lerp_float4(SampleTexture2DRGBA, SampleTexture2DRGBA1, (FlowBlend.xxxx), LerpOut_Vector4);
Output = LerpOut_Vector4;
}
void Unity_Power_float(float A, float B, out float Out)
{
Out = pow(A, B);
}
void Unity_Clamp_float(float In, float Min, float Max, out float Out)
{
Out = clamp(In, Min, Max);
}
void Unity_SampleGradientV1_float(Gradient Gradient, float Time, out float4 Out)
{
float3 color = Gradient.colors[0].rgb;
[unroll]
for (int c = 1; c < Gradient.colorsLength; c++)
{
float colorPos = saturate((Time - Gradient.colors[c - 1].w) / (Gradient.colors[c].w - Gradient.colors[c - 1].w)) * step(c, Gradient.colorsLength - 1);
color = lerp(color, Gradient.colors[c].rgb, lerp(colorPos, step(0.01, colorPos), Gradient.type));
}
#ifdef UNITY_COLORSPACE_GAMMA
color = LinearToSRGB(color);
#endif
float alpha = Gradient.alphas[0].x;
[unroll]
for (int a = 1; a < Gradient.alphasLength; a++)
{
float alphaPos = saturate((Time - Gradient.alphas[a - 1].y) / (Gradient.alphas[a].y - Gradient.alphas[a - 1].y)) * step(a, Gradient.alphasLength - 1);
alpha = lerp(alpha, Gradient.alphas[a].x, lerp(alphaPos, step(0.01, alphaPos), Gradient.type));
}
Out = float4(color, alpha);
}
void Unity_Add_float4(float4 A, float4 B, out float4 Out)
{
Out = A + B;
}
// Custom interpolators pre vertex
/* WARNING: $splice Could not find named fragment 'CustomInterpolatorPreVertex' */
// Graph Vertex
struct VertexDescription
{
float3 Position;
float3 Normal;
float3 Tangent;
};
VertexDescription VertexDescriptionFunction(VertexDescriptionInputs IN)
{
VertexDescription description = (VertexDescription)0;
description.Position = IN.ObjectSpacePosition;
description.Normal = IN.ObjectSpaceNormal;
description.Tangent = IN.ObjectSpaceTangent;
return description;
}
// Custom interpolators, pre surface
#ifdef FEATURES_GRAPH_VERTEX
Varyings CustomInterpolatorPassThroughFunc(inout Varyings output, VertexDescription input)
{
return output;
}
#define CUSTOMINTERPOLATOR_VARYPASSTHROUGH_FUNC
#endif
// Graph Pixel
struct SurfaceDescription
{
float3 BaseColor;
float3 NormalTS;
float3 Emission;
float Metallic;
float Smoothness;
float Occlusion;
float Alpha;
};
SurfaceDescription SurfaceDescriptionFunction(SurfaceDescriptionInputs IN)
{
SurfaceDescription surface = (SurfaceDescription)0;
float SceneDepthOut_Float;
Unity_SceneDepth_Eye_float(float4(IN.NDCPosition.xy, 0, 0), SceneDepthOut_Float);
float4 ScreenPositionOut_Vector4 = IN.ScreenPosition;
float SubtractOut_Float;
Unity_Subtract_float(SceneDepthOut_Float, ScreenPositionOut_Vector4[3], SubtractOut_Float);
float MultiplyOut_Float;
Unity_Multiply_float_float(SubtractOut_Float, _DepthMulti, MultiplyOut_Float);
float SmoothstepOut_Float;
Unity_Smoothstep_float(_DepthStepV2[0], _DepthStepV2[1], MultiplyOut_Float, SmoothstepOut_Float);
float OneMinusOut_Float;
Unity_OneMinus_float(SmoothstepOut_Float, OneMinusOut_Float);
float4 MultiplyOut_Vector4;
Unity_Multiply_float4_float4(_DepthColor, (OneMinusOut_Float.xxxx), MultiplyOut_Vector4);
float4 MultiplyOut_Vector41;
Unity_Multiply_float4_float4(MultiplyOut_Vector4, (_DepthIntensity.xxxx), MultiplyOut_Vector41);
float3 ViewVectorOut_Vector3;
Unity_ViewVectorWorld_float(ViewVectorOut_Vector3, IN.WorldSpacePosition);
float FresnelEffectOut_Float;
Unity_FresnelEffect_float(IN.WorldSpaceNormal, ViewVectorOut_Vector3, _FresnelPower, FresnelEffectOut_Float);
float4 MultiplyOut_Vector42;
Unity_Multiply_float4_float4(_EmissionColor, (FresnelEffectOut_Float.xxxx), MultiplyOut_Vector42);
float4 MultiplyOut_Vector43;
Unity_Multiply_float4_float4((_EmissionColorIntensity.xxxx), MultiplyOut_Vector42, MultiplyOut_Vector43);
float2 MultiplyOut_Vector2;
Unity_Multiply_float2_float2((IN.TimeParameters.x.xx), _FlowScroll, MultiplyOut_Vector2);
float2 AddOut_Vector2;
Unity_Add_float2((IN.uv0.xy), MultiplyOut_Vector2, AddOut_Vector2);
UnityTexture2D BuildFlowTexture = UnityBuildTexture2DStructNoScale(_FlowSampleTexture);
float2 TilingAndOffsetOut_Vector2;
Unity_TilingAndOffset_float(AddOut_Vector2, _FlowMapUVTiling, _FlowMapUVOffset, TilingAndOffsetOut_Vector2);
float MultiplyOut_Float1;
Unity_Multiply_float_float(IN.TimeParameters.x, _FlowMapUVTimeSpeed, MultiplyOut_Float1);
float SineOut_Float;
Unity_Sine_float(MultiplyOut_Float1, SineOut_Float);
float RampOut_Float;
Unity_Remap_float(SineOut_Float, float2 (-1, 1), float2 (0, 1), RampOut_Float);
UnityTexture2D PropertyOut_Texture2D = UnityBuildTexture2DStructNoScale(_FlowMap);
Bindings_FlowMapComputeUV_float FlowMapComputeUV_float;
float4 FlowMapComputeUV_FlowUV_Vector4;
float FlowMapComputeUV_FlowBlend_Float;
FlowMapComputeUV(TilingAndOffsetOut_Vector2, RampOut_Float, PropertyOut_Texture2D, _FlowMapIntensity, _FlowScrollPeriod, FlowMapComputeUV_float, FlowMapComputeUV_FlowUV_Vector4, FlowMapComputeUV_FlowBlend_Float);
Bindings_FlowMapSampleTexture_float FlowMapSampleTexture_float;
float4 FlowMapSampleTexture_Output_Vector4;
FlowMapSampleTexture(AddOut_Vector2, BuildFlowTexture, _FlowSampleScale, FlowMapComputeUV_FlowUV_Vector4, FlowMapComputeUV_FlowBlend_Float, FlowMapSampleTexture_float, FlowMapSampleTexture_Output_Vector4);
float PowerOut_Float;
Unity_Power_float(FlowMapSampleTexture_Output_Vector4[3], _FlowPower, PowerOut_Float);
float ClampOut_Float;
Unity_Clamp_float(PowerOut_Float, 0, 1, ClampOut_Float);
float SmoothstepOut_Float1;
Unity_Smoothstep_float(_FlowStepV2[0], _FlowStepV2[1], ClampOut_Float, SmoothstepOut_Float1);
float4 SampleGradientOut_Vector4;
Unity_SampleGradientV1_float(_FlowGradient, SmoothstepOut_Float1, SampleGradientOut_Vector4);
float4 MultiplyOut_Vector44;
Unity_Multiply_float4_float4((_FlowLightIntensity.xxxx), SampleGradientOut_Vector4, MultiplyOut_Vector44);
float4 MultiplyOut_Vector45;
Unity_Multiply_float4_float4(MultiplyOut_Vector43, MultiplyOut_Vector44, MultiplyOut_Vector45);
float4 MultiplyOut_Vector46;
Unity_Multiply_float4_float4(MultiplyOut_Vector41, MultiplyOut_Vector45, MultiplyOut_Vector46);
float4 AddOut_Vector4;
Unity_Add_float4(MultiplyOut_Vector46, MultiplyOut_Vector45, AddOut_Vector4);
surface.BaseColor = IsGammaSpace() ? float3(1, 1, 1) : SRGBToLinear(float3(1, 1, 1));
surface.NormalTS = IN.TangentSpaceNormal;
surface.Emission = (AddOut_Vector4.xyz);
surface.Metallic = 0;
surface.Smoothness = 0.5;
surface.Occlusion = 1;
surface.Alpha = MultiplyOut_Vector43;
return surface;
}
// --------------------------------------------------
// Build Graph Inputs
#ifdef HAVE_VFX_MODIFICATION
#define VFX_SRP_ATTRIBUTES Attributes
#define VFX_SRP_VARYINGS Varyings
#define VFX_SRP_SURFACE_INPUTS SurfaceDescriptionInputs
#endif
VertexDescriptionInputs BuildVertexDescriptionInputs(Attributes input)
{
VertexDescriptionInputs output;
ZERO_INITIALIZE(VertexDescriptionInputs, output);
output.ObjectSpaceNormal = input.normalOS;
output.ObjectSpaceTangent = input.tangentOS.xyz;
output.ObjectSpacePosition = input.positionOS;
return output;
}
SurfaceDescriptionInputs BuildSurfaceDescriptionInputs(Varyings input)
{
SurfaceDescriptionInputs output;
ZERO_INITIALIZE(SurfaceDescriptionInputs, output);
#ifdef HAVE_VFX_MODIFICATION
#if VFX_USE_GRAPH_VALUES
uint instanceActiveIndex = asuint(UNITY_ACCESS_INSTANCED_PROP(PerInstance, _InstanceActiveIndex));
/* WARNING: $splice Could not find named fragment 'VFXLoadGraphValues' */
#endif
/* WARNING: $splice Could not find named fragment 'VFXSetFragInputs' */
#endif
// must use interpolated tangent, bitangent and normal before they are normalized in the pixel shader.
float3 unnormalizedNormalWS = input.normalWS;
const float renormFactor = 1.0 / length(unnormalizedNormalWS);
output.WorldSpaceNormal = renormFactor * input.normalWS.xyz; // we want a unit length Normal Vector node in shader graph
output.TangentSpaceNormal = float3(0.0f, 0.0f, 1.0f);
output.WorldSpacePosition = input.positionWS;
output.ScreenPosition = ComputeScreenPos(TransformWorldToHClip(input.positionWS), _ProjectionParams.x);
#if UNITY_UV_STARTS_AT_TOP
output.PixelPosition = float2(input.positionCS.x, (_ProjectionParams.x < 0) ? (_ScaledScreenParams.y - input.positionCS.y) : input.positionCS.y);
#else
output.PixelPosition = float2(input.positionCS.x, (_ProjectionParams.x > 0) ? (_ScaledScreenParams.y - input.positionCS.y) : input.positionCS.y);
#endif
output.NDCPosition = output.PixelPosition.xy / _ScaledScreenParams.xy;
output.NDCPosition.y = 1.0f - output.NDCPosition.y;
output.uv0 = input.texCoord0;
output.TimeParameters = _TimeParameters.xyz; // This is mainly for LW as HD overwrite this value
#if defined(SHADER_STAGE_FRAGMENT) && defined(VARYINGS_NEED_CULLFACE)
#define BUILD_SURFACE_DESCRIPTION_INPUTS_OUTPUT_FACESIGN output.FaceSign = IS_FRONT_VFACE(input.cullFace, true, false);
#else
#define BUILD_SURFACE_DESCRIPTION_INPUTS_OUTPUT_FACESIGN
#endif
#undef BUILD_SURFACE_DESCRIPTION_INPUTS_OUTPUT_FACESIGN
return output;
}
// --------------------------------------------------
// Main
#include "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/Varyings.hlsl"
#include "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/PBRForwardPass.hlsl"
// --------------------------------------------------
// Visual Effect Vertex Invocations
#ifdef HAVE_VFX_MODIFICATION
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/VisualEffectVertex.hlsl"
#endif
ENDHLSL
}
}
}
目前只修改了名称,还不会影响最终效果。
现在根据这篇文章的效果,附加点击相应。
unity URP 利用particle system制作简单的shader交互-CSDN博客
点击相应效果在附带文件中的名为ForceField的shader graph
最终效果在附带文件中的名为FinalGraph的shader graph
这个方法就是交互的主要计算方法
float4 CalculateCircle(SurfaceDescriptionInputs i, float3 _HitPos, float _HitSize, float _HitSpread, float _HitSizeMax, float _DisappearSpread)
{
float3 tempdis = distance(_HitPos, i.WorldSpacePosition);
float tempupmul = clamp(((tempdis - _HitSizeMax) * (-1) )/ _DisappearSpread, 0, 1);
//float noiseout = 0;
//Unity_SimpleNoise_Deterministic_float(i.uv, _HitSpreadNoiseScale, noiseout);
//这里换成Triplanar三方向平面映射,原本使用uv采样,会导致噪点在那两个位置收缩,现在使用三面映射,就规避了这个问题。特别是对于噪点图,我认为是非常合适的采样方式。
float4 noiseout = TriPlanar(i.WorldSpacePosition, i.WorldSpaceNormal, _TriPlanarTile, _TriPlanarBlend);
noiseout = noiseout * _HitSpreadNoiseMulti;
float temp1 = noiseout + (tempdis - _HitSize);
float temp2 = 1 - clamp(temp1 / min(_HitSize, _HitSpread), 0, 1);
Gradient _Gradient = NewGradient(0, 4, 2, float4(0, 0, 0, 0),float4(0.767647, 0.767647, 0.767647, 0.1058824),float4(0.6861503, 0.6861503, 0.6861503, 0.7705958),float4(0, 0, 0, 0.9647059),float4(0, 0, 0, 0),float4(0, 0, 0, 0),float4(0, 0, 0, 0),float4(0, 0, 0, 0), float2(1, 0),float2(1, 1),float2(0, 0),float2(0, 0),float2(0, 0),float2(0, 0),float2(0, 0),float2(0, 0));
float4 gradientout = 0;
Unity_SampleGradientV1_float(_Gradient, temp2, gradientout);
return tempupmul * gradientout;
}
有些交互计算需要的变量输入要添加一下
通过数组参数循环添加到目前的颜色计算中,最终代码为这样
Shader "Translate/InteractiveShieldFinal"
{
Properties
{
_TriplanarTexture ("TriplanarTexture", 2D) = "white" {}
_HitPos("HitPos", Vector) = (0, 0, 0, 0)
_HitSize("HitSize", Float) = 0.001
_HitSpread("HitSpread", Range(0, 10)) = 1
_HitSizeMax("HitSizeMax", Float) = 0
_DisappearSpread("DisappearSpread", Float) = 1
_HitSpreadNoiseMulti("HitSpreadNoiseMulti", Range(0.01, 10)) = 1
_HitSpreadNoiseScale("HitSpreadNoiseScale", Range(1, 200)) = 20
_TriPlanarTile("TriPlanarTile", Range(0.01, 10)) = 1
_TriPlanarBlend("TriPlanarBlend", Range(0.01, 10)) = 1
_FresnelPower("FresnelPower", Float) = 1
_EmissionColor("EmissionColor", Color) = (0.2783019, 0.7026262, 1, 0)
_EmissionColorIntensity("EmissionColorIntensity", Float) = 12
[NoScaleOffset]_FlowMap("FlowMap", 2D) = "white" {}
_FlowScroll("FlowScroll", Vector) = (0.1, 0.1, 0, 0)
_FlowMapUVTiling("FlowMapUVTiling", Vector) = (1, 1, 0, 0)
_FlowMapUVOffset("FlowMapUVOffset", Vector) = (0, 0, 0, 0)
_FlowMapUVTimeSpeed("FlowMapUVTimeSpeed", Float) = 6
_FlowMapIntensity("FlowMapIntensity", Float) = 1
_FlowScrollPeriod("FlowScrollPeriod", Float) = 5
[NoScaleOffset]_FlowSampleTexture("FlowSampleTexture", 2D) = "white" {}
_FlowSampleScale("FlowSampleScale", Float) = 0
_FlowPower("FlowPower", Float) = 1
_FlowStepV2("FlowStepV2", Vector) = (0, 1, 0, 0)
_FlowLightIntensity("FlowLightIntensity", Float) = 1
_DepthMulti("DepthMulti", Float) = 1
_DepthColor("DepthColor", Color) = (1, 1, 1, 0)
_DepthStepV2("DepthStepV2", Vector) = (0.2, 1, 0, 0)
_DepthIntensity("DepthIntensity", Float) = 1
_AlphaPow("AlphaPow", Float) = 1
[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) = "" {}
}
SubShader
{
Tags
{
"RenderPipeline"="UniversalPipeline"
"RenderType"="Transparent"
"UniversalMaterialType" = "Lit"
"Queue"="Transparent"
"DisableBatching"="False"
"ShaderGraphShader"="true"
"ShaderGraphTargetId"="UniversalLitSubTarget"
}
Pass
{
Name "Universal Forward"
Tags
{
"LightMode" = "UniversalForward"
}
// Render State
Cull Back
Blend One OneMinusSrcAlpha, One OneMinusSrcAlpha
ZTest LEqual
ZWrite Off
HLSLPROGRAM
// Pragmas
#pragma target 2.0
#pragma multi_compile_fog
#pragma vertex vert
#pragma fragment frag
// Defines
#define _NORMALMAP 1
#define _NORMAL_DROPOFF_TS 1
#define ATTRIBUTES_NEED_NORMAL
#define ATTRIBUTES_NEED_TANGENT
#define ATTRIBUTES_NEED_TEXCOORD0
#define ATTRIBUTES_NEED_TEXCOORD1
#define ATTRIBUTES_NEED_TEXCOORD2
#define VARYINGS_NEED_POSITION_WS
#define VARYINGS_NEED_NORMAL_WS
#define VARYINGS_NEED_TANGENT_WS
#define VARYINGS_NEED_TEXCOORD0
#define VARYINGS_NEED_FOG_AND_VERTEX_LIGHT
#define VARYINGS_NEED_SHADOW_COORD
#define FEATURES_GRAPH_VERTEX
/* WARNING: $splice Could not find named fragment 'PassInstancing' */
#define SHADERPASS SHADERPASS_FORWARD
#define _FOG_FRAGMENT 1
#define _SURFACE_TYPE_TRANSPARENT 1
#define _ALPHAPREMULTIPLY_ON 1
#define REQUIRE_DEPTH_TEXTURE
/* WARNING: $splice Could not find named fragment 'DotsInstancingVars' */
// custom interpolator pre-include
/* WARNING: $splice Could not find named fragment 'sgci_CustomInterpolatorPreInclude' */
// Includes
#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 "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 "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"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Hashes.hlsl"
// --------------------------------------------------
// Structs and Packing
// custom interpolators pre packing
/* WARNING: $splice Could not find named fragment 'CustomInterpolatorPrePacking' */
struct Attributes
{
float3 positionOS : POSITION;
float3 normalOS : NORMAL;
float4 tangentOS : TANGENT;
float4 uv0 : TEXCOORD0;
};
struct Varyings
{
float4 positionCS : SV_POSITION;
float3 positionWS;
float3 normalWS;
float4 tangentWS;
float4 texCoord0;
#if defined(LIGHTMAP_ON)
float2 staticLightmapUV;
#endif
#if defined(DYNAMICLIGHTMAP_ON)
float2 dynamicLightmapUV;
#endif
#if !defined(LIGHTMAP_ON)
float3 sh;
#endif
float4 fogFactorAndVertexLight;
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
float4 shadowCoord;
#endif
#if UNITY_ANY_INSTANCING_ENABLED
uint instanceID : CUSTOM_INSTANCE_ID;
#endif
#if (defined(UNITY_STEREO_MULTIVIEW_ENABLED)) || (defined(UNITY_STEREO_INSTANCING_ENABLED) && (defined(SHADER_API_GLES3) || defined(SHADER_API_GLCORE)))
uint stereoTargetEyeIndexAsBlendIdx0 : BLENDINDICES0;
#endif
#if (defined(UNITY_STEREO_INSTANCING_ENABLED))
uint stereoTargetEyeIndexAsRTArrayIdx : SV_RenderTargetArrayIndex;
#endif
#if defined(SHADER_STAGE_FRAGMENT) && defined(VARYINGS_NEED_CULLFACE)
FRONT_FACE_TYPE cullFace : FRONT_FACE_SEMANTIC;
#endif
};
struct SurfaceDescriptionInputs
{
float3 WorldSpaceNormal;
float3 TangentSpaceNormal;
float3 WorldSpacePosition;
float4 ScreenPosition;
float2 NDCPosition;
float2 PixelPosition;
float4 uv0;
float3 TimeParameters;
};
struct VertexDescriptionInputs
{
float3 ObjectSpaceNormal;
float3 ObjectSpaceTangent;
float3 ObjectSpacePosition;
};
struct PackedVaryings
{
float4 positionCS : SV_POSITION;
#if defined(LIGHTMAP_ON)
float2 staticLightmapUV : INTERP0;
#endif
#if defined(DYNAMICLIGHTMAP_ON)
float2 dynamicLightmapUV : INTERP1;
#endif
#if !defined(LIGHTMAP_ON)
float3 sh : INTERP2;
#endif
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
float4 shadowCoord : INTERP3;
#endif
float4 tangentWS : INTERP4;
float4 texCoord0 : INTERP5;
float4 fogFactorAndVertexLight : INTERP6;
float3 positionWS : INTERP7;
float3 normalWS : INTERP8;
#if UNITY_ANY_INSTANCING_ENABLED
uint instanceID : CUSTOM_INSTANCE_ID;
#endif
#if (defined(UNITY_STEREO_MULTIVIEW_ENABLED)) || (defined(UNITY_STEREO_INSTANCING_ENABLED) && (defined(SHADER_API_GLES3) || defined(SHADER_API_GLCORE)))
uint stereoTargetEyeIndexAsBlendIdx0 : BLENDINDICES0;
#endif
#if (defined(UNITY_STEREO_INSTANCING_ENABLED))
uint stereoTargetEyeIndexAsRTArrayIdx : SV_RenderTargetArrayIndex;
#endif
#if defined(SHADER_STAGE_FRAGMENT) && defined(VARYINGS_NEED_CULLFACE)
FRONT_FACE_TYPE cullFace : FRONT_FACE_SEMANTIC;
#endif
};
PackedVaryings PackVaryings (Varyings input)
{
PackedVaryings output;
ZERO_INITIALIZE(PackedVaryings, output);
output.positionCS = input.positionCS;
#if defined(LIGHTMAP_ON)
output.staticLightmapUV = input.staticLightmapUV;
#endif
#if defined(DYNAMICLIGHTMAP_ON)
output.dynamicLightmapUV = input.dynamicLightmapUV;
#endif
#if !defined(LIGHTMAP_ON)
output.sh = input.sh;
#endif
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
output.shadowCoord = input.shadowCoord;
#endif
output.tangentWS.xyzw = input.tangentWS;
output.texCoord0.xyzw = input.texCoord0;
output.fogFactorAndVertexLight.xyzw = input.fogFactorAndVertexLight;
output.positionWS.xyz = input.positionWS;
output.normalWS.xyz = input.normalWS;
#if UNITY_ANY_INSTANCING_ENABLED
output.instanceID = input.instanceID;
#endif
#if (defined(UNITY_STEREO_MULTIVIEW_ENABLED)) || (defined(UNITY_STEREO_INSTANCING_ENABLED) && (defined(SHADER_API_GLES3) || defined(SHADER_API_GLCORE)))
output.stereoTargetEyeIndexAsBlendIdx0 = input.stereoTargetEyeIndexAsBlendIdx0;
#endif
#if (defined(UNITY_STEREO_INSTANCING_ENABLED))
output.stereoTargetEyeIndexAsRTArrayIdx = input.stereoTargetEyeIndexAsRTArrayIdx;
#endif
#if defined(SHADER_STAGE_FRAGMENT) && defined(VARYINGS_NEED_CULLFACE)
output.cullFace = input.cullFace;
#endif
return output;
}
Varyings UnpackVaryings (PackedVaryings input)
{
Varyings output;
output.positionCS = input.positionCS;
#if defined(LIGHTMAP_ON)
output.staticLightmapUV = input.staticLightmapUV;
#endif
#if defined(DYNAMICLIGHTMAP_ON)
output.dynamicLightmapUV = input.dynamicLightmapUV;
#endif
#if !defined(LIGHTMAP_ON)
output.sh = input.sh;
#endif
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
output.shadowCoord = input.shadowCoord;
#endif
output.tangentWS = input.tangentWS.xyzw;
output.texCoord0 = input.texCoord0.xyzw;
output.fogFactorAndVertexLight = input.fogFactorAndVertexLight.xyzw;
output.positionWS = input.positionWS.xyz;
output.normalWS = input.normalWS.xyz;
#if UNITY_ANY_INSTANCING_ENABLED
output.instanceID = input.instanceID;
#endif
#if (defined(UNITY_STEREO_MULTIVIEW_ENABLED)) || (defined(UNITY_STEREO_INSTANCING_ENABLED) && (defined(SHADER_API_GLES3) || defined(SHADER_API_GLCORE)))
output.stereoTargetEyeIndexAsBlendIdx0 = input.stereoTargetEyeIndexAsBlendIdx0;
#endif
#if (defined(UNITY_STEREO_INSTANCING_ENABLED))
output.stereoTargetEyeIndexAsRTArrayIdx = input.stereoTargetEyeIndexAsRTArrayIdx;
#endif
#if defined(SHADER_STAGE_FRAGMENT) && defined(VARYINGS_NEED_CULLFACE)
output.cullFace = input.cullFace;
#endif
return output;
}
// --------------------------------------------------
// Graph
// Graph Properties
CBUFFER_START(UnityPerMaterial)
float _TriPlanarTile;
float _TriPlanarBlend;
float _HitSpreadNoiseScale;
float _HitSpreadNoiseMulti;
int count;
float3 hitposarray[20];
float hitsizearray[20];
float hitspreadarray[20];
float hitsizemaxarray[20];
float disappearspreadarray[20];
float _FresnelPower;
float4 _EmissionColor;
float _EmissionColorIntensity;
float4 _FlowMap_TexelSize;
float2 _FlowScroll;
float _FlowMapIntensity;
float _FlowScrollPeriod;
float4 _FlowSampleTexture_TexelSize;
float _FlowMapUVTimeSpeed;
float2 _FlowMapUVTiling;
float2 _FlowMapUVOffset;
float _FlowSampleScale;
float _FlowPower;
float2 _FlowStepV2;
float _FlowLightIntensity;
float _DepthMulti;
float4 _DepthColor;
float2 _DepthStepV2;
float _DepthIntensity;
float _AlphaPow;
CBUFFER_END
// Object and Global properties
SAMPLER(SamplerState_Linear_Repeat);
TEXTURE2D(_FlowMap);
SAMPLER(sampler_FlowMap);
TEXTURE2D(_FlowSampleTexture);
SAMPLER(sampler_FlowSampleTexture);
static Gradient _FlowGradient = {0,4,2,{float4(1,1,1,0),float4(0.5676471,0.5676471,0.5676471,0.1088273),float4(0.09179813,0.09179813,0.09179813,0.3882353),float4(0,0,0,1),float4(0,0,0,0),float4(0,0,0,0),float4(0,0,0,0),float4(0,0,0,0)},{float2(1,0),float2(1,0.9941252),float2(0,0),float2(0,0),float2(0,0),float2(0,0),float2(0,0),float2(0,0)}};
float Unity_SimpleNoise_ValueNoise_Deterministic_float (float2 uv)
{
float2 i = floor(uv);
float2 f = frac(uv);
f = f * f * (3.0 - 2.0 * f);
uv = abs(frac(uv) - 0.5);
float2 c0 = i + float2(0.0, 0.0);
float2 c1 = i + float2(1.0, 0.0);
float2 c2 = i + float2(0.0, 1.0);
float2 c3 = i + float2(1.0, 1.0);
float r0; Hash_Tchou_2_1_float(c0, r0);
float r1; Hash_Tchou_2_1_float(c1, r1);
float r2; Hash_Tchou_2_1_float(c2, r2);
float r3; Hash_Tchou_2_1_float(c3, r3);
float bottomOfGrid = lerp(r0, r1, f.x);
float topOfGrid = lerp(r2, r3, f.x);
float t = lerp(bottomOfGrid, topOfGrid, f.y);
return t;
}
void Unity_SimpleNoise_Deterministic_float(float2 UV, float Scale, out float Out)
{
float freq, amp;
Out = 0.0f;
freq = pow(2.0, float(0));
amp = pow(0.5, float(3-0));
Out += Unity_SimpleNoise_ValueNoise_Deterministic_float(float2(UV.xy*(Scale/freq)))*amp;
freq = pow(2.0, float(1));
amp = pow(0.5, float(3-1));
Out += Unity_SimpleNoise_ValueNoise_Deterministic_float(float2(UV.xy*(Scale/freq)))*amp;
freq = pow(2.0, float(2));
amp = pow(0.5, float(3-2));
Out += Unity_SimpleNoise_ValueNoise_Deterministic_float(float2(UV.xy*(Scale/freq)))*amp;
}
float4 _TriplanarTexture_TexelSize;
TEXTURE2D(_TriplanarTexture);
SAMPLER(sampler_TriplanarTexture);
//https://indienova.com/indie-game-development/unity-shader-triplanar-mapping/ 这个文章讲解TriPlanar不错,这里的是shader graph中的代码,参数相比这篇文章更多,观感上有更多调整空间
half4 TriPlanar (float3 positionWS, float3 normalWS, float tile, float blendValue)
{
UnityTexture2D mytexture2d = UnityBuildTexture2DStructNoScale(_TriplanarTexture);
float3 TriplanarUV = positionWS * tile;
float3 TriplanarBlend = SafePositivePow_float(normalWS, min(1, floor(log2(Min_float())/log2(1/sqrt(3)))) );
TriplanarBlend /= dot(TriplanarBlend, blendValue);
float4 Triplanar_X = SAMPLE_TEXTURE2D(mytexture2d.tex, mytexture2d.samplerstate, TriplanarUV.zy);
float4 Triplanar_Y = SAMPLE_TEXTURE2D(mytexture2d.tex, mytexture2d.samplerstate, TriplanarUV.xz);
float4 Triplanar_Z = SAMPLE_TEXTURE2D(mytexture2d.tex, mytexture2d.samplerstate, TriplanarUV.xy);
float4 _Triplanar_Out_Vector4 = Triplanar_X * TriplanarBlend.x + Triplanar_Y * TriplanarBlend.y + Triplanar_Z * TriplanarBlend.z;
return _Triplanar_Out_Vector4;
}
void Unity_SceneDepth_Eye_float(float4 UV, out float Out)
{
if (unity_OrthoParams.w == 1.0)
{
Out = LinearEyeDepth(ComputeWorldSpacePosition(UV.xy, SHADERGRAPH_SAMPLE_SCENE_DEPTH(UV.xy), UNITY_MATRIX_I_VP), UNITY_MATRIX_V);
}
else
{
Out = LinearEyeDepth(SHADERGRAPH_SAMPLE_SCENE_DEPTH(UV.xy), _ZBufferParams);
}
}
void Unity_Subtract_float(float A, float B, out float Out)
{
Out = A - B;
}
void Unity_Multiply_float_float(float A, float B, out float Out)
{
Out = A * B;
}
void Unity_Smoothstep_float(float Edge1, float Edge2, float In, out float Out)
{
Out = smoothstep(Edge1, Edge2, In);
}
void Unity_OneMinus_float(float In, out float Out)
{
Out = 1 - In;
}
void Unity_Multiply_float4_float4(float4 A, float4 B, out float4 Out)
{
Out = A * B;
}
void Unity_ViewVectorWorld_float(out float3 Out, float3 WorldSpacePosition)
{
Out = _WorldSpaceCameraPos.xyz - GetAbsolutePositionWS(WorldSpacePosition);
if(!IsPerspectiveProjection())
{
Out = GetViewForwardDir() * dot(Out, GetViewForwardDir());
}
}
void Unity_FresnelEffect_float(float3 Normal, float3 ViewDir, float Power, out float Out)
{
Out = pow((1.0 - saturate(dot(normalize(Normal), normalize(ViewDir)))), Power);
}
void Unity_Multiply_float2_float2(float2 A, float2 B, out float2 Out)
{
Out = A * B;
}
void Unity_Add_float2(float2 A, float2 B, out float2 Out)
{
Out = A + B;
}
void Unity_TilingAndOffset_float(float2 UV, float2 Tiling, float2 Offset, out float2 Out)
{
Out = UV * Tiling + Offset;
}
void Unity_Sine_float(float In, out float Out)
{
Out = sin(In);
}
void Unity_Remap_float(float In, float2 InMinMax, float2 OutMinMax, out float Out)
{
Out = OutMinMax.x + (In - InMinMax.x) * (OutMinMax.y - OutMinMax.x) / (InMinMax.y - InMinMax.x);
}
void Unity_Subtract_float2(float2 A, float2 B, out float2 Out)
{
Out = A - B;
}
void Unity_Modulo_float(float A, float B, out float Out)
{
Out = fmod(A, B);
}
void Unity_Divide_float(float A, float B, out float Out)
{
Out = A / B;
}
void Unity_Add_float(float A, float B, out float Out)
{
Out = A + B;
}
void Unity_Fraction_float(float In, out float Out)
{
Out = frac(In);
}
void Unity_Absolute_float(float In, out float Out)
{
Out = abs(In);
}
struct Bindings_FlowMapComputeUV_float
{
};
void FlowMapComputeUV(float2 UV, float Time, UnityTexture2D FlowMap, float FlowIntensity, float Period, Bindings_FlowMapComputeUV_float IN, out float4 FlowUV, out float FlowBlend)
{
float4 FlowMapSample = SAMPLE_TEXTURE2D(FlowMap.tex, FlowMap.samplerstate, FlowMap.GetTransformedUV(UV));
float2 FlowMapSampleRG = float2(FlowMapSample.r, FlowMapSample.g);
float2 SubtractOut_Vector2;
Unity_Subtract_float2(FlowMapSampleRG, float2(0.5, 0.5), SubtractOut_Vector2);
float ModuloOut_Float;
Unity_Modulo_float(Time, Period, ModuloOut_Float);
float DivideOut_Float;
Unity_Divide_float(ModuloOut_Float, Period, DivideOut_Float);
float SubtractOut_Float;
Unity_Subtract_float(DivideOut_Float, 0.5, SubtractOut_Float);
float2 MultiplyOut_Vector2;
Unity_Multiply_float2_float2(SubtractOut_Vector2, (SubtractOut_Float.xx), MultiplyOut_Vector2);
float AddOut_Float;
Unity_Add_float(DivideOut_Float, 0.5, AddOut_Float);
float FractionOut_Float;
Unity_Fraction_float(AddOut_Float, FractionOut_Float);
float SubtractOut_Float1;
Unity_Subtract_float(FractionOut_Float, 0.5, SubtractOut_Float1);
float2 MultiplyOut_Vector21;
Unity_Multiply_float2_float2(SubtractOut_Vector2, (SubtractOut_Float1.xx), MultiplyOut_Vector21);
float4 Vector4Out_Vector4 = float4(MultiplyOut_Vector2[0], MultiplyOut_Vector2[1], MultiplyOut_Vector21[0], MultiplyOut_Vector21[1]);
float4 MultiplyOut_Vector4;
Unity_Multiply_float4_float4(Vector4Out_Vector4, (FlowIntensity.xxxx), MultiplyOut_Vector4);
float AbsoluteOut_Float;
Unity_Absolute_float(SubtractOut_Float, AbsoluteOut_Float);
float AddOut_Float1;
Unity_Add_float(AbsoluteOut_Float, AbsoluteOut_Float, AddOut_Float1);
FlowUV = MultiplyOut_Vector4;
FlowBlend = AddOut_Float1;
}
void Unity_Lerp_float4(float4 A, float4 B, float4 T, out float4 Out)
{
Out = lerp(A, B, T);
}
struct Bindings_FlowMapSampleTexture_float
{
};
void FlowMapSampleTexture(float2 UV, UnityTexture2D SampleTexture, float FlowSampleScale, float4 FlowMapUV, float FlowBlend, Bindings_FlowMapSampleTexture_float IN, out float4 Output)
{
float4 MultiplyOut_Vector4;
Unity_Multiply_float4_float4(FlowMapUV, (FlowSampleScale.xxxx), MultiplyOut_Vector4);
float2 Vector2Out_Vector2 = float2(MultiplyOut_Vector4[0], MultiplyOut_Vector4[1]);
float2 AddOut_Vector2;
Unity_Add_float2(UV, Vector2Out_Vector2, AddOut_Vector2);
float4 SampleTexture2DRGBA = SAMPLE_TEXTURE2D(SampleTexture.tex, SampleTexture.samplerstate, SampleTexture.GetTransformedUV(AddOut_Vector2) );
float2 Vector2Out_Vector21 = float2(MultiplyOut_Vector4[2], MultiplyOut_Vector4[3]);
float2 AddOut_Vector21;
Unity_Add_float2(UV, Vector2Out_Vector21, AddOut_Vector21);
float4 SampleTexture2DRGBA1 = SAMPLE_TEXTURE2D(SampleTexture.tex, SampleTexture.samplerstate, SampleTexture.GetTransformedUV(AddOut_Vector21) );
float4 LerpOut_Vector4;
Unity_Lerp_float4(SampleTexture2DRGBA, SampleTexture2DRGBA1, (FlowBlend.xxxx), LerpOut_Vector4);
Output = LerpOut_Vector4;
}
void Unity_Power_float(float A, float B, out float Out)
{
Out = pow(A, B);
}
void Unity_Clamp_float(float In, float Min, float Max, out float Out)
{
Out = clamp(In, Min, Max);
}
void Unity_SampleGradientV1_float(Gradient Gradient, float Time, out float4 Out)
{
float3 color = Gradient.colors[0].rgb;
[unroll]
for (int c = 1; c < Gradient.colorsLength; c++)
{
float colorPos = saturate((Time - Gradient.colors[c - 1].w) / (Gradient.colors[c].w - Gradient.colors[c - 1].w)) * step(c, Gradient.colorsLength - 1);
color = lerp(color, Gradient.colors[c].rgb, lerp(colorPos, step(0.01, colorPos), Gradient.type));
}
#ifdef UNITY_COLORSPACE_GAMMA
color = LinearToSRGB(color);
#endif
float alpha = Gradient.alphas[0].x;
[unroll]
for (int a = 1; a < Gradient.alphasLength; a++)
{
float alphaPos = saturate((Time - Gradient.alphas[a - 1].y) / (Gradient.alphas[a].y - Gradient.alphas[a - 1].y)) * step(a, Gradient.alphasLength - 1);
alpha = lerp(alpha, Gradient.alphas[a].x, lerp(alphaPos, step(0.01, alphaPos), Gradient.type));
}
Out = float4(color, alpha);
}
void Unity_Add_float4(float4 A, float4 B, out float4 Out)
{
Out = A + B;
}
float4 CalculateCircle(SurfaceDescriptionInputs i, float3 _HitPos, float _HitSize, float _HitSpread, float _HitSizeMax, float _DisappearSpread)
{
float3 tempdis = distance(_HitPos, i.WorldSpacePosition);
float tempupmul = clamp(((tempdis - _HitSizeMax) * (-1) )/ _DisappearSpread, 0, 1);
//float noiseout = 0;
//Unity_SimpleNoise_Deterministic_float(i.uv, _HitSpreadNoiseScale, noiseout);
//这里换成Triplanar三方向平面映射,原本使用uv采样,会导致噪点在那两个位置收缩,现在使用三面映射,就规避了这个问题。特别是对于噪点图,我认为是非常合适的采样方式。
float4 noiseout = TriPlanar(i.WorldSpacePosition, i.WorldSpaceNormal, _TriPlanarTile, _TriPlanarBlend);
noiseout = noiseout * _HitSpreadNoiseMulti;
float temp1 = noiseout + (tempdis - _HitSize);
float temp2 = 1 - clamp(temp1 / min(_HitSize, _HitSpread), 0, 1);
Gradient _Gradient = NewGradient(0, 4, 2, float4(0, 0, 0, 0),float4(0.767647, 0.767647, 0.767647, 0.1058824),float4(0.6861503, 0.6861503, 0.6861503, 0.7705958),float4(0, 0, 0, 0.9647059),float4(0, 0, 0, 0),float4(0, 0, 0, 0),float4(0, 0, 0, 0),float4(0, 0, 0, 0), float2(1, 0),float2(1, 1),float2(0, 0),float2(0, 0),float2(0, 0),float2(0, 0),float2(0, 0),float2(0, 0));
float4 gradientout = 0;
Unity_SampleGradientV1_float(_Gradient, temp2, gradientout);
return tempupmul * gradientout;
}
// Custom interpolators pre vertex
/* WARNING: $splice Could not find named fragment 'CustomInterpolatorPreVertex' */
// Graph Vertex
struct VertexDescription
{
float3 Position;
float3 Normal;
float3 Tangent;
};
VertexDescription VertexDescriptionFunction(VertexDescriptionInputs IN)
{
VertexDescription description = (VertexDescription)0;
description.Position = IN.ObjectSpacePosition;
description.Normal = IN.ObjectSpaceNormal;
description.Tangent = IN.ObjectSpaceTangent;
return description;
}
// Custom interpolators, pre surface
#ifdef FEATURES_GRAPH_VERTEX
Varyings CustomInterpolatorPassThroughFunc(inout Varyings output, VertexDescription input)
{
return output;
}
#define CUSTOMINTERPOLATOR_VARYPASSTHROUGH_FUNC
#endif
// Graph Pixel
struct SurfaceDescription
{
float3 BaseColor;
float3 NormalTS;
float3 Emission;
float Metallic;
float Smoothness;
float Occlusion;
float Alpha;
};
SurfaceDescription SurfaceDescriptionFunction(SurfaceDescriptionInputs IN)
{
SurfaceDescription surface = (SurfaceDescription)0;
float SceneDepthOut_Float;
Unity_SceneDepth_Eye_float(float4(IN.NDCPosition.xy, 0, 0), SceneDepthOut_Float);
float4 ScreenPositionOut_Vector4 = IN.ScreenPosition;
float SubtractOut_Float;
Unity_Subtract_float(SceneDepthOut_Float, ScreenPositionOut_Vector4[3], SubtractOut_Float);
float MultiplyOut_Float;
Unity_Multiply_float_float(SubtractOut_Float, _DepthMulti, MultiplyOut_Float);
float SmoothstepOut_Float;
Unity_Smoothstep_float(_DepthStepV2[0], _DepthStepV2[1], MultiplyOut_Float, SmoothstepOut_Float);
float OneMinusOut_Float;
Unity_OneMinus_float(SmoothstepOut_Float, OneMinusOut_Float);
float4 MultiplyOut_Vector4;
Unity_Multiply_float4_float4(_DepthColor, (OneMinusOut_Float.xxxx), MultiplyOut_Vector4);
float4 MultiplyOut_Vector41;
Unity_Multiply_float4_float4(MultiplyOut_Vector4, (_DepthIntensity.xxxx), MultiplyOut_Vector41);
float3 ViewVectorOut_Vector3;
Unity_ViewVectorWorld_float(ViewVectorOut_Vector3, IN.WorldSpacePosition);
float FresnelEffectOut_Float;
Unity_FresnelEffect_float(IN.WorldSpaceNormal, ViewVectorOut_Vector3, _FresnelPower, FresnelEffectOut_Float);
float4 MultiplyOut_Vector42;
Unity_Multiply_float4_float4(_EmissionColor, (FresnelEffectOut_Float.xxxx), MultiplyOut_Vector42);
float4 MultiplyOut_Vector43;
Unity_Multiply_float4_float4((_EmissionColorIntensity.xxxx), MultiplyOut_Vector42, MultiplyOut_Vector43);
float2 MultiplyOut_Vector2;
Unity_Multiply_float2_float2((IN.TimeParameters.x.xx), _FlowScroll, MultiplyOut_Vector2);
float2 AddOut_Vector2;
Unity_Add_float2((IN.uv0.xy), MultiplyOut_Vector2, AddOut_Vector2);
UnityTexture2D BuildFlowTexture = UnityBuildTexture2DStructNoScale(_FlowSampleTexture);
float2 TilingAndOffsetOut_Vector2;
Unity_TilingAndOffset_float(AddOut_Vector2, _FlowMapUVTiling, _FlowMapUVOffset, TilingAndOffsetOut_Vector2);
float MultiplyOut_Float1;
Unity_Multiply_float_float(IN.TimeParameters.x, _FlowMapUVTimeSpeed, MultiplyOut_Float1);
float SineOut_Float;
Unity_Sine_float(MultiplyOut_Float1, SineOut_Float);
float RampOut_Float;
Unity_Remap_float(SineOut_Float, float2 (-1, 1), float2 (0, 1), RampOut_Float);
UnityTexture2D PropertyOut_Texture2D = UnityBuildTexture2DStructNoScale(_FlowMap);
Bindings_FlowMapComputeUV_float FlowMapComputeUV_float;
float4 FlowMapComputeUV_FlowUV_Vector4;
float FlowMapComputeUV_FlowBlend_Float;
FlowMapComputeUV(TilingAndOffsetOut_Vector2, RampOut_Float, PropertyOut_Texture2D, _FlowMapIntensity, _FlowScrollPeriod, FlowMapComputeUV_float, FlowMapComputeUV_FlowUV_Vector4, FlowMapComputeUV_FlowBlend_Float);
Bindings_FlowMapSampleTexture_float FlowMapSampleTexture_float;
float4 FlowMapSampleTexture_Output_Vector4;
FlowMapSampleTexture(AddOut_Vector2, BuildFlowTexture, _FlowSampleScale, FlowMapComputeUV_FlowUV_Vector4, FlowMapComputeUV_FlowBlend_Float, FlowMapSampleTexture_float, FlowMapSampleTexture_Output_Vector4);
float PowerOut_Float;
Unity_Power_float(FlowMapSampleTexture_Output_Vector4[3], _FlowPower, PowerOut_Float);
float ClampOut_Float;
Unity_Clamp_float(PowerOut_Float, 0, 1, ClampOut_Float);
float SmoothstepOut_Float1;
Unity_Smoothstep_float(_FlowStepV2[0], _FlowStepV2[1], ClampOut_Float, SmoothstepOut_Float1);
float4 SampleGradientOut_Vector4;
Unity_SampleGradientV1_float(_FlowGradient, SmoothstepOut_Float1, SampleGradientOut_Vector4);
float4 MultiplyOut_Vector44;
Unity_Multiply_float4_float4((_FlowLightIntensity.xxxx), SampleGradientOut_Vector4, MultiplyOut_Vector44);
float4 MultiplyOut_Vector45;
Unity_Multiply_float4_float4(MultiplyOut_Vector43, MultiplyOut_Vector44, MultiplyOut_Vector45);
float4 MultiplyOut_Vector46;
Unity_Multiply_float4_float4(MultiplyOut_Vector41, MultiplyOut_Vector45, MultiplyOut_Vector46);
float4 AddOut_Vector4;
//计算forcefield
float4 CalculateCircleOut = 0;
for(int j = 0; j < count; j++){
CalculateCircleOut += CalculateCircle(IN, hitposarray[j], hitsizearray[j], hitspreadarray[j], hitsizemaxarray[j], disappearspreadarray[j]);
};
MultiplyOut_Vector45 += clamp(CalculateCircleOut * MultiplyOut_Vector44, 0, 1) * _EmissionColor * _EmissionColorIntensity;
Unity_Add_float4(MultiplyOut_Vector46, MultiplyOut_Vector45, AddOut_Vector4);
surface.BaseColor = IsGammaSpace() ? float3(1, 1, 1) : SRGBToLinear(float3(1, 1, 1));
surface.NormalTS = IN.TangentSpaceNormal;
surface.Emission = (AddOut_Vector4.xyz);
surface.Metallic = 0;
surface.Smoothness = 0.5;
surface.Occlusion = 1;
surface.Alpha = pow(MultiplyOut_Vector43, _AlphaPow);
return surface;
}
// --------------------------------------------------
// Build Graph Inputs
#ifdef HAVE_VFX_MODIFICATION
#define VFX_SRP_ATTRIBUTES Attributes
#define VFX_SRP_VARYINGS Varyings
#define VFX_SRP_SURFACE_INPUTS SurfaceDescriptionInputs
#endif
VertexDescriptionInputs BuildVertexDescriptionInputs(Attributes input)
{
VertexDescriptionInputs output;
ZERO_INITIALIZE(VertexDescriptionInputs, output);
output.ObjectSpaceNormal = input.normalOS;
output.ObjectSpaceTangent = input.tangentOS.xyz;
output.ObjectSpacePosition = input.positionOS;
return output;
}
SurfaceDescriptionInputs BuildSurfaceDescriptionInputs(Varyings input)
{
SurfaceDescriptionInputs output;
ZERO_INITIALIZE(SurfaceDescriptionInputs, output);
float3 unnormalizedNormalWS = input.normalWS;
const float renormFactor = 1.0 / length(unnormalizedNormalWS);
output.WorldSpaceNormal = renormFactor * input.normalWS.xyz; // we want a unit length Normal Vector node in shader graph
output.TangentSpaceNormal = float3(0.0f, 0.0f, 1.0f);
output.WorldSpacePosition = input.positionWS;
output.ScreenPosition = ComputeScreenPos(TransformWorldToHClip(input.positionWS), _ProjectionParams.x);
#if UNITY_UV_STARTS_AT_TOP
output.PixelPosition = float2(input.positionCS.x, (_ProjectionParams.x < 0) ? (_ScaledScreenParams.y - input.positionCS.y) : input.positionCS.y);
#else
output.PixelPosition = float2(input.positionCS.x, (_ProjectionParams.x > 0) ? (_ScaledScreenParams.y - input.positionCS.y) : input.positionCS.y);
#endif
output.NDCPosition = output.PixelPosition.xy / _ScaledScreenParams.xy;
output.NDCPosition.y = 1.0f - output.NDCPosition.y;
output.uv0 = input.texCoord0;
output.TimeParameters = _TimeParameters.xyz; // This is mainly for LW as HD overwrite this value
return output;
}
// --------------------------------------------------
// Main
#include "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/Varyings.hlsl"
#include "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/PBRForwardPass.hlsl"
// --------------------------------------------------
// Visual Effect Vertex Invocations
#ifdef HAVE_VFX_MODIFICATION
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/VisualEffectVertex.hlsl"
#endif
ENDHLSL
}
}
}
效果为
参数如下