TSL texture( uniform(map), uv() ) not working
Makio64 opened this issue ยท 7 comments
Description
The current texture
node don't work if the it's an uniform pass as the first element.
Reproduction steps
- see code bellow
Code
const txt = await new TextureLoader().loadAsync( url )
const map = uniform( txt )
texture( map , uv() ) // don't work
texture( map.value , uv() ) // work
Live example
Screenshots
No response
Version
r170
Device
No response
Browser
No response
OS
No response
texture( uniform(texture) )
What is your motivation for this syntax? At first sight, it seems like a user error to me.
@Mugen87 it was an example but the motivation is to use the uniform node and not his value ( which isnt a node but a Texture ) .
in glsl:
uniform sampler2D map;
vec4 t = texture2D( map, vUv ) // if i change map.value , the new uniform is push and everything works.
in tsl :
const map = uniform( txt )
texture( map , uv() ) // will update automatically as it's the goal of uniform
texture( map.value , uv() ) // will not update automatically and material.needsUpdate require cause value is a js variable not a node
Map.value is not a Node so it will not update with the current synthax and we need to call material.needsUpdate , uniform accepted will fix this issue
I think the example below should work without needing material.needsUpdate
const node = texture( map , uv() );
node.value = txt; // update the texture
@sunag @Mugen87 : here an example demonstrating the error : https://jsfiddle.net/Makio64/yk5u1h7f/
code :
let map = new THREE.TextureLoader().load('https://threejs.org/examples/textures/crate.gif')
let uMap = uniform( map )
material.colorNode = texture( uMap, uv() ) // work with map, dont work with uMap
TextureNode
is extended from UniformNode
, this is not a bug. You can use the above example to update your texture without needing material.needsUpdate
( #29974 (comment) ) or create multiple samples using const newSample = textureNode.uv( newUV )
which will be renamed to .sample( uv )
soon.
which will be renamed to
.sample( uv )
soon
๐๐๐
@sunag sorry but there is a bug , check my jsfiddle to see it : https://jsfiddle.net/Makio64/yk5u1h7f/
texture( myUniform) // problem using uniform if its a Texture
But in other node i can do for example :
step( myUniform, 0.5 ) // no problem using the uniform if its a float