Emissive planet system upgrades / Indexed vertices for planets

This commit is contained in:
Anuken
2025-05-28 21:21:21 -04:00
parent fcb5b42d58
commit 43fb2e7cdc
15 changed files with 193 additions and 82 deletions

View File

@@ -2,7 +2,6 @@ package mindustry.maps.generators;
import arc.*;
import arc.graphics.g2d.*;
import arc.math.*;
import arc.math.geom.*;
import arc.struct.*;
import arc.struct.ObjectIntMap.*;
@@ -26,10 +25,6 @@ public abstract class PlanetGenerator extends BasicGenerator implements HexMeshe
protected @Nullable Sector sector;
public static float packAlpha(float albedo, float emissive){
return emissive > 0 ? 1f + 1f/255f - 0.5f * Mathf.clamp(emissive) : Mathf.clamp(albedo) * 0.5f;
}
/** Should generate sector bases for a planet. */
public void generateSector(Sector sector){

View File

@@ -47,7 +47,7 @@ public class ErekirPlanetGenerator extends PlanetGenerator{
//TODO this might be too green
//if(block == Blocks.beryllicStone) block = Blocks.arkyicStone;
return Tmp.c1.set(block.mapColor).a(packAlpha(block.albedo, 0f));
return Tmp.c1.set(block.mapColor).a(1f - block.albedo);
}
@Override
@@ -64,17 +64,17 @@ public class ErekirPlanetGenerator extends PlanetGenerator{
}
Block getBlock(Vec3 position){
float ice = rawTemp(position);
Tmp.v32.set(position);
float px = position.x, py = position.y, pz = position.z;
float ice = rawTemp(position);
float height = rawHeight(position);
Tmp.v31.set(position);
height *= 1.2f;
height = Mathf.clamp(height);
Block result = terrain[Mathf.clamp((int)(height * terrain.length), 0, terrain.length - 1)];
if(ice < 0.3 + Math.abs(Ridged.noise3d(seed + crystalSeed, position.x + 4f, position.y + 8f, position.z + 1f, crystalOct, crystalScl)) * crystalMag){
if(ice < 0.3 + Math.abs(Ridged.noise3d(seed + crystalSeed, px + 4f, py + 8f, pz + 1f, crystalOct, crystalScl)) * crystalMag){
return Blocks.crystallineStone;
}
@@ -85,11 +85,9 @@ public class ErekirPlanetGenerator extends PlanetGenerator{
}
}
position = Tmp.v32;
//TODO tweak this to make it more natural
//TODO edge distortion?
if(ice < redThresh - noArkThresh && Ridged.noise3d(seed + arkSeed, position.x + 2f, position.y + 8f, position.z + 1f, arkOct, arkScl) > arkThresh){
if(ice < redThresh - noArkThresh && Ridged.noise3d(seed + arkSeed, px + 2f, py + 8f, pz + 1f, arkOct, arkScl) > arkThresh){
//TODO arkyic in middle
result = Blocks.beryllicStone;
}

View File

@@ -87,17 +87,6 @@ public class SerpuloPlanetGenerator extends PlanetGenerator{
@Override
public Color getColor(Vec3 position){
float dst = 999f;
for(Sector sector : Planets.serpulo.sectors){
if(sector.hasEnemyBase() && !sector.isCaptured()){
dst = Math.min(dst, position.dst(sector.tile.v));
}
}
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 < 0.06f){
return Tmp.c1.set(Team.crux.color).lerp(Team.sharded.color, 0.4f*Simplex.noise3d(seed, 1, 1, 9f, position.x, position.y + 999f, position.z)).a(packAlpha(0f, 1f));
}
//if(dst*metalDstScl + Simplex.noise3d(seed, 3, 0.4, 4f, position.x, position.y + 200f, position.z)*0.14f < 0.09f){
// return Tmp.c1.set(Team.crux.color).lerp(Team.sharded.color, 0.4f*Simplex.noise3d(seed, 1, 1, 9f, position.x, position.y + 999f, position.z)).a(packAlpha(0f, 1f));
//}
@@ -105,7 +94,30 @@ public class SerpuloPlanetGenerator extends PlanetGenerator{
Block block = getBlock(position);
//replace salt with sand color
if(block == Blocks.salt) return Blocks.sand.mapColor;
return Tmp.c1.set(block.mapColor).a(packAlpha(block.albedo, 0f));
return Tmp.c1.set(block.mapColor).a(1f - block.albedo);
}
@Override
public boolean hasEmissive(){
return true;
}
@Override
public Color getEmissiveColor(Vec3 position){
float dst = 999f;
for(Sector sector : Planets.serpulo.sectors){
if(sector.hasEnemyBase() && !sector.isCaptured()){
dst = Math.min(dst, 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){
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));
}
return Color.clear;
}
@Override
@@ -123,17 +135,16 @@ public class SerpuloPlanetGenerator extends PlanetGenerator{
Block getBlock(Vec3 position){
//float metalDst = position.dst(basePos);
float height = rawHeight(position);
Tmp.v31.set(position);
position = Tmp.v33.set(position).scl(scl);
float px = position.x * scl, py = position.y * scl, pz = position.z * scl;
float rad = scl;
float temp = Mathf.clamp(Math.abs(position.y * 2f) / (rad));
float tnoise = Simplex.noise3d(seed, 7, 0.56, 1f/3f, position.x, position.y + 999f, position.z);
float temp = Mathf.clamp(Math.abs(py * 2f) / (rad));
float tnoise = Simplex.noise3d(seed, 7, 0.56, 1f/3f, px, py + 999f, pz);
temp = Mathf.lerp(temp, tnoise, 0.5f);
height *= 1.2f;
height = Mathf.clamp(height);
float tar = Simplex.noise3d(seed, 4, 0.55f, 1f/2f, position.x, position.y + 999f, position.z) * 0.3f + Tmp.v31.dst(0, 0, 1f) * 0.2f;
float tar = Simplex.noise3d(seed, 4, 0.55f, 1f/2f, px, py + 999f, pz) * 0.3f + Tmp.v31.dst(0, 0, 1f) * 0.2f;
Block res = arr[Mathf.clamp((int)(temp * arr.length), 0, arr[0].length - 1)][Mathf.clamp((int)(height * arr[0].length), 0, arr[0].length - 1)];
if(tar > 0.5f){

View File

@@ -32,7 +32,7 @@ public class TantrosPlanetGenerator extends PlanetGenerator{
@Override
public Color getColor(Vec3 position){
float depth = Simplex.noise3d(seed, 2, 0.56, 1.7f, position.x, position.y, position.z) / 2f;
return c1.write(out).lerp(c2, Mathf.clamp(Mathf.round(depth, 0.15f))).a(packAlpha(0.2f, 0f));
return c1.write(out).lerp(c2, Mathf.clamp(Mathf.round(depth, 0.15f))).a(1f - 0.2f);
}
@Override