Guest User

2d Toolkit Palettized Sprite Shader

a guest
Jan 23rd, 2015
760
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. Shader "Sprite/Palettized"
  2. {
  3. Properties
  4. {
  5. _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
  6. _GColor ("Color (green channel)", Color) = (0,1,0,1)
  7. _BColor ("Color (blue channel)", Color) = (0,0,1,1)
  8. }
  9.  
  10. SubShader
  11. {
  12. Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
  13. ZWrite Off Lighting Off Cull Off Fog { Mode Off } Blend SrcAlpha OneMinusSrcAlpha
  14. LOD 110
  15.  
  16. Pass
  17. {
  18. CGPROGRAM
  19. #pragma vertex vert_vct
  20. #pragma fragment frag_mult
  21. #pragma fragmentoption ARB_precision_hint_fastest
  22. #include "UnityCG.cginc"
  23.  
  24. sampler2D _MainTex;
  25. float4 _MainTex_ST;
  26. float4 _GColor;
  27. float4 _BColor;
  28.  
  29. struct vin_vct
  30. {
  31. float4 vertex : POSITION;
  32. float4 color : COLOR;
  33. float2 texcoord : TEXCOORD0;
  34. };
  35.  
  36. struct v2f_vct
  37. {
  38. float4 vertex : POSITION;
  39. fixed4 color : COLOR;
  40. float2 texcoord : TEXCOORD0;
  41. };
  42.  
  43. v2f_vct vert_vct(vin_vct v)
  44. {
  45. v2f_vct o;
  46. o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
  47. o.color = v.color;
  48. o.texcoord = v.texcoord;
  49. return o;
  50. }
  51.  
  52. half4 frag_mult(v2f_vct i) : COLOR
  53. {
  54. half4 profile = tex2D(_MainTex, i.texcoord);
  55. half4 col = i.color * profile.r;
  56. col += _GColor * profile.g;
  57. col += _BColor * profile.b;
  58. col.a = i.color.a * profile.a;
  59. return col;
  60. }
  61.  
  62. ENDCG
  63. }
  64. }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment