rbsp/fbsp lightstyle support in the default wall shader
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4057 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
aee80e353b
commit
a88b2274c7
1 changed files with 48 additions and 5 deletions
|
@ -1,6 +1,7 @@
|
|||
!!permu OFFSETMAPPING
|
||||
!!permu FULLBRIGHT
|
||||
!!permu FOG
|
||||
!!permu LIGHTSTYLED
|
||||
!!cvarf r_glsl_offsetmapping_scale
|
||||
|
||||
//this is what normally draws all of your walls, even with rtlights disabled
|
||||
|
@ -10,10 +11,24 @@
|
|||
#if defined(OFFSETMAPPING)
|
||||
varying vec3 eyevector;
|
||||
#endif
|
||||
|
||||
varying vec2 tc;
|
||||
#ifdef LIGHTSTYLED
|
||||
//we could use an offset, but that would still need to be per-surface which would break batches
|
||||
//fixme: merge attributes?
|
||||
varying vec2 lm, lm2, lm3, lm4;
|
||||
#else
|
||||
varying vec2 lm;
|
||||
#endif
|
||||
|
||||
#ifdef VERTEX_SHADER
|
||||
attribute vec2 v_texcoord;
|
||||
attribute vec2 v_lmcoord;
|
||||
varying vec2 tc, lm;
|
||||
#ifdef LIGHTSTYLED
|
||||
attribute vec2 v_lmcoord2;
|
||||
attribute vec2 v_lmcoord3;
|
||||
attribute vec2 v_lmcoord4;
|
||||
#endif
|
||||
#if defined(OFFSETMAPPING)
|
||||
uniform vec3 e_eyepos;
|
||||
attribute vec3 v_normal;
|
||||
|
@ -24,16 +39,24 @@ void main ()
|
|||
{
|
||||
#if defined(OFFSETMAPPING)
|
||||
vec3 eyeminusvertex = e_eyepos - v_position.xyz;
|
||||
eyevector.x = dot(eyeminusvertex, v_svector.xyz);
|
||||
eyevector.y = -dot(eyeminusvertex, v_tvector.xyz);
|
||||
eyevector.x = -dot(eyeminusvertex, v_svector.xyz);
|
||||
eyevector.y = dot(eyeminusvertex, v_tvector.xyz);
|
||||
eyevector.z = dot(eyeminusvertex, v_normal.xyz);
|
||||
#endif
|
||||
tc = v_texcoord;
|
||||
lm = v_lmcoord;
|
||||
#ifdef LIGHTSTYLED
|
||||
lm2 = v_lmcoord2;
|
||||
lm3 = v_lmcoord3;
|
||||
lm4 = v_lmcoord4;
|
||||
#endif
|
||||
gl_Position = ftetransform();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef FRAGMENT_SHADER
|
||||
//samplers
|
||||
uniform sampler2D s_t0;
|
||||
uniform sampler2D s_t1;
|
||||
#ifdef OFFSETMAPPING
|
||||
|
@ -42,8 +65,17 @@ uniform sampler2D s_t2;
|
|||
#ifdef FULLBRIGHT
|
||||
uniform sampler2D s_t4;
|
||||
#endif
|
||||
varying vec2 tc, lm;
|
||||
#ifdef LIGHTSTYLED
|
||||
uniform sampler2D s_t5;
|
||||
uniform sampler2D s_t6;
|
||||
uniform sampler2D s_t7;
|
||||
#endif
|
||||
|
||||
#ifdef LIGHTSTYLED
|
||||
uniform vec4 e_lmscale[4];
|
||||
#else
|
||||
uniform vec4 e_lmscale;
|
||||
#endif
|
||||
uniform vec4 e_colourident;
|
||||
#ifdef OFFSETMAPPING
|
||||
#include "sys/offsetmapping.h"
|
||||
|
@ -54,7 +86,18 @@ void main ()
|
|||
vec2 tcoffsetmap = offsetmap(s_t2, tc, eyevector);
|
||||
#define tc tcoffsetmap
|
||||
#endif
|
||||
gl_FragColor = texture2D(s_t0, tc) * texture2D(s_t1, lm) * e_lmscale;
|
||||
gl_FragColor = texture2D(s_t0, tc);
|
||||
#ifdef LIGHTSTYLED
|
||||
vec4 lightmaps;
|
||||
lightmaps = texture2D(s_t1, lm ) * e_lmscale[0];
|
||||
lightmaps += texture2D(s_t5, lm2) * e_lmscale[1];
|
||||
lightmaps += texture2D(s_t6, lm3) * e_lmscale[2];
|
||||
lightmaps += texture2D(s_t7, lm4) * e_lmscale[3];
|
||||
gl_FragColor.rgb *= lightmaps.rgb;
|
||||
#else
|
||||
gl_FragColor.rgb *= texture2D(s_t1, lm) * e_lmscale;
|
||||
#endif
|
||||
|
||||
#ifdef FULLBRIGHT
|
||||
gl_FragColor.rgb += texture2D(s_t4, tc).rgb;
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue