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: Array of vectors as uniform. #28878

Closed
Mugen87 opened this issue Jul 15, 2024 · 3 comments
Closed

TSL: Array of vectors as uniform. #28878

Mugen87 opened this issue Jul 15, 2024 · 3 comments
Labels
TSL Three.js Shading Language

Comments

@Mugen87
Copy link
Collaborator

Mugen87 commented Jul 15, 2024

Description

For the port of PoissonDenoiseShader it's necessary to pass an array of vec3 into the shader. Can this be done with uniform() already? Something like:

this.vectors = uniform( [ new Vector3( 1, 0, 0 ), new Vector3( 0, 1, 0 ), new Vector3( 0, 0, 1 ) ]  );

The above code produces the following runtime error when I try to access a vector via this.vectors.element( i ).

Error: Uniform "null" not declared.

@Mugen87 Mugen87 added the TSL Three.js Shading Language label Jul 15, 2024
@cmhhelgeson
Copy link
Contributor

cmhhelgeson commented Jul 15, 2024

Unless I'm mistaken, the uniforms() function ( exported from nodes/accessors/UniformsNode.js ) allows you to do this.

#27706

I do think it would be nice if the functionality of UniformNode and UniformsNode was unified in a single call to the uniform function, which may be as simple as constructing the requisite node object depending on whether the argument passes the Array.isArray check. I'm not sure there's a reason the end user would want to differentiate between using uniform() or uniforms().

@Mugen87
Copy link
Collaborator Author

Mugen87 commented Jul 15, 2024

uniforms() does the trick, thanks!

@Mugen87 Mugen87 closed this as completed Jul 15, 2024
@Mugen87
Copy link
Collaborator Author

Mugen87 commented Jul 16, 2024

I'm not sure there's a reason the end user would want to differentiate between using uniform() or uniforms().

That's indeed a good point.

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