-
-
Notifications
You must be signed in to change notification settings - Fork 35.9k
Closed
Labels
Milestone
Description
Description
The GLSL to TSL transpiler turns multiplications with negative numbers into subtractions if they are not surrounded by parenthesis.
The GLSL code
float correct = 1.0 * (-1.0);
float wrong = 1.0 * -1.0;
is transpiled to the obviously wrong result:
// Three.js Transpiler r177
import { float, mul } from 'three/tsl';
const correct = float( mul( 1.0, float( - 1.0 ) ) ).toVar();
const wrong = float( 1.0 - 1.0 ).toVar();
The same issue occurs for vector (and matrix?) data types when they are multiplied by a negative number.
Reproduction steps
- Copy the above example into the TSL transpiler.
Code
GLSL code that gives wrong transpilation result:
float correct = 1.0 * (-1.0);
float wrong = 1.0 * -1.0;
Live example
TSL transpiler (copy the code from above).
Screenshots
No response
Version
r177
Device
Desktop
Browser
Firefox
OS
MacOS