Merge duplicate shaders and use defines to alter behavior.

This commit is contained in:
Mari the Deer 2021-10-25 16:28:44 +02:00
commit b8655862e3
12 changed files with 51 additions and 171 deletions

View file

@ -1,41 +1,52 @@
HardwareShader Texture "graphics/HUD/HealthBarS.png"
{
Shader "shaders/glsl/Fuzz_Gray.fp"
Shader "shaders/glsl/Fuzz.fp"
Define "GRAY_COLORS"
Define "BASE_RES" = "vec2(100.,12.)"
Texture "noisetex" "textures/graynoise.png"
}
HardwareShader Texture "graphics/HUD/EnemyBarS.png"
{
Shader "shaders/glsl/Fuzz_GraySmall.fp"
Shader "shaders/glsl/Fuzz.fp"
Define "GRAY_COLORS"
Define "BASE_RES" = "vec2(50.,3.)"
Texture "noisetex" "textures/graynoise.png"
}
HardwareShader Texture "graphics/HUD/FuelBarS.png"
{
Shader "shaders/glsl/Fuzz_GraySmall2.fp"
Shader "shaders/glsl/Fuzz.fp"
Define "GRAY_COLORS"
Define "BASE_RES" = "vec2(120.,3.)"
Texture "noisetex" "textures/graynoise.png"
}
HardwareShader Texture "graphics/HUD/HealthBarD.png"
{
Shader "shaders/glsl/HealthBarD.fp"
Define "TEX_SIZE" = "vec2(120.,32.)"
Texture "noisetex" "textures/graynoise.png"
}
HardwareShader Texture "graphics/HUD/EnemyBarD.png"
{
Shader "shaders/glsl/HealthBarD.fp"
Define "TEX_SIZE" = "vec2(70.,23.)"
Texture "noisetex" "textures/graynoise.png"
}
HardwareShader Texture "graphics/tempbg.png"
{
Shader "shaders/glsl/Fuzz.fp"
Define "BASE_RES" = "vec2(640.,400.)"
Texture "noisetex" "textures/graynoise.png"
}
HardwareShader Texture "graphics/SWWMGZLogo.png"
{
Shader "shaders/glsl/LogoAnimated.fp"
Define "TEX_SZ" = "vec2(2048.,1024.)"
Texture "LogoTex" "graphics/SWWMGZLogo_Layers.png"
}
HardwareShader Texture "graphics/M_SWWM.png"
{
Shader "shaders/glsl/LogoAnimated.fp"
Define "TEX_SZ" = "vec2(256.,128.)"
Texture "LogoTex" "graphics/M_SWWM_Layers.png"
}
HardwareShader Sprite "MBRNB0"

View file

