Advertisement
Guest User

PaintLightmap

a guest
Nov 7th, 2017
8,487
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1.  
  2.  
  3. Shader "Custom/Paint Diffuse" {
  4.  
  5. Properties{
  6. _MainTex("Main Texture", 2D) = "white" {}
  7. _PaintMap("PaintMap", 2D) = "white" {} // texture to paint on
  8. }
  9.  
  10. SubShader{
  11. Tags{ "RenderType" = "Opaque" "LightMode" = "ForwardBase" }
  12.  
  13. Pass{
  14.  
  15. Lighting Off
  16.  
  17. CGPROGRAM
  18.  
  19. #pragma vertex vert
  20. #pragma fragment frag
  21.  
  22.  
  23. #include "UnityCG.cginc"
  24. #include "AutoLight.cginc"
  25.  
  26. struct v2f {
  27. float4 pos : SV_POSITION;
  28. float2 uv0 : TEXCOORD0;
  29. float2 uv1 : TEXCOORD1;
  30.  
  31. };
  32.  
  33. struct appdata {
  34. float4 vertex : POSITION;
  35. float2 texcoord : TEXCOORD0;
  36. float2 texcoord1 : TEXCOORD1;
  37.  
  38. };
  39.  
  40. sampler2D _PaintMap;
  41. sampler2D _MainTex;
  42. float4 _MainTex_ST;
  43. v2f vert(appdata v) {
  44. v2f o;
  45.  
  46. o.pos = UnityObjectToClipPos(v.vertex);
  47. o.uv0 = TRANSFORM_TEX(v.texcoord, _MainTex);
  48.  
  49. o.uv1 = v.texcoord1.xy * unity_LightmapST.xy + unity_LightmapST.zw;// lightmap uvs
  50.  
  51. return o;
  52. }
  53.  
  54. half4 frag(v2f o) : COLOR{
  55. half4 main_color = tex2D(_MainTex, o.uv0); // main texture
  56. half4 paint = (tex2D(_PaintMap, o.uv1)); // painted on texture
  57. main_color *= paint; // add paint to main;
  58. return main_color;
  59. }
  60. ENDCG
  61. }
  62. }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement