diff --git a/DynmapCore/build.gradle b/DynmapCore/build.gradle index 0f96966d..92b55765 100644 --- a/DynmapCore/build.gradle +++ b/DynmapCore/build.gradle @@ -15,6 +15,7 @@ processResources { include 'core.yml' include 'lightings.txt' include 'perspectives.txt' + include 'shaders.txt' include 'extracted/web/version.js' include 'extracted/web/index.html' include 'extracted/web/login.html' diff --git a/DynmapCore/src/main/java/org/dynmap/hdmap/TexturePackHDShader.java b/DynmapCore/src/main/java/org/dynmap/hdmap/TexturePackHDShader.java index 8bfa4e90..330258ea 100644 --- a/DynmapCore/src/main/java/org/dynmap/hdmap/TexturePackHDShader.java +++ b/DynmapCore/src/main/java/org/dynmap/hdmap/TexturePackHDShader.java @@ -107,7 +107,7 @@ public class TexturePackHDShader implements HDShader { final protected HDMap map; final private TexturePack scaledtp; final private HDLighting lighting; - private DynmapBlockState lastblk; + protected DynmapBlockState lastblk; final boolean do_biome_shading; final boolean do_better_grass; DynLongHashMap ctm_cache; diff --git a/DynmapCore/src/main/java/org/dynmap/hdmap/TexturePackHDUnderwaterShader.java b/DynmapCore/src/main/java/org/dynmap/hdmap/TexturePackHDUnderwaterShader.java new file mode 100644 index 00000000..d1e3080c --- /dev/null +++ b/DynmapCore/src/main/java/org/dynmap/hdmap/TexturePackHDUnderwaterShader.java @@ -0,0 +1,44 @@ +package org.dynmap.hdmap; + +import org.dynmap.ConfigurationNode; +import org.dynmap.DynmapCore; +import org.dynmap.renderer.DynmapBlockState; +import org.dynmap.utils.MapChunkCache; +import org.dynmap.utils.MapIterator; + +public class TexturePackHDUnderwaterShader extends TexturePackHDShader { + + class UnderwaterShaderState extends TexturePackHDShader.ShaderState { + private boolean ready; + private DynmapBlockState full_water; + + protected UnderwaterShaderState(MapIterator mapiter, HDMap map, MapChunkCache cache, int scale) { + super(mapiter, map, cache, scale); + full_water = DynmapBlockState.getBaseStateByName(DynmapBlockState.WATER_BLOCK); + } + @Override + public void reset(HDPerspectiveState ps) { + super.reset(ps); + ready = false; + } + /** + * Process next ray step - called for each block on route + * @return true if ray is done, false if ray needs to continue + */ + public boolean processBlock(HDPerspectiveState ps) { + DynmapBlockState bs = ps.getBlockState(); + if (bs.isWater() || bs.isWaterlogged()) { + ready = true; + this.lastblk = full_water; + } + return ready ? super.processBlock(ps) : false; + } + } + public TexturePackHDUnderwaterShader(DynmapCore core, ConfigurationNode configuration) { + super(core, configuration); + } + @Override + public HDShaderState getStateInstance(HDMap map, MapChunkCache cache, MapIterator mapiter, int scale) { + return new UnderwaterShaderState(mapiter, map, cache, scale); + } +} diff --git a/DynmapCore/src/main/resources/shaders.txt b/DynmapCore/src/main/resources/shaders.txt index 51669c77..bd68d80c 100644 --- a/DynmapCore/src/main/resources/shaders.txt +++ b/DynmapCore/src/main/resources/shaders.txt @@ -1,3 +1,4 @@ +version: ${version} # # This file contains default standard shader definitions. The contents of this file are replaced and updated # during upgrades, so new or updated shader definitions should be done in the custom-shaders.txt file @@ -74,6 +75,11 @@ shaders: texturepack: standard max-sky-light: 0 min-emitted-light: 1 + + # Standard texture underwater view shader + - class: org.dynmap.hdmap.TexturePackHDUnderwaterShader + name: stdtexture-underwater + texturepack: standard # Texture pack based shader for standard Minecraft textures, without biome-tinted grass/leaves - class: org.dynmap.hdmap.TexturePackHDShader