LYDS_Fresnel.shader 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. // Shader created with Shader Forge v1.37
  2. // Shader Forge (c) Neat Corporation / Joachim Holmer - http://www.acegikmo.com/shaderforge/
  3. // Note: Manually altering this data may prevent you from opening it in Shader Forge
  4. /*SF_DATA;ver:1.37;sub:START;pass:START;ps:flbk:,iptp:0,cusa:False,bamd:0,cgin:,lico:1,lgpr:1,limd:0,spmd:1,trmd:0,grmd:0,uamb:True,mssp:True,bkdf:False,hqlp:False,rprd:False,enco:False,rmgx:True,imps:True,rpth:0,vtps:0,hqsc:True,nrmq:1,nrsp:0,vomd:0,spxs:False,tesm:0,olmd:1,culm:1,bsrc:3,bdst:7,dpts:2,wrdp:False,dith:0,atcv:False,rfrpo:True,rfrpn:Refraction,coma:15,ufog:True,aust:True,igpj:True,qofs:0,qpre:3,rntp:2,fgom:False,fgoc:False,fgod:False,fgor:False,fgmd:0,fgcr:0.5,fgcg:0.5,fgcb:0.5,fgca:1,fgde:0.01,fgrn:0,fgrf:300,stcl:False,stva:128,stmr:255,stmw:255,stcp:6,stps:0,stfa:0,stfz:0,ofsf:0,ofsu:0,f2p0:False,fnsp:False,fnfb:False,fsmp:False;n:type:ShaderForge.SFN_Final,id:4013,x:33666,y:32796,varname:node_4013,prsc:2|emission-8407-OUT,alpha-5534-OUT;n:type:ShaderForge.SFN_Fresnel,id:2109,x:32487,y:32854,varname:node_2109,prsc:2|EXP-4005-OUT;n:type:ShaderForge.SFN_Slider,id:4005,x:32135,y:32870,ptovrint:False,ptlb:F_G,ptin:_F_G,varname:node_4005,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,min:0,cur:5,max:5;n:type:ShaderForge.SFN_Color,id:4225,x:32250,y:33135,ptovrint:False,ptlb:F_C,ptin:_F_C,varname:node_4225,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,c1:0.5,c2:0.5,c3:0.5,c4:1;n:type:ShaderForge.SFN_Multiply,id:3052,x:32704,y:32884,varname:node_3052,prsc:2|A-2109-OUT,B-4225-RGB;n:type:ShaderForge.SFN_Slider,id:5726,x:32624,y:33247,ptovrint:False,ptlb:F_S,ptin:_F_S,varname:node_5726,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,min:0,cur:1.678263,max:5;n:type:ShaderForge.SFN_Multiply,id:8407,x:32988,y:32858,varname:node_8407,prsc:2|A-3052-OUT,B-5726-OUT;n:type:ShaderForge.SFN_Slider,id:4513,x:33045,y:33072,ptovrint:False,ptlb:node_4513,ptin:_node_4513,varname:node_4513,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,min:0,cur:1,max:1;n:type:ShaderForge.SFN_Tex2d,id:2877,x:33084,y:32458,ptovrint:False,ptlb:node_2877,ptin:_node_2877,varname:node_2877,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,ntxv:0,isnm:False;n:type:ShaderForge.SFN_Multiply,id:5534,x:33405,y:32925,varname:node_5534,prsc:2|A-2877-A,B-4513-OUT;proporder:4005-4225-5726-4513-2877;pass:END;sub:END;*/
  5. Shader "LuoYeDaShi/Fresnel01" {
  6. Properties {
  7. _F_G ("F_G", Range(0, 5)) = 5
  8. _F_C ("F_C", Color) = (0.5,0.5,0.5,1)
  9. _F_S ("F_S", Range(0, 5)) = 1.678263
  10. _node_4513 ("node_4513", Range(0, 1)) = 1
  11. _node_2877 ("node_2877", 2D) = "white" {}
  12. [HideInInspector]_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
  13. }
  14. SubShader {
  15. Tags {
  16. "IgnoreProjector"="True"
  17. "Queue"="Transparent"
  18. "RenderType"="Transparent"
  19. }
  20. Pass {
  21. Name "FORWARD"
  22. Tags {
  23. "LightMode"="ForwardBase"
  24. }
  25. Blend SrcAlpha OneMinusSrcAlpha
  26. Cull Front
  27. ZWrite Off
  28. CGPROGRAM
  29. #pragma vertex vert
  30. #pragma fragment frag
  31. #define UNITY_PASS_FORWARDBASE
  32. #include "UnityCG.cginc"
  33. #pragma multi_compile_fwdbase
  34. #pragma multi_compile_fog
  35. #pragma only_renderers d3d9 d3d11 glcore gles gles3 metal d3d11_9x xboxone n3ds wiiu
  36. #pragma target 3.0
  37. uniform float _F_G;
  38. uniform float4 _F_C;
  39. uniform float _F_S;
  40. uniform float _node_4513;
  41. uniform sampler2D _node_2877; uniform float4 _node_2877_ST;
  42. struct VertexInput {
  43. float4 vertex : POSITION;
  44. float3 normal : NORMAL;
  45. float2 texcoord0 : TEXCOORD0;
  46. };
  47. struct VertexOutput {
  48. float4 pos : SV_POSITION;
  49. float2 uv0 : TEXCOORD0;
  50. float4 posWorld : TEXCOORD1;
  51. float3 normalDir : TEXCOORD2;
  52. UNITY_FOG_COORDS(3)
  53. };
  54. VertexOutput vert (VertexInput v) {
  55. VertexOutput o = (VertexOutput)0;
  56. o.uv0 = v.texcoord0;
  57. o.normalDir = UnityObjectToWorldNormal(-v.normal);
  58. o.posWorld = mul(unity_ObjectToWorld, v.vertex);
  59. o.pos = UnityObjectToClipPos( v.vertex );
  60. UNITY_TRANSFER_FOG(o,o.pos);
  61. return o;
  62. }
  63. float4 frag(VertexOutput i) : COLOR {
  64. i.normalDir = normalize(i.normalDir);
  65. float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
  66. float3 normalDirection = i.normalDir;
  67. ////// Lighting:
  68. ////// Emissive:
  69. float3 node_8407 = ((pow(1.0-max(0,dot(normalDirection, viewDirection)),_F_G)*_F_C.rgb)*_F_S);
  70. float3 emissive = node_8407;
  71. float3 finalColor = emissive;
  72. float4 _node_2877_var = tex2D(_node_2877,TRANSFORM_TEX(i.uv0, _node_2877));
  73. fixed4 finalRGBA = fixed4(finalColor,(_node_2877_var.a*_node_4513));
  74. UNITY_APPLY_FOG(i.fogCoord, finalRGBA);
  75. return finalRGBA;
  76. }
  77. ENDCG
  78. }
  79. Pass {
  80. Name "ShadowCaster"
  81. Tags {
  82. "LightMode"="ShadowCaster"
  83. }
  84. Offset 1, 1
  85. Cull Front
  86. CGPROGRAM
  87. #pragma vertex vert
  88. #pragma fragment frag
  89. #define UNITY_PASS_SHADOWCASTER
  90. #include "UnityCG.cginc"
  91. #include "Lighting.cginc"
  92. #pragma fragmentoption ARB_precision_hint_fastest
  93. #pragma multi_compile_shadowcaster
  94. #pragma multi_compile_fog
  95. #pragma only_renderers d3d9 d3d11 glcore gles gles3 metal d3d11_9x xboxone n3ds wiiu
  96. #pragma target 3.0
  97. struct VertexInput {
  98. float4 vertex : POSITION;
  99. };
  100. struct VertexOutput {
  101. V2F_SHADOW_CASTER;
  102. };
  103. VertexOutput vert (VertexInput v) {
  104. VertexOutput o = (VertexOutput)0;
  105. o.pos = UnityObjectToClipPos( v.vertex );
  106. TRANSFER_SHADOW_CASTER(o)
  107. return o;
  108. }
  109. float4 frag(VertexOutput i) : COLOR {
  110. SHADOW_CASTER_FRAGMENT(i)
  111. }
  112. ENDCG
  113. }
  114. }
  115. FallBack "Diffuse"
  116. CustomEditor "ShaderForgeMaterialInspector"
  117. }