mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-01-23 21:12:52 -08:00
Player base emissive lights on Serpulo (WIP)
This commit is contained in:
parent
43fb2e7cdc
commit
8f0ca13ace
6 changed files with 46 additions and 16 deletions
|
|
@ -23,7 +23,6 @@ void main(){
|
|||
vec3 vertexEye = normalize(u_campos - (u_trans * a_position).xyz);
|
||||
|
||||
float albedo = 1.0 - a_color.a;
|
||||
float emissive = a_emissive.a * u_emissive;
|
||||
|
||||
float specularFactor = dot(vertexEye, lightReflect);
|
||||
if(specularFactor > 0.0){
|
||||
|
|
@ -32,6 +31,8 @@ void main(){
|
|||
|
||||
vec3 norc = (u_ambientColor + specular) * (diffuse + vec3(clamp((dot(a_normal, u_lightdir) + 1.0) / 2.0, 0.0, 1.0)));
|
||||
|
||||
v_col = vec4(mix(a_color.rgb, a_emissive.rgb, vec3(1.0 - norc)), 1.0) * vec4(mix(norc, vec3(1.0), emissive), 1.0);
|
||||
float emissive = a_emissive.a * u_emissive * min(pow(max(0.0, (1.0 - norc.r) * 1.2), 3.0), 1.1);
|
||||
|
||||
v_col = vec4(mix(a_color.rgb, a_emissive.rgb, emissive), 1.0) * vec4(mix(norc, vec3(1.0), emissive), 1.0);
|
||||
gl_Position = u_proj * u_trans * a_position;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -156,6 +156,16 @@ public class Logic implements ApplicationListener{
|
|||
if(!net.client() && e.sector == state.getSector() && e.sector.isBeingPlayed()){
|
||||
state.rules.waveTeam.data().destroyToDerelict();
|
||||
}
|
||||
|
||||
if(!net.client() && e.sector.planet.generator != null){
|
||||
e.sector.planet.generator.onSectorCaptured(e.sector);
|
||||
}
|
||||
});
|
||||
|
||||
Events.on(SectorLoseEvent.class, e -> {
|
||||
if(!net.client() && e.sector.planet.generator != null){
|
||||
e.sector.planet.generator.onSectorLost(e.sector);
|
||||
}
|
||||
});
|
||||
|
||||
Events.on(BlockDestroyEvent.class, e -> {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import arc.*;
|
|||
import arc.graphics.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import mindustry.graphics.g3d.PlanetGrid.*;
|
||||
import mindustry.maps.generators.*;
|
||||
|
||||
|
|
@ -98,6 +97,7 @@ public class MeshBuilder{
|
|||
}, divisions, radius, 0);
|
||||
}
|
||||
|
||||
//TODO: make this thread safe
|
||||
public static Mesh buildHex(HexMesher mesher, int divisions, float radius, float intensity){
|
||||
PlanetGrid grid = PlanetGrid.create(divisions);
|
||||
|
||||
|
|
@ -201,8 +201,6 @@ public class MeshBuilder{
|
|||
}
|
||||
}
|
||||
|
||||
static int totalBytes;
|
||||
|
||||
private static Mesh end(){
|
||||
Mesh last = mesh;
|
||||
last.getVerticesBuffer().limit(last.getVerticesBuffer().position());
|
||||
|
|
@ -211,11 +209,6 @@ public class MeshBuilder{
|
|||
}
|
||||
mesh = null;
|
||||
|
||||
totalBytes += last.getVerticesBuffer().capacity() * 4;
|
||||
totalBytes += last.getIndicesBuffer().capacity() * 2;
|
||||
|
||||
Log.info("total memory used: @ mb", totalBytes / 1000f / 1000f);
|
||||
|
||||
return last;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,11 +25,18 @@ public abstract class PlanetGenerator extends BasicGenerator implements HexMeshe
|
|||
|
||||
protected @Nullable Sector sector;
|
||||
|
||||
/** Should generate sector bases for a planet. */
|
||||
public void generateSector(Sector sector){
|
||||
|
||||
}
|
||||
|
||||
public void onSectorCaptured(Sector sector){
|
||||
|
||||
}
|
||||
|
||||
public void onSectorLost(Sector sector){
|
||||
|
||||
}
|
||||
|
||||
public void getLockedText(Sector hovered, StringBuilder out){
|
||||
out.append("[gray]").append(Iconc.lock).append(" ").append(Core.bundle.get("locked"));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,6 +64,16 @@ public class SerpuloPlanetGenerator extends PlanetGenerator{
|
|||
return (Mathf.pow(Simplex.noise3d(seed, 7, 0.5f, 1f/3f, position.x * scl, position.y * scl, position.z * scl), 2.3f) + waterOffset) / (1f + waterOffset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSectorCaptured(Sector sector){
|
||||
sector.planet.requiresMeshReload = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSectorLost(Sector sector){
|
||||
sector.planet.requiresMeshReload = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowLanding(Sector sector){
|
||||
return sector.planet.allowLaunchToNumbered && (sector.hasBase() || sector.near().contains(s -> s.hasBase() &&
|
||||
|
|
@ -104,17 +114,26 @@ public class SerpuloPlanetGenerator extends PlanetGenerator{
|
|||
|
||||
@Override
|
||||
public Color getEmissiveColor(Vec3 position){
|
||||
float dst = 999f;
|
||||
float dst = 999f, captureDst = 999f;
|
||||
for(Sector sector : Planets.serpulo.sectors){
|
||||
if(sector.hasEnemyBase() && !sector.isCaptured()){
|
||||
dst = Math.min(dst, position.dst(sector.tile.v));
|
||||
dst = Math.min(dst, position.dst(sector.tile.v) - (sector.preset != null ? sector.preset.difficulty/10f * 0.03f - 0.03f : 0f));
|
||||
}else if(sector.hasBase()){
|
||||
captureDst = Math.min(captureDst, position.dst(sector.tile.v));
|
||||
}
|
||||
}
|
||||
|
||||
float freq = 0.05f;
|
||||
if(position.dst(basePos) < 0.55f && dst*metalDstScl + Simplex.noise3d(seed, 3, 0.4, 5.5f, position.x, position.y + 200f, position.z)*0.08f + ((basePos.dst(position) + 0.00f) % freq < freq/2f ? 1f : 0f) * 0.07f < 0.08f){
|
||||
if(position.dst(basePos) < 0.55f ?
|
||||
|
||||
dst*metalDstScl + Simplex.noise3d(seed, 3, 0.4, 5.5f, position.x, position.y + 200f, position.z)*0.08f + ((basePos.dst(position) + 0.00f) % freq < freq/2f ? 1f : 0f) * 0.07f < 0.08f :
|
||||
dst*metalDstScl + Simplex.noise3d(seed, 3, 0.4, 6f, position.x, position.y + 370f, position.z)*0.06f < 0.045){
|
||||
|
||||
return Tmp.c1.set(Team.crux.color).mul(0.8f + Simplex.noise3d(seed, 1, 1, 9f, position.x, position.y + 99f, position.z) * 0.4f)
|
||||
.lerp(Team.sharded.color, 0.2f*Simplex.noise3d(seed, 1, 1, 9f, position.x, position.y + 999f, position.z));
|
||||
}else if(captureDst*metalDstScl + Simplex.noise3d(seed, 3, 0.4, 6f, position.x, position.y + 600f, position.z)*0.07f < 0.05){
|
||||
return Tmp.c1.set(Team.sharded.color).mul(0.7f + Simplex.noise3d(seed, 1, 1, 9f, position.x, position.y + 99f, position.z) * 0.4f)
|
||||
.lerp(Team.crux.color, 0.3f*Simplex.noise3d(seed, 1, 1, 9f, position.x, position.y + 999f, position.z));
|
||||
}
|
||||
|
||||
return Color.clear;
|
||||
|
|
|
|||
|
|
@ -659,8 +659,8 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
|||
|
||||
if(debugSectorAttackEdit){
|
||||
int timeShift = input.keyDown(KeyCode.rightBracket) ? 1 : input.keyDown(KeyCode.leftBracket) ? -1 : 0;
|
||||
if(timeShift != -1){
|
||||
universe.setSeconds(universe.secondsf() + timeShift * Time.delta * 2f);
|
||||
if(timeShift != 0){
|
||||
universe.setSeconds(universe.secondsf() + timeShift * Time.delta * 2.5f);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue