Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Surface Shader Unlit (Unity 5)

Discussion in 'Shaders' started by Bravo_cr, Jun 2, 2015.

  1. Bravo_cr

    Bravo_cr

    Joined:
    Jul 19, 2012
    Posts:
    148
    Hi,

    I have this simple Unlit surface shader for Unity 5. You may ask ¿Why do you need a surface shader for an unlit shader? The answer is because I want a simple unlit/lightmap with texture but I need that the color texture is taken into account for light bounces.

    Here is the shader:
    Code (CSharp):
    1. Shader "Unlit/Unlit Surface Shaders (Lightmap)" {
    2. Properties {
    3.  
    4.     _MainTex ("Base (RGB)", 2D) = "white" {}
    5.  
    6.    
    7. }
    8.  
    9. SubShader {
    10.     Tags { "RenderType"="Opaque" "Queue" = "Geometry"}
    11.    
    12. CGPROGRAM
    13.  
    14.  
    15. #pragma surface surf NoLighting  noambient
    16.  
    17.     sampler2D _MainTex;
    18.  
    19.     struct Input {
    20.         half2 uv_MainTex;
    21.    
    22.     };
    23.          
    24.      fixed4 LightingNoLighting(SurfaceOutput s, fixed3 lightDir, fixed atten)
    25.      {
    26.          fixed4 c;
    27.          c.rgb = s.Albedo;
    28.          c.a = s.Alpha;
    29.          return c;
    30.      }
    31.  
    32.     void surf (Input IN, inout SurfaceOutput o)
    33.     {  
    34.         o.Albedo = tex2D(_MainTex, IN.uv_MainTex);
    35.        
    36.     }
    37. ENDCG
    38. }
    39.  
    40. Fallback "Mobile/VertexLit"
    41. }
    The results its different if I check or uncheck realtime GI, so some light is being captured by the shader. Any clues?
     
    ahungrybear likes this.
  2. Ippokratis

    Ippokratis

    Joined:
    Oct 13, 2008
    Posts:
    1,521
    Try to add _Color
     
  3. Bravo_cr

    Bravo_cr

    Joined:
    Jul 19, 2012
    Posts:
    148
    Sorry I don't understand where to add _Color and what this is this going to do. Could you explain please?
     
  4. Superflat

    Superflat

    Joined:
    Mar 19, 2009
    Posts:
    354
    Create a Color property and then multiply it with the .rgb value in the o.Albedo slot.