2013-05-12 04:51:02 +00:00
|
|
|
-- Math.const
|
|
|
|
|
|
|
|
const float PI = 3.14159265;
|
|
|
|
const float E = 2.71828183;
|
|
|
|
|
|
|
|
-- Math.quaternion
|
|
|
|
|
|
|
|
vec3
|
|
|
|
qmult (vec4 q, vec3 v)
|
|
|
|
{
|
2014-01-28 04:28:35 +00:00
|
|
|
float qs = q.w;
|
2013-05-12 04:51:02 +00:00
|
|
|
vec3 qv = q.xyz;
|
|
|
|
vec3 t = cross (qv, v);
|
|
|
|
return (qs * qs) * v + 2.0 * qs * t + dot (qv, v) * qv + cross (qv, t);
|
|
|
|
}
|
|
|
|
|
|
|
|
vec3
|
|
|
|
dqtrans (vec4 q0, vec4 qe)
|
|
|
|
{//2.0 * (q0.w * qe.xyz - qe.w * q0.xyz - cross (qe.xyz, q0.xyz));
|
|
|
|
float qs = q0.w, Ts = qe.w;
|
|
|
|
vec3 qv = -q0.xyz, Tv = qe.xyz;
|
|
|
|
|
|
|
|
return 2.0 * (Ts * qv + qs * Tv + cross (Tv, qv));
|
|
|
|
}
|
|
|
|
|
|
|
|
-- Fragment.fog
|
|
|
|
|
|
|
|
uniform vec4 fog;
|
|
|
|
|
|
|
|
vec4
|
|
|
|
fogBlend (vec4 color)
|
|
|
|
{
|
|
|
|
float fog_factor;
|
|
|
|
float az = fog.a * gl_FragCoord.z / gl_FragCoord.w;
|
|
|
|
vec4 fog_color = vec4 (fog.rgb, 1.0);
|
|
|
|
|
|
|
|
fog_factor = exp (-az * az);
|
|
|
|
return vec4 (mix (fog_color.rgb, color.rgb, fog_factor), color.a);
|
|
|
|
}
|
|
|
|
|
2014-01-28 04:00:28 +00:00
|
|
|
-- Fragment.palette
|
|
|
|
|
|
|
|
uniform sampler2D palette;
|
|
|
|
|
|
|
|
vec4
|
|
|
|
palettedColor (float pix)
|
|
|
|
{
|
|
|
|
return texture2D (palette, vec2 (pix, 0.0));
|
|
|
|
}
|
|
|
|
|
2013-05-12 04:51:02 +00:00
|
|
|
-- Fragment.colormap
|
|
|
|
|
|
|
|
uniform sampler2D colormap;
|
|
|
|
|
|
|
|
vec4
|
|
|
|
mappedColor (float pix, float light)
|
|
|
|
{
|
|
|
|
return texture2D (colormap, vec2 (pix, light));
|
|
|
|
}
|
|
|
|
|
2013-06-07 10:08:58 +00:00
|
|
|
-- env.warp.nop
|
|
|
|
|
|
|
|
vec2
|
|
|
|
warp_st (vec2 st, float time)
|
|
|
|
{
|
|
|
|
return st;
|
|
|
|
}
|
|
|
|
|
|
|
|
-- env.warp.turb
|
2013-05-12 04:51:02 +00:00
|
|
|
|
|
|
|
const float SPEED = 20.0;
|
|
|
|
const float CYCLE = 128.0;
|
|
|
|
const float FACTOR = PI * 2.0 / CYCLE;
|
2013-06-07 10:08:58 +00:00
|
|
|
const vec2 BIAS = vec2 (1.0, 1.0);
|
2013-05-12 04:51:02 +00:00
|
|
|
const float SCALE = 8.0;
|
|
|
|
|
|
|
|
vec2
|
2013-06-07 10:08:58 +00:00
|
|
|
warp_st (vec2 st, float time)
|
2013-05-12 04:51:02 +00:00
|
|
|
{
|
|
|
|
vec2 angle = st.ts * CYCLE / 2.0;
|
|
|
|
vec2 phase = vec2 (time, time) * SPEED;
|
|
|
|
return st + (sin ((angle + phase) * FACTOR) + BIAS) / SCALE;
|
|
|
|
}
|
|
|
|
|
2013-06-07 08:12:44 +00:00
|
|
|
-- env.sky.cube
|
|
|
|
|
|
|
|
uniform samplerCube sky;
|
|
|
|
|
|
|
|
vec4
|
|
|
|
sky_color (vec3 dir)
|
|
|
|
{
|
|
|
|
// NOTE: quake's world and GL's world are rotated relative to each other
|
|
|
|
// quake has x right, y in, z up. gl has x right, y up, z out
|
|
|
|
// The textures are loaded with GL's z (quake's y) already negated, so
|
|
|
|
// all that's needed here is to swizzle y and z.
|
|
|
|
return textureCube(sky, dir.xzy);
|
|
|
|
}
|
|
|
|
|
|
|
|
-- env.sky.id
|
2013-05-12 04:51:02 +00:00
|
|
|
|
|
|
|
uniform sampler2D solid;
|
|
|
|
uniform sampler2D trans;
|
2013-06-07 08:12:44 +00:00
|
|
|
uniform float time;
|
2013-05-12 04:51:02 +00:00
|
|
|
|
|
|
|
const float SCALE = 189.0 / 64.0;
|
|
|
|
|
|
|
|
vec4
|
2013-06-07 08:12:44 +00:00
|
|
|
sky_color (vec3 dir)
|
2013-05-12 04:51:02 +00:00
|
|
|
{
|
|
|
|
float len;
|
|
|
|
float pix;
|
|
|
|
vec2 flow = vec2 (1.0, 1.0);
|
|
|
|
vec2 st, base;
|
|
|
|
|
|
|
|
dir.z *= 3.0;
|
|
|
|
len = dot (dir, dir);
|
|
|
|
len = SCALE * inversesqrt (len);
|
|
|
|
|
|
|
|
base = dir.yx * vec2(1.0, -1.0) * len;
|
|
|
|
st = base + flow * time / 8.0;
|
|
|
|
pix = texture2D (trans, st).r;
|
|
|
|
if (pix == 0.0) {
|
2013-06-07 08:12:44 +00:00
|
|
|
st = base + flow * time / 16.0;
|
2013-05-12 04:51:02 +00:00
|
|
|
pix = texture2D (solid, st).r;
|
|
|
|
}
|
2014-01-28 04:00:28 +00:00
|
|
|
return palettedColor (pix);
|
2013-05-12 04:51:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-- Vertex.mdl
|
2013-06-07 08:12:44 +00:00
|
|
|
|
2013-05-12 04:51:02 +00:00
|
|
|
uniform mat4 mvp_mat;
|
|
|
|
uniform mat3 norm_mat;
|
|
|
|
uniform vec2 skin_size;
|
|
|
|
uniform float blend;
|
|
|
|
|
|
|
|
attribute vec3 vertexa, vertexb;
|
2014-01-28 02:38:13 +00:00
|
|
|
attribute vec3 vnormala, vnormalb;
|
|
|
|
attribute vec2 vsta, vstb;
|
|
|
|
attribute vec4 vcolora, vcolorb;
|
2013-05-12 04:51:02 +00:00
|
|
|
|
|
|
|
varying vec3 normal;
|
|
|
|
varying vec2 st;
|
|
|
|
varying vec4 color;
|
|
|
|
|
|
|
|
void
|
|
|
|
main (void)
|
|
|
|
{
|
|
|
|
vec3 vertex;
|
|
|
|
vec3 vnormal;
|
|
|
|
|
|
|
|
vertex = mix (vertexa, vertexb, blend);
|
|
|
|
vnormal = mix (vnormala, vnormalb, blend);
|
|
|
|
gl_Position = mvp_mat * vec4 (vertex, 1.0);
|
|
|
|
st = mix (vsta, vstb, blend) / skin_size;
|
|
|
|
normal = norm_mat * vnormal;
|
|
|
|
color = mix (vcolora, vcolorb, blend);
|
|
|
|
}
|
2013-06-07 08:12:44 +00:00
|
|
|
|
2013-05-12 04:51:02 +00:00
|
|
|
-- Fragment.mdl
|
2013-06-07 08:12:44 +00:00
|
|
|
|
2013-05-12 04:51:02 +00:00
|
|
|
uniform sampler2D skin;
|
|
|
|
uniform float ambient;
|
|
|
|
uniform float shadelight;
|
|
|
|
uniform vec3 lightvec;
|
|
|
|
|
|
|
|
varying vec3 normal;
|
|
|
|
varying vec2 st;
|
|
|
|
varying vec4 color;
|
|
|
|
|
|
|
|
void
|
|
|
|
main (void)
|
|
|
|
{
|
|
|
|
float pix = texture2D (skin, st).r;
|
|
|
|
float light = ambient;
|
|
|
|
float d, col;
|
|
|
|
vec4 lit;
|
|
|
|
|
|
|
|
d = dot (normal, lightvec);
|
|
|
|
d = min (d, 0.0);
|
|
|
|
light = 255.0 - light;
|
|
|
|
light += d * shadelight;
|
|
|
|
lit = mappedColor (pix, light / 255.0);
|
|
|
|
gl_FragColor = fogBlend (lit * color);
|
|
|
|
}
|
2013-06-07 08:12:44 +00:00
|
|
|
|
|
|
|
-- Vertex.bsp
|
|
|
|
|
|
|
|
uniform mat4 mvp_mat;
|
|
|
|
uniform mat4 sky_mat;
|
|
|
|
|
|
|
|
attribute vec4 vertex;
|
2014-01-28 02:38:13 +00:00
|
|
|
attribute vec4 tlst;
|
|
|
|
attribute vec4 vcolor;
|
2013-06-07 08:12:44 +00:00
|
|
|
|
|
|
|
varying vec2 tst;
|
|
|
|
varying vec2 lst;
|
|
|
|
varying vec4 color;
|
|
|
|
varying vec3 direction;
|
|
|
|
|
|
|
|
void
|
|
|
|
main (void)
|
|
|
|
{
|
|
|
|
gl_Position = mvp_mat * vertex;
|
|
|
|
direction = (sky_mat * vertex).xyz;
|
|
|
|
tst = tlst.st;
|
|
|
|
lst = tlst.pq;
|
|
|
|
color = vcolor;
|
|
|
|
}
|
|
|
|
|
|
|
|
-- Fragment.bsp.lit
|
|
|
|
|
|
|
|
uniform sampler2D texture;
|
|
|
|
uniform sampler2D lightmap;
|
2013-06-07 10:08:58 +00:00
|
|
|
uniform float time;
|
2013-06-07 08:12:44 +00:00
|
|
|
|
|
|
|
varying vec2 tst;
|
|
|
|
varying vec2 lst;
|
|
|
|
varying vec4 color;
|
|
|
|
|
|
|
|
void
|
|
|
|
main (void)
|
|
|
|
{
|
2013-06-07 10:08:58 +00:00
|
|
|
float pix;
|
|
|
|
vec2 st;
|
2013-06-07 08:12:44 +00:00
|
|
|
float light = texture2D (lightmap, lst).r;
|
|
|
|
vec4 c;
|
|
|
|
|
2013-06-07 10:08:58 +00:00
|
|
|
st = warp_st (tst, time);
|
|
|
|
pix = texture2D (texture, st).r;
|
2013-06-07 08:12:44 +00:00
|
|
|
c = mappedColor (pix, light * 4.0) * color;
|
|
|
|
gl_FragColor = fogBlend (c);
|
|
|
|
}
|
|
|
|
|
2013-06-07 10:08:58 +00:00
|
|
|
-- Fragment.bsp.unlit
|
|
|
|
|
|
|
|
uniform sampler2D texture;
|
|
|
|
uniform float time;
|
|
|
|
|
|
|
|
varying vec2 tst;
|
|
|
|
varying vec4 color;
|
|
|
|
|
|
|
|
void
|
|
|
|
main (void)
|
|
|
|
{
|
|
|
|
float pix;
|
|
|
|
vec2 st;
|
|
|
|
vec4 c;
|
|
|
|
|
|
|
|
st = warp_st (tst, time);
|
|
|
|
pix = texture2D (texture, st).r;
|
2014-01-28 04:00:28 +00:00
|
|
|
c = palettedColor (pix) * color;
|
2013-06-07 10:08:58 +00:00
|
|
|
gl_FragColor = fogBlend (c);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-06-07 08:12:44 +00:00
|
|
|
-- Fragment.bsp.sky
|
|
|
|
|
|
|
|
varying vec3 direction;
|
|
|
|
|
|
|
|
void
|
|
|
|
main (void)
|
|
|
|
{
|
|
|
|
vec4 c = sky_color (direction);
|
|
|
|
gl_FragColor = fogBlend (c);
|
|
|
|
}
|
2014-01-28 03:08:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
-- Vertex.particle.point
|
|
|
|
|
|
|
|
uniform mat4 mvp_mat;
|
|
|
|
/** Vertex position.
|
|
|
|
|
|
|
|
x, y, z, c
|
|
|
|
|
|
|
|
c is the color of the point.
|
|
|
|
*/
|
|
|
|
attribute vec3 vertex;
|
2014-01-28 04:49:06 +00:00
|
|
|
attribute float vcolor;
|
2014-01-28 03:08:53 +00:00
|
|
|
|
|
|
|
varying float color;
|
|
|
|
|
|
|
|
void
|
|
|
|
main (void)
|
|
|
|
{
|
|
|
|
gl_Position = mvp_mat * vec4 (vertex, 1.0);
|
|
|
|
gl_PointSize = max (1.0, 1024.0 * abs (1.0 / gl_Position.z));
|
|
|
|
color = vcolor;
|
|
|
|
}
|
|
|
|
|
2014-01-28 03:16:52 +00:00
|
|
|
-- Vertex.particle.textured
|
|
|
|
|
|
|
|
uniform mat4 mvp_mat;
|
|
|
|
/** Vertex position.
|
|
|
|
|
|
|
|
x, y, z, c
|
|
|
|
|
|
|
|
c is the color of the point.
|
|
|
|
*/
|
|
|
|
attribute vec3 vertex;
|
2014-01-28 04:49:06 +00:00
|
|
|
attribute vec2 vst;
|
|
|
|
attribute vec4 vcolor;
|
2014-01-28 03:16:52 +00:00
|
|
|
|
|
|
|
varying vec4 color;
|
|
|
|
varying vec2 st;
|
|
|
|
|
|
|
|
void
|
|
|
|
main (void)
|
|
|
|
{
|
|
|
|
gl_Position = mvp_mat * vec4 (vertex, 1.0);
|
|
|
|
color = vcolor;
|
|
|
|
st = vst;
|
|
|
|
}
|
|
|
|
|
2014-01-28 03:08:53 +00:00
|
|
|
-- Fragment.particle.point
|
|
|
|
|
|
|
|
//precision mediump float;
|
|
|
|
|
|
|
|
varying float color;
|
|
|
|
|
|
|
|
void
|
|
|
|
main (void)
|
|
|
|
{
|
|
|
|
if (color == 1.0)
|
|
|
|
discard;
|
2014-01-28 04:00:28 +00:00
|
|
|
gl_FragColor = fogBlend (palettedColor (color));
|
2014-01-28 03:08:53 +00:00
|
|
|
}
|
2014-01-28 03:16:52 +00:00
|
|
|
|
|
|
|
-- Fragment.particle.textured
|
|
|
|
|
|
|
|
//precision mediump float;
|
|
|
|
uniform sampler2D texture;
|
|
|
|
|
|
|
|
varying vec4 color;
|
|
|
|
varying vec2 st;
|
|
|
|
|
|
|
|
void
|
|
|
|
main (void)
|
|
|
|
{
|
|
|
|
gl_FragColor = fogBlend (texture2D (texture, st) * color);
|
|
|
|
}
|
2014-01-28 03:31:27 +00:00
|
|
|
|
|
|
|
-- Vertex.sprite
|
|
|
|
|
|
|
|
uniform mat4 mvp_mat;
|
|
|
|
attribute vec3 vertexa, vertexb;
|
2014-01-28 04:49:06 +00:00
|
|
|
attribute vec4 uvab; ///< ua va ub vb
|
|
|
|
attribute float vblend; //FIXME why is this not a uniform?
|
|
|
|
attribute vec4 vcolora, vcolorb;
|
2014-01-28 03:31:27 +00:00
|
|
|
|
|
|
|
varying float blend;
|
|
|
|
varying vec4 colora, colorb;
|
|
|
|
varying vec2 sta, stb;
|
|
|
|
|
|
|
|
void
|
|
|
|
main (void)
|
|
|
|
{
|
|
|
|
gl_Position = mvp_mat * vec4 (mix (vertexa, vertexb, vblend), 1.0);
|
|
|
|
blend = vblend;
|
|
|
|
colora = vcolora;
|
|
|
|
colorb = vcolorb;
|
|
|
|
sta = uvab.xy;
|
|
|
|
stb = uvab.zw;
|
|
|
|
}
|
|
|
|
|
|
|
|
-- Fragment.sprite
|
|
|
|
|
|
|
|
uniform sampler2D spritea;
|
|
|
|
uniform sampler2D spriteb;
|
|
|
|
|
|
|
|
varying float blend;
|
|
|
|
varying vec4 colora, colorb;
|
|
|
|
varying vec2 sta, stb;
|
|
|
|
|
|
|
|
void
|
|
|
|
main (void)
|
|
|
|
{
|
|
|
|
float pixa, pixb;
|
|
|
|
vec4 cola, colb;
|
|
|
|
vec4 col;
|
|
|
|
|
|
|
|
pixa = texture2D (spritea, sta).r;
|
|
|
|
pixb = texture2D (spriteb, stb).r;
|
|
|
|
if (pixa == 1.0 && pixb == 1.0)
|
|
|
|
discard;
|
2014-01-28 04:00:28 +00:00
|
|
|
cola = palettedColor (pixa) * colora;
|
|
|
|
colb = palettedColor (pixb) * colorb;
|
2014-01-28 03:31:27 +00:00
|
|
|
col = mix (cola, colb, blend);
|
|
|
|
if (col.a == 0.0)
|
|
|
|
discard;
|
|
|
|
gl_FragColor = fogBlend (col);
|
|
|
|
}
|
2014-01-28 04:10:56 +00:00
|
|
|
|
|
|
|
-- Vertex.2d
|
|
|
|
|
|
|
|
uniform mat4 mvp_mat;
|
|
|
|
/** Vertex position.
|
|
|
|
|
|
|
|
x, y, s, t
|
|
|
|
|
|
|
|
\a vertex provides the onscreen location at which to draw the icon
|
|
|
|
(\a x, \a y) and texture coordinate for the icon (\a s=z, \a t=w).
|
|
|
|
*/
|
|
|
|
attribute vec4 vertex;
|
2014-01-28 04:49:06 +00:00
|
|
|
attribute vec4 vcolor;
|
2014-01-28 04:10:56 +00:00
|
|
|
|
|
|
|
varying vec4 color;
|
|
|
|
varying vec2 st;
|
|
|
|
|
|
|
|
void
|
|
|
|
main (void)
|
|
|
|
{
|
|
|
|
gl_Position = mvp_mat * vec4 (vertex.xy, 0.0, 1.0);
|
|
|
|
st = vertex.zw;
|
|
|
|
color = vcolor;
|
|
|
|
}
|
|
|
|
|
|
|
|
-- Fragment.2d
|
|
|
|
|
|
|
|
//precision mediump float;
|
|
|
|
uniform sampler2D texture;
|
|
|
|
varying vec4 color;
|
|
|
|
varying vec2 st;
|
|
|
|
|
|
|
|
void
|
|
|
|
main (void)
|
|
|
|
{
|
|
|
|
float pix;
|
|
|
|
|
|
|
|
pix = texture2D (texture, st).r;
|
|
|
|
if (pix == 1.0)
|
|
|
|
discard;
|
|
|
|
gl_FragColor = palettedColor (pix) * color;
|
|
|
|
}
|
2014-01-28 04:28:35 +00:00
|
|
|
|
2022-12-05 16:18:01 +00:00
|
|
|
-- Fragment.2d.alpha
|
|
|
|
|
|
|
|
uniform sampler2D texture;
|
|
|
|
varying vec4 color;
|
|
|
|
varying vec2 st;
|
|
|
|
|
|
|
|
void
|
|
|
|
main (void)
|
|
|
|
{
|
|
|
|
float alpha;
|
|
|
|
|
|
|
|
alpha = texture2D (texture, st).r;
|
|
|
|
if (alpha == 0.0)
|
|
|
|
discard;
|
|
|
|
gl_FragColor = alpha * color;
|
|
|
|
}
|
|
|
|
|
2014-01-28 04:28:35 +00:00
|
|
|
-- Vertex.iqm
|
|
|
|
|
|
|
|
uniform mat4 mvp_mat;
|
|
|
|
uniform mat3 norm_mat;
|
|
|
|
uniform mat4 bonemats[80];
|
|
|
|
attribute vec4 vcolor;
|
|
|
|
attribute vec4 vweights;
|
|
|
|
attribute vec4 vbones;
|
|
|
|
attribute vec4 vtangent;
|
|
|
|
attribute vec3 vnormal;
|
|
|
|
attribute vec2 texcoord;
|
|
|
|
attribute vec3 vposition;
|
|
|
|
|
|
|
|
varying vec3 position;
|
|
|
|
varying vec3 bitangent;
|
|
|
|
varying vec3 tangent;
|
|
|
|
varying vec3 normal;
|
|
|
|
varying vec2 st;
|
|
|
|
varying vec4 color;
|
|
|
|
|
|
|
|
void
|
|
|
|
main (void)
|
|
|
|
{
|
|
|
|
mat4 m;
|
|
|
|
vec4 q0, qe;
|
|
|
|
vec3 sh, sc, tr, v, n, t;
|
|
|
|
|
|
|
|
m = bonemats[int (vbones.x)] * vweights.x;
|
|
|
|
m += bonemats[int (vbones.y)] * vweights.y;
|
|
|
|
m += bonemats[int (vbones.z)] * vweights.z;
|
|
|
|
m += bonemats[int (vbones.w)] * vweights.w;
|
|
|
|
#if 0
|
2018-10-12 05:33:55 +00:00
|
|
|
q0 = m[0];
|
|
|
|
qe = m[1];
|
2014-01-28 04:28:35 +00:00
|
|
|
sh = m[2].xyz;
|
|
|
|
sc = m[3].xyz;
|
|
|
|
|
|
|
|
// extract translation from dual quaternion
|
|
|
|
tr = dqtrans (q0, qe);
|
|
|
|
// apply rotation and translation
|
|
|
|
v = qmult (q0, vposition) + tr;
|
|
|
|
// apply shear
|
|
|
|
v.z += v.y * sh.z + v.x * sh.y;
|
|
|
|
v.y += v.x * sh.x;
|
|
|
|
// apply scale
|
|
|
|
v *= sc;
|
|
|
|
// rotate normal (won't bother with shear or scale: not super accurate,
|
|
|
|
// but probably good enough)
|
|
|
|
n = qmult (q0, vnormal);
|
|
|
|
// rotate tangent (won't bother with shear or scale: not super accurate,
|
|
|
|
// but probably good enough)
|
|
|
|
t = qmult (q0, vtangent.xyz);
|
|
|
|
#else
|
|
|
|
mat3 nm = mat3 (m[0].xyz, m[1].xyz, m[2].xyz);
|
|
|
|
v = (m * vec4 (vposition, 1.0)).xyz;
|
|
|
|
n = nm * vnormal;
|
|
|
|
t = nm * vtangent.xyz;
|
|
|
|
#endif
|
|
|
|
position = v;
|
|
|
|
normal = norm_mat * n;
|
|
|
|
tangent = norm_mat * t;
|
|
|
|
bitangent = cross (normal, tangent) * vtangent.w;
|
|
|
|
color = vcolor;
|
|
|
|
st = texcoord;
|
|
|
|
gl_Position = mvp_mat * vec4 (position, 1.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
-- Fragment.iqm
|
|
|
|
|
|
|
|
struct light {
|
|
|
|
vec4 position; // xyz = pos, w = strength
|
|
|
|
vec4 color; // rgb. a = ?
|
|
|
|
};
|
|
|
|
uniform sampler2D texture;
|
|
|
|
uniform sampler2D normalmap;
|
|
|
|
uniform vec3 ambient;
|
|
|
|
uniform light lights[8];
|
|
|
|
|
|
|
|
varying vec3 position;
|
|
|
|
varying vec3 bitangent;
|
|
|
|
varying vec3 tangent;
|
|
|
|
varying vec3 normal;
|
|
|
|
varying vec2 st;
|
|
|
|
varying vec4 color;
|
|
|
|
|
|
|
|
vec3
|
|
|
|
calc_light (vec3 n, int ind)
|
|
|
|
{
|
|
|
|
vec3 d;
|
|
|
|
light l = lights[ind];
|
|
|
|
float mag;
|
|
|
|
|
|
|
|
d = l.position.xyz - position;
|
|
|
|
mag = dot (d, n);
|
|
|
|
mag = max (0.0, mag);
|
|
|
|
return l.color.rgb * (l.position.w * mag / dot (d, d));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
main (void)
|
|
|
|
{
|
|
|
|
mat3 tbn = mat3 (tangent, bitangent, normal);
|
|
|
|
vec3 norm, l;
|
|
|
|
vec4 col;
|
|
|
|
|
|
|
|
norm = (texture2D (normalmap, st).xyz - vec3(0.5)) * 2.0;
|
|
|
|
norm = tbn * norm;
|
|
|
|
l = ambient;
|
|
|
|
l += calc_light (norm, 0);
|
|
|
|
l += calc_light (norm, 1);
|
|
|
|
l += calc_light (norm, 2);
|
|
|
|
l += calc_light (norm, 3);
|
|
|
|
l += calc_light (norm, 4);
|
|
|
|
l += calc_light (norm, 5);
|
|
|
|
l += calc_light (norm, 6);
|
|
|
|
l += calc_light (norm, 7);
|
|
|
|
col = texture2D (texture, st) * color * vec4 (l, 1.0);
|
|
|
|
gl_FragColor = fogBlend (col);
|
|
|
|
}
|
2022-03-24 16:24:38 +00:00
|
|
|
|
2022-11-03 07:42:49 +00:00
|
|
|
-- version.130
|
2022-03-24 16:24:38 +00:00
|
|
|
#version 130
|
2022-11-03 07:42:49 +00:00
|
|
|
-- Vertex.fstri
|
2022-03-24 16:24:38 +00:00
|
|
|
|
|
|
|
out vec2 uv;
|
|
|
|
|
|
|
|
void
|
|
|
|
main ()
|
|
|
|
{
|
|
|
|
// quake uses clockwise triangle order
|
|
|
|
float x = (gl_VertexID & 2);
|
|
|
|
float y = (gl_VertexID & 1);
|
|
|
|
uv = vec2(x, y*2);
|
|
|
|
gl_Position = vec4 (2, 4, 0, 0) * vec4 (x, y, 0, 0) - vec4 (1, 1, 0, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
-- Fragment.screen.warp
|
|
|
|
|
|
|
|
uniform sampler2D screenTex;
|
|
|
|
uniform float time;
|
|
|
|
|
|
|
|
in vec2 uv;
|
|
|
|
|
|
|
|
const float S = 0.15625;
|
|
|
|
const float F = 2.5;
|
|
|
|
const float A = 0.01;
|
|
|
|
const vec2 B = vec2 (1, 1);
|
|
|
|
|
|
|
|
void
|
|
|
|
main ()
|
|
|
|
{
|
2022-11-03 07:42:49 +00:00
|
|
|
vec2 st;
|
|
|
|
st = uv * (1.0 - 2.0*A) + A * (B + sin ((time * S + F * uv.yx) * 2.0*PI));
|
|
|
|
vec4 c = texture2D (screenTex, st);
|
2022-03-24 16:24:38 +00:00
|
|
|
gl_FragColor = c;//vec4(uv, c.x, 1);
|
|
|
|
}
|
2022-03-25 03:22:16 +00:00
|
|
|
|
|
|
|
-- Fragment.screen.fisheye
|
|
|
|
|
|
|
|
uniform samplerCube screenTex;
|
|
|
|
uniform float fov;
|
|
|
|
uniform float aspect;
|
|
|
|
|
|
|
|
in vec2 uv;
|
|
|
|
|
|
|
|
void
|
|
|
|
main ()
|
|
|
|
{
|
2022-10-26 03:32:09 +00:00
|
|
|
// slight offset on y is to avoid the singularity straight ahead
|
2022-03-25 03:22:16 +00:00
|
|
|
vec2 xy = (2.0 * uv - vec2 (1, 1.00002)) * (vec2(1, -aspect));
|
|
|
|
float r = sqrt (dot (xy, xy));
|
|
|
|
vec2 cs = vec2 (cos (r * fov), sin (r * fov));
|
|
|
|
vec3 dir = vec3 (cs.y * xy / r, cs.x);
|
|
|
|
|
|
|
|
vec4 c = textureCube(screenTex, dir);
|
|
|
|
gl_FragColor = c;// * 0.001 + vec4(dir, 1);
|
|
|
|
}
|