142 lines
8.4 KiB
Plaintext
142 lines
8.4 KiB
Plaintext
![]() |
// Made with Amplify Shader Editor
|
||
|
// Available at the Unity Asset Store - http://u3d.as/y3X
|
||
|
Shader "Cheng/HeatWave"
|
||
|
{
|
||
|
Properties
|
||
|
{
|
||
|
_SpecColor("Specular Color",Color)=(1,1,1,1)
|
||
|
[Header(Refraction)]
|
||
|
_ChromaticAberration("Chromatic Aberration", Range( 0 , 0.3)) = 0.1
|
||
|
_NormalTexture("NormalTexture", 2D) = "white" {}
|
||
|
_U_Direction("U_Direction", Range( 0 , 1)) = 0
|
||
|
_V_Direction("V_Direction", Range( 0 , 1)) = 0
|
||
|
_Direction_Int("Direction_Int", Range( 0 , 1)) = 0
|
||
|
_MaskTexture("MaskTexture", 2D) = "white" {}
|
||
|
[HideInInspector] _texcoord( "", 2D ) = "white" {}
|
||
|
[HideInInspector] __dirty( "", Int ) = 1
|
||
|
}
|
||
|
|
||
|
SubShader
|
||
|
{
|
||
|
Tags{ "RenderType" = "Transparent" "Queue" = "Transparent+0" "IgnoreProjector" = "True" }
|
||
|
Cull Off
|
||
|
ZWrite Off
|
||
|
Blend SrcAlpha OneMinusSrcAlpha
|
||
|
|
||
|
GrabPass{ }
|
||
|
CGPROGRAM
|
||
|
#include "UnityShaderVariables.cginc"
|
||
|
#pragma target 3.0
|
||
|
#pragma multi_compile _ALPHAPREMULTIPLY_ON
|
||
|
#pragma surface surf BlinnPhong keepalpha finalcolor:RefractionF noshadow exclude_path:deferred
|
||
|
struct Input
|
||
|
{
|
||
|
float2 uv_texcoord;
|
||
|
float4 vertexColor : COLOR;
|
||
|
float4 screenPos;
|
||
|
float3 worldPos;
|
||
|
};
|
||
|
|
||
|
uniform sampler2D _NormalTexture;
|
||
|
uniform half _U_Direction;
|
||
|
uniform half _V_Direction;
|
||
|
uniform float4 _NormalTexture_ST;
|
||
|
uniform half _Direction_Int;
|
||
|
uniform sampler2D _GrabTexture;
|
||
|
uniform float _ChromaticAberration;
|
||
|
uniform sampler2D _MaskTexture;
|
||
|
uniform half4 _MaskTexture_ST;
|
||
|
|
||
|
inline float4 Refraction( Input i, SurfaceOutput o, float indexOfRefraction, float chomaticAberration ) {
|
||
|
float3 worldNormal = o.Normal;
|
||
|
float4 screenPos = i.screenPos;
|
||
|
#if UNITY_UV_STARTS_AT_TOP
|
||
|
float scale = -1.0;
|
||
|
#else
|
||
|
float scale = 1.0;
|
||
|
#endif
|
||
|
float halfPosW = screenPos.w * 0.5;
|
||
|
screenPos.y = ( screenPos.y - halfPosW ) * _ProjectionParams.x * scale + halfPosW;
|
||
|
#if SHADER_API_D3D9 || SHADER_API_D3D11
|
||
|
screenPos.w += 0.00000000001;
|
||
|
#endif
|
||
|
float2 projScreenPos = ( screenPos / screenPos.w ).xy;
|
||
|
float3 worldViewDir = normalize( UnityWorldSpaceViewDir( i.worldPos ) );
|
||
|
float3 refractionOffset = ( indexOfRefraction - 1.0 ) * mul( UNITY_MATRIX_V, float4( worldNormal, 0.0 ) ) * ( 1.0 - dot( worldNormal, worldViewDir ) );
|
||
|
float2 cameraRefraction = float2( refractionOffset.x, refractionOffset.y );
|
||
|
float4 redAlpha = tex2D( _GrabTexture, ( projScreenPos + cameraRefraction ) );
|
||
|
float green = tex2D( _GrabTexture, ( projScreenPos + ( cameraRefraction * ( 1.0 - chomaticAberration ) ) ) ).g;
|
||
|
float blue = tex2D( _GrabTexture, ( projScreenPos + ( cameraRefraction * ( 1.0 + chomaticAberration ) ) ) ).b;
|
||
|
return float4( redAlpha.r, green, blue, redAlpha.a );
|
||
|
}
|
||
|
|
||
|
void RefractionF( Input i, SurfaceOutput o, inout half4 color )
|
||
|
{
|
||
|
#ifdef UNITY_PASS_FORWARDBASE
|
||
|
half temp_output_17_0 = ( i.vertexColor.a * _Direction_Int );
|
||
|
float2 uv_MaskTexture = i.uv_texcoord * _MaskTexture_ST.xy + _MaskTexture_ST.zw;
|
||
|
half lerpResult3 = lerp( 1.0 , 1.4 , ( temp_output_17_0 * tex2D( _MaskTexture, uv_MaskTexture ).r * i.vertexColor ).r);
|
||
|
color.rgb = color.rgb + Refraction( i, o, lerpResult3, _ChromaticAberration ) * ( 1 - color.a );
|
||
|
color.a = 1;
|
||
|
#endif
|
||
|
}
|
||
|
|
||
|
void surf( Input i , inout SurfaceOutput o )
|
||
|
{
|
||
|
o.Normal = float3(0,0,1);
|
||
|
half2 appendResult12 = (half2(_U_Direction , _V_Direction));
|
||
|
float2 uv0_NormalTexture = i.uv_texcoord * _NormalTexture_ST.xy + _NormalTexture_ST.zw;
|
||
|
half2 panner9 = ( 1.0 * _Time.y * appendResult12 + uv0_NormalTexture);
|
||
|
half temp_output_17_0 = ( i.vertexColor.a * _Direction_Int );
|
||
|
half4 lerpResult16 = lerp( half4( half3(0,0,1) , 0.0 ) , tex2D( _NormalTexture, panner9 ) , temp_output_17_0);
|
||
|
o.Normal = lerpResult16.rgb;
|
||
|
o.Alpha = 0.0;
|
||
|
o.Normal = o.Normal + 0.00001 * i.screenPos * i.worldPos;
|
||
|
}
|
||
|
|
||
|
ENDCG
|
||
|
}
|
||
|
CustomEditor "ASEMaterialInspector"
|
||
|
}
|
||
|
/*ASEBEGIN
|
||
|
Version=18100
|
||
|
1482;229;2115;1081;1333.457;547.0842;1;True;False
|
||
|
Node;AmplifyShaderEditor.RangedFloatNode;10;-1199.582,-283.5934;Inherit;False;Property;_U_Direction;U_Direction;5;0;Create;True;0;0;False;0;False;0;0.811;0;1;0;1;FLOAT;0
|
||
|
Node;AmplifyShaderEditor.RangedFloatNode;11;-1195.582,-174.5934;Inherit;False;Property;_V_Direction;V_Direction;6;0;Create;True;0;0;False;0;False;0;0.659;0;1;0;1;FLOAT;0
|
||
|
Node;AmplifyShaderEditor.RangedFloatNode;19;-706.627,-51.8179;Inherit;False;Property;_Direction_Int;Direction_Int;7;0;Create;True;0;0;False;0;False;0;0.07;0;1;0;1;FLOAT;0
|
||
|
Node;AmplifyShaderEditor.VertexColorNode;18;-680.0374,60.19611;Inherit;False;0;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
|
||
|
Node;AmplifyShaderEditor.DynamicAppendNode;12;-892.5816,-226.5934;Inherit;False;FLOAT2;4;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;0;False;3;FLOAT;0;False;1;FLOAT2;0
|
||
|
Node;AmplifyShaderEditor.TextureCoordinatesNode;1;-915.5816,-381.5934;Inherit;False;0;2;2;3;2;SAMPLER2D;;False;0;FLOAT2;1,1;False;1;FLOAT2;0,0;False;5;FLOAT2;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
|
||
|
Node;AmplifyShaderEditor.PannerNode;9;-643.5816,-271.5934;Inherit;False;3;0;FLOAT2;0,0;False;2;FLOAT2;0,0;False;1;FLOAT;1;False;1;FLOAT2;0
|
||
|
Node;AmplifyShaderEditor.SimpleMultiplyOpNode;17;-373.5,-26.5;Inherit;False;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0
|
||
|
Node;AmplifyShaderEditor.SamplerNode;7;-566.3458,293.2245;Inherit;True;Property;_MaskTexture;MaskTexture;8;0;Create;True;0;0;False;0;False;-1;None;c78003f10d1be2343970b0e5e4134eab;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
|
||
|
Node;AmplifyShaderEditor.SamplerNode;2;-433.5,-304.5;Inherit;True;Property;_NormalTexture;NormalTexture;4;0;Create;True;0;0;False;0;False;-1;None;7415d90b369f8754ebf4cacea2d30acc;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
|
||
|
Node;AmplifyShaderEditor.Vector3Node;22;-59.1779,-429.0829;Inherit;False;Constant;_Vector0;Vector 0;8;0;Create;True;0;0;False;0;False;0,0,1;0,0,0;0;4;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3
|
||
|
Node;AmplifyShaderEditor.RangedFloatNode;5;-92.3459,-0.7754974;Inherit;False;Constant;_Float1;Float 1;2;0;Create;True;0;0;False;0;False;1;0;0;0;0;1;FLOAT;0
|
||
|
Node;AmplifyShaderEditor.RangedFloatNode;6;-102.3459,64.2244;Inherit;False;Constant;_Float2;Float 2;2;0;Create;True;0;0;False;0;False;1.4;0;0;0;0;1;FLOAT;0
|
||
|
Node;AmplifyShaderEditor.SimpleMultiplyOpNode;8;-18.3459,251.2245;Inherit;False;3;3;0;FLOAT;0;False;1;FLOAT;0;False;2;COLOR;0,0,0,0;False;1;COLOR;0
|
||
|
Node;AmplifyShaderEditor.LerpOp;16;177.5,-306.5;Inherit;False;3;0;COLOR;0,0,0,0;False;1;COLOR;0,0,0,0;False;2;FLOAT;0;False;1;COLOR;0
|
||
|
Node;AmplifyShaderEditor.RangedFloatNode;4;222.6541,238.2243;Inherit;False;Constant;_Float0;Float 0;2;0;Create;True;0;0;False;0;False;0;0;0;0;0;1;FLOAT;0
|
||
|
Node;AmplifyShaderEditor.LerpOp;3;106.6541,-2.775597;Inherit;False;3;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;0;False;1;FLOAT;0
|
||
|
Node;AmplifyShaderEditor.StandardSurfaceOutputNode;0;475.548,-322.5195;Half;False;True;-1;2;ASEMaterialInspector;0;0;BlinnPhong;Cheng/HeatWave;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;False;False;False;False;False;False;Off;2;False;-1;0;False;-1;False;0;False;-1;0;False;-1;False;0;Custom;0.5;True;False;0;False;Transparent;;Transparent;ForwardOnly;14;all;True;True;True;True;0;False;-1;False;0;False;-1;255;False;-1;255;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;False;2;15;10;25;False;0.5;False;2;5;False;-1;10;False;-1;0;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;0;0,0,0,0;VertexOffset;True;False;Cylindrical;False;Relative;0;;0;-1;2;-1;0;False;0;0;False;-1;1;0;False;-1;0;0;0;False;0.1;False;-1;0;False;-1;15;0;FLOAT3;0,0,0;False;1;FLOAT3;0,0,0;False;2;FLOAT3;0,0,0;False;3;FLOAT;0;False;4;FLOAT;0;False;6;FLOAT3;0,0,0;False;7;FLOAT3;0,0,0;False;8;FLOAT;0;False;9;FLOAT;0;False;10;FLOAT;0;False;13;FLOAT3;0,0,0;False;11;FLOAT3;0,0,0;False;12;FLOAT3;0,0,0;False;14;FLOAT4;0,0,0,0;False;15;FLOAT3;0,0,0;False;0
|
||
|
WireConnection;12;0;10;0
|
||
|
WireConnection;12;1;11;0
|
||
|
WireConnection;9;0;1;0
|
||
|
WireConnection;9;2;12;0
|
||
|
WireConnection;17;0;18;4
|
||
|
WireConnection;17;1;19;0
|
||
|
WireConnection;2;1;9;0
|
||
|
WireConnection;8;0;17;0
|
||
|
WireConnection;8;1;7;1
|
||
|
WireConnection;8;2;18;0
|
||
|
WireConnection;16;0;22;0
|
||
|
WireConnection;16;1;2;0
|
||
|
WireConnection;16;2;17;0
|
||
|
WireConnection;3;0;5;0
|
||
|
WireConnection;3;1;6;0
|
||
|
WireConnection;3;2;8;0
|
||
|
WireConnection;0;1;16;0
|
||
|
WireConnection;0;8;3;0
|
||
|
WireConnection;0;9;4;0
|
||
|
ASEEND*/
|
||
|
//CHKSM=59B640688523D51D568F04B4AD230CB41A69E94B
|