Add TexturePackHDUnderwaterShader (clear view underwater)

This commit is contained in:
Mike Primm 2018-08-20 21:39:39 -04:00
parent 2ebab4b7fc
commit 25eb57c658
4 changed files with 52 additions and 1 deletions

View File

@ -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'

View File

@ -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;

View File

@ -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);
}
}

View File

@ -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