If/Else switch node and Tree Viewer

#1

I’m building a math graph in the node editor where I need a switch operator, I tried to use the MixShader node but I’m not getting the expected results.
I’m also trying to check the results in a 2D viewer, I know some people do Ctrl+Shift+LMB but this only shows in the 3D view and after a pause.

0 Likes

(Secrop) #2

I have my own node for that, perhaps you can adapt it to your needs:

0 Likes

#3

Thank you, I will try it out. I think I know why it doesn’t work, MixShader expects shader type inputs (green knots) but I’m feeding it with single values with the value node.

Edit: I’m new to blender, how does the script work? I tried both placing it in the startup folder and also running it from the scripting panel.

0 Likes

#4

I went and installed the whole addon but it doesn’t show on the addon panel (to enable it).
I’m on blender 2.80.45

0 Likes

(Secrop) #5

For now, it’s only working with cycles.
You can still use the MixRGB node as it allows you to operate with 3 values at the same time. (My node just does one value)

0 Likes

(Benjamin Morrison) #6

I’m also trying to check the results in a 2D viewer

I’m not sure what this means? The UV/Image Editor?
If you haven’t done a proper render (not interactive viewport) then it won’t update.

The mix nodes blend between two shaders or rgb values based a float value (the grey socket).
The math node can do comparison operations that will output either 0 or 1. Chain them for multistep switching if necessary.
Depending on the use case, you could use a use a color ramp with stepped interpolation to map values(0.0 - 1.0) to RGB values.

0 Likes

#7

Yes, the image editor.
I have the LookDev view mode in this layout, so you mean to perform a full render?
I saw some people that basically check the textures with a plane in 3D view, but for me this is cumbersome because first, for a moment when it needs to update, the image is wiped so for comparisons it’s not very convenient, and second, I have some Color Management settings that override the “Emissive” mode of the viewer.

Finally I used the mixRGB node, I just didn’t spot the mix mode for a few times.
I made a proper sRGB to Linear group node. Is there a way to export this to a library? I read I could export as a blend file but I don’t want to pass the rest of the scene information.

0 Likes

(Benjamin Morrison) #8

Not sure why you need such a node. As far as I know, image maps are linearized based on the color/non-color option. Otherwise all blending within the shader node tree should be linear.

Regardless, check out the linked libraries documentation. You can treat any blend file like an asset library and import individual datablocks (meshes, group nodes, shaders etc.)
https://docs.blender.org/manual/en/latest/data_system/linked_libraries.html

0 Likes

#9

Very cool, you can navigate the file structure. I guess I will end buying some sort of asset library although I always prefer internal tools.

For the custom node I’m trying to replicate my PBR+ACES workflow within Blender, I think I might need it at some point even after knowing what those two actually meant (as if color maps couldn’t be linear!).

0 Likes

(Korchy) #10

Maybe if/else node from the BIS material library can help you

https://b3d.interplanety.org/en/if-else-statement-by-nodes/

1 Like

(pauljs75_) #11

Vertex color. For some odd reason, there’s no linear output option. So it having it converted to linear has its uses.

0 Likes