Search Unity

Need help with Unlit Vertex Blend shader

Discussion in 'Shaders' started by skylebones, Aug 20, 2013.

  1. skylebones

    skylebones

    Joined:
    Nov 21, 2009
    Posts:
    106
    I'm trying to create a shader that I can blend multiple diffuse maps with a vertex painter, but I want the maps to be unlit. I've been able to hack together this from some shaders off the internet, but I can't figure out how to change it to unlit without breaking it.

    I know next to nothing about shader creation.

    Here is what I have, any help would be HUGELY appreciated.

    -Sky
    Code (csharp):
    1.  
    2. Shader "Unlit Blend"
    3. {
    4.     properties {
    5.  
    6.         _Splat1 ("Diffuse 01 (R)", 2D) = "white"{}
    7.         _Splat2 ("Diffuse 02 (G)", 2D) = "white"{}
    8.         _Splat3 ("Diffuse 03 (B)", 2D) = "white"{}
    9.         _Splat4 ("Diffuse 04 (A)", 2D) = "white"{}
    10.     }
    11.    
    12.     subshader {
    13.         Tags {"SplatCount" = "4" "RenderType" = "Opaque" }
    14.        
    15.         Pass {
    16.         Lighting Off}
    17.        
    18.         CGPROGRAM
    19.         #pragma surface surf Lambert vertex:vert
    20.         #pragma target 3.0
    21.        
    22.        
    23.         sampler2D _Splat1;
    24.         sampler2D _Splat2;
    25.         sampler2D _Splat3;
    26.         sampler2D _Splat4;
    27.    
    28.        
    29.         struct Input {
    30.             float2 uv_Splat1;
    31.             float2 uv_Splat2;
    32.             float2 uv_Splat3;
    33.             float2 uv_Splat4;
    34.             float4 vertexColor;
    35.         };
    36.        
    37.         void vert (inout appdata_full v, out Input o) {
    38.             o.vertexColor = v.color;
    39.         }
    40.            
    41.         void surf (Input IN, inout SurfaceOutput o) {
    42.            
    43.             float4 splat_control = IN.vertexColor;
    44.             fixed3 albedo;
    45.             float gloss;
    46.             float2 uv1 = IN.uv_Splat1;
    47.             float2 uv2 = IN.uv_Splat2;
    48.             float2 uv3 = IN.uv_Splat3;
    49.             float2 uv4 = IN.uv_Splat4;
    50.            
    51.             float4 Splat1 = tex2D(_Splat1, uv1);
    52.             float4 Splat2 = tex2D(_Splat2, uv2);
    53.             float4 Splat3 = tex2D(_Splat3, uv3);
    54.             float4 Splat4 = tex2D(_Splat4, uv4);
    55.            
    56.             albedo = Splat1.rgb * splat_control.r;
    57.             albedo += Splat2.rgb * splat_control.g;
    58.             albedo += Splat3.rgb * splat_control.b;
    59.             albedo += Splat4.rgb * splat_control.a;
    60.    
    61.             o.Albedo = albedo;
    62.            
    63.  
    64.         }
    65.        
    66.         ENDCG
    67.     }
    68.     Fallback "Diffuse"
    69. }
     
  2. Phantomx

    Phantomx

    Joined:
    Oct 30, 2012
    Posts:
    202
    Instead of
    Code (csharp):
    1.  o.Albedo = albedo;
    use
    Code (csharp):
    1.  o.Emission = albedo;
    but you shouldn't use a surface shader if you want no lighting.
     
  3. Jessy

    Jessy

    Joined:
    Jun 7, 2007
    Posts:
    7,325
    Surface shaders only exist for incorporating lighting; "void surf" will have no place in what you want.