IceShaderFastSimleBackFace.shader 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. Shader "Effects/Ice/IceBack" {
  2. Properties {
  3. _Color ("Main Color", Color) = (1,1,1,1)
  4. _SpecColor ("Specular Color", Color) = (0.5,0.5,0.5,1)
  5. _Shininess ("Shininess", Range (0.01, 1)) = 0.078125
  6. _ReflectColor ("Reflection Color", Color) = (1,1,1,0.5)
  7. _ReflectionStrength ("ReflectionStrength", Range (1, 20)) = 1
  8. _MainTex ("Base (RGB) Emission Tex (A)", 2D) = "white" {}
  9. _Opacity ("Material opacity", Range (-1, 1)) = 0.5
  10. _Cube ("Reflection Cubemap", Cube) = "" { }
  11. _BumpMap ("Normalmap", 2D) = "bump" {}
  12. _FPOW("FPOW Fresnel", Float) = 5.0
  13. _R0("R0 Fresnel", Float) = 0.05
  14. _Cutoff ("Cutoff", Range (0, 1)) = 0.5
  15. _LightStr ("Light strength", Range (0, 1)) = 1
  16. }
  17. SubShader {
  18. Tags { "Queue"="Transparent" "RenderType"="Transperent" }
  19. LOD 200
  20. CGPROGRAM
  21. #pragma surface surf Lambert alpha
  22. #pragma target 3.0
  23. #pragma glsl
  24. sampler2D _MainTex;
  25. sampler2D _BumpMap;
  26. samplerCUBE _Cube;
  27. float4 _Color;
  28. float4 _ReflectColor;
  29. float _ReflectionStrength;
  30. float _Shininess;
  31. float _FPOW;
  32. float _R0;
  33. float _Opacity;
  34. float _Cutoff;
  35. float _LightStr;
  36. struct Input {
  37. float2 uv_MainTex;
  38. float2 uv_BumpMap;
  39. float3 viewDir;
  40. float3 worldRefl;
  41. INTERNAL_DATA
  42. };
  43. void surf (Input IN, inout SurfaceOutput o) {
  44. half4 tex = tex2D(_MainTex, IN.uv_MainTex);
  45. half4 c = tex * _Color;
  46. o.Albedo = _Color;
  47. o.Gloss = tex.a;
  48. o.Specular = _Shininess;
  49. o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
  50. float3 worldRefl = WorldReflectionVector (IN, o.Normal);
  51. half4 reflcol = texCUBE (_Cube, worldRefl);
  52. reflcol *= tex.a;
  53. half fresnel = saturate(1.0 - dot(o.Normal, normalize(IN.viewDir)));
  54. fresnel = pow(fresnel, _FPOW);
  55. fresnel = _R0 + (1.0 - _R0) * fresnel;
  56. reflcol = lerp(c, reflcol, fresnel);
  57. o.Emission = reflcol.rgb * _ReflectColor.rgb * _ReflectionStrength * _LightStr;
  58. o.Alpha = _Cutoff > tex.a ? tex.a+_Opacity : 0;
  59. }
  60. ENDCG
  61. }
  62. FallBack "Reflective/Bumped Diffuse"
  63. }