- Home /
How does Unity apply a lightmap?
Hi,
I'm trying to bake my own lightmaps in Maya, partly because I want more control and partly because I can't afford Unity Pro. So I baked a lightmap with just "Illumination" as a render pass:
So I wrote a simple surface shader which blends two textures together and applies the result to the Emission property of the material. The problem is, I can't figure out how to properly blend the lightmap with the object's color:
I tried using multiply - the shadows are correct, but the highlights are washed out
Using screen - Way too much light and no shadows
So how does Unity do it? Or is there an easier way to tell Unity "apply this texture to this object as a lightmap"?
Thanks!
[SOLVED] RESULT Read my comment from the accepted answer for more details. Here is a screenshot from Unity with the lightmap correctly applied. The advantages of using this method is that I can completely customize the look of my scene with area lights/shadows, advanced GI and AO settings and more.
Answer by MaT227 · Nov 27, 2013 at 01:33 PM
I think that you need to write your own Lighting function as explained here.
There is a built-in legacy shader that authorize manual lightmaps. Maybe you could look at the source of this shader.
You can also replace the lightmaps in the lightmap panel by your own like explained here.
Here are other good resources:
A Truly Lightmap Shader
Vray lightmapping workflow in 3dsmax
Using externally baked lightmaps in Unity 3.5
Found the answer in the third link, thanks! I also had to render the lightmaps as EXR files and select Lightmap from the import settings.
Glad to help ! There are different ways to achieve what you want. Don't forget to validate the answer. ;)
Edit: Good looking results !
Yup, forgot to do that. I updated my question with the final result.
Hi,i still can't figure out this...i already render the exr files but it is not working....can you help ? Thank you!
Your answer
Follow this Question
Related Questions
Unity fails to recognize Maya models/Unity scenes 1 Answer
Alpha Transparency Shader Issue 1 Answer
How to approximate this surface with primitives? 1 Answer
Maya to Unity Glossy Shader Problem 1 Answer
How to implement shader 0 Answers