From ad491aa92d5795a764d18b00f9c0c8e1d5a1535a Mon Sep 17 00:00:00 2001 From: divverent Date: Sat, 18 Dec 2010 20:12:02 +0000 Subject: [PATCH] equalize entities: desaturate the lightgrid when equalizing fullbright entities git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10673 d7cf8633-e32d-0410-b094-e92efae38249 ::stable-branch::merge=f72a9ca5a4751f8db3b4c0191203e306d4f20697 --- gl_rmain.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/gl_rmain.c b/gl_rmain.c index 6102c0e1..62c530e1 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -7945,13 +7945,16 @@ static void R_View_UpdateEntityLighting (void) if(r_equalize_entities_to.value > 0 && r_equalize_entities_by.value != 0) { - VectorMA(ent->modellight_ambient, 0.25f, ent->modellight_diffuse, avg); - f = 0.299f * avg[0] + 0.587f * avg[1] + 0.114f * avg[2]; + fa = 0.299f * ent->modellight_ambient[0] + 0.587f * ent->modellight_ambient[1] + 0.114f * ent->modellight_ambient[2]; + fd = 0.299f * ent->modellight_diffuse[0] + 0.587f * ent->modellight_diffuse[1] + 0.114f * ent->modellight_diffuse[2]; + f = fa + 0.25 * fd; if(f > 0) { - f = pow(f / r_equalize_entities_to.value, -r_equalize_entities_by.value); - VectorScale(ent->modellight_ambient, f, ent->modellight_ambient); - VectorScale(ent->modellight_diffuse, f, ent->modellight_diffuse); + // adjust brightness and saturation to target + avg[0] = avg[1] = avg[2] = fa / f; + VectorLerp(ent->modellight_ambient, r_equalize_entities_by.value, avg, ent->modellight_ambient); + avg[0] = avg[1] = avg[2] = fd / f; + VectorLerp(ent->modellight_diffuse, r_equalize_entities_by.value, avg, ent->modellight_diffuse); } } } -- 2.39.2