I have many SkinnedMesh characters using a custom ShaderMaterial,
which interprets a particular quad as a camera-facing “label” naming each character.
A label amounts to rendering some words using some font, and they are collectively packed as a single texture which is passed to the shader.
If we spawn a new character and re-pack the labels, the new packing needn’t extend the old one. Then potentially we might need to update the label-uv-mapping for every character.
Is it possible to update a single uniform (e.g. a DataTexture) which is shared by all the programs?
Cheers for any help,
Rob
Yeah. You can do like:
let mySharedUniform={
value: myDataTexture
}
material1.uniforms.dataTexture = mySharedUniform
material2.uniforms.dataTexture = mySharedUniform
you can also make it a getter:
let timeUniform={
get value(){ return performance.now()/1000; }
}
shader1.uniforms.time = timeUniform
shader2.uniforms.time = timeUniform
3 Likes
Thanks @manthrax.
If we change the uniform, will it be re-uploaded exactly once, or once for each material instance?
I’m talking about the DataTexture here, not your nice epoch-seconds example.
Once. The DataTexture itself stores contains its (single) gpu handle.
1 Like