在Shader中使用Lightmap的简单的例子
Shader "Self-Illum/NewSurfaceShader"
{
Properties{
}
SubShader
{
Tags{
"RenderType" = "Opaque"}
Pass
{
Tags{
"LightMode" = "ForwardBase"}
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
#include "Lighting.cginc"
#pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON
struct vertOut {
float4 pos:SV_POSITION;
float2 lmuv:TEXCOORD0;
};
vertOut vert(appdata_full v) {
vertOut o;
o.pos = UnityObjectToClipPos(v.vertex);
o.lmuv = v.texcoord1.xy * unity_LightmapST.xy + unity_LightmapST.zw;
return o;
}
float4 frag(vertOut i) :COLOR{
#ifdef LIGHTMAP_ON
return float4(DecodeLightmap(UNITY_SAMPLE_TEX2D(