I have been trying to take the nature leaf shader and add a lightmap to it. I’ve looked all over the forums and can’t figure out how to do this. I tried adding the components from the lightmap shader to the nature shader but was unsuccessful. Sorry if this has been discussed but I’m out of ideas. Any help would be great, thanks…
Andrew
I want to know also. I using nature double sided shader for leaf and how can i add in lightmap?
Add the following to the shader.
Properties {
...
_Lightmap ("Lightmap (RGB)", 2D) = "lightmap" { LightmapMode }
...
}
To the vertex shader:
uniform float4 _Lightmap_ST;
v2f_vtx_lit_blend vert (appdata v)
{
...
o.uv2 = TRANSFORM_TEX(v.texcoord1, _Lightmap);
...
return o;
}
To the frag shader:
uniform sampler2D _Lightmap;
...
float4 frag (v2f_vtx_lit_blend i) : COLOR
{
...
float4 light = tex2D(_Lightmap, i.uv2);
return texcol * light + (texcol * _PPLAmbient * 2 * _Color);
}