Open
Description
Description
Using setLayout with Fn makes uniform usage broken.
Whether uniform is defined within the function or outside is not relevant.
Tested both with WebGPU and WebGL fallback.
Works if setLayout function is not used.
Reproduction steps
See code.
Code
const testColor = Fn(() => {
const tint = uniform(vec4(1,0,0,1)).label('tint');
return vec4(1, 1, 1, 1).mul(tint);
}).setLayout({
name: 'testColor', type: 'vec4',
inputs: [],
});
...
testMaterial.fragmentNode = testColor();
Result
// Error while parsing WGSL: :23:45 error: unresolved value 'object'
// Three.js r177 - Node System
// global
diagnostic( off, derivative_uniformity );
// structs
struct OutputStruct {
@location(0) color: vec4<f32>
};
var<private> output : OutputStruct;
// uniforms
// codes
fn testColor ( ) -> vec4<f32> {
return ( vec4<f32>( 1.0, 1.0, 1.0, 1.0 ) * object.tint );
}
@fragment
fn main( ) -> OutputStruct {
// vars
// flow
// code
// result
output.color = testColor( );
return output;
}
Live example
N/A
Screenshots
No response
Version
three 0.177.0
Device
No response
Browser
No response
OS
No response