@ -52,12 +52,14 @@ HardwareShader Texture "models/matcap/leadmap.png"
}
HardwareShader Texture "models/matcap/barriermap.png"
{
Shader "shaders/glsl/Shinemap_barrier.fp"
Shader "shaders/glsl/Shinemap.fp"
Define "BARRIER_MAP"
Texture "bartex" "models/barrierbar.png"
}
HardwareShader Texture "models/matcap/errormap.png"
{
Shader "shaders/glsl/Shinemap_error.fp"
Shader "shaders/glsl/Shinemap.fp"
Define "AMBIENT_GLOW"
}
HardwareShader Texture "models/matcap/glassmap.png"
{

View file

@ -1,3 +1,3 @@
[default]
SWWM_MODVER="\chSWWM \czGZ\c- \cw1.1.36 \cu(Mon 25 Oct 13:13:02 CEST 2021)\c-";
SWWM_SHORTVER="\cw1.1.36 \cu(2021-10-25 13:13:02)\c-";
SWWM_MODVER="\chSWWM \czGZ\c- \cw1.1.37 \cu(Mon 25 Oct 16:30:00 CEST 2021)\c-";
SWWM_SHORTVER="\cw1.1.37 \cu(2021-10-25 16:30:00)\c-";

View file

@ -13,9 +13,15 @@ float rnd( in vec2 sd )
// what the fuck even is this insane syntax?
const vec3 layers[3] =
vec3[](
#ifdef GRAY_COLORS
vec3(1.01,1.07,1.05),
vec3(1.06,1.04,1.03),
vec3(1.05,1.03,1.01)
#else
vec3(0.91,0.87,1.95),
vec3(0.66,1.84,0.73),
vec3(1.35,0.73,1.21)
#endif
);
const float speed[3] =
float[](
@ -36,9 +42,12 @@ void SetupMaterial( inout Material mat )
vec3 col = vec3(1.);
for ( int i=0; i<3; i++ )
{
coord = floor(vTexCoord.st*vec2(640.,400.)/zoom[i]);
col *= layers[i]*2.0*abs(fract(rnd(coord)+timer*speed[i])-0.5);
coord = floor(vTexCoord.st*BASE_RES/zoom[i]);
col *= layers[i]*2.*abs(fract(rnd(coord)+timer*speed[i])-.5);
}
#ifdef GRAY_COLORS
col += getTexel(vTexCoord.st).rgb;
#endif
mat.Base = vec4(col,1.);
mat.Normal = ApplyNormalMap(vTexCoord.st);
}

View file

@ -1,44 +0,0 @@
// adapted from original "fuzz" filter devised in 2016
// PRNG replaced with noise texture sampling to compensate for odd patterning
// on intel hardware
float rnd( in vec2 sd )
{
//return cos(sd.y*3874.8674+sd.x*6783.5325)*2737.8474;
// use noise tex instead of trig-based PRNG, much better and doesn't break on intel
return texelFetch(noisetex,ivec2(mod(sd.x,256.),mod(sd.y,256.)),0).x;
}
// haha are you telling me I can't declare arrays like in C?
// what the fuck even is this insane syntax?
const vec3 layers[3] =
vec3[](
vec3(1.01,1.07,1.05),
vec3(1.06,1.04,1.03),
vec3(1.05,1.03,1.01)
);
const float speed[3] =
float[](
.5526,
.7843,
.3725
);
const float zoom[3] =
float[](
1.,
2.,
3.
);
void SetupMaterial( inout Material mat )
{
vec2 coord;
vec3 col = vec3(1.);
for ( int i=0; i<3; i++ )
{
coord = floor(vTexCoord.st*vec2(100.,12.)/zoom[i]);
col *= layers[i]*2.0*abs(fract(rnd(coord)+timer*speed[i])-0.5);
}
col += getTexel(vTexCoord.st).rgb;
mat.Base = vec4(col,1.);
}

View file

@ -1,45 +0,0 @@
// adapted from original "fuzz" filter devised in 2016
// PRNG replaced with noise texture sampling to compensate for odd patterning
// on intel hardware
float rnd( in vec2 sd )
{
//return cos(sd.y*3874.8674+sd.x*6783.5325)*2737.8474;
// use noise tex instead of trig-based PRNG, much better and doesn't break on intel
return texelFetch(noisetex,ivec2(mod(sd.x,256.),mod(sd.y,256.)),0).x;
}
// haha are you telling me I can't declare arrays like in C?
// what the fuck even is this insane syntax?
const vec3 layers[3] =
vec3[](
vec3(1.01,1.07,1.05),
vec3(1.06,1.04,1.03),
vec3(1.05,1.03,1.01)
);
const float speed[3] =
float[](
.5526,
.7843,
.3725
);
const float zoom[3] =
float[](
1.,
2.,
3.
);
void SetupMaterial( inout Material mat )
{
vec2 coord;
vec3 col = vec3(1.);
for ( int i=0; i<3; i++ )
{
coord = floor(vTexCoord.st*vec2(50.,3.)/zoom[i]);
col *= layers[i]*2.0*abs(fract(rnd(coord)+timer*speed[i])-0.5);
}
col += getTexel(vTexCoord.st).rgb;
mat.Base = vec4(col,1.);
mat.Normal = ApplyNormalMap(vTexCoord.st);
}

View file

@ -1,45 +0,0 @@
// adapted from original "fuzz" filter devised in 2016
// PRNG replaced with noise texture sampling to compensate for odd patterning
// on intel hardware
float rnd( in vec2 sd )
{
//return cos(sd.y*3874.8674+sd.x*6783.5325)*2737.8474;
// use noise tex instead of trig-based PRNG, much better and doesn't break on intel
return texelFetch(noisetex,ivec2(mod(sd.x,256.),mod(sd.y,256.)),0).x;
}
// haha are you telling me I can't declare arrays like in C?
// what the fuck even is this insane syntax?
const vec3 layers[3] =
vec3[](
vec3(1.01,1.07,1.05),
vec3(1.06,1.04,1.03),
vec3(1.05,1.03,1.01)
);
const float speed[3] =
float[](
.5526,
.7843,
.3725
);
const float zoom[3] =
float[](
1.,
2.,
3.
);
void SetupMaterial( inout Material mat )
{
vec2 coord;
vec3 col = vec3(1.);
for ( int i=0; i<3; i++ )
{
coord = floor(vTexCoord.st*vec2(120.,3.)/zoom[i]);
col *= layers[i]*2.0*abs(fract(rnd(coord)+timer*speed[i])-0.5);
}
col += getTexel(vTexCoord.st).rgb;
mat.Base = vec4(col,1.);
mat.Normal = ApplyNormalMap(vTexCoord.st);
}

View file

@ -8,7 +8,7 @@ void SetupMaterial( inout Material mat )
.008764, .002216, .000436, .000067, .000008
);
vec2 coord = vTexCoord.st;
vec2 bresl = textureSize(tex,0);
vec2 bresl = TEX_SIZE;
vec2 bof = 1./bresl;
bof *= .9+.4*texture(noisetex,vec2(fract(timer*.05))).x;
vec4 col = texture(tex,coord);

