diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-05-12 14:41:23 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-05-13 16:56:10 +0300 |
commit | 21854575a4ede7d0c16fbe31ac90e66493f607fe (patch) | |
tree | 1a196b314cbd7f5eedd16caef6d1de43b0cd2837 /intern | |
parent | 7ad802cf3ae500bc72863b6dba0f28a488fce3d1 (diff) |
Cycles/Eevee: unify light strength and color
Cycles lights now use strength and color properties of the light outside
of the shading nodes, just like Eevee. The shading nodes then act as a
multiplier on this, and become optional unless textures, fallof or other
effects are desired.
Backwards compatibility is not exact, as we can't be sure which renderer
the .blend was designed for or even if it was designed for a single one.
If the render engine in the active scene is set to Cycles, lights are
converted to ensure overall light strength remains the same, and removing
unnecessary shader node setups that only included a single emission node.
If the engine is set to Eevee, we increase strength to remove the automatic
100x multiplier that was there to match Cycles.
Differential Revision: https://developer.blender.org/D4588
Diffstat (limited to 'intern')
-rw-r--r-- | intern/cycles/blender/addon/ui.py | 7 | ||||
-rw-r--r-- | intern/cycles/blender/blender_object.cpp | 4 | ||||
-rw-r--r-- | intern/cycles/blender/blender_shader.cpp | 11 | ||||
-rw-r--r-- | intern/cycles/kernel/kernel_emission.h | 5 | ||||
-rw-r--r-- | intern/cycles/kernel/kernel_types.h | 2 | ||||
-rw-r--r-- | intern/cycles/render/light.cpp | 11 | ||||
-rw-r--r-- | intern/cycles/render/light.h | 1 |
7 files changed, 28 insertions, 13 deletions
diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py index 0845f567056..9714067b08e 100644 --- a/intern/cycles/blender/addon/ui.py +++ b/intern/cycles/blender/addon/ui.py @@ -1341,6 +1341,10 @@ class CYCLES_LIGHT_PT_light(CyclesButtonsPanel, Panel): col = layout.column() + col.prop(light, "color") + col.prop(light, "energy") + col.separator() + if light.type in {'POINT', 'SUN', 'SPOT'}: col.prop(light, "shadow_soft_size", text="Size") elif light.type == 'AREA': @@ -1384,8 +1388,7 @@ class CYCLES_LIGHT_PT_nodes(CyclesButtonsPanel, Panel): layout = self.layout light = context.light - if not panel_node_draw(layout, light, 'OUTPUT_LIGHT', 'Surface'): - layout.prop(light, "color") + panel_node_draw(layout, light, 'OUTPUT_LIGHT', 'Surface') class CYCLES_LIGHT_PT_spot(CyclesButtonsPanel, Panel): diff --git a/intern/cycles/blender/blender_object.cpp b/intern/cycles/blender/blender_object.cpp index 00f53804e38..1094ff37afb 100644 --- a/intern/cycles/blender/blender_object.cpp +++ b/intern/cycles/blender/blender_object.cpp @@ -182,6 +182,10 @@ void BlenderSync::sync_light(BL::Object &b_parent, } } + /* strength */ + light->strength = get_float3(b_light.color()); + light->strength *= BL::PointLight(b_light).energy(); + /* location and (inverted!) direction */ light->co = transform_get_column(&tfm, 3); light->dir = -transform_get_column(&tfm, 2); diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp index a08f767f964..8321d0c088c 100644 --- a/intern/cycles/blender/blender_shader.cpp +++ b/intern/cycles/blender/blender_shader.cpp @@ -1409,16 +1409,9 @@ void BlenderSync::sync_lights(BL::Depsgraph &b_depsgraph, bool update_all) add_nodes(scene, b_engine, b_data, b_depsgraph, b_scene, graph, b_ntree); } else { - float strength = 1.0f; - - if (b_light.type() == BL::Light::type_POINT || b_light.type() == BL::Light::type_SPOT || - b_light.type() == BL::Light::type_AREA) { - strength = 100.0f; - } - EmissionNode *emission = new EmissionNode(); - emission->color = get_float3(b_light.color()); - emission->strength = strength; + emission->color = make_float3(1.0f, 1.0f, 1.0f); + emission->strength = 1.0f; graph->add(emission); ShaderNode *out = graph->output(); diff --git a/intern/cycles/kernel/kernel_emission.h b/intern/cycles/kernel/kernel_emission.h index f2eaa7b50a5..34300543f91 100644 --- a/intern/cycles/kernel/kernel_emission.h +++ b/intern/cycles/kernel/kernel_emission.h @@ -90,6 +90,11 @@ ccl_device_noinline float3 direct_emissive_eval(KernelGlobals *kg, eval *= ls->eval_fac; + if (ls->lamp != LAMP_NONE) { + const ccl_global KernelLight *klight = &kernel_tex_fetch(__lights, ls->lamp); + eval *= make_float3(klight->strength[0], klight->strength[1], klight->strength[2]); + } + return eval; } diff --git a/intern/cycles/kernel/kernel_types.h b/intern/cycles/kernel/kernel_types.h index 7d4f655a32e..4070d5a8992 100644 --- a/intern/cycles/kernel/kernel_types.h +++ b/intern/cycles/kernel/kernel_types.h @@ -1455,6 +1455,8 @@ typedef struct KernelLight { int samples; float max_bounces; float random; + float strength[3]; + float pad1; Transform tfm; Transform itfm; union { diff --git a/intern/cycles/render/light.cpp b/intern/cycles/render/light.cpp index d4c233e3bb3..ef4bd4260c9 100644 --- a/intern/cycles/render/light.cpp +++ b/intern/cycles/render/light.cpp @@ -114,6 +114,8 @@ NODE_DEFINE(Light) type_enum.insert("spot", LIGHT_SPOT); SOCKET_ENUM(type, "Type", type_enum, LIGHT_POINT); + SOCKET_COLOR(strength, "Strength", make_float3(1.0f, 1.0f, 1.0f)); + SOCKET_POINT(co, "Co", make_float3(0.0f, 0.0f, 0.0f)); SOCKET_VECTOR(dir, "Dir", make_float3(0.0f, 0.0f, 0.0f)); @@ -162,6 +164,9 @@ void Light::tag_update(Scene *scene) bool Light::has_contribution(Scene *scene) { + if (strength == make_float3(0.0f, 0.0f, 0.0f)) { + return false; + } if (is_portal) { return false; } @@ -672,7 +677,6 @@ void LightManager::device_update_points(Device *, DeviceScene *dscene, Scene *sc float3 co = light->co; Shader *shader = (light->shader) ? light->shader : scene->default_light; int shader_id = scene->shader_manager->get_shader_id(shader); - int samples = light->samples; int max_bounces = light->max_bounces; float random = (float)light->random_id * (1.0f / (float)0xFFFFFFFF); @@ -697,7 +701,10 @@ void LightManager::device_update_points(Device *, DeviceScene *dscene, Scene *sc } klights[light_index].type = light->type; - klights[light_index].samples = samples; + klights[light_index].samples = light->samples; + klights[light_index].strength[0] = light->strength.x; + klights[light_index].strength[1] = light->strength.y; + klights[light_index].strength[2] = light->strength.z; if (light->type == LIGHT_POINT) { shader_id &= ~SHADER_AREA_LIGHT; diff --git a/intern/cycles/render/light.h b/intern/cycles/render/light.h index 66732000f3b..a7bffde7a8d 100644 --- a/intern/cycles/render/light.h +++ b/intern/cycles/render/light.h @@ -42,6 +42,7 @@ class Light : public Node { Light(); LightType type; + float3 strength; float3 co; float3 dir; |