4
$\begingroup$

I'm trying to create a little trick, which recognizes if a texture type node has a texture inside it, so if yes, like in this example, it should set the MixRGB value to 1, I'm using a math node set to "Greater Than ", but obviously, this interacts on the parts where the pixels have a value higher than" 0 "but on the others it doesn't interact and the color stays on red. Tracing the Blender logo I'm using as a test.

Is there a way to "Smooth" those values, and make everything set to RGB "Green" if a map is inserted into the node and has at least one pixel with a value greater than 0?

In short:

I would like solid color Red if no texture is inserted in the node, and all green if a texture inserted in the node

enter image description here

Edit: Something was suggested to me in a previous answer. But the problem is that in Blender, an empty Texture Node fires RGB values: (0,0,0) in Eevee, and (1,0,1) in Cycles. So, use solution would be with regard to RGB values only (Leaving aside the Alpha factor for now) Feedback like this:

enter image description here

$\endgroup$
3
  • 1
    $\begingroup$ Hi. You should indicate if it is for Eevee, Cycles or both. $\endgroup$
    – lemon
    Nov 22, 2020 at 7:07
  • $\begingroup$ Hi @lemon , I would like it to work on all 2 and also understand how math can be used here. if possible. $\endgroup$
    – Noob Cat
    Nov 22, 2020 at 13:44
  • 1
    $\begingroup$ Python As stated in the bottom Awnser $\endgroup$
    – Phönix 64
    Nov 23, 2020 at 23:15

2 Answers 2

5
+50
$\begingroup$

Here are three ways to do it:

  1. Python Nodes API: with Python nodes like mentioned before, you can create a smart/dynamic node, that can change values depending on Python properties, like if an image is inserted or not

  2. if you don't want to use PyNodes, you can use drivers, here's a simple driver that does what you need (change "Image Texture" in drivers panel to the name of your Image Texture Node):

  3. if you plan to have such functionality inside a node group, you could set a chosen default value for a socket (a negative value would work in this case), then if nothing is connected to the socket, it would have the default value, which you compare and detect, if something is then connected to the socket, that would change its value, now the compare would return 0, it all works out, because Image Texture Node won't produce a negative value.

enter image description here

enter image description here

$\endgroup$
9
  • 2
    $\begingroup$ That's a nice solution. Obviously the name in the driver needs to match that of the Image Texture node it's relating to (the name, not the label). What's the third way..? $\endgroup$ Nov 24, 2020 at 16:46
  • $\begingroup$ Oh, the third way was relevant to node groups, will edit the answer to include. $\endgroup$
    – Iyad Ahmed
    Nov 24, 2020 at 16:51
  • 1
    $\begingroup$ Your solution is very beautiful and useful! Actually, it hadn't even crossed my mind. In any case, I have had bad experiences with drivers, especially if you switch to other computers. I would like a mathematical solution with nodes without the use of "Script". It's not really easy to get a node that does this. Someone suggests that this is probably not possible. But I keep hoping . I don't understand what you mean in solution 3. If I showed an example it would be nice $\endgroup$
    – Noob Cat
    Nov 24, 2020 at 18:27
  • 1
    $\begingroup$ @IyadAhmed Carefull when you say that "Image Texture Node won't produce a negative value"... Some image formats (hdr and exr) do work with negative values, and the node will still output those. $\endgroup$
    – Secrop
    Nov 25, 2020 at 6:06
  • 1
    $\begingroup$ The real problem, seems to be the Empty texture node, In Eevee it produces 0,0,0 in Cycles 1,0,1. I have updated the question. It seems like a very arduous undertaking. So the comparison is really difficult to make. $\endgroup$
    – Noob Cat
    Nov 25, 2020 at 14:06
4
$\begingroup$

It's not possible to 'sample all values in the image to determine whether something is present' in this way. The Image Texture node takes a vector and returns the value in the image at that specific point. As such it can only return a single point at a time. Having no image returns a fixed value for all pixels but this is still within the range of what a 'valid' image could feasibly return so there is no way of determining whether it's an image or a default 'no image'.

Therefore, I don't think it is possible to achieve what is being asked.

$\endgroup$
3
  • 2
    $\begingroup$ With a python node, it would be possible to traverse any input nodes, and check if any of them is an Image Texture, and if it has some texture assigned. $\endgroup$
    – Secrop
    Nov 23, 2020 at 17:40
  • $\begingroup$ Yes, this is a possibility. But that's not for me (Unfortunately) $\endgroup$
    – Noob Cat
    Nov 24, 2020 at 0:34
  • 2
    $\begingroup$ @Rich Sedman , Technically it is feasible, practically a disaster. I explain. I assume that a complete "Black" image, I do not think it is used for any purpose. So By updating my question, maybe you will understand what I mean. The problem is precisely that Blender Eevee Blank image is 0,0,0 while Cycles is Magenta, 1,0,1. With the distance node you can evaluate if there is something or not, but the problem is that you cannot evaluate which rendering engine you are in. Apart with the use of drivers $\endgroup$
    – Noob Cat
    Nov 24, 2020 at 22:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .