Is it possible for a shader node to detect which renderer is being used in Blender?

Was curious, is there a way to check which render engine is in use within a shader? Wondering if it would be possible to create a node that can return which render engine (Cycles/Eevee/etc) is in use. Good for branching shaders, perhaps.

In 2.8 shader output nodes can specify which engine they’re for, so you can use that:

Depending on what exactly is in your material, this might result in a lot of duplicate notes or crisscrossing wires though. While there isn’t an actual node for what you want, you can abuse Cycles’ lack of support for the Shader to RGB node (which converts BSDF closures to colors). Specifically, this setup will return a constant value of 1 in Eevee, and 0 in Cycles:

A little dirty and might break in a future release of Blender, but it gets the job done.

1 Like

Thank you! I had forgotten about the Material Output toggle in 2.8. And the Shader-to-RGB node makes perfect sense as well. Much appreciated.