From 7b31083d56bfa14347c89a480b1995f89631737e Mon Sep 17 00:00:00 2001 From: Christian Helgeson <62450112+cmhhelgeson@users.noreply.github.com> Date: Wed, 4 Jun 2025 01:43:33 -0700 Subject: [PATCH] NodeBuilder - Fix Interpolation (#31222) * init branch * fix * remove comment * Update GLSLNodeBuilder.js Clean up. --------- Co-authored-by: Michael Herzog --- examples/webgpu_centroid_sampling.html | 12 ++++++------ src/constants.js | 4 ++-- .../webgl-fallback/nodes/GLSLNodeBuilder.js | 4 +--- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/examples/webgpu_centroid_sampling.html b/examples/webgpu_centroid_sampling.html index d22aabffe63fe1..f562353ee36bde 100644 --- a/examples/webgpu_centroid_sampling.html +++ b/examples/webgpu_centroid_sampling.html @@ -158,8 +158,8 @@ }; - const withFlatFirstShader = createShader( THREE.InterpolationSamplingType.FLAT, THREE.InterpolationSamplingMode.FLAT_FIRST ); - const withFlatEitherShader = createShader( THREE.InterpolationSamplingType.FLAT, THREE.InterpolationSamplingMode.FLAT_EITHER ); + const withFlatFirstShader = createShader( THREE.InterpolationSamplingType.FLAT, THREE.InterpolationSamplingMode.FIRST ); + const withFlatEitherShader = createShader( THREE.InterpolationSamplingType.FLAT, THREE.InterpolationSamplingMode.EITHER ); const withSampleShader = Fn( () => { @@ -235,16 +235,16 @@ THREE.InterpolationSamplingMode.NORMAL, THREE.InterpolationSamplingMode.CENTROID, THREE.InterpolationSamplingMode.SAMPLE, - THREE.InterpolationSamplingMode.FLAT_FIRST, - THREE.InterpolationSamplingMode.FLAT_EITHER + 'flat first', + 'flat either' ] ).onChange( () => { const interpolationShaderLib = { [ THREE.InterpolationSamplingMode.NORMAL ]: withoutInterpolationShader, [ THREE.InterpolationSamplingMode.CENTROID ]: withInterpolationShader, [ THREE.InterpolationSamplingMode.SAMPLE ]: withSampleShader, - [ THREE.InterpolationSamplingMode.FLAT_FIRST ]: withFlatFirstShader, - [ THREE.InterpolationSamplingMode.FLAT_EITHER ]: withFlatEitherShader + [ 'flat first' ]: withFlatFirstShader, + [ 'flat either' ]: withFlatEitherShader }; const shader = interpolationShaderLib[ effectController.sampling ]; diff --git a/src/constants.js b/src/constants.js index 77bc2613c0583d..7a6334e3870b7e 100644 --- a/src/constants.js +++ b/src/constants.js @@ -1612,8 +1612,8 @@ export const InterpolationSamplingMode = { NORMAL: 'normal', CENTROID: 'centroid', SAMPLE: 'sample', - FLAT_FIRST: 'flat first', - FLAT_EITHER: 'flat either' + FIRST: 'first', + EITHER: 'either' }; /** diff --git a/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js b/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js index da2f96f8911a88..226d5d29c1599a 100644 --- a/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +++ b/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js @@ -30,9 +30,7 @@ const interpolationTypeMap = { }; const interpolationModeMap = { - 'centroid': 'centroid', - 'flat first': 'flat', - 'flat either': 'flat' + 'centroid': 'centroid' }; const defaultPrecisions = `