Diffuse.shader 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
  2. Shader "Santa/Diffuse" {
  3. Properties {
  4. _Color ("Tint", COLOR) = (1,1,1,1)
  5. _Light ("Light", Range (0.01,3)) = 1
  6. _Contrast ("Contrast", Range (-5.0,5.0)) = 0.5
  7. _MainTex ("Base (RGB)", 2D) = "white" {}
  8. _Lightmap ("Lightmap x2 (RGB)", 2D) = "white" {}
  9. }
  10. SubShader { Tags { "Queue" = "Transparent" }
  11. Pass { //Blend SrcAlpha OneMinusSrcAlpha
  12. //Fog { Mode Off }
  13. CGPROGRAM
  14. #pragma vertex vert
  15. #pragma fragment frag
  16. #pragma multi_compile_fog
  17. #include "UnityCG.cginc"
  18. uniform float4 _Color;
  19. uniform float _Light;
  20. uniform float _Contrast;
  21. uniform sampler2D _MainTex;
  22. uniform sampler2D _Lightmap;
  23. // vertex input: position, color
  24. struct appdata
  25. {
  26. float4 vertex : POSITION;
  27. fixed4 color : COLOR;
  28. float4 uv0 : TEXCOORD0;
  29. float4 uv1 : TEXCOORD1;
  30. };
  31. struct v2f
  32. {
  33. float4 pos : SV_POSITION;
  34. fixed4 color : COLOR;
  35. float4 uv0 : TEXCOORD0;
  36. float4 uv1 : TEXCOORD1;
  37. UNITY_FOG_COORDS(n)
  38. };
  39. v2f vert (appdata v)
  40. {
  41. v2f o;
  42. o.pos = UnityObjectToClipPos( v.vertex );
  43. o.color = v.color;
  44. o.uv0 = v.uv0;
  45. o.uv1 = v.uv1;
  46. UNITY_TRANSFER_FOG(o, o.pos);
  47. return o;
  48. }
  49. fixed4 frag (v2f i) : SV_Target
  50. {
  51. fixed4 c = tex2D(_MainTex, i.uv0) * tex2D(_Lightmap, i.uv1) * _Light * i.color * _Color;
  52. _Contrast += 1;
  53. c = c - _Contrast * (c - 1.0f) * c *(c - 0.5f);
  54. UNITY_APPLY_FOG(i.fogCoord, c);
  55. return c;
  56. }
  57. ENDCG
  58. }
  59. }
  60. }