-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
render-pass-lightmapper.js
47 lines (39 loc) · 1.46 KB
/
render-pass-lightmapper.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { DebugGraphics } from '../../platform/graphics/debug-graphics.js';
import { RenderPass } from '../../platform/graphics/render-pass.js';
import { SHADER_FORWARDHDR } from '../../scene/constants.js';
/**
* A render pass implementing rendering of mesh instance receivers for light-mapper.
*
* @ignore
*/
class RenderPassLightmapper extends RenderPass {
/** @type {import('../../platform/graphics/bind-group.js').BindGroup[]} */
viewBindGroups = [];
constructor(device, renderer, camera, worldClusters, receivers, lightArray) {
super(device);
this.renderer = renderer;
this.camera = camera;
this.worldClusters = worldClusters;
this.receivers = receivers;
this.lightArray = lightArray;
}
destroy() {
this.viewBindGroups.forEach((bg) => {
bg.defaultUniformBuffer.destroy();
bg.destroy();
});
this.viewBindGroups.length = 0;
}
execute() {
const device = this.device;
DebugGraphics.pushGpuMarker(device, 'Lightmapper');
const { renderer, camera, receivers, renderTarget, worldClusters, lightArray } = this;
renderer.renderForwardLayer(camera, renderTarget, null, undefined, SHADER_FORWARDHDR, this.viewBindGroups, {
meshInstances: receivers,
splitLights: lightArray,
lightClusters: worldClusters
});
DebugGraphics.popGpuMarker(device);
}
}
export { RenderPassLightmapper };