Player base emissive lights on Serpulo (WIP)
This commit is contained in:
@@ -23,7 +23,6 @@ void main(){
|
|||||||
vec3 vertexEye = normalize(u_campos - (u_trans * a_position).xyz);
|
vec3 vertexEye = normalize(u_campos - (u_trans * a_position).xyz);
|
||||||
|
|
||||||
float albedo = 1.0 - a_color.a;
|
float albedo = 1.0 - a_color.a;
|
||||||
float emissive = a_emissive.a * u_emissive;
|
|
||||||
|
|
||||||
float specularFactor = dot(vertexEye, lightReflect);
|
float specularFactor = dot(vertexEye, lightReflect);
|
||||||
if(specularFactor > 0.0){
|
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)));
|
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;
|
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()){
|
if(!net.client() && e.sector == state.getSector() && e.sector.isBeingPlayed()){
|
||||||
state.rules.waveTeam.data().destroyToDerelict();
|
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 -> {
|
Events.on(BlockDestroyEvent.class, e -> {
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import arc.*;
|
|||||||
import arc.graphics.*;
|
import arc.graphics.*;
|
||||||
import arc.math.geom.*;
|
import arc.math.geom.*;
|
||||||
import arc.struct.*;
|
import arc.struct.*;
|
||||||
import arc.util.*;
|
|
||||||
import mindustry.graphics.g3d.PlanetGrid.*;
|
import mindustry.graphics.g3d.PlanetGrid.*;
|
||||||
import mindustry.maps.generators.*;
|
import mindustry.maps.generators.*;
|
||||||
|
|
||||||
@@ -98,6 +97,7 @@ public class MeshBuilder{
|
|||||||
}, divisions, radius, 0);
|
}, divisions, radius, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO: make this thread safe
|
||||||
public static Mesh buildHex(HexMesher mesher, int divisions, float radius, float intensity){
|
public static Mesh buildHex(HexMesher mesher, int divisions, float radius, float intensity){
|
||||||
PlanetGrid grid = PlanetGrid.create(divisions);
|
PlanetGrid grid = PlanetGrid.create(divisions);
|
||||||
|
|
||||||
@@ -201,8 +201,6 @@ public class MeshBuilder{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int totalBytes;
|
|
||||||
|
|
||||||
private static Mesh end(){
|
private static Mesh end(){
|
||||||
Mesh last = mesh;
|
Mesh last = mesh;
|
||||||
last.getVerticesBuffer().limit(last.getVerticesBuffer().position());
|
last.getVerticesBuffer().limit(last.getVerticesBuffer().position());
|
||||||
@@ -211,11 +209,6 @@ public class MeshBuilder{
|
|||||||
}
|
}
|
||||||
mesh = null;
|
mesh = null;
|
||||||
|
|
||||||
totalBytes += last.getVerticesBuffer().capacity() * 4;
|
|
||||||
totalBytes += last.getIndicesBuffer().capacity() * 2;
|
|
||||||
|
|
||||||
Log.info("total memory used: @ mb", totalBytes / 1000f / 1000f);
|
|
||||||
|
|
||||||
return last;
|
return last;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,11 +25,18 @@ public abstract class PlanetGenerator extends BasicGenerator implements HexMeshe
|
|||||||
|
|
||||||
protected @Nullable Sector sector;
|
protected @Nullable Sector sector;
|
||||||
|
|
||||||
/** Should generate sector bases for a planet. */
|
|
||||||
public void generateSector(Sector sector){
|
public void generateSector(Sector sector){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onSectorCaptured(Sector sector){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onSectorLost(Sector sector){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public void getLockedText(Sector hovered, StringBuilder out){
|
public void getLockedText(Sector hovered, StringBuilder out){
|
||||||
out.append("[gray]").append(Iconc.lock).append(" ").append(Core.bundle.get("locked"));
|
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);
|
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
|
@Override
|
||||||
public boolean allowLanding(Sector sector){
|
public boolean allowLanding(Sector sector){
|
||||||
return sector.planet.allowLaunchToNumbered && (sector.hasBase() || sector.near().contains(s -> s.hasBase() &&
|
return sector.planet.allowLaunchToNumbered && (sector.hasBase() || sector.near().contains(s -> s.hasBase() &&
|
||||||
@@ -104,17 +114,26 @@ public class SerpuloPlanetGenerator extends PlanetGenerator{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Color getEmissiveColor(Vec3 position){
|
public Color getEmissiveColor(Vec3 position){
|
||||||
float dst = 999f;
|
float dst = 999f, captureDst = 999f;
|
||||||
for(Sector sector : Planets.serpulo.sectors){
|
for(Sector sector : Planets.serpulo.sectors){
|
||||||
if(sector.hasEnemyBase() && !sector.isCaptured()){
|
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;
|
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)
|
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));
|
.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;
|
return Color.clear;
|
||||||
|
|||||||
@@ -659,8 +659,8 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
|||||||
|
|
||||||
if(debugSectorAttackEdit){
|
if(debugSectorAttackEdit){
|
||||||
int timeShift = input.keyDown(KeyCode.rightBracket) ? 1 : input.keyDown(KeyCode.leftBracket) ? -1 : 0;
|
int timeShift = input.keyDown(KeyCode.rightBracket) ? 1 : input.keyDown(KeyCode.leftBracket) ? -1 : 0;
|
||||||
if(timeShift != -1){
|
if(timeShift != 0){
|
||||||
universe.setSeconds(universe.secondsf() + timeShift * Time.delta * 2f);
|
universe.setSeconds(universe.secondsf() + timeShift * Time.delta * 2.5f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user