← All ideas
  • Published 18 Sep 2019

Switch node in Shader editor

The idea came from other DCC packages and renderers. Blender offers pretty decent random color variations for copied/instanced objects, although it turned out to me it is not so easy to implement switching textures with the current given nodes. Sometimes I need variations of textures across different objects and it become messy building the graph.

My proposal is to implement the special-purpose node which should have dynamic inputs for textures and one input ranged [0..1] as a switch between them. Basically, the switch criteria should be just a random object id.

As a proof of concept, I wrote simple OSL shader with this functionality and it works fine! The only drawback is that OSL isn't working with GPU in Blender.

switch node osl.JPG

100%

Development Status: Open

Upvote 44 Downvote 0
damian_winnichenko
18 Sep 2019

4 Comments

dekanuva

That looks great! It would be nice to have a button to add more input sockets.

I made something similar a while back with a group of math nodes and mix shaders. It's not perfect, but as far as I know it works on GPU. Image

2
damian_winnichenko Author

* @dekanuva * Yeah! Good setup! I`ve tried the same too. Although, both variants lack dynamic inputs...

benjaminround

I need this! <3

peaolo81

Damian, where is the complete code for your OSL shader? I can see just a fraction of it...