remove unexplored terrain rendering

This commit is contained in:
James Seibel
2025-09-11 07:06:15 -05:00
parent 1ec536b7df
commit 6bdfee3636
6 changed files with 5 additions and 236 deletions
@@ -444,13 +444,6 @@ public class Config
+ "")
.build();
public static ConfigEntry<Boolean> enableUnexploredFogRendering = new ConfigEntry.Builder<Boolean>()
.set(true)
.comment(""
+ "If true unexplored/ungenerated LODs will be rendered as large dark gray boxes. \n"
+ "")
.build();
public static ConfigEntry<Boolean> enableInstancedRendering = new ConfigEntry.Builder<Boolean>()
.set(true)
.comment(""
@@ -1,30 +0,0 @@
/*
* This file is part of the Distant Horizons mod
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020 James Seibel
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.distanthorizons.core.enums;
/**
* OCEAN, <br>
* FOG_WALL, <br>
*/
public enum EUnexploredTerrainType
{
OCEAN,
FOG_WALL
}
@@ -26,8 +26,6 @@ import com.seibel.distanthorizons.api.objects.data.DhApiChunk;
import com.seibel.distanthorizons.api.objects.data.IDhApiFullDataSource;
import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV2;
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
import com.seibel.distanthorizons.core.enums.EUnexploredTerrainType;
import com.seibel.distanthorizons.core.file.AbstractDataSourceHandler;
import com.seibel.distanthorizons.core.generation.tasks.IWorldGenTaskTracker;
import com.seibel.distanthorizons.core.generation.tasks.InProgressWorldGenTaskGroup;
import com.seibel.distanthorizons.core.generation.tasks.WorldGenResult;
@@ -659,21 +657,10 @@ public class WorldGenerationQueue implements IFullDataSourceRetrievalQueue, IDeb
@Override
public void debugRender(DebugRenderer renderer)
{
// determine the height the wireframe should render at
final int maxY;
if (Config.Client.Advanced.Graphics.GenericRendering.enableUnexploredFogRendering.get()
&& this.level.getUnexploredTerrainType() == EUnexploredTerrainType.FOG_WALL)
{
// if unexplored fog is enabled, make sure the wireframe can be seen over it
maxY = this.level.getMaxY();
}
else
{
// if unexplored fog is disabled or is an ocean, show the wireframe a bit lower
// since most worlds don't render all the way up to the max height
int levelHeightRange = (this.level.getMaxY() - this.level.getMinY());
maxY = this.level.getMaxY() - (levelHeightRange / 2);
}
// show the wireframe a bit lower than world max height,
// since most worlds don't render all the way up to the max height
int levelHeightRange = (this.level.getMaxY() - this.level.getMinY());
int maxY = this.level.getMaxY() - (levelHeightRange / 2);
// blue - queued
@@ -28,7 +28,6 @@ import com.seibel.distanthorizons.api.objects.render.DhApiRenderableBox;
import com.seibel.distanthorizons.api.objects.render.DhApiRenderableBoxGroupShading;
import com.seibel.distanthorizons.core.config.Config;
import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV2;
import com.seibel.distanthorizons.core.enums.EUnexploredTerrainType;
import com.seibel.distanthorizons.core.file.fullDatafile.DelayedFullDataSourceSaveCache;
import com.seibel.distanthorizons.core.generation.DhLightingEngine;
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
@@ -88,7 +87,6 @@ public abstract class AbstractDhLevel implements IDhLevel
protected CloudRenderHandler cloudRenderHandler;
private IDhApiRenderableBoxGroup unexploredFogRenderableBoxGroup;
private EUnexploredTerrainType unexploredTerrainType = null;
@@ -378,133 +376,6 @@ public abstract class AbstractDhLevel implements IDhLevel
//====================//
// unexplored terrain //
//====================//
// TODO potentially merge how this and getGenericRenderer() are handled
// synchronized to prevent issues with two threads getting the same un-initalized group at the same time
public synchronized IDhApiRenderableBoxGroup getUnexploredTerrainRenderableBoxGroup()
{
// lazy setup to prevent issues on server levels and
// prevent order issues with the genericRenderer
if (this.unexploredFogRenderableBoxGroup == null)
{
// ocean looks better without SSAO
boolean enableSsao = (this.getUnexploredTerrainType() == EUnexploredTerrainType.FOG_WALL);
this.unexploredFogRenderableBoxGroup = GenericRenderObjectFactory.INSTANCE.createAbsolutePositionedGroup(ModInfo.NAME+":UnexploredFog", new ArrayList<>(512));
this.unexploredFogRenderableBoxGroup.setBlockLight(LodUtil.MIN_MC_LIGHT);
this.unexploredFogRenderableBoxGroup.setSkyLight(LodUtil.MAX_MC_LIGHT);
this.unexploredFogRenderableBoxGroup.setSsaoEnabled(enableSsao);
this.unexploredFogRenderableBoxGroup.setShading(DhApiRenderableBoxGroupShading.getDefaultShaded());
this.unexploredFogRenderableBoxGroup.setPreRenderFunc((DhApiRenderParam param) ->
{
boolean renderingEnabled = Config.Client.Advanced.Graphics.GenericRendering.enableUnexploredFogRendering.get();
this.unexploredFogRenderableBoxGroup.setActive(renderingEnabled);
});
GenericObjectRenderer genericRenderer = this.getGenericRenderer();
if (genericRenderer != null)
{
genericRenderer.add(this.unexploredFogRenderableBoxGroup);
}
}
return this.unexploredFogRenderableBoxGroup;
}
@Override
public EUnexploredTerrainType getUnexploredTerrainType()
{
// use cached value to prevent repeat string/levelWrapper operations
if (this.unexploredTerrainType != null)
{
return this.unexploredTerrainType;
}
// determine if we should use an infinite ocean or a fog wall
boolean hasCeiling = this.getLevelWrapper().hasCeiling();
String dimensionName = this.getLevelWrapper().getDimensionName().toLowerCase();
boolean dimensionHasOcean =
!hasCeiling
&& !dimensionName.contains("the_end")
&& !dimensionName.contains("nether");
this.unexploredTerrainType = dimensionHasOcean ? EUnexploredTerrainType.OCEAN : EUnexploredTerrainType.FOG_WALL;
return this.unexploredTerrainType;
}
/**
* @param levelWrapper is passed in due to how levelWrapper caching is poorly handled in most
* {@link IDhLevel}'s. If that's ever fixed we can just use the local {@link IClientLevelWrapper}
* getter instead.
*/
@Override
public DhApiRenderableBox createUnexploredTerrainRenderableBox(long pos, IClientLevelWrapper levelWrapper)
{
EUnexploredTerrainType terrainType = this.getUnexploredTerrainType();
if (terrainType == EUnexploredTerrainType.OCEAN)
{
return createUnexploredOceanRenderableBox(pos, levelWrapper);
}
else
{
return createUnexploredFogWallRenderableBox(pos, levelWrapper);
}
}
private static DhApiRenderableBox createUnexploredOceanRenderableBox(long pos, IClientLevelWrapper levelWrapper)
{
// width
float fogWidthInBlocks = (float) DhSectionPos.getBlockWidth(pos);
int seaLevel = levelWrapper.getSeaLevel();
Color waterColor = ColorUtil.toColorObjRGB(levelWrapper.getWaterBlockColor());
return new DhApiRenderableBox(
// min pos
new DhApiVec3d(DhSectionPos.getMinCornerBlockX(pos),
levelWrapper.getMinHeight(),
DhSectionPos.getMinCornerBlockZ(pos)),
// max pos
new DhApiVec3d(DhSectionPos.getMinCornerBlockX(pos) + fogWidthInBlocks,
seaLevel,
DhSectionPos.getMinCornerBlockZ(pos) + fogWidthInBlocks),
waterColor, EDhApiBlockMaterial.UNKNOWN);
}
private static DhApiRenderableBox createUnexploredFogWallRenderableBox(long pos, IClientLevelWrapper levelWrapper)
{
// width
float fogWidthInBlocks = (float) DhSectionPos.getBlockWidth(pos);
// pseudo random height (should be consistent for a given position)
int fogHeightRange = (int) ((levelWrapper.getMaxHeight() - levelWrapper.getMinHeight()) * 0.25);
int halfFogHeightRange = fogHeightRange / 2;
float randomHeightModifier = (float) (DhSectionPos.hashCode(pos) % halfFogHeightRange) - fogHeightRange;
// pseudo random color (should be consistent for a given position)
int randomColorModifier = (DhSectionPos.hashCode(pos) % 30) - 15;
int randomGrayColorValue = 180 + randomColorModifier;
randomGrayColorValue = MathUtil.clamp(1, randomGrayColorValue, 256); // clamp to prevent accidental out-of-range colors
return new DhApiRenderableBox(
// min pos
new DhApiVec3d(DhSectionPos.getMinCornerBlockX(pos),
levelWrapper.getMinHeight(),
DhSectionPos.getMinCornerBlockZ(pos)),
// max pos
new DhApiVec3d(DhSectionPos.getMinCornerBlockX(pos) + fogWidthInBlocks,
levelWrapper.getMaxHeight() + randomHeightModifier,
DhSectionPos.getMinCornerBlockZ(pos) + fogWidthInBlocks),
new Color(randomGrayColorValue, randomGrayColorValue, randomGrayColorValue), EDhApiBlockMaterial.UNKNOWN);
}
//================//
// base overrides //
//================//
@@ -22,7 +22,6 @@ package com.seibel.distanthorizons.core.level;
import com.seibel.distanthorizons.api.interfaces.render.IDhApiRenderableBoxGroup;
import com.seibel.distanthorizons.api.objects.render.DhApiRenderableBox;
import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV2;
import com.seibel.distanthorizons.core.enums.EUnexploredTerrainType;
import com.seibel.distanthorizons.core.file.fullDatafile.FullDataSourceProviderV2;
import com.seibel.distanthorizons.core.file.fullDatafile.GeneratedFullDataSourceProvider;
import com.seibel.distanthorizons.core.file.structure.ISaveStructure;
@@ -69,15 +68,6 @@ public interface IDhLevel extends AutoCloseable, GeneratedFullDataSourceProvider
@Nullable
BeaconBeamRepo getBeaconBeamRepo();
/** @return null on server-only levels */
@Nullable
IDhApiRenderableBoxGroup getUnexploredTerrainRenderableBoxGroup();
/** should only be used for client levels */
DhApiRenderableBox createUnexploredTerrainRenderableBox(long pos, IClientLevelWrapper levelWrapper);
EUnexploredTerrainType getUnexploredTerrainType();
FullDataSourceProviderV2 getFullDataProvider();
ISaveStructure getSaveStructure();
@@ -84,8 +84,6 @@ public class LodRenderSection implements IDebugRenderable, AutoCloseable
private final Cache<Long, CachedColumnRenderSource> cachedRenderSourceByPos;
private final AtomicInteger uploadTaskCountRef;
private final DhApiRenderableBox unexploredFogRenderableBox;
/**
* contains the list of beacons currently being rendered in this section
* if this list is modified the {@link LodRenderSection#beaconRenderHandler} should be updated to match.
@@ -161,9 +159,7 @@ public class LodRenderSection implements IDebugRenderable, AutoCloseable
this.beaconRenderHandler = this.quadTree.beaconRenderHandler;
this.beaconBeamRepo = this.level.getBeaconBeamRepo();
this.unexploredFogRenderableBox = this.level.createUnexploredTerrainRenderableBox(this.pos, this.levelWrapper);
DebugRenderer.register(this, Config.Client.Advanced.Debugging.DebugWireframe.showRenderSectionStatus);
}
@@ -218,14 +214,6 @@ public class LodRenderSection implements IDebugRenderable, AutoCloseable
this.getAndBuildRenderDataRunnable = () ->
{
// reset the fog
this.stopRenderingUnexploredFog();
if (!this.getFullDataSourceExists())
{
// no render data is present, fill the area with "fog"
this.startRenderingUnexploredFog();
}
this.getAndRefreshRenderingBeacons();
this.getAndUploadRenderDataToGpuAsync()
.thenRun(() ->
@@ -450,7 +438,6 @@ public class LodRenderSection implements IDebugRenderable, AutoCloseable
public void onRenderingDisabled()
{
this.stopRenderingBeacons();
this.stopRenderingUnexploredFog();
if (Config.Client.Advanced.Debugging.DebugWireframe.showRenderSectionStatus.get())
{
@@ -645,34 +632,6 @@ public class LodRenderSection implements IDebugRenderable, AutoCloseable
//================//
// unexplored fog //
//================//
private void startRenderingUnexploredFog()
{
IDhApiRenderableBoxGroup boxGroup = this.level.getUnexploredTerrainRenderableBoxGroup();
if (boxGroup != null) // box group will be null for server levels, that shouldn't be a problem here, but just in case
{
boxGroup.add(this.unexploredFogRenderableBox);
boxGroup.triggerBoxChange();
}
}
private void stopRenderingUnexploredFog()
{
IDhApiRenderableBoxGroup boxGroup = this.level.getUnexploredTerrainRenderableBoxGroup();
if (boxGroup != null) // box group will be null for server levels, that shouldn't be a problem here, but just in case
{
if (boxGroup.remove(this.unexploredFogRenderableBox))
{
boxGroup.triggerBoxChange();
}
}
}
//==============//
// base methods //
//==============//
@@ -723,7 +682,6 @@ public class LodRenderSection implements IDebugRenderable, AutoCloseable
this.stopRenderingBeacons();
this.stopRenderingUnexploredFog();
if (this.renderBuffer != null)
{