Open vorg opened 2 years ago
Another use case for more structured shader code is similarity to shader graph nodes
module.exports = (node, graph) => {
const vec3In = node.in("vec3", [1, 1, 1, 1]);
const xOut = node.out("x", 1);
const yOut = node.out("y", 1);
const zOut = node.out("z", 1);
node.sg = {
ins: {
vec3: { type: "vec3", port: vec3In },
},
outs: {
x: { type: "float", port: xOut },
y: { type: "float", port: yOut },
z: { type: "float", port: zOut },
},
code: (sg) => `
${sg.outs.x.type} ${sg.outs.x.var} = ${sg.ins.vec3.var}.x;
${sg.outs.y.type} ${sg.outs.y.var} = ${sg.ins.vec3.var}.y;
${sg.outs.z.type} ${sg.outs.z.var} = ${sg.ins.vec3.var}.z;
`,
};
};
It looks like BabylonJS doesn't care about this kind of issues and have most shaders still in GLSL100 with some in GLSL300.
Another thing to consider is not only how you create the source code but also how you provide all those attributes and uniforms (buffers).
In WebGL you have attributes and uniforms In WebGL2 you have attributes, uniforms and uniform buffers In WebGPU you have bindings (to uniform buffers, textures and vertex buffers)
To make this transition manageable i propose following steps
The questions is why would we need that?