Advice needed on making working with materials more sane and efficient

I don’t think you should do anything more complicated with uniforms other than setting a value or getting a value. Even getting one is i think less common. The most expensive operation that comes to mind is multiplying matrices. like anotherProjection * anotherView * anotherModel

Get should really never ever be anything other than just reading the value. After all, shaders are supposed to do the heavy computation :slight_smile:

1 Like

A shader might not have access to the context that you need to do the computation.
But fair point about doing heavy computation in shaders.. which circles back to shader complexity.

I guess I’ll just have to wallow further in my ignorance. :smiley:

1 Like

Fwiw it would be nice if userData could be typed the same way events on an Object3D can. I haven’t looked at the types recently maybe it is possible. I really dislike userData.

1 Like

Yeah.. I actually rarely/never use userdata for anything. The only usecase for userData imo is serializing stuff alongside with threejs objects, or storing integer handles for stuff.. literally just makes it easier to store metadata without having to copy it when .clone’ing. things. I can see it tho for the case of having a custom shader with properties on the threejs object, and being able to clone the defaults when .cloning a hierarchy or something.