mirror of
https://github.com/edubart/otclient.git
synced 2025-10-14 19:44:54 +02:00
experimental map shaders
This commit is contained in:
16
modules/game_shaders/shaders/bloom.frag
Normal file
16
modules/game_shaders/shaders/bloom.frag
Normal file
@@ -0,0 +1,16 @@
|
||||
uniform float u_Time;
|
||||
uniform sampler2D u_Tex0;
|
||||
varying vec2 v_TexCoord;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 color = texture2D(u_Tex0, v_TexCoord);
|
||||
int j;
|
||||
int i;
|
||||
|
||||
for(i = -2 ;i <= 2; i++)
|
||||
for(j = -2; j <= 2; j++)
|
||||
color += texture2D(u_Tex0, v_TexCoord + vec2(i, j)*0.0025) * 0.025;
|
||||
|
||||
gl_FragColor = color;
|
||||
}
|
8
modules/game_shaders/shaders/default.frag
Normal file
8
modules/game_shaders/shaders/default.frag
Normal file
@@ -0,0 +1,8 @@
|
||||
uniform float u_Time;
|
||||
uniform sampler2D u_Tex0;
|
||||
varying vec2 v_TexCoord;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = texture2D(u_Tex0, v_TexCoord);
|
||||
}
|
18
modules/game_shaders/shaders/fog.frag
Normal file
18
modules/game_shaders/shaders/fog.frag
Normal file
@@ -0,0 +1,18 @@
|
||||
uniform float u_Time;
|
||||
uniform sampler2D u_Tex0;
|
||||
uniform sampler2D u_Tex1;
|
||||
varying vec2 v_TexCoord;
|
||||
|
||||
vec2 direction = vec2(1.0,0.3);
|
||||
float speed = 0.05;
|
||||
float pressure = 0.6;
|
||||
float zoom = 0.5;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec2 offset = (v_TexCoord + (direction * u_Time * speed)) / zoom;
|
||||
vec3 bgcol = texture2D(u_Tex0, v_TexCoord).xyz;
|
||||
vec3 fogcol = texture2D(u_Tex1, offset).xyz;
|
||||
vec3 col = bgcol + fogcol*pressure;
|
||||
gl_FragColor = vec4(col,1.0);
|
||||
}
|
14
modules/game_shaders/shaders/grayscale.frag
Normal file
14
modules/game_shaders/shaders/grayscale.frag
Normal file
@@ -0,0 +1,14 @@
|
||||
uniform float u_Time;
|
||||
uniform sampler2D u_Tex0;
|
||||
varying vec2 v_TexCoord;
|
||||
|
||||
vec4 grayscale(vec4 color)
|
||||
{
|
||||
float gray = dot(color.rgb, vec3(0.299, 0.587, 0.114));
|
||||
return vec4(gray, gray, gray, 1);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = grayscale(texture2D(u_Tex0, v_TexCoord));
|
||||
}
|
24
modules/game_shaders/shaders/oldtv.frag
Normal file
24
modules/game_shaders/shaders/oldtv.frag
Normal file
@@ -0,0 +1,24 @@
|
||||
uniform float u_Time;
|
||||
varying vec2 v_TexCoord;
|
||||
uniform sampler2D u_Tex0;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec2 q = v_TexCoord;
|
||||
vec2 uv = 0.5 + (q-0.5)*(0.9 + 0.1*sin(0.2*u_Time));
|
||||
|
||||
vec3 oricol = texture2D(u_Tex0,vec2(q.x,q.y)).xyz;
|
||||
vec3 col = oricol;
|
||||
|
||||
col = clamp(col*0.5+0.5*col*col*1.2,0.0,1.0);
|
||||
|
||||
col *= 0.5 + 0.5*16.0*uv.x*uv.y*(1.0-uv.x)*(1.0-uv.y);
|
||||
|
||||
col *= vec3(0.8,1.0,0.7);
|
||||
|
||||
col *= 0.9+0.1*sin(10.0*u_Time+uv.y*1000.0);
|
||||
|
||||
col *= 0.97+0.03*sin(110.0*u_Time);
|
||||
|
||||
gl_FragColor = vec4(col,1.0);
|
||||
}
|
13
modules/game_shaders/shaders/party.frag
Normal file
13
modules/game_shaders/shaders/party.frag
Normal file
@@ -0,0 +1,13 @@
|
||||
uniform float u_Time;
|
||||
uniform sampler2D u_Tex0;
|
||||
varying vec2 v_TexCoord;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 col = texture2D(u_Tex0, v_TexCoord);
|
||||
float d = u_Time * 2;
|
||||
col.x += (1.0 + sin(d))*0.25;
|
||||
col.y += (1.0 + sin(d*2))*0.25;
|
||||
col.z += (1.0 + sin(d*4))*0.25;
|
||||
gl_FragColor = col;
|
||||
}
|
19
modules/game_shaders/shaders/pulse.frag
Normal file
19
modules/game_shaders/shaders/pulse.frag
Normal file
@@ -0,0 +1,19 @@
|
||||
uniform float u_Time;
|
||||
uniform vec2 u_Resolution;
|
||||
uniform sampler2D u_Tex0;
|
||||
varying vec2 v_TexCoord;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec2 halfres = u_Resolution.xy/2.0;
|
||||
vec2 cPos = v_TexCoord.xy * u_Resolution;
|
||||
|
||||
cPos.x -= 0.5*halfres.x*sin(u_Time/2.0)+0.3*halfres.x*cos(u_Time)+halfres.x;
|
||||
cPos.y -= 0.4*halfres.y*sin(u_Time/5.0)+0.3*halfres.y*cos(u_Time)+halfres.y;
|
||||
float cLength = length(cPos);
|
||||
|
||||
vec2 uv = v_TexCoord.xy+ ((cPos/cLength)*sin(cLength/30.0-u_Time*10.0)/25.0)*0.15;
|
||||
vec3 col = texture2D(u_Tex0,uv).xyz * 250.0/cLength;
|
||||
|
||||
gl_FragColor = vec4(col,1.0);
|
||||
}
|
46
modules/game_shaders/shaders/radialblur.frag
Normal file
46
modules/game_shaders/shaders/radialblur.frag
Normal file
@@ -0,0 +1,46 @@
|
||||
uniform sampler2D u_Tex0;
|
||||
varying vec2 v_TexCoord;
|
||||
|
||||
// some const, tweak for best look
|
||||
const float sampleDist = 1.0;
|
||||
const float sampleStrength = 2.2;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
// some sample positions
|
||||
float samples[10] =
|
||||
float[](-0.08,-0.05,-0.03,-0.02,-0.01,0.01,0.02,0.03,0.05,0.08);
|
||||
|
||||
// 0.5,0.5 is the center of the screen
|
||||
// so substracting v_TexCoord from it will result in
|
||||
// a vector pointing to the middle of the screen
|
||||
vec2 dir = 0.5 - v_TexCoord;
|
||||
|
||||
// calculate the distance to the center of the screen
|
||||
float dist = sqrt(dir.x*dir.x + dir.y*dir.y);
|
||||
|
||||
// normalize the direction (reuse the distance)
|
||||
dir = dir/dist;
|
||||
|
||||
// this is the original colour of this fragment
|
||||
// using only this would result in a nonblurred version
|
||||
vec4 color = texture2D(u_Tex0,v_TexCoord);
|
||||
|
||||
vec4 sum = color;
|
||||
|
||||
// take 10 additional blur samples in the direction towards
|
||||
// the center of the screen
|
||||
for(int i = 0; i < 10; i++)
|
||||
sum += texture2D(u_Tex0, v_TexCoord + dir * samples[i] * sampleDist);
|
||||
|
||||
// we have taken eleven samples
|
||||
sum *= 1.0/11.0;
|
||||
|
||||
// weighten the blur effect with the distance to the
|
||||
// center of the screen ( further out is blurred more)
|
||||
float t = dist * sampleStrength;
|
||||
t = clamp(t ,0.0,1.0); //0 <= t <= 1
|
||||
|
||||
//Blend the original color with the averaged pixels
|
||||
gl_FragColor = mix(color, sum, t);
|
||||
}
|
16
modules/game_shaders/shaders/sepia.frag
Normal file
16
modules/game_shaders/shaders/sepia.frag
Normal file
@@ -0,0 +1,16 @@
|
||||
uniform float u_Time;
|
||||
uniform sampler2D u_Tex0;
|
||||
varying vec2 v_TexCoord;
|
||||
|
||||
vec4 sepia(vec4 color)
|
||||
{
|
||||
return vec4(dot(color, vec4(.393, .769, .189, .0)),
|
||||
dot(color, vec4(.349, .686, .168, .0)),
|
||||
dot(color, vec4(.272, .534, .131, .0)),
|
||||
1);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = sepia(texture2D(u_Tex0, v_TexCoord));
|
||||
}
|
13
modules/game_shaders/shaders/zomg.frag
Normal file
13
modules/game_shaders/shaders/zomg.frag
Normal file
@@ -0,0 +1,13 @@
|
||||
uniform sampler2D u_Tex0;
|
||||
uniform float u_Time;
|
||||
varying vec2 v_TexCoord;
|
||||
|
||||
vec2 tibiaDir = vec2(1.0, 1.0);
|
||||
void main(void)
|
||||
{
|
||||
vec2 dir = 0.5 - v_TexCoord;
|
||||
float dist = sqrt(dir.x*dir.x + dir.y*dir.y);
|
||||
float scale = 0.8 + dist*0.5;
|
||||
vec4 color = texture2D(u_Tex0, -(dir*scale - 0.5));
|
||||
gl_FragColor = color;
|
||||
}
|
Reference in New Issue
Block a user