Overlay identical Mesh - Render on Top - no Z-fighting

Hello everyone :slight_smile:

I had this Idea of re-creating my favorite mission from my favorite game so i could step into it in VR. So i got the Mod-Kit, gathered all the Game assets, and was then trying to put everything back together in Unity.

So far so good, but then i reach the point that has me frustrated so much: The way they created lightmaps back in 99: They have the Game Mesh with all the associated Textures, and then segments of it that are identical to parts of the Game mesh, that they overlay with a “multiply” blending mode, to create the lightmap.

(see Image)


[the grey mesh is the lightmap - its topology is almost identical to the underlying mesh. I moved it up from the main mesh to better visualize it]

I tried many things to get those Lightmaps to work in unity- nothing worked. Now im thinking of just replicating it the way they did it in 1999, by just overlaying the Lightmap mesh with a blending mode over top the actual game Geometry. But How would i do that in Unity without getting Z-Fighting or without the lightmap rendering on top of everything?

Ideally if the two meshes are identical apart from their UVs, there shouldn’t be any problem. As long as the lightmap geometry is using ZTest LEqual, there shouldn’t be any z fighting at all.

Now in your case there may be some issues with the export or import of the assets, or the original meshes don’t actually perfectly match and the original game is using another trick, one that can fix the issues you’re having now. That is doing an offset.

thank you sooo much!!
this helped me a lot, i got it to work!!

You happened across the right guy for the job, bgolus knows his stuff.

i ran into one more issue:

the Overlay-Lightmaps work perfectly fine! So they mix with the colors underneath (multiplicative), which is fine, because that’s what the original Game did. But when ever i have some emissive material underneath the bright parts get really muddy. Is there any or trick way to make textures with emissive properties shine trough the overlaying mesh better?

thanks again :slight_smile:

My guess is the original game rendered out the emissive to a separate screen buffer to do the bloom. And by guess I mean I’m almost positive that’s what they did since I have a good guess what that game is. :wink:

But that doesn’t help you here. There are options though.

Easiest option, render the albedo alone first, then the light map geometry, then the base geometry again with emissive. Clunky, but will work.

Second option would be to render the light map first, then render the albedo layer on top in two passes. First is the albedo multiplying with the lightmap, and the second is the emissive. This might actually be even easier than the first option.