-
-
Notifications
You must be signed in to change notification settings - Fork 35.7k
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 - Clarity For Accessor Methodology #30778
Comments
Hi @Bug-Reaper , I also think a super simple example for basic modification of core material is important as well as the capacity to 'hijack' the core materials. From my understanding the pain point is the uniform for the map ( In my recent TSL project I'm creating more So for me creating and contributing to this libs is a good way to solve it. A bit like trokita for sdf text in legacy threejs. |
👍 :: Agree w/you @Makio64 some common use-cases are a welcome addition and it felt odd to not have them in the docs. <- Open ears if anyone has example use-case reqs. 👍 :: Great reference info on three.js/src/nodes/accessors/MaterialNode.js Lines 94 to 104 in a5ec0a6
It should be possible to expose 👍 :: In my recent TSL projects I too found myself doing odd work-arounds. That's part of why I put so much thought into this thread. I feel like if I get too many good workarounds I'm never gonna make the improvements to benefit everyone. Have some stuff to do today/tomorrow. Will see if anyone else has thoughts over the next couple of days. Ty for reading my post! |
Hey @Makio64 did you ever figure out how to update a texture uniform? You mention it in #30050 (comment) but I don't see a proper resolution?
Would love to have a basic example with this one! I couldn't figure it out tho 😳 More generally feel clarity on my goal here. Find all cases where "I could do this in GLSL" and ensure+document how to do. it in TSL. |
Yes it was confusing , so let txt = new TextureLoader().load(url) // threejs texture
// here the shader/node part start
let utxt = texture( txt ) // glsl : uniform sampler2D utxt
material.colorNode = utxt.sample( uv() ) // glsl : output = texture(utxt, vUv);
//... later in your code update the texture, for example with a new one :
utxt.value = new TextureLoader().load( anotherURL ) |
Description
I keep getting footgunned in TSL and think maybe there's some soft goals we can clarify to provide a more intuitive developer experience.
Namely I'd propose we roadmap this goal:
Attributes, Varyings, and Uniforms
that are used in the default shader logic for a node should be available to the developer when they add custom shader logicFn()
for a node.💁♂️
I know the default
colorNode
can access the texture-uniform controlled by the material'smap
property. However I cannot access it when declaring custom-logic designed to replace that node.Similarly I know that the
vertexNode
can access theinstanceMatrix
for an instanced mesh. However I cannot access it when declaring custom-logic designed to replace that node.Sure you could re-import the
map
prop in a tsltexture()
constructor (redundant) or roll your own custom shared instancebufferattributes (painful). The problem is muddled greatly by the fact these are technically possible and thus it can cause us as developers to guess at the intention.In the current low-documentation/example climate it also creates a longer than usual wild-goose chase for the developer. You naturally assume that the custom logic will have access to the same
attribs/uniforms/varyings
the default logic has. Especially since so many times you can access theattrib/uniform/varying
used in the default logic.Solution
A clearly stated goal of the language to expose
attribs/varys/uniforms
in TSL-worldFn()
context if they are already exposed to the developer on an object3D like a mesh/material/geometry etc.Hopefully discourages an ecosystem full of hacky work-arounds to re-create GPU communication in TSL that is already available just not exposed. I also think it'll really help provide clarity to non-core contributors on where they can assist to fill in some low hanging fruit.
I am happy to assist in organization of some type of tracker of this and at the very least add a clarification note to our TSL readme.
Alternatives
I was kind of surprised TSL did not have a more generalized solution to solve the mapping of GPU<->CPU communication. Perhaps there's something there like:
attribute()
I've pondered this briefly
Additional context
r174 longterm three.js nerd
Ty for your consideration! Long live TSL!
The text was updated successfully, but these errors were encountered: