From c695875654cec934f462634bf79ca5ed5867c179 Mon Sep 17 00:00:00 2001 From: vlj Date: Sat, 19 Apr 2014 02:04:39 +0200 Subject: [PATCH] PointLight: Use a 1/(1 + d + k d^2) attenuation This is not physically accurate, but a 1/d^2 attenuation makes light extend too broad, and went too high if close from the source. --- data/shaders/pointlight.frag | 4 ++-- src/graphics/stkmesh.cpp | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/data/shaders/pointlight.frag b/data/shaders/pointlight.frag index 30b891dcd..6369a7850 100644 --- a/data/shaders/pointlight.frag +++ b/data/shaders/pointlight.frag @@ -32,8 +32,8 @@ void main() vec3 light_pos = pseudocenter.xyz; vec3 light_col = col.xyz; float d = distance(light_pos, xpos.xyz); - float att = energy * 200. / (4. * 3.14 * d * d); - float spec_att = (energy + 10.) * 200. / (4. * 3.14 * d * d); + float att = energy * 200. / (1 + d + 4. * 3.14 * d * d); + float spec_att = energy * 200. / (1 + d + 4. * 3.14 * d * d); // Light Direction vec3 L = -normalize(xpos.xyz - light_pos); diff --git a/src/graphics/stkmesh.cpp b/src/graphics/stkmesh.cpp index e1fc81da3..29eeed2e5 100644 --- a/src/graphics/stkmesh.cpp +++ b/src/graphics/stkmesh.cpp @@ -572,6 +572,7 @@ void drawObjectUnlit(const GLMesh &mesh, const core::matrix4 &ModelViewProjectio void drawDetailledObjectPass2(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix) { + return; irr_driver->IncreaseObjectCount(); GLenum ptype = mesh.PrimitiveType; GLenum itype = mesh.IndexType;