-
-
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
TSL - CustomMaterial Features? #30654
Comments
Classic solve it immediately after post, found a snippet somewhere but you can import { output } from 'three/tsl'
const mat = new THREE.MeshStandardNodeMaterial({});
const invert = Fn([frag]=>{
// Any TSL code ontop of final material color coming in as [frag]
return vec4(sub(1,frag.rgb),1)
})
mat.outputNode = invert(output); This solves my first question about mutating shadernode outputs. May add some better examples to the doc along with any other things from my learning TSL adventures of the past few days. |
There are predefined TSL objects for this use case. Try it with three.js/src/nodes/accessors/MaterialNode.js Lines 451 to 458 in ef73c54
You can then do this: material.colorNode = materialColor; And of course modify the color with more TSL according to your use case. |
Thanks @Mugen87 I had no idea we have all these node-accessors. I guess my question is: someMaterial.colorNode = Fn(()=>{
// ?? => How to access material-props here??
}) I can't figure out how to reference a Mostly curious if all a node-material's properties can be accessed inside these custom-node functions? |
If you want individual access on someMaterial.colorNode = texture( map ); |
It's confusing that The material is able to reference these properties/uniforms internally right @Mugen87 could they be exposed easily? I think it's a good idea to expose access to all unique material properties including all Let me know if that makes sense to you? Material-prop access like outlined above was possible and widely used in/via |
Description
Yo the new TSL stuff is pretty slick. I've spent the past two days trying to feel it out, great bindings once you get the hang of it.
I've read through the God TSL document like 3 times, combed code examples, and I can't figure out a couple of thing?
Mesh<TYPE>NodeMaterial
(chain on additional shader logic to the final product?)colorNode
which replacesmap*color
does not have access to the material'smap
unless re-added as a new uniform?Perhaps I'm missing something obvious. It appears
uv()
andvertexColor()
can be grabbed a-la-carte but is there no way to access other material properties inside custom TSLFn()
s?Much appreciate any insight!
Solution
My dream is TSL "First Party" feeling materials with arbitrary top-level properties to drive uniforms. Modularity in these materials also pretty cool if possible.
Alternatives
Open minded, can contribute some help if it's a good fit.
Additional context
N/A
The text was updated successfully, but these errors were encountered: