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:
authorClément Foucault <foucault.clem@gmail.com>2018-05-02 19:39:17 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-05-02 19:39:53 +0300
commit1ff2646d5858676761dac88e24b7d2da4ba4ba7d (patch)
treed0e292fe579530399b8e53a8689b157700c07dfc
parent965e6ed54f058c21ae6096a5449fb3d1e5235821 (diff)
Eevee: Add Lamp Specular multiplier.
It's usefull in some scenario to tweak the specular intensity of a light without modifying the diffuse contribution. Cycles allows it via lamps material which we currently not support in Eevee. This is a good workaround for now.
-rw-r--r--release/scripts/startup/bl_ui/properties_data_lamp.py2
-rw-r--r--source/blender/blenloader/intern/versioning_280.c8
-rw-r--r--source/blender/draw/engines/eevee/eevee_lights.c2
-rw-r--r--source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl8
-rw-r--r--source/blender/makesdna/DNA_lamp_types.h2
-rw-r--r--source/blender/makesrna/intern/rna_lamp.c7
6 files changed, 24 insertions, 5 deletions
diff --git a/release/scripts/startup/bl_ui/properties_data_lamp.py b/release/scripts/startup/bl_ui/properties_data_lamp.py
index 892ca26189d..1d7e5807b34 100644
--- a/release/scripts/startup/bl_ui/properties_data_lamp.py
+++ b/release/scripts/startup/bl_ui/properties_data_lamp.py
@@ -143,7 +143,7 @@ class DATA_PT_EEVEE_lamp(DataButtonsPanel, Panel):
sub.prop(lamp, "size_y", text="Size Y")
col = split.column()
- col.label()
+ col.prop(lamp, "specular_factor", text="Specular")
class DATA_PT_EEVEE_shadow(DataButtonsPanel, Panel):
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index 7d473230a4e..07f51dfbc2f 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -1072,4 +1072,12 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
}
+
+ {
+ if (!DNA_struct_elem_find(fd->filesdna, "Lamp", "float", "spec_fac")) {
+ for (Lamp *la = main->lamp.first; la; la = la->id.next) {
+ la->spec_fac = 1.0f;
+ }
+ }
+ }
}
diff --git a/source/blender/draw/engines/eevee/eevee_lights.c b/source/blender/draw/engines/eevee/eevee_lights.c
index 76e8fe83f0a..3508a425eb0 100644
--- a/source/blender/draw/engines/eevee/eevee_lights.c
+++ b/source/blender/draw/engines/eevee/eevee_lights.c
@@ -546,6 +546,8 @@ static void eevee_light_setup(Object *ob, EEVEE_Light *evli)
/* Color */
copy_v3_v3(evli->color, &la->r);
+ evli->spec = la->spec_fac;
+
/* Influence Radius */
evli->dist = la->dist;
diff --git a/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl b/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl
index cc66b477da0..88fde8929cb 100644
--- a/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl
@@ -200,11 +200,11 @@ void CLOSURE_NAME(
#endif
#ifdef CLOSURE_GLOSSY
- out_spec += l_color_vis * light_specular(ld, N, view_vec, l_vector, roughnessSquared, f0) * occlu;
+ out_spec += l_color_vis * light_specular(ld, N, view_vec, l_vector, roughnessSquared, f0) * occlu * ld.l_spec;
#endif
#ifdef CLOSURE_CLEARCOAT
- out_spec += l_color_vis * light_specular(ld, C_N, view_vec, l_vector, C_roughnessSquared, f0) * C_intensity * occlu;
+ out_spec += l_color_vis * light_specular(ld, C_N, view_vec, l_vector, C_roughnessSquared, f0) * C_intensity * occlu * ld.l_spec;
#endif
#else /* HAIR_SHADER */
@@ -218,11 +218,11 @@ void CLOSURE_NAME(
#endif
#ifdef CLOSURE_GLOSSY
- out_spec += l_color_vis * light_specular(ld, N, V, l_vector, roughnessSquared, f0);
+ out_spec += l_color_vis * light_specular(ld, N, V, l_vector, roughnessSquared, f0) * ld.l_spec;
#endif
#ifdef CLOSURE_CLEARCOAT
- out_spec += l_color_vis * light_specular(ld, C_N, V, l_vector, C_roughnessSquared, f0) * C_intensity;
+ out_spec += l_color_vis * light_specular(ld, C_N, V, l_vector, C_roughnessSquared, f0) * C_intensity * ld.l_spec;
#endif
#endif /* HAIR_SHADER */
diff --git a/source/blender/makesdna/DNA_lamp_types.h b/source/blender/makesdna/DNA_lamp_types.h
index b3c07543201..43606cbcd9d 100644
--- a/source/blender/makesdna/DNA_lamp_types.h
+++ b/source/blender/makesdna/DNA_lamp_types.h
@@ -89,6 +89,8 @@ typedef struct Lamp {
float contact_dist, contact_bias, contact_spread, contact_thickness;
+ float spec_fac, pad;
+
/* preview */
struct PreviewImage *preview;
diff --git a/source/blender/makesrna/intern/rna_lamp.c b/source/blender/makesrna/intern/rna_lamp.c
index 6f176ebe331..5bb24f0270d 100644
--- a/source/blender/makesrna/intern/rna_lamp.c
+++ b/source/blender/makesrna/intern/rna_lamp.c
@@ -312,6 +312,13 @@ static void rna_def_lamp_shadow(StructRNA *srna, int sun)
"in shadow maps");
RNA_def_property_update(prop, 0, "rna_Lamp_update");
+ prop = RNA_def_property(srna, "specular_factor", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_sdna(prop, NULL, "spec_fac");
+ RNA_def_property_range(prop, 0.0f, 9999.0f);
+ RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.01, 2);
+ RNA_def_property_ui_text(prop, "Specular Factor", "Specular reflection multiplier");
+ RNA_def_property_update(prop, 0, "rna_Lamp_update");
+
prop = RNA_def_property(srna, "contact_shadow_distance", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_sdna(prop, NULL, "contact_dist");
RNA_def_property_range(prop, 0.0f, 9999.0f);