Transparent.shader 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
  2. Shader "Santa/Transparent" {
  3. Properties {
  4. _Color ("Tint", COLOR) = (1,1,1,1)
  5. _Light ("Light", Range (0.01,3)) = 1.5
  6. _Contrast ("Contrast", Range (-5.0,5.0)) = 0.5
  7. _Cutoff ("Alpha cutoff", Range (0,1)) = 0.5
  8. [NoScaleOffset]
  9. _MainTex ("Base (RGBA)", 2D) = "white" {}
  10. [NoScaleOffset]
  11. _Lightmap ("Lightmap x2 (RGB)", 2D) = "white" {}
  12. }
  13. SubShader { Tags { "Queue" = "Transparent" }
  14. Pass { Blend SrcAlpha OneMinusSrcAlpha
  15. Lighting Off
  16. //Fog { Mode Linear }
  17. CGPROGRAM
  18. #pragma target 2.0
  19. #pragma vertex vert
  20. #pragma fragment frag
  21. #pragma multi_compile_fog
  22. #include "UnityCG.cginc"
  23. #pragma exclude_renderers xbox360 ps3 flash
  24. uniform float4 _Color;
  25. uniform Float _Light;
  26. uniform Float _Contrast;
  27. uniform Float _Cutoff;
  28. uniform sampler2D _MainTex;
  29. uniform sampler2D _Lightmap;
  30. struct appdata
  31. {
  32. float4 vertex : POSITION;
  33. fixed4 color : COLOR;
  34. half4 uv0 : TEXCOORD0;
  35. half4 uv1 : TEXCOORD1;
  36. };
  37. struct v2f
  38. {
  39. float4 pos : SV_POSITION;
  40. fixed4 color : COLOR;
  41. half4 uv0 : TEXCOORD0;
  42. half4 uv1 : TEXCOORD1;
  43. UNITY_FOG_COORDS(n)
  44. };
  45. v2f vert (appdata v)
  46. {
  47. v2f o;
  48. o.pos = UnityObjectToClipPos( v.vertex );
  49. o.color = v.color;
  50. o.uv0 = v.uv0;
  51. o.uv1 = v.uv1;
  52. UNITY_TRANSFER_FOG(o, o.pos);
  53. return o;
  54. }
  55. fixed4 frag (v2f i) : SV_Target
  56. {
  57. fixed4 Tex = tex2D(_MainTex, i.uv0);
  58. fixed4 LM = tex2D(_Lightmap, i.uv1);
  59. fixed3 FinalColor = Tex.rgb * LM.rgb * _Light * i.color.rgb * _Color;
  60. fixed4 c = fixed4(FinalColor, Tex.a);
  61. _Contrast += 1;
  62. c = c - _Contrast * (c - 1.0f) * c *(c - 0.5f);
  63. if(c.a < _Cutoff) discard;
  64. UNITY_APPLY_FOG(i.fogCoord, c);
  65. return c;
  66. }
  67. ENDCG
  68. }
  69. }
  70. FallBack "Diffuse"
  71. }