Unity is not illuminated but accepts shadow baking and normal map Lightmap shader
The original version of the shader was written by other big guys, I added a normal map bump,
Code after adding normal map:
Shader "PengLu/Unlit/TextureLM_Norm" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {
}
_BumpMap("Normal Map", 2D) = "bump"{
}
_Color("LightColor",Color) = (1,1,1,1)
_MainColorIntensity("Main Color Intensity", Range(0.0,4.0))=1.0
}
SubShader {
Tags {
"RenderType"="Opaque" }
LOD 100
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_fog
#pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON
#include "UnityCG.cginc"
struct appdata_t {
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
float2 texcoord1 : TEXCOORD1;
};
struct v2f {
float4 vertex : SV_POSITION;
half2 texcoord : TEXCOORD0;
half2 uvLM : TEXCOORD1;
float3 viewDir:TEXCOORD2;
UNITY_FOG_COORDS(1)
};
sampler2D _MainTex;
half4 _MainTex_ST;
sampler2D _BumpMap;
float4 _Color;
float _MainColorIntensity;
float4 _LightColor0;
v2f vert (appdata_full v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.texcoord = TRANSFORM_TEX(v.texcoord.xy, _MainTex);
TANGENT_SPACE_ROTATION;
o.uvLM=ObjSpaceLightDir(o.vertex);
o.viewDir=ObjSpaceViewDir(o.vertex);
o.uvLM=mul((float2x2)rotation,o.uvLM);
o.viewDir=mul(rotation,o.viewDir);
o.uvLM = v.texcoord1.xy * unity_LightmapST.xy + unity_LightmapST.zw;
UNITY_TRANSFER_FOG(o,o.vertex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
fixed4 col = tex2D(_MainTex, i.texcoord);
UNITY_APPLY_FOG(i.fogCoord, col);
UNITY_OPAQUE_ALPHA(col.a);
fixed3 lm = DecodeLightmap (UNITY_SAMPLE_TEX2D(unity_Lightmap, i.uvLM.xy));
col.rgb*=lm;
float3 N=UnpackNormal(tex2D(_BumpMap, i.texcoord));
float diff=max(0,dot(N,i.uvLM));
col=_Color*(col*diff)+col*_MainColorIntensity*UNITY_LIGHTMODEL_AMBIENT;
return col;
}
ENDCG
}
}
}