Lighting improvements
BIN
core/assets-raw/sprites/effects/circle-end.png
Normal file
After Width: | Height: | Size: 7.8 KiB |
BIN
core/assets-raw/sprites/effects/circle-mid.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 9.6 KiB After Width: | Height: | Size: 14 KiB |
@ -13,5 +13,6 @@ varying vec2 v_texCoord;
|
||||
|
||||
void main(){
|
||||
vec4 color = texture2D(u_texture, v_texCoord.xy);
|
||||
//color.a = clamp(color.a, 0.0, 0.8);
|
||||
gl_FragColor = clamp(vec4(mix(u_ambient.rgb, color.rgb, color.a), u_ambient.a - color.a), 0.0, 1.0);
|
||||
}
|
||||
|
Before Width: | Height: | Size: 736 B After Width: | Height: | Size: 738 B |
Before Width: | Height: | Size: 718 KiB After Width: | Height: | Size: 735 KiB |
@ -48,7 +48,7 @@ public class Blocks implements ContentList{
|
||||
melter, separator, sporePress, pulverizer, incinerator, coalCentrifuge,
|
||||
|
||||
//sandbox
|
||||
powerVoid, powerSource, itemSource, liquidSource, itemVoid, message,
|
||||
powerVoid, powerSource, itemSource, liquidSource, itemVoid, message, light,
|
||||
|
||||
//defense
|
||||
scrapWall, scrapWallLarge, scrapWallHuge, scrapWallGigantic, thruster, //ok, these names are getting ridiculous, but at least I don't have humongous walls yet
|
||||
@ -736,6 +736,10 @@ public class Blocks implements ContentList{
|
||||
message = new MessageBlock("message"){{
|
||||
requirements(Category.effect, ItemStack.with(Items.graphite, 5));
|
||||
}};
|
||||
light = new LightBlock("light"){{
|
||||
requirements(Category.effect, ItemStack.with(Items.graphite, 5));
|
||||
consumes.power(0.05f);
|
||||
}};
|
||||
|
||||
//endregion
|
||||
//region defense
|
||||
|
@ -13,7 +13,7 @@ import io.anuke.mindustry.graphics.*;
|
||||
import io.anuke.mindustry.type.*;
|
||||
import io.anuke.mindustry.ui.Cicon;
|
||||
|
||||
import static io.anuke.mindustry.Vars.tilesize;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class Fx implements ContentList{
|
||||
public static Effect
|
||||
@ -456,6 +456,8 @@ public class Fx implements ContentList{
|
||||
});
|
||||
|
||||
Draw.color();
|
||||
|
||||
renderer.lights.add(e.x, e.y, 20f * e.fslope(), Pal.lightFlame, 0.5f);
|
||||
});
|
||||
|
||||
fireSmoke = new Effect(35f, e -> {
|
||||
|
@ -257,6 +257,7 @@ public class Renderer implements ApplicationListener{
|
||||
drawFlyerShadows();
|
||||
|
||||
blocks.drawBlocks(Layer.power);
|
||||
blocks.drawBlocks(Layer.lights);
|
||||
|
||||
drawAllTeams(true);
|
||||
|
||||
|
@ -19,7 +19,6 @@ import io.anuke.mindustry.entities.*;
|
||||
import io.anuke.mindustry.entities.traits.*;
|
||||
import io.anuke.mindustry.game.*;
|
||||
import io.anuke.mindustry.gen.*;
|
||||
import io.anuke.mindustry.graphics.*;
|
||||
import io.anuke.mindustry.input.*;
|
||||
import io.anuke.mindustry.io.*;
|
||||
import io.anuke.mindustry.net.Administration.*;
|
||||
@ -343,8 +342,6 @@ public class Player extends Unit implements BuilderMinerTrait, ShooterTrait{
|
||||
}
|
||||
|
||||
Draw.reset();
|
||||
|
||||
renderer.lights.add(x, y, 100f, Pal.powerLight, 0.6f);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -353,6 +350,7 @@ public class Player extends Unit implements BuilderMinerTrait, ShooterTrait{
|
||||
Draw.rect(getPowerCellRegion(), x + Angles.trnsx(rotation, mech.cellTrnsY, 0f), y + Angles.trnsy(rotation, mech.cellTrnsY, 0f), rotation - 90);
|
||||
Draw.reset();
|
||||
drawBackItems(itemtime, isLocal);
|
||||
drawLight();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -399,6 +399,12 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
|
||||
Draw.color();
|
||||
|
||||
drawBackItems(item.amount > 0 ? 1f : 0f, false);
|
||||
|
||||
drawLight();
|
||||
}
|
||||
|
||||
public void drawLight(){
|
||||
renderer.lights.add(x, y, 50f, Pal.powerLight, 0.6f);
|
||||
}
|
||||
|
||||
public void drawBackItems(float itemtime, boolean number){
|
||||
|
@ -9,10 +9,9 @@ import io.anuke.arc.graphics.glutils.*;
|
||||
import io.anuke.arc.math.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.content.*;
|
||||
import io.anuke.mindustry.game.*;
|
||||
import io.anuke.mindustry.game.EventType.*;
|
||||
import io.anuke.mindustry.game.Teams.*;
|
||||
import io.anuke.mindustry.ui.Cicon;
|
||||
import io.anuke.mindustry.ui.*;
|
||||
import io.anuke.mindustry.world.*;
|
||||
|
||||
import static io.anuke.arc.Core.camera;
|
||||
@ -219,6 +218,9 @@ public class BlockRenderer implements Disposable{
|
||||
addRequest(tile, Layer.block);
|
||||
}
|
||||
|
||||
//TODO don't add at daytime / disabled lights
|
||||
addRequest(tile, Layer.lights);
|
||||
|
||||
if(block.expanded || !expanded){
|
||||
|
||||
if(block.layer != null){
|
||||
@ -274,6 +276,9 @@ public class BlockRenderer implements Disposable{
|
||||
if(block.synthetic() && request.tile.getTeam() != player.getTeam()){
|
||||
block.drawTeam(request.tile);
|
||||
}
|
||||
|
||||
}else if(request.layer == Layer.lights){
|
||||
block.drawLight(request.tile);
|
||||
}else if(request.layer == block.layer){
|
||||
block.drawLayer(request.tile);
|
||||
}else if(request.layer == block.layer2){
|
||||
@ -282,39 +287,6 @@ public class BlockRenderer implements Disposable{
|
||||
}
|
||||
}
|
||||
|
||||
public void drawTeamBlocks(Layer layer, Team team){
|
||||
int index = this.iterateidx;
|
||||
|
||||
for(; index < requestidx; index++){
|
||||
|
||||
if(index < requests.size && requests.get(index).layer.ordinal() > layer.ordinal()){
|
||||
break;
|
||||
}
|
||||
|
||||
BlockRequest req = requests.get(index);
|
||||
if(req.tile.getTeam() != team) continue;
|
||||
|
||||
Block block = req.tile.block();
|
||||
|
||||
if(req.layer == Layer.block){
|
||||
block.draw(req.tile);
|
||||
}else if(req.layer == block.layer){
|
||||
block.drawLayer(req.tile);
|
||||
}else if(req.layer == block.layer2){
|
||||
block.drawLayer2(req.tile);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void skipLayer(Layer stopAt){
|
||||
for(; iterateidx < requestidx; iterateidx++){
|
||||
if(iterateidx < requests.size && requests.get(iterateidx).layer.ordinal() > stopAt.ordinal()){
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addRequest(Tile tile, Layer layer){
|
||||
if(requestidx >= requests.size){
|
||||
requests.add(new BlockRequest());
|
||||
|
@ -6,6 +6,8 @@ import io.anuke.arc.graphics.g2d.*;
|
||||
import io.anuke.arc.math.*;
|
||||
import io.anuke.arc.util.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.renderer;
|
||||
|
||||
public class Drawf{
|
||||
|
||||
public static void dashCircle(float x, float y, float rad, Color color){
|
||||
@ -40,15 +42,6 @@ public class Drawf{
|
||||
square(x, y, radius, Pal.accent);
|
||||
}
|
||||
|
||||
/*
|
||||
public static void square(float x, float y, float radius){
|
||||
Lines.stroke(1f, Pal.gray);
|
||||
Lines.square(x, y - 1f, radius + 1f, 45);
|
||||
Lines.stroke(1f, Pal.accent);
|
||||
Lines.square(x, y, radius + 1f, 45);
|
||||
Draw.reset();
|
||||
}*/
|
||||
|
||||
public static void arrow(float x, float y, float x2, float y2, float length, float radius){
|
||||
float angle = Angles.angle(x, y, x2, y2);
|
||||
float space = 2f;
|
||||
@ -81,6 +74,8 @@ public class Drawf{
|
||||
Lines.line(line, x + Tmp.v1.x, y + Tmp.v1.y, x2 - Tmp.v1.x, y2 - Tmp.v1.y, CapStyle.none, 0f);
|
||||
Lines.precise(false);
|
||||
Lines.stroke(1f);
|
||||
|
||||
renderer.lights.line(x, y, x2, y2);
|
||||
}
|
||||
|
||||
public static void tri(float x, float y, float width, float length, float rotation){
|
||||
|
@ -10,5 +10,7 @@ public enum Layer{
|
||||
/** "High" blocks, like turrets. */
|
||||
turret,
|
||||
/** Power lasers. */
|
||||
power
|
||||
power,
|
||||
/** Extra layer that's always on top.*/
|
||||
lights
|
||||
}
|
||||
|
@ -5,9 +5,13 @@ import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.graphics.*;
|
||||
import io.anuke.arc.graphics.g2d.*;
|
||||
import io.anuke.arc.graphics.glutils.*;
|
||||
import io.anuke.arc.math.*;
|
||||
import io.anuke.arc.math.geom.*;
|
||||
import io.anuke.arc.util.*;
|
||||
|
||||
public class LightRenderer{
|
||||
private static final int scaling = 4;
|
||||
private float[] vertices = new float[24];
|
||||
private FrameBuffer buffer = new FrameBuffer(2, 2);
|
||||
private Array<Runnable> lights = new Array<>();
|
||||
|
||||
@ -22,6 +26,134 @@ public class LightRenderer{
|
||||
});
|
||||
}
|
||||
|
||||
public void add(float x, float y, TextureRegion region, Color color, float opacity){
|
||||
add(() -> {
|
||||
Draw.color(color, opacity);
|
||||
Draw.rect(region, x, y);
|
||||
});
|
||||
}
|
||||
|
||||
public void line(float x, float y, float x2, float y2){
|
||||
add(() -> {
|
||||
Draw.color(Color.orange, 0.5f);
|
||||
|
||||
float stroke = 10f;
|
||||
float rot = Mathf.angleExact(x2 - x, y2 - y);
|
||||
TextureRegion ledge = Core.atlas.find("circle-end"), lmid = Core.atlas.find("circle-mid");
|
||||
|
||||
float color = Draw.getColor().toFloatBits();
|
||||
float u = lmid.getU();
|
||||
float v = lmid.getV2();
|
||||
float u2 = lmid.getU2();
|
||||
float v2 = lmid.getV();
|
||||
|
||||
|
||||
Vector2 v1 = Tmp.v1.trnsExact(rot + 90f, stroke);
|
||||
float lx1 = x - v1.x, ly1 = y - v1.y,
|
||||
lx2 = x + v1.x, ly2 = y + v1.y,
|
||||
lx3 = x2 + v1.x, ly3 = y2 + v1.y,
|
||||
lx4 = x2 - v1.x, ly4 = y2 - v1.y;
|
||||
|
||||
vertices[0] = lx1;
|
||||
vertices[1] = ly1;
|
||||
vertices[2] = color;
|
||||
vertices[3] = u;
|
||||
vertices[4] = v;
|
||||
vertices[5] = 0;
|
||||
|
||||
vertices[6] = lx2;
|
||||
vertices[7] = ly2;
|
||||
vertices[8] = color;
|
||||
vertices[9] = u;
|
||||
vertices[10] = v2;
|
||||
vertices[11] = 0;
|
||||
|
||||
vertices[12] = lx3;
|
||||
vertices[13] = ly3;
|
||||
vertices[14] = color;
|
||||
vertices[15] = u2;
|
||||
vertices[16] = v2;
|
||||
vertices[17] = 0;
|
||||
|
||||
vertices[18] = lx4;
|
||||
vertices[19] = ly4;
|
||||
vertices[20] = color;
|
||||
vertices[21] = u2;
|
||||
vertices[22] = v;
|
||||
vertices[23] = 0;
|
||||
|
||||
Draw.vert(ledge.getTexture(), vertices, 0, vertices.length);
|
||||
|
||||
|
||||
Vector2 v3 = Tmp.v2.trnsExact(rot, stroke);
|
||||
|
||||
u = ledge.getU();
|
||||
v = ledge.getV2();
|
||||
u2 = ledge.getU2();
|
||||
v2 = ledge.getV();
|
||||
|
||||
vertices[0] = lx4;
|
||||
vertices[1] = ly4;
|
||||
vertices[2] = color;
|
||||
vertices[3] = u;
|
||||
vertices[4] = v;
|
||||
vertices[5] = 0;
|
||||
|
||||
vertices[6] = lx3;
|
||||
vertices[7] = ly3;
|
||||
vertices[8] = color;
|
||||
vertices[9] = u;
|
||||
vertices[10] = v2;
|
||||
vertices[11] = 0;
|
||||
|
||||
vertices[12] = lx3 + v3.x;
|
||||
vertices[13] = ly3 + v3.y;
|
||||
vertices[14] = color;
|
||||
vertices[15] = u2;
|
||||
vertices[16] = v2;
|
||||
vertices[17] = 0;
|
||||
|
||||
vertices[18] = lx4 + v3.x;
|
||||
vertices[19] = ly4 + v3.y;
|
||||
vertices[20] = color;
|
||||
vertices[21] = u2;
|
||||
vertices[22] = v;
|
||||
vertices[23] = 0;
|
||||
|
||||
Draw.vert(ledge.getTexture(), vertices, 0, vertices.length);
|
||||
|
||||
vertices[0] = lx2;
|
||||
vertices[1] = ly2;
|
||||
vertices[2] = color;
|
||||
vertices[3] = u;
|
||||
vertices[4] = v;
|
||||
vertices[5] = 0;
|
||||
|
||||
vertices[6] = lx1;
|
||||
vertices[7] = ly1;
|
||||
vertices[8] = color;
|
||||
vertices[9] = u;
|
||||
vertices[10] = v2;
|
||||
vertices[11] = 0;
|
||||
|
||||
vertices[12] = lx1 - v3.x;
|
||||
vertices[13] = ly1 - v3.y;
|
||||
vertices[14] = color;
|
||||
vertices[15] = u2;
|
||||
vertices[16] = v2;
|
||||
vertices[17] = 0;
|
||||
|
||||
vertices[18] = lx2 - v3.x;
|
||||
vertices[19] = ly2 - v3.y;
|
||||
vertices[20] = color;
|
||||
vertices[21] = u2;
|
||||
vertices[22] = v;
|
||||
vertices[23] = 0;
|
||||
|
||||
Draw.vert(ledge.getTexture(), vertices, 0, vertices.length);
|
||||
});
|
||||
}
|
||||
|
||||
public void draw(){
|
||||
if(buffer.getWidth() != Core.graphics.getWidth()/scaling || buffer.getHeight() != Core.graphics.getHeight()/scaling){
|
||||
buffer.resize(Core.graphics.getWidth()/scaling, Core.graphics.getHeight()/scaling);
|
||||
@ -29,7 +161,7 @@ public class LightRenderer{
|
||||
|
||||
Draw.color();
|
||||
buffer.beginDraw(Color.clear);
|
||||
Draw.blend(Blending.additive);
|
||||
Draw.blend(Blending.normal);
|
||||
for(Runnable run : lights){
|
||||
run.run();
|
||||
}
|
||||
|
@ -295,6 +295,10 @@ public class Block extends BlockStorage{
|
||||
Draw.rect(region, tile.drawx(), tile.drawy(), rotate ? tile.rotation() * 90 : 0);
|
||||
}
|
||||
|
||||
public void drawLight(Tile tile){
|
||||
|
||||
}
|
||||
|
||||
public void drawTeam(Tile tile){
|
||||
Draw.color(tile.getTeam().color);
|
||||
Draw.rect("block-border", tile.drawx() - size * tilesize / 2f + 4, tile.drawy() - size * tilesize / 2f + 4);
|
||||
|
@ -117,7 +117,7 @@ public abstract class BlockStorage extends UnlockableContent{
|
||||
|
||||
other = other.block().getLiquidDestination(other, tile);
|
||||
|
||||
if(other.getTeam() == tile.getTeam() && other.block().hasLiquids && canDumpLiquid(tile, other, liquid) && other.entity.liquids != null){
|
||||
if(other != null && other.getTeam() == tile.getTeam() && other.block().hasLiquids && canDumpLiquid(tile, other, liquid) && other.entity.liquids != null){
|
||||
float ofract = other.entity.liquids.get(liquid) / other.block().liquidCapacity;
|
||||
float fract = tile.entity.liquids.get(liquid) / liquidCapacity;
|
||||
|
||||
|
@ -132,6 +132,11 @@ public class MendProjector extends Block{
|
||||
Draw.reset();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawLight(Tile tile){
|
||||
renderer.lights.add(tile.drawx(), tile.drawy(), 50f * tile.entity.power.satisfaction, color, 0.7f * tile.entity.power.satisfaction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity newEntity(){
|
||||
return new MendEntity();
|
||||
|
@ -66,6 +66,11 @@ public class OverdriveProjector extends Block{
|
||||
stats.add(BlockStat.boostEffect, (int)((speedBoost + speedBoostPhase) * 100f), StatUnit.percent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawLight(Tile tile){
|
||||
renderer.lights.add(tile.drawx(), tile.drawy(), 50f * tile.entity.power.satisfaction, color, 0.7f * tile.entity.power.satisfaction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Tile tile){
|
||||
OverdriveEntity entity = tile.entity();
|
||||
|
@ -172,6 +172,11 @@ public class ItemLiquidGenerator extends PowerGenerator{
|
||||
Draw.rect(liquidRegion, tile.drawx(), tile.drawy());
|
||||
Draw.color();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawLight(Tile tile){
|
||||
ItemLiquidGeneratorEntity entity = tile.entity();
|
||||
|
||||
renderer.lights.add(tile.drawx(), tile.drawy(), (60f + Mathf.absin(10f, 5f)) * entity.productionEfficiency * size, Color.orange, 0.5f);
|
||||
}
|
||||
|
@ -0,0 +1,22 @@
|
||||
package io.anuke.mindustry.world.blocks.power;
|
||||
|
||||
import io.anuke.arc.graphics.*;
|
||||
import io.anuke.mindustry.world.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.renderer;
|
||||
|
||||
public class LightBlock extends Block{
|
||||
protected Color color = Color.royal;
|
||||
protected float radius = 200f;
|
||||
|
||||
public LightBlock(String name){
|
||||
super(name);
|
||||
hasPower = true;
|
||||
update = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawLight(Tile tile){
|
||||
renderer.lights.add(tile.drawx(), tile.drawy(), radius, color, 0.5f * tile.entity.power.satisfaction);
|
||||
}
|
||||
}
|
@ -1,11 +1,11 @@
|
||||
package io.anuke.mindustry.world.blocks.production;
|
||||
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.graphics.*;
|
||||
import io.anuke.arc.graphics.g2d.*;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.util.Time;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.arc.math.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.world.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.renderer;
|
||||
|
||||
@ -45,8 +45,13 @@ public class GenericSmelter extends GenericCrafter{
|
||||
Fill.circle(tile.drawx(), tile.drawy(), 1.9f + Mathf.absin(Time.time(), 5f, 1f) + cr);
|
||||
|
||||
Draw.color();
|
||||
|
||||
renderer.lights.add(tile.drawx(), tile.drawy(), (60f + Mathf.absin(10f, 5f)) * entity.warmup * size, flameColor, 0.65f);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawLight(Tile tile){
|
||||
GenericCrafterEntity entity = tile.entity();
|
||||
|
||||
renderer.lights.add(tile.drawx(), tile.drawy(), (60f + Mathf.absin(10f, 5f)) * entity.warmup * size, flameColor, 0.65f);
|
||||
}
|
||||
}
|
||||
|
@ -63,6 +63,11 @@ public class CoreBlock extends StorageBlock{
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawLight(Tile tile){
|
||||
renderer.lights.add(tile.drawx(), tile.drawy(), 30f * size, Pal.accent, 0.5f + Mathf.absin(20f, 0.1f));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Item item, Tile tile, Tile source){
|
||||
return tile.entity.items.get(item) < getMaximumAccepted(tile, item);
|
||||
|