Hi BabylonJS team!
I’d love to hear your thoughts and advice.
My current goal is to dynamically inject parts of NodeMaterial/Frame code into other materials, without modifying the original materials where this code is being used.
Example:
Let’s say we want to switch 20 materials between day and night modes. We do this by multiplying by a color — #ffffff for day, #0000ff for night.
The color value is stored in a shared frame, and that value is then propagated into all consumer materials. As a result, the color updates across every material — even when editing the shared material in the Node Editor.
But the ultimate goal is to transmit more complex logic this way — for example, noise functions or texture projections in world-space coordinates, and similar constructs.
I’ve just started working on this, but it’s already showing promising results — and I really like how it’s shaping up.
Here’s what I’m currently doing:
I created a dedicated material with a frame, cloned that frame into the consumer materials, and used a custom PassThrough block as a marker for where the frame should be inserted. Then I linked all clones to listen for updates of the input block values from the source material.
As a result, I now have synchronized parameter updates (like color, even directly in the editor!) across multiple materials, without having to manually edit each one. This has already solved several related issues — though I realize this is just the beginning.
(I’m also aware that this approach causes some duplicated computation, but in many cases it’s still quite practical and works well.)
I’d really appreciate your feedback, suggestions, and ideas on how to improve or optimize this approach.
What can you recomend about it? Maybe there is different approach that allow to do it a better way?
@Deltakosh @Evgeni_Popov