Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@ import {
} from 'three';

/**
* Visualizes an {@link LightProbeGrid} by rendering a sphere at each
* Visualizes an {@link LightProbeGridWebGL} by rendering a sphere at each
* probe position, shaded with the probe's L2 spherical harmonics.
*
* Uses a single `InstancedMesh` draw call for all probes.
*
* ```js
* const helper = new LightProbeGridHelper( probes );
* const helper = new LightProbeGridHelperWebGL( probes );
* scene.add( helper );
* ```
*
* @augments InstancedMesh
* @three_import import { LightProbeGridHelper } from 'three/addons/helpers/LightProbeGridHelper.js';
* @three_import import { LightProbeGridHelperWebGL } from 'three/addons/helpers/LightProbeGridHelperWebGL.js';
*/
class LightProbeGridHelper extends InstancedMesh {
class LightProbeGridHelperWebGL extends InstancedMesh {

/**
* Constructs a new irradiance probe grid helper.
*
* @param {LightProbeGrid} probes - The probe grid to visualize.
* @param {LightProbeGridWebGL} probes - The probe grid to visualize.
* @param {number} [sphereSize=0.12] - The radius of each probe sphere.
*/
constructor( probes, sphereSize = 0.12 ) {
Expand Down Expand Up @@ -135,11 +135,11 @@ class LightProbeGridHelper extends InstancedMesh {
/**
* The probe grid to visualize.
*
* @type {LightProbeGrid}
* @type {LightProbeGridWebGL}
*/
this.probes = probes;

this.type = 'LightProbeGridHelper';
this.type = 'LightProbeGridHelperWebGL';

this.update();

Expand Down Expand Up @@ -218,4 +218,4 @@ class LightProbeGridHelper extends InstancedMesh {

}

export { LightProbeGridHelper };
export { LightProbeGridHelperWebGL };
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ const ATLAS_PADDING = 1;
* Baking is fully GPU-resident: cubemap rendering, SH projection, and
* texture packing all happen on the GPU with zero CPU readback.
*
* @three_import import { LightProbeGrid } from 'three/addons/lighting/LightProbeGrid.js';
* @three_import import { LightProbeGridWebGL } from 'three/addons/lighting/LightProbeGridWebGL.js';
*/
class LightProbeGrid extends Object3D {
class LightProbeGridWebGL extends Object3D {

/**
* Constructs a new irradiance probe grid.
Expand Down Expand Up @@ -141,7 +141,7 @@ class LightProbeGrid extends Object3D {

/**
* The world-space bounding box for the grid. Updated automatically
* by {@link LightProbeGrid#bake}.
* by {@link LightProbeGridWebGL#bake}.
*
* @type {Box3}
*/
Expand Down Expand Up @@ -362,7 +362,7 @@ class LightProbeGrid extends Object3D {

scene.matrixWorldAutoUpdate = currentMatrixWorldAutoUpdate;

// console.log( `LightProbeGrid: bake complete ${ ( performance.now() - t0 ).toFixed( 1 ) }ms` );
// console.log( `LightProbeGridWebGL: bake complete ${ ( performance.now() - t0 ).toFixed( 1 ) }ms` );

this.visible = true;

Expand Down Expand Up @@ -678,4 +678,4 @@ function _ensureBatchTarget( totalProbes ) {

}

export { LightProbeGrid };
export { LightProbeGridWebGL };
Binary file modified examples/screenshots/webgl_lightprobes.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 7 additions & 11 deletions examples/webgl_lightprobes.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@

import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
import { GUI } from 'three/addons/libs/lil-gui.module.min.js';
import { LightProbeGrid } from 'three/addons/lighting/LightProbeGrid.js';
import { LightProbeGridHelper } from 'three/addons/helpers/LightProbeGridHelper.js';
import { LightProbeGridWebGL } from 'three/addons/lighting/LightProbeGridWebGL.js';
import { LightProbeGridHelperWebGL } from 'three/addons/helpers/LightProbeGridHelperWebGL.js';

let camera, scene, renderer, controls;
let probes, probesHelper;
Expand Down Expand Up @@ -134,10 +134,6 @@
light.shadow.normalBias = - 0.02;
scene.add( light );

// Dim ambient to see GI effect better
const ambient = new THREE.AmbientLight( 0xffffff, 0.05 );
scene.add( ambient );

// Renderer

renderer = new THREE.WebGLRenderer( { antialias: true } );
Expand All @@ -157,7 +153,7 @@

// Bake light probe volume

async function bakeWithResolution( resolution ) {
async function bake( resolution ) {

if ( probes ) {

Expand All @@ -166,7 +162,7 @@

}

probes = new LightProbeGrid( 5.6, 4.7, 5.6, resolution, resolution, resolution );
probes = new LightProbeGridWebGL( 5.6, 4.7, 5.6, resolution, resolution, resolution );
probes.position.set( 0, 2.45, 0 );
probes.bake( renderer, scene, { cubemapSize: 32, near: 0.05, far: 20 } );
probes.visible = params.enabled;
Expand All @@ -176,7 +172,7 @@

if ( ! probesHelper ) {

probesHelper = new LightProbeGridHelper( probes );
probesHelper = new LightProbeGridHelperWebGL( probes );
probesHelper.visible = params.showProbes;
scene.add( probesHelper );

Expand All @@ -195,7 +191,7 @@
resolution: 6
};

await bakeWithResolution( params.resolution );
await bake( params.resolution );

// GUI

Expand All @@ -207,7 +203,7 @@
} );
gui.add( params, 'resolution', 2, 12, 1 ).name( 'Resolution' ).onFinishChange( ( value ) => {

bakeWithResolution( value );
bake( value );

} );
gui.add( params, 'showProbes' ).name( 'Show Probes' ).onChange( ( value ) => {
Expand Down
18 changes: 9 additions & 9 deletions examples/webgl_lightprobes_complex.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@

import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
import { GUI } from 'three/addons/libs/lil-gui.module.min.js';
import { LightProbeGrid } from 'three/addons/lighting/LightProbeGrid.js';
import { LightProbeGridHelper } from 'three/addons/helpers/LightProbeGridHelper.js';
import { LightProbeGridWebGL } from 'three/addons/lighting/LightProbeGridWebGL.js';
import { LightProbeGridHelperWebGL } from 'three/addons/helpers/LightProbeGridHelperWebGL.js';

let camera, scene, renderer, controls;
let probesLeft, probesRight;
Expand Down Expand Up @@ -279,7 +279,7 @@
resolution: 6
};

async function bakeWithResolution( resolution ) {
async function bake( resolution ) {

// Remove both volumes before baking to prevent feedback

Expand All @@ -299,12 +299,12 @@

// Bake both volumes

probesLeft = new LightProbeGrid( 7.8, 4.7, 7.6, resolution, resolution, resolution );
probesLeft = new LightProbeGridWebGL( 7.8, 4.7, 7.6, resolution, resolution, resolution );
probesLeft.position.set( - 3.9, 2.45, 0 );
probesLeft.bake( renderer, scene, { cubemapSize: 32, near: 0.05, far: 20 } );
probesLeft.visible = params.enabled;

probesRight = new LightProbeGrid( 7.8, 4.7, 7.6, resolution, resolution, resolution );
probesRight = new LightProbeGridWebGL( 7.8, 4.7, 7.6, resolution, resolution, resolution );
probesRight.position.set( 3.9, 2.45, 0 );
probesRight.bake( renderer, scene, { cubemapSize: 32, near: 0.05, far: 20 } );
probesRight.visible = params.enabled;
Expand All @@ -318,11 +318,11 @@

if ( ! probesHelperLeft ) {

probesHelperLeft = new LightProbeGridHelper( probesLeft );
probesHelperLeft = new LightProbeGridHelperWebGL( probesLeft );
probesHelperLeft.visible = params.showProbes;
scene.add( probesHelperLeft );

probesHelperRight = new LightProbeGridHelper( probesRight );
probesHelperRight = new LightProbeGridHelperWebGL( probesRight );
probesHelperRight.visible = params.showProbes;
scene.add( probesHelperRight );

Expand All @@ -338,7 +338,7 @@

}

await bakeWithResolution( params.resolution );
await bake( params.resolution );

// GUI

Expand All @@ -351,7 +351,7 @@
} );
gui.add( params, 'resolution', 2, 12, 1 ).name( 'Resolution' ).onFinishChange( ( value ) => {

bakeWithResolution( value );
bake( value );

} );
gui.add( params, 'showProbes' ).name( 'Show Probes' ).onChange( ( value ) => {
Expand Down
10 changes: 5 additions & 5 deletions examples/webgl_lightprobes_sponza.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
import { GUI } from 'three/addons/libs/lil-gui.module.min.js';
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
import { Sky } from 'three/addons/objects/Sky.js';
import { LightProbeGrid } from 'three/addons/lighting/LightProbeGrid.js';
import { LightProbeGridHelper } from 'three/addons/helpers/LightProbeGridHelper.js';
import { LightProbeGridWebGL } from 'three/addons/lighting/LightProbeGridWebGL.js';
import { LightProbeGridHelperWebGL } from 'three/addons/helpers/LightProbeGridHelperWebGL.js';

const MODEL_INDEX_URL = 'https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Assets/main/Models/model-index.json';
const SAMPLE_ASSETS_BASE_URL = 'https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Assets/main/Models/';
Expand Down Expand Up @@ -233,7 +233,7 @@

}

probes = new LightProbeGrid(
probes = new LightProbeGridWebGL(
params.sizeX, params.sizeY, params.sizeZ,
params.countX, params.countY, params.countZ
);
Expand All @@ -252,7 +252,7 @@

if ( ! probesHelper ) {

probesHelper = new LightProbeGridHelper( probes, params.probeSize );
probesHelper = new LightProbeGridHelperWebGL( probes, params.probeSize );
probesHelper.visible = params.showProbes;
scene.add( probesHelper );

Expand Down Expand Up @@ -320,7 +320,7 @@

scene.remove( probesHelper );
probesHelper.dispose();
probesHelper = new LightProbeGridHelper( probes, value );
probesHelper = new LightProbeGridHelperWebGL( probes, value );
probesHelper.visible = params.showProbes;
scene.add( probesHelper );

Expand Down