Examples: Add DepthSavePass
and depth texture tools
#31360
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Add
DepthSavePass
, depth texture utilities, and interactive displacement exampleThis
DepthSavePass
introduces support for working with depth textures in post-processing workflows andDepthTextureUtils
adds a world position picking;This position picking method based on the depth texture takes into account map displacement. It can also be more performant than raycasting, especially when the mesh has a high number of faces, as it avoids the computational cost of geometric intersection tests.
🧱 New Post-Processing Pass
DepthSavePass
A render pass that saves the scene’s depth buffer into a
Texture
.Useful for accessing per-pixel depth values using
renderer.readRenderTargetPixels()
or for use in subsequent post-processing effects.🛠️ Depth Utilities
DepthTextureUtils
A small utility module for working with depth data:
pickWorldPosition()
— converts screen-space mouse coordinates into a 3D world position using the depth texture.🧪 Example
webgl_postprocessing_interactive_displacement.html
A live demo showcasing:
These additions extend Three.js’s post-processing capabilities and simplify depth buffer access for custom spatial effects.