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
path: root/source
diff options
context:
space:
mode:
authorTim Stullich <tstullich>2019-05-15 15:45:33 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2019-05-15 17:07:50 +0300
commit5ba1a6bee0426e77a01cec8c89999ee4d15ced63 (patch)
tree3f6fa2deef19c31f93c9d68d54814fa85bf5d52a /source
parent2497ee31ec89560a9b72a070a70735caa6655b9e (diff)
Lights: change sun light size to be specified as angle
This is the angular diameter as seen from earth, which is between 0.526° and 0.545° in reality. Sharing the size with other light types did not make much sense and meant the unit was unclear. Differential Revision: https://developer.blender.org/D4819
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/light.c1
-rw-r--r--source/blender/blenloader/intern/versioning_280.c7
-rw-r--r--source/blender/draw/engines/eevee/eevee_lights.c3
-rw-r--r--source/blender/makesdna/DNA_light_types.h3
-rw-r--r--source/blender/makesrna/intern/rna_light.c8
5 files changed, 22 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/light.c b/source/blender/blenkernel/intern/light.c
index 05b2eb82daf..1c3acb6a73a 100644
--- a/source/blender/blenkernel/intern/light.c
+++ b/source/blender/blenkernel/intern/light.c
@@ -80,6 +80,7 @@ void BKE_light_init(Light *la)
la->contact_thickness = 0.2f;
la->spec_fac = 1.0f;
la->att_dist = 40.0f;
+ la->sun_angle = DEG2RADF(0.526f);
curvemapping_initialize(la->curfalloff);
}
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index 9d8fa2d06d0..526931d1a45 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -3418,5 +3418,12 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
LISTBASE_FOREACH (bArmature *, arm, &bmain->armatures) {
arm->flag &= ~(ARM_FLAG_UNUSED_7 | ARM_FLAG_UNUSED_9);
}
+
+ /* Initializes sun lights with the new angular diameter property */
+ if (!DNA_struct_elem_find(fd->filesdna, "Light", "float", "sun_angle")) {
+ LISTBASE_FOREACH (Light *, light, &bmain->lights) {
+ light->sun_angle = 2.0f * atanf(light->area_size);
+ }
+ }
}
}
diff --git a/source/blender/draw/engines/eevee/eevee_lights.c b/source/blender/draw/engines/eevee/eevee_lights.c
index 730372bce9c..f64cd340ab2 100644
--- a/source/blender/draw/engines/eevee/eevee_lights.c
+++ b/source/blender/draw/engines/eevee/eevee_lights.c
@@ -672,6 +672,9 @@ static void light_shape_parameters_set(EEVEE_Light *evli, const Light *la, float
evli->sizey = max_ff(0.003f, la->area_size * scale[1] * 0.5f);
}
}
+ else if (la->type == LA_SUN) {
+ evli->radius = max_ff(0.001f, tanf(la->sun_angle / 2.0f));
+ }
else {
evli->radius = max_ff(0.001f, la->area_size);
}
diff --git a/source/blender/makesdna/DNA_light_types.h b/source/blender/makesdna/DNA_light_types.h
index 6bd118b7be9..5e881053910 100644
--- a/source/blender/makesdna/DNA_light_types.h
+++ b/source/blender/makesdna/DNA_light_types.h
@@ -66,6 +66,9 @@ typedef struct Light {
short area_shape;
float area_size, area_sizey, area_sizez;
+ 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 da2b5752a0f..54c8049d4d2 100644
--- a/source/blender/makesrna/intern/rna_light.c
+++ b/source/blender/makesrna/intern/rna_light.c
@@ -545,12 +545,20 @@ static void rna_def_spot_light(BlenderRNA *brna)
static void rna_def_sun_light(BlenderRNA *brna)
{
StructRNA *srna;
+ PropertyRNA *prop;
srna = RNA_def_struct(brna, "SunLight", "Light");
RNA_def_struct_sdna(srna, "Light");
RNA_def_struct_ui_text(srna, "Sun Light", "Constant direction parallel ray Light");
RNA_def_struct_ui_icon(srna, ICON_LIGHT_SUN);
+ prop = RNA_def_property(srna, "angle", PROP_FLOAT, PROP_ANGLE);
+ RNA_def_property_float_sdna(prop, NULL, "sun_angle");
+ RNA_def_property_float_default(prop, DEG2RADF(0.526f));
+ RNA_def_property_range(prop, DEG2RADF(0.0f), DEG2RADF(180.0f));
+ RNA_def_property_ui_text(prop, "Angle", "Angular diameter of the Sun as seen from the Earth");
+ RNA_def_property_update(prop, 0, "rna_Light_update");
+
rna_def_light_energy(srna, true);
rna_def_light_shadow(srna, true);
}