2012-01-18 02:44:50 +00:00
/*
WARNING : THIS FILE IS GENERATED BY ' generatebuiltinsl . c ' .
YOU SHOULD NOT EDIT THIS FILE BY HAND
*/
2012-05-11 01:57:00 +00:00
# ifdef GLQUAKE
{ QR_OPENGL , 110 , " altwater " ,
2012-11-27 03:23:19 +00:00
" !!cvarf r_glsl_turbscale \n "
2012-07-05 19:42:36 +00:00
//modifier: REFLECT (s_t2 is a reflection instead of diffusemap)
//modifier: STRENGTH (0.1 = fairly gentle, 0.2 = big waves)
2012-05-11 01:57:00 +00:00
//modifier: FRESNEL (5=water)
2012-07-05 19:42:36 +00:00
//modifier: TXSCALE (0.2 - wave strength)
//modifier: RIPPLEMAP (s_t3 contains a ripplemap
//modifier: TINT (some colour value)
2012-11-27 03:23:19 +00:00
" uniform float cvar_r_glsl_turbscale; \n "
2012-07-05 19:42:36 +00:00
" #ifndef FRESNEL \n "
" #define FRESNEL 5.0 \n "
" #endif \n "
" #ifndef STRENGTH \n "
" #define STRENGTH 0.1 \n "
" #endif \n "
" #ifndef TXSCALE \n "
" #define TXSCALE 0.2 \n "
" #endif \n "
" #ifndef TINT \n "
" #define TINT vec3(0.7, 0.8, 0.7) \n "
" #endif \n "
2012-05-11 01:57:00 +00:00
" varying vec2 tc; \n "
" varying vec4 tf; \n "
" varying vec3 norm; \n "
" varying vec3 eye; \n "
" #ifdef VERTEX_SHADER \n "
" attribute vec2 v_texcoord; \n "
" attribute vec3 v_normal; \n "
" uniform vec3 e_eyepos; \n "
" void main (void) \n "
" { \n "
" tc = v_texcoord.st; \n "
" tf = ftetransform(); \n "
" norm = v_normal; \n "
" eye = e_eyepos - v_position.xyz; \n "
" gl_Position = tf; \n "
" } \n "
" #endif \n "
" #ifdef FRAGMENT_SHADER \n "
" uniform sampler2D s_t0; //refract \n "
" uniform sampler2D s_t1; //normalmap \n "
2012-07-05 19:42:36 +00:00
" uniform sampler2D s_t2; //diffuse/reflection \n "
" #ifdef RIPPLEMAP \n "
" uniform sampler2D s_t3; //ripplemap \n "
2012-05-11 01:57:00 +00:00
" #endif \n "
" uniform float e_time; \n "
" void main (void) \n "
" { \n "
" vec2 stc, ntc; \n "
" vec3 n, refr, refl, fres; \n "
" float f; \n "
" stc = (1.0 + (tf.xy / tf.w)) * 0.5; \n "
//apply q1-style warp, just for kicks
" ntc.s = tc.s + sin(tc.t+e_time)*0.125; \n "
" ntc.t = tc.t + sin(tc.s+e_time)*0.125; \n "
//generate the two wave patterns from the normalmap
2012-09-30 05:52:03 +00:00
" n = (texture2D(s_t1, TXSCALE*tc + vec2(e_time*0.1, 0.0)).xyz); \n "
2012-07-05 19:42:36 +00:00
" n += (texture2D(s_t1, TXSCALE*tc - vec2(0, e_time*0.097)).xyz); \n "
2012-05-11 01:57:00 +00:00
" n -= 1.0 - 4.0/256.0; \n "
2012-07-05 19:42:36 +00:00
" #ifdef RIPPLEMAP \n "
2013-03-12 22:35:33 +00:00
" n += texture2D(s_t3, stc).rgb*3.0; \n "
2012-05-11 01:57:00 +00:00
" #endif \n "
2012-07-05 19:42:36 +00:00
//the fresnel term decides how transparent the water should be
" f = pow(1.0-abs(dot(normalize(n), normalize(eye))), float(FRESNEL)); \n "
2012-11-27 03:23:19 +00:00
" refr = texture2D(s_t0, stc + n.st*STRENGTH*cvar_r_glsl_turbscale).rgb * TINT; \n "
2012-05-11 01:57:00 +00:00
" #ifdef REFLECT \n "
2012-11-27 03:23:19 +00:00
" refl = texture2D(s_t2, stc - n.st*STRENGTH*cvar_r_glsl_turbscale).rgb; \n "
2012-05-11 01:57:00 +00:00
" #else \n "
" refl = texture2D(s_t2, ntc).xyz; \n "
" #endif \n "
2012-07-05 19:42:36 +00:00
// refl += 0.1*pow(dot(n, vec3(0.0,0.0,1.0)), 64.0);
2012-05-11 01:57:00 +00:00
" fres = refr * (1.0-f) + refl*f; \n "
2012-07-05 19:42:36 +00:00
// fres = texture2D(s_t2, stc).xyz;
2012-05-11 01:57:00 +00:00
" gl_FragColor = vec4(fres, 1.0); \n "
" } \n "
" #endif \n "
} ,
# endif
2012-01-18 02:44:50 +00:00
# ifdef GLQUAKE
{ QR_OPENGL , 110 , " bloom_blur " ,
//apply gaussian filter
" varying vec2 tc; \n "
" #ifdef VERTEX_SHADER \n "
" attribute vec2 v_texcoord; \n "
" void main () \n "
" { \n "
" tc = v_texcoord; \n "
" gl_Position = ftetransform(); \n "
" } \n "
" #endif \n "
" #ifdef FRAGMENT_SHADER \n "
/*offset should be 1.2 pixels away from the center*/
" uniform vec3 e_glowmod; \n "
" uniform sampler2D s_t0; \n "
" void main () \n "
" { \n "
" gl_FragColor = \n "
" 0.3125 * texture2D(s_t0, tc - e_glowmod.st) + \n "
" 0.375 * texture2D(s_t0, tc) + \n "
" 0.3125 * texture2D(s_t0, tc + e_glowmod.st); \n "
" } \n "
" #endif \n "
} ,
# endif
# ifdef GLQUAKE
{ QR_OPENGL , 110 , " bloom_filter " ,
2012-05-11 01:57:00 +00:00
" !!cvarv r_bloom_filter \n "
2012-01-18 02:44:50 +00:00
//the bloom filter
//filter out any texels which are not to bloom
2012-05-11 01:57:00 +00:00
" uniform vec3 cvar_r_bloom_filter; \n "
2012-01-18 02:44:50 +00:00
" varying vec2 tc; \n "
" #ifdef VERTEX_SHADER \n "
" attribute vec2 v_texcoord; \n "
" void main () \n "
" { \n "
" tc = v_texcoord; \n "
" gl_Position = ftetransform(); \n "
" } \n "
" #endif \n "
" #ifdef FRAGMENT_SHADER \n "
" uniform sampler2D s_t0; \n "
" void main () \n "
" { \n "
2012-05-11 01:57:00 +00:00
" gl_FragColor.rgb = (texture2D(s_t0, tc).rgb - cvar_r_bloom_filter)/(1.0-cvar_r_bloom_filter); \n "
2012-01-18 02:44:50 +00:00
" } \n "
" #endif \n "
} ,
# endif
# ifdef GLQUAKE
{ QR_OPENGL , 110 , " bloom_final " ,
2012-05-11 01:57:00 +00:00
" !!cvarf r_bloom \n "
" uniform float cvar_r_bloom; \n "
2012-01-18 02:44:50 +00:00
//add them together
//optionally apply tonemapping
" varying vec2 tc; \n "
" #ifdef VERTEX_SHADER \n "
" attribute vec2 v_texcoord; \n "
" void main () \n "
" { \n "
" tc = v_texcoord; \n "
" gl_Position = ftetransform(); \n "
" } \n "
" #endif \n "
" #ifdef FRAGMENT_SHADER \n "
" uniform sampler2D s_t0; \n "
" uniform sampler2D s_t1; \n "
" uniform sampler2D s_t2; \n "
" uniform sampler2D s_t3; \n "
" void main () \n "
" { \n "
" gl_FragColor = \n "
" texture2D(s_t0, tc) + \n "
2012-05-11 01:57:00 +00:00
" cvar_r_bloom*( \n "
2012-01-18 02:44:50 +00:00
" texture2D(s_t1, tc) + \n "
" texture2D(s_t2, tc) + \n "
2012-05-11 01:57:00 +00:00
" texture2D(s_t3, tc) \n "
" ) ; \n "
2012-01-18 02:44:50 +00:00
" } \n "
" #endif \n "
} ,
# endif
2012-05-09 15:30:53 +00:00
# ifdef GLQUAKE
{ QR_OPENGL , 110 , " colourtint " ,
//this glsl shader is useful for cubemapped post processing effects (see csaddon for an example)
" varying vec4 tf; \n "
" #ifdef VERTEX_SHADER \n "
" void main () \n "
" { \n "
" gl_Position = tf = vec4(v_position.xy,-1.0, 1.0); \n "
" } \n "
" #endif \n "
" #ifdef FRAGMENT_SHADER \n "
" uniform sampler2D s_t0; \n "
" uniform sampler3D s_t1; \n "
" void main() \n "
" { \n "
" vec2 fc; \n "
" fc = tf.xy / tf.w; \n "
" vec3 raw = texture2D(s_t0, (1.0 + fc) / 2.0).rgb; \n "
" #define LUTSIZE 16.0 \n "
" vec3 scale = vec3((LUTSIZE-1.0)/LUTSIZE); \n "
" vec3 bias = vec3(1.0/(2.0*LUTSIZE)); \n "
" gl_FragColor = texture3D(s_t1, raw * scale + bias); \n "
" } \n "
" #endif \n "
} ,
# endif
# ifdef GLQUAKE
{ QR_OPENGL , 110 , " crepuscular_opaque " ,
//opaque surfaces are drawn to the render target to mask out skies
" #ifdef VERTEX_SHADER \n "
" void main () \n "
" { \n "
" gl_Position = ftetransform(); \n "
" } \n "
" #endif \n "
" #ifdef FRAGMENT_SHADER \n "
" void main() \n "
" { \n "
" gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); \n "
" } \n "
" #endif \n "
} ,
# endif
# ifdef GLQUAKE
{ QR_OPENGL , 110 , " crepuscular_rays " ,
" !!cvarf crep_decay \n "
" !!cvarf crep_density \n "
" !!cvarf crep_weight \n "
//this is a post-processing shader, drawn in 2d
//there will be a render target containing sky surfaces drawn with crepuscular_sky, and everything else drawn with crepuscular_opaque (to mask out the sky)
//this shader then just smudges the sky out a bit as though its coming from the sun or whatever through the clouds.
//yoinked from http://fabiensanglard.net/lightScattering/index.php
" varying vec2 tc; \n "
" #ifdef VERTEX_SHADER \n "
" attribute vec2 v_texcoord; \n "
" void main () \n "
" { \n "
" tc = v_texcoord; \n "
" gl_Position = v_position; \n "
" } \n "
" #endif \n "
" #ifdef FRAGMENT_SHADER \n "
" const float crep_decay = 0.94; \n "
" const float crep_density = 0.5; \n "
" const float crep_weight = 0.2; \n "
" uniform vec3 l_lightcolour; \n "
" uniform vec3 l_lightscreen; \n "
" uniform sampler2D s_t0; \n "
" const int NUM_SAMPLES = 100; \n "
" void main() \n "
" { \n "
" vec2 deltaTextCoord = vec2(tc.st - l_lightscreen.xy); \n "
" vec2 textCoo = tc.st; \n "
" deltaTextCoord *= 1.0 / float(NUM_SAMPLES) * crep_density; \n "
" float illuminationDecay = 1.0; \n "
" for(int i=0; i < NUM_SAMPLES ; i++) \n "
" { \n "
" textCoo -= deltaTextCoord; \n "
" vec4 sample = texture2D(s_t0, textCoo); \n "
" sample *= illuminationDecay * crep_weight; \n "
" gl_FragColor += sample; \n "
" illuminationDecay *= crep_decay; \n "
" } \n "
" gl_FragColor *= vec4(l_lightcolour, 1.0); \n "
" } \n "
" #endif \n "
} ,
# endif
# ifdef GLQUAKE
{ QR_OPENGL , 110 , " crepuscular_sky " ,
//pretty much a regular sky shader
//though in reality we should render a sun circle in the middle.
//still, its kinda cool to have scrolling clouds masking out parts of the sun.
" #ifdef VERTEX_SHADER \n "
" varying vec3 pos; \n "
" void main () \n "
" { \n "
" pos = v_position.xyz; \n "
" gl_Position = ftetransform(); \n "
" } \n "
" #endif \n "
" #ifdef FRAGMENT_SHADER \n "
" uniform float e_time; \n "
" uniform vec3 e_eyepos; \n "
" varying vec3 pos; \n "
" uniform sampler2D s_t0; \n "
" uniform sampler2D s_t1; \n "
" void main () \n "
" { \n "
" vec2 tccoord; \n "
" vec3 dir = pos - e_eyepos; \n "
" dir.z *= 3.0; \n "
" dir.xy /= 0.5*length(dir); \n "
" tccoord = (dir.xy + e_time*0.03125); \n "
" vec3 solid = vec3(texture2D(s_t0, tccoord)); \n "
" tccoord = (dir.xy + e_time*0.0625); \n "
" vec4 clouds = texture2D(s_t1, tccoord); \n "
" gl_FragColor.rgb = (solid.rgb*(1.0-clouds.a)) + (clouds.a*clouds.rgb); \n "
" } \n "
" #endif \n "
} ,
# endif
# ifdef GLQUAKE
{ QR_OPENGL , 110 , " default2d " ,
//this shader is present for support for gles/gl3core contexts
//it is single-texture-with-vertex-colours, and doesn't do anything special.
//beware that a few things use this, including apparently fonts and bloom rescaling.
//its really not meant to do anything special.
2012-09-30 05:52:03 +00:00
" varying vec2 tc; \n "
" varying vec4 vc; \n "
2012-05-09 15:30:53 +00:00
" #ifdef VERTEX_SHADER \n "
" attribute vec2 v_texcoord; \n "
" attribute vec4 v_colour; \n "
" void main () \n "
" { \n "
" tc = v_texcoord; \n "
" vc = v_colour; \n "
" gl_Position = ftetransform(); \n "
" } \n "
" #endif \n "
" #ifdef FRAGMENT_SHADER \n "
" uniform sampler2D s_t0; \n "
" void main () \n "
" { \n "
" gl_FragColor = texture2D(s_t0, tc) * vc; \n "
" } \n "
" #endif \n "
} ,
# endif
2012-11-27 03:23:19 +00:00
# ifdef D3D11QUAKE
{ QR_DIRECT3D11 , 11 , " default2d " ,
" struct a2v \n "
" { \n "
" float4 pos: POSITION; \n "
" float2 tc: TEXCOORD0; \n "
" float4 vcol: COLOR0; \n "
" }; \n "
" struct v2f \n "
" { \n "
" float4 pos: SV_POSITION; \n "
" float2 tc: TEXCOORD0; \n "
" float4 vcol: COLOR0; \n "
" }; \n "
" #include <ftedefs.h> \n "
" #ifdef VERTEX_SHADER \n "
" v2f main (a2v inp) \n "
" { \n "
" v2f outp; \n "
" outp.pos = mul(m_projection, inp.pos); \n "
" outp.tc = inp.tc; \n "
" outp.vcol = inp.vcol; \n "
" return outp; \n "
" } \n "
" #endif \n "
" #ifdef FRAGMENT_SHADER \n "
" Texture2D shaderTexture; \n "
" SamplerState SampleType; \n "
" float4 main (v2f inp) : SV_TARGET \n "
" { \n "
" return shaderTexture.Sample(SampleType, inp.tc) * inp.vcol; \n "
" } \n "
" #endif \n "
} ,
# endif
2012-05-09 15:30:53 +00:00
# ifdef GLQUAKE
{ QR_OPENGL , 110 , " defaultadditivesprite " ,
" !!permu FOG \n "
//meant to be used for additive stuff. presumably particles and sprites. though actually its only flashblend effects that use this at the time of writing.
//includes fog, apparently.
" #include \" sys/fog.h \" \n "
" #ifdef VERTEX_SHADER \n "
" attribute vec2 v_texcoord; \n "
" attribute vec4 v_colour; \n "
" varying vec2 tc; \n "
" varying vec4 vc; \n "
" void main () \n "
" { \n "
" tc = v_texcoord; \n "
" vc = v_colour; \n "
" gl_Position = ftetransform(); \n "
" } \n "
" #endif \n "
" #ifdef FRAGMENT_SHADER \n "
" uniform sampler2D s_t0; \n "
" varying vec2 tc; \n "
" varying vec4 vc; \n "
" uniform vec4 e_colourident; \n "
" void main () \n "
" { \n "
" gl_FragColor = fog4additive(texture2D(s_t0, tc) * vc * e_colourident); \n "
" } \n "
" #endif \n "
} ,
# endif
# ifdef GLQUAKE
{ QR_OPENGL , 110 , " defaultskin " ,
" !!permu FULLBRIGHT \n "
" !!permu UPPERLOWER \n "
" !!permu FRAMEBLEND \n "
" !!permu SKELETAL \n "
" !!permu FOG \n "
2013-03-12 22:35:33 +00:00
" !!cvarf r_glsl_offsetmapping_scale \n "
" !!cvarf gl_specular \n "
2012-05-09 15:30:53 +00:00
//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.
2013-03-12 22:35:33 +00:00
" #ifdef UPPERLOWER \n "
" #define UPPER \n "
" #define LOWER \n "
" #endif \n "
2012-05-09 15:30:53 +00:00
" varying vec2 tc; \n "
" varying vec3 light; \n "
2013-03-12 22:35:33 +00:00
" #if defined(SPECULAR) || defined(OFFSETMAPPING) \n "
" varying vec3 eyevector; \n "
" #endif \n "
2012-05-09 15:30:53 +00:00
" #ifdef VERTEX_SHADER \n "
" #include \" sys/skeletal.h \" \n "
" attribute vec2 v_texcoord; \n "
" uniform vec3 e_light_dir; \n "
" uniform vec3 e_light_mul; \n "
" uniform vec3 e_light_ambient; \n "
2013-03-12 22:35:33 +00:00
" #if defined(SPECULAR) || defined(OFFSETMAPPING) \n "
" uniform vec3 e_eyepos; \n "
" #endif \n "
2012-05-09 15:30:53 +00:00
" void main () \n "
" { \n "
2013-03-12 22:35:33 +00:00
" #if defined(SPECULAR)||defined(OFFSETMAPPING) \n "
" vec3 n, s, t, w; \n "
" gl_Position = skeletaltransform_wnst(w,n,s,t); \n "
" vec3 eyeminusvertex = e_eyepos - w.xyz; \n "
" eyevector.x = -dot(eyeminusvertex, s.xyz); \n "
" eyevector.y = dot(eyeminusvertex, t.xyz); \n "
" eyevector.z = dot(eyeminusvertex, n.xyz); \n "
" #else \n "
2012-05-09 15:30:53 +00:00
" vec3 n; \n "
" gl_Position = skeletaltransform_n(n); \n "
2013-03-12 22:35:33 +00:00
" #endif \n "
2012-05-09 15:30:53 +00:00
" light = e_light_ambient + (dot(n,e_light_dir)*e_light_mul); \n "
" tc = v_texcoord; \n "
" } \n "
" #endif \n "
" #ifdef FRAGMENT_SHADER \n "
" #include \" sys/fog.h \" \n "
" uniform sampler2D s_t0; \n "
" #ifdef LOWER \n "
" uniform sampler2D s_t1; \n "
" uniform vec3 e_lowercolour; \n "
" #endif \n "
" #ifdef UPPER \n "
" uniform sampler2D s_t2; \n "
" uniform vec3 e_uppercolour; \n "
" #endif \n "
" #ifdef FULLBRIGHT \n "
" uniform sampler2D s_t3; \n "
" #endif \n "
2013-03-12 22:35:33 +00:00
" #if defined(SPECULAR) \n "
" uniform sampler2D s_t4; \n "
" uniform sampler2D s_t5; \n "
" uniform float cvar_gl_specular; \n "
" #endif \n "
" #ifdef OFFSETMAPPING \n "
" #include \" sys/offsetmapping.h \" \n "
" #endif \n "
2012-05-09 15:30:53 +00:00
" uniform vec4 e_colourident; \n "
" void main () \n "
" { \n "
" vec4 col, sp; \n "
2013-03-12 22:35:33 +00:00
" #ifdef OFFSETMAPPING \n "
" vec2 tcoffsetmap = offsetmap(s_t1, tcbase, eyevector); \n "
" #define tc tcoffsetmap \n "
" #endif \n "
2012-05-09 15:30:53 +00:00
" col = texture2D(s_t0, tc); \n "
" #ifdef UPPER \n "
" vec4 uc = texture2D(s_t2, tc); \n "
2013-03-12 22:35:33 +00:00
" col.rgb += uc.rgb*e_uppercolour*uc.a; \n "
2012-05-09 15:30:53 +00:00
" #endif \n "
" #ifdef LOWER \n "
" vec4 lc = texture2D(s_t1, tc); \n "
2013-03-12 22:35:33 +00:00
" col.rgb += lc.rgb*e_lowercolour*lc.a; \n "
2012-05-09 15:30:53 +00:00
" #endif \n "
" col.rgb *= light; \n "
2013-03-12 22:35:33 +00:00
" #if defined(SPECULAR) \n "
" vec3 bumps = normalize(vec3(texture2D(s_t4, tc)) - 0.5); \n "
" vec4 specs = texture2D(s_t5, tc); \n "
" vec3 halfdir = normalize(normalize(eyevector) + vec3(0.0, 0.0, 1.0)); \n "
" float spec = pow(max(dot(halfdir, bumps), 0.0), 32.0 * specs.a); \n "
" col.rgb += cvar_gl_specular * spec * specs.rgb; \n "
" #endif \n "
2012-05-09 15:30:53 +00:00
" #ifdef FULLBRIGHT \n "
" vec4 fb = texture2D(s_t3, tc); \n "
" col.rgb = mix(col.rgb, fb.rgb, fb.a); \n "
" #endif \n "
2013-03-12 22:35:33 +00:00
2012-05-09 15:30:53 +00:00
" gl_FragColor = fog4(col * e_colourident); \n "
" } \n "
" #endif \n "
} ,
# endif
2012-11-27 03:23:19 +00:00
# ifdef D3D11QUAKE
{ QR_DIRECT3D11 , 11 , " defaultskin " ,
" struct a2v \n "
" { \n "
" float4 pos: POSITION; \n "
" float4 tc: TEXCOORD0; \n "
" float3 normal: NORMAL; \n "
" }; \n "
" struct v2f \n "
" { \n "
" float4 pos: SV_POSITION; \n "
" float2 tc: TEXCOORD0; \n "
" float3 light: TEXCOORD1; \n "
" }; \n "
" #include <ftedefs.h> \n "
" #ifdef VERTEX_SHADER \n "
//attribute vec2 v_texcoord;
//uniform vec3 e_light_dir;
//uniform vec3 e_light_mul;
//uniform vec3 e_light_ambient;
" v2f main (a2v inp) \n "
" { \n "
" v2f outp; \n "
" outp.pos = mul(m_model, inp.pos); \n "
" outp.pos = mul(m_view, outp.pos); \n "
" outp.pos = mul(m_projection, outp.pos); \n "
" outp.light = e_light_ambient + (dot(inp.normal,e_light_dir)*e_light_mul); \n "
" outp.tc = inp.tc.xy; \n "
" return outp; \n "
" } \n "
" #endif \n "
" #ifdef FRAGMENT_SHADER \n "
" Texture2D shaderTexture[4]; //diffuse, lower, upper, fullbright \n "
" SamplerState SampleType; \n "
//uniform vec4 e_colourident;
" float4 main (v2f inp) : SV_TARGET \n "
" { \n "
" float4 col; \n "
" col = shaderTexture[0].Sample(SampleType, inp.tc); \n "
" #ifdef UPPER \n "
" float4 uc = shaderTexture[2].Sample(SampleType, inp.tc); \n "
" col.rgb = mix(col.rgb, uc.rgb*e_uppercolour, uc.a); \n "
" #endif \n "
" #ifdef LOWER \n "
" float4 lc = shaderTexture[1].Sample(SampleType, inp.tc); \n "
" col.rgb = mix(col.rgb, lc.rgb*e_lowercolour, lc.a); \n "
" #endif \n "
" col.rgb *= inp.light; \n "
" #ifdef FULLBRIGHT \n "
" float4 fb = shaderTexture[3].Sample(SampleType, inp.tc); \n "
" col.rgb = mix(col.rgb, fb.rgb, fb.a); \n "
" #endif \n "
" return col; \n "
// return fog4(col * e_colourident);
" } \n "
" #endif \n "
} ,
# endif
2012-05-09 15:30:53 +00:00
# ifdef GLQUAKE
{ QR_OPENGL , 110 , " defaultsky " ,
//regular sky shader for scrolling q1 skies
//the sky surfaces are thrown through this as-is.
" #ifdef VERTEX_SHADER \n "
" varying vec3 pos; \n "
" void main () \n "
" { \n "
" pos = v_position.xyz; \n "
" gl_Position = ftetransform(); \n "
" } \n "
" #endif \n "
" #ifdef FRAGMENT_SHADER \n "
" uniform float e_time; \n "
" uniform vec3 e_eyepos; \n "
" varying vec3 pos; \n "
" uniform sampler2D s_t0; \n "
" uniform sampler2D s_t1; \n "
" void main () \n "
" { \n "
" vec2 tccoord; \n "
" vec3 dir = pos - e_eyepos; \n "
" dir.z *= 3.0; \n "
" dir.xy /= 0.5*length(dir); \n "
" tccoord = (dir.xy + e_time*0.03125); \n "
" vec3 solid = vec3(texture2D(s_t0, tccoord)); \n "
" tccoord = (dir.xy + e_time*0.0625); \n "
" vec4 clouds = texture2D(s_t1, tccoord); \n "
" gl_FragColor.rgb = (solid.rgb*(1.0-clouds.a)) + (clouds.a*clouds.rgb); \n "
" } \n "
" #endif \n "
} ,
# endif
2012-11-27 03:23:19 +00:00
# ifdef D3D9QUAKE
{ QR_DIRECT3D9 , 9 , " defaultsky " ,
" struct a2v \n "
" { \n "
" float4 pos: POSITION; \n "
" }; \n "
" struct v2f \n "
" { \n "
" #ifndef FRAGMENT_SHADER \n "
" float4 pos: POSITION; \n "
" #endif \n "
" float3 vpos: TEXCOORD0; \n "
" }; \n "
" #ifdef VERTEX_SHADER \n "
" float4x4 m_modelviewprojection; \n "
" v2f main (a2v inp) \n "
" { \n "
" v2f outp; \n "
" outp.pos = mul(m_modelviewprojection, inp.pos); \n "
" outp.vpos = inp.pos; \n "
" return outp; \n "
" } \n "
" #endif \n "
" #ifdef FRAGMENT_SHADER \n "
" float e_time; \n "
" float3 e_eyepos; \n "
" float l_lightradius; \n "
" float3 l_lightcolour; \n "
" float3 l_lightposition; \n "
" sampler s_t0; /*diffuse*/ \n "
" sampler s_t1; /*normal*/ \n "
" sampler s_t2; /*specular*/ \n "
" float4 main (v2f inp) : COLOR0 \n "
" { \n "
" float2 tccoord; \n "
" float3 dir = inp.vpos - e_eyepos; \n "
" dir.z *= 3.0; \n "
" dir.xy /= 0.5*length(dir); \n "
" tccoord = (dir.xy + e_time*0.03125); \n "
" float4 solid = tex2D(s_t0, tccoord); \n "
" tccoord = (dir.xy + e_time*0.0625); \n "
" float4 clouds = tex2D(s_t1, tccoord); \n "
" return float4((solid.rgb*(1.0-clouds.a)) + (clouds.a*clouds.rgb), 1); \n "
" } \n "
" #endif \n "
} ,
# endif
# ifdef D3D11QUAKE
{ QR_DIRECT3D11 , 11 , " defaultsky " ,
//regular sky shader for scrolling q1 skies
//the sky surfaces are thrown through this as-is.
" struct a2v \n "
" { \n "
" float4 pos: POSITION; \n "
" float2 tc: TEXCOORD0; \n "
" }; \n "
" struct v2f \n "
" { \n "
" float4 pos: SV_POSITION; \n "
" float2 tc: TEXCOORD0; \n "
" float3 mpos: TEXCOORD1; \n "
" }; \n "
" #include <ftedefs.h> \n "
" #ifdef VERTEX_SHADER \n "
" v2f main (a2v inp) \n "
" { \n "
" v2f outp; \n "
" outp.pos = mul(m_model, inp.pos); \n "
" outp.mpos = outp.pos.xyz; \n "
" outp.pos = mul(m_view, outp.pos); \n "
" outp.pos = mul(m_projection, outp.pos); \n "
" outp.tc = inp.tc; \n "
" return outp; \n "
" } \n "
" #endif \n "
" #ifdef FRAGMENT_SHADER \n "
" Texture2D shaderTexture[2]; \n "
" SamplerState SampleType; \n "
" float4 main (v2f inp) : SV_TARGET \n "
" { \n "
" float2 tccoord; \n "
" float3 dir = inp.mpos - v_eyepos; \n "
" dir.z *= 3.0; \n "
" dir.xy /= 0.5*length(dir); \n "
" tccoord = (dir.xy + e_time*0.03125); \n "
" float4 solid = shaderTexture[0].Sample(SampleType, tccoord); \n "
" tccoord = (dir.xy + e_time*0.0625); \n "
" float4 clouds = shaderTexture[1].Sample(SampleType, tccoord); \n "
" return (solid*(1.0-clouds.a)) + (clouds.a*clouds); \n "
" } \n "
" #endif \n "
} ,
# endif
2012-05-09 15:30:53 +00:00
# ifdef GLQUAKE
{ QR_OPENGL , 110 , " defaultsprite " ,
" !!permu FOG \n "
//used by both particles and sprites.
//note the fog blending mode is all that differs from defaultadditivesprite
" #include \" sys/fog.h \" \n "
" #ifdef VERTEX_SHADER \n "
" attribute vec2 v_texcoord; \n "
" attribute vec4 v_colour; \n "
" varying vec2 tc; \n "
" varying vec4 vc; \n "
" void main () \n "
" { \n "
" tc = v_texcoord; \n "
" vc = v_colour; \n "
" gl_Position = ftetransform(); \n "
" } \n "
" #endif \n "
" #ifdef FRAGMENT_SHADER \n "
" uniform sampler2D s_t0; \n "
" varying vec2 tc; \n "
" varying vec4 vc; \n "
" uniform vec4 e_colourident; \n "
" void main () \n "
" { \n "
" gl_FragColor = fog4blend(texture2D(s_t0, tc) * vc * e_colourident); \n "
" } \n "
" #endif \n "
} ,
# endif
2012-11-27 03:23:19 +00:00
# ifdef D3D11QUAKE
{ QR_DIRECT3D11 , 11 , " defaultsprite " ,
" struct a2v \n "
" { \n "
" float4 pos: POSITION; \n "
" float4 tc: TEXCOORD0; \n "
" float4 vcol: COLOR0; \n "
" }; \n "
" struct v2f \n "
" { \n "
" float4 pos: SV_POSITION; \n "
" float2 tc: TEXCOORD0; \n "
" float4 vcol: COLOR0; \n "
" }; \n "
" #include <ftedefs.h> \n "
" #ifdef VERTEX_SHADER \n "
" v2f main (a2v inp) \n "
" { \n "
" v2f outp; \n "
" outp.pos = mul(m_model, inp.pos); \n "
" outp.pos = mul(m_view, outp.pos); \n "
" outp.pos = mul(m_projection, outp.pos); \n "
" outp.tc = inp.tc.xy; \n "
" outp.vcol = inp.vcol; \n "
" return outp; \n "
" } \n "
" #endif \n "
" #ifdef FRAGMENT_SHADER \n "
" Texture2D shaderTexture; \n "
" SamplerState SampleType; \n "
" float4 main (v2f inp) : SV_TARGET \n "
" { \n "
" return shaderTexture.Sample(SampleType, inp.tc) * inp.vcol; \n "
" } \n "
" #endif \n "
} ,
# endif
2012-05-09 15:30:53 +00:00
# ifdef GLQUAKE
{ QR_OPENGL , 110 , " defaultwall " ,
2012-10-08 04:36:10 +00:00
" !!permu DELUXE \n "
2012-05-09 15:30:53 +00:00
" !!permu FULLBRIGHT \n "
" !!permu FOG \n "
2012-07-05 19:42:36 +00:00
" !!permu LIGHTSTYLED \n "
2012-10-08 04:36:10 +00:00
" !!permu BUMP \n "
2012-11-27 03:23:19 +00:00
" !!permu SPECULAR \n "
2012-05-09 15:30:53 +00:00
" !!cvarf r_glsl_offsetmapping_scale \n "
2012-11-27 03:23:19 +00:00
" !!cvarf gl_specular \n "
2012-05-09 15:30:53 +00:00
//this is what normally draws all of your walls, even with rtlights disabled
//note that the '286' preset uses drawflat_walls instead.
" #include \" sys/fog.h \" \n "
2012-11-27 03:23:19 +00:00
" #if defined(OFFSETMAPPING) || defined(SPECULAR) \n "
2012-05-09 15:30:53 +00:00
" varying vec3 eyevector; \n "
" #endif \n "
2012-07-05 19:42:36 +00:00
" varying vec2 tc; \n "
" #ifdef LIGHTSTYLED \n "
//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; \n "
" #else \n "
" varying vec2 lm; \n "
" #endif \n "
2012-05-09 15:30:53 +00:00
" #ifdef VERTEX_SHADER \n "
" attribute vec2 v_texcoord; \n "
" attribute vec2 v_lmcoord; \n "
2012-07-05 19:42:36 +00:00
" #ifdef LIGHTSTYLED \n "
" attribute vec2 v_lmcoord2; \n "
" attribute vec2 v_lmcoord3; \n "
" attribute vec2 v_lmcoord4; \n "
" #endif \n "
2012-11-27 03:23:19 +00:00
" #if defined(OFFSETMAPPING) || defined(SPECULAR) \n "
2012-05-09 15:30:53 +00:00
" uniform vec3 e_eyepos; \n "
" attribute vec3 v_normal; \n "
" attribute vec3 v_svector; \n "
" attribute vec3 v_tvector; \n "
" #endif \n "
" void main () \n "
" { \n "
2012-11-27 03:23:19 +00:00
" #if defined(OFFSETMAPPING) || defined(SPECULAR) \n "
2012-05-09 15:30:53 +00:00
" vec3 eyeminusvertex = e_eyepos - v_position.xyz; \n "
2012-07-05 19:42:36 +00:00
" eyevector.x = -dot(eyeminusvertex, v_svector.xyz); \n "
" eyevector.y = dot(eyeminusvertex, v_tvector.xyz); \n "
2012-05-09 15:30:53 +00:00
" eyevector.z = dot(eyeminusvertex, v_normal.xyz); \n "
" #endif \n "
" tc = v_texcoord; \n "
" lm = v_lmcoord; \n "
2012-07-05 19:42:36 +00:00
" #ifdef LIGHTSTYLED \n "
" lm2 = v_lmcoord2; \n "
" lm3 = v_lmcoord3; \n "
" lm4 = v_lmcoord4; \n "
" #endif \n "
2012-05-09 15:30:53 +00:00
" gl_Position = ftetransform(); \n "
" } \n "
" #endif \n "
2012-07-05 19:42:36 +00:00
2012-05-09 15:30:53 +00:00
" #ifdef FRAGMENT_SHADER \n "
2012-07-05 19:42:36 +00:00
//samplers
2012-10-08 04:36:10 +00:00
" uniform sampler2D s_t0; //diffuse \n "
" uniform sampler2D s_t1; //lightmap0 \n "
2012-11-27 03:23:19 +00:00
" #if defined(BUMP) && (defined(OFFSETMAPPING) || defined(DELUXE) || defined(SPECULAR)) \n "
" uniform sampler2D s_t2; //normal.rgb+height.a \n "
2012-05-09 15:30:53 +00:00
" #endif \n "
2012-10-08 04:36:10 +00:00
" uniform sampler2D s_t3; //deluxe0 \n "
2012-05-09 15:30:53 +00:00
" #ifdef FULLBRIGHT \n "
2012-10-08 04:36:10 +00:00
" uniform sampler2D s_t4; //fullbright \n "
2012-05-09 15:30:53 +00:00
" #endif \n "
2012-11-27 03:23:19 +00:00
" #ifdef SPECULAR \n "
" uniform sampler2D s_t5; //specular \n "
" #endif \n "
2012-07-05 19:42:36 +00:00
" #ifdef LIGHTSTYLED \n "
2012-11-27 03:23:19 +00:00
" uniform sampler2D s_t6; //lightmap1 \n "
" uniform sampler2D s_t7; //lightmap2 \n "
" uniform sampler2D s_t8; //lightmap3 \n "
" uniform sampler2D s_t9; //deluxe1 \n "
" uniform sampler2D s_t10; //deluxe2 \n "
" uniform sampler2D s_t11; //deluxe3 \n "
2012-07-05 19:42:36 +00:00
" #endif \n "
" #ifdef LIGHTSTYLED \n "
" uniform vec4 e_lmscale[4]; \n "
" #else \n "
2012-05-09 15:30:53 +00:00
" uniform vec4 e_lmscale; \n "
2012-07-05 19:42:36 +00:00
" #endif \n "
2012-05-09 15:30:53 +00:00
" uniform vec4 e_colourident; \n "
2012-11-27 03:23:19 +00:00
" #ifdef SPECULAR \n "
" uniform float cvar_gl_specular; \n "
" #endif \n "
2012-05-09 15:30:53 +00:00
" #ifdef OFFSETMAPPING \n "
" #include \" sys/offsetmapping.h \" \n "
" #endif \n "
" void main () \n "
" { \n "
2012-10-08 04:36:10 +00:00
//adjust texture coords for offsetmapping
2012-05-09 15:30:53 +00:00
" #ifdef OFFSETMAPPING \n "
" vec2 tcoffsetmap = offsetmap(s_t2, tc, eyevector); \n "
" #define tc tcoffsetmap \n "
" #endif \n "
2012-10-08 04:36:10 +00:00
//yay, regular texture!
2012-07-05 19:42:36 +00:00
" gl_FragColor = texture2D(s_t0, tc); \n "
2012-10-08 04:36:10 +00:00
2012-11-27 03:23:19 +00:00
" #if defined(BUMP) && (defined(DELUXE) || defined(SPECULAR)) \n "
" vec3 norm = normalize(texture2D(s_t2, tc).rgb - 0.5); \n "
" #elif defined(SPECULAR) || defined(DELUXE) \n "
" vec3 norm = vec3(0, 0, 1); //specular lighting expects this to exist. \n "
" #endif \n "
2012-10-08 04:36:10 +00:00
//modulate that by the lightmap(s) including deluxemap(s)
2012-07-05 19:42:36 +00:00
" #ifdef LIGHTSTYLED \n "
2012-11-27 03:23:19 +00:00
" vec3 lightmaps; \n "
2012-10-08 04:36:10 +00:00
" #ifdef DELUXE \n "
2012-11-27 03:23:19 +00:00
" lightmaps = texture2D(s_t1, lm ).rgb * e_lmscale[0].rgb * dot(norm, texture2D(s_t3, lm ).rgb); \n "
" lightmaps += texture2D(s_t6, lm2).rgb * e_lmscale[1].rgb * dot(norm, texture2D(s_t9, lm2).rgb); \n "
" lightmaps += texture2D(s_t7, lm3).rgb * e_lmscale[2].rgb * dot(norm, texture2D(s_t10, lm3).rgb); \n "
" lightmaps += texture2D(s_t8, lm4).rgb * e_lmscale[3].rgb * dot(norm, texture2D(s_t11,lm4).rgb); \n "
2012-10-08 04:36:10 +00:00
" #else \n "
2012-11-27 03:23:19 +00:00
" lightmaps = texture2D(s_t1, lm ).rgb * e_lmscale[0].rgb; \n "
" lightmaps += texture2D(s_t6, lm2).rgb * e_lmscale[1].rgb; \n "
" lightmaps += texture2D(s_t7, lm3).rgb * e_lmscale[2].rgb; \n "
" lightmaps += texture2D(s_t8, lm4).rgb * e_lmscale[3].rgb; \n "
2012-10-08 04:36:10 +00:00
" #endif \n "
2012-07-05 19:42:36 +00:00
" #else \n "
2012-11-27 03:23:19 +00:00
" vec3 lightmaps = (texture2D(s_t1, lm) * e_lmscale).rgb; \n "
//modulate by the bumpmap dot light
2012-10-08 04:36:10 +00:00
" #ifdef DELUXE \n "
2012-11-27 03:23:19 +00:00
" lightmaps *= dot(norm, 2.0*(texture2D(s_t3, lm).rgb-0.5)); \n "
" #endif \n "
" #endif \n "
" #ifdef SPECULAR \n "
" vec4 specs = texture2D(s_t5, tc); \n "
" #ifdef DELUXE \n "
//not lightstyled...
" vec3 halfdir = normalize(normalize(eyevector) + 2.0*(texture2D(s_t3, lm).rgb-0.5)); //this norm should be the deluxemap info instead \n "
2012-10-08 04:36:10 +00:00
" #else \n "
2012-11-27 03:23:19 +00:00
" vec3 halfdir = normalize(normalize(eyevector) + vec3(0.0, 0.0, 1.0)); //this norm should be the deluxemap info instead \n "
2012-07-05 19:42:36 +00:00
" #endif \n "
2012-11-27 03:23:19 +00:00
" float spec = pow(max(dot(halfdir, norm), 0.0), 32.0 * specs.a); \n "
" spec *= cvar_gl_specular; \n "
//NOTE: rtlights tend to have a *4 scaler here to over-emphasise the effect because it looks cool.
//As not all maps will have deluxemapping, and the double-cos from the light util makes everything far too dark anyway,
//we default to something that is not garish when the light value is directly infront of every single pixel.
//we can justify this difference due to the rtlight editor etc showing the *4.
" gl_FragColor.rgb += spec * specs.rgb; \n "
2012-10-08 04:36:10 +00:00
" #endif \n "
2012-07-05 19:42:36 +00:00
2012-11-27 03:23:19 +00:00
//now we have our diffuse+specular terms, modulate by lightmap values.
" gl_FragColor.rgb *= lightmaps.rgb; \n "
2012-10-08 04:36:10 +00:00
//add on the fullbright
2012-05-09 15:30:53 +00:00
" #ifdef FULLBRIGHT \n "
" gl_FragColor.rgb += texture2D(s_t4, tc).rgb; \n "
" #endif \n "
2012-10-08 04:36:10 +00:00
//entity modifiers
2012-05-09 15:30:53 +00:00
" gl_FragColor = gl_FragColor * e_colourident; \n "
2012-10-08 04:36:10 +00:00
//and finally hide it all if we're fogged.
2012-05-09 15:30:53 +00:00
" #ifdef FOG \n "
" gl_FragColor = fog4(gl_FragColor); \n "
" #endif \n "
" } \n "
" #endif \n "
} ,
# endif
2012-11-27 03:23:19 +00:00
# ifdef D3D11QUAKE
{ QR_DIRECT3D11 , 11 , " defaultwall " ,
" struct a2v \n "
" { \n "
" float4 pos: POSITION; \n "
" float4 tc: TEXCOORD0; \n "
" }; \n "
" struct v2f \n "
" { \n "
" float4 pos: SV_POSITION; \n "
" float2 tc: TEXCOORD0; \n "
" float2 lmtc: TEXCOORD1; \n "
" }; \n "
" #include <ftedefs.h> \n "
" #ifdef VERTEX_SHADER \n "
" v2f main (a2v inp) \n "
" { \n "
" v2f outp; \n "
" outp.pos = mul(m_model, inp.pos); \n "
" outp.pos = mul(m_view, outp.pos); \n "
" outp.pos = mul(m_projection, outp.pos); \n "
" outp.tc = inp.tc.xy; \n "
" outp.lmtc = inp.tc.zw; \n "
" return outp; \n "
" } \n "
" #endif \n "
" #ifdef FRAGMENT_SHADER \n "
" Texture2D shaderTexture[2]; \n "
" SamplerState SampleType[2]; \n "
" float4 main (v2f inp) : SV_TARGET \n "
" { \n "
" return shaderTexture[0].Sample(SampleType[0], inp.tc) * shaderTexture[1].Sample(SampleType[1], inp.lmtc).bgra; \n "
" } \n "
" #endif \n "
} ,
# endif
2012-05-09 15:30:53 +00:00
# ifdef GLQUAKE
{ QR_OPENGL , 110 , " defaultwarp " ,
" !!cvarf r_wateralpha \n "
" !!permu FOG \n "
//this is the shader that's responsible for drawing default q1 turbulant water surfaces
//this is expected to be moderately fast.
" #include \" sys/fog.h \" \n "
" varying vec2 tc; \n "
" #ifdef VERTEX_SHADER \n "
" attribute vec2 v_texcoord; \n "
" void main () \n "
" { \n "
" tc = v_texcoord.st; \n "
" gl_Position = ftetransform(); \n "
" } \n "
" #endif \n "
" #ifdef FRAGMENT_SHADER \n "
" uniform sampler2D s_t0; \n "
" uniform float e_time; \n "
" uniform float cvar_r_wateralpha; \n "
" void main () \n "
" { \n "
" vec2 ntc; \n "
" ntc.s = tc.s + sin(tc.t+e_time)*0.125; \n "
" ntc.t = tc.t + sin(tc.s+e_time)*0.125; \n "
" vec3 ts = vec3(texture2D(s_t0, ntc)); \n "
" gl_FragColor = fog4(vec4(ts, cvar_r_wateralpha)); \n "
" } \n "
" #endif \n "
} ,
# endif
2012-11-27 03:23:19 +00:00
# ifdef D3D9QUAKE
{ QR_DIRECT3D9 , 9 , " defaultwarp " ,
" !!cvarf r_wateralpha \n "
" struct a2v { \n "
" float4 pos: POSITION; \n "
" float2 tc: TEXCOORD0; \n "
" }; \n "
" struct v2f { \n "
" #ifndef FRAGMENT_SHADER \n "
" float4 pos: POSITION; \n "
" #endif \n "
" float2 tc: TEXCOORD0; \n "
" }; \n "
" #ifdef VERTEX_SHADER \n "
" float4x4 m_modelviewprojection; \n "
" v2f main (a2v inp) \n "
" { \n "
" v2f outp; \n "
" outp.pos = mul(m_modelviewprojection, inp.pos); \n "
" outp.tc = inp.tc; \n "
" return outp; \n "
" } \n "
" #endif \n "
" #ifdef FRAGMENT_SHADER \n "
" float cvar_r_wateralpha; \n "
" float e_time; \n "
" sampler s_t0; \n "
" float4 main (v2f inp) : COLOR0 \n "
" { \n "
" float2 ntc; \n "
" ntc.x = inp.tc.x + sin(inp.tc.y+e_time)*0.125; \n "
" ntc.y = inp.tc.y + sin(inp.tc.x+e_time)*0.125; \n "
" float3 ts = tex2D(s_t0, ntc).xyz; \n "
" return float4(ts, cvar_r_wateralpha); \n "
" } \n "
" #endif \n "
} ,
# endif
# ifdef D3D11QUAKE
{ QR_DIRECT3D11 , 11 , " defaultwarp " ,
" !!cvarf r_wateralpha \n "
" struct a2v \n "
" { \n "
" float4 pos: POSITION; \n "
" float2 tc: TEXCOORD0; \n "
" }; \n "
" struct v2f \n "
" { \n "
" float4 pos: SV_POSITION; \n "
" float2 tc: TEXCOORD0; \n "
" }; \n "
" #include <ftedefs.h> \n "
" #ifdef VERTEX_SHADER \n "
" v2f main (a2v inp) \n "
" { \n "
" v2f outp; \n "
" outp.pos = mul(m_model, inp.pos); \n "
" outp.pos = mul(m_view, outp.pos); \n "
" outp.pos = mul(m_projection, outp.pos); \n "
" outp.tc = inp.tc; \n "
" return outp; \n "
" } \n "
" #endif \n "
" #ifdef FRAGMENT_SHADER \n "
// float cvar_r_wateralpha;
// float e_time;
// sampler s_t0;
" Texture2D shaderTexture; \n "
" SamplerState SampleType; \n "
" float4 main (v2f inp) : SV_TARGET \n "
" { \n "
" float2 ntc; \n "
" ntc.x = inp.tc.x + sin(inp.tc.y+e_time)*0.125; \n "
" ntc.y = inp.tc.y + sin(inp.tc.x+e_time)*0.125; \n "
" return shaderTexture.Sample(SampleType, ntc); \n "
" } \n "
" #endif \n "
} ,
# endif
2012-05-09 15:30:53 +00:00
# ifdef GLQUAKE
{ QR_OPENGL , 110 , " drawflat_wall " ,
" !!cvarv r_floorcolor \n "
" !!cvarv r_wallcolor \n "
" !!permu FOG \n "
//this is for the '286' preset walls, and just draws lightmaps coloured based upon surface normals.
" #include \" sys/fog.h \" \n "
" varying vec4 col; \n "
" #ifdef VERTEX_SHADER \n "
" attribute vec3 v_normal; \n "
" attribute vec2 v_lmcoord; \n "
" varying vec2 lm; \n "
" uniform vec3 cvar_r_wallcolor; \n "
" uniform vec3 cvar_r_floorcolor; \n "
" uniform vec4 e_lmscale; \n "
" void main () \n "
" { \n "
" col = vec4(e_lmscale.rgb/255.0 * ((v_normal.z < 0.73)?cvar_r_wallcolor:cvar_r_floorcolor), e_lmscale.a); \n "
" lm = v_lmcoord; \n "
" gl_Position = ftetransform(); \n "
" } \n "
" #endif \n "
" #ifdef FRAGMENT_SHADER \n "
" uniform sampler2D s_t0; \n "
" varying vec2 lm; \n "
" void main () \n "
" { \n "
" gl_FragColor = fog4(col * texture2D(s_t0, lm)); \n "
" } \n "
" #endif \n "
} ,
# endif
2012-11-27 03:23:19 +00:00
# ifdef D3D11QUAKE
{ QR_DIRECT3D11 , 11 , " drawflat_wall " ,
" struct a2v \n "
" { \n "
" float4 pos: POSITION; \n "
" float4 tc: TEXCOORD0; \n "
" float3 norm: NORMAL; \n "
" }; \n "
" struct v2f \n "
" { \n "
" float4 pos: SV_POSITION; \n "
" float2 tc: TEXCOORD0; \n "
" float2 lmtc: TEXCOORD1; \n "
" float4 col: TEXCOORD2; \n "
" }; \n "
" #include <ftedefs.h> \n "
" #ifdef VERTEX_SHADER \n "
" v2f main (a2v inp) \n "
" { \n "
" v2f outp; \n "
" outp.pos = mul(m_model, inp.pos); \n "
" outp.pos = mul(m_view, outp.pos); \n "
" outp.pos = mul(m_projection, outp.pos); \n "
" outp.tc = inp.tc.xy; \n "
" outp.lmtc = inp.tc.zw; \n "
" outp.col = ((inp.norm.z<0.73)?float4(0.5, 0.5, 0.5, 1):float4(0.25, 0.25, 0.5, 1)); \n "
" return outp; \n "
" } \n "
" #endif \n "
" #ifdef FRAGMENT_SHADER \n "
" Texture2D shaderTexture; \n "
" SamplerState SampleType; \n "
" float4 main (v2f inp) : SV_TARGET \n "
" { \n "
" return inp.col * shaderTexture.Sample(SampleType, inp.lmtc); \n "
" } \n "
" #endif \n "
} ,
# endif
2012-05-09 15:30:53 +00:00
# ifdef GLQUAKE
{ QR_OPENGL , 110 , " lpp_depthnorm " ,
" !!permu BUMP \n "
" !!permu SKELETAL \n "
//light pre-pass rendering (defered lighting)
//this is the initial pass, that draws the surface normals and depth to the initial colour buffer
" varying vec3 norm, tang, bitang; \n "
" #if defined(BUMP) \n "
" varying vec2 tc; \n "
" #endif \n "
" #ifdef VERTEX_SHADER \n "
" #include \" sys/skeletal.h \" \n "
" attribute vec2 v_texcoord; \n "
" void main() \n "
" { \n "
" #if defined(BUMP) \n "
" gl_Position = skeletaltransform_nst(norm, tang, bitang); \n "
" tc = v_texcoord; \n "
" #else \n "
" gl_Position = skeletaltransform_n(norm); \n "
" #endif \n "
" } \n "
" #endif \n "
" #ifdef FRAGMENT_SHADER \n "
" #if defined(BUMP) \n "
" uniform sampler2D s_t0; \n "
" #endif \n "
" void main() \n "
" { \n "
" vec3 onorm; \n "
" #if defined(BUMP) \n "
" vec3 bm = 2.0*texture2D(s_t0, tc).xyz - 1.0; \n "
" onorm = normalize(bm.x * tang + bm.y * bitang + bm.z * norm); \n "
" #else \n "
" onorm = norm; \n "
" #endif \n "
" gl_FragColor = vec4(onorm.xyz, gl_FragCoord.z / gl_FragCoord.w); \n "
" } \n "
" #endif \n "
} ,
# endif
# ifdef GLQUAKE
{ QR_OPENGL , 110 , " lpp_light " ,
//this shader is a light shader. ideally drawn with a quad covering the entire region
//the output is contribution from this light (which will be additively blended)
//you can blame Electro for much of the maths in here.
//fixme: no fog
" varying vec4 tf; \n "
" #ifdef VERTEX_SHADER \n "
" void main() \n "
" { \n "
" tf = ftetransform(); \n "
" gl_Position = tf; \n "
" } \n "
" #endif \n "
" #ifdef FRAGMENT_SHADER \n "
" uniform sampler2D s_t0; \n "
" uniform vec3 l_lightposition; \n "
" uniform mat4 m_invviewprojection; \n "
" uniform vec3 l_lightcolour; \n "
" uniform float l_lightradius; \n "
" vec3 calcLightWorldPos(vec2 screenPos, float depth) \n "
" { \n "
" vec4 pos; \n "
" pos.x = screenPos.x; \n "
" pos.y = screenPos.y; \n "
" pos.z = depth; \n "
" pos.w = 1.0; \n "
" pos = m_invviewprojection * pos; \n "
" return pos.xyz / pos.w; \n "
" } \n "
" void main () \n "
" { \n "
" vec3 lightColour = l_lightcolour.rgb; \n "
" float lightIntensity = 1.0; \n "
" float lightAttenuation = l_lightradius; // fixme: just use the light radius for now, use better near/far att math separately once working \n "
" float radiusFar = l_lightradius; \n "
" float radiusNear = l_lightradius*0.5; \n "
" vec2 fc; \n "
" fc = tf.xy / tf.w; \n "
" vec4 data = texture2D(s_t0, (1.0 + fc) / 2.0); \n "
" float depth = data.a; \n "
" vec3 norm = data.xyz; \n "
/* calc where the wall that generated this sample came from */
" vec3 worldPos = calcLightWorldPos(fc, depth); \n "
/*calc diffuse lighting term*/
" vec3 lightDir = l_lightposition - worldPos; \n "
" float zdiff = 1.0 - clamp(length(lightDir) / lightAttenuation, 0.0, 1.0); \n "
" float atten = (radiusFar * zdiff) / (radiusFar - radiusNear); \n "
" atten = pow(atten, 2.0); \n "
" lightDir = normalize(lightDir); \n "
" float nDotL = dot(norm, lightDir) * atten; \n "
" float lightDiffuse = max(0.0, nDotL); \n "
" gl_FragColor = vec4(lightDiffuse * (lightColour * lightIntensity), 1.0); \n "
" } \n "
" #endif \n "
} ,
# endif
# ifdef GLQUAKE
{ QR_OPENGL , 110 , " lpp_wall " ,
//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.
" varying vec2 tc, lm; \n "
" varying vec4 tf; \n "
" #ifdef VERTEX_SHADER \n "
" attribute vec2 v_texcoord; \n "
" attribute vec2 v_lmcoord; \n "
" void main () \n "
" { \n "
" tc = v_texcoord; \n "
" lm = v_lmcoord; \n "
" gl_Position = tf = ftetransform(); \n "
" } \n "
" #endif \n "
" #ifdef FRAGMENT_SHADER \n "
" uniform sampler2D s_t0; \n "
" uniform sampler2D s_t1; \n "
" uniform sampler2D s_t2; \n "
" uniform vec4 e_lmscale; \n "
" void main () \n "
" { \n "
" vec2 nst; \n "
" nst = tf.xy / tf.w; \n "
" nst = (1.0 + nst) / 2.0; \n "
" vec4 l = texture2D(s_t0, nst)*5.0; \n "
" vec4 c = texture2D(s_t1, tc); \n "
" vec3 lmsamp = texture2D(s_t2, lm).rgb*lmscale; \n "
" vec3 diff = l.rgb; \n "
" vec3 chrom = diff / (0.001 + dot(diff, vec3(0.3, 0.59, 0.11))); \n "
" vec3 spec = chrom * l.a; \n "
" gl_FragColor = vec4((diff + lmsamp) * c.xyz, 1.0); \n "
" } \n "
" #endif \n "
} ,
# endif
# ifdef GLQUAKE
{ QR_OPENGL , 110 , " postproc_fisheye " ,
" !!cvarf ffov \n "
//fisheye view rendering, for silly fovs that are still playable.
" #ifdef VERTEX_SHADER \n "
" attribute vec2 v_texcoord; \n "
" varying vec2 texcoord; \n "
" void main() \n "
" { \n "
" texcoord = v_texcoord.xy; \n "
" gl_Position = ftetransform(); \n "
" } \n "
" #endif \n "
" #ifdef FRAGMENT_SHADER \n "
" uniform samplerCube s_t0; \n "
" varying vec2 texcoord; \n "
" uniform float cvar_ffov; \n "
" void main() \n "
" { \n "
" vec3 tc; \n "
" vec2 d; \n "
" vec2 ang; \n "
" d = texcoord; \n "
" ang.x = sqrt(d.x*d.x+d.y*d.y)*radians(cvar_ffov); \n "
" ang.y = -atan(d.y, d.x); \n "
" tc.x = sin(ang.x) * cos(ang.y); \n "
" tc.y = sin(ang.x) * sin(ang.y); \n "
" tc.z = cos(ang.x); \n "
" gl_FragColor = textureCube(s_t0, tc); \n "
" } \n "
" #endif \n "
} ,
# endif
# ifdef GLQUAKE
{ QR_OPENGL , 110 , " postproc_panorama " ,
" !!cvarf ffov \n "
//panoramic view rendering, for promo map shots or whatever.
" #ifdef VERTEX_SHADER \n "
" attribute vec2 v_texcoord; \n "
" varying vec2 texcoord; \n "
" void main() \n "
" { \n "
" texcoord = v_texcoord.xy; \n "
" gl_Position = ftetransform(); \n "
" } \n "
" #endif \n "
" #ifdef FRAGMENT_SHADER \n "
" uniform samplerCube s_t0; \n "
" varying vec2 texcoord; \n "
" uniform float cvar_ffov; \n "
" void main() \n "
" { \n "
" vec3 tc; \n "
" float ang; \n "
" ang = texcoord.x*-radians(cvar_ffov); \n "
" tc.x = sin(ang); \n "
" tc.y = -texcoord.y; \n "
" tc.z = cos(ang); \n "
" gl_FragColor = textureCube(s_t0, tc); \n "
" } \n "
" #endif \n "
} ,
# endif
# ifdef GLQUAKE
{ QR_OPENGL , 110 , " rtlight " ,
" !!permu BUMP \n "
" !!permu SKELETAL \n "
2013-03-12 22:35:33 +00:00
" !!permu UPPERLOWER \n "
2012-05-09 15:30:53 +00:00
" !!permu FOG \n "
" !!cvarf r_glsl_offsetmapping_scale \n "
//this is the main shader responsible for realtime dlights.
//texture units:
//s0=diffuse, s1=normal, s2=specular, s3=shadowmap
//custom modifiers:
//PCF(shadowmap)
2012-08-04 01:35:52 +00:00
//CUBEPROJ(projected cubemap)
//SPOT(projected circle
//CUBESHADOW
" #if 0 && defined(GL_ARB_texture_gather) && defined(PCF) \n "
" #extension GL_ARB_texture_gather : enable \n "
" #endif \n "
2012-05-09 15:30:53 +00:00
2013-03-12 22:35:33 +00:00
" #ifdef UPPERLOWER \n "
" #define UPPER \n "
" #define LOWER \n "
" #endif \n "
2012-05-09 15:30:53 +00:00
" varying vec2 tcbase; \n "
" varying vec3 lightvector; \n "
" #if defined(SPECULAR) || defined(OFFSETMAPPING) \n "
" varying vec3 eyevector; \n "
" #endif \n "
2012-12-04 19:39:25 +00:00
" #if defined(PCF) || defined(CUBEPROJ) || defined(SPOT) \n "
2012-08-04 01:35:52 +00:00
" varying vec4 vtexprojcoord; \n "
" uniform mat4 l_cubematrix; \n "
" #ifndef SPOT \n "
2012-05-09 15:30:53 +00:00
" uniform mat4 l_projmatrix; \n "
" #endif \n "
2012-08-04 01:35:52 +00:00
" #endif \n "
2012-05-09 15:30:53 +00:00
" #ifdef VERTEX_SHADER \n "
" #include \" sys/skeletal.h \" \n "
" uniform vec3 l_lightposition; \n "
" attribute vec2 v_texcoord; \n "
" #if defined(SPECULAR) || defined(OFFSETMAPPING) \n "
" uniform vec3 e_eyepos; \n "
" #endif \n "
" void main () \n "
" { \n "
" vec3 n, s, t, w; \n "
" gl_Position = skeletaltransform_wnst(w,n,s,t); \n "
" tcbase = v_texcoord; //pass the texture coords straight through \n "
" vec3 lightminusvertex = l_lightposition - w.xyz; \n "
2012-07-05 19:42:36 +00:00
" lightvector.x = -dot(lightminusvertex, s.xyz); \n "
2012-05-09 15:30:53 +00:00
" lightvector.y = dot(lightminusvertex, t.xyz); \n "
" lightvector.z = dot(lightminusvertex, n.xyz); \n "
" #if defined(SPECULAR)||defined(OFFSETMAPPING) \n "
" vec3 eyeminusvertex = e_eyepos - w.xyz; \n "
2012-07-05 19:42:36 +00:00
" eyevector.x = -dot(eyeminusvertex, s.xyz); \n "
" eyevector.y = dot(eyeminusvertex, t.xyz); \n "
2012-05-09 15:30:53 +00:00
" eyevector.z = dot(eyeminusvertex, n.xyz); \n "
" #endif \n "
2012-08-04 01:35:52 +00:00
" #if defined(PCF) || defined(SPOT) || defined(PROJECTION) \n "
//for texture projections/shadowmapping on dlights
" vtexprojcoord = (l_cubematrix*vec4(w.xyz, 1.0)); \n "
2012-05-09 15:30:53 +00:00
" #endif \n "
" } \n "
" #endif \n "
2012-08-04 01:35:52 +00:00
2012-05-09 15:30:53 +00:00
" #ifdef FRAGMENT_SHADER \n "
" #include \" sys/fog.h \" \n "
2013-03-12 22:35:33 +00:00
" uniform sampler2D s_t0; //diffuse \n "
2012-08-04 01:35:52 +00:00
2012-05-09 15:30:53 +00:00
" #if defined(BUMP) || defined(SPECULAR) || defined(OFFSETMAPPING) \n "
2013-03-12 22:35:33 +00:00
" uniform sampler2D s_t1; //normalmap \n "
2012-05-09 15:30:53 +00:00
" #endif \n "
" #ifdef SPECULAR \n "
2013-03-12 22:35:33 +00:00
" uniform sampler2D s_t2; //specular \n "
2012-05-09 15:30:53 +00:00
" #endif \n "
2012-08-04 01:35:52 +00:00
" #ifdef CUBEPROJ \n "
2013-03-12 22:35:33 +00:00
" uniform samplerCube s_t3; //projected cubemap \n "
2012-05-09 15:30:53 +00:00
" #endif \n "
" #ifdef PCF \n "
2012-08-04 01:35:52 +00:00
" #ifdef CUBESHADOW \n "
2013-03-12 22:35:33 +00:00
" uniform samplerCubeShadow s_t4; //shadowmap \n "
2012-05-09 15:30:53 +00:00
" #else \n "
2012-08-04 01:35:52 +00:00
" #if 0//def GL_ARB_texture_gather \n "
" uniform sampler2D s_t4; \n "
" #else \n "
" uniform sampler2DShadow s_t4; \n "
2012-05-09 15:30:53 +00:00
" #endif \n "
" #endif \n "
2012-08-04 01:35:52 +00:00
" #endif \n "
2013-03-12 22:35:33 +00:00
" #ifdef LOWER \n "
" uniform sampler2D s_t5; //pants colours \n "
" uniform vec3 e_lowercolour; \n "
" #endif \n "
" #ifdef UPPER \n "
" uniform sampler2D s_t6; //shirt colours \n "
" uniform vec3 e_uppercolour; \n "
" #endif \n "
2012-08-04 01:35:52 +00:00
2012-05-09 15:30:53 +00:00
" uniform float l_lightradius; \n "
" uniform vec3 l_lightcolour; \n "
" uniform vec3 l_lightcolourscale; \n "
2012-08-04 01:35:52 +00:00
" #ifdef PCF \n "
//#define shadow2DProj(t,c) (vec2(1.0,1.0))
//#define shadow2DProj(t,c) texture2DProj(t,c).rg
" float ShadowmapFilter(void) \n "
" { \n "
" #ifdef SPOT \n "
" const vec3 texscale = vec3(1.0/512.0, 1.0/512.0, 1.0); \n "
" #else \n "
" const vec3 texscale = vec3(1.0/(512.0*3.0), 1.0/(512.0*2.0), 1.0); \n "
" #endif \n "
//dehomogonize input
" vec3 shadowcoord = (vtexprojcoord.xyz / vtexprojcoord.w); \n "
" #ifdef CUBESHADOW \n "
// vec3 shadowcoord = vshadowcoord.xyz / vshadowcoord.w;
// #define dosamp(x,y) shadowCube(s_t4, shadowcoord + vec2(x,y)*texscale.xy).r
" #else \n "
" #ifdef SPOT \n "
//bias it. don't bother figuring out which side or anything, its not needed
//l_projmatrix contains the light's projection matrix so no other magic needed
" shadowcoord.xyz = (shadowcoord.xyz + vec3(1.0, 1.0, 1.0)) * vec3(0.5, 0.5, 0.5); \n "
" #else \n "
//figure out which axis to use
//texture is arranged thusly:
//forward left up
//back right down
" vec3 dir = abs(shadowcoord); \n "
//assume z is the major axis (ie: forward from the light)
" vec3 t = shadowcoord; \n "
" float ma = dir.z; \n "
2013-03-12 22:35:33 +00:00
" vec3 axis = vec3(1.0, 1.0, 1.0); \n "
2012-08-04 01:35:52 +00:00
" if (dir.x > ma) \n "
" { \n "
" ma = dir.x; \n "
" t = shadowcoord.zyx; \n "
" axis.x = 3.0; \n "
" } \n "
" if (dir.y > ma) \n "
" { \n "
" ma = dir.y; \n "
" t = shadowcoord.xzy; \n "
" axis.x = 5.0; \n "
" } \n "
" if (t.z > 0.0) \n "
" { \n "
" axis.y = 3.0; \n "
" t.z = -t.z; \n "
" } \n "
//we also need to pass the result through the light's projection matrix too
" vec4 nsc =l_projmatrix*vec4(t, 1.0); \n "
" shadowcoord = (nsc.xyz / nsc.w); \n "
//now bias and relocate it
" shadowcoord = (shadowcoord + axis.xyz) * vec3(0.5/3.0, 0.5/2.0, 0.5); \n "
" #endif \n "
" #if 0//def GL_ARB_texture_gather \n "
" vec2 ipart, fpart; \n "
" #define dosamp(x,y) textureGatherOffset(s_t4, ipart.xy, vec2(x,y))) \n "
" vec4 tl = step(shadowcoord.z, dosamp(-1.0, -1.0)); \n "
" vec4 bl = step(shadowcoord.z, dosamp(-1.0, 1.0)); \n "
" vec4 tr = step(shadowcoord.z, dosamp(1.0, -1.0)); \n "
" vec4 br = step(shadowcoord.z, dosamp(1.0, 1.0)); \n "
//we now have 4*4 results, woo
//we can just average them for 1/16th precision, but that's still limited graduations
//the middle four pixels are 'full strength', but we interpolate the sides to effectively give 3*3
" vec4 col = vec4(tl.ba, tr.ba) + vec4(bl.rg, br.rg) + //middle two rows are full strength \n "
" mix(vec4(tl.rg, tr.rg), vec4(bl.ba, br.ba), fpart.y); //top+bottom rows \n "
" return dot(mix(col.rgb, col.agb, fpart.x), vec3(1.0/9.0)); //blend r+a, gb are mixed because its pretty much free and gives a nicer dot instruction instead of lots of adds. \n "
" #else \n "
" #define dosamp(x,y) shadow2D(s_t4, shadowcoord.xyz + (vec3(x,y,0.0)*texscale.xyz)).r \n "
" float s = 0.0; \n "
" s += dosamp(-1.0, -1.0); \n "
" s += dosamp(-1.0, 0.0); \n "
" s += dosamp(-1.0, 1.0); \n "
" s += dosamp(0.0, -1.0); \n "
" s += dosamp(0.0, 0.0); \n "
" s += dosamp(0.0, 1.0); \n "
" s += dosamp(1.0, -1.0); \n "
" s += dosamp(1.0, 0.0); \n "
" s += dosamp(1.0, 1.0); \n "
" return s/9.0; \n "
" #endif \n "
" #endif \n "
" } \n "
" #endif \n "
2012-05-09 15:30:53 +00:00
" #ifdef OFFSETMAPPING \n "
" #include \" sys/offsetmapping.h \" \n "
" #endif \n "
" void main () \n "
" { \n "
2012-07-05 19:42:36 +00:00
//read raw texture samples (offsetmapping munges the tex coords first)
2012-05-09 15:30:53 +00:00
" #ifdef OFFSETMAPPING \n "
" vec2 tcoffsetmap = offsetmap(s_t1, tcbase, eyevector); \n "
" #define tcbase tcoffsetmap \n "
" #endif \n "
" vec3 bases = vec3(texture2D(s_t0, tcbase)); \n "
2013-03-12 22:35:33 +00:00
" #ifdef UPPER \n "
" vec4 uc = texture2D(s_t6, tcbase); \n "
" bases.rgb += uc.rgb*e_uppercolour*uc.a; \n "
" #endif \n "
" #ifdef LOWER \n "
" vec4 lc = texture2D(s_t5, tcbase); \n "
" bases.rgb += lc.rgb*e_lowercolour*lc.a; \n "
" #endif \n "
2012-05-09 15:30:53 +00:00
" #if defined(BUMP) || defined(SPECULAR) \n "
2012-07-05 19:42:36 +00:00
" vec3 bumps = normalize(vec3(texture2D(s_t1, tcbase)) - 0.5); \n "
2012-05-09 15:30:53 +00:00
" #endif \n "
" #ifdef SPECULAR \n "
" vec4 specs = texture2D(s_t2, tcbase); \n "
" #endif \n "
2012-07-05 19:42:36 +00:00
2012-05-09 15:30:53 +00:00
" vec3 nl = normalize(lightvector); \n "
2012-07-05 19:42:36 +00:00
" float colorscale = max(1.0 - (dot(lightvector, lightvector)/(l_lightradius*l_lightradius)), 0.0); \n "
2012-05-09 15:30:53 +00:00
" vec3 diff; \n "
" #ifdef BUMP \n "
2012-07-05 19:42:36 +00:00
" diff = bases * (l_lightcolourscale.x + l_lightcolourscale.y * max(dot(bumps, nl), 0.0)); \n "
2012-05-09 15:30:53 +00:00
" #else \n "
2012-08-04 01:35:52 +00:00
//we still do bumpmapping even without bumps to ensure colours are always sane. light.exe does it too.
2012-05-09 15:30:53 +00:00
" diff = bases * (l_lightcolourscale.x + l_lightcolourscale.y * max(dot(vec3(0.0, 0.0, 1.0), nl), 0.0)); \n "
" #endif \n "
2012-07-05 19:42:36 +00:00
2012-05-09 15:30:53 +00:00
" #ifdef SPECULAR \n "
2012-07-05 19:42:36 +00:00
" vec3 halfdir = normalize(normalize(eyevector) + nl); \n "
" float spec = pow(max(dot(halfdir, bumps), 0.0), 32.0 * specs.a); \n "
" diff += l_lightcolourscale.z * spec * specs.rgb; \n "
2012-05-09 15:30:53 +00:00
" #endif \n "
2012-07-05 19:42:36 +00:00
2012-08-04 01:35:52 +00:00
" #ifdef CUBEPROJ \n "
/*filter the colour by the cubemap projection*/
" diff *= textureCube(s_t3, vtexprojcoord.xyz).rgb; \n "
2012-05-09 15:30:53 +00:00
" #endif \n "
2012-08-04 01:35:52 +00:00
2012-05-09 15:30:53 +00:00
" #if defined(SPOT) \n "
2012-08-04 01:35:52 +00:00
/*filter the colour by the spotlight. discard anything behind the light so we don't get a mirror image*/
" if (vtexprojcoord.w < 0.0) discard; \n "
" vec2 spot = ((vtexprojcoord.st)/vtexprojcoord.w);colorscale*=1.0-(dot(spot,spot)); \n "
2012-05-09 15:30:53 +00:00
" #endif \n "
2012-08-04 01:35:52 +00:00
" #ifdef PCF \n "
/*filter the light by the shadowmap. logically a boolean, but we allow fractions for softer shadows*/
//diff.rgb = (vtexprojcoord.xyz/vtexprojcoord.w) * 0.5 + 0.5;
" colorscale *= ShadowmapFilter(); \n "
// gl_FragColor.rgb = vec3(ShadowmapFilter());
2012-05-09 15:30:53 +00:00
" #endif \n "
2012-08-04 01:35:52 +00:00
2012-05-09 15:30:53 +00:00
" #if defined(PROJECTION) \n "
2012-08-04 01:35:52 +00:00
/*2d projection, not used*/
// diff *= texture2d(s_t3, shadowcoord);
2012-05-09 15:30:53 +00:00
" #endif \n "
2012-08-04 01:35:52 +00:00
2012-05-09 15:30:53 +00:00
" gl_FragColor.rgb = fog3additive(diff*colorscale*l_lightcolour); \n "
" } \n "
" #endif \n "
} ,
# endif
2012-11-27 03:23:19 +00:00
# ifdef D3D9QUAKE
{ QR_DIRECT3D9 , 9 , " rtlight " ,
" !!permu BUMP \n "
" !!permu SPECULAR \n "
" !!permu OFFSETMAPPING \n "
" !!permu SKELETAL \n "
" !!permu FOG \n "
// texture units:
// s0=diffuse, s1=normal, s2=specular, s3=shadowmap
// custom modifiers:
// PCF(shadowmap)
// CUBE(projected cubemap)
" struct a2v \n "
" { \n "
" float4 pos: POSITION; \n "
" float3 tc: TEXCOORD0; \n "
" float3 n: NORMAL0; \n "
" float3 s: TANGENT0; \n "
" float3 t: BINORMAL0; \n "
" }; \n "
" struct v2f \n "
" { \n "
" #ifndef FRAGMENT_SHADER \n "
" float4 pos: POSITION; \n "
" #endif \n "
" float3 tc: TEXCOORD0; \n "
" float3 lpos: TEXCOORD1; \n "
" }; \n "
" #ifdef VERTEX_SHADER \n "
" float4x4 m_modelviewprojection; \n "
" float3 l_lightposition; \n "
" v2f main (a2v inp) \n "
" { \n "
" v2f outp; \n "
" outp.pos = mul(m_modelviewprojection, inp.pos); \n "
" outp.tc = inp.tc; \n "
" float3 lightminusvertex = l_lightposition - inp.pos.xyz; \n "
" outp.lpos.x = dot(lightminusvertex, inp.s.xyz); \n "
" outp.lpos.y = dot(lightminusvertex, inp.t.xyz); \n "
" outp.lpos.z = dot(lightminusvertex, inp.n.xyz); \n "
" return outp; \n "
" } \n "
" #endif \n "
" #ifdef FRAGMENT_SHADER \n "
" sampler s_t0; \n "
" sampler s_t1; \n "
" float l_lightradius; \n "
" float3 l_lightcolour; \n "
" float4 main (v2f inp) : COLOR0 \n "
" { \n "
" float3 col = l_lightcolour; \n "
" col *= max(1.0 - dot(inp.lpos, inp.lpos)/(l_lightradius*l_lightradius), 0.0); \n "
" float3 diff = tex2D(s_t0, inp.tc); \n "
" return float4(diff * col, 1); \n "
" } \n "
" #endif \n "
} ,
# endif
2012-05-09 15:30:53 +00:00
# ifdef GLQUAKE
{ QR_OPENGL , 110 , " underwaterwarp " ,
" !!cvarf r_waterwarp \n "
//this is a post processing shader that is drawn fullscreen whenever the view is underwater.
//its generally expected to warp the view a little.
" #ifdef VERTEX_SHADER \n "
" attribute vec2 v_texcoord; \n "
" varying vec2 v_stc; \n "
" varying vec2 v_warp; \n "
" varying vec2 v_edge; \n "
" uniform float e_time; \n "
" void main () \n "
" { \n "
" gl_Position = ftetransform(); \n "
" v_stc = (1.0+(gl_Position.xy / gl_Position.w))/2.0; \n "
" v_warp.s = e_time * 0.25 + v_texcoord.s; \n "
" v_warp.t = e_time * 0.25 + v_texcoord.t; \n "
" v_edge = v_texcoord.xy; \n "
" } \n "
" #endif \n "
" #ifdef FRAGMENT_SHADER \n "
" varying vec2 v_stc; \n "
" varying vec2 v_warp; \n "
" varying vec2 v_edge; \n "
" uniform sampler2D s_t0;/*$currentrender*/ \n "
" uniform sampler2D s_t1;/*warp image*/ \n "
" uniform sampler2D s_t2;/*edge image*/ \n "
2013-03-12 22:35:33 +00:00
" uniform vec4 e_rendertexturescale; \n "
2012-05-09 15:30:53 +00:00
" uniform float cvar_r_waterwarp; \n "
" void main () \n "
" { \n "
" float amptemp; \n "
" vec3 edge; \n "
" edge = texture2D( s_t2, v_edge ).rgb; \n "
" amptemp = (0.010 / 0.625) * cvar_r_waterwarp * edge.x; \n "
" vec3 offset; \n "
" offset = texture2D( s_t1, v_warp ).rgb; \n "
" offset.x = (offset.x - 0.5) * 2.0; \n "
" offset.y = (offset.y - 0.5) * 2.0; \n "
" vec2 temp; \n "
" temp.x = v_stc.x + offset.x * amptemp; \n "
" temp.y = v_stc.y + offset.y * amptemp; \n "
" gl_FragColor = texture2D( s_t0, temp*e_rendertexturescale.st ); \n "
" } \n "
" #endif \n "
} ,
# endif
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
# ifdef GLQUAKE
2013-03-12 22:37:59 +00:00
{ QR_OPENGL , 110 , " menutint " ,
" !!cvari r_menutint_inverse \n "
" !!cvarv r_menutint \n "
" #ifdef VERTEX_SHADER \n "
" attribute vec2 v_texcoord; \n "
" varying vec2 texcoord; \n "
" uniform vec4 e_rendertexturescale; \n "
" void main(void) \n "
" { \n "
" texcoord.x = v_texcoord.x*e_rendertexturescale.x; \n "
" texcoord.y = (1.0-v_texcoord.y)*e_rendertexturescale.y; \n "
" gl_Position = ftetransform(); \n "
" } \n "
" #endif \n "
" #ifdef FRAGMENT_SHADER \n "
" varying vec2 texcoord; \n "
" uniform vec3 cvar_r_menutint; \n "
" uniform sampler2D s_t0; \n "
" uniform int cvar_r_menutint_inverse; \n "
" const vec3 lumfactors = vec3(0.299, 0.587, 0.114); \n "
" const vec3 invertvec = vec3(1.0, 1.0, 1.0); \n "
" void main(void) \n "
" { \n "
" vec3 texcolor = texture2D(s_t0, texcoord).rgb; \n "
" float luminance = dot(lumfactors, texcolor); \n "
" texcolor = vec3(luminance, luminance, luminance); \n "
" texcolor *= cvar_r_menutint; \n "
" texcolor = (cvar_r_menutint_inverse > 0) ? (invertvec - texcolor) : texcolor; \n "
" gl_FragColor = vec4(texcolor, 1.0); \n "
" } \n "
" #endif \n "
} ,
# endif
# ifdef GLQUAKE
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
{ QR_OPENGL , 110 , " terrain " ,
" !!permu FOG \n "
" #include \" sys/fog.h \" \n "
" varying vec2 tc; \n "
" varying vec2 lm; \n "
2012-08-04 01:35:52 +00:00
" varying vec4 vc; \n "
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
" #ifdef VERTEX_SHADER \n "
" attribute vec2 v_texcoord; \n "
" attribute vec2 v_lmcoord; \n "
2012-08-04 01:35:52 +00:00
" attribute vec4 v_colour; \n "
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
" void main (void) \n "
" { \n "
" tc = v_texcoord.st; \n "
" lm = v_lmcoord.st; \n "
2012-08-04 01:35:52 +00:00
" vc = v_colour; \n "
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
" gl_Position = ftetransform(); \n "
" } \n "
" #endif \n "
" #ifdef FRAGMENT_SHADER \n "
//four texture passes
" uniform sampler2D s_t0; \n "
" uniform sampler2D s_t1; \n "
" uniform sampler2D s_t2; \n "
" uniform sampler2D s_t3; \n "
//mix values
" uniform sampler2D s_t4; \n "
" void main (void) \n "
" { \n "
" vec4 m = texture2D(s_t4, lm); \n "
2012-08-04 01:35:52 +00:00
" gl_FragColor = fog4(vc*vec4(m.aaa,1.0)*( \n "
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
" texture2D(s_t0, tc)*m.r \n "
" + texture2D(s_t1, tc)*m.g \n "
" + texture2D(s_t2, tc)*m.b \n "
" + texture2D(s_t3, tc)*(1.0 - (m.r + m.g + m.b)) \n "
2012-07-20 01:46:05 +00:00
" )); \n "
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
" } \n "
" #endif \n "
} ,
# endif
2012-11-27 03:23:19 +00:00
# ifdef D3D11QUAKE
{ QR_DIRECT3D11 , 11 , " terrain " ,
" struct a2v \n "
" { \n "
" float4 pos: POSITION; \n "
" float4 tc: TEXCOORD0; \n "
" float4 vcol: COLOR0; \n "
" }; \n "
" struct v2f \n "
" { \n "
" float4 pos: SV_POSITION; \n "
" float2 tc: TEXCOORD0; \n "
" float2 lmtc: TEXCOORD1; \n "
" float4 vcol: COLOR0; \n "
" }; \n "
" #include <ftedefs.h> \n "
" #ifdef VERTEX_SHADER \n "
" v2f main (a2v inp) \n "
" { \n "
" v2f outp; \n "
" outp.pos = mul(m_model, inp.pos); \n "
" outp.pos = mul(m_view, outp.pos); \n "
" outp.pos = mul(m_projection, outp.pos); \n "
" outp.tc = inp.tc.xy; \n "
" outp.lmtc = inp.tc.zw; \n "
" outp.vcol = inp.vcol; \n "
" return outp; \n "
" } \n "
" #endif \n "
" #ifdef FRAGMENT_SHADER \n "
" Texture2D shaderTexture[5]; \n "
" SamplerState SampleType; \n "
" float4 main (v2f inp) : SV_TARGET \n "
" { \n "
" return float4(1,1,1,1); \n "
// float4 m = shaderTexture[4].Sample(SampleType, inp.tc) ;
// return inp.vcol*float4(m.aaa,1.0)*(
// shaderTexture[0].Sample(SampleType, inp.tc)*m.r
// + shaderTexture[1].Sample(SampleType, inp.tc)*m.g
// + shaderTexture[2].Sample(SampleType, inp.tc)*m.b
// + shaderTexture[3].Sample(SampleType, inp.tc)*1.0 - (m.r + m.g + m.b))
// ;
" } \n "
" #endif \n "
} ,
# endif