New basic water sprite

This commit is contained in:
Anuken 2019-01-29 22:26:02 -05:00
parent 5af35b6771
commit dbf05a1419
22 changed files with 725 additions and 766 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 75 B

After

Width:  |  Height:  |  Size: 1 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 95 B

After

Width:  |  Height:  |  Size: 992 B

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 109 B

After

Width:  |  Height:  |  Size: 1 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 100 B

After

Width:  |  Height:  |  Size: 990 B

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 75 B

After

Width:  |  Height:  |  Size: 1.1 KiB

Before After
Before After

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

View file

@ -0,0 +1,14 @@
attribute vec4 a_position;
attribute vec4 a_color;
attribute vec2 a_texCoord0;
uniform mat4 u_projectionViewMatrix;
varying vec4 v_color;
varying vec2 v_texCoords;
void main()
{
v_color = a_color;
v_color.a = v_color.a * (255.0/254.0);
v_texCoords = a_texCoord0;
gl_Position = u_projectionViewMatrix * a_position;
}

View file

@ -1,90 +1,18 @@
#ifdef GL_ES
precision highp float;
precision mediump int;
precision mediump float;
#endif
varying vec4 v_color;
varying vec2 v_texCoords;
uniform sampler2D u_texture;
uniform float u_time;
uniform vec2 camerapos;
uniform vec2 screensize;
uniform float time;
varying vec4 v_color;
varying vec2 v_texCoord;
float round(float num, float f){
return float(int(num / f)) * f;
float round(float f, float v){
return float(int(f / v)) * v;
}
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;
vec4 color = texture2D(u_texture, c) * v_color;
vec2 v = vec2(1.0/screensize.x, 1.0/screensize.y);
ivec2 icoords = ivec2(int(c.x / v.x + camerapos.x), int(c.y / v.y + camerapos.y));
vec2 coords = vec2(float(icoords.x), float(icoords.y));
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);
color.a = 1.0;
if(color.r < 0.01){
color = old;
}
float n1 = snoise(coords / 40.0 + vec2(time) / 200.0);
float n2 = snoise((coords + vec2(632.0)) / 25.0 + vec2(0.0, -time) / 190.0);
float r = (n1 + n2) * 3.0;
if(mod(float(int(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 + coords.y) +
sin(stime / 20.0 + coords.x/4.0) * 1.0, mscl) + r < mth){
color *= 1.2;
color.a = 1.0;
}
}
gl_FragColor = color;
}
void main(){
vec2 r = v_texCoords.xy;
vec4 c = v_color * texture2D(u_texture, v_texCoords.xy);
gl_FragColor = c * vec4(vec3(round(1.0 + sin((r.x + r.y) * 404.0 + u_time / 20.0) / 10.0, 0.05)), 1.0);
}

File diff suppressed because it is too large Load diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 975 KiB

After

Width:  |  Height:  |  Size: 980 KiB

Before After
Before After

View file

