I’ve been working with the node system for some time and have gotten to know it quite well. I know how to use the uniform, attributes, texture, and many other nodes. But I’m still missing a very important element from the webgl world (varyings or in/out in webgl2).
There is a varyingNode but I admit I don’t yet understand how to use it in conjunction with wgslFn nodes.
Here I have a simple schema with a vertexFn and a fragmentFn. The analogies to webgl are clear. The node system makes the use of wgsl noticeably easier because you don’t have to specify all the bindings and locations yourself.
const vertexFn = wgslFn(`
fn mainVertex (
// uniforms, attributes, textures, ... from shaderParams
) -> vec4<f32) {
...myVarying = ...; //set varying ?
}
`);
const fragmentFn = wgslFn(`
fn mainFragment (
// uniforms, attributes, textures, ... from shaderParams
) -> vec4<f32> {
...myVarying; //get varying ?
}
`);
const shaderParams = {
// uniforms, attributes, textures, ...
}
const material = new MeshBasicNodeMaterial();
material.positionNode = vertexFn(shaderParams);
material.colorNode = fragmentFn(shaderParams);
Has anyone had experience with the varyingNode in conjunction with the wgslFn node?
I want to set a varying in the vertexFn and I want to use it in the fragmentFn. Completely analogous to how to use a varying in webgl (in/out in webgl2)