voxel value generation work
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good

This commit is contained in:
austin 2025-04-29 17:19:57 -04:00
parent 782b31954e
commit 388f622c9b
12 changed files with 37 additions and 33 deletions

View File

@ -7,6 +7,9 @@
+ non-feedback requirements + non-feedback requirements
+ feedback driven requirements + feedback driven requirements
Spawn a town in macro data
- Place a building
- Elevation calls give you the ACTUAL elevation
Crouching Crouching
Model clothing, hair for the human Model clothing, hair for the human
particles, light on sword collision particles, light on sword collision
@ -17,6 +20,5 @@
+ bug fixes + bug fixes
- Window does not play nice with its minWidth/minHeight being set differently - Window does not play nice with its minWidth/minHeight being set differently
- Interaction block cursor is overwriting fab cursor
+ unreproducible bugs + unreproducible bugs

View File

@ -1595,6 +1595,8 @@ Unit tests for unhash func
Filter client entity list to terrain Filter client entity list to terrain
Fix server loading full res chunks from disk as strided chunks Fix server loading full res chunks from disk as strided chunks
Debugging tooling for foliage manager Debugging tooling for foliage manager
Refactor ProceduralChunkGenerator
NoiseVoxelGen work to make elevation values align with voxel values that are generated

View File

@ -5,7 +5,7 @@ import electrosphere.engine.signal.Signal.SignalType;
import electrosphere.renderer.ui.imgui.ImGuiWindow; import electrosphere.renderer.ui.imgui.ImGuiWindow;
import electrosphere.renderer.ui.imgui.ImGuiWindow.ImGuiWindowCallback; import electrosphere.renderer.ui.imgui.ImGuiWindow.ImGuiWindowCallback;
import electrosphere.server.datacell.gridded.GriddedDataCellManager; import electrosphere.server.datacell.gridded.GriddedDataCellManager;
import electrosphere.server.physics.terrain.generation.TestGenerationChunkGenerator; import electrosphere.server.physics.terrain.generation.ProceduralChunkGenerator;
import electrosphere.server.physics.terrain.models.TerrainModel; import electrosphere.server.physics.terrain.models.TerrainModel;
import imgui.ImGui; import imgui.ImGui;
import imgui.type.ImInt; import imgui.type.ImInt;
@ -62,7 +62,7 @@ public class ImGuiTestGen {
} }
//set macro data scale in terrain model //set macro data scale in terrain model
if(ImGui.sliderInt("Macro Data Scale", macroDataScaleInput, TestGenerationChunkGenerator.GENERATOR_REALM_SIZE / terrainModel.getBiome().length, TerrainModel.DEFAULT_MACRO_DATA_SCALE)){ if(ImGui.sliderInt("Macro Data Scale", macroDataScaleInput, ProceduralChunkGenerator.GENERATOR_REALM_SIZE / terrainModel.getBiome().length, TerrainModel.DEFAULT_MACRO_DATA_SCALE)){
terrainModel.setMacroDataScale(macroDataScaleInput[0]); terrainModel.setMacroDataScale(macroDataScaleInput[0]);
} }

View File

