+3

Channel select node

Jason Booth 11 years ago updated by msperling 11 years ago 6
This is likely a lower priority thing, but one for the backlog.

I'd love to be able to expose a channel selection node for users of a shader, allowing them to select which texture channel I pull some information from. I often write shaders which expect different information packed into different channels; for instance, a noise function in R, a gradient shade map in G, and a height field in B. 

Often this causes the shaders to be hard coded to the specific format your working with, and requires users to magically know this information. In the past, I've solved this by exposing an enumeration to the user (Red = 0, Green = 1, Blue = 2, Alpha = 3) and then just accessed the texture using the array notation myVector4[myEnumVal], which nicely solves this issue. 

Anyway, it would be nice to be able to do something like this with shader forge. 
Could you show me an example? Sounds like a very useful feature ... is this some kind of custom material editor?
The bare minimum implementation would be to allow ints in shader forge as an exposed value type then create one with a range of 0-3. Then you'd have a node like the texture node which takes a tex input and an int. It would essentially generate code like so:

float result = SampleTex(myTexure, uv)[myInt];

Unfortunately I don't think there's an easy way to make the material display a nice enum for that in Unity's shader editor. It would likely only be able to show up as an int without writing a custom editor for it (which seems out of scope). So maybe unity's editor structure just makes this too obscure to be useful, beyond adding support for integer types. 

Well, SF is already using a custom inspector, so it wouldn't be too far off
Ah, interesting. That opens up some great possibilities then. 

In that case, can we get numeric values next to the sliders? I like being able to range limit a value, but then not being able to see it numerically is annoying..
I find it annoying as well, and I did plan to make the inspector more similar to the SF sliders etc.
I just haven't found the time for it yet :)
Great. Having no numerical values next to a slider made me abandon those things completely in Unity. There are times when you need to have 2 different materials have the same values for a specific variable. And although a clamped range would make sense you have to expose a float... annoying as hell.
Also for sliders: give them some room aka pixel length.
Often the jumps in numbers are too big when you drag that thing around.