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.
This commit is contained in:
vlj 2014-04-19 02:04:39 +02:00
parent f6d52511ea
commit c695875654
2 changed files with 3 additions and 2 deletions

View File

@ -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);

View File

@ -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;