Search Unity

second pass of my custom shader does not influence after light map shader

Discussion in 'Shaders' started by michael_unity988, Dec 2, 2018.

  1. michael_unity988

    michael_unity988

    Joined:
    Aug 30, 2018
    Posts:
    9
    with the light map pass: why cant see blue color on the ball
    upload_2018-12-2_19-53-38.png
    without
    upload_2018-12-2_19-53-3.png

    Pass{
    //Name "FORWARD"
    //Tags{ "LightMode" = "ForwardBase" }
    //Tags{ "LightMode" = "ForwardAdd" "SHADOWSUPPORT" = "false" }
    //Blend One Zero
    ZWrite [_ZWrite]
    //LOD 100
    CGPROGRAM
    #pragma vertex vert
    #pragma fragment frag
    #pragma fragmentoption ARB_precision_hint_fastest
    #pragma exclude_renderers d3d11_9x d3d11
    #pragma multi_compile_fog
    #pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON
    #pragma multi_compile_fwdbase
    #include "UnityCG.cginc"
    #include "AutoLight.cginc"
    #include "Lighting.cginc"
    sampler2D _MainTex;
    struct appdata
    {
    float4 vertex : POSITION;
    half2 texcoord : TEXCOORD0;
    half2 texcoord1 : TEXCOORD1;
    };
    struct v2f {
    float4 pos : SV_POSITION;
    half2 uv : TEXCOORD0;
    half2 lightmapuv : TEXCOORD1;
    UNITY_FOG_COORDS(2)
    };
    v2f vert(appdata v)
    {
    v2f o;
    o.pos = UnityObjectToClipPos(v.vertex);
    o.uv = v.texcoord;
    o.lightmapuv = v.texcoord1.xy * unity_LightmapST.xy + unity_LightmapST.zw;
    UNITY_TRANSFER_FOG(o,o.pos);
    return o;
    }
    fixed4 frag(v2f i) : COLOR
    {
    fixed4 color = tex2D(_MainTex, i.uv);
    #ifndef LIGHTMAP_OFF
    fixed3 lightMap = DecodeLightmap(UNITY_SAMPLE_TEX2D(unity_Lightmap, i.lightmapuv));
    color.rgb *= lightMap;
    #endif
    UNITY_APPLY_FOG(i.fogCoord, color);
    return color;
    }
    ENDCG
    }