Unity Vertex Lighting with Lightmaps

If you’ve ever tried this before, using non-important (or vertex lighting) on a mesh that is also lightmapped in Unity you will already know that it doesn’t work. According to this thread on the Unity forums the reason for this is that if you select Vertex Lighting you’ve indicated that you want things to run as a fast as possible, and that generally means you don’t want lightmaps.

Well, it is not wrong. Generally speaking this is an accurate assessment, but as an experienced game developer sometimes you have to do things that seems counterintuitive. Similarly, in the mobile space, this method is used as a way to generate good looking lighting via lightmaps without resorting to relatively expensive per pixel dynamic lights.

Using Unity’s builtin shader source as a point of reference I’ve come up with something that appears to work.

Vertex Lit with Lightmapping Shader

Move the runtime light in the editor to see the effect it has on the lightmapped cube.

VertexLit with Lightmapping Sample

VertexLit with Lightmapping Sample

Note that the Main Color has been removed from the lightmap combiner, you can add it back if you want this. The primary (vertex light) color is added to the lightmap color, so I removed the DOUBLE from the main texture and lightmap combination to reduce oversaturation, ultimately you can change this to your needs.

Leave a Reply

Your email address will not be published. Required fields are marked *