Hi everyone,
I’m working on implementing bloom effects for vehicle lights in a Three.js project. Below is the class VehicleLight
that I’ve created to manage the lights on a vehicle:
import * as THREE from 'three';
export class VehicleLight {
private lightObject: THREE.Object3D;
private Material: THREE.MeshStandardMaterial;
private onColor: number;
private offColor: number;
constructor(
object: THREE.Object3D,
Material: THREE.MeshStandardMaterial,
onColor: number,
offColor: number
) {
this.lightObject = object;
this.lightObject.layers.enable(1);
this.Material = Material;
this.onColor = onColor;
this.offColor = offColor;
this.lightObject.traverse((child) => {
if ((child as THREE.Mesh).isMesh) {
(child as THREE.Mesh).material = this.Material;
}
});
}
toggleLight(state: boolean) {
if (state) {
this.Material.emissiveIntensity = 1;
this.Material.emissive.set(this.onColor);
this.Material.color.set(this.onColor);
} else {
this.Material.emissiveIntensity = 0;
this.Material.emissive.set(this.offColor);
this.Material.color.set(this.offColor);
}
}
}
I use the https://threejs.org/examples/?q=bloom#webgl_postprocessing_unreal_bloom_selective from Three.js as a reference to apply the bloom effect. I suspect this might be a costly process, so I’m looking for ways to optimize it. Specifically, I’m interested in reducing the computational load without significantly compromising the visual quality.
Does anyone have suggestions or techniques they’ve used to optimize similar effects in Three.js
Thanks in advance for your help!
Here are some screenshots from the game showing the current bloom effect on vehicle lights: