2017-11-15 12:38:20 +00:00
|
|
|
!!ver 100 150
|
2016-11-20 21:05:10 +00:00
|
|
|
!!permu BUMP //for offsetmapping rather than bumpmapping (real bumps are handled elsewhere)
|
|
|
|
!!cvarf r_glsl_offsetmapping_scale
|
2017-10-31 22:52:58 +00:00
|
|
|
!!samps 2
|
2016-11-20 21:05:10 +00:00
|
|
|
|
2012-05-09 15:30:53 +00:00
|
|
|
//the final defered lighting pass.
|
|
|
|
//the lighting values were written to some render target, which is fed into this shader, and now we draw all the wall textures with it.
|
|
|
|
|
2016-11-20 21:05:10 +00:00
|
|
|
#include "sys/defs.h"
|
|
|
|
|
|
|
|
#if defined(OFFSETMAPPING)
|
|
|
|
varying vec3 eyevector;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2012-05-09 15:30:53 +00:00
|
|
|
varying vec2 tc, lm;
|
|
|
|
varying vec4 tf;
|
|
|
|
#ifdef VERTEX_SHADER
|
|
|
|
void main ()
|
|
|
|
{
|
|
|
|
tc = v_texcoord;
|
|
|
|
lm = v_lmcoord;
|
|
|
|
gl_Position = tf = ftetransform();
|
2016-11-20 21:05:10 +00:00
|
|
|
|
|
|
|
#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.z = dot(eyeminusvertex, v_normal.xyz);
|
|
|
|
#endif
|
2012-05-09 15:30:53 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#ifdef FRAGMENT_SHADER
|
2016-11-20 21:05:10 +00:00
|
|
|
#ifdef OFFSETMAPPING
|
|
|
|
#include "sys/offsetmapping.h"
|
|
|
|
#endif
|
2012-05-09 15:30:53 +00:00
|
|
|
void main ()
|
|
|
|
{
|
2016-11-20 21:05:10 +00:00
|
|
|
//adjust texture coords for offsetmapping
|
|
|
|
#ifdef OFFSETMAPPING
|
|
|
|
vec2 tcoffsetmap = offsetmap(s_normalmap, tc, eyevector);
|
|
|
|
#define tc tcoffsetmap
|
|
|
|
#endif
|
|
|
|
|
2012-05-09 15:30:53 +00:00
|
|
|
vec2 nst;
|
|
|
|
nst = tf.xy / tf.w;
|
|
|
|
nst = (1.0 + nst) / 2.0;
|
2017-10-31 22:52:58 +00:00
|
|
|
vec4 dl = texture2D(s_t0, nst); //diffuse lighting
|
|
|
|
vec4 sl = texture2D(s_t1, nst); //specular lighting
|
2016-11-20 21:05:10 +00:00
|
|
|
vec4 c = texture2D(s_diffuse, tc);
|
2017-10-31 22:52:58 +00:00
|
|
|
vec4 s = texture2D(s_specular, tc);
|
|
|
|
vec4 f = texture2D(s_fullbright, tc);
|
2016-11-20 21:05:10 +00:00
|
|
|
//fixme: top+bottom should add upper+lower colours to c here
|
|
|
|
vec3 lmsamp = texture2D(s_lightmap, lm).rgb*e_lmscale.rgb;
|
|
|
|
//fixme: fog the legacy lightmap data
|
2017-10-31 22:52:58 +00:00
|
|
|
vec3 diff = dl.rgb + lmsamp;
|
|
|
|
vec3 spec = sl.rgb * float(SPECMUL); //should be rgb, but whatever.
|
|
|
|
|
2016-11-20 21:05:10 +00:00
|
|
|
//fixme: do specular somehow
|
2017-10-31 22:52:58 +00:00
|
|
|
gl_FragColor = vec4(diff*c.rgb + spec*s.rgb + f.rgb, 1.0);
|
2016-11-20 21:05:10 +00:00
|
|
|
//fixme: fullbrights should add to the rgb value
|
2012-05-09 15:30:53 +00:00
|
|
|
}
|
|
|
|
#endif
|