Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. Shader "CustomColorPattern" {
  2. Properties{
  3. _Color1("Main Color 1", Color) = (1,1,1,1)
  4. _Color2("Main Color 2", Color) = (1,1,1,1)
  5. _MainTex("Mask Texture", 2D) = "white" {}
  6. }
  7.  
  8. SubShader{
  9. Tags{ "RenderType" = "Diffuse" }
  10. LOD 100
  11.  
  12. Pass{
  13. CGPROGRAM
  14. #pragma vertex vert
  15. #pragma fragment frag
  16. #pragma multi_compile_fog
  17.  
  18. #include "UnityCG.cginc"
  19.  
  20. struct appdata_t {
  21. float4 vertex : POSITION;
  22. float4 color : COLOR;
  23. float2 texcoord : TEXCOORD0;
  24. };
  25.  
  26. struct v2f {
  27. float4 vertex : SV_POSITION;
  28. fixed4 color : COLOR;
  29. half2 texcoord : TEXCOORD0;
  30. UNITY_FOG_COORDS(0)
  31. };
  32.  
  33. fixed4 _Color1;
  34. fixed4 _Color2;
  35.  
  36. v2f vert(appdata_t v)
  37. {
  38. v2f o;
  39. o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
  40. o.texcoord = v.texcoord;
  41. o.color = v.color;
  42. UNITY_TRANSFER_FOG(o,o.vertex);
  43. return o;
  44. }
  45.  
  46. sampler _MainTex;
  47.  
  48. fixed4 frag(v2f i) : COLOR
  49. {
  50. fixed4 c = tex2D(_MainTex, i.texcoord);
  51. if (c.r == 0 && c.g == 0 && c.b == 0)
  52. {
  53. c = _Color1;
  54. }
  55. else
  56. {
  57. c = _Color2;
  58. }
  59. UNITY_APPLY_FOG(i.fogCoord, c);
  60. UNITY_OPAQUE_ALPHA(c.a);
  61. return c;
  62. }
  63. ENDCG
  64. }
  65. }
  66.  
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement