Capítulo 137 de 859

Chapter 137: ProgressiveLightMap

Core Idea

Progressive Light Map Accumulator, by zalo.

To use, simply construct a ProgressiveLightMap object, plmap.addObjectsToLightMap(object) an array of semi-static objects and lights to the class once, and then call plmap.update(camera) every frame to begin accumulating lighting samples.

This should begin accumulating lightmaps which apply to your objects, so you can start jittering lighting to achieve the texture-space effect you're looking for.

This class can only be used with WebGLRenderer. When using WebGPURenderer, import from ProgressiveLightMapGPU.js.

Key Concepts

  • renderer : WebGLRenderer: The renderer.
  • res : number: The side-long dimension of the total lightmap.

Code Examples

import { ProgressiveLightMap } from 'three/addons/misc/ProgressiveLightMap.js';
  • What it demonstrates: Typical usage of ProgressiveLightMap.

Reference Tables

Constructor

Signature
new ProgressiveLightMap( renderer : WebGLRenderer, res : number )

Properties

PropertyDescription
.renderer : WebGLRendererThe renderer.
.res : numberThe side-long dimension of the total lightmap.

Methods

MethodDescription
.addObjectsToLightMap( objects : Array.<Object3D> )Sets these objects' materials' lightmaps and modifies their uv1's.
.dispose()Frees all internal resources.
.showDebugLightmap( visible : boolean, position : Vector3 )Draws the lightmap in the main scene. Call this after adding the objects to it.
.update( camera : Camera, blendWindow : number, blurEdges : boolean )This function renders each mesh one at a time into their respective surface maps.

Key Takeaways

  1. Most relevant properties: renderer, res.
  2. Key methods: addObjectsToLightMap, dispose, showDebugLightmap, update.

Connects To