7
$\begingroup$

I can make a light not illuminate things further away than a set distance, using the attached node setup. Is there a way to refine this setup so that the light intensity can be controlled between the light source and the set distance, with a gradient?

I do understand that there is a light falloff node. I need a way to control not only falloff but also the distance where the light stops illuminating the scene (physically non realistic light). node setup 1

I came up with the below node setup. As qwazix pointed out, the divide value of 60 is actually the distance in system units from the light source to where the light stops affecting the scene.

node setup 2

$\endgroup$
  • $\begingroup$ Your edited setup is correct. The Divide value (60) should be the distance of the falloff. See update to my answer. $\endgroup$ – qwazix Jan 3 '17 at 20:25
7
$\begingroup$

You can use the ColorRamp to visually modify the attenuation across space.

What the setup does is "normalize" the ray length to make the max length you want to control equal to 1.

In the following image, the plane is exactly 5x5, so the falloff should be 2.5 units in order for the light to go off exactly before it reaches the edge.

gradient-light-attenuation

Reasoning

The ColorRamp factor input takes values between 0 and 1 while the ray length is in absolute blender units (length). So in order to use the ColorRamp we need to bring down the maximum ray length we want to control to correspond to 1. So, let's say we want to shine light up to 10 meters (or units), we'd need to divide Ray Length by 10, so that the end of the ColorRamp corresponds to 10 meters from the light source.

The ColorRamp then assigns a color to each ray depending on their length. This result (which is a color - different for each ray) is plugged into the Emission color node so that we can pass color information in addition to strength.

We still need to make the light falloff constant so that the default attenuation does not interfere (multiply) with the our gradient. So we plug in the Constant output of a Light Falloff node into the Emission Strength input.

In the final setup, we control the distance by modifying the division value (2.500 in the screenshot above) and the strength by tweaking the Strength input (100.000) of the Light Falloff node.

Credits:

Using the additional info from cegaton's answer and Booth's edited question, I have edited this answer to be correct and complete. If the reader wants to see how we got here, visit the history

$\endgroup$
  • 2
    $\begingroup$ I'm trying to understand this. Your description sounds good but: where can specific values for overall light strength and max ray length be inserted? Why is normalizing needed? Could you explain a bit more? $\endgroup$ – Booth Jan 3 '17 at 13:26
  • 1
    $\begingroup$ The ColorRamp factor input takes values between 0 and 1 while AIUI the ray length is in absolute blender units (length). So in order to use the ColorRamp we need to bring down our maximum ray length to be equal to 1. So, let's say we want to shine light up to 10 meters (or units), we'd need to divide Ray Length by 10, so that the end of the ColorRamp corresponds to 10 meters from the light source. $\endgroup$ – qwazix Jan 3 '17 at 15:17
  • 1
    $\begingroup$ The ColorRamp also spits out values between 0 and 1 so I scaled the output back to it's original size, so that if we had a full length white ColorRamp we'd get the same result as plugging the ray length directly into the strength. I don't know if this actually has any utility, but it produced really dim results (because it squares the attenuation) so I multiplied again by 10 in order to make the result visible. It is possible that you get better results without the selected multiplication. $\endgroup$ – qwazix Jan 3 '17 at 15:23
  • $\begingroup$ Thank you, that explains why normalizing is needed. But your setup works on the ray length calculated by blender, while I need to set my own distance at which light intensity diminishes to 0... $\endgroup$ – Booth Jan 3 '17 at 17:31
  • $\begingroup$ I wasn't aware that the divide value (60 in my case) = the attenuation distance in system units (cm in my case). I tested and you are right, it actually is. I don't understand why... I divided the ray length - why does dividing the ray length return the attenuation distance of the light? $\endgroup$ – Booth Jan 3 '17 at 21:24
0
$\begingroup$

There is a light Falloff node. It controls how the intensity of the light fades away.

enter image description here

$\endgroup$
  • $\begingroup$ How to controll falloff is not the question. I look for a way to controll it within the distance I have set by using the node setup I have attached. $\endgroup$ – Booth Jan 3 '17 at 17:36

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.