I have a procedural texture node group that is being commonly used by a lot of materials as part of a global shader setup for a project. For a few objects in the scene, I want to use a image texture instead. It would be convenient for my setup if an object defaulted to using the procedural textures in the group unless another texture was plugged into the group. In that case, I need it to use that new texture and ignore the procedurals.

This could be accomplished by adding a mix node between the two, and giving the Fac as a group input. But is there a way to automate this? It seems it should be possible with some sort of math that controls the mix Fac based on the texture input itself. If the input was Black by default, then math with Greater Than could be used to set the mix fac to 1 if the input is anything other than solid black. But then if the new input texture has solid black pixels, I'd still get the procedural texture on those pixels.

Is there a better way?


You can do this by filtering on the Pink colour the Image Texture node outputs when no image is loaded. The only caveat is that it won't fully work if your Texture Image contains any pixels with RGB values of (1.0/0.0/1.0).

enter image description here

I've bundled the switching logic into a node for ease of viewing. Here's what the interior of the node group looks like:

enter image description here

Handling 2 Procedural Textures

In order to handle 1 or 2 procedural textures, you can set the default Colour on the Switch node to the Pink colour (R1/G0/B1). This way if nothing is connected it uses the default texture, and if the 2nd procedural texture is connected it uses that.

enter image description here

Blend file attached:

| improve this answer | |
  • $\begingroup$ That looks good for image textures. What about if I'm overriding with another procedural texture? Would it work to just have the default color input for the group socket be that pink, or another unlikely color, if nothing is connected? $\endgroup$ – Ascalon Jun 16 '16 at 23:40
  • $\begingroup$ Yes, you could set the Colour input on the Group node to have a default colour set to the Pink, so that when it is not connected it feeds in the pink colour. $\endgroup$ – Todd McIntosh Jun 16 '16 at 23:49
  • $\begingroup$ I've updated the answer to reflect this alternative usage with 2 proc textures. $\endgroup$ – Todd McIntosh Jun 16 '16 at 23:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.