diff --git a/examples/jsm/shaders/VolumeShader.js b/examples/jsm/shaders/VolumeShader.js index cf6a710fa1a41c..48ae0ac8007f39 100644 --- a/examples/jsm/shaders/VolumeShader.js +++ b/examples/jsm/shaders/VolumeShader.js @@ -134,6 +134,8 @@ const VolumeRenderShader1 = { vec4 apply_colormap(float val) { val = (val - u_clim[0]) / (u_clim[1] - u_clim[0]); + float n = float(textureSize(u_cmdata, 0).x); // see #33842 + val = (val * (n - 1.0) + 0.5) / n; return texture2D(u_cmdata, vec2(val, 0.5)); } diff --git a/src/nodes/accessors/Batch.js b/src/nodes/accessors/Batch.js index 20a9d48a3c94fe..ab62e98dadab25 100644 --- a/src/nodes/accessors/Batch.js +++ b/src/nodes/accessors/Batch.js @@ -13,7 +13,7 @@ import { varyingProperty } from '../core/PropertyNode.js'; * * @param {Node} colorsTexture - The colors texture. * @param {Node} id - The instance or batch ID. - * @returns {Node} The retrieved color. + * @returns {Node} The retrieved color. */ const getBatchingColor = /*@__PURE__*/ Fn( ( [ colorsTexture, id ] ) => { @@ -21,7 +21,7 @@ const getBatchingColor = /*@__PURE__*/ Fn( ( [ colorsTexture, id ] ) => { const j = int( id ); const x = j.mod( size ).toConst(); const y = j.div( size ).toConst(); - return textureLoad( colorsTexture, ivec2( x, y ) ).rgb; + return textureLoad( colorsTexture, ivec2( x, y ) ); } ); @@ -44,9 +44,9 @@ const getIndirectIndex = /*@__PURE__*/ Fn( ( [ indirectTexture, id ] ) => { /** * TSL object representing a varying property for the batching color vector. * - * @type {VaryingNode} + * @type {VaryingNode} */ -export const batchColor = /*@__PURE__*/ varyingProperty( 'vec3', 'vBatchColor' ); +export const batchColor = /*@__PURE__*/ varyingProperty( 'vec4', 'vBatchColor' ); /** * TSL function representing the vertex shader batching setup.