Valve pinch a little code from Godot for Half-Life 2, Counter-Strike: Source, Day of Defeat: Source, Team Fortress 2
Submitted 2 days ago by ZippyBot@lemmy.zip [bot] to gaming@lemmy.zip
Submitted 2 days ago by ZippyBot@lemmy.zip [bot] to gaming@lemmy.zip
Lojcs@lemm.ee 2 days ago
What is a bicubic lightmap?
Clearwater@lemmy.world 1 day ago
Reference: developer.valvesoftware.com/wiki/Lightmap
Skipping over some details and simplifying this to (hopefully) make it something anyone can reasonably understand: For Source in particular (as other engines may do things differently), maps start out as being fully bright without shadows. Here is an image I stole off a google search showing what that looks like:
Image
When the map is being compiled (or exported or whatever term resonates with you the best), the lights placed within the map as well (and probably sky information too) are used to determine what parts should be covered in shadow and what should be brightly lit. The result is called the lightmap. (The lightmap itself doesn’t have any texture of, say concrete. It only stores data along the lines of “this light brightness here is 50%”). By taking the texture of the surface (concrete, asphalt, stucco) and darkening / lightening it according to the lightmap, you then end up with a lit version of the map which does have shadows.
Now on to the bicubic part: To keep the size of map files down, and reduce the resources required to load it, lightmaps by default render at a resolution of one pixel per (approximately) 40 cm or roughly one pixel per 1.5 ft. This low resolution is perfectly fine since the shadow of a building or highway overpass doesn’t need to be especially detailed beyond just “it’s dark over there”. Where required, the map author can increase the resolution in the spots that require additional detail. However, there is still one problem: When rendering a frame for you to view, the low texture lightmap is “scaled up” to cover the entire surface and you don’t want pixelated shadows. The fast way of handling this is linear scaling, where to find the value of a “scaled up” pixel, you just take the values of the nearest “original pixels” and simply average them (with more weight given toward nearer “original pixels” than farther). While extremely fast, this leads to stair-stepping as shown in the top-left panel:
Image
Bicubic is just a fancier method of finding the value of that “scaled up” value. It’s a slower method than linear, but it resolves the stair-stepping problem.