mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-11-28 13:15:30 +01:00
Add shader option to disable biome shading, disable biome shading on non-normal worlds
This commit is contained in:
parent
62b42aa302
commit
78f571a68b
@ -133,7 +133,7 @@ public class DynmapPlugin extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
/* Table of default templates - all are resources in dynmap.jar unnder templates/, and go in templates directory when needed */
|
/* Table of default templates - all are resources in dynmap.jar unnder templates/, and go in templates directory when needed */
|
||||||
private static final String[] stdtemplates = { "normal.txt", "nether.txt", "skylands.txt", "normal-lowres.txt",
|
private static final String[] stdtemplates = { "normal.txt", "nether.txt", "skylands.txt", "normal-lowres.txt",
|
||||||
"nether-lowres.txt", "skylands-lowres.txt", "normal-hires.txt", "nether-hires.txt", "skyands-hires.txt"
|
"nether-lowres.txt", "skylands-lowres.txt", "normal-hires.txt", "nether-hires.txt", "skylands-hires.txt"
|
||||||
};
|
};
|
||||||
|
|
||||||
private static final String CUSTOM_PREFIX = "custom-";
|
private static final String CUSTOM_PREFIX = "custom-";
|
||||||
|
@ -374,9 +374,15 @@ public class TexturePack {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* All the same - no biome lookup needed */
|
/* All the same - no biome lookup needed */
|
||||||
if(same)
|
if(same) {
|
||||||
imgs[idx].argb = null;
|
imgs[idx].argb = null;
|
||||||
li.trivial_color = clr;
|
li.trivial_color = clr;
|
||||||
|
}
|
||||||
|
else { /* Else, calculate color average for lower left quadrant */
|
||||||
|
int[] clr_scale = new int[4];
|
||||||
|
scaleTerrainPNGSubImage(li.width, 2, li.argb, clr_scale);
|
||||||
|
li.trivial_color = clr_scale[2];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Patch image into texture table */
|
/* Patch image into texture table */
|
||||||
@ -694,7 +700,7 @@ public class TexturePack {
|
|||||||
/**
|
/**
|
||||||
* Read color for given subblock coordinate, with given block id and data and face
|
* Read color for given subblock coordinate, with given block id and data and face
|
||||||
*/
|
*/
|
||||||
public void readColor(HDPerspectiveState ps, MapIterator mapiter, Color rslt, int blkid, int lastblocktype) {
|
public void readColor(HDPerspectiveState ps, MapIterator mapiter, Color rslt, int blkid, int lastblocktype, boolean biome_shaded) {
|
||||||
int blkdata = ps.getBlockData();
|
int blkdata = ps.getBlockData();
|
||||||
HDTextureMap map = HDTextureMap.getMap(blkid, blkdata);
|
HDTextureMap map = HDTextureMap.getMap(blkid, blkdata);
|
||||||
BlockStep laststep = ps.getLastBlockStep();
|
BlockStep laststep = ps.getLastBlockStep();
|
||||||
@ -797,7 +803,7 @@ public class TexturePack {
|
|||||||
switch(textop) {
|
switch(textop) {
|
||||||
case COLORMOD_GRASSTONED:
|
case COLORMOD_GRASSTONED:
|
||||||
li = imgs[IMG_GRASSCOLOR];
|
li = imgs[IMG_GRASSCOLOR];
|
||||||
if(li.argb == null) {
|
if((li.argb == null) || (!biome_shaded)) {
|
||||||
rslt.blendColor(li.trivial_color);
|
rslt.blendColor(li.trivial_color);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -806,7 +812,7 @@ public class TexturePack {
|
|||||||
break;
|
break;
|
||||||
case COLORMOD_FOLIAGETONED:
|
case COLORMOD_FOLIAGETONED:
|
||||||
li = imgs[IMG_FOLIAGECOLOR];
|
li = imgs[IMG_FOLIAGECOLOR];
|
||||||
if(li.argb == null) {
|
if((li.argb == null) || (!biome_shaded)) {
|
||||||
rslt.blendColor(li.trivial_color);
|
rslt.blendColor(li.trivial_color);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -2,6 +2,7 @@ package org.dynmap.hdmap;
|
|||||||
|
|
||||||
import static org.dynmap.JSONUtils.s;
|
import static org.dynmap.JSONUtils.s;
|
||||||
|
|
||||||
|
import org.bukkit.World.Environment;
|
||||||
import org.dynmap.Color;
|
import org.dynmap.Color;
|
||||||
import org.dynmap.ConfigurationNode;
|
import org.dynmap.ConfigurationNode;
|
||||||
import org.dynmap.Log;
|
import org.dynmap.Log;
|
||||||
@ -13,11 +14,13 @@ public class TexturePackHDShader implements HDShader {
|
|||||||
private String tpname;
|
private String tpname;
|
||||||
private String name;
|
private String name;
|
||||||
private TexturePack tp;
|
private TexturePack tp;
|
||||||
|
private boolean biome_shaded;
|
||||||
|
|
||||||
public TexturePackHDShader(ConfigurationNode configuration) {
|
public TexturePackHDShader(ConfigurationNode configuration) {
|
||||||
tpname = configuration.getString("texturepack", "minecraft");
|
tpname = configuration.getString("texturepack", "minecraft");
|
||||||
name = configuration.getString("name", tpname);
|
name = configuration.getString("name", tpname);
|
||||||
tp = TexturePack.getTexturePack(tpname);
|
tp = TexturePack.getTexturePack(tpname);
|
||||||
|
biome_shaded = configuration.getBoolean("biomeshaded", true);
|
||||||
if(tp == null) {
|
if(tp == null) {
|
||||||
Log.severe("Error: shader '" + name + "' cannot load texture pack '" + tpname + "'");
|
Log.severe("Error: shader '" + name + "' cannot load texture pack '" + tpname + "'");
|
||||||
}
|
}
|
||||||
@ -30,7 +33,7 @@ public class TexturePackHDShader implements HDShader {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isRawBiomeDataNeeded() {
|
public boolean isRawBiomeDataNeeded() {
|
||||||
return true;
|
return biome_shaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -67,8 +70,9 @@ public class TexturePackHDShader implements HDShader {
|
|||||||
private TexturePack scaledtp;
|
private TexturePack scaledtp;
|
||||||
private HDLighting lighting;
|
private HDLighting lighting;
|
||||||
private int lastblkid;
|
private int lastblkid;
|
||||||
|
private boolean do_biome_shading;
|
||||||
|
|
||||||
private OurShaderState(MapIterator mapiter, HDMap map) {
|
private OurShaderState(MapIterator mapiter, HDMap map, MapChunkCache cache) {
|
||||||
this.mapiter = mapiter;
|
this.mapiter = mapiter;
|
||||||
this.map = map;
|
this.map = map;
|
||||||
this.lighting = map.getLighting();
|
this.lighting = map.getLighting();
|
||||||
@ -82,6 +86,8 @@ public class TexturePackHDShader implements HDShader {
|
|||||||
}
|
}
|
||||||
c = new Color();
|
c = new Color();
|
||||||
scaledtp = tp.resampleTexturePack(map.getPerspective().getModelScale());
|
scaledtp = tp.resampleTexturePack(map.getPerspective().getModelScale());
|
||||||
|
/* Biome raw data only works on normal worlds at this point */
|
||||||
|
do_biome_shading = biome_shaded && (cache.getWorld().getEnvironment() != Environment.NORMAL);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Get our shader
|
* Get our shader
|
||||||
@ -126,7 +132,7 @@ public class TexturePackHDShader implements HDShader {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
/* Get color from textures */
|
/* Get color from textures */
|
||||||
scaledtp.readColor(ps, mapiter, c, blocktype, lastblocktype);
|
scaledtp.readColor(ps, mapiter, c, blocktype, lastblocktype, do_biome_shading);
|
||||||
|
|
||||||
if (c.getAlpha() > 0) {
|
if (c.getAlpha() > 0) {
|
||||||
int subalpha = ps.getSubmodelAlpha();
|
int subalpha = ps.getSubmodelAlpha();
|
||||||
@ -210,7 +216,7 @@ public class TexturePackHDShader implements HDShader {
|
|||||||
* @return state object to use for all rays in tile
|
* @return state object to use for all rays in tile
|
||||||
*/
|
*/
|
||||||
public HDShaderState getStateInstance(HDMap map, MapChunkCache cache, MapIterator mapiter) {
|
public HDShaderState getStateInstance(HDMap map, MapChunkCache cache, MapIterator mapiter) {
|
||||||
return new OurShaderState(mapiter, map);
|
return new OurShaderState(mapiter, map, cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add shader's contributions to JSON for map object */
|
/* Add shader's contributions to JSON for map object */
|
||||||
|
@ -541,4 +541,7 @@ public class LegacyMapChunkCache implements MapChunkCache {
|
|||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
public World getWorld() {
|
||||||
|
return w;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -96,4 +96,8 @@ public interface MapChunkCache {
|
|||||||
* Set autogenerate - must be done after at least one visible range has been set
|
* Set autogenerate - must be done after at least one visible range has been set
|
||||||
*/
|
*/
|
||||||
public void setAutoGenerateVisbileRanges(DynmapWorld.AutoGenerateOption do_generate);
|
public void setAutoGenerateVisbileRanges(DynmapWorld.AutoGenerateOption do_generate);
|
||||||
|
/**
|
||||||
|
* Get world
|
||||||
|
*/
|
||||||
|
public World getWorld();
|
||||||
}
|
}
|
||||||
|
@ -629,4 +629,9 @@ public class NewMapChunkCache implements MapChunkCache {
|
|||||||
this.blockdata = blockdata;
|
this.blockdata = blockdata;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public World getWorld() {
|
||||||
|
return w;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -43,3 +43,9 @@ shaders:
|
|||||||
name: stdtexture
|
name: stdtexture
|
||||||
texturepack: standard
|
texturepack: standard
|
||||||
|
|
||||||
|
- class: org.dynmap.hdmap.TexturePackHDShader
|
||||||
|
name: stdtexture-nobiome
|
||||||
|
texturepack: standard
|
||||||
|
biomeshaded: false
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user