vB_Diffuse_unLit_3tex.shader 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. Shader "vertexPainter/vB_Diffuse_unLit_3tex" {
  2. Properties {
  3. _Color ("Main Color", Color) = (1,1,1,1)
  4. _MainTex1 ("Texture 1 (RGB)", 2D) = "white" {}
  5. _MainTex2 ("Texture 2 (RGB)", 2D) = "white" {}
  6. _MainTex3 ("Texture 2 (RGB)", 2D) = "white" {}
  7. }
  8. SubShader {
  9. Tags { "RenderType" = "Opaque" }
  10. CGPROGRAM
  11. #pragma surface surf Lambert vertex:vert
  12. struct Input {
  13. float2 uv_MainTex1 : TEXCOORD0;
  14. float2 uv_MainTex2 : TEXCOORD1;
  15. float2 uv_MainTex3 : TEXCOORD2;
  16. float4 color : TEXCOORD3;
  17. };
  18. void vert (inout appdata_full v, out Input o)
  19. {
  20. UNITY_INITIALIZE_OUTPUT(Input,o);
  21. o.color = (v.color);
  22. }
  23. uniform sampler2D _MainTex1, _MainTex2, _MainTex3;
  24. fixed4 _Color;
  25. fixed _Tile;
  26. void surf (Input IN, inout SurfaceOutput o) {
  27. fixed4 col = tex2D( _MainTex1, IN.uv_MainTex1)*IN.color.r;
  28. col += tex2D( _MainTex2, IN.uv_MainTex2)*IN.color.g;
  29. col += tex2D( _MainTex3, IN.uv_MainTex3)*IN.color.b;
  30. o.Albedo = col * _Color.rgb;
  31. // o.Albedo = (0,0,0,0);
  32. }
  33. ENDCG
  34. }
  35. SubShader{
  36. Tags { "Queue" = "Geometry" }
  37. Pass{
  38. Tags {"LightMode"="Vertex" }
  39. GLSLPROGRAM
  40. uniform sampler2D _MainTex1, _MainTex2, _MainTex3;
  41. uniform lowp vec4 _Color;
  42. varying lowp vec4 color;
  43. #ifdef VERTEX
  44. void main(){
  45. gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
  46. gl_TexCoord[0] = gl_MultiTexCoord0;
  47. color = gl_Color;
  48. }
  49. #endif
  50. #ifdef VERTEX
  51. void main(){
  52. vec4 col = texture2D( _MainTex1,gl_TexCoord[0].st) * color.r;
  53. col += texture2D( _MainTex2,gl_TexCoord[0].st) * color.g;
  54. col += texture2D( _MainTex3,gl_TexCoord[0].st) * color.b;
  55. col *= _Color;
  56. gl_FragColor = col;
  57. }
  58. #endif
  59. #endif
  60. ENDGLSL
  61. }
  62. Pass {
  63. Tags {"LightMode"="VertexLM" }
  64. GLSLPROGRAM
  65. uniform lowp mat4 unity_LightmapMatrix;
  66. varying lowp vec2 uv, uv2;
  67. varying lowp vec4 color;
  68. #ifdef VERTEX
  69. void main() {
  70. gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
  71. uv = gl_MultiTexCoord0.xy;
  72. color = gl_Color;
  73. uv2 = vec2(unity_LightmapMatrix[0].x, unity_LightmapMatrix[1].y)
  74. * gl_MultiTexCoord1.xy + unity_LightmapMatrix[3].xy;
  75. }
  76. #endif
  77. #ifdef FRAGMENT
  78. uniform lowp sampler2D _MainTex1, _MainTex2, _MainTex3, unity_Lightmap;
  79. void main() {
  80. gl_FragColor = vec4((
  81. (texture2D(_MainTex1, uv).rgb * color.r)
  82. + (texture2D(_MainTex2, uv).rgb * color.g)
  83. + (texture2D(_MainTex3, uv).rgb * color.b))
  84. * (texture2D(unity_Lightmap, uv2).rgb * 2.), 1);
  85. }
  86. #endif
  87. ENDGLSL
  88. }
  89. Pass { // Editor only - Graphics Emulation uses the wrong lightmap type
  90. Tags {"LightMode"="VertexLMRGBM" }
  91. GLSLPROGRAM
  92. uniform lowp mat4 unity_LightmapMatrix;
  93. varying lowp vec2 uv, uv2;
  94. varying lowp vec4 color;
  95. #ifdef VERTEX
  96. void main() {
  97. gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
  98. uv = gl_MultiTexCoord0.xy;
  99. color = gl_Color;
  100. uv2 = vec2(unity_LightmapMatrix[0].x, unity_LightmapMatrix[1].y)
  101. * gl_MultiTexCoord1.xy + unity_LightmapMatrix[3].xy;
  102. }
  103. #endif
  104. #ifdef FRAGMENT
  105. uniform lowp sampler2D _MainTex1, _MainTex2, _MainTex3, unity_Lightmap;
  106. void main() {
  107. gl_FragColor = vec4((
  108. (texture2D(_MainTex1, uv).rgb * color.r)
  109. + (texture2D(_MainTex2, uv).rgb * color.g)
  110. + (texture2D(_MainTex3, uv).rgb * color.b))
  111. * (texture2D(unity_Lightmap, uv2).rgb * 2.), 1);
  112. }
  113. #endif
  114. ENDGLSL
  115. }
  116. }
  117. }