diff --git a/src/projectzombie/Main.java b/src/projectzombie/Main.java index 09bb4e6..7575ca1 100755 --- a/src/projectzombie/Main.java +++ b/src/projectzombie/Main.java @@ -3,6 +3,7 @@ package projectzombie; import java.io.IOException; import java.util.Random; +import gl_engine.MathHelpers; import mainloop.manager.MainloopManager; import projectzombie.audio.AudioEngine; import projectzombie.audio.AudioSources; @@ -62,6 +63,9 @@ public class Main public static void main(String[] args) throws IOException { + // Initialize math + MathHelpers.init(); + worker = new Worker(); worker.start(); diff --git a/src/projectzombie/display/lighting/TileLighting.java b/src/projectzombie/display/DisplayLighting.java similarity index 87% rename from src/projectzombie/display/lighting/TileLighting.java rename to src/projectzombie/display/DisplayLighting.java index 8a40fbc..f6778c0 100755 --- a/src/projectzombie/display/lighting/TileLighting.java +++ b/src/projectzombie/display/DisplayLighting.java @@ -1,8 +1,9 @@ -package projectzombie.display.lighting; +package projectzombie.display; import java.nio.ByteBuffer; import java.util.Arrays; +import org.lwjgl.BufferUtils; import org.lwjgl.opengl.GL33; import bdf.types.BdfNamedList; @@ -12,7 +13,6 @@ import gl_engine.range.Range2i; import gl_engine.vec.Vec2d; import gl_engine.vec.Vec2i; import projectzombie.Main; -import projectzombie.display.Camera; import projectzombie.entity.Entity; import projectzombie.entity.player.EntityPlayer; import projectzombie.util.math.TileState; @@ -20,7 +20,7 @@ import projectzombie.world.chunk.Chunk; import projectzombie.world.chunk.ChunkEventHandler; import projectzombie.world.layer.Layer; -public class TileLighting +public class DisplayLighting { private static class Lighting { float[] p; @@ -48,10 +48,10 @@ public class TileLighting } private synchronized static void setLighting(Lighting lighting) { - TileLighting.lighting = lighting; + DisplayLighting.lighting = lighting; } - public TileLighting() { + public DisplayLighting() { lightmap = GL33.glGenTextures(); } @@ -255,9 +255,29 @@ public class TileLighting } } + ByteBuffer pixels_b = BufferUtils.createByteBuffer(pixels.length); + + for(int i=0;i -{ - private Map2D chunks = new Map2D(this); - - public final int RENDER_DISTANCE = Chunk.RENDER_DISTANCE; - - @Override - public ChunkLightingTemp getEmpty(Vec2i pos) { - return new ChunkLightingTemp(); - } - - private Vec2i getChunkPosFromPos(Vec2i pos) { - return this.getChunkPosFromPos(new Vec2d(pos.x, pos.y)); - } - - private Vec2i getChunkPosFromPos(Vec2d pos) { - return new Vec2i( - MathHelpers.floor(pos.x / (double)Chunk.CHUNK_SIZE.mx), - MathHelpers.floor(pos.y / (double)Chunk.CHUNK_SIZE.my)); - } - - public ChunkLightingTemp getChunkwCPos(Vec2i cpos) { - if(!chunks.contains(cpos)) { - ChunkLightingTemp chunk = new ChunkLightingTemp(); - chunks.set(cpos, chunk); - return chunk; - } else { - return chunks.get(cpos); - } - } - - public ChunkLightingTemp getChunk(Vec2i pos) { - return getChunkwCPos(getChunkPosFromPos(pos)); - } - - public ChunkLightingTemp getChunk(Vec2d pos) { - return getChunkwCPos(getChunkPosFromPos(pos)); - } -} diff --git a/src/projectzombie/display/lighting/ChunkLightingTemp.java b/src/projectzombie/display/lighting/ChunkLightingTemp.java deleted file mode 100755 index 1e91a38..0000000 --- a/src/projectzombie/display/lighting/ChunkLightingTemp.java +++ /dev/null @@ -1,49 +0,0 @@ -package projectzombie.display.lighting; - -import gl_engine.vec.Vec2i; -import projectzombie.world.chunk.Chunk; - -public class ChunkLightingTemp -{ - private byte lighting_daylight[] = new byte[Chunk.CHUNK_INDEX]; - private byte lighting_light[] = new byte[Chunk.CHUNK_INDEX]; - - public ChunkLightingTemp() { - for(int i=0;i Chunk.RENDER_DISTANCE) { - return; - } - - // Get the light pos id - int lid = lpos.getId(Chunk.CHUNK_SIZE); - - // Get the light dissipation amount - Chunk chunk = layer.getChunk(lpos); - TileState bt = chunk.getBackTile(lid); - TileState ft = chunk.getFrontTile(lid); - - double light_dissipation = MathHelpers.biggest( - bt.tile.getLightDissipation(bt), - ft.tile.getLightDissipation(ft)); - - // Calculate the light level - double light_tile = chunk.getDynamicLightLevel(lid); - if(light <= light_tile) { - return; - } - - // Merge the light and the light tile values - chunk.setDynamicLightLevel(light, lid); - - // Get all the adjacent positions of the light tiles to flow onto - Vec2i positions[] = { - new Vec2i(lpos.x+1, lpos.y), - new Vec2i(lpos.x-1, lpos.y), - new Vec2i(lpos.x, lpos.y+1), - new Vec2i(lpos.x, lpos.y-1) - }; - - // Add the light to all the adjacent positions - for(Vec2i position : positions) { - addLightToTiles(layer, position, light - light_dissipation); - } - } -} diff --git a/src/projectzombie/entity/player/EntityPlayer.java b/src/projectzombie/entity/player/EntityPlayer.java index d6aae90..0d9d223 100755 --- a/src/projectzombie/entity/player/EntityPlayer.java +++ b/src/projectzombie/entity/player/EntityPlayer.java @@ -7,7 +7,7 @@ import gl_engine.vec.Vec2d; import gl_engine.vec.Vec2i; import mainloop.task.IMainloopTask; import projectzombie.Main; -import projectzombie.display.lighting.TileLighting; +import projectzombie.display.DisplayLighting; import projectzombie.entity.Entity; import projectzombie.entity.EntityAlive; import projectzombie.entity.EntityBullet; @@ -136,7 +136,7 @@ public class EntityPlayer extends Entity implements EntityAlive, EntityInventory if(chunk != null && chunk.c_pos != null && (last_chunk == null || !chunk.c_pos.equal(last_chunk))) { last_chunk = chunk.c_pos; - TileLighting.setDirty(); + DisplayLighting.setDirty(); } if(dead) return; diff --git a/src/projectzombie/init/Models.java b/src/projectzombie/init/Models.java index cff656f..bc61fa1 100755 --- a/src/projectzombie/init/Models.java +++ b/src/projectzombie/init/Models.java @@ -3,6 +3,7 @@ package projectzombie.init; import gl_engine.vec.Vec2d; import projectzombie.model.Model; import projectzombie.model.ModelEmpty; +import projectzombie.model.ModelGrass; import projectzombie.model.ModelGui; import projectzombie.model.ModelItem; import projectzombie.model.ModelRandom; @@ -13,7 +14,7 @@ public class Models { public static final Model EMPTY = new ModelEmpty(); - public static final Model TILE_GRASS = new ModelTile(Resources.ATLAS.get("/tile/grass.png")); + public static final Model TILE_GRASS = new ModelGrass(); public static final Model TILE_SAND = new ModelTile(Resources.ATLAS.get("/tile/sand.png")); public static final Model TILE_STONE = new ModelTile(Resources.ATLAS.get("/tile/stone.png")); public static final Model TILE_DIRT = new ModelTile(Resources.ATLAS.get("/tile/dirt.png")); diff --git a/src/projectzombie/model/ModelGrass.java b/src/projectzombie/model/ModelGrass.java new file mode 100644 index 0000000..a142d3a --- /dev/null +++ b/src/projectzombie/model/ModelGrass.java @@ -0,0 +1,51 @@ +package projectzombie.model; + +import gl_engine.texture.TextureRef3D; +import projectzombie.init.Resources; + +public class ModelGrass extends Model +{ + private static final TextureRef3D GRASS = Resources.ATLAS.get("/tile/grass.png"); + + @Override + public int getSize() { + return 4; + } + + @Override + public int[] getIndicies() { + return new int[] { + 0, 1, 2, + 2, 3, 0, + }; + } + + @Override + public float[] getVerticies() + { + return new float[] { + 0.5f, 0, 0.5f, 1, 1, 0, GRASS.sy, GRASS.ey, 0, 0, 0, 1, 1, 0x100, + 0.5f, 0, -0.5f, 1, 0, 0, GRASS.sy, GRASS.ey, 0, 0, 0, 1, 1, 0x100, + -0.5f, 0, -0.5f, 0, 0, 0, GRASS.sy, GRASS.ey, 0, 0, 0, 1, 1, 0x100, + -0.5f, 0, 0.5f, 0, 1, 0, GRASS.sy, GRASS.ey, 0, 0, 0, 1, 1, 0x100, + }; + } + + @Override + public int getIndexSize() { + return 6; + } + + @Override + public TextureRef3D[] getTextures() + { + return new TextureRef3D[] { + GRASS, GRASS, GRASS, GRASS + }; + } + + @Override + public double getHeight() { + return 1; + } +} diff --git a/src/projectzombie/util/math/TileState.java b/src/projectzombie/util/math/TileState.java index 1a9167d..285f906 100755 --- a/src/projectzombie/util/math/TileState.java +++ b/src/projectzombie/util/math/TileState.java @@ -10,7 +10,7 @@ public class TileState public Tile tile; public byte meta; - public Vec3d light; + public double light; public TileState(Tile tile, byte meta) { this.tile = tile; @@ -21,7 +21,7 @@ public class TileState this(tile, (byte)meta); } - public TileState withLightLevel(Vec3d level) { + public TileState withLightLevel(double level) { TileState ts = new TileState(tile, meta); ts.light = level; return ts; diff --git a/src/projectzombie/worker/Worker.java b/src/projectzombie/worker/Worker.java index 0d3fdc1..e7ce624 100644 --- a/src/projectzombie/worker/Worker.java +++ b/src/projectzombie/worker/Worker.java @@ -9,7 +9,7 @@ import java.nio.ByteBuffer; import bdf.data.BdfDatabase; import bdf.types.BdfNamedList; import bdf.types.BdfObject; -import projectzombie.display.lighting.TileLighting; +import projectzombie.display.DisplayLighting; public class Worker extends Thread { @@ -103,7 +103,7 @@ public class Worker extends Thread switch(nl.get("task").getString()) { case "light": - TileLighting.updateLighting(bdf); + DisplayLighting.updateLighting(bdf); break; default: Thread.sleep(10); diff --git a/src/projectzombie/world/World.java b/src/projectzombie/world/World.java index 94b77a2..105d6ad 100755 --- a/src/projectzombie/world/World.java +++ b/src/projectzombie/world/World.java @@ -8,7 +8,7 @@ import bdf.types.BdfNamedList; import bdf.types.BdfObject; import projectzombie.Main; import projectzombie.display.Camera; -import projectzombie.display.lighting.TileLighting; +import projectzombie.display.DisplayLighting; import projectzombie.entity.player.EntityPlayer; import projectzombie.time.GameTimer; import projectzombie.world.chunk.ChunkEventHandler; @@ -34,8 +34,8 @@ public class World implements IBdfClassManager public void setLayer(int id) { ChunkEventHandler.loaded = false; - TileLighting.clearLighting(); - TileLighting.setDirty(); + DisplayLighting.clearLighting(); + DisplayLighting.setDirty(); this.loaded = layers.get(id); } diff --git a/src/projectzombie/world/chunk/Chunk.java b/src/projectzombie/world/chunk/Chunk.java index b8a4d3a..9ba99de 100755 --- a/src/projectzombie/world/chunk/Chunk.java +++ b/src/projectzombie/world/chunk/Chunk.java @@ -46,9 +46,8 @@ public class Chunk implements IBdfClassManager private Tile tiles_front[] = new Tile[CHUNK_INDEX]; private byte tiles_front_meta[] = new byte[CHUNK_INDEX]; private byte tiles_back_meta[] = new byte[CHUNK_INDEX]; - private byte tiles_lighting[] = new byte[CHUNK_INDEX]; - private byte tiles_lighting_dynamic[] = new byte[CHUNK_INDEX]; - private byte tiles_lighting_daylight[] = new byte[CHUNK_INDEX]; + private byte tiles_lighting_src[] = new byte[CHUNK_INDEX]; + private byte tiles_lighting_day[] = new byte[CHUNK_INDEX]; public ArrayList entities = new ArrayList(); private Layer layer; public Vec2i c_pos; @@ -96,14 +95,14 @@ public class Chunk implements IBdfClassManager byte[] mb = nl.get("mb").getByteArray(); byte[] mf = nl.get("mf").getByteArray(); - for(int i=0;i light.x) light.x = light_level; - if(light_level > light.y) light.y = light_level; - if(light_level > light.z) light.z = light_level; - - return light; - } - public void breakBackTile(Vec2i pos) { TileState ts = getBackTile(pos); @@ -471,7 +452,7 @@ public class Chunk implements IBdfClassManager } public double getLightLevel(int id) { - return tiles_lighting[id] / (double)Byte.MAX_VALUE; + return tiles_lighting_src[id] / (double)Byte.MAX_VALUE; } public double getLightLevel(Vec2i pos) @@ -486,7 +467,7 @@ public class Chunk implements IBdfClassManager } public double getDaylightLevel(int id) { - return tiles_lighting_daylight[id] / (double)Byte.MAX_VALUE; + return tiles_lighting_day[id] / (double)Byte.MAX_VALUE; } public double getDaylightLevel(Vec2i pos) @@ -501,7 +482,7 @@ public class Chunk implements IBdfClassManager } public void setLightLevel(double light, int id) { - this.tiles_lighting[id] = (byte)(light * Byte.MAX_VALUE); + this.tiles_lighting_src[id] = (byte)(light * Byte.MAX_VALUE); } public void setLightLevel(double light, Vec2i pos) @@ -516,7 +497,7 @@ public class Chunk implements IBdfClassManager } public void setDaylightLevel(double light, int id) { - this.tiles_lighting_daylight[id] = (byte)(light * Byte.MAX_VALUE); + this.tiles_lighting_day[id] = (byte)(light * Byte.MAX_VALUE); } public void setDaylightLevel(double light, Vec2i pos) @@ -530,36 +511,6 @@ public class Chunk implements IBdfClassManager setDaylightLevel(light, id); } - public double getDynamicLightLevel(int id) { - return tiles_lighting_dynamic[id] / (double)Byte.MAX_VALUE; - } - - public double getDynamicLightLevel(Vec2i pos) - { - // Get the id - Vec2i cpos = new Vec2i(0, 0); - cpos.x = MathHelpers.mod(pos.x, CHUNK_SIZE.mx); - cpos.y = MathHelpers.mod(pos.y, CHUNK_SIZE.my); - int id = cpos.getId(CHUNK_SIZE); - - return getDynamicLightLevel(id); - } - - public void setDynamicLightLevel(double light, int id) { - this.tiles_lighting_dynamic[id] = (byte)(light * Byte.MAX_VALUE); - } - - public void setDynamicLightLevel(double light, Vec2i pos) - { - // Get the id - Vec2i cpos = new Vec2i(0, 0); - cpos.x = MathHelpers.mod(pos.x, CHUNK_SIZE.mx); - cpos.y = MathHelpers.mod(pos.y, CHUNK_SIZE.my); - int id = cpos.getId(CHUNK_SIZE); - - setDynamicLightLevel(light, id); - } - public void killEntity(Entity e) { if(e instanceof EntityKillWithParticles) { diff --git a/src/projectzombie/world/chunk/ChunkEmpty.java b/src/projectzombie/world/chunk/ChunkEmpty.java index 5c2c762..6db34af 100755 --- a/src/projectzombie/world/chunk/ChunkEmpty.java +++ b/src/projectzombie/world/chunk/ChunkEmpty.java @@ -25,16 +25,6 @@ public class ChunkEmpty extends Chunk public void BdfClassSave(BdfObject bdf) { } - @Override - public Vec3d getRGBLightLevel(int id) { - return new Vec3d(0, 0, 0); - } - - @Override - public Vec3d getRGBLightLevel(Vec2i tpos) { - return new Vec3d(0, 0, 0); - } - @Override public void render(Camera camera) {} @@ -117,21 +107,12 @@ public class ChunkEmpty extends Chunk } @Override - public double getDynamicLightLevel(int id) { - return 0; + public boolean isLightDirty() { + return false; } @Override - public double getDynamicLightLevel(Vec2i pos) { - return 0; - } - - @Override - public void setDynamicLightLevel(double light, int id) { - } - - @Override - public void setDynamicLightLevel(double light, Vec2i pos) { + public void resetLightDirty() { } @Override diff --git a/src/projectzombie/world/chunk/ChunkEventHandler.java b/src/projectzombie/world/chunk/ChunkEventHandler.java index f3d35b1..268a842 100755 --- a/src/projectzombie/world/chunk/ChunkEventHandler.java +++ b/src/projectzombie/world/chunk/ChunkEventHandler.java @@ -4,7 +4,7 @@ import gl_engine.MathHelpers; import gl_engine.vec.Vec2i; import mainloop.task.IMainloopTask; import projectzombie.Main; -import projectzombie.display.lighting.TileLighting; +import projectzombie.display.DisplayLighting; import projectzombie.util.math.map.Map2DElement; import projectzombie.world.layer.Layer; @@ -67,7 +67,7 @@ public class ChunkEventHandler implements IMainloopTask } } - TileLighting.update(); + DisplayLighting.update(); } } diff --git a/src/projectzombie/world/layer/Layer.java b/src/projectzombie/world/layer/Layer.java index 956cf63..250398d 100755 --- a/src/projectzombie/world/layer/Layer.java +++ b/src/projectzombie/world/layer/Layer.java @@ -17,6 +17,7 @@ import projectzombie.init.LayerGenerators; import projectzombie.util.math.TileState; import projectzombie.util.math.map.Map2D; import projectzombie.util.math.map.Map2DElement; +import projectzombie.util.math.random.OpenSimplexNoise; import projectzombie.world.chunk.Chunk; import projectzombie.world.layer.layergen.LayerGen; @@ -24,6 +25,7 @@ public class Layer implements IBdfClassManager { public Map2D chunks; private Map2D dirty_chunks; + public OpenSimplexNoise[] noise_gens; public LayerGen layergen; private Random rand; public long lseed; @@ -39,6 +41,8 @@ public class Layer implements IBdfClassManager this.lseed = this.rand.nextLong(); this.chunks = new Map2D(layergen); this.dirty_chunks = new Map2D(layergen); + + this.layergen.init(this); } public Layer(BdfObject bdf) { @@ -161,24 +165,6 @@ public class Layer implements IBdfClassManager chunks.get(c_pos).setLightLevel(light, pos); } - public double getDynamicLightLevel(Vec2i pos) - { - // Get the chunk pos - Vec2i c_pos = getChunkPosFromPos(pos); - - // Get the chunks front tile - return chunks.get(c_pos).getDynamicLightLevel(pos); - } - - public void setDynamicLightLevel(double light, Vec2i pos) - { - // Get the chunk pos - Vec2i c_pos = getChunkPosFromPos(pos); - - // Get the chunks front tile - chunks.get(c_pos).setDynamicLightLevel(light, pos); - } - public double getDaylightLevel(Vec2i pos) { // Get the chunk pos diff --git a/src/projectzombie/world/layer/layergen/LayerGen.java b/src/projectzombie/world/layer/layergen/LayerGen.java index 4c1f95a..98cf4ed 100755 --- a/src/projectzombie/world/layer/layergen/LayerGen.java +++ b/src/projectzombie/world/layer/layergen/LayerGen.java @@ -2,6 +2,7 @@ package projectzombie.world.layer.layergen; import java.util.Random; +import gl_engine.vec.Vec2d; import gl_engine.vec.Vec2i; import projectzombie.util.math.ColorRange; import projectzombie.util.math.TileState; @@ -15,10 +16,16 @@ public abstract class LayerGen implements IMap2D public boolean destroyOnLeave = false; public abstract void generateChunk(Chunk chunk, Layer layer, Random rand, Vec2i pos); + public abstract double getTemperatureStatic(Layer layer, Vec2d pos); + public abstract double getTemperatureDynamic(Layer layer, Vec2d pos); public abstract void spawnEntities(Layer layer, Random rand); public abstract TileState getTileDestroyed(); public abstract ColorRange getLightLevel(); + public void init(Layer layer) { + + } + @Override public Chunk getEmpty(Vec2i pos) { return Chunk.CHUNK_EMPTY; diff --git a/src/projectzombie/world/layer/layergen/LayerGenBossArena.java b/src/projectzombie/world/layer/layergen/LayerGenBossArena.java index 3f0cc46..9bd11fa 100755 --- a/src/projectzombie/world/layer/layergen/LayerGenBossArena.java +++ b/src/projectzombie/world/layer/layergen/LayerGenBossArena.java @@ -114,5 +114,15 @@ public class LayerGenBossArena extends LayerGen implements LayerGenRememberPlaye RandomHelpers.randrange(rand, -size + 2, size - 2), RandomHelpers.randrange(rand, -size + 2, size - 2)); } + + @Override + public double getTemperatureStatic(Layer layer, Vec2d pos) { + return 0.8; + } + + @Override + public double getTemperatureDynamic(Layer layer, Vec2d pos) { + return 0.8; + } } diff --git a/src/projectzombie/world/layer/layergen/LayerGenCaves.java b/src/projectzombie/world/layer/layergen/LayerGenCaves.java index 3026b18..ac7cb9d 100755 --- a/src/projectzombie/world/layer/layergen/LayerGenCaves.java +++ b/src/projectzombie/world/layer/layergen/LayerGenCaves.java @@ -118,5 +118,15 @@ public class LayerGenCaves extends LayerGen public ColorRange getLightLevel() { return new ColorRange(new Vec3d(0, 0, 0), new Vec3d(0, 0, 0)); } + + @Override + public double getTemperatureStatic(Layer layer, Vec2d pos) { + return 0.5; + } + + @Override + public double getTemperatureDynamic(Layer layer, Vec2d pos) { + return 0.5; + } } diff --git a/src/projectzombie/world/layer/layergen/LayerGenEarth.java b/src/projectzombie/world/layer/layergen/LayerGenEarth.java index da27763..b07a985 100755 --- a/src/projectzombie/world/layer/layergen/LayerGenEarth.java +++ b/src/projectzombie/world/layer/layergen/LayerGenEarth.java @@ -2,6 +2,7 @@ package projectzombie.world.layer.layergen; import java.util.Random; +import gl_engine.MathHelpers; import gl_engine.vec.Vec2d; import gl_engine.vec.Vec2i; import gl_engine.vec.Vec3d; @@ -20,6 +21,34 @@ import projectzombie.world.layer.Layer; public class LayerGenEarth extends LayerGen { + @Override + public double getTemperatureStatic(Layer layer, Vec2d pos) + { + // Get the noise generator + OpenSimplexNoise terrain_noise = layer.noise_gens[0]; + return MathHelpers.map(terrain_noise.eval(pos.x/64.0, pos.y/64.0), -1, 1, 0, 0.7); + } + + @Override + public double getTemperatureDynamic(Layer layer, Vec2d pos) + { + // Get the noise generator + double light = (getEarthLight() + 1) * 0.2; + OpenSimplexNoise terrain_noise = layer.noise_gens[0]; + return MathHelpers.map(terrain_noise.eval(pos.x/64.0, pos.y/64.0), -1, 1, light, 0.5 + light); + } + + @Override + public void init(Layer layer) { + super.init(layer); + + Random rand = new Random(layer.lseed); + + layer.noise_gens = new OpenSimplexNoise[] { + new OpenSimplexNoise(rand.nextLong()), + }; + } + @Override public void generateChunk(Chunk chunk, Layer layer, Random rand, Vec2i c_pos) { @@ -31,38 +60,25 @@ public class LayerGenEarth extends LayerGen RandomHelpers.randrange(rand, Chunk.CHUNK_SIZE.my)); // Get the noise generator - Random rand_seed = new Random(layer.lseed); - OpenSimplexNoise noisegen_n = new OpenSimplexNoise(rand_seed.nextLong()); + OpenSimplexNoise noise_terrain = layer.noise_gens[0]; // Loop over the layer dimensions and create land for(int x=0;x 0.5) { + chunk.setBackTile(Tiles.DIRT.getDefaultState(), pos.toInt()); + } - // Tree and rock generation - if(!chunk.getBackTile(pos).tile.tileSolid && noise_n >= 40) { - if(rand.nextDouble() > 0.9) chunk.setFrontTile(new TileState(Tiles.TREE, - (short)RandomHelpers.randrange(rand, Short.MAX_VALUE)), pos); - else if(rand.nextDouble() > 0.99) chunk.setFrontTile(new TileState(Tiles.ROCK, - (short)RandomHelpers.randrange(rand, Short.MAX_VALUE)), pos); - else chunk.setFrontTile(Tiles.VOID.getDefaultState(), pos); + else { + chunk.setBackTile(Tiles.GRASS.getDefaultState(), pos.toInt()); } } } @@ -104,7 +120,7 @@ public class LayerGenEarth extends LayerGen } private double getEarthLight() { - return Math.sin(GameTimer.getTime() / 7200.0); + return MathHelpers.sin(GameTimer.getTime() / 7200.0); } @Override diff --git a/src/projectzombie/world/layer/layergen/LayerGenLavaCaves.java b/src/projectzombie/world/layer/layergen/LayerGenLavaCaves.java index 29fecaf..248594b 100755 --- a/src/projectzombie/world/layer/layergen/LayerGenLavaCaves.java +++ b/src/projectzombie/world/layer/layergen/LayerGenLavaCaves.java @@ -160,5 +160,15 @@ public class LayerGenLavaCaves extends LayerGen public ColorRange getLightLevel() { return new ColorRange(new Vec3d(0, 0, 0), new Vec3d(0, 0, 0)); } + + @Override + public double getTemperatureStatic(Layer layer, Vec2d pos) { + return 0.7; + } + + @Override + public double getTemperatureDynamic(Layer layer, Vec2d pos) { + return 0.7; + } } diff --git a/src/resources/shader/environmentRenderer.fsh b/src/resources/shader/environmentRenderer.fsh index faa3675..5941631 100644 --- a/src/resources/shader/environmentRenderer.fsh +++ b/src/resources/shader/environmentRenderer.fsh @@ -4,6 +4,8 @@ in vec3 pPos; in vec3 pTexture; in vec3 pLightMapPos; +flat in int pFlags; + out vec4 FragColor; uniform sampler3D atlas; @@ -18,6 +20,9 @@ uniform vec2 lightmap_size; uniform vec2 tex_cut; uniform vec4 color; +uniform vec3 color_grass_min; +uniform vec3 color_grass_max; + float map(float x, float in_min, float in_max, float out_min, float out_max) { return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; } @@ -44,8 +49,12 @@ void main() vec3 light_day = mapVec(scaleLight(light.r), 0, 1, lighting_day_low, lighting_day_high); vec3 light_src = vec3(1, 1, 1) * (scaleLight(light.g) - abs(pLightMapPos.y) * 0.1); + + vec4 color_white = vec4(1, 1, 1, 1); + vec4 color_grass = vec4(mapVec(light.b, 0, 1, color_grass_min, color_grass_max), 1); - FragColor = texture(atlas, pTexture) * color * vec4(biggest(light_day, light_src), 1); + FragColor = texture(atlas, pTexture) * (mod(pFlags >> 2, 1) == 1 ? color_grass : color_white) * + color * vec4(biggest(light_day, light_src), 1); discard(FragColor.a == 0 || (pPos.x > tex_cut.y && tex_cut.x > 0.5)); } \ No newline at end of file diff --git a/src/resources/shader/environmentRenderer.vsh b/src/resources/shader/environmentRenderer.vsh index 37c6473..90d638e 100644 --- a/src/resources/shader/environmentRenderer.vsh +++ b/src/resources/shader/environmentRenderer.vsh @@ -7,10 +7,11 @@ layout (location = 3) in vec3 aChunkOffset; layout (location = 4) in vec3 aFlags; out vec3 pLightMapPos; -out vec3 pLighting; out vec3 pTexture; out vec3 pPos; +flat out int pFlags; + uniform mat4 projection; uniform mat4 model; uniform mat4 rotated; @@ -61,5 +62,6 @@ void main() pLightMapPos = pos.xyz; pTexture = vec3(aTex.x, getTexY(), aTex.z); + pFlags = type; pPos = aPos; } \ No newline at end of file diff --git a/src/resources/texture/tile/sand.png b/src/resources/texture/tile/sand.png index 6092478..0d7016d 100644 Binary files a/src/resources/texture/tile/sand.png and b/src/resources/texture/tile/sand.png differ