-
-
Notifications
You must be signed in to change notification settings - Fork 36k
Closed
Labels
TSLThree.js Shading LanguageThree.js Shading Language
Milestone
Description
Description
I'm currently trying to port the FXAA shader to TSL. The code uses more than one return
statement to return a color value computed in its FxaaPixelShader()
function.
Using an If()
statement in TSL to determine if a return is required produces a WGSL error though.
Error while parsing WGSL: :40:3 error: return statement type must match its function return type, returned 'vec4', expected 'OutputStruct'
return vec4( 1.0, 0.0, 0.0, 1.0 );
^^^^^^
I have reproduce the issue with a live example by writing a simple effect that output just two colors depending on how an if statement evaluates.
Reproduction steps
- Go to https://jsfiddle.net/pq2dtag3/
- Check browser console.
Code
class CustomEffectNode extends TempNode {
constructor() {
super();
}
setup() {
const effect = tslFn( () => {
If( uv().x.lessThan( 0.5 ), () => {
return vec4( 1, 0, 0, 1 );
} );
return vec4( 0, 0, 1, 1 );
} );
const outputNode = effect();
return outputNode;
}
}
Live example
https://jsfiddle.net/pq2dtag3/
Screenshots
No response
Version
r167dev
Device
Desktop
Browser
Chrome
OS
MacOS
Metadata
Metadata
Assignees
Labels
TSLThree.js Shading LanguageThree.js Shading Language