diff --git a/core/assets/shaders/slag.frag b/core/assets/shaders/slag.frag index afb161de6d..0d87812584 100755 --- a/core/assets/shaders/slag.frag +++ b/core/assets/shaders/slag.frag @@ -3,84 +3,34 @@ precision highp float; precision mediump int; #endif -//shade 1 + 2 -#define s2 vec3(100.0, 93.0, 49.0) / 100.0 -#define s1 vec3(100.0, 60.0, 25.0) / 100.0 +//shades of slag +#define S2 vec3(100.0, 93.0, 49.0) / 100.0 +#define S1 vec3(100.0, 60.0, 25.0) / 100.0 +#define NSCALE 300.0 uniform sampler2D u_texture; +uniform sampler2D u_noise; -uniform vec2 camerapos; -uniform vec2 screensize; -uniform float time; +uniform vec2 u_campos; +uniform vec2 u_resolution; +uniform float u_time; varying vec4 v_color; varying vec2 v_texCoord; -vec3 permute(vec3 x) { return mod(((x*34.0)+1.0)*x, 289.0); } - -float snoise(vec2 v){ - const vec4 C = vec4(0.211324865405187, 0.366025403784439, - -0.577350269189626, 0.024390243902439); - vec2 i = floor(v + dot(v, C.yy) ); - vec2 x0 = v - i + dot(i, C.xx); - vec2 i1; - i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0); - vec4 x12 = x0.xyxy + C.xxzz; - x12.xy -= i1; - i = mod(i, 289.0); - vec3 p = permute( permute( i.y + vec3(0.0, i1.y, 1.0 )) - + i.x + vec3(0.0, i1.x, 1.0 )); - vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x12.xy,x12.xy), - dot(x12.zw,x12.zw)), 0.0); - m = m*m ; - m = m*m ; - vec3 x = 2.0 * fract(p * C.www) - 1.0; - vec3 h = abs(x) - 0.5; - vec3 ox = floor(x + 0.5); - vec3 a0 = x - ox; - m *= 1.79284291400159 - 0.85373472095314 * ( a0*a0 + h*h ); - vec3 g; - g.x = a0.x * x0.x + h.x * x0.y; - g.yz = a0.yz * x12.xz + h.yz * x12.yw; - return 130.0 * dot(m, g); -} - void main(){ + vec2 c = v_texCoord.xy; + vec2 coords = vec2(c.x * u_resolution.x + u_campos.x, c.y * u_resolution.y + u_campos.y); - vec2 c = v_texCoord.xy; - vec4 color = texture2D(u_texture, c); + float btime = u_time / 4000.0; + float noise = (texture2D(u_noise, (coords) / NSCALE + vec2(btime) * vec2(-0.9, 0.8)).r + texture2D(u_noise, (coords) / NSCALE + vec2(btime * 1.1) * vec2(0.8, -1.0)).r) / 2.0; + vec3 color = texture2D(u_texture, c).rgb; - vec2 v = vec2(1.0/screensize.x, 1.0/screensize.y); - vec2 coords = c / v + camerapos; - - float stime = time / 5.0; - - float mscl = 30.0; - float mth = 5.0; - - //if there's something actually there - if(color.r > 0.01){ - vec4 old = color; - color = texture2D(u_texture, c + vec2(sin(stime/3.0 + coords.y/0.75) * v.x, 0.0)) * vec4(0.9, 0.9, 1, 1.0); - - if(color.r < 0.01){ - color = old; - } - - const float bs = 1.1; - - float n1 = snoise(coords / (30.0 * bs) + vec2(time) / 280.0); - float n2 = snoise((coords + vec2(632.0)) / (14.0 * bs) + vec2(0.0, -time) / 290.0); - float n3 = snoise((coords + vec2(2233.0)) / (25.0 * bs) + vec2(time, 0.0) / 380.0); - - float r = (n1 + n2 + n3) / 3.0; - - if(r < -0.5){ - color = vec4(s2, color.a); - }else if(r < -0.2){ - color = vec4(s1, color.a); - } - } + if(noise > 0.6){ + color = S2; + }else if(noise > 0.54){ + color = S1; + } - gl_FragColor = color; -} + gl_FragColor = vec4(color.rgb, 1.0); +} \ No newline at end of file diff --git a/core/assets/shaders/tar.frag b/core/assets/shaders/tar.frag index bdbd49c4b3..e0aebac243 100644 --- a/core/assets/shaders/tar.frag +++ b/core/assets/shaders/tar.frag @@ -3,69 +3,29 @@ precision highp float; precision mediump int; #endif -uniform sampler2D u_texture; +#define NSCALE 180.0 -uniform vec2 camerapos; -uniform vec2 screensize; -uniform float time; +uniform sampler2D u_texture; +uniform sampler2D u_noise; + +uniform vec2 u_campos; +uniform vec2 u_resolution; +uniform float u_time; varying vec4 v_color; varying vec2 v_texCoord; -vec3 permute(vec3 x) { return mod(((x*34.0)+1.0)*x, 289.0); } +void main(){ + vec2 c = v_texCoord.xy; + vec2 coords = vec2(c.x * u_resolution.x + u_campos.x, c.y * u_resolution.y + u_campos.y); -float snoise(vec2 v){ - const vec4 C = vec4(0.211324865405187, 0.366025403784439, - -0.577350269189626, 0.024390243902439); - vec2 i = floor(v + dot(v, C.yy) ); - vec2 x0 = v - i + dot(i, C.xx); - vec2 i1; - i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0); - vec4 x12 = x0.xyxy + C.xxzz; - x12.xy -= i1; - i = mod(i, 289.0); - vec3 p = permute( permute( i.y + vec3(0.0, i1.y, 1.0 )) - + i.x + vec3(0.0, i1.x, 1.0 )); - vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x12.xy,x12.xy), - dot(x12.zw,x12.zw)), 0.0); - m = m*m ; - m = m*m ; - vec3 x = 2.0 * fract(p * C.www) - 1.0; - vec3 h = abs(x) - 0.5; - vec3 ox = floor(x + 0.5); - vec3 a0 = x - ox; - m *= 1.79284291400159 - 0.85373472095314 * ( a0*a0 + h*h ); - vec3 g; - g.x = a0.x * x0.x + h.x * x0.y; - g.yz = a0.yz * x12.xz + h.yz * x12.yw; - return 130.0 * dot(m, g); -} + float btime = u_time / 8000.0; + float noise = (texture2D(u_noise, (coords) / NSCALE + vec2(btime) * vec2(-0.9, 0.8)).r + texture2D(u_noise, (coords) / NSCALE + vec2(btime * 1.1) * vec2(-0.8, -1.0)).r) / 2.0; + vec3 color = texture2D(u_texture, c).rgb; -void main() { - - vec2 c = v_texCoord.xy; - vec4 color = texture2D(u_texture, c); - - vec2 v = vec2(1.0/screensize.x, 1.0/screensize.y); - vec2 coords = vec2(c.x / v.x + camerapos.x, c.y / v.y + camerapos.y); - - float stime = time / 5.0; - - float mscl = 30.0; - float mth = 5.0; - - if(color.r > 0.01){ - color = texture2D(u_texture, c + vec2(sin(stime/3.0 + coords.y/0.75) * v.x, 0.0)) * vec4(0.9, 0.9, 1, 1.0); - - float n1 = snoise(coords / 22.0 + vec2(-time) / 540.0); - float n2 = snoise((coords + vec2(632.0)) / 8.0 + vec2(0.0, time) / 510.0); - - float r = (n1 + n2) / 2.0; - - if(r < -0.3 && r > -0.6){ - color *= 1.4; - } + if(!(noise > 0.54 && noise < 0.58)){ + color *= 0.6; } - gl_FragColor = color; + gl_FragColor = vec4(color.rgb, 1.0); } \ No newline at end of file diff --git a/core/assets/shaders/water.frag b/core/assets/shaders/water.frag index d8319103a7..1d2b67f889 100644 --- a/core/assets/shaders/water.frag +++ b/core/assets/shaders/water.frag @@ -5,34 +5,33 @@ precision mediump int; uniform sampler2D u_texture; -uniform vec2 camerapos; -uniform vec2 screensize; -uniform float time; +uniform vec2 u_campos; +uniform vec2 u_resolution; +uniform float u_time; varying vec4 v_color; varying vec2 v_texCoord; +const float mscl = 40.0; +const float mth = 7.0; + void main(){ vec2 c = v_texCoord.xy; - vec2 v = vec2(1.0/screensize.x, 1.0/screensize.y); - vec2 coords = vec2(c.x / v.x + camerapos.x, c.y / v.y + camerapos.y); + vec2 v = vec2(1.0/u_resolution.x, 1.0/u_resolution.y); + vec2 coords = vec2(c.x / v.x + u_campos.x, c.y / v.y + u_campos.y); - float stime = time / 5.0; - - float mscl = 40.0; - float mth = 7.0; + float stime = u_time / 5.0; vec3 color = texture2D(u_texture, c + vec2(sin(stime/3.0 + coords.y/0.75) * v.x, 0.0)).rgb * vec3(0.9, 0.9, 1); - float r = 0.0; float tester = mod((coords.x + coords.y*1.1 + sin(stime / 8.0 + coords.x/5.0 - coords.y/100.0)*2.0) + sin(stime / 20.0 + coords.y/3.0) * 1.0 + sin(stime / 10.0 - coords.y/2.0) * 2.0 + sin(stime / 7.0 + coords.y/1.0) * 0.5 + sin(coords.x / 3.0 + coords.y / 2.0) + - sin(stime / 20.0 + coords.x/4.0) * 1.0, mscl) + r; + sin(stime / 20.0 + coords.x/4.0) * 1.0, mscl); if(tester < mth){ color *= 1.2; diff --git a/core/assets/sprites/noise.png b/core/assets/sprites/noise.png new file mode 100644 index 0000000000..b9302dd5f4 Binary files /dev/null and b/core/assets/sprites/noise.png differ diff --git a/core/src/mindustry/core/Control.java b/core/src/mindustry/core/Control.java index 63564cb211..bbbdc415cb 100644 --- a/core/src/mindustry/core/Control.java +++ b/core/src/mindustry/core/Control.java @@ -167,8 +167,11 @@ public class Control implements ApplicationListener, Loadable{ if(core == null) return; //TODO this sounds pretty bad due to conflict - Musics.land.stop(); - Musics.land.play(); + if(settings.getInt("musicvol") > 0){ + Musics.land.stop(); + Musics.land.play(); + Musics.land.setVolume(settings.getInt("musicvol") / 100f); + } app.post(() -> ui.hudfrag.showLand()); renderer.zoomIn(Fx.coreLand.lifetime); diff --git a/core/src/mindustry/graphics/Shaders.java b/core/src/mindustry/graphics/Shaders.java index 3f4b7c6208..8723c687ea 100644 --- a/core/src/mindustry/graphics/Shaders.java +++ b/core/src/mindustry/graphics/Shaders.java @@ -2,6 +2,7 @@ package mindustry.graphics; import arc.*; import arc.graphics.*; +import arc.graphics.Texture.*; import arc.graphics.g2d.*; import arc.graphics.g3d.*; import arc.graphics.gl.*; @@ -12,6 +13,8 @@ import arc.util.ArcAnnotate.*; import arc.util.*; import mindustry.type.*; +import static mindustry.Vars.renderer; + public class Shaders{ public static Shadow shadow; public static BlockBuild blockbuild; @@ -251,13 +254,25 @@ public class Shaders{ public SurfaceShader(String frag){ super(frag, "default"); + + Core.assets.load("sprites/noise.png", Texture.class).loaded = t -> { + ((Texture)t).setFilter(TextureFilter.Linear); + ((Texture)t).setWrap(TextureWrap.Repeat); + }; } @Override public void apply(){ - setUniformf("camerapos", Core.camera.position.x - Core.camera.width / 2, Core.camera.position.y - Core.camera.height / 2); - setUniformf("screensize", Core.camera.width, Core.camera.height); - setUniformf("time", Time.time()); + setUniformf("u_campos", Core.camera.position.x - Core.camera.width / 2, Core.camera.position.y - Core.camera.height / 2); + setUniformf("u_resolution", Core.camera.width, Core.camera.height); + setUniformf("u_time", Time.time()); + + if(hasUniform("u_noise")){ + Core.assets.get("sprites/noise.png", Texture.class).bind(1); + renderer.effectBuffer.getTexture().bind(0); + + setUniformi("u_noise", 1); + } } } diff --git a/gradle.properties b/gradle.properties index 8100c8da39..da0c3966fa 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ org.gradle.daemon=true org.gradle.jvmargs=-Xms256m -Xmx1024m -archash=81dbe69779811234169486401f68ff66bc573d58 +archash=7f42d930e71cad9bf0f461d0cc92c4963fcc8067