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 /source/blender
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 'source/blender')
-rw-r--r--source/blender/blenloader/intern/versioning_290.c7
-rw-r--r--source/blender/makesdna/DNA_light_defaults.h1
-rw-r--r--source/blender/makesdna/DNA_light_types.h2
-rw-r--r--source/blender/makesrna/intern/rna_light.c9
4 files changed, 18 insertions, 1 deletions
diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c
index d8f798a11cd..0c6817542d1 100644
--- a/source/blender/blenloader/intern/versioning_290.c
+++ b/source/blender/blenloader/intern/versioning_290.c
@@ -1963,5 +1963,12 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
arm->axes_position = 1.0;
}
}
+
+ /* Initialize the spread parameter for area lights*/
+ if (!DNA_struct_elem_find(fd->filesdna, "Lamp", "float", "area_spread")) {
+ LISTBASE_FOREACH (Light *, la, &bmain->lights) {
+ la->area_spread = DEG2RADF(180.0f);
+ }
+ }
}
}
diff --git a/source/blender/makesdna/DNA_light_defaults.h b/source/blender/makesdna/DNA_light_defaults.h
index f3ccf14ac5b..5e5ce4bf540 100644
--- a/source/blender/makesdna/DNA_light_defaults.h
+++ b/source/blender/makesdna/DNA_light_defaults.h
@@ -68,6 +68,7 @@
.volume_fac = 1.0f, \
.att_dist = 40.0f, \
.sun_angle = DEG2RADF(0.526f), \
+ .area_spread = DEG2RADF(180.0f), \
}
/** \} */
diff --git a/source/blender/makesdna/DNA_light_types.h b/source/blender/makesdna/DNA_light_types.h
index 3b7440aedd2..82ff3c95834 100644
--- a/source/blender/makesdna/DNA_light_types.h
+++ b/source/blender/makesdna/DNA_light_types.h
@@ -70,9 +70,9 @@ typedef struct Light {
short area_shape;
float area_size, area_sizey, area_sizez;
+ float area_spread;
float sun_angle;
- char _pad3[4];
/* texact is for buttons */
short texact, shadhalostep;
diff --git a/source/blender/makesrna/intern/rna_light.c b/source/blender/makesrna/intern/rna_light.c
index bb99e5c6c1d..0593db0dd56 100644
--- a/source/blender/makesrna/intern/rna_light.c
+++ b/source/blender/makesrna/intern/rna_light.c
@@ -480,6 +480,15 @@ static void rna_def_area_light(BlenderRNA *brna)
"Size Y",
"Size of the area of the area light in the Y direction for rectangle shapes");
RNA_def_property_update(prop, 0, "rna_Light_draw_update");
+
+ prop = RNA_def_property(srna, "spread", PROP_FLOAT, PROP_ANGLE);
+ RNA_def_property_float_sdna(prop, NULL, "area_spread");
+ RNA_def_property_range(prop, DEG2RADF(1.0f), DEG2RADF(180.0f));
+ RNA_def_property_ui_text(
+ prop,
+ "Spread",
+ "How widely the emitted light fans out, as in the case of a gridded softbox");
+ RNA_def_property_update(prop, 0, "rna_Light_draw_update");
}
static void rna_def_spot_light(BlenderRNA *brna)