With all of this being said, you can probably achieve something like this already, either with
mesh.onBeforeCompile or drawGroup thingie which i haven’t used. I believe that it is possible to assign an array of materials to a mesh, and then have the mesh render itself several times. This could also be achieved by manually managing the render order through the scene graph:
NodeMaterial becomes available. It will allow you to, instead of this:
float foo = a + b / c;
const a = new THREE.FloatNode( 1 )
const b = new THREE.FloatNode( 2 )
const c = new THREE.FloatNode( 3 )
const foo = new THREE.OperatorNode(
(I think i got it right at least, there is absolutely no documentation.)
IMO this API should not be supported by the core of three.js. Conceptually it may not make sense to include something like this on a medium such as the web, because it introduces disproportionately more overhead for parsing shaders. In addition to the driver compiling and the string manipulation, this whole graph has to be traversed and logic applied to it. There are probably lot’s of uses (like games) where you don’t want this happening at run time but would a more compact shader representation closer to what webgl actually consumes (a string).
Besides these technical challenges, there’s the issue of excluding a fair amount of three.js contributors from contributing.
If you take a look at the first page of three.js open PR’s you’ll notice that they range from a few additional lines to a few dozen.
NodeMaterial PRs touch over 100 files and 10.000 (ten thousand) lines of code. I don’t consider myself a very experienced engineer, but i have some experience, and that experience tells me that large diffs are hard to read.
Unfortunately the standard is much higher:
If you do not have the skills to do that by studying webgl_materials_nodes.html and reading the source, you should not be a developer on this project.
This API sets the bar extremely high IMO. If you are unable to follow what is going on in these 103 files and almost 10k lines of code, you won’t be able to contribute to anything material related. I’m not an expert, but i know some GLSL and i can read the shaders in three.js. Obfuscating it behind this API, makes that a lot harder and may close that door.
Note that this above is just part 1 of the diff, there is another one with 8500 lines changed:
It is being aggressively pushed as a cure for a lot of issues that three.js suffers from. I can’t do anything to stop this, but I can try to argue against it, wherever this push is made. I also am aware of how careful one has to be, since this issue has prompted threats of ban’s from both the repo and this forum. So I mean this as no offense to anyone and am trying to be as constructive and objective (albeit blunt) as possible. Thank you.