8
$\begingroup$

I was writing a tutorial on the "Object Info" node of Blender Cycles and was trying to describe what happens when a color node is fed with numbers out side the interval (0, 1). I gave up and just said "strange things happen".

I know how to map values onto or clip them to the interval (0, 1) so I can usually get the effect I'm after but I'm curious and would like to understand how the color clipping works.

The image below show a grid of cubes in the XY plane. They all have the same material as shown. The larger wire frame cube goes from (0, 0, 0) to (1, 1, 1). There are no lamps and the world surface color is set to (0.051, 0.051, 0.051) (default start up).

color cubes on xy plane enter image description here

Outside the wire frame cube all the little cubes seem to act like emission lights. I think this is related to the answer to this question.

What I don't get is the diagonal line of black cubes. For example rgb(2, -2, 0) gets mapped to black but rgb(2, -1.75, 0) gets mapped to red. There are other lines of black cubes if we move the grid of cubes up in z.

For example all of the following cubes are black (-1, -1, 2) , (0.5, -1, 0.5), (-1, 0.5, 0.5), (0.5, 0.5, -1) , (2, -1, -1) (2.5, -3, 0.5).

Can anyone explain how this works?

$\endgroup$
6
$\begingroup$

This is result of Diffuse shader code implementation. Probably somewhere in the code is:

if R + G + B = 0:    # black
    renderSurfaceBlack()

To back this up I tested with this node setup:

enter image description here

And a cube on grey ground:

enter image description here

You can see red cube with red bounce light (color bleed) and red-complementary bounce light (cyan) under a anti-red (cyan) cube but which is rendered black (explained later).

When some channel is more than 1 the bounce light will look like emission (the light gets energy on bounces from the cube - energy is not preserved) and the surface will reflect redder red than it should (it will clip at 1,0,0 rendered red):

enter image description here

Till now all makes some sense. When the channel is below -1 actual weird stuff happens:

enter image description here

Try to render this, the sampling process is very wild in the start and looks like a burning fire under a piece of coal:)

When the sum of channels is not 0, all the negative values are replaced with 0 and that surface color is rendered.. You will still see the effect of negative channels in bounce light.

enter image description here

To sum this diffuse shader behaviour up:

When the channel sum is 0 the surface color is black.

When the channel sum is not 0, the surface color is same as with all negative channels equal to 0.

$\endgroup$
  • $\begingroup$ duh... I didn't see that r+g+b = 0 for the black cubes. Great explanation with the different renders. Negative values look strange but could be useful for something... Thanks. $\endgroup$ – elfnor Feb 26 '15 at 7:24

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.