Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatteo Falduto <matteolegna>2021-04-01 06:35:56 +0300
committerBrecht Van Lommel <brecht@blender.org>2021-04-01 13:31:01 +0300
commita4260ac21977acd5b9cd792f2a68c3aa78dd91cd (patch)
tree61bdd5358e5279ddb9c13c53bb3079d1d8f79b65 /intern/cycles/kernel/kernel_light.h
parentc859e1afa0dcca1a495c6b25d00bab65bf94be0b (diff)
Cycles: add a spread setting for area lights
This simulates the effect of a honeycomb or grid placed in front of a softbox. In practice, it works by attenuating rays coming off-angle as a function of the provided spread angle parameter. Setting the parameter to 180 degrees poses no restrictions to the rays, making the light behave the same way as before this patch. The total light power is normalized based on the spread angle, so that the light strength remains the same. Differential Revision: https://developer.blender.org/D10594
Diffstat (limited to 'intern/cycles/kernel/kernel_light.h')
-rw-r--r--intern/cycles/kernel/kernel_light.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/intern/cycles/kernel/kernel_light.h b/intern/cycles/kernel/kernel_light.h
index 9650b85a5c2..93b05f0ffce 100644
--- a/intern/cycles/kernel/kernel_light.h
+++ b/intern/cycles/kernel/kernel_light.h
@@ -147,6 +147,13 @@ ccl_device_inline bool lamp_light_sample(
ls->D = normalize_len(ls->P - P, &ls->t);
ls->eval_fac = 0.25f * invarea;
+
+ if (klight->area.tan_spread > 0.0f) {
+ /* Area Light spread angle attenuation */
+ ls->eval_fac *= light_spread_attenuation(
+ ls->D, ls->Ng, klight->area.tan_spread, klight->area.normalize_spread);
+ }
+
if (is_round) {
ls->pdf *= lamp_light_pdf(kg, D, -ls->D, ls->t);
}
@@ -286,6 +293,15 @@ ccl_device bool lamp_light_eval(
ls->pdf = rect_light_sample(P, &light_P, axisu, axisv, 0, 0, false);
}
ls->eval_fac = 0.25f * invarea;
+
+ if (klight->area.tan_spread > 0.0f) {
+ /* Area Light spread angle attenuation */
+ ls->eval_fac *= light_spread_attenuation(
+ ls->D, ls->Ng, klight->area.tan_spread, klight->area.normalize_spread);
+ if (ls->eval_fac == 0.0f) {
+ return false;
+ }
+ }
}
else {
return false;