@ -11,7 +11,7 @@ import electrosphere.renderer.ui.imgui.ImGuiLinePlot;
import electrosphere.renderer.ui.imgui.ImGuiWindow; import electrosphere.renderer.ui.imgui.ImGuiWindow;
import electrosphere.renderer.ui.imgui.ImGuiLinePlot.ImGuiLinePlotDataset; import electrosphere.renderer.ui.imgui.ImGuiLinePlot.ImGuiLinePlotDataset;
import electrosphere.renderer.ui.imgui.ImGuiWindow.ImGuiWindowCallback; import electrosphere.renderer.ui.imgui.ImGuiWindow.ImGuiWindowCallback;
import electrosphere.server.physics.terrain.generation.TestGenerationChunkGenerator; import electrosphere.server.physics.terrain.generation.ProceduralChunkGenerator;
import imgui.ImGui; import imgui.ImGui;
/** /**
@ -161,7 +161,7 @@ public class ImGuiWindowMacros {
Globals.realmManager != null && Globals.realmManager != null &&
Globals.realmManager.first() != null && Globals.realmManager.first() != null &&
Globals.realmManager.first().getServerWorldData() != null && Globals.realmManager.first().getServerWorldData() != null &&
Globals.realmManager.first().getServerWorldData().getServerTerrainManager().getChunkGenerator() instanceof TestGenerationChunkGenerator && Globals.realmManager.first().getServerWorldData().getServerTerrainManager().getChunkGenerator() instanceof ProceduralChunkGenerator &&
ImGui.button("Test Terrain Gen") ImGui.button("Test Terrain Gen")
){ ){
ImGuiTestGen.testGenWindow.setOpen(true); ImGuiTestGen.testGenWindow.setOpen(true);

View File

@ -13,7 +13,7 @@ import electrosphere.logger.LoggerInterface;
import electrosphere.net.parser.net.message.TerrainMessage; import electrosphere.net.parser.net.message.TerrainMessage;
import electrosphere.net.server.ServerConnectionHandler; import electrosphere.net.server.ServerConnectionHandler;
import electrosphere.renderer.ui.elements.Window; import electrosphere.renderer.ui.elements.Window;
import electrosphere.server.physics.terrain.generation.TestGenerationChunkGenerator; import electrosphere.server.physics.terrain.generation.ProceduralChunkGenerator;
import electrosphere.server.saves.SaveUtils; import electrosphere.server.saves.SaveUtils;
/** /**
@ -43,7 +43,7 @@ public class ChunkGenerationTestLoading {
}); });
//wait on script engine to load //wait on script engine to load
if(TestGenerationChunkGenerator.DEFAULT_USE_JAVASCRIPT){ if(ProceduralChunkGenerator.DEFAULT_USE_JAVASCRIPT){
WindowUtils.updateLoadingWindow("Waiting on scripting engine"); WindowUtils.updateLoadingWindow("Waiting on scripting engine");
while(!Globals.scriptEngine.isInitialized()){ while(!Globals.scriptEngine.isInitialized()){
try { try {

View File

@ -3,7 +3,7 @@ package electrosphere.entity.scene;
import java.util.Objects; import java.util.Objects;
import electrosphere.server.datacell.gridded.GriddedDataCellManager; import electrosphere.server.datacell.gridded.GriddedDataCellManager;
import electrosphere.server.physics.terrain.generation.TestGenerationChunkGenerator; import electrosphere.server.physics.terrain.generation.ProceduralChunkGenerator;
/** /**
* Generates scene files where appropriate (ie, if playing the procedurally generated level) * Generates scene files where appropriate (ie, if playing the procedurally generated level)
@ -37,7 +37,7 @@ public class SceneGenerator {
SceneFile file = SceneFile.createSceneFile(); SceneFile file = SceneFile.createSceneFile();
//realm descriptor stuff //realm descriptor stuff
file.realmDescriptor.type = RealmDescriptor.REALM_DESCRIPTOR_GENERATION_TESTING; file.realmDescriptor.type = RealmDescriptor.REALM_DESCRIPTOR_GENERATION_TESTING;
file.realmDescriptor.griddedRealmSize = TestGenerationChunkGenerator.GENERATOR_REALM_SIZE; file.realmDescriptor.griddedRealmSize = ProceduralChunkGenerator.GENERATOR_REALM_SIZE;
file.createSaveInstance = true; //won't have a predefined scene to load, so must create one in the save file.createSaveInstance = true; //won't have a predefined scene to load, so must create one in the save
file.loadAllCells = false; // do not load all cells on init file.loadAllCells = false; // do not load all cells on init

View File

@ -5,7 +5,7 @@ import electrosphere.server.physics.block.manager.ServerBlockManager;
import electrosphere.server.physics.fluid.generation.DefaultFluidGenerator; import electrosphere.server.physics.fluid.generation.DefaultFluidGenerator;
import electrosphere.server.physics.fluid.manager.ServerFluidManager; import electrosphere.server.physics.fluid.manager.ServerFluidManager;
import electrosphere.server.physics.terrain.generation.DefaultChunkGenerator; import electrosphere.server.physics.terrain.generation.DefaultChunkGenerator;
import electrosphere.server.physics.terrain.generation.TestGenerationChunkGenerator; import electrosphere.server.physics.terrain.generation.ProceduralChunkGenerator;
import electrosphere.server.physics.terrain.manager.ServerTerrainChunk; import electrosphere.server.physics.terrain.manager.ServerTerrainChunk;
import electrosphere.server.physics.terrain.manager.ServerTerrainManager; import electrosphere.server.physics.terrain.manager.ServerTerrainManager;
import electrosphere.server.physics.terrain.models.TerrainModel; import electrosphere.server.physics.terrain.models.TerrainModel;
@ -147,7 +147,7 @@ public class ServerWorldData {
} else { } else {
//TODO: Allow loading procedurally generated terrain from disk (the chunk generator is always default currently) //TODO: Allow loading procedurally generated terrain from disk (the chunk generator is always default currently)
serverWorldData = FileUtils.loadObjectFromSavePath(sceneOrSaveName, "world.json", ServerWorldData.class); serverWorldData = FileUtils.loadObjectFromSavePath(sceneOrSaveName, "world.json", ServerWorldData.class);
serverTerrainManager = new ServerTerrainManager(serverWorldData, 0, new TestGenerationChunkGenerator(serverWorldData, false)); serverTerrainManager = new ServerTerrainManager(serverWorldData, 0, new ProceduralChunkGenerator(serverWorldData, false));
serverTerrainManager.load(sceneOrSaveName); serverTerrainManager.load(sceneOrSaveName);
serverFluidManager = new ServerFluidManager(serverWorldData, serverTerrainManager, 0, new DefaultFluidGenerator()); serverFluidManager = new ServerFluidManager(serverWorldData, serverTerrainManager, 0, new DefaultFluidGenerator());
serverBlockManager = new ServerBlockManager(serverWorldData); serverBlockManager = new ServerBlockManager(serverWorldData);
@ -170,13 +170,13 @@ public class ServerWorldData {
ServerFluidManager serverFluidManager = null; ServerFluidManager serverFluidManager = null;
ServerBlockManager serverBlockManager = null; ServerBlockManager serverBlockManager = null;
//TODO: Allow loading procedurally generated terrain from disk (the chunk generator is always default currently) //TODO: Allow loading procedurally generated terrain from disk (the chunk generator is always default currently)
serverWorldData = ServerWorldData.createFixedWorldData(new Vector3d(0),new Vector3d(TestGenerationChunkGenerator.GENERATOR_REALM_SIZE * ServerTerrainChunk.CHUNK_DIMENSION)); serverWorldData = ServerWorldData.createFixedWorldData(new Vector3d(0),new Vector3d(ProceduralChunkGenerator.GENERATOR_REALM_SIZE * ServerTerrainChunk.CHUNK_DIMENSION));
serverWorldData.worldSizeDiscrete = TestGenerationChunkGenerator.GENERATOR_REALM_SIZE; serverWorldData.worldSizeDiscrete = ProceduralChunkGenerator.GENERATOR_REALM_SIZE;
serverWorldData.worldSizeDiscreteVertical = TestGenerationChunkGenerator.GENERATOR_REALM_SIZE; serverWorldData.worldSizeDiscreteVertical = ProceduralChunkGenerator.GENERATOR_REALM_SIZE;
//test terrain gen //test terrain gen
{ {
TestGenerationChunkGenerator chunkGen = new TestGenerationChunkGenerator(serverWorldData, TestGenerationChunkGenerator.DEFAULT_USE_JAVASCRIPT); ProceduralChunkGenerator chunkGen = new ProceduralChunkGenerator(serverWorldData, ProceduralChunkGenerator.DEFAULT_USE_JAVASCRIPT);
serverTerrainManager = new ServerTerrainManager(serverWorldData, 0, chunkGen); serverTerrainManager = new ServerTerrainManager(serverWorldData, 0, chunkGen);
serverTerrainManager.genTestData(chunkGen); serverTerrainManager.genTestData(chunkGen);
} }
@ -278,12 +278,12 @@ public class ServerWorldData {
/** /**
* Converts a chunk space coordinate to a real space coordinate * Converts a chunk space coordinate to a real space coordinate
* @param chunk The position within the chunk * @param voxelPos The voxel's position within the chunk
* @param worldPos The world pos of the chunk * @param worldPos The world pos of the chunk
* @return The real pos * @return The real pos
*/ */
public double convertVoxelToRealSpace(int chunk, int worldPos){ public double convertVoxelToRealSpace(int voxelPos, int worldPos){
return chunk + this.convertWorldToReal(worldPos); return voxelPos + this.convertWorldToReal(worldPos);
} }
public double getRelativeLocation(double real, int world){ public double getRelativeLocation(double real, int world){

View File

@ -32,7 +32,7 @@ import io.github.studiorailgun.MathUtils;
/** /**
* A generator for testing terrain generation * A generator for testing terrain generation
*/ */
public class TestGenerationChunkGenerator implements ChunkGenerator { public class ProceduralChunkGenerator implements ChunkGenerator {
/** /**
* The size of the realm for testing generation * The size of the realm for testing generation
@ -87,7 +87,7 @@ public class TestGenerationChunkGenerator implements ChunkGenerator {
/** /**
* Constructor * Constructor
*/ */
public TestGenerationChunkGenerator(ServerWorldData serverWorldData, boolean useJavascript){ public ProceduralChunkGenerator(ServerWorldData serverWorldData, boolean useJavascript){
this.serverWorldData = serverWorldData; this.serverWorldData = serverWorldData;
this.registerAllGenerators(); this.registerAllGenerators();
this.useJavascript = useJavascript; this.useJavascript = useJavascript;

View File

@ -85,28 +85,28 @@ public class NoiseVoxelGen implements VoxelGenerator {
} }
sample = Math.min(sample,1.0); sample = Math.min(sample,1.0);
if(heightDiff < -strideMultiplier * SURFACE_VOXEL_WIDTH){ if(heightDiff < -strideMultiplier * SURFACE_VOXEL_WIDTH){
//below surface //below surface, ie generate stone here
double finalSurface = sample; double finalSurface = sample;
voxel.weight = (float)finalSurface; voxel.weight = (float)finalSurface;
voxel.type = 1; voxel.type = 1;
} else if(heightDiff > 0) { } else if(heightDiff > 0) {
//above surface //above surface, ie generate air here
voxel.weight = -1.0f; voxel.weight = -1.0f;
voxel.type = 0; voxel.type = 0;
} else if(heightDiff < -strideMultiplier){ } else if(heightDiff < -strideMultiplier){
BiomeFloorElement floorEl = surfaceParams.getFloorVariant((float)surfaceSelectionNoise); BiomeFloorElement floorEl = surfaceParams.getFloorVariant((float)surfaceSelectionNoise);
//generate full-size surface-type voxel //generate full-size surface-type voxel, ie generate grass here
double finalHeight = sample; double finalHeight = sample;
voxel.weight = (float)finalHeight; voxel.weight = (float)finalHeight;
voxel.type = floorEl.getVoxelId(); voxel.type = floorEl.getVoxelId();
} else { } else {
BiomeFloorElement floorEl = surfaceParams.getFloorVariant((float)surfaceSelectionNoise); BiomeFloorElement floorEl = surfaceParams.getFloorVariant((float)surfaceSelectionNoise);
//surface //surface, ie generate grass here
double surfacePercent = -heightDiff / strideMultiplier; double surfacePercent = -heightDiff / strideMultiplier;
if(surfacePercent > 1.0 || surfacePercent < 0){ if(surfacePercent > 1.0 || surfacePercent < 0){
throw new Error("surfacePercent " + surfacePercent + " " + realY + " " + surfaceHeight + " " + heightDiff + " " + strideMultiplier); throw new Error("surfacePercent " + surfacePercent + " " + realY + " " + surfaceHeight + " " + heightDiff + " " + strideMultiplier);
} }
double finalHeight = sample * surfacePercent * 2 - 1; double finalHeight = sample * surfacePercent * 2;
voxel.weight = (float)(finalHeight * sample); voxel.weight = (float)(finalHeight * sample);
voxel.type = floorEl.getVoxelId(); voxel.type = floorEl.getVoxelId();
} }

View File

@ -5,7 +5,7 @@ import electrosphere.engine.Globals;
import electrosphere.entity.scene.RealmDescriptor; import electrosphere.entity.scene.RealmDescriptor;
import electrosphere.server.datacell.ServerWorldData; import electrosphere.server.datacell.ServerWorldData;
import electrosphere.server.physics.terrain.diskmap.ChunkDiskMap; import electrosphere.server.physics.terrain.diskmap.ChunkDiskMap;
import electrosphere.server.physics.terrain.generation.TestGenerationChunkGenerator; import electrosphere.server.physics.terrain.generation.ProceduralChunkGenerator;
import electrosphere.server.physics.terrain.generation.interfaces.ChunkGenerator; import electrosphere.server.physics.terrain.generation.interfaces.ChunkGenerator;
import electrosphere.server.physics.terrain.generation.macro.DefaultMacroGenerator; import electrosphere.server.physics.terrain.generation.macro.DefaultMacroGenerator;
import electrosphere.server.physics.terrain.generation.macro.HomogenousMacroGenerator; import electrosphere.server.physics.terrain.generation.macro.HomogenousMacroGenerator;
@ -234,7 +234,7 @@ public class ServerTerrainManager {
* Generates a test terrain model * Generates a test terrain model
* @param chunkGen The chunk generator * @param chunkGen The chunk generator
*/ */
public void genTestData(TestGenerationChunkGenerator chunkGen){ public void genTestData(ProceduralChunkGenerator chunkGen){
this.model = TerrainModel.generateTestModel(); this.model = TerrainModel.generateTestModel();
chunkGen.setModel(model); chunkGen.setModel(model);
} }

View File

@ -2,7 +2,7 @@ package electrosphere.server.physics.terrain.models;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.game.data.biome.BiomeData; import electrosphere.game.data.biome.BiomeData;
import electrosphere.server.physics.terrain.generation.TestGenerationChunkGenerator; import electrosphere.server.physics.terrain.generation.ProceduralChunkGenerator;
import electrosphere.server.physics.terrain.manager.ServerTerrainChunk; import electrosphere.server.physics.terrain.manager.ServerTerrainChunk;
import electrosphere.util.annotation.Exclude; import electrosphere.util.annotation.Exclude;
@ -109,12 +109,12 @@ public class TerrainModel {
*/ */
public static TerrainModel generateTestModel(){ public static TerrainModel generateTestModel(){
TerrainModel rVal = new TerrainModel(); TerrainModel rVal = new TerrainModel();
rVal.discreteArrayDimension = TestGenerationChunkGenerator.GENERATOR_REALM_SIZE; rVal.discreteArrayDimension = ProceduralChunkGenerator.GENERATOR_REALM_SIZE;
int macroDataImageScale = TestGenerationChunkGenerator.GENERATOR_REALM_SIZE / DEFAULT_MACRO_DATA_SCALE + 1; int macroDataImageScale = ProceduralChunkGenerator.GENERATOR_REALM_SIZE / DEFAULT_MACRO_DATA_SCALE + 1;
rVal.biome = new short[macroDataImageScale][macroDataImageScale]; rVal.biome = new short[macroDataImageScale][macroDataImageScale];
for(int x = 0; x < macroDataImageScale; x++){ for(int x = 0; x < macroDataImageScale; x++){
for(int z = 0; z < macroDataImageScale; z++){ for(int z = 0; z < macroDataImageScale; z++){
rVal.biome[x][z] = TestGenerationChunkGenerator.DEFAULT_BIOME_INDEX; rVal.biome[x][z] = ProceduralChunkGenerator.DEFAULT_BIOME_INDEX;
} }
} }
rVal.biome[1][0] = 0; rVal.biome[1][0] = 0;

View File

@ -14,7 +14,7 @@ import electrosphere.server.macro.MacroData;
import electrosphere.server.physics.fluid.generation.DefaultFluidGenerator; import electrosphere.server.physics.fluid.generation.DefaultFluidGenerator;
import electrosphere.server.physics.fluid.manager.ServerFluidManager; import electrosphere.server.physics.fluid.manager.ServerFluidManager;
import electrosphere.server.physics.terrain.generation.DefaultChunkGenerator; import electrosphere.server.physics.terrain.generation.DefaultChunkGenerator;
import electrosphere.server.physics.terrain.generation.TestGenerationChunkGenerator; import electrosphere.server.physics.terrain.generation.ProceduralChunkGenerator;
import electrosphere.server.physics.terrain.manager.ServerTerrainManager; import electrosphere.server.physics.terrain.manager.ServerTerrainManager;
import electrosphere.util.FileUtils; import electrosphere.util.FileUtils;
@ -117,7 +117,7 @@ public class SaveUtils {
ServerWorldData serverWorldData = ServerWorldData.createGriddedRealmWorldData(ServerWorldData.PROCEDURAL_WORLD_SIZE); ServerWorldData serverWorldData = ServerWorldData.createGriddedRealmWorldData(ServerWorldData.PROCEDURAL_WORLD_SIZE);
FileUtils.serializeObjectToSavePath(saveName, "./world.json", serverWorldData); FileUtils.serializeObjectToSavePath(saveName, "./world.json", serverWorldData);
//terrain manager //terrain manager
ServerTerrainManager serverTerrainManager = new ServerTerrainManager(serverWorldData, sceneFile.getSeed(), new TestGenerationChunkGenerator(serverWorldData, false)); ServerTerrainManager serverTerrainManager = new ServerTerrainManager(serverWorldData, sceneFile.getSeed(), new ProceduralChunkGenerator(serverWorldData, false));
serverTerrainManager.generate(sceneFile.getRealmDescriptor()); serverTerrainManager.generate(sceneFile.getRealmDescriptor());
serverTerrainManager.save(saveName); serverTerrainManager.save(saveName);
//fluid manager //fluid manager