Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TSL texture reading / passed as argument in Fn does not work #30133

Open
Samsy opened this issue Dec 16, 2024 · 0 comments
Open

TSL texture reading / passed as argument in Fn does not work #30133

Samsy opened this issue Dec 16, 2024 · 0 comments
Labels
TSL Three.js Shading Language

Comments

@Samsy
Copy link
Contributor

Samsy commented Dec 16, 2024

Description

Hello there !

Sampling a texture via inline materialnode look straightforward :

const uTex = texture( tex );

material.colorNode = uTex.sample(oneMinus( uv() ));

Using Fn and passing a texture as argument makes it challenging and not working ( tdisp.sample is not a function ) :

 const sampleTex = Fn(([tdisp])=> {
    
      	return tdisp.sample(oneMinus( uv() ) )
        
}).setLayout( {
        name: 'sampleTex',
        type: 'float',
        inputs: [
          {
            name: "sampleTex",
            //type: "texture"
            type: "sampler2D"
          }
        ]
} )


material.colorNode = Fn(()=>{

        return sampleTex(uTex)

})()

Been looking at the example folder, and there is no example of passing a texture in a Fn

The transpiler gives wrong results :

Screenshot 2024-12-16 at 11 02 45

But also, it all seems unclear how to use textures as uniforms / in nodes,

To test you can move the CASE variable from 0 to 1

Live example

https://jsfiddle.net/0w3mhbfa/107/

Screenshots

No response

Version

last

Device

Desktop

Browser

Chrome

OS

MacOS

@Mugen87 Mugen87 added the TSL Three.js Shading Language label Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
TSL Three.js Shading Language
Projects
None yet
Development

No branches or pull requests

2 participants