Visual tweaks

This commit is contained in:
Anuken
2020-02-21 22:58:18 -05:00
parent a5e469e96c
commit 6871db7155
5 changed files with 57 additions and 8 deletions

View File

@@ -6,12 +6,12 @@ varying vec4 v_col;
const vec3 ambientColor = vec3(1.0); const vec3 ambientColor = vec3(1.0);
const vec3 ambientDir = normalize(vec3(1.0, 1.0, 1.0)); const vec3 ambientDir = normalize(vec3(1.0, 1.0, 1.0));
const vec3 diffuse = vec3(0); const vec3 diffuse = vec3(0.3);
const vec3 v1 = vec3(1.0, 0.0, 1.0); const vec3 v1 = vec3(1.0, 0.0, 1.0);
const vec3 v2 = vec3(1.0, 0.5, 0.0); const vec3 v2 = vec3(1.0, 0.5, 0.0);
void main(){ void main(){
vec3 norc = ambientColor * lerp(vec3(1.0), diffuse, 1.0 - clamp((dot(a_normal, ambientDir) + 1.0) / 2.0, 0.0, 1.0)); vec3 norc = ambientColor * (diffuse + vec3(clamp((dot(a_normal, ambientDir) + 1.0) / 2.0, 0.0, 1.0)));
v_col = a_color * vec4(norc, 1.0); v_col = a_color * vec4(norc, 1.0);
gl_Position = u_projModelView * a_position; gl_Position = u_projModelView * a_position;

View File

@@ -17,7 +17,7 @@ import mindustry.world.*;
import static mindustry.Vars.*; import static mindustry.Vars.*;
public class PlanetRenderer implements PlanetGenerator{ public class PlanetRenderer implements PlanetGenerator{
private static final Color outlineColor = Pal.accent.cpy().a(0.7f); private static final Color outlineColor = Pal.accent.cpy().a(0.6f);
private static final float camLength = 4f, outlineRad = 1.15f; private static final float camLength = 4f, outlineRad = 1.15f;
private static final boolean drawRect = false; private static final boolean drawRect = false;
@@ -105,15 +105,16 @@ public class PlanetRenderer implements PlanetGenerator{
if(Core.input.keyDown(KeyCode.MOUSE_LEFT)){ if(Core.input.keyDown(KeyCode.MOUSE_LEFT)){
float upV = cam.position.angle(Vec3.Y); float upV = cam.position.angle(Vec3.Y);
float xscale = 9f, yscale = 10f;
float margin = 1; float margin = 1;
//scale X speed depending on polar coordinate //scale X speed depending on polar coordinate
float speed = 1f - Math.abs(upV - 90) / 90f; float speed = 1f - Math.abs(upV - 90) / 90f;
cam.position.rotate(cam.up, (v.x - lastX) / 10 * speed); cam.position.rotate(cam.up, (v.x - lastX) / xscale * speed);
//prevent user from scrolling all the way up and glitching it out //prevent user from scrolling all the way up and glitching it out
float amount = (v.y - lastY) / 10; float amount = (v.y - lastY) / yscale;
amount = Mathf.clamp(upV + amount, margin, 180f - margin) - upV; amount = Mathf.clamp(upV + amount, margin, 180f - margin) - upV;
cam.position.rotate(Tmp.v31.set(cam.up).rotate(cam.direction, 90), amount); cam.position.rotate(Tmp.v31.set(cam.up).rotate(cam.direction, 90), amount);

View File

@@ -12,10 +12,11 @@ import mindustry.world.*;
import java.util.*; import java.util.*;
import static mindustry.Vars.world; import static mindustry.Vars.*;
public abstract class BasicGenerator implements WorldGenerator{ public abstract class BasicGenerator implements WorldGenerator{
protected static final DistanceHeuristic manhattan = (x1, y1, x2, y2) -> Math.abs(x1 - x2) + Math.abs(y1 - y2); protected static final DistanceHeuristic manhattan = (x1, y1, x2, y2) -> Math.abs(x1 - x2) + Math.abs(y1 - y2);
protected static final ShortArray ints1 = new ShortArray(), ints2 = new ShortArray();
protected Simplex sim = new Simplex(); protected Simplex sim = new Simplex();
protected Simplex sim2 = new Simplex(); protected Simplex sim2 = new Simplex();
@@ -44,8 +45,38 @@ public abstract class BasicGenerator implements WorldGenerator{
} }
public void median(int radius){
median(radius, 0.5);
}
public void median(int radius, double percentile){
short[] blocks = new short[tiles.width * tiles.height];
short[] floors = new short[blocks.length];
tiles.each((x, y) -> {
ints1.clear();
ints2.clear();
Geometry.circle(x, y, width, height, radius, (cx, cy) -> {
ints1.add(tiles.getn(cx, cy).floorID());
ints2.add(tiles.getn(cx, cy).blockID());
});
ints1.sort();
ints2.sort();
floors[x + y*width] = ints1.get(Mathf.clamp((int)(ints1.size * percentile), 0, ints1.size - 1));
blocks[x + y*width] = ints2.get(Mathf.clamp((int)(ints2.size * percentile), 0, ints2.size - 1));
});
pass((x, y) -> {
block = content.block(blocks[x + y * width]);
floor = content.block(floors[x + y * width]);
});
}
public void ores(Array<Block> ores){ public void ores(Array<Block> ores){
pass((x, y) -> { pass((x, y) -> {
if(floor.asFloor().isLiquid) return;
int offsetX = x - 4, offsetY = y + 23; int offsetX = x - 4, offsetY = y + 23;
for(int i = ores.size - 1; i >= 0; i--){ for(int i = ores.size - 1; i >= 0; i--){
Block entry = ores.get(i); Block entry = ores.get(i);
@@ -234,6 +265,19 @@ public abstract class BasicGenerator implements WorldGenerator{
return out; return out;
} }
public void trimDark(){
for(Tile tile : tiles){
boolean any = world.getDarkness(tile.x, tile.y) > 0;
for(int i = 0; i < 4 && !any; i++){
any = world.getDarkness(tile.x + Geometry.d4[i].x, tile.y + Geometry.d4[i].y) > 0;
}
if(any){
tile.setBlock(tile.floor().wall);
}
}
}
public void inverseFloodFill(Tile start){ public void inverseFloodFill(Tile start){
IntArray arr = new IntArray(); IntArray arr = new IntArray();
arr.add(start.pos()); arr.add(start.pos());
@@ -254,7 +298,7 @@ public abstract class BasicGenerator implements WorldGenerator{
} }
for(Tile tile : tiles){ for(Tile tile : tiles){
if((tile.cost != 2 && tile.block() == Blocks.air) || world.getDarkness(tile.x, tile.y) != 0){ if(tile.cost != 2 && tile.block() == Blocks.air){
tile.setBlock(tile.floor().wall); tile.setBlock(tile.floor().wall);
} }
} }

View File

@@ -149,6 +149,10 @@ public class TestPlanetGenerator implements PlanetGenerator{
} }
} }
trimDark();
median(2);
schematics.placeLoadout(Loadouts.advancedShard, spawn.x, spawn.y); schematics.placeLoadout(Loadouts.advancedShard, spawn.x, spawn.y);
} }

View File

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