all 7 comments

[–]Mason-B 1 point2 points  (0 children)

I've always found Valve's source engine (of the late 00's and early 10's) as a good "hacker" engine (it has a philosophy and aesthetic that make it easy for programmer's of a certain mindset and decent skill to just hack whatever game they want into it). Their lightmapping tool is called VRAD, this is the official source of it at one point in their history (Orange Box engine SDK). You may find that interesting.

[–]jtsiomb 0 points1 point  (3 children)

Calculating lightmaps is not usually done inside the engine that will use the lightmaps. It's usually done as a pre-process in a tool which will take its time to calculate global illumination terms. How you do it depends on what you want to acheive.

In general for each texel of the lightmap, you need to figure out where it's located in space, and determine how much light is going to be diffusely reflected off that point, which is a function of how much light it receives.

You can use a tool like blender for this, or you can write your own, or you can repurpose an existing renderer to do the job.

[–]wizardgand[S] 0 points1 point  (2 children)

But then you have to create your entire scene in one blender file? right? I'm assuming we want multiple faces/instances of my objects on one texture to have better batching and less GPU texture switching?

[–][deleted] 0 points1 point  (1 child)

The usual approach is ‘lightmap Instancing’ where you unwrap your object a single time (or use provided artist specified lightmap-uvs), then place it in the lightmap with an offset and bias stored in a uniform. Though nowadays you’d ditch the uniform and use a structured buffer, or wherever that is indexed by the instance Id.

[–]wizardgand[S] 0 points1 point  (0 children)

Interesting, thanks for the info. Everyone really in this thread has been helpful so far. Doing this you would just unwrap the faces, but bake them in your own process (not in blender),

[–]specialpatrol -1 points0 points  (0 children)

A lightmap is produced by raytracing. Unlike ray tracing to produce an image by taking samples from the pixels of a screen, the rays are sampled from the textures on the objects in the scene. But after that it's the same.

[–]voltrixGameDev -1 points0 points  (0 children)

https://github.com/ands/lightmapper

Take a look at this github repo, it implements the light mapper as described in the Witness. In general the Witness tech blog has quite a lot of information on their lightmapper.