EnviroTransparentSurface.shader 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. Shader "Enviro 3/Sample/TransparentSurface"
  2. {
  3. Properties
  4. {
  5. _Color ("Color", Color) = (1,1,1,1)
  6. _MainTex ("Albedo (RGB)", 2D) = "white" {}
  7. _Glossiness ("Smoothness", Range(0,1)) = 0.5
  8. _Metallic ("Metallic", Range(0,1)) = 0.0
  9. }
  10. SubShader
  11. {
  12. Tags {"Queue" = "Transparent" "RenderType"="Transparent" }
  13. LOD 200
  14. CGPROGRAM
  15. #include "Assets/Enviro 3 - Sky and Weather/Resources/Shader/Includes/FogInclude.cginc"
  16. #pragma surface surf Standard fullforwardshadows alpha finalcolor:ApplyFog
  17. #pragma target 3.0
  18. sampler2D _MainTex;
  19. sampler2D _CameraDepthTexture;
  20. struct Input {
  21. float2 uv_MainTex;
  22. float4 screenPos;
  23. float3 worldPos;
  24. };
  25. void ApplyFog(Input IN, SurfaceOutputStandard o, inout fixed4 color)
  26. {
  27. //Get ScreenPosition
  28. float3 uvscreen = IN.screenPos.xyz/IN.screenPos.w;
  29. // Calculate Linear Depth
  30. half linear01Depth = Linear01Depth(uvscreen.z);
  31. //get World Position
  32. float3 wPos = IN.worldPos.xyz;
  33. // Calculate Fog and apply volume lighting tex
  34. float3 fogClr = ApplyFogAndVolumetricLights(color.rgb,uvscreen.xy, wPos, linear01Depth);
  35. #if _ALPHAPREMULTIPLY_ON
  36. fogClr.rgb *= o.Alpha;
  37. #endif
  38. #ifndef UNITY_PASS_FORWARDADD
  39. color.rgb = fogClr.rgb;
  40. #endif
  41. }
  42. half _Glossiness;
  43. half _Metallic;
  44. fixed4 _Color;
  45. void surf (Input IN, inout SurfaceOutputStandard o)
  46. {
  47. fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
  48. o.Albedo = c.rgb;
  49. o.Metallic = _Metallic;
  50. o.Smoothness = _Glossiness;
  51. o.Alpha = c.a;
  52. }
  53. ENDCG
  54. }
  55. FallBack "Standard"
  56. }