-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
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
Material.onBeforeCompile() enhancements #13446
Comments
The main idea behind this is based on an observation that passing data in seems like a more intuitive way of dealing with this problem. Configuration over convention? (not aware of (aware of (another expectation coming from someone not aware of
(one of the first PRs to tackle this, configuration over convention) |
It's not exactly the same but in case others find it useful, I wrote this I'm using it for lots of things now, such as rendering SDF text based on builtin materials: https://troika-examples.netlify.com/#text |
In the meanwhile I don't think it makes sense to put any more effort in an enhanced version of |
I would like a more robust
Material.onBeforeCompile
system to work with the current state of the default materials.See:
[BUG]: onBeforeCompile hashing #13192
https://codepen.io/anon/pen/KQPBjd
The workaround for this seems extremely hacky, and one has to think of functions/callbacks in a specific way, if that makes sense. Literally the raw code you write in the callback matters. I would like to not think of this function as data, but the stuff inside it as data. If you are writing some kind of a utility that somehow configures
onBeforeCompile
in different ways, rather than writing:{ chunkName: chunkString}
. If replace() is the only thing i will ever want to call in this callback, onfragmentShader
orvertexShader
it would be nice if it's hidden away:#extension
directives (there's more stuff that happens above the pre-compile shader). Again i'd like to see it more as data.I've tried to implement these changes in:
#13198
Thoughts @Mugen87 ?
Per discussion with @mrdoob all of this would go away in favor of all the materials being rewritten with the node material. Until that happens, i would like to see a way to interact with the default materials thats more robust.
I think this is called configuration over convention. I would configure these materials with custom stuff upon construction, and then not care about the string manipulation, and particular moments in time like compile time.
Three.js version
The text was updated successfully, but these errors were encountered: