# \#uniforms

**URL:** https://discourse.threejs.org/tag/uniforms/410.md

[Latest](https://discourse.threejs.org/latest.md) · [Categories](https://discourse.threejs.org/categories.md) · [Tags](https://discourse.threejs.org/tags.md)

---

## [Can I make a TSL uniform node specific to a material, and not global?](https://discourse.threejs.org/t/can-i-make-a-tsl-uniform-node-specific-to-a-material-and-not-global/85864)

<div class="topic-metadata">

**Author:** [@torrent](https://discourse.threejs.org/u/torrent)\
**Replies:** 3\
**Last updated:** [April 20, 2026, 6:16pm UTC](https://discourse.threejs.org/t/can-i-make-a-tsl-uniform-node-specific-to-a-material-and-not-global/85864 "2026-04-20T18:16:06Z")

</div>

Let’s say I have a simple TSL node like this: const goGreen = tsl.uniform(0); const myTslNode = tsl.Fn(() =\> { const n = tsl.vec4().toVar(); tsl.If(goGreen.equal(1), () =\> { n.assign(tsl.vec4(0, 1, 0, 1…

---

## [TSL: How do I create a nullable texture uniform in TSL?](https://discourse.threejs.org/t/tsl-how-do-i-create-a-nullable-texture-uniform-in-tsl/87175)

<div class="topic-metadata">

**Author:** [@torrent](https://discourse.threejs.org/u/torrent)\
**Replies:** 18\
**Last updated:** [September 29, 2025, 4:38am UTC](https://discourse.threejs.org/t/tsl-how-do-i-create-a-nullable-texture-uniform-in-tsl/87175 "2025-09-29T04:38:54Z")

</div>

I’m trying to create a texture node that starts out null, but can be set later if needed. But, if I create this texture node: const mapNode = tsl.texture(null, tsl.uv(), null); I get the following error: Uncaught (in…

---

## [UBO - UniformBufferObject with onBeforeCompile on MeshStandardMaterial won't compile](https://discourse.threejs.org/t/ubo-uniformbufferobject-with-onbeforecompile-on-meshstandardmaterial-wont-compile/75359)

<div class="topic-metadata">

**Author:** [@dghez](https://discourse.threejs.org/u/dghez)\
**Replies:** 6\
**Last updated:** [May 13, 2025, 11:07pm UTC](https://discourse.threejs.org/t/ubo-uniformbufferobject-with-onbeforecompile-on-meshstandardmaterial-wont-compile/75359 "2025-05-13T23:07:03Z")

</div>

Hey there! I’m extending / updating an existing material (MeshStandard one) using the onBeforeCompile method. So far so good, done plenty of times but now i’m using uniformsGroup and apparently i cannot bind them onBef…

---

## [Sharing a NodeMaterial For Multiple Objects with Unique Uniforms](https://discourse.threejs.org/t/sharing-a-nodematerial-for-multiple-objects-with-unique-uniforms/77316)

<div class="topic-metadata">

**Author:** [@michealmyers81](https://discourse.threejs.org/u/michealmyers81)\
**Replies:** 3\
**Last updated:** [January 30, 2025, 4:00pm UTC](https://discourse.threejs.org/t/sharing-a-nodematerial-for-multiple-objects-with-unique-uniforms/77316 "2025-01-30T16:00:58Z")

</div>

I want to know how I can use one shared NodeMaterial for multiple objects, each with different uniforms. From what I’ve gathered on this forum, with the old material system, you could only achieve this using a ShaderMate…

---

## [What's the difference between \`UniformsGroup\` and \`UniformsGroup\`?](https://discourse.threejs.org/t/whats-the-difference-between-uniformsgroup-and-uniformsgroup/76834)

<div class="topic-metadata">

**Author:** [@trusktr](https://discourse.threejs.org/u/trusktr)\
**Replies:** 1\
**Last updated:** [January 22, 2025, 6:00am UTC](https://discourse.threejs.org/t/whats-the-difference-between-uniformsgroup-and-uniformsgroup/76834 "2025-01-22T06:00:13Z")

</div>

There are two of them: src/core/UniformsGroup.js and src/renderers/common/UniformsGroup.js. The one that seems internal is ironically documented, but the one exported from the lib is not documented (with JSDoc comments,…

---

## [Nodes - how to pass array of floats to wgslFn?](https://discourse.threejs.org/t/nodes-how-to-pass-array-of-floats-to-wgslfn/61797)

<div class="topic-metadata">

**Author:** [@geolehmann](https://discourse.threejs.org/u/geolehmann)\
**Replies:** 0\
**Last updated:** [February 22, 2024, 10:28am UTC](https://discourse.threejs.org/t/nodes-how-to-pass-array-of-floats-to-wgslfn/61797 "2024-02-22T10:28:55Z")

</div>

Hi everyone, as simple as the title says - how do I pass an array of floats to a wgslFn? Within the WGSL code I can receive the array as array\<\< f32 \>, count\> but I did not found any examples how to pass the array from …

---

## [How to access an \`uniformArray\` element using a \`Node\` object?](https://discourse.threejs.org/t/how-to-access-an-uniformarray-element-using-a-node-object/72803)

<div class="topic-metadata">

**Author:** [@Byloth](https://discourse.threejs.org/u/Byloth)\
**Replies:** 6\
**Last updated:** [October 16, 2024, 2:36pm UTC](https://discourse.threejs.org/t/how-to-access-an-uniformarray-element-using-a-node-object/72803 "2024-10-16T14:36:52Z")

</div>

Hi there, everyone. :wave: I’m quite new to Three.js and even more in TSL. I just started developing a digital version of a famous board game to get some confidence in Three.js; I immediately started using WebGPU even …

---

## [How do you set uTime inside useFrame in R3F for a shader?](https://discourse.threejs.org/t/how-do-you-set-utime-inside-useframe-in-r3f-for-a-shader/54400)

<div class="topic-metadata">

**Author:** [@Jo\_DeCore](https://discourse.threejs.org/u/Jo_DeCore)\
**Replies:** 8\
**Last updated:** [May 10, 2024, 7:10am UTC](https://discourse.threejs.org/t/how-do-you-set-utime-inside-useframe-in-r3f-for-a-shader/54400 "2024-05-10T07:10:37Z")

</div>

ive been trying to set uTime from my uniforms for my shader but i keep getting this typeset error HandTOPb.jsx?t=1690643611434:37 Uncaught TypeError: Cannot set properties of undefined (setting 'uTime') here is my code…

---

## [Cost of updating (many) uniforms](https://discourse.threejs.org/t/cost-of-updating-many-uniforms/59873)

<div class="topic-metadata">

**Author:** [@theahura](https://discourse.threejs.org/u/theahura)\
**Replies:** 3\
**Last updated:** [January 2, 2024, 8:00pm UTC](https://discourse.threejs.org/t/cost-of-updating-many-uniforms/59873 "2024-01-02T20:00:00Z")

</div>

Hey folks, had a performance intuition question. I have ~20 animation parameters that I want to interpolate based on some function of the elapsed time, ideally at 60fps. I could either: calculate the updated interpo…

---

## [How do I update node-material uniforms?](https://discourse.threejs.org/t/how-do-i-update-node-material-uniforms/54159)

<div class="topic-metadata">

**Author:** [@Attila\_Schroeder](https://discourse.threejs.org/u/Attila_Schroeder)\
**Replies:** 2\
**Last updated:** [July 21, 2023, 12:34pm UTC](https://discourse.threejs.org/t/how-do-i-update-node-material-uniforms/54159 "2023-07-21T12:34:07Z")

</div>

I finally want to understand the 3js node system a little better and for that I made this very small example. That works so far. const textureLoader = new THREE.TextureLoader(); const uvTexture = textureLoader.load( '..…

---

## [Clone a ShaderMaterial and Have Different Uniforms for Different Copies of the Material](https://discourse.threejs.org/t/clone-a-shadermaterial-and-have-different-uniforms-for-different-copies-of-the-material/49713)

<div class="topic-metadata">

**Author:** [@oldsegotia](https://discourse.threejs.org/u/oldsegotia)\
**Replies:** 3\
**Last updated:** [March 29, 2023, 12:30am UTC](https://discourse.threejs.org/t/clone-a-shadermaterial-and-have-different-uniforms-for-different-copies-of-the-material/49713 "2023-03-29T00:30:49Z")

</div>

Here’s a basic demo of a little something that I recently discovered and thought was pretty neat. You can clone a shader material and have different sets of uniforms for different copies of the material. In the followi…

---

## [THREE.UniformsLib\['lights'\] gives wrong light position?](https://discourse.threejs.org/t/three-uniformslib-lights-gives-wrong-light-position/36672)

<div class="topic-metadata">

**Author:** [@Brainafic](https://discourse.threejs.org/u/Brainafic)\
**Replies:** 0\
**Last updated:** [April 3, 2022, 10:17am UTC](https://discourse.threejs.org/t/three-uniformslib-lights-gives-wrong-light-position/36672 "2022-04-03T10:17:51Z")

</div>

Hi! I’m working on a shader that will take scene light data and use it to make light calculations in the shader. To pass the light data from the scene to the uniforms I am using: var u = THREE.UniformsUtils.merge( …

---

## [R118.1 to r127 shader problem](https://discourse.threejs.org/t/r118-1-to-r127-shader-problem/33961)

<div class="topic-metadata">

**Author:** [@UI\_UNICORN](https://discourse.threejs.org/u/UI_UNICORN)\
**Replies:** 2\
**Last updated:** [January 29, 2022, 11:11pm UTC](https://discourse.threejs.org/t/r118-1-to-r127-shader-problem/33961 "2022-01-29T23:11:04Z")

</div>

So I’m converting my project from r118.1 to r127 but I am getting this error message in r127: THREE.WebGLProgram: shader error: 0 35715 false gl.getProgramInfoLog invalid shaders THREE.WebGLShader: gl.getShaderInfoLog(…

---

## [Linking uniforms to getters](https://discourse.threejs.org/t/linking-uniforms-to-getters/26915)

<div class="topic-metadata">

**Author:** [@tfoller](https://discourse.threejs.org/u/tfoller)\
**Replies:** 1\
**Last updated:** [June 4, 2021, 8:55am UTC](https://discourse.threejs.org/t/linking-uniforms-to-getters/26915 "2021-06-04T08:55:07Z")

</div>

I don’t want to write a code to update uniform values directly, so is it OK with the library to use getter, like so: const uni\_color = { color: \[0.3, 0.0, 0.3\], get value() { const t = window.performance.now(); …

---

## [Per Object Uniforms](https://discourse.threejs.org/t/per-object-uniforms/9091)

<div class="topic-metadata">

**Author:** [@titansoftime](https://discourse.threejs.org/u/titansoftime)\
**Replies:** 21\
**Last updated:** [August 20, 2019, 5:42pm UTC](https://discourse.threejs.org/t/per-object-uniforms/9091 "2019-08-20T17:42:27Z")

</div>

OK so I have successfully been able to extend materials to use the same image for diffuse/normal/specular maps. My next step was to use the same image also for all diffuse variants. This is an example image: https://www…

---

## [Update material uniforms](https://discourse.threejs.org/t/update-material-uniforms/8141)

<div class="topic-metadata">

**Author:** [@ATHellboy](https://discourse.threejs.org/u/ATHellboy)\
**Replies:** 1\
**Last updated:** [June 18, 2019, 7:05am UTC](https://discourse.threejs.org/t/update-material-uniforms/8141 "2019-06-18T07:05:54Z")

</div>

Hey there, I want to update some of uniforms of my material after creating it. I use material.uniforms.targetUniform.value but there is an error which says material.uniforms is not defined. My material code: const fra…

---

## [Where in source code does ThreeJS perform updates to WebGL uniforms that are Objects?](https://discourse.threejs.org/t/where-in-source-code-does-threejs-perform-updates-to-webgl-uniforms-that-are-objects/6056)

<div class="topic-metadata">

**Author:** [@marquizzo](https://discourse.threejs.org/u/marquizzo)\
**Replies:** 2\
**Last updated:** [February 11, 2019, 11:20pm UTC](https://discourse.threejs.org/t/where-in-source-code-does-threejs-perform-updates-to-webgl-uniforms-that-are-objects/6056 "2019-02-11T23:20:21Z")

</div>

I’m trying to find out where in the source code does the ThreeJS engine perform automatic updates to shader uniforms that are objects (e.g., variables of type Vector3 or Color). Consider the following code. If I want to…

---

## [Uniforms: Arrays instead of vectors \[SOLVED\]](https://discourse.threejs.org/t/uniforms-arrays-instead-of-vectors-solved/1915)

<div class="topic-metadata">

**Author:** [@diniden](https://discourse.threejs.org/u/diniden)\
**Replies:** 5\
**Last updated:** [February 23, 2018, 12:40am UTC](https://discourse.threejs.org/t/uniforms-arrays-instead-of-vectors-solved/1915 "2018-02-23T00:40:09Z")

</div>

Is there anyway to have uniform values be Arrays instead of Vectors? Such as: "myUniform" : { type: "4fv", value: \[\[0, 1, 2, 3\], \[4, 5, 6, 7\]\] } I’ve been perusing around, but unable to find a way if there is.
