From 861616bf693b78b070ada6cbc6aa79eb807fdde8 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Sun, 13 Mar 2016 02:00:12 +0100 Subject: Full Inverse-Quadratic-Equation Lamp Falloff MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch adds a new `falloff_type` ('Inverse Coefficients') for Lamps in Blender-Internal and GLSL. The current falloff modes use a formula like this inverse-square one: `I = E × (D^2 / (D^2 + Q × r^2))` While such a formula is simple for 3D-artists to use, it's algebraically cumbersome to work with. Game-designers authoring their own shaders could benefit much more by having direct control of falloff-coefficients: `I = E × (1.0 / (coefC + coefL × r + coefQ × r^2))` In this mode, the `distance` parameter is unused (except for 'Sphere' mode); instead relying on the designer to mathematically-model the falloff-behavior. The UI has been patched like so: {F153843} Reviewers: brecht, psy-fi Reviewed By: psy-fi Subscribers: brita_, antidote, campbellbarton, psy-fi Differential Revision: https://developer.blender.org/D1194 --- source/blender/blenkernel/intern/lamp.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/intern/lamp.c b/source/blender/blenkernel/intern/lamp.c index 9601a93b1f1..49a573489ef 100644 --- a/source/blender/blenkernel/intern/lamp.c +++ b/source/blender/blenkernel/intern/lamp.c @@ -79,6 +79,9 @@ void BKE_lamp_init(Lamp *la) la->adapt_thresh = 0.001f; la->preview = NULL; la->falloff_type = LA_FALLOFF_INVSQUARE; + la->coeff_const = 1.0f; + la->coeff_lin = 0.0f; + la->coeff_quad = 0.0f; la->curfalloff = curvemapping_add(1, 0.0f, 1.0f, 1.0f, 0.0f); la->sun_effect_type = 0; la->horizon_brightness = 1.0; -- cgit v1.2.3