mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-01-07 14:01:51 +07:00
Shader cleanup
This commit is contained in:
parent
25bbce2e10
commit
930c342fb6
48
core/assets/shaders/snow.frag
Normal file
48
core/assets/shaders/snow.frag
Normal file
@ -0,0 +1,48 @@
|
||||
#define LIGHT
|
||||
|
||||
#ifdef LIGHT
|
||||
#define LAYERS 30.
|
||||
#define DEPTH .5
|
||||
#define WIDTH .3
|
||||
#define SPEED .6
|
||||
#define SIZE 0.2
|
||||
#else
|
||||
#define LAYERS 200.
|
||||
#define DEPTH .1
|
||||
#define WIDTH .8
|
||||
#define SPEED 1.5
|
||||
#define SIZE 1.0
|
||||
#endif
|
||||
|
||||
varying vec2 v_texCoords;
|
||||
|
||||
uniform vec2 u_pos;
|
||||
uniform vec2 u_resolution;
|
||||
uniform float u_time;
|
||||
uniform sampler2D u_texture0;
|
||||
|
||||
void main(){
|
||||
gl_FragColor = texture2D(u_texture0, v_texCoords);
|
||||
|
||||
vec2 uv = (v_texCoords * u_resolution + u_pos) / 1000.0;
|
||||
const mat3 p = mat3(
|
||||
13.3231, 23.5112, 21.7112,
|
||||
21.1212, 28.7312, 11.9312,
|
||||
21.8112, 14.7212, 61.3934
|
||||
);
|
||||
float dof = 5.*sin(u_time*.1);
|
||||
|
||||
//TODO this is very slow
|
||||
for(float i=0.0; i<LAYERS; i++){
|
||||
vec2 q = uv* (1.+i*DEPTH);
|
||||
q += vec2( q.y* WIDTH *( fract(i*7.238917) - .5 ),
|
||||
SPEED* u_time / (1.+i*DEPTH*.03) );
|
||||
vec3 n = vec3(floor(q), 31.189+i), m = floor(n)/1e5 + fract(n), mp = (31.9+m) / fract(p*m),
|
||||
r = fract(mp);
|
||||
vec2 s = abs(fract(q)-.5 +.9*r.xy-.45) + .01*abs(2.0*fract(10.*q.yx) - 1.0);
|
||||
float d = .6 * (s.x+s.y) + max(s.x,s.y) -.01,
|
||||
edge = .005*SIZE + .05 * SIZE * min( .5* abs(i-5.-dof), 1.);
|
||||
|
||||
gl_FragColor += smoothstep(edge,-edge,d) * r.x / (1.+.02*i*DEPTH);
|
||||
}
|
||||
}
|
@ -114,6 +114,7 @@ public class Control implements ApplicationListener, Loadable{
|
||||
|
||||
//autohost for pvp maps
|
||||
Events.on(WorldLoadEvent.class, event -> app.post(() -> {
|
||||
player.add();
|
||||
if(state.rules.pvp && !net.active()){
|
||||
try{
|
||||
net.host(port);
|
||||
|
@ -38,6 +38,8 @@ public class Renderer implements ApplicationListener{
|
||||
public Renderer(){
|
||||
camera = new Camera();
|
||||
Shaders.init();
|
||||
|
||||
fx.addEffect(new SnowFilter());
|
||||
}
|
||||
|
||||
public void shake(float intensity, float duration){
|
||||
|
@ -229,7 +229,7 @@ public class Shaders{
|
||||
|
||||
public static class LoadShader extends Shader{
|
||||
public LoadShader(String frag, String vert){
|
||||
super(Core.files.internal("shaders/" + vert + ".vertex.glsl"), Core.files.internal("shaders/" + frag + ".fragment.glsl"));
|
||||
super(Core.files.internal("shaders/" + vert + ".vert"), Core.files.internal("shaders/" + frag + ".frag"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
19
core/src/mindustry/graphics/SnowFilter.java
Normal file
19
core/src/mindustry/graphics/SnowFilter.java
Normal file
@ -0,0 +1,19 @@
|
||||
package mindustry.graphics;
|
||||
|
||||
import arc.*;
|
||||
import arc.fx.*;
|
||||
|
||||
public class SnowFilter extends FxFilter{
|
||||
|
||||
public SnowFilter(){
|
||||
super(compileShader(Core.files.internal("shaders/screenspace.vert"), Core.files.internal("shaders/snow.frag")));
|
||||
autobind = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParams(){
|
||||
shader.setUniformf("u_time", time / 60f);
|
||||
shader.setUniformf("u_pos", Core.camera.position.x - Core.camera.width / 2, Core.camera.position.y - Core.camera.height / 2);
|
||||
shader.setUniformf("u_resolution", Core.camera.width, Core.camera.height);
|
||||
}
|
||||
}
|
4
fastlane/metadata/android/en-US/changelogs/104.5.txt
Normal file
4
fastlane/metadata/android/en-US/changelogs/104.5.txt
Normal file
@ -0,0 +1,4 @@
|
||||
- Updated feature suggestion link
|
||||
- Updated translations
|
||||
- Fixed modified player name persisting after server is exited
|
||||
- Added solar power multiplier rule
|
4
fastlane/metadata/android/en-US/changelogs/29623.txt
Normal file
4
fastlane/metadata/android/en-US/changelogs/29623.txt
Normal file
@ -0,0 +1,4 @@
|
||||
- Updated feature suggestion link
|
||||
- Updated translations
|
||||
- Fixed modified player name persisting after server is exited
|
||||
- Added solar power multiplier rule
|
@ -1,3 +1,3 @@
|
||||
org.gradle.daemon=true
|
||||
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
||||
archash=b9e67c0962f933315770d978c8a82b6fe6ec33a1
|
||||
archash=d781ecb488d5431692ffa509fa1a1a21a8f8185d
|
||||
|
Loading…
Reference in New Issue
Block a user