-
-
Notifications
You must be signed in to change notification settings - Fork 35.6k
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
Auto NodeMaterial build #14214
Auto NodeMaterial build #14214
Conversation
examples/webgl_sprites_nodes.html
Outdated
@@ -278,7 +275,7 @@ | |||
|
|||
// unserialize |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"deserialize"
Wait... still missing a little revision in sprites. |
I think i like this, the reasoning being there is no need to change I advocate for more of these hooks with meaningful names to be in the core, so |
The code result three.js/src/renderers/WebGLRenderer.js Line 1439 in f2c4cfe
|
|
This approach is good for you guys? I can fix |
three.js/src/renderers/WebGLRenderer.js Line 1439 in f2c4cfe
this part also generates a lot of extra CPU load and garbage, as you basically end up generating 2 strings for the shaders, and for some usecases it happens an awful lot (at least once per frame per material). |
So the problem is that
I'm not yet familiar with |
Not quite. That's part of it, but really, for me, the problem is that shader doesn't change at all, WebGLRenderer assumes it might have, those assumptions are bad, then to check those assumptions it constructs the It's not related to the commit here. Just an observation of mentioned code. see more detail here: #14121 |
But if add a simple The idea used in approach is based on top this: #11475 |
I still not find a good approach to fix |
@sunag Sorry, but for now, I need to defer to others regarding Node. Thank you for all your work on this. |
@WestLangley No problems! 👍 |
Good news. WIP I create a There is still a slight difference in brightness that I will check. Use: ( not need material = new THREE.MeshStandardNodeMaterial();
material.roughness = 1; // attenuates roughnessMap
material.metalness = 1; // attenuates metalnessMap
material.map = loader.load( 'Cerberus_A.jpg' );
// roughness is in G channel, metalness is in B channel
material.metalnessMap = loader.load( 'Cerberus_RM.jpg' );
material.roughnessMap = loader.load( 'Cerberus_RM.jpg' );
material.normalMap = loader.load( 'Cerberus_N.jpg' ); |
// cc @bhouston |
I maintain this sequence or change to three.js/src/renderers/WebGLRenderer.js Lines 1975 to 1981 in f2c4cfe
/cc @WestLangley @mrdoob |
We need a UVTransform per texture for proper glTF compatibility as well as proper FBX compatibility. /ping @donmccurdy |
There is a gap in the core implementation here, and if possible we should not repeat it in NodeMaterial. See #12788 for details, but the gist is that cloning a texture and assigning a new transform results in a duplicate texture upload. Even if that were fixed, I think it's better to represent the UVTransform elsewhere, at the per-map conceptual level rather than per-texture. There is not exactly a "map" concept in NodeMaterial today, but |
@donmccurdy I did solve that issue with my unmerged PR from 2016 that added multiple UV Transform support via the introduction of a "Map" between Textures and Materials: https://github.com/mrdoob/three.js/pull/8278/files#diff-cea5a42c1c15fd23dde252730d82e223 And then every texture in a material got a Map that specified the UV and Texel tansforms. I thought it was elegant and would encourage a similar structure going forward. Better link: https://github.com/bhouston/three.js/blob/94290c538caffeac12f8c644d8d867907232f63a/src/materials/Map.js |
Yes, I believe that's the right idea, or whatever form it translates into with nodes. :) |
|
I mean to say that a |
Only considering that per texture is a uvTransform per map. For example: vUvMap = ( uvTransformMap * vec3( uv, 1 ) ).xy;
vUvSpecular = ( uvTransformSpecular * vec3( uv, 1 ) ).xy;
vUvNormal = ( uvTransformNormal * vec3( uv, 1 ) ).xy; This does not seem very optimized. // MeshStandardNodeMaterial a hybrid material, it works both with backward-compatible as nodes
var material = new THREE.MeshStandardNodeMaterial();
var texture = loader.load( 'Cerberus_RM.jpg' )
// not use uvTransform per texture but backward-compatible, avoiding many uvTransform
material.roughness = 1;
material.roughnessMap = texture;
// or use uvTransform in an specific texture in same material
var uv = new THREE.UVTransformNode( new THREE.UVNode(), new THREE.Matrix3Node( texture.matrix ) );
material.roughness = new THREE.TextureNode( texture, uv ); |
In fact is very similiar with my approach. |
Hello fellow three.js aficionados! Over the years, users have been confused about the design of this system. Would you consider discussing the topic around this:
Outside of the Discussing them and making decisions here might obscure them from some people. Thank you! I for example have no stake in the I would like to discuss what a future mapping/texturing system could look like (or at least follow that discussion) but not participate in the shader graph conversation. I hope this makes sense. Thank you! |
The reasoning behind this is: When i read "Auto NodeMaterial build", I can't even fathom that #12788 would actually be discussed here. I correctly assumed it would have something to do with refreshing updating There are other authoring tools and engines, i'd like to post these shots somewhere: (texture properties in 3ds max) These screenshots most likely don't belong here since this topic is on "auto building" and not "anything related with textures", but since you're having the discussion here i would like to participate. Three.js is a complex system, and there are many issues and PRs here, if it's not sorted out and categorized properly it will be really hard for people to participate. If i didn't know any better i'd say you l33t people are kinda hiding here 🤣 ❤️ |
I had assumed we were just discussing texture transformations for NodeMaterial, and that @sunag was not planning to change the non-NodeMaterial implementation at all here. I would love to see the issues in #12788 solved generally, so if that's the intention, great! But I expect that is too complex to tackle here. For example #8278 would solve much of that, but is fairly complex and hasn't been merged. Better not to duplicate that in this PR. |
I'm suggesting to break diffs into smaller ones so they can be used better as bread crumbs. Eventually once you move this into As is i can't find why texture transforms and texture images work as is. So if this is for auto building (possibly a different term for If doing this according to the current state of the world (list of priorities) ends up being an issue, what would be the reason to not untangle/solve/test this with |
@pailhead Many issues are solved with // backward-compatible (uv1)
material.map = texture;
// or using nodes (uv2)
material.map = new THREE.TextureNode( texture, new THREE.UVNode(1) ); Our focus right now preserve backward-compatible only to think later make any modification in core. |
@sunag I’d split this into two diffs, one for this refresh pattern, another for texture transform prioritizations. |
As there is nothing very well defined yet I will try to keep the |
@sunag This PR looks good to me, was there more you wanted to change here, or is it ready for review and merge? |
Is ready 👍 |
Looking good! Thanks! |
THREE.NodePass
.build()
is deprecated useneedsUpdate = true
instead.THREE.NodeMaterial
.build()
is deprecated to update theshader
useneedsUpdate = true
instead.One more step towards the core.
https://rawgit.com/sunag/three.js/dev-nodeupdate1/examples/index.html?q=nodes#webgl_loader_nodes