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: Using float(1e21) causes a shader syntax error, but uniform(1e21) does not #29560

Closed
PoseidonEnergy opened this issue Oct 5, 2024 · 0 comments · Fixed by #29562
Closed
Labels
Milestone

Comments

@PoseidonEnergy
Copy link
Contributor

PoseidonEnergy commented Oct 5, 2024

Description

Using the following TSL (Three.js Shading Language) node throws an error:

float(1e21)

but the following node does not:

uniform(1e21)

The reason I bring this up is because I noticed that the webgpu_camera_logarithmicdepthbuffer example on threejs.org uses 1e27 as the camera.far value, and camera.far is used in TSL nodes (as a uniform node). In the case that one day the camera.far value is not used in a uniform node, an error will be thrown.

Reproduction steps

  1. Use the node float(x) in a NodeMaterial where x is a number greater than or equal to 1e21.

Code

  const nodeMaterial = new THREE.NodeMaterial()
  nodeMaterial.colorNode = THREE.Fn(() => {
    const n = THREE.float(1e21); // <-- this throws an error
    //const n = THREE.uniform(1e21); // <-- this does not throw an error
    return THREE.vec3(n.mul(0), 0, 1)
  })()

Live example

https://jsfiddle.net/trm2onsy/2/

Screenshots

No response

Version

169

Device

Desktop

Browser

Chrome

OS

Windows

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants