From b8655862e3dc84e633a9baae348549a752462e31 Mon Sep 17 00:00:00 2001 From: Marisa Kirisame Date: Mon, 25 Oct 2021 16:28:44 +0200 Subject: [PATCH] Merge duplicate shaders and use defines to alter behavior. --- gldefs.misc | 17 +++++++++--- gldefs.shinemaps | 6 +++-- language.version | 4 +-- shaders/glsl/Fuzz.fp | 13 +++++++-- shaders/glsl/Fuzz_Gray.fp | 44 ------------------------------- shaders/glsl/Fuzz_GraySmall.fp | 45 -------------------------------- shaders/glsl/Fuzz_GraySmall2.fp | 45 -------------------------------- shaders/glsl/HealthBarD.fp | 2 +- shaders/glsl/LogoAnimated.fp | 2 +- shaders/glsl/Shinemap.fp | 18 +++++++++++++ shaders/glsl/Shinemap_barrier.fp | 12 --------- shaders/glsl/Shinemap_error.fp | 14 ---------- 12 files changed, 51 insertions(+), 171 deletions(-) delete mode 100644 shaders/glsl/Fuzz_Gray.fp delete mode 100644 shaders/glsl/Fuzz_GraySmall.fp delete mode 100644 shaders/glsl/Fuzz_GraySmall2.fp delete mode 100644 shaders/glsl/Shinemap_barrier.fp delete mode 100644 shaders/glsl/Shinemap_error.fp diff --git a/gldefs.misc b/gldefs.misc index 22f19aa3e..aaa8fad1b 100644 --- a/gldefs.misc +++ b/gldefs.misc @@ -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" diff --git a/gldefs.shinemaps b/gldefs.shinemaps index e483cde52..3baef3e64 100644 --- a/gldefs.shinemaps +++ b/gldefs.shinemaps @@ -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" { diff --git a/language.version b/language.version index 3f06824b7..10f8a3362 100644 --- a/language.version +++ b/language.version @@ -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-"; diff --git a/shaders/glsl/Fuzz.fp b/shaders/glsl/Fuzz.fp index c226a93fa..35ad5e131 100644 --- a/shaders/glsl/Fuzz.fp +++ b/shaders/glsl/Fuzz.fp @@ -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); } diff --git a/shaders/glsl/Fuzz_Gray.fp b/shaders/glsl/Fuzz_Gray.fp deleted file mode 100644 index 74ec9698d..000000000 --- a/shaders/glsl/Fuzz_Gray.fp +++ /dev/null @@ -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.); -} diff --git a/shaders/glsl/Fuzz_GraySmall.fp b/shaders/glsl/Fuzz_GraySmall.fp deleted file mode 100644 index 360c0af99..000000000 --- a/shaders/glsl/Fuzz_GraySmall.fp +++ /dev/null @@ -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); -} diff --git a/shaders/glsl/Fuzz_GraySmall2.fp b/shaders/glsl/Fuzz_GraySmall2.fp deleted file mode 100644 index c62ec27e2..000000000 --- a/shaders/glsl/Fuzz_GraySmall2.fp +++ /dev/null @@ -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); -} diff --git a/shaders/glsl/HealthBarD.fp b/shaders/glsl/HealthBarD.fp index 6bfec1bbb..ffc20ff92 100644 --- a/shaders/glsl/HealthBarD.fp +++ b/shaders/glsl/HealthBarD.fp @@ -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); diff --git a/shaders/glsl/LogoAnimated.fp b/shaders/glsl/LogoAnimated.fp index 79836a990..ce8e2e900 100644 --- a/shaders/glsl/LogoAnimated.fp +++ b/shaders/glsl/LogoAnimated.fp @@ -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.); diff --git a/shaders/glsl/Shinemap.fp b/shaders/glsl/Shinemap.fp index 11b0bd376..ea744a0ef 100644 --- a/shaders/glsl/Shinemap.fp +++ b/shaders/glsl/Shinemap.fp @@ -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 +} diff --git a/shaders/glsl/Shinemap_barrier.fp b/shaders/glsl/Shinemap_barrier.fp deleted file mode 100644 index ba3d661dd..000000000 --- a/shaders/glsl/Shinemap_barrier.fp +++ /dev/null @@ -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); -} diff --git a/shaders/glsl/Shinemap_error.fp b/shaders/glsl/Shinemap_error.fp deleted file mode 100644 index 17b763345..000000000 --- a/shaders/glsl/Shinemap_error.fp +++ /dev/null @@ -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); -}