173 lines
6.8 KiB
Plaintext
173 lines
6.8 KiB
Plaintext
![]() |
// Made with Amplify Shader Editor
|
||
|
// Available at the Unity Asset Store - http://u3d.as/y3X
|
||
|
Shader "Cheng/Fresnel"
|
||
|
{
|
||
|
Properties
|
||
|
{
|
||
|
_MainTex("MainTex", 2D) = "white" {}
|
||
|
_MianColor("MianColor", Color) = (1,1,1,1)
|
||
|
_Float0("Float 0", Float) = 3.88
|
||
|
[HideInInspector] _texcoord( "", 2D ) = "white" {}
|
||
|
|
||
|
}
|
||
|
|
||
|
SubShader
|
||
|
{
|
||
|
|
||
|
|
||
|
Tags { "RenderType"="Opaque" }
|
||
|
LOD 100
|
||
|
|
||
|
CGINCLUDE
|
||
|
#pragma target 3.0
|
||
|
ENDCG
|
||
|
Blend One One
|
||
|
Cull Back
|
||
|
ColorMask RGBA
|
||
|
ZWrite Off
|
||
|
ZTest LEqual
|
||
|
Offset 0 , 0
|
||
|
|
||
|
|
||
|
|
||
|
Pass
|
||
|
{
|
||
|
Name "Unlit"
|
||
|
Tags { "LightMode"="ForwardBase" }
|
||
|
CGPROGRAM
|
||
|
|
||
|
|
||
|
|
||
|
#ifndef UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX
|
||
|
//only defining to not throw compilation error over Unity 5.5
|
||
|
#define UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input)
|
||
|
#endif
|
||
|
#pragma vertex vert
|
||
|
#pragma fragment frag
|
||
|
#pragma multi_compile_instancing
|
||
|
#include "UnityCG.cginc"
|
||
|
#define ASE_NEEDS_FRAG_COLOR
|
||
|
#define ASE_NEEDS_FRAG_WORLD_POSITION
|
||
|
|
||
|
|
||
|
struct appdata
|
||
|
{
|
||
|
float4 vertex : POSITION;
|
||
|
float4 color : COLOR;
|
||
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||
|
float4 ase_texcoord : TEXCOORD0;
|
||
|
float3 ase_normal : NORMAL;
|
||
|
};
|
||
|
|
||
|
struct v2f
|
||
|
{
|
||
|
float4 vertex : SV_POSITION;
|
||
|
#ifdef ASE_NEEDS_FRAG_WORLD_POSITION
|
||
|
float3 worldPos : TEXCOORD0;
|
||
|
#endif
|
||
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||
|
UNITY_VERTEX_OUTPUT_STEREO
|
||
|
float4 ase_texcoord1 : TEXCOORD1;
|
||
|
float4 ase_color : COLOR;
|
||
|
float4 ase_texcoord2 : TEXCOORD2;
|
||
|
};
|
||
|
|
||
|
uniform float4 _MianColor;
|
||
|
uniform sampler2D _MainTex;
|
||
|
uniform float4 _MainTex_ST;
|
||
|
uniform float _Float0;
|
||
|
|
||
|
|
||
|
v2f vert ( appdata v )
|
||
|
{
|
||
|
v2f o;
|
||
|
UNITY_SETUP_INSTANCE_ID(v);
|
||
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||
|
UNITY_TRANSFER_INSTANCE_ID(v, o);
|
||
|
|
||
|
float3 ase_worldNormal = UnityObjectToWorldNormal(v.ase_normal);
|
||
|
o.ase_texcoord2.xyz = ase_worldNormal;
|
||
|
|
||
|
o.ase_texcoord1.xy = v.ase_texcoord.xy;
|
||
|
o.ase_color = v.color;
|
||
|
|
||
|
//setting value to unused interpolator channels and avoid initialization warnings
|
||
|
o.ase_texcoord1.zw = 0;
|
||
|
o.ase_texcoord2.w = 0;
|
||
|
float3 vertexValue = float3(0, 0, 0);
|
||
|
#if ASE_ABSOLUTE_VERTEX_POS
|
||
|
vertexValue = v.vertex.xyz;
|
||
|
#endif
|
||
|
vertexValue = vertexValue;
|
||
|
#if ASE_ABSOLUTE_VERTEX_POS
|
||
|
v.vertex.xyz = vertexValue;
|
||
|
#else
|
||
|
v.vertex.xyz += vertexValue;
|
||
|
#endif
|
||
|
o.vertex = UnityObjectToClipPos(v.vertex);
|
||
|
|
||
|
#ifdef ASE_NEEDS_FRAG_WORLD_POSITION
|
||
|
o.worldPos = mul(unity_ObjectToWorld, v.vertex).xyz;
|
||
|
#endif
|
||
|
return o;
|
||
|
}
|
||
|
|
||
|
fixed4 frag (v2f i ) : SV_Target
|
||
|
{
|
||
|
UNITY_SETUP_INSTANCE_ID(i);
|
||
|
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||
|
fixed4 finalColor;
|
||
|
#ifdef ASE_NEEDS_FRAG_WORLD_POSITION
|
||
|
float3 WorldPosition = i.worldPos;
|
||
|
#endif
|
||
|
float2 uv_MainTex = i.ase_texcoord1.xy * _MainTex_ST.xy + _MainTex_ST.zw;
|
||
|
float3 ase_worldViewDir = UnityWorldSpaceViewDir(WorldPosition);
|
||
|
ase_worldViewDir = normalize(ase_worldViewDir);
|
||
|
float3 ase_worldNormal = i.ase_texcoord2.xyz;
|
||
|
float fresnelNdotV20 = dot( ase_worldNormal, ase_worldViewDir );
|
||
|
float fresnelNode20 = ( 0.0 + 1.0 * pow( 1.0 - fresnelNdotV20, _Float0 ) );
|
||
|
|
||
|
|
||
|
finalColor = ( ( _MianColor * tex2D( _MainTex, uv_MainTex ) * i.ase_color * i.ase_color.a ) * fresnelNode20 );
|
||
|
return finalColor;
|
||
|
}
|
||
|
ENDCG
|
||
|
}
|
||
|
}
|
||
|
CustomEditor "ASEMaterialInspector"
|
||
|
|
||
|
|
||
|
}
|
||
|
/*ASEBEGIN
|
||
|
Version=18100
|
||
|
2567;7;2546;1364;1170.032;420.3472;1;True;True
|
||
|
Node;AmplifyShaderEditor.ColorNode;3;-495.5,-188.5;Inherit;False;Property;_MianColor;MianColor;1;0;Create;True;0;0;False;0;False;1,1,1,1;1,0.8986911,0.6367924,1;True;0;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
|
||
|
Node;AmplifyShaderEditor.SamplerNode;4;-547.5,27.5;Inherit;True;Property;_MainTex;MainTex;0;0;Create;True;0;0;False;0;False;-1;None;None;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.VertexColorNode;5;-491.5,243.5;Inherit;False;0;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
|
||
|
Node;AmplifyShaderEditor.RangedFloatNode;21;-387.0323,594.6528;Inherit;False;Property;_Float0;Float 0;3;0;Create;True;0;0;False;0;False;3.88;1.5;0;0;0;1;FLOAT;0
|
||
|
Node;AmplifyShaderEditor.CommentaryNode;18;-2063.38,1134.109;Inherit;False;1542.199;473.8066;Fenel ;7;7;11;13;15;14;9;10;;1,1,1,1;0;0
|
||
|
Node;AmplifyShaderEditor.SimpleMultiplyOpNode;6;-132.5,76.5;Inherit;False;4;4;0;COLOR;0,0,0,0;False;1;COLOR;0,0,0,0;False;2;COLOR;0,0,0,0;False;3;FLOAT;0;False;1;COLOR;0
|
||
|
Node;AmplifyShaderEditor.FresnelNode;20;-61.349,504.8966;Inherit;True;Standard;WorldNormal;ViewDir;False;False;5;0;FLOAT3;0,0,1;False;4;FLOAT3;0,0,0;False;1;FLOAT;0;False;2;FLOAT;1;False;3;FLOAT;5;False;1;FLOAT;0
|
||
|
Node;AmplifyShaderEditor.FunctionNode;14;-1097.339,1235.304;Inherit;True;SmoothStep_Smple;-1;;1;8594d1506a87e5b4fb80cb099b5fcde4;0;0;0
|
||
|
Node;AmplifyShaderEditor.RangedFloatNode;15;-1530.635,1492.915;Inherit;False;Property;_FrenelWidth;FrenelWidth;2;0;Create;True;0;0;False;0;False;0.6588235;0.131;0;1;0;1;FLOAT;0
|
||
|
Node;AmplifyShaderEditor.OneMinusNode;13;-1392.203,1228.915;Inherit;True;1;0;FLOAT;0;False;1;FLOAT;0
|
||
|
Node;AmplifyShaderEditor.ViewDirInputsCoordNode;10;-2013.381,1183.109;Inherit;False;World;False;0;4;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3
|
||
|
Node;AmplifyShaderEditor.DotProductOpNode;7;-1764.48,1217.708;Inherit;True;2;0;FLOAT3;0,0,0;False;1;FLOAT3;0,0,0;False;1;FLOAT;0
|
||
|
Node;AmplifyShaderEditor.SimpleMultiplyOpNode;24;228.9678,146.6528;Inherit;False;2;2;0;COLOR;0,0,0,0;False;1;FLOAT;0;False;1;COLOR;0
|
||
|
Node;AmplifyShaderEditor.WorldNormalVector;9;-2017.481,1339.408;Inherit;False;False;1;0;FLOAT3;0,0,1;False;4;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3
|
||
|
Node;AmplifyShaderEditor.SimpleMaxOpNode;11;-1543.572,1222.408;Inherit;False;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0
|
||
|
Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;23;545,155;Float;False;True;-1;2;ASEMaterialInspector;100;1;Cheng/Fresnel;0770190933193b94aaa3065e307002fa;True;Unlit;0;0;Unlit;2;True;4;1;False;-1;1;False;-1;0;1;False;-1;0;False;-1;True;0;False;-1;0;False;-1;True;False;True;0;False;-1;True;True;True;True;True;0;False;-1;True;False;255;False;-1;255;False;-1;255;False;-1;7;False;-1;1;False;-1;1;False;-1;1;False;-1;7;False;-1;1;False;-1;1;False;-1;1;False;-1;True;2;False;-1;True;3;False;-1;True;True;0;False;-1;0;False;-1;True;1;RenderType=Opaque=RenderType;True;2;0;False;False;False;False;False;False;False;False;False;True;1;LightMode=ForwardBase;False;0;;0;0;Standard;1;Vertex Position,InvertActionOnDeselection;1;0;1;True;False;;0
|
||
|
WireConnection;6;0;3;0
|
||
|
WireConnection;6;1;4;0
|
||
|
WireConnection;6;2;5;0
|
||
|
WireConnection;6;3;5;4
|
||
|
WireConnection;20;3;21;0
|
||
|
WireConnection;13;0;11;0
|
||
|
WireConnection;7;0;10;0
|
||
|
WireConnection;7;1;9;0
|
||
|
WireConnection;24;0;6;0
|
||
|
WireConnection;24;1;20;0
|
||
|
WireConnection;11;0;7;0
|
||
|
WireConnection;23;0;24;0
|
||
|
ASEEND*/
|
||
|
//CHKSM=8F24F261DFAE4264079181B30DE00F3277BB0671
|