From 5f484a45a5ba20fbe73896d166778e00965ab878 Mon Sep 17 00:00:00 2001 From: ac-stef Date: Sun, 23 Feb 2014 14:44:55 +0100 Subject: [PATCH] engine tweak: fixing lighting postfilter no longer directional IIR filtering, now it's (mostly) pure FIR also, huge speedup (for example, ac_iceroad recalcs 80% faster) --- source/src/worldlight.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/source/src/worldlight.cpp b/source/src/worldlight.cpp index 4678d1ad..3650b2f2 100644 --- a/source/src/worldlight.cpp +++ b/source/src/worldlight.cpp @@ -129,11 +129,10 @@ void calclightsource(const persistent_entity &l, float fade = 1, bool flicker = for(float sy2 = sy+s; sy2<=ey-s; sy2+=s*2) { lightray((float)sx, sy2, l, fade, flicker); lightray((float)ex, sy2, l, fade, flicker); } } -void postlightarea(const block &a) // median filter, smooths out random noise in light and makes it more mipable +void postlightarealine(sqr *s, int len) { - loop(x,a.xs) loop(y,a.ys) // assumes area not on edge of world + loopirev(len) { - sqr *s = S(x+a.x,y+a.y); #define median(m) s->m = (s->m*2 + SW(s,1,0)->m*2 + SW(s,0,1)->m*2 \ + SW(s,-1,0)->m*2 + SW(s,0,-1)->m*2 \ + SW(s,1,1)->m + SW(s,1,-1)->m \ @@ -141,8 +140,25 @@ void postlightarea(const block &a) // median filter, smooths out random noise median(r); median(g); median(b); + s += 2; } +} +void postlightarea(const block &a) // median filter, smooths out random noise in light and makes it more mipable +{ + int ia = (a.xs + 1) >> 1, ib = a.xs - ia;; + for(int y = a.ys - 1; y >= 0; y -= 2) + { + sqr *s = S(a.x,y+a.y); + postlightarealine(s, ia); + postlightarealine(s + 1, ib); + } + for(int y = a.ys - 2; y >= 0; y -= 2) + { + sqr *s = S(a.x,y+a.y); + postlightarealine(s, ia); + postlightarealine(s + 1, ib); + } remip(a); }