ands / lightmapper

A C/C++ single-file library for drop-in lightmap baking. Just use your existing OpenGL renderer to bounce light!
1.44k stars 134 forks source link

Baking a thickness texture #18

Closed ghost closed 3 years ago

ghost commented 3 years ago

I would like to use lightmapper to bake a "thickness" texture, i.e. something that approximates the thickness of a closed mesh beneath each surface point. Blender has an option to negate the sample vectors in its AO shader node, in order to sample "inside" the mesh. Substance Painter has also has a thickness baker, documented here.

What modifications of lightmapper.h would have to be made to make this possible?

ghost commented 3 years ago

Currently, I merely added a line to negate the sample direction after computing both the sample position and direction: https://github.com/ands/lightmapper/blob/master/lightmapper.h#L572

Edges are now brighter, but the overhaul rendition still differs quite a bit from what Blender renders:

Screenshot 2021-06-17 at 12 33 26 Screenshot 2021-06-17 at 12 42 58
ghost commented 3 years ago

Alright, answering my own question: You have to limit the draw distance as well.