Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

postfx cleanups

  • Loading branch information...
commit cdd4471636b0d38b1340c099f7af0dee4629e02e 1 parent 26dd0e4
Lee Salzman authored
69 data/glsl.cfg
View
@@ -2588,75 +2588,6 @@ rotoscope = [
]
]
-// bloom-ish
-
-lazyshader 0 "bloom_scale" [ @fsvs @setup4corners } ] [
- @fsps
- @sample4corners
- gl_FragColor = 0.2 * (s02 + s00 + s22 + s20 + sample);
- }
-]
-
-lazyshader 0 "bloom_init" [ @fsvs } ] [
- @fsps
- float t = max(sample.r, max(sample.g, sample.b));
- gl_FragColor = t*t*sample;
- }
-]
-
-bloomshader = [
- defershader 0 $arg1 [
- forceshader "bloom_scale"
- forceshader "bloom_init"
- shader 0 @arg1 [
- void main(void)
- {
- gl_Position = gl_Vertex;
- gl_TexCoord[0].xy = gl_MultiTexCoord0.xy;
- vec2 tc = gl_MultiTexCoord0.xy;
- @@(loopconcat i $arg2 [concat [
- tc *= 0.5;
- gl_TexCoord[@@(+ $i 1)].xy = tc;
- ]])
- }
- ] [
- #extension GL_ARB_texture_rectangle : enable
- uniform vec4 params;
- uniform sampler2DRect tex0 @@(loopconcat i $arg2 [format ", tex%1" (+ $i 1)]);
- void main(void)
- {
- vec4 sample = texture2DRect(tex0, gl_TexCoord[0].xy);
- @@(loopconcat i $arg2 [
- format [
- @(? (> $i 0) "bloom +=" "vec4 bloom =") texture2DRect(tex%1, gl_TexCoord[%1].xy);
- ] (+ $i 1)
- ])
- gl_FragColor = bloom*params.x + sample;
- }
- ]
- ]
-]
-
-bloomshader bloom1 1
-bloomshader bloom2 2
-bloomshader bloom3 3
-bloomshader bloom4 4
-bloomshader bloom5 5
-bloomshader bloom6 6
-
-setupbloom = [
- addpostfx bloom_init 1 1 "+0"
- loop i (- $arg1 1) [
- addpostfx bloom_scale (+ $i 2) (+ $i 2) (concatword "+" (+ $i 1))
- ]
- addpostfx (concatword bloom $arg1) 0 0 (loopconcat i (+ $arg1 1) [result $i]) $arg2
-]
-
-bloom = [
- clearpostfx
- if (>= $numargs 1) [setupbloom 6 $arg1]
-]
-
////////////////////////////////////////////////
//
// miscellaneous effect shaders:
14 data/menus.cfg
View
@@ -819,9 +819,6 @@ newgui monsters [
newgui postfx [
guibutton "(effect OFF)" "clearpostfx"
- guibutton "bloom (subtle: 30%)" "bloom 0.3"
- guibutton "bloom (bright: 55%)" "bloom 0.55"
- guibutton "bloom (intense: 80%)" "bloom 0.8"
guibutton "rotoscope" "rotoscope 1"
guibutton "rotoscope + blur3" "rotoscope 1 1"
guibutton "rotoscope + blur5" "rotoscope 1 2"
@@ -961,17 +958,6 @@ newgui options [
]
]
guilist [
- guicheckbox "^f3motion blur " motionblur
- if $motionblur [
- guibar
- guiradio "^f3subtle" motionblurscale 0.5
- guibar
- guiradio "^f3moderate" motionblurscale 0.65
- guibar
- guiradio "^f3intense" motionblurscale 0.8
- ]
- ]
- guilist [
guicheckbox "^f3grass " grass
if $grass [
guibar
2  src/engine/engine.h
View
@@ -205,6 +205,7 @@ extern void createtexture(int tnum, int w, int h, const void *pixels, int clamp,
extern void create3dtexture(int tnum, int w, int h, int d, const void *pixels, int clamp, int filter, GLenum component = GL_RGB, GLenum target = GL_TEXTURE_3D_EXT);
extern void blurtexture(int n, int bpp, int w, int h, uchar *dst, const uchar *src, int margin = 0);
extern void blurnormals(int n, int w, int h, bvec *dst, const bvec *src, int margin = 0);
+extern GLuint setuppostfx(int w, int h);
extern void renderpostfx();
extern void initenvmaps();
extern void genenvmaps();
@@ -260,7 +261,6 @@ extern vec curfogcolor;
extern void gl_checkextensions();
extern void gl_init(int w, int h, int bpp, int depth, int fsaa);
extern void cleangl();
-extern void invalidatepostfx();
extern void gl_setupframe(int w, int h);
extern void gl_drawframe(int w, int h);
extern void gl_drawmainmenu(int w, int h);
1  src/engine/octaedit.cpp
View
@@ -516,7 +516,6 @@ void commitchanges(bool force)
octarender();
inbetweenframes = true;
setupmaterials(oldlen);
- invalidatepostfx();
clearshadowcache();
updatevabbs();
}
1  src/engine/octarender.cpp
View
@@ -1486,7 +1486,6 @@ void allchanged(bool load)
octarender();
if(load) precachetextures();
setupmaterials();
- invalidatepostfx();
clearshadowcache();
updatevabbs(true);
if(load)
95 src/engine/rendergl.cpp
View
@@ -849,9 +849,6 @@ static void cleanuplightsphere();
void cleanupgl()
{
- extern void cleanupmotionblur();
- cleanupmotionblur();
-
extern void clearminimap();
clearminimap();
@@ -1571,87 +1568,6 @@ void clipminimap(ivec &bbmin, ivec &bbmax, cube *c = worldroot, int x = 0, int y
}
}
-GLuint motiontex = 0;
-int motionw = 0, motionh = 0, lastmotion = 0;
-
-void cleanupmotionblur()
-{
- if(motiontex) { glDeleteTextures(1, &motiontex); motiontex = 0; }
- motionw = motionh = 0;
- lastmotion = 0;
-}
-
-VARFP(motionblur, 0, 0, 1, { if(!motionblur) cleanupmotionblur(); });
-VARP(motionblurmillis, 1, 5, 1000);
-FVARP(motionblurscale, 0, 0.5f, 1);
-
-void addmotionblur()
-{
- if(!motionblur || !hasTR || max(screen->w, screen->h) > hwtexsize) return;
-
- if(paused || game::ispaused()) { lastmotion = 0; return; }
-
- if(!motiontex || motionw != screen->w || motionh != screen->h)
- {
- if(!motiontex) glGenTextures(1, &motiontex);
- motionw = screen->w;
- motionh = screen->h;
- lastmotion = 0;
- createtexture(motiontex, motionw, motionh, NULL, 3, 0, GL_RGB, GL_TEXTURE_RECTANGLE_ARB);
- }
-
- glBindTexture(GL_TEXTURE_RECTANGLE_ARB, motiontex);
-
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
- glLoadIdentity();
-
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
- glLoadIdentity();
-
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
- glDisable(GL_TEXTURE_2D);
- glEnable(GL_TEXTURE_RECTANGLE_ARB);
-
- rectshader->set();
-
- glColor4f(1, 1, 1, lastmotion ? pow(motionblurscale, max(float(lastmillis - lastmotion)/motionblurmillis, 1.0f)) : 0);
- glBegin(GL_TRIANGLE_STRIP);
- glTexCoord2f( 0, 0); glVertex2f(-1, -1);
- glTexCoord2f(motionw, 0); glVertex2f( 1, -1);
- glTexCoord2f( 0, motionh); glVertex2f(-1, 1);
- glTexCoord2f(motionw, motionh); glVertex2f( 1, 1);
- glEnd();
-
- glDisable(GL_TEXTURE_RECTANGLE_ARB);
- glEnable(GL_TEXTURE_2D);
-
- glDisable(GL_BLEND);
-
- glMatrixMode(GL_PROJECTION);
- glPopMatrix();
-
- glMatrixMode(GL_MODELVIEW);
- glPopMatrix();
-
- if(lastmillis - lastmotion >= motionblurmillis)
- {
- lastmotion = lastmillis - lastmillis%motionblurmillis;
-
- glCopyTexSubImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, 0, 0, screen->w, screen->h);
- }
-}
-
-bool dopostfx = false;
-
-void invalidatepostfx()
-{
- dopostfx = false;
-}
-
void gl_drawhud(int w, int h);
int xtraverts, xtravertsva;
@@ -4588,7 +4504,7 @@ void processhdr(GLuint outfbo = 0)
timer_end(TIMER_HDR);
}
-void dosmaa()
+void dosmaa(GLuint outfbo = 0)
{
timer_begin(TIMER_SMAA);
@@ -4645,7 +4561,7 @@ void dosmaa()
}
else if(smaastencil && ((gdepthstencil && hasDS) || gstencil)) glDisable(GL_STENCIL_TEST);
- glBindFramebuffer_(GL_FRAMEBUFFER_EXT, 0);
+ glBindFramebuffer_(GL_FRAMEBUFFER_EXT, outfbo);
smaaneighborhoodshader->set();
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, gcolortex);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
@@ -5348,10 +5264,10 @@ void gl_drawframe(int w, int h)
glDisable(GL_CULL_FACE);
glDisable(GL_DEPTH_TEST);
- processhdr(smaa ? smaafbo[0] : 0);
- if(smaa) dosmaa();
+ GLuint postfxfbo = setuppostfx(w, h);
+ processhdr(smaa ? smaafbo[0] : postfxfbo);
+ if(smaa) dosmaa(postfxfbo);
- addmotionblur();
if(fogoverlay && fogmat != MAT_AIR) drawfogoverlay(fogmat, fogbelow, clamp(fogbelow, 0.0f, 1.0f), abovemat);
renderpostfx();
@@ -5370,7 +5286,6 @@ void gl_drawmainmenu(int w, int h)
xtravertsva = xtraverts = glde = gbatches = vtris = vverts = 0;
renderbackground(NULL, NULL, NULL, NULL, true, true);
- renderpostfx();
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
81 src/engine/shader.cpp
View
@@ -1072,7 +1072,7 @@ static int allocatepostfxtex(int scale)
postfxtex &t = postfxtexs.add();
t.scale = scale;
glGenTextures(1, &t.id);
- createtexture(t.id, max(screen->w>>scale, 1), max(screen->h>>scale, 1), NULL, 3, 1, GL_RGB, GL_TEXTURE_RECTANGLE_ARB);
+ createtexture(t.id, max(postfxw>>scale, 1), max(postfxh>>scale, 1), NULL, 3, 1, GL_RGB, GL_TEXTURE_RECTANGLE_ARB);
return postfxtexs.length()-1;
}
@@ -1091,32 +1091,33 @@ void cleanuppostfx(bool fullclean)
postfxh = 0;
}
-void renderpostfx()
+GLuint setuppostfx(int w, int h)
{
- if(postfxpasses.empty()) return;
+ if(postfxpasses.empty()) return 0;
- if(postfxw != screen->w || postfxh != screen->h)
+ if(postfxw != w || postfxh != h)
{
cleanuppostfx(false);
- postfxw = screen->w;
- postfxh = screen->h;
+ postfxw = w;
+ postfxh = h;
}
- int binds[NUMPOSTFXBINDS];
- loopi(NUMPOSTFXBINDS) binds[i] = -1;
+ loopi(NUMPOSTFXBINDS) postfxbinds[i] = -1;
loopv(postfxtexs) postfxtexs[i].used = -1;
+
+ if(!postfxfb) glGenFramebuffers_(1, &postfxfb);
+ glBindFramebuffer_(GL_FRAMEBUFFER_EXT, postfxfb);
+ int tex = allocatepostfxtex(0);
+ glFramebufferTexture2D_(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_RECTANGLE_ARB, postfxtexs[tex].id, 0);
- binds[0] = allocatepostfxtex(0);
- postfxtexs[binds[0]].used = 0;
- glBindTexture(GL_TEXTURE_RECTANGLE_ARB, postfxtexs[binds[0]].id);
- glCopyTexSubImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, 0, 0, screen->w, screen->h);
-
- if(hasFBO && postfxpasses.length() > 1)
- {
- if(!postfxfb) glGenFramebuffers_(1, &postfxfb);
- glBindFramebuffer_(GL_FRAMEBUFFER_EXT, postfxfb);
- }
+ postfxbinds[0] = tex;
+ postfxtexs[tex].used = 0;
+ return postfxfb;
+}
+
+void renderpostfx()
+{
loopv(postfxpasses)
{
postfxpass &p = postfxpasses[i];
@@ -1124,29 +1125,29 @@ void renderpostfx()
int tex = -1;
if(!postfxpasses.inrange(i+1))
{
- if(hasFBO && postfxpasses.length() > 1) glBindFramebuffer_(GL_FRAMEBUFFER_EXT, 0);
+ glBindFramebuffer_(GL_FRAMEBUFFER_EXT, 0);
}
else
{
tex = allocatepostfxtex(p.outputscale);
- if(hasFBO) glFramebufferTexture2D_(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_RECTANGLE_ARB, postfxtexs[tex].id, 0);
+ glFramebufferTexture2D_(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_RECTANGLE_ARB, postfxtexs[tex].id, 0);
}
- int w = tex >= 0 ? max(screen->w>>postfxtexs[tex].scale, 1) : screen->w,
- h = tex >= 0 ? max(screen->h>>postfxtexs[tex].scale, 1) : screen->h;
+ int w = tex >= 0 ? max(postfxw>>postfxtexs[tex].scale, 1) : postfxw,
+ h = tex >= 0 ? max(postfxh>>postfxtexs[tex].scale, 1) : postfxh;
glViewport(0, 0, w, h);
p.shader->set();
LOCALPARAM(params, (p.params));
int tw = w, th = h, tmu = 0;
- loopj(NUMPOSTFXBINDS) if(p.inputs&(1<<j) && binds[j] >= 0)
+ loopj(NUMPOSTFXBINDS) if(p.inputs&(1<<j) && postfxbinds[j] >= 0)
{
if(!tmu)
{
- tw = max(screen->w>>postfxtexs[binds[j]].scale, 1);
- th = max(screen->h>>postfxtexs[binds[j]].scale, 1);
+ tw = max(postfxw>>postfxtexs[postfxbinds[j]].scale, 1);
+ th = max(postfxh>>postfxtexs[postfxbinds[j]].scale, 1);
}
else glActiveTexture_(GL_TEXTURE0_ARB + tmu);
- glBindTexture(GL_TEXTURE_RECTANGLE_ARB, postfxtexs[binds[j]].id);
+ glBindTexture(GL_TEXTURE_RECTANGLE_ARB, postfxtexs[postfxbinds[j]].id);
++tmu;
}
if(tmu) glActiveTexture_(GL_TEXTURE0_ARB);
@@ -1157,21 +1158,16 @@ void renderpostfx()
glTexCoord2f(tw, th); glVertex2f( 1, 1);
glEnd();
- loopj(NUMPOSTFXBINDS) if(p.freeinputs&(1<<j) && binds[j] >= 0)
+ loopj(NUMPOSTFXBINDS) if(p.freeinputs&(1<<j) && postfxbinds[j] >= 0)
{
- postfxtexs[binds[j]].used = -1;
- binds[j] = -1;
+ postfxtexs[postfxbinds[j]].used = -1;
+ postfxbinds[j] = -1;
}
if(tex >= 0)
{
- if(binds[p.outputbind] >= 0) postfxtexs[binds[p.outputbind]].used = -1;
- binds[p.outputbind] = tex;
+ if(postfxbinds[p.outputbind] >= 0) postfxtexs[postfxbinds[p.outputbind]].used = -1;
+ postfxbinds[p.outputbind] = tex;
postfxtexs[tex].used = p.outputbind;
- if(!hasFBO)
- {
- glBindTexture(GL_TEXTURE_RECTANGLE_ARB, postfxtexs[tex].id);
- glCopyTexSubImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, 0, 0, w, h);
- }
}
}
}
@@ -1208,13 +1204,16 @@ ICOMMAND(addpostfx, "siisffff", (char *name, int *bind, int *scale, char *inputs
int inputmask = inputs[0] ? 0 : 1;
int freemask = inputs[0] ? 0 : 1;
bool freeinputs = true;
- for(; *inputs; inputs++) if(isdigit(*inputs))
+ for(; *inputs; inputs++)
{
- inputmask |= 1<<(*inputs-'0');
- if(freeinputs) freemask |= 1<<(*inputs-'0');
+ if(isdigit(*inputs))
+ {
+ inputmask |= 1<<(*inputs-'0');
+ if(freeinputs) freemask |= 1<<(*inputs-'0');
+ }
+ else if(*inputs=='+') freeinputs = false;
+ else if(*inputs=='-') freeinputs = true;
}
- else if(*inputs=='+') freeinputs = false;
- else if(*inputs=='-') freeinputs = true;
inputmask &= (1<<NUMPOSTFXBINDS)-1;
freemask &= (1<<NUMPOSTFXBINDS)-1;
addpostfx(name, clamp(*bind, 0, NUMPOSTFXBINDS-1), max(*scale, 0), inputmask, freemask, vec4(*x, *y, *z, *w));
Please sign in to comment.
Something went wrong with that request. Please try again.