Files
test2/intern/cycles/kernel/osl/shaders/node_light_falloff.osl

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

35 lines
1023 B
Plaintext
Raw Normal View History

/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
*
* SPDX-License-Identifier: Apache-2.0 */
#include "stdcycles.h"
shader node_light_falloff(float Strength = 0.0,
float Smooth = 0.0,
output float Quadratic = 0.0,
output float Linear = 0.0,
output float Constant = 0.0)
{
float ray_length = 0.0;
float strength = Strength;
getattribute("path:ray_length", ray_length);
if (ray_length == FLT_MAX) {
/* Distant lights (which have a ray_length of FLT_MAX) overflow when using most outputs of
* the light falloff node. So just ignore the node in that case. */
Quadratic = strength;
Linear = strength;
Constant = strength;
}
else {
if (Smooth > 0.0) {
float squared = ray_length * ray_length;
strength *= squared / (Smooth + squared);
}
Quadratic = strength;
Linear = (strength * ray_length);
Constant = (strength * ray_length * ray_length);
}
}