@ -107,7 +107,7 @@ public class Blocks implements ContentList{
}
deepwater = new Floor("deepwater"){{
liquidColor = Color.valueOf("546bb3");
liquidColor = Color.valueOf("4d5ca4");
speedMultiplier = 0.2f;
variants = 0;
liquidDrop = Liquids.water;
@ -120,7 +120,7 @@ public class Blocks implements ContentList{
}};
water = new Floor("water"){{
liquidColor = Color.valueOf("546bb3");
liquidColor = Color.valueOf("596ab8");
speedMultiplier = 0.5f;
variants = 0;
status = StatusEffects.wet;
@ -165,25 +165,25 @@ public class Blocks implements ContentList{
playerUnmineable = true;
}};
holostone = new Floor("holostone"){{
hasOres = true;
edgeStyle = "blocky";
}};
iceSnow = new Floor("ice-snow"){{
variants = 3;
}};
snow = new Floor("snow"){{
minimapColor = Color.valueOf("c2d1d2");
}};
ice = new Floor("ice"){{
dragMultiplier = 0.2f;
speedMultiplier = 0.4f;
minimapColor = Color.valueOf("b8eef8");
}};
holostone = new Floor("holostone"){{
hasOres = true;
edgeStyle = "blocky";
}};
snow = new Floor("snow"){{
minimapColor = Color.valueOf("c2d1d2");
}};
grass = new Floor("grass"){{
hasOres = true;
minimapColor = Color.valueOf("549d5b");
@ -776,7 +776,7 @@ public class Blocks implements ContentList{
blastDrill = new Drill("blast-drill"){{
requirements(Category.production, ItemStack.with(Items.copper, 130, Items.silicon, 120, Items.titanium, 100, Items.thorium, 60));
drillTime = 120;
drillTime = 200;
size = 3;
drawRim = true;
hasPower = true;
@ -792,7 +792,7 @@ public class Blocks implements ContentList{
plasmaDrill = new Drill("plasma-drill"){{
heatColor = Color.valueOf("ff461b");
drillTime = 100;
drillTime = 150;
size = 4;
hasLiquids = true;
hasPower = true;

View file

@ -117,7 +117,7 @@ public class Fx implements ContentList{
});
unitLand = new GroundEffect(30, e -> {
Draw.color(Palette.lightishGray, e.color, e.rotation);
Draw.color(Tmp.c1.set(e.color).mul(1.1f));
Angles.randLenVectors(e.id, 6, 17f * e.finpow(), (x, y) -> {
Fill.circle(e.x + x, e.y + y, e.fout() * 4f + 0.3f);
});
@ -1067,7 +1067,7 @@ public class Fx implements ContentList{
Draw.reset();
});
ripple = new GroundEffect(false, 30, e -> {
Draw.color(Tmp.c1.set(e.color).shiftValue(0.1f));
Draw.color(Tmp.c1.set(e.color).mul(1.2f));
Lines.stroke(e.fout() + 0.4f);
Lines.circle(e.x, e.y, 2f + e.fin() * 4f);
Draw.reset();

View file

@ -10,7 +10,7 @@ public class Liquids implements ContentList{
@Override
public void load(){
water = new Liquid("water", Color.valueOf("486acd")){{
water = new Liquid("water", Color.valueOf("596ab8")){{
heatCapacity = 0.4f;
tier = 0;
effect = StatusEffects.wet;

View file

@ -168,7 +168,7 @@ public class Zones implements ContentList{
}};
}};
ruinousShores = new Zone("ruinousShores", new MapGenerator("groundZero", 1)){{ //TODO implement
ruinousShores = new Zone("ruinousShores", new MapGenerator("ruinousShores")){{ //TODO implement
deployCost = ItemStack.with(Items.copper, 300);
startingItems = ItemStack.with(Items.copper, 200);
conditionWave = 15;

View file

@ -516,7 +516,7 @@ public class Player extends Unit implements BuilderTrait, ShooterTrait{
if(mech.shake > 1f){
Effects.shake(mech.shake, mech.shake, this);
}
Effects.effect(Fx.unitLand, tile.floor().minimapColor, x, y, tile.floor().isLiquid ? 1f : 0.5f);
Effects.effect(Fx.unitLand, tile.floor().liquidColor == null ? tile.floor().minimapColor : tile.floor().minimapColor, x, y, tile.floor().isLiquid ? 1f : 0.5f);
}
mech.onLand(this);
achievedFlight = false;

View file

@ -3,6 +3,13 @@ package io.anuke.mindustry.graphics;
//TODO implement effects again
public enum CacheLayer{
water{
public void begin(){
//Draw.shader(Shaders.water);
}
public void end(){
//Draw.shader();
}
},
lava{
},
@ -11,8 +18,7 @@ public enum CacheLayer{
space{
},
normal,
walls{ //TODO implement walls
};
walls;
public void begin(){

View file

@ -124,6 +124,8 @@ public class FloorRenderer{
int crangex = (int) (camera.width / (chunksize * tilesize)) + 1;
int crangey = (int) (camera.height / (chunksize * tilesize)) + 1;
SpriteBatch batch = Core.batch;
Core.batch = cbatch;
layer.begin();
for(int x = -crangex; x <= crangex; x++){
@ -142,6 +144,7 @@ public class FloorRenderer{
}
layer.end();
Core.batch = batch;
}
private void cacheChunk(int cx, int cy){

View file

@ -207,7 +207,7 @@ public class Shaders{
public static class SurfaceShader extends LoadShader{
public SurfaceShader(String frag){
super(frag, "default");
super(frag, "cache");
}
@Override
@ -217,7 +217,7 @@ public class Shaders{
Core.camera.position.y - Core.camera.height / 2 );
setUniformf("screensize", Core.camera.width,
Core.camera.height );
setUniformf("time", Time.time());
setUniformf("u_time", Time.time());
}
}

View file

@ -155,6 +155,7 @@ public class HudFragment extends Fragment{
});
parent.fill(t -> {
t.touchable(Touchable.disabled);
t.visible(() -> !state.is(State.menu));
t.table("flat", c -> c.add("$nearpoint")
.update(l -> l.setColor(Tmp.c1.set(Color.WHITE).lerp(Color.SCARLET, Mathf.absin(Time.time(), 10f, 1f))))

View file

@ -133,7 +133,7 @@ public class Floor extends Block{
}
protected boolean doEdge(Floor other){
return (other.id < id || edges == null) && other.edgeOnto(this);
return (other.id > id || edges == null) && other.edgeOnto(this);
}
protected boolean edgeOnto(Floor other){