View file

@ -85,7 +85,7 @@ void SetupMaterial( inout Material mat )
tmp2.rgb = (tmp.rgb*tmp.a+base.rgb*base.a*(1-tmp.a))/tmp2.a;
if ( tmp2.a == 0. ) tmp2.rgb = vec3(0.);
// clamp borders
vec2 sz = vec2(256,128);
vec2 sz = TEX_SZ;
vec2 px = uv*sz;
if ( (px.x <= 1) || (px.x >= (sz.x-1)) || (px.y <= 1) || (px.y >= (sz.y-1)) )
tmp2 = vec4(0.);

View file

@ -3,6 +3,24 @@
void SetupMaterial( inout Material mat )
{
vec3 rnorm = normalize(vEyeNormal.xyz)*vec3(1,-1,1);
#ifdef BARRIER_MAP
vec4 basemap = getTexel(rnorm.xy*.49+.5);
basemap.rgb *= .25;
vec3 grad = texture(bartex,vec2(0.,vTexCoord.t*5.+timer)).rgb;
grad *= .25;
mat.Base = basemap+vec4(grad,0.);
#else
mat.Base = getTexel(rnorm.xy*.49+.5);
#endif
mat.Normal = ApplyNormalMap(vTexCoord.st);
}
vec4 ProcessLight( Material mat, vec4 color )
{
#ifdef AMBIENT_GLOW
float glow = .75+.25*sin(timer*8);
return vec4(vec3(glow),color.a);
#else
return color;
#endif
}

View file

@ -1,12 +0,0 @@
// pseudo-matcap + scrolling overlay
void SetupMaterial( inout Material mat )
{
vec3 rnorm = normalize(vEyeNormal.xyz)*vec3(1,-1,1);
vec4 basemap = getTexel(rnorm.xy*.49+.5);
basemap.rgb *= .25;
vec3 grad = texture(bartex,vec2(0.,vTexCoord.t*5.+timer)).rgb;
grad *= .25;
mat.Base = basemap+vec4(grad,0.);
mat.Normal = ApplyNormalMap(vTexCoord.st);
}

View file

@ -1,14 +0,0 @@
// pseudo-matcap + ambient glow
void SetupMaterial( inout Material mat )
{
vec3 rnorm = normalize(vEyeNormal.xyz)*vec3(1,-1,1);
mat.Base = getTexel(rnorm.xy*.49+.5);
mat.Normal = ApplyNormalMap(vTexCoord.st);
}
vec4 ProcessLight( Material mat, vec4 color )
{
float glow = .75+.25*sin(timer*8);
return vec4(vec3(glow),color.a);
}