diff --git a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/BlueMapConfigs.java b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/BlueMapConfigs.java index cb3db340..481841d8 100644 --- a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/BlueMapConfigs.java +++ b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/BlueMapConfigs.java @@ -363,6 +363,7 @@ private ConfigTemplate createOverworldMapTemplate(String name, Path worldFolder, .setVariable("sorting", "" + index) .setVariable("world", formatPath(worldFolder)) .setVariable("sky-color", "#7dabff") + .setVariable("void-color", "#000000") .setVariable("ambient-light", "0.1") .setVariable("world-sky-light", "15") .setVariable("remove-caves-below-y", "55") @@ -376,6 +377,7 @@ private ConfigTemplate createNetherMapTemplate(String name, Path worldFolder, in .setVariable("sorting", "" + (100 + index)) .setVariable("world", formatPath(worldFolder)) .setVariable("sky-color", "#290000") + .setVariable("void-color", "#000000") .setVariable("ambient-light", "0.6") .setVariable("world-sky-light", "0") .setVariable("remove-caves-below-y", "-10000") @@ -389,6 +391,7 @@ private ConfigTemplate createEndMapTemplate(String name, Path worldFolder, int i .setVariable("sorting", "" + (200 + index)) .setVariable("world", formatPath(worldFolder)) .setVariable("sky-color", "#080010") + .setVariable("void-color", "#000000") .setVariable("ambient-light", "0.6") .setVariable("world-sky-light", "0") .setVariable("remove-caves-below-y", "-10000") diff --git a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/MapConfig.java b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/MapConfig.java index dc2648f4..553c0833 100644 --- a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/MapConfig.java +++ b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/MapConfig.java @@ -49,6 +49,7 @@ public class MapConfig implements MapSettings { private Vector2i startPos = null; private String skyColor = "#7dabff"; + private String voidColor = "#000000"; private float ambientLight = 0; @@ -112,6 +113,11 @@ public String getSkyColor() { return skyColor; } + @Override + public String getVoidColor() { + return voidColor; + } + @Override public float getAmbientLight() { return ambientLight; diff --git a/BlueMapCommon/src/main/resources/de/bluecolored/bluemap/config/maps/map.conf b/BlueMapCommon/src/main/resources/de/bluecolored/bluemap/config/maps/map.conf index 6b85532a..9b948c3a 100644 --- a/BlueMapCommon/src/main/resources/de/bluecolored/bluemap/config/maps/map.conf +++ b/BlueMapCommon/src/main/resources/de/bluecolored/bluemap/config/maps/map.conf @@ -24,11 +24,16 @@ sorting: ${sorting} # This defaults to the world-spawn if you don't set it. #start-pos: {x:500, z:-820} -# The color of thy sky as a hex-color +# The color of the sky as a hex-color # You can change this at any time. # Default is "#7dabff" sky-color: "${sky-color}" +# The color of the void as a hex-color +# You can change this at any time. +# Default is "#000000" +void-color: "${void-color}" + # Defines the ambient light-strength that every block is receiving, regardless of the sunlight/blocklight. # 0 is no ambient light, 1 is fully lighted. # You can change this at any time. diff --git a/BlueMapCommon/webapp/src/js/MapViewer.js b/BlueMapCommon/webapp/src/js/MapViewer.js index 12a79ecd..a917637c 100644 --- a/BlueMapCommon/webapp/src/js/MapViewer.js +++ b/BlueMapCommon/webapp/src/js/MapViewer.js @@ -60,6 +60,7 @@ export class MapViewer { sunlightStrength: { value: 1 }, ambientLight: { value: 0 }, skyColor: { value: new Color(0.5, 0.5, 1) }, + voidColor: { value: new Color(0, 0, 0) }, hiresTileMap: { value: { map: null, @@ -393,6 +394,7 @@ export class MapViewer { this.data.uniforms.distance.value = this.controlsManager.distance; this.data.uniforms.skyColor.value = map.data.skyColor; + this.data.uniforms.voidColor.value = map.data.voidColor; this.data.uniforms.ambientLight.value = map.data.ambientLight; this.data.uniforms.hiresTileMap.value.map = map.hiresTileManager.tileMap.texture; this.data.uniforms.hiresTileMap.value.scale.set(map.data.hires.tileSize.x, map.data.hires.tileSize.z); diff --git a/BlueMapCommon/webapp/src/js/map/Map.js b/BlueMapCommon/webapp/src/js/map/Map.js index b42299ad..98e11af3 100644 --- a/BlueMapCommon/webapp/src/js/map/Map.js +++ b/BlueMapCommon/webapp/src/js/map/Map.js @@ -63,6 +63,7 @@ export class Map { name: id, startPos: {x: 0, z: 0}, skyColor: new Color(), + voidColor: new Color(), ambientLight: 0, hires: { tileSize: {x: 32, z: 32}, @@ -150,6 +151,14 @@ export class Map { ); } + if (worldSettings.voidColor && worldSettings.voidColor.length >= 3) { + this.data.voidColor.setRGB( + worldSettings.voidColor[0], + worldSettings.voidColor[1], + worldSettings.voidColor[2] + ); + } + this.data.ambientLight = worldSettings.ambientLight ? worldSettings.ambientLight : this.data.ambientLight; if (worldSettings.hires === undefined) worldSettings.hires = {}; diff --git a/BlueMapCommon/webapp/src/js/map/lowres/LowresFragmentShader.js b/BlueMapCommon/webapp/src/js/map/lowres/LowresFragmentShader.js index de7b7b49..095d2b5a 100644 --- a/BlueMapCommon/webapp/src/js/map/lowres/LowresFragmentShader.js +++ b/BlueMapCommon/webapp/src/js/map/lowres/LowresFragmentShader.js @@ -50,6 +50,7 @@ uniform vec2 tileSize; uniform vec2 textureSize; uniform float lod; uniform float lodScale; +uniform vec3 voidColor; varying vec3 vPosition; varying vec3 vWorldPosition; @@ -76,14 +77,16 @@ vec2 posToMetaUV(vec2 pos) { return vec2(pos.x / textureSize.x, pos.y / textureSize.y + 0.5); } +vec3 adjustColor(vec3 color) { + return vec3(color * max(sunlightStrength * sunlightStrength, ambientLight)); +} void main() { //discard if hires tile is loaded at that position if (distance < 1000.0 && texture(hiresTileMap.map, ((vWorldPosition.xz - hiresTileMap.translate) / hiresTileMap.scale - hiresTileMap.pos) / hiresTileMap.size + 0.5).r > 0.75) discard; vec4 color = texture(textureImage, posToColorUV(vPosition.xz)); - color.a = 1.0; // don't use alpha channel - + vec4 meta = texture(textureImage, posToMetaUV(vPosition.xz)); float height = metaToHeight(meta); @@ -119,7 +122,12 @@ void main() { float blockLight = metaToLight(meta); float light = mix(blockLight, 15.0, sunlightStrength); color.rgb *= mix(ambientLight, 1.0, light / 15.0); - + + vec3 adjustedVoidColor = adjustColor(voidColor); + //where there's transparency, there is void that needs to be coloured + color.rgb = mix(adjustedVoidColor, color.rgb, color.a); + color.a = 1.0; //but don't actually display the transparency + gl_FragColor = color; ${ShaderChunk.logdepthbuf_fragment} diff --git a/BlueMapCommon/webapp/src/js/skybox/SkyFragmentShader.js b/BlueMapCommon/webapp/src/js/skybox/SkyFragmentShader.js index 67fe9e56..d25a389a 100644 --- a/BlueMapCommon/webapp/src/js/skybox/SkyFragmentShader.js +++ b/BlueMapCommon/webapp/src/js/skybox/SkyFragmentShader.js @@ -26,17 +26,23 @@ export const SKY_FRAGMENT_SHADER = ` uniform float sunlightStrength; uniform float ambientLight; uniform vec3 skyColor; +uniform vec3 voidColor; varying vec3 vPosition; +vec3 adjustColor(vec3 color) { + return vec3(color * max(sunlightStrength * sunlightStrength, ambientLight)); +} + void main() { float horizonWidth = 0.005; float horizonHeight = 0.0; - vec4 color = vec4(skyColor * max(sunlightStrength * sunlightStrength, ambientLight), 1.0); + vec3 adjustedSkyColor = adjustColor(skyColor); + vec3 adjustedVoidColor = adjustColor(voidColor); float voidMultiplier = (clamp(vPosition.y - horizonHeight, -horizonWidth, horizonWidth) + horizonWidth) / (horizonWidth * 2.0); - color.rgb *= voidMultiplier; + vec3 color = mix(adjustedVoidColor, adjustedSkyColor, voidMultiplier); - gl_FragColor = color; + gl_FragColor = vec4(color, 1.0); } `; diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/map/MapSettings.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/map/MapSettings.java index c2f1d1ba..ace9e3ca 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/map/MapSettings.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/map/MapSettings.java @@ -37,6 +37,8 @@ public interface MapSettings extends RenderSettings { String getSkyColor(); + String getVoidColor(); + long getMinInhabitedTime(); int getMinInhabitedTimeRadius(); diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/map/MapSettingsSerializer.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/map/MapSettingsSerializer.java index 8e1780b1..747fd26d 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/map/MapSettingsSerializer.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/map/MapSettingsSerializer.java @@ -74,6 +74,10 @@ public JsonElement serialize(BmMap map, Type typeOfSrc, JsonSerializationContext Color skyColor = new Color().parse(map.getMapSettings().getSkyColor()); root.add("skyColor", context.serialize(skyColor)); + // voidColor + Color voidColor = new Color().parse(map.getMapSettings().getVoidColor()); + root.add("voidColor", context.serialize(voidColor)); + // ambientLight root.addProperty("ambientLight", map.getMapSettings().getAmbientLight()); diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/map/hires/HiresModelRenderer.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/map/hires/HiresModelRenderer.java index 452cf8a5..d7fc65e7 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/map/hires/HiresModelRenderer.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/map/hires/HiresModelRenderer.java @@ -70,7 +70,7 @@ public void render(World world, Vector3i modelMin, Vector3i modelMax, HiresTileM maxHeight = 0; topBlockLight = 0f; - columnColor.set(0, 0, 0, 1, true); + columnColor.set(0, 0, 0, 0, true); if (renderSettings.isInsideRenderBoundaries(x, z)) { minY = Math.max(min.getY(), world.getMinY(x, z));