Earth.shader 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // Upgrade NOTE: upgraded instancing buffer 'Props' to new syntax.
  2. Shader "ZED/Planetarium/FresnelShader" {
  3. Properties{
  4. _Color("Color", Color) = (1,1,1,1)
  5. _MainTex("Albedo (RGB)", 2D) = "white" {}
  6. _Glossiness("Smoothness", Range(0,1)) = 0.5
  7. _Metallic("Metallic", Range(0,1)) = 0.0
  8. _FresnelFactor("Fresnel Factor", Range(0,1)) = 0.04
  9. _FresnelExponent("Fresnel Exponent", Range(0,10)) = 5
  10. }
  11. SubShader{
  12. Tags{ "RenderType" = "Opaque""LightMode"="Deferred" }
  13. Stencil{
  14. Ref 148
  15. Comp Always
  16. Pass replace
  17. }
  18. CGPROGRAM
  19. // Physically based Standard lighting model, and enable shadows on all light types
  20. #pragma surface surf SimpleSpecular
  21. // Use shader model 3.0 target, to get nicer looking lighting
  22. #pragma target 3.0
  23. sampler2D _MainTex;
  24. struct Input {
  25. float2 uv_MainTex;
  26. };
  27. half _Glossiness;
  28. half _Metallic;
  29. half _FresnelFactor;
  30. half _FresnelExponent;
  31. fixed4 _Color;
  32. half4 LightingSimpleSpecular(SurfaceOutput s, half3 lightDir, half3 viewDir, half atten) {
  33. half NdotL = dot(s.Normal, lightDir);
  34. half4 c;
  35. half fresnel = _FresnelFactor + (1 - _FresnelFactor)*pow(1 - dot(s.Normal, viewDir), _FresnelExponent);
  36. half4 fresnelColor = 3.0*half4(0.382, 0.664, 1.0, 1.0)*fresnel;
  37. c.rgb = s.Albedo * _LightColor0.rgb * (NdotL * atten) + fresnelColor;
  38. c.a = s.Alpha;
  39. return c;
  40. }
  41. void surf(Input IN, inout SurfaceOutput o) {
  42. // Albedo comes from a texture tinted by color
  43. fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
  44. o.Albedo = c.rgb;
  45. o.Alpha = c.a;
  46. }
  47. ENDCG
  48. }
  49. FallBack "Diffuse"
  50. }