q2w bsp format support.

automatic lightmap texture scaling to retain more performance on large maps.
r_clutter preliminary implementation should probably fix up the shader still.
CSQC_Parse_Damage implemented.
finally implement q2 inventory.
fix mixer overflow crash.
glsl can now use s_diffuse etc to force inclusion of a diffuse sampler/texture, meaning shaders don't need to include them.
fix issue with writeip

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4841 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2015-03-03 00:14:43 +00:00
parent 02ab57490e
commit bed989f529
100 changed files with 3502 additions and 2204 deletions

View file

@ -40,19 +40,16 @@ void main (void)
}
#endif
#ifdef FRAGMENT_SHADER
#define s_refract s_t0
#define s_reflect s_t1
#define s_ripplemap s_t2
#define s_refractdepth s_t3
uniform float cvar_r_glsl_turbscale;
uniform sampler2D s_t0; //refract
uniform sampler2D s_t1; //normalmap
uniform sampler2D s_t2; //diffuse/reflection
#ifdef DEPTH
uniform sampler2D s_t3; //refraction depth
#define s_ripplemap s_t4
#else
#define s_ripplemap s_t3
#endif
#ifdef RIPPLEMAP
uniform sampler2D s_refract; //refract
uniform sampler2D s_reflect; //reflection
uniform sampler2D s_refractdepth; //refraction depth
uniform sampler2D s_ripplemap; //ripplemap
#endif
uniform float e_time;
void main (void)
@ -70,8 +67,8 @@ void main (void)
ntc.t = tc.t + sin(tc.s+e_time)*0.125;
//generate the two wave patterns from the normalmap
n = (texture2D(s_t1, TXSCALE*tc + vec2(e_time*0.1, 0.0)).xyz);
n += (texture2D(s_t1, TXSCALE*tc - vec2(0, e_time*0.097)).xyz);
n = (texture2D(s_normalmap, TXSCALE*tc + vec2(e_time*0.1, 0.0)).xyz);
n += (texture2D(s_normalmap, TXSCALE*tc - vec2(0, e_time*0.097)).xyz);
n -= 1.0 - 4.0/256.0;
#ifdef RIPPLEMAP
@ -90,7 +87,7 @@ void main (void)
sdepth = mix(near, far, sdepth);
//get depth value at the ground beyond the surface.
float gdepth = texture2D(s_t3, stc).x;
float gdepth = texture2D(s_refractdepth, stc).x;
gdepth = (2.0*near) / (far + near - gdepth * (far - near));
if (gdepth >= 0.5)
{
@ -112,16 +109,16 @@ void main (void)
//refraction image (and water fog, if possible)
refr = texture2D(s_t0, stc + n.st*STRENGTH*cvar_r_glsl_turbscale).rgb * TINT;
refr = texture2D(s_refract, stc + n.st*STRENGTH*cvar_r_glsl_turbscale).rgb * TINT;
#ifdef DEPTH
refr = mix(refr, FOGTINT, min(depth/4096.0, 1.0));
#endif
//reflection/diffuse
#ifdef REFLECT
refl = texture2D(s_t2, stc - n.st*STRENGTH*cvar_r_glsl_turbscale).rgb;
refl = texture2D(s_reflect, stc - n.st*STRENGTH*cvar_r_glsl_turbscale).rgb;
#else
refl = texture2D(s_t2, ntc).xyz;
refl = texture2D(s_diffuse, ntc).xyz;
#endif
//FIXME: add specular

View file

@ -7,6 +7,8 @@
!!cvarf r_glsl_offsetmapping_scale
!!cvarf gl_specular
#include "sys/defs.h"
//standard shader used for models.
//must support skeletal and 2-way vertex blending or Bad Things Will Happen.
//the vertex shader is responsible for calculating lighting values.
@ -22,13 +24,6 @@ varying vec3 eyevector;
#ifdef VERTEX_SHADER
#include "sys/skeletal.h"
attribute vec2 v_texcoord;
uniform vec3 e_light_dir;
uniform vec3 e_light_mul;
uniform vec3 e_light_ambient;
#if defined(SPECULAR) || defined(OFFSETMAPPING)
uniform vec3 e_eyepos;
#endif
void main ()
{
#if defined(SPECULAR)||defined(OFFSETMAPPING)
@ -52,25 +47,8 @@ void main ()
#endif
#ifdef FRAGMENT_SHADER
#include "sys/fog.h"
uniform sampler2D s_t0;
#ifdef LOWER
uniform sampler2D s_t1;
uniform vec3 e_lowercolour;
#endif
#ifdef UPPER
uniform sampler2D s_t2;
uniform vec3 e_uppercolour;
#endif
#ifdef FULLBRIGHT
uniform sampler2D s_t3;
#endif
#if defined(BUMP)
uniform sampler2D s_t4;
#endif
#if defined(SPECULAR)
uniform sampler2D s_t5;
uniform float cvar_gl_specular;
#endif
@ -78,31 +56,28 @@ uniform float cvar_gl_specular;
#include "sys/offsetmapping.h"
#endif
uniform vec4 e_colourident;
void main ()
{
vec4 col, sp;
#ifdef OFFSETMAPPING
vec2 tcoffsetmap = offsetmap(s_t4, tc, eyevector);
vec2 tcoffsetmap = offsetmap(s_normalmap, tc, eyevector);
#define tc tcoffsetmap
#endif
col = texture2D(s_t0, tc);
col = texture2D(s_diffuse, tc);
#ifdef UPPER
vec4 uc = texture2D(s_t2, tc);
vec4 uc = texture2D(s_upper, tc);
col.rgb += uc.rgb*e_uppercolour*uc.a;
#endif
#ifdef LOWER
vec4 lc = texture2D(s_t1, tc);
vec4 lc = texture2D(s_lower, tc);
col.rgb += lc.rgb*e_lowercolour*lc.a;
#endif
#if defined(BUMP) && defined(SPECULAR)
vec3 bumps = normalize(vec3(texture2D(s_t4, tc)) - 0.5);
vec4 specs = texture2D(s_t5, tc);
vec3 bumps = normalize(vec3(texture2D(s_normalmap, tc)) - 0.5);
vec4 specs = texture2D(s_specular, tc);
vec3 halfdir = normalize(normalize(eyevector) + vec3(0.0, 0.0, 1.0));
float spec = pow(max(dot(halfdir, bumps), 0.0), 32.0 * specs.a);
@ -112,7 +87,7 @@ void main ()
col.rgb *= light;
#ifdef FULLBRIGHT
vec4 fb = texture2D(s_t3, tc);
vec4 fb = texture2D(s_fullbright, tc);
// col.rgb = mix(col.rgb, fb.rgb, fb.a);
col.rgb += fb.rgb * fb.a;
#endif

View file

@ -7,6 +7,8 @@
!!cvarf r_glsl_offsetmapping_scale
!!cvarf gl_specular
#include "sys/defs.h"
//this is what normally draws all of your walls, even with rtlights disabled
//note that the '286' preset uses drawflat_walls instead.
@ -25,19 +27,6 @@ varying vec2 lm0;
#endif
#ifdef VERTEX_SHADER
attribute vec2 v_texcoord;
attribute vec2 v_lmcoord;
#ifdef LIGHTSTYLED
attribute vec2 v_lmcoord2;
attribute vec2 v_lmcoord3;
attribute vec2 v_lmcoord4;
#endif
#if defined(OFFSETMAPPING) || defined(SPECULAR)
uniform vec3 e_eyepos;
attribute vec3 v_normal;
attribute vec3 v_svector;
attribute vec3 v_tvector;
#endif
void main ()
{
#if defined(OFFSETMAPPING) || defined(SPECULAR)
@ -61,50 +50,9 @@ void main ()
#ifdef FRAGMENT_SHADER
//samplers
#define s_diffuse s_t0
#define s_lightmap0 s_t1
#define s_normalmap s_t2
#define s_delux0 s_t3
#define s_fullbright s_t4
#define s_specular s_t5
#define s_lightmap1 s_t6
#define s_lightmap2 s_t7
#define s_lightmap3 s_t8
#define s_delux1 s_t9
#define s_delux2 s_t10
#define s_delux3 s_t11
#define s_paletted s_diffuse
#define s_colourmap s_fullbright
#define s_colourmap s_t0
uniform sampler2D s_colourmap;
uniform sampler2D s_diffuse;
uniform sampler2D s_lightmap0;
#if defined(BUMP) && (defined(OFFSETMAPPING) || defined(DELUXE) || defined(SPECULAR))
uniform sampler2D s_normalmap;
#endif
#ifdef DELUXE
uniform sampler2D s_delux0;
#endif
#if defined(FULLBRIGHT) || defined(EIGHTBIT)
uniform sampler2D s_fullbright;
#endif
#ifdef SPECULAR
uniform sampler2D s_specular;
#endif
#ifdef LIGHTSTYLED
uniform sampler2D s_lightmap1;
uniform sampler2D s_lightmap2;
uniform sampler2D s_lightmap3;
uniform sampler2D s_delux1;
uniform sampler2D s_delux2;
uniform sampler2D s_delux3;
#endif
#ifdef LIGHTSTYLED
uniform vec4 e_lmscale[4];
#else
uniform vec4 e_lmscale;
#endif
uniform vec4 e_colourident;
#ifdef SPECULAR
uniform float cvar_gl_specular;
#endif
@ -141,10 +89,10 @@ void main ()
#ifdef LIGHTSTYLED
vec3 lightmaps;
#ifdef DELUXE
lightmaps = texture2D(s_lightmap0, lm0).rgb * e_lmscale[0].rgb * dot(norm, 2.0*texture2D(s_delux0, lm0).rgb-0.5);
lightmaps += texture2D(s_lightmap1, lm1).rgb * e_lmscale[1].rgb * dot(norm, 2.0*texture2D(s_delux1, lm1).rgb-0.5);
lightmaps += texture2D(s_lightmap2, lm2).rgb * e_lmscale[2].rgb * dot(norm, 2.0*texture2D(s_delux2, lm2).rgb-0.5);
lightmaps += texture2D(s_lightmap3, lm3).rgb * e_lmscale[3].rgb * dot(norm, 2.0*texture2D(s_delux3, lm3).rgb-0.5);
lightmaps = texture2D(s_lightmap0, lm0).rgb * e_lmscale[0].rgb * dot(norm, 2.0*texture2D(s_deluxmap0, lm0).rgb-0.5);
lightmaps += texture2D(s_lightmap1, lm1).rgb * e_lmscale[1].rgb * dot(norm, 2.0*texture2D(s_deluxmap1, lm1).rgb-0.5);
lightmaps += texture2D(s_lightmap2, lm2).rgb * e_lmscale[2].rgb * dot(norm, 2.0*texture2D(s_deluxmap2, lm2).rgb-0.5);
lightmaps += texture2D(s_lightmap3, lm3).rgb * e_lmscale[3].rgb * dot(norm, 2.0*texture2D(s_deluxmap3, lm3).rgb-0.5);
#else
lightmaps = texture2D(s_lightmap0, lm0).rgb * e_lmscale[0].rgb;
lightmaps += texture2D(s_lightmap1, lm1).rgb * e_lmscale[1].rgb;
@ -152,10 +100,12 @@ void main ()
lightmaps += texture2D(s_lightmap3, lm3).rgb * e_lmscale[3].rgb;
#endif
#else
vec3 lightmaps = (texture2D(s_lightmap0, lm0) * e_lmscale).rgb;
vec3 lightmaps = (texture2D(s_lightmap, lm0) * e_lmscale).rgb;
//modulate by the bumpmap dot light
#ifdef DELUXE
lightmaps *= dot(norm, 2.0*(texture2D(s_delux0, lm0).rgb-0.5));
vec3 delux = 2.0*(texture2D(s_deluxmap, lm0).rgb-0.5);
lightmaps *= 1.0 / max(0.25, delux.z); //counter the darkening from deluxmaps
lightmaps *= dot(norm, delux);
#endif
#endif
@ -164,7 +114,7 @@ void main ()
vec4 specs = texture2D(s_specular, tc);
#ifdef DELUXE
//not lightstyled...
vec3 halfdir = normalize(normalize(eyevector) + 2.0*(texture2D(s_delux0, lm0).rgb-0.5)); //this norm should be the deluxemap info instead
vec3 halfdir = normalize(normalize(eyevector) + 2.0*(texture2D(s_deluxmap0, lm0).rgb-0.5)); //this norm should be the deluxemap info instead
#else
vec3 halfdir = normalize(normalize(eyevector) + vec3(0.0, 0.0, 1.0)); //this norm should be the deluxemap info instead
#endif
@ -179,7 +129,7 @@ void main ()
#ifdef EIGHTBIT //FIXME: with this extra flag, half the permutations are redundant.
lightmaps *= 0.5; //counter the fact that the colourmap contains overbright values and logically ranges from 0 to 2 intead of to 1.
float pal = texture2D(s_diffuse, tc).r; //the palette index. hopefully not interpolated.
float pal = texture2D(s_paletted, tc).r; //the palette index. hopefully not interpolated.
lightmaps -= 1.0 / 128.0; //software rendering appears to round down, so make sure we favour the lower values instead of rounding to the nearest
gl_FragColor.r = texture2D(s_colourmap, vec2(pal, 1.0-lightmaps.r)).r; //do 3 lookups. this is to cope with lit files, would be a waste to not support those.
gl_FragColor.g = texture2D(s_colourmap, vec2(pal, 1.0-lightmaps.g)).g; //its not very softwarey, but re-palettizing is ugly.

View file

@ -1,5 +1,7 @@
!!cvarf r_wateralpha
!!permu FOG
!!cvarf r_wateralpha
#include "sys/defs.h"
//this is the shader that's responsible for drawing default q1 turbulant water surfaces
//this is expected to be moderately fast.
@ -7,16 +9,16 @@
#include "sys/fog.h"
varying vec2 tc;
#ifdef VERTEX_SHADER
attribute vec2 v_texcoord;
void main ()
{
tc = v_texcoord.st;
#ifdef FLOW
tc.s += e_time * -0.5;
#endif
gl_Position = ftetransform();
}
#endif
#ifdef FRAGMENT_SHADER
uniform sampler2D s_t0;
uniform float e_time;
#ifndef ALPHA
uniform float cvar_r_wateralpha;
#define USEALPHA cvar_r_wateralpha
@ -28,7 +30,7 @@ void main ()
vec2 ntc;
ntc.s = tc.s + sin(tc.t+e_time)*0.125;
ntc.t = tc.t + sin(tc.s+e_time)*0.125;
vec3 ts = vec3(texture2D(s_t0, ntc));
vec3 ts = vec3(texture2D(s_diffuse, ntc));
gl_FragColor = fog4(vec4(ts, USEALPHA));
}
#endif