-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WebGPURenderer: Introduce TiledLighting
#29642
Conversation
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
Am I the only one with 5fps on the Also the demo looks odd, maybe related to the recent changes on the transmission pass of the Renderer: /cc @sunag |
On
|
I ended up turning it off after an unsuccessful cleanup, here it is again |
This is how it looks like now on a Pixel 8: https://raw.githack.com/mrdoob/three.js/dev/examples/index.html?q=tiled#webgpu_lights_tiled |
Could it be cache? |
I think it was yeah. |
Description
The main idea of having a lighting system is to open up the possibility for contributors to add their own lighting system like clustered lighting, which is why I added
TiledLighting
in addons.About
TiledLighting
, there are still improvements to be made, such as sorting the lights according to the proximity of the camera to obtain better indexes, adding disposes, math optimizations and mainly added WebGLBackend support.API
The user does not need to manipulate anything special, such as shaders or uniforms, just define the class for light system.
Or define per material.
Process summary
Store all the light data in a texture. It's position, color, distance...
Create a buffer that represents pieces of the image, the tiles. Each tile will have the indexes of the lights that are visible in that piece.
Instead of processing all the lights on the entire screen, we will only process the lights that are present in the indexes of each tile, I made each tile store 8 indexes. It is as if it had only 8 lights to calculate per pixel.
There is a pre-renderer stage where the compute-shader will project the position and radius of light to screen space where we can check for intersection with the tiles using AABB and thus bind the light, indexing it in the tile buffer.
As I limited it to 8 indexes per tile and we do not have a sort lights, the system may fail if too many lights are added close to each other.
three.js.webgpu.-.tiled.lighting.-.Google.Chrome.2024-10-13.07-36-53.mp4
Commits