Low resolution reflections in FTEQW
Posted: Sun May 03, 2015 1:59 pm
Hy guys I modified a little altwater.glsl in FTEQW and added the OPACITY filed modifiable by shader like this:
And then ton_reflections.glsl:
Effect is cool and works great but:
Since cubemaps glsl, without help from a skilled coder, can be considered trash (and, incredible as it may sound, it's a frame dropper worse than true reflections!
), I was trying to use low resolution reflections to impact a little less on frame rate, because on an empty scene with 480/500 fps, with reflections activated on all six walls and just one entity framerate drops to 200 /250 fps!
So I edited gl_backend.c GLBE_SubmitMeshesSortList from this
to
And, infact, resolution becomes very low and blocky, that, together with an high OPACITY value, seems blurry, which it's kinda cool! 
The problem is that framerate remains the same!
There's a way to reduce reflection texture size and save some fps?
And, since cubemaps as said it's useless for now, there could be the method to use reflections also on non-flat surfaces with some extra work?
Thanks guys! It's fun messing with GLSL when you have no idea what you're doing!
Code: Select all
//OPACITY=0 - total mirror / OPACITY=100 - no mirror at all
textures/world/mywall
{
program ton_reflections#OPACITY=10
{
map $reflection
}
}Code: Select all
varying vec4 camtransform;
#ifdef VERTEX_SHADER
void main (void)
{
camtransform = ftetransform();
gl_Position = camtransform;
}
#endif
#ifdef FRAGMENT_SHADER
#define reflectionpass s_t0//st0 is the first {}block in the shader. Make sure that $reflection is the first block!
uniform sampler2D reflectionpass;
void main (void)
{
vec2 screnspace;
vec3 reflectionvector;
screnspace = (1.0 + (camtransform.xy / camtransform.w)) * 0.5; //this stores reflection
#ifdef OPACITY
reflectionvector = texture2D(reflectionpass, screnspace).rgb/OPACITY;
#else
reflectionvector = texture2D(reflectionpass, screnspace).rgb;
#endif
gl_FragColor = vec4(reflectionvector, 0.1);
}
#endifSince cubemaps glsl, without help from a skilled coder, can be considered trash (and, incredible as it may sound, it's a frame dropper worse than true reflections!
So I edited gl_backend.c GLBE_SubmitMeshesSortList from this
Code: Select all
r_refdef.vrect.x = 0;
r_refdef.vrect.y = 0;
r_refdef.vrect.width = vid.fbvwidth/2;
r_refdef.vrect.height = vid.fbvheight/2;
r_refdef.pxrect.x = 0;
r_refdef.pxrect.y = 0;
r_refdef.pxrect.width = vid.fbpwidth/2;
r_refdef.pxrect.height = vid.fbpheight/2;
Code: Select all
r_refdef.vrect.x = 0;
r_refdef.vrect.y = 0;
r_refdef.vrect.width = vid.fbvwidth/16;
r_refdef.vrect.height = vid.fbvheight/16;
r_refdef.pxrect.x = 0;
r_refdef.pxrect.y = 0;
r_refdef.pxrect.width = vid.fbpwidth/16;
r_refdef.pxrect.height = vid.fbpheight/16;The problem is that framerate remains the same!
And, since cubemaps as said it's useless for now, there could be the method to use reflections also on non-flat surfaces with some extra work?
Thanks guys! It's fun messing with GLSL when you have no idea what you're doing!