How to generate lightmaps UV coordinates? ( by code )

Hi all,

I’m playing with coding a simple lightmap generator program using ray casting, by now I have harcoded the UV texture coordinates of the objects which I want to apply the generated lightmap. But now I want to improve it, and generate those coordinates by code.

I have been searching for this issue in the web and the only thing that I have found, is that a possible solution could be to use “Planar texture mapping”. But I have not idea of what it is.

Have anybody an idea of what method could I use in order to generate the lightmap UV coordinates for the different objects of my scene??

Thanks in advance,

The same way that you’d generate any other set of texture coordinates. Normally this is done when modelling the object (in Blender, 3dsMax, Maya, etc). While there are algorithms to assist in UV mapping, the process normally involves some manual element. At a minimum, for any closed surface you need to choose texture seams, essentially turning into an open surface which can be unwrapped onto a plane. Typically, you choose seams so that the “opened” surface is approximately developable, as this allows a mapping which is approximately conformal and with uniform scale.

1 Like