-
-
Notifications
You must be signed in to change notification settings - Fork 36.1k
NodeMaterial: Using native code ShaderLib approach #18162
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
Conversation
|
This approach is very simple to implement extending natives materials with Using this approach we can add
...
#include <normal_fragment_begin>
#include <normal_fragment_maps>
// used for index the snippets of the NodeMaterial normal code
#include <normal_fragment_nodes>
...Final user: // native material
var material = THREE.MeshStandardMaterial();
// node extension
material.normal = new Nodes.NormalMapNode( new Nodes.TextureNode( texture ) );
|
|
Would it be much trouble to include the suggested changes to the core library (just WebGLRenderer?) as well? I am having trouble understanding the tradeoffs here — do you agree with these claims about the PR?
On (3), in particular, I cannot guess by looking at the PR. 😇 Are there other pros/cons I've missed?
Which features do you think would be incompatible? Or which inputs become more limited? It sounds like the proposal would also mean adding various properties to the Material classes, so for example users might choose between: // Used only if .roughnessNode is not set?
material.roughness = ...;
material.roughnessMap = ...;
// If set, both .roughness and .roughnessMap are ignored?
material.roughnessNode = ...;I would be curious what @mrdoob thinks of this API? Or would the user set a node on the existing Finally, do you think it would be possible to implement this without having the core material classes actually import anything from // my-application.js
import { FloatNode, NodeBuilder } from 'three/examples/jsm/nodes/nodes.js';
material.roughnessNode = new FloatNode( 0.5 );
material.setNodeBuilder( new NodeBuilder() );// MeshStandardMaterial.js
MeshStandardMaterial.prototype.build = function ( shader, renderer ) {
const main = 'void main() {';
const builder = this.nodeBuilder;
const nodes = builder.createNativeNode( 'standard' );
nodes.color = this.color;
builder.setMaterial( this, renderer );
builder.build( nodes, nodes );
...
}I don't know exactly what we decided about all of |
[1,2,3] Yes, with all of them. And about (2) include
Its replace in runtime
The Before of this commentary ( #18162 (comment) ), adding
I think that we can add a minimalist code of
Its is interessating, I think initialy detect and replace native uniforms in case of use some // Add .roughness uniform if this is not Node ( default )
material.roughness = 1;
// .roughness uniform is replaced for a variable ( uniform property is removed )
material.roughness = new Nodes.TextureNode( texture ); |
|
Thanks, the limitations you mention seem totally fine. So the material properties would be something like: class MeshStandardMaterial {
color: Node | Color;
map: Texture;
opacity: Node | number;
roughness: Node | number;
roughnessMap: Texture;
metalness: Node | number;
metalnessMap: Texture;
normal: Node;
normalMap: Texture;
ao: Node;
aoMap: Texture;
aoMapIntensity: number;
environment: Node;
envMap: Texture;
envMapIntensity: number;
}Is everyone OK with that API? @mrdoob @bhouston It seems mostly clear and readable to me. But some existing code will obviously break if given a material that has nodes where primitives used to be, and support for nodes in places like OBJExporter and GLTFExporter will probably take a while.
Sounds good to me. If the nodes themselves don't have to be part of the core library that's definitely a benefit, so users can write their own Node classes. |
|
We'd need |
I think that . |
|
Agreed, I forgot about In addition to that, we might still want |
|
After this PR ( #18399 ) some modification has necessary in This still is a WIP but I think that the way is this. |
|
All material / variations node material test: Live here: |
|
I think this issue is being better resolved and continued in the new node material system. |



I have this idea recently, I will mature this, basically, this use 100% native shader code with support to
NodeMaterialin some inputs that non use texture uniforms like:color,opacity, etc.Its replace in runtime
uniform vec3 diffusetovec3 diffuseand add the code relative ofcolorinput aftermain(){and relative nodeuniform, vars and etc. This approach is compatible with almost all features ofNodeMaterial.The implementation in core will be more simple since it does not modify the core shader but be more limited with relation at some inputs.
Is necessary change the uniform logic inside of
WebGLRenderer.Final code should be:
Live here:
https://raw.githack.com/sunag/three.js/dev-node-native-live/examples/index.html?q=variations#webgl_materials_variations_toon
WIP
/cc @bhouston @mrdoob @WestLangley @Mugen87 @donmccurdy ...