Open aardgoose opened 2 months ago
I had a few issues with cond()
as well when porting code to TSL. Out of curiosity, does it work if the code is change to the following?
const lineDistance = float( 0 ).toVar();
If( positionGeometry.y.lessThan( 0.5 ), () => {
lineDistance.assign( dashScaleNode.mul( instanceDistanceStart ) );
} ).else( () => {
lineDistance.assign( materialLineScale.mul( instanceDistanceEnd ) );
} );
Yes and no (with a float( 0 ).toVar();
It doesn't produce an invalid shader, but doesn't work as expected. Presumably because If() uses cond() internally.
Ah yes, the toVar()
is required in this case.
In any event, this was just intended as a possible workaround. Of course it's best to make the normal cond()
usage work.
Description
The PR #28585 appears to have broken Line2NodeMaterial. Reverting the PR fixes the error.
In dashed mode, the fragment shader fails to compile with the error in
https://github.com/mrdoob/three.js/blob/0679c557066907c19659697deaa3d2d0b0c7e724/src/nodes/materials/Line2NodeMaterial.js#L269
If the multiplications within the cond() expression are removed, the shader compiles as expected.
Reproduction steps
Code
n/a
Live example
Line2NodeMaterials example
Screenshots
No response
Version
166
Device
No response
Browser
No response
OS
No response