This commit is contained in:
Anuken 2020-05-10 13:34:52 -04:00
parent dabc891791
commit 2cb9cfb097
17 changed files with 65 additions and 58 deletions

View File

@ -678,6 +678,7 @@ setting.pixelate.name = Pixelate
setting.minimap.name = Show Minimap
setting.position.name = Show Player Position
setting.musicvol.name = Music Volume
setting.atmosphere.name = Show Planet Atmosphere
setting.ambientvol.name = Ambient Volume
setting.mutemusic.name = Mute Music
setting.sfxvol.name = SFX Volume

View File

@ -1,34 +1,16 @@
#ifdef GL_ES
precision mediump float;
precision lowp int;
#define INTEGER lowp int
#else
#define INTEGER int
#endif
//#define GRADIENTS
#define step 0.5
const int MAX_COLORS = 10;
uniform INTEGER u_colornum;
uniform vec4 u_colors[MAX_COLORS];
varying float v_height;
void main() {
#ifdef GRADIENTS
uniform sampler2D u_colors;
int from = int(v_height * float(u_colornum));
int to = int(clamp(float(int(v_height * float(u_colornum) + 1.0)), 0.0, float(u_colornum)-1.0));
float alpha = fract(v_height * float(u_colornum));
alpha = floor(alpha / step) * step;
gl_FragColor = vec4(mix(u_colors[from], u_colors[to], alpha));
#else
gl_FragColor = u_colors[int(v_height * float(u_colornum))];
#endif
void main(){
gl_FragColor = texture2D(u_colors, vec2(v_height, 0.0));
}

View File

@ -1,9 +1,6 @@
#ifdef GL_ES
precision mediump float;
precision lowp int;
#define INTEGER lowp int
#else
#define INTEGER int
#endif
attribute vec4 a_position;
@ -22,8 +19,6 @@ uniform float u_spread;
uniform float u_magnitude;
uniform float u_seed;
uniform INTEGER u_colornum;
varying float v_height;
float rand(vec2 co){

View File

@ -156,6 +156,13 @@ abstract class TileComp implements Posc, Teamc, Healthc, Tilec, Timerc, QuadTree
Call.onTileConfig(null, this, value);
}
/** Deselect this tile from configuration. */
public void deselect(){
if(!headless && control.input.frag.config.getSelectedTile() == this){
control.input.frag.config.hideConfig();
}
}
public void applyBoost(float intensity, float duration){
timeScale = Math.max(timeScale, intensity);
timeScaleDuration = Math.max(timeScaleDuration, duration);

View File

@ -27,7 +27,7 @@ public class LoadRenderer implements Disposable{
private static final String red = "[#" + colorRed + "]";
private static final String orange = "[#" + color + "]";
private static final FloatArray floats = new FloatArray();
private static final boolean preview = true;
private static final boolean preview = false;
private float testprogress = 0f;
private StringBuilder assetText = new StringBuilder();
@ -137,6 +137,7 @@ public class LoadRenderer implements Disposable{
}
}
Draw.flush();
float aspect = 1.94f;
@ -228,10 +229,13 @@ public class LoadRenderer implements Disposable{
}else if(panei == 1){
float height = maxy - miny;
float barpad = s * 8f;
float barspace = (height - barpad) / bars.length;
int barsUsed = Math.min((int)((height - barpad) / (font.getLineHeight() * 1.4f)), bars.length);
float barspace = (height - barpad) / barsUsed;
float barheight = barspace * 0.8f;
for(int i = 0; i < bars.length; i++){
for(int i = 0; i < barsUsed; i++){
Bar bar = bars[i];
if(bar.valid()){
Draw.color(bar.red() ? colorRed : color);

View File

@ -108,8 +108,7 @@ public class Shaders{
public static class SunShader extends LoadShader{
public int octaves = 5;
public float falloff = 0.5f, scale = 1f, power = 1.3f, magnitude = 0.6f, speed = 99999999999f, spread = 1.3f, seed = Mathf.random(9999f);
public float[] colorValues;
public Texture colors;
public SunShader(){
super("sun", "sun");
@ -117,6 +116,10 @@ public class Shaders{
@Override
public void apply(){
colors.bind(1);
Gl.activeTexture(Gl.texture0);
setUniformi("u_colors", 1);
setUniformi("u_octaves", octaves);
setUniformf("u_falloff", falloff);
setUniformf("u_scale", scale);
@ -125,9 +128,6 @@ public class Shaders{
setUniformf("u_time", Time.globalTime() / speed);
setUniformf("u_seed", seed);
setUniformf("u_spread", spread);
setUniformi("u_colornum", colorValues.length / 4);
setUniform4fv("u_colors[0]", colorValues, 0, colorValues.length);
}
}

View File

@ -3,10 +3,11 @@ package mindustry.graphics.g3d;
import arc.graphics.*;
import arc.graphics.gl.*;
import arc.math.geom.*;
import arc.util.*;
import mindustry.type.*;
/** Defines a mesh that is rendered for a planet. Subclasses provide a mesh and a shader. */
public abstract class PlanetMesh{
public abstract class PlanetMesh implements Disposable{
protected final Mesh mesh;
protected final Planet planet;
protected final Shader shader;
@ -28,4 +29,9 @@ public abstract class PlanetMesh{
shader.apply();
mesh.render(shader, Gl.triangles);
}
@Override
public void dispose(){
mesh.dispose();
}
}

View File

@ -2,6 +2,7 @@ package mindustry.graphics.g3d;
import arc.graphics.*;
import arc.math.*;
import arc.util.*;
import mindustry.graphics.*;
import mindustry.graphics.Shaders.*;
import mindustry.type.*;
@ -9,25 +10,19 @@ import mindustry.type.*;
public class SunMesh extends ShaderSphereMesh{
public int octaves = 5;
public float falloff = 0.5f, scale = 1f, power = 1.3f, magnitude = 0.6f, speed = 99999999999f, spread = 1.3f, seed = Mathf.random(9999f);
public float[] colorValues;
public Texture colors;
public SunMesh(Planet planet, int divisions){
super(planet, Shaders.sun, divisions);
}
public void setColors(Color... colors){
setColors(1f, colors);
}
public void setColors(float scl, Color... colors){
colorValues = new float[colors.length*4];
for(int i = 0; i < colors.length; i ++){
colorValues[i*4] = colors[i].r * scl;
colorValues[i*4 + 1] = colors[i].g * scl;
colorValues[i*4 + 2] = colors[i].b * scl;
colorValues[i*4 + 3] = colors[i].a * scl;
Pixmap pix = new Pixmap(colors.length, 1);
for(int i = 0; i < colors.length; i++){
pix.draw(i, 0, Tmp.c1.set(colors[i]).mul(scl));
}
this.colors = new Texture(pix);
pix.dispose();
}
@Override
@ -40,6 +35,12 @@ public class SunMesh extends ShaderSphereMesh{
s.magnitude = magnitude;
s.speed = speed;
s.seed = seed;
s.colorValues = colorValues;
s.colors = colors;
}
@Override
public void dispose(){
super.dispose();
colors.dispose();
}
}

View File

@ -177,13 +177,13 @@ public class PlanetDialog extends FloatingDialog{
projector.proj(cam.combined);
batch.proj(cam.combined);
bloom.capture();
beginBloom();
skybox.render(cam.combined);
renderPlanet(solarSystem);
bloom.render();
endBloom();
Gl.enable(Gl.blend);
@ -217,6 +217,14 @@ public class PlanetDialog extends FloatingDialog{
cam.update();
}
private void beginBloom(){
bloom.capture();
}
private void endBloom(){
bloom.render();
}
private void renderPlanet(Planet planet){
//render planet at offsetted position in the world
planet.mesh.render(cam.combined, planet.getTransform(mat));
@ -227,7 +235,7 @@ public class PlanetDialog extends FloatingDialog{
renderSectors(planet);
}
if(planet.parent != null && planet.hasAtmosphere){
if(planet.parent != null && planet.hasAtmosphere && Core.settings.getBool("atmosphere")){
Blending.additive.apply();
Shaders.atmosphere.camera = cam;

View File

@ -317,6 +317,7 @@ public class SettingsMenuDialog extends SettingsDialog{
}
graphics.checkPref("effects", true);
graphics.checkPref("atmosphere", !mobile);
graphics.checkPref("destroyedblocks", true);
graphics.checkPref("blockstatus", false);
graphics.checkPref("playerchat", true);

View File

@ -140,7 +140,7 @@ public class Sorter extends Block{
@Override
public boolean onConfigureTileTapped(Tilec other){
if(this == other){
control.input.frag.config.hideConfig();
deselect();
configure(null);
return false;
}

View File

@ -125,7 +125,7 @@ public class MessageBlock extends Block{
});
dialog.show();
}
control.input.frag.config.hideConfig();
deselect();
}).size(40f);
}

View File

@ -44,7 +44,7 @@ public class LightBlock extends Block{
public void buildConfiguration(Table table){
table.button(Icon.pencil, () -> {
ui.picker.show(Tmp.c1.set(color).a(0.5f), false, res -> configure(res.rgba()));
control.input.frag.config.hideConfig();
deselect();
}).size(40f);
}

View File

@ -194,7 +194,9 @@ public class PowerNode extends PowerBlock{
tempTileEnts.each(valid, t -> {
graphs.add(t.power().graph);
others.get(t);
if(t.power().graph != tile.entity.power().graph){
others.get(t);
}
});
}

View File

@ -75,7 +75,7 @@ public class ItemSource extends Block{
@Override
public boolean onConfigureTileTapped(Tilec other){
if(this == other){
control.input.frag.config.hideConfig();
deselect();
configure(null);
return false;
}

View File

@ -74,7 +74,7 @@ public class LiquidSource extends Block{
@Override
public boolean onConfigureTileTapped(Tilec other){
if(this == other){
control.input.frag.config.hideConfig();
deselect();
configure(null);
return false;
}

View File

@ -92,7 +92,7 @@ public class Unloader extends Block{
@Override
public boolean onConfigureTileTapped(Tilec other){
if(this == other){
control.input.frag.config.hideConfig();
deselect();
configure(null);
return false;
}