Add shader option to disable biome shading, disable biome shading on non-normal worlds

This commit is contained in:
Mike Primm 2011-07-24 17:14:45 -05:00
parent 62b42aa302
commit 78f571a68b
7 changed files with 40 additions and 10 deletions

View File

@ -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 */
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-";

View File

@ -374,10 +374,16 @@ public class TexturePack {
}
}
/* All the same - no biome lookup needed */
if(same)
if(same) {
imgs[idx].argb = null;
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 */
private void patchTextureWithImage(int image_idx, int block_idx) {
@ -694,7 +700,7 @@ public class TexturePack {
/**
* 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();
HDTextureMap map = HDTextureMap.getMap(blkid, blkdata);
BlockStep laststep = ps.getLastBlockStep();
@ -797,7 +803,7 @@ public class TexturePack {
switch(textop) {
case COLORMOD_GRASSTONED:
li = imgs[IMG_GRASSCOLOR];
if(li.argb == null) {
if((li.argb == null) || (!biome_shaded)) {
rslt.blendColor(li.trivial_color);
}
else {
@ -806,7 +812,7 @@ public class TexturePack {
break;
case COLORMOD_FOLIAGETONED:
li = imgs[IMG_FOLIAGECOLOR];
if(li.argb == null) {
if((li.argb == null) || (!biome_shaded)) {
rslt.blendColor(li.trivial_color);
}
else {

View File

@ -2,6 +2,7 @@ package org.dynmap.hdmap;
import static org.dynmap.JSONUtils.s;
import org.bukkit.World.Environment;
import org.dynmap.Color;
import org.dynmap.ConfigurationNode;
import org.dynmap.Log;
@ -13,11 +14,13 @@ public class TexturePackHDShader implements HDShader {
private String tpname;
private String name;
private TexturePack tp;
private boolean biome_shaded;
public TexturePackHDShader(ConfigurationNode configuration) {
tpname = configuration.getString("texturepack", "minecraft");
name = configuration.getString("name", tpname);
tp = TexturePack.getTexturePack(tpname);
biome_shaded = configuration.getBoolean("biomeshaded", true);
if(tp == null) {
Log.severe("Error: shader '" + name + "' cannot load texture pack '" + tpname + "'");
}
@ -30,7 +33,7 @@ public class TexturePackHDShader implements HDShader {
@Override
public boolean isRawBiomeDataNeeded() {
return true;
return biome_shaded;
}
@Override
@ -67,8 +70,9 @@ public class TexturePackHDShader implements HDShader {
private TexturePack scaledtp;
private HDLighting lighting;
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.map = map;
this.lighting = map.getLighting();
@ -82,6 +86,8 @@ public class TexturePackHDShader implements HDShader {
}
c = new Color();
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
@ -126,7 +132,7 @@ public class TexturePackHDShader implements HDShader {
return false;
}
/* 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) {
int subalpha = ps.getSubmodelAlpha();
@ -210,7 +216,7 @@ public class TexturePackHDShader implements HDShader {
* @return state object to use for all rays in tile
*/
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 */

View File

@ -541,4 +541,7 @@ public class LegacyMapChunkCache implements MapChunkCache {
return false;
return true;
}
public World getWorld() {
return w;
}
}

View File

@ -96,4 +96,8 @@ public interface MapChunkCache {
* Set autogenerate - must be done after at least one visible range has been set
*/
public void setAutoGenerateVisbileRanges(DynmapWorld.AutoGenerateOption do_generate);
/**
* Get world
*/
public World getWorld();
}

View File

@ -629,4 +629,9 @@ public class NewMapChunkCache implements MapChunkCache {
this.blockdata = blockdata;
return true;
}
@Override
public World getWorld() {
return w;
}
}

View File

@ -43,3 +43,9 @@ shaders:
name: stdtexture
texturepack: standard
- class: org.dynmap.hdmap.TexturePackHDShader
name: stdtexture-nobiome
texturepack: standard
biomeshaded: false