Export the POM march as a composable parallaxOcclusionUv function#9
Open
promontis wants to merge 1 commit into
Open
Export the POM march as a composable parallaxOcclusionUv function#9promontis wants to merge 1 commit into
promontis wants to merge 1 commit into
Conversation
The march was locked inside createPomMaterial: single height texture, parallaxDirection tangent frame, fixed 24-40 layers, [0,1] discard. Using it on a layered terrain (blended height maps, world-XZ ground frame, distance-faded depth) meant copying the loop out by hand. parallaxOcclusionUv(sampleHeight, options?) exposes the same linear search + binary refinement with: - a height-sampler callback (uv, ddx, ddy) so the field can be a blend, a select between layers, or fully procedural, with start-UV gradients available for mip pinning - caller-supplied startUv / viewDirTs / depthScale nodes, so any tangent frame works and depth can be faded with distance - minLayers/maxLayers/refinementSteps/minViewZ tuning, with a fixed layer count when min == max - edgeBehavior: 'discard' (single-tile, unchanged default) or 'none' for repeating surfaces createPomMaterial now calls it internally; behaviour is unchanged. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
Extracts the parallax-occlusion march out of
createPomMaterialinto a new exported TSL primitive:createPomMaterialis refactored on top of it — its behaviour and public API are unchanged.Why
I'm using this POM technique in a WebGPU terrain renderer, where the material-level API can't be used directly because the terrain needs:
select/blend between forest and moss displacement maps, not one texture. Solved with asampleHeight(uv, ddx, ddy)callback; the start-UV gradients are passed in so the callback can mip-pin with.sample(uv).grad(ddx, ddy).viewDirTsis caller-supplied instead of hard-wired toparallaxDirection.depthScaleaccepts any node, so it can be driven to zero with distance and the march exits on its first step.minLayers/maxLayers(equal = fixed count, the adaptive mix is skipped),refinementSteps,minViewZ, andedgeBehavior: 'none'for repeating surfaces where the[0,1]discard is wrong.Notes
@promontis/threejs-pom/parallaxOcclusionUv+ entry in the Vite lib config.npm run build(lib + demo) passes. No behaviour change for existing users — the default options reproduce the old constants exactly, including the discard.WebGPU/TSL context: tested against the same march running in a
MeshStandardNodeMaterialcolorNode graph onWebGPURenderer(Chrome, macOS).🤖 Generated with Claude Code