diff options
author | Jack Andersen <someemail@gmail.com> | 2016-03-13 04:00:12 +0300 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2016-03-13 04:05:36 +0300 |
commit | 861616bf693b78b070ada6cbc6aa79eb807fdde8 (patch) | |
tree | 4626f295c739ea7fa689e4f56d6877845eb9adf1 /source/gameengine | |
parent | 989b0e472e74869be9f170e2dafbae76d6a4ce94 (diff) |
Full Inverse-Quadratic-Equation Lamp Falloff
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
Diffstat (limited to 'source/gameengine')
3 files changed, 6 insertions, 2 deletions
diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 20281eb986e..c2cfd8808a9 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -1417,6 +1417,9 @@ static KX_LightObject *gamelight_from_blamp(Object *ob, Lamp *la, unsigned int l lightobj->m_att1 = la->att1; lightobj->m_att2 = (la->mode & LA_QUAD) ? la->att2 : 0.0f; + lightobj->m_coeff_const = la->coeff_const; + lightobj->m_coeff_lin = la->coeff_lin; + lightobj->m_coeff_quad = la->coeff_quad; lightobj->m_color[0] = la->r; lightobj->m_color[1] = la->g; lightobj->m_color[2] = la->b; diff --git a/source/gameengine/Rasterizer/RAS_ILightObject.h b/source/gameengine/Rasterizer/RAS_ILightObject.h index 59475200a73..a3d55c925d6 100644 --- a/source/gameengine/Rasterizer/RAS_ILightObject.h +++ b/source/gameengine/Rasterizer/RAS_ILightObject.h @@ -69,6 +69,7 @@ public: float m_att1; float m_att2; + float m_coeff_const, m_coeff_lin, m_coeff_quad; float m_spotsize; float m_spotblend; diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLLight.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLLight.cpp index 7639189a6f0..e15ae4bd0d7 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLLight.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLLight.cpp @@ -59,7 +59,7 @@ RAS_OpenGLLight::~RAS_OpenGLLight() if ((lamp = GetGPULamp())) { float obmat[4][4] = {{0}}; GPU_lamp_update(lamp, 0, 0, obmat); - GPU_lamp_update_distance(lamp, la->dist, la->att1, la->att2); + GPU_lamp_update_distance(lamp, la->dist, la->att1, la->att2, la->coeff_const, la->coeff_lin, la->coeff_quad); GPU_lamp_update_spot(lamp, la->spotsize, la->spotblend); } } @@ -291,7 +291,7 @@ void RAS_OpenGLLight::Update() GPU_lamp_update(lamp, m_layer, hide, obmat); GPU_lamp_update_colors(lamp, m_color[0], m_color[1], m_color[2], m_energy); - GPU_lamp_update_distance(lamp, m_distance, m_att1, m_att2); + GPU_lamp_update_distance(lamp, m_distance, m_att1, m_att2, m_coeff_const, m_coeff_lin, m_coeff_quad); GPU_lamp_update_spot(lamp, m_spotsize, m_spotblend); } } |