- Home /
where is Unity's shader handeling lightmapping?
Hi all,
I noticed that after I baked a lightmap with Beast within the Unity Editor, my standard Diffuse shader must use a different shader to display the lightmap.
So my question is: Where do find this shader so I can customize how the lightmap is calculated. Or is there a built-in function that is handleing the lightmap data? Again, where could I find it? Do I have to change and overwrite the legacy's shader (Lightmapped Diffuse)?
Thank you for your help,
0tacun
Answer by rutter · Jun 04, 2014 at 05:47 AM
Unity provides several built-in lightmapping shaders.
If those don't work, and/or you're going as far as creating your own lightmaps, it's not terribly difficult to incorporate lightmaps into them. It can be as simple as an extra multiply between your own color and the lightmap texture.
Thank you very much for your reply.
Unfortunatly it was not the solution. I tried to feed one lightmap shader with the lightmap unity generated. Alas the shader has not the correct uv coordiantes to display. (I made a copy of the generated lightmap and saved it in another folder. After that I cleared the lightmap in the lightmap tab)
Furthermore It looks more like when a lightmap is built, this lightmap is overlayed on top of any shader regardless of the type. So is there somewhere a function to change this behaivour?
P.S.: I used dual lightmaps.
I think in the fallback shaders (Vertex-Lit) there you can change how the lightmapping is handled:
// Lightmapped, encoded as RGB$$anonymous$$
Pass {
Tags { "Light$$anonymous$$ode" = "VertexL$$anonymous$$RGB$$anonymous$$" }
BindChannels {
Bind "Vertex", vertex
Bind "normal", normal
Bind "texcoord1", texcoord0 // lightmap uses 2nd uv
Bind "texcoord1", texcoord1 // unused
Bind "texcoord", texcoord2 // main uses 1st uv
}
SetTexture [unity_Lightmap] {
matrix [unity_Lightmap$$anonymous$$atrix]
combine texture * texture alpha DOUBLE
}
SetTexture [unity_Lightmap] {
constantColor [_Color]
combine previous * constant
}
SetTexture [_$$anonymous$$ainTex] {
combine texture * previous QUAD, texture * primary
}
}
Your answer
Follow this Question
Related Questions
Replacing lightmap shader pass 0 Answers
what does LightingLambert_DirLightmap()? 0 Answers
Day Cycle and LightMapping 2 Answers