Shader cleanup

This commit is contained in:
Anuken 2020-03-10 19:48:38 -04:00
parent 25bbce2e10
commit 930c342fb6
34 changed files with 80 additions and 2 deletions

View 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);
}
}

View File

@ -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);

View File

@ -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){

View File

@ -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"));
}
}
}

View 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);
}
}

View 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

View 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

View File

@ -1,3 +1,3 @@
org.gradle.daemon=true
org.gradle.jvmargs=-Xms256m -Xmx1024m
archash=b9e67c0962f933315770d978c8a82b6fe6ec33a1
archash=d781ecb488d5431692ffa509fa1a1a21a8f8185d