-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Three.JS Shader Language Proposal #17321
Conversation
Demo doesn't work on Firefox. Console error is
|
@takahirox Thanks updated! I update the description. Unfortunately, I did not get good results on firefox, only Chrome Windows, you tested on Mac? |
On Android chrome: StandardNodeMaterial: 1.07s MeshStandardMaterial: 0.769s |
It's safe to assume that a GLSL parser will be a bit slower than the current (pre-NodeMaterial) approach. Whether it would ultimately be faster or slower to construct shaders than NodeMaterial today, I'm not sure. For the sake of discussion let's set strict parsing performance aside for a moment, or just assume the problem could be solved by enabling users to precompile their node materials somehow. The remaining motivations you mention are interesting ones — some of them I understand, and some I do not:
Is the goal here easier shader authoring for developers, similar to #17105? I agree that the closer we are to GLSL, the easier that shader creation will be for developers comfortable with GLSL. Creating a dialect for threejs with namespaces and macros, I'm undecided about – it simplifies some things and makes other things more complicated. #17105 seemed like a good improvement already. There is another subset of developers and artists who are not comfortable writing GLSL, for whom I would still love to provide a workflow with a UI node graph editor. Whether that means an official UI for creating threejs shaders, or support for loading node graphs created in other tools, I'm not sure. Related: MaterialX Standard Nodes,THREE.ShadeNodeLoader.
I don't understand this item. Do you mean it allows better sharing of GLSL chunks between existing materials and NodeMaterials? Or how does it help with merging NodeMaterial to core?
Simplifying how NodeMaterial works, or simplifying how developers would use NodeMaterial? This PR adds 1000 lines to
Yes; I don't know enough here to say how much easier, but intuitively this makes sense. Summary — I'm undecided about this proposal. I understand some of the potential benefits, but it also sounds more complex to maintain and debug to me. If you disagree and are pretty sure it's cleaner, I'm glad to discuss that more. Otherwise, I'm hoping there is a good path to moving more users over to NodeMaterial without going quite this far, quite yet. |
I tested on Windows + Firefox. Yeah, the new system is slower than the current one. Node Material System Current Material System |
Yeah. The parser performance in non-Windows+Chrome can be improved caching the
The idea of simply was not done effectively, that would be closer to brainstorm and a preview of the code, than the proposed result. An example in case of include nodes in the core, for example, is auto-convert natives to node-input if this is set in properties, like // its check is some node is implemented in native uniform
// if is node is converted and moved automatically to main() code
node uniform float roughness; For this not need to change the current chunks only implementing the compiler. glsl parser in other contextThe good news of this is that I did not design thinking about implementing in the core but in NodeMaterial, not like this one, on this PR, but using For example: Code like this that are complex to do using many Nodes, can be done writing complex nodes only using GLSL code, so it is not necessary to create complex nodes like this approach: https://github.com/mrdoob/three.js/blob/dev/examples/jsm/nodes/misc/TextureCubeUVNode.js, it can be reused directing of the core code, for example.
It is just an idea that I proposed, I have not great intentions to continue this outside of the context of @donmccurdy Thank very much your feedback. |
I commit the
And other improvements that I will document later... I will work on it now to sync native |
Some motivations
GLSL
chunk
core conversion forNodes
andNodeMaterial System
( I think that the last hard change to merger NodeMaterial to the core )
More performanceOptimization
EDITED -> CHROME WINDOWS ONLY
The flow system of the parser optimize GLSL call tree, I make a test optimizing using
NodeMaterial
(current performance 1/1), adding the parse, its excluding functions and properties not used in code. The result was 2x at 3x faster (2.5~/1) than the current material.Link to benchmark
https://rawgit.com/sunag/three.js/dev-shader-parser/examples/webgl_performance_nodes.html?count=10
count=10 program per material
Namespace Proposal
The idea is to replace the chunks for namespaces, making it more organized and clean to work.
For example:
Example source-code only ( Open console )
https://rawgit.com/sunag/three.js/dev-shader-parser/examples/webgl_nodes.html
Example
Material property preprocessor
Now we no longer have to worry about hiding functions using
defines
since we havenamespace
. The idea is to use the samepreprocessor
to detect materials properties in shader code, using#ifprop
for example.CODE IS WIP