Added shadow quality setting, updated the BDF to fix boolean
This commit is contained in:
parent
96a0f0fdb9
commit
2946a7ec9e
|
|
@ -41,6 +41,6 @@
|
||||||
<classpathentry kind="lib" path="/home/josua/code/Java Libraries/lwjgl-3.2.2-lightweight/lwjgl-stb-natives-macos.jar"/>
|
<classpathentry kind="lib" path="/home/josua/code/Java Libraries/lwjgl-3.2.2-lightweight/lwjgl-stb-natives-macos.jar"/>
|
||||||
<classpathentry kind="lib" path="/home/josua/code/Java Libraries/lwjgl-3.2.2-lightweight/lwjgl-stb-natives-windows.jar"/>
|
<classpathentry kind="lib" path="/home/josua/code/Java Libraries/lwjgl-3.2.2-lightweight/lwjgl-stb-natives-windows.jar"/>
|
||||||
<classpathentry kind="lib" path="/home/josua/code/Java Libraries/lwjgl-3.2.2-lightweight/lwjgl-stb-sources.jar"/>
|
<classpathentry kind="lib" path="/home/josua/code/Java Libraries/lwjgl-3.2.2-lightweight/lwjgl-stb-sources.jar"/>
|
||||||
<classpathentry kind="lib" path="/home/josua/code/Java Libraries/binary-data-format-v2.1.jar"/>
|
<classpathentry kind="lib" path="/home/josua/code/Java Libraries/binary-data-format-v2.3.jar"/>
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ import gl_engine.vec.Vec3d;
|
||||||
import projectzombie.Main;
|
import projectzombie.Main;
|
||||||
import projectzombie.entity.player.EntityPlayer;
|
import projectzombie.entity.player.EntityPlayer;
|
||||||
import projectzombie.model.Model;
|
import projectzombie.model.Model;
|
||||||
|
import projectzombie.settings.SettingQuality;
|
||||||
import projectzombie.util.math.ColorRange;
|
import projectzombie.util.math.ColorRange;
|
||||||
import projectzombie.world.chunk.Chunk;
|
import projectzombie.world.chunk.Chunk;
|
||||||
import projectzombie.world.chunk.ChunkEventHandler;
|
import projectzombie.world.chunk.ChunkEventHandler;
|
||||||
|
|
@ -24,7 +25,58 @@ public class DisplayRender
|
||||||
{
|
{
|
||||||
public static int shadow_fbo;
|
public static int shadow_fbo;
|
||||||
public static int shadow_depth;
|
public static int shadow_depth;
|
||||||
public static int shadow_size = 2048;
|
public static int shadow_size;
|
||||||
|
private static SettingQuality shadow_quality;
|
||||||
|
|
||||||
|
public static SettingQuality setShadowQuality(SettingQuality quality)
|
||||||
|
{
|
||||||
|
int size;
|
||||||
|
|
||||||
|
switch(quality)
|
||||||
|
{
|
||||||
|
case LOWEST:
|
||||||
|
size = 1024;
|
||||||
|
break;
|
||||||
|
case LOW:
|
||||||
|
size = 2048;
|
||||||
|
break;
|
||||||
|
case MEDIUM:
|
||||||
|
size = 4096;
|
||||||
|
break;
|
||||||
|
case HIGH:
|
||||||
|
size = 8192;
|
||||||
|
break;
|
||||||
|
case EXTREME:
|
||||||
|
size = 16384;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
size = 2048;
|
||||||
|
quality = SettingQuality.LOW;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Main.window != null && size > Main.window.texture_max_size) {
|
||||||
|
quality = SettingQuality.LOWEST;
|
||||||
|
size = 1024;
|
||||||
|
}
|
||||||
|
|
||||||
|
shadow_size = size;
|
||||||
|
shadow_quality = quality;
|
||||||
|
|
||||||
|
return quality;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SettingQuality getShadowQuality() {
|
||||||
|
return shadow_quality;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void updateShadowQuality()
|
||||||
|
{
|
||||||
|
GL33.glBindFramebuffer(GL33.GL_FRAMEBUFFER, shadow_fbo);
|
||||||
|
GL33.glDeleteTextures(shadow_depth);
|
||||||
|
|
||||||
|
shadow_depth = generateDepthTexture(shadow_size, shadow_size);
|
||||||
|
}
|
||||||
|
|
||||||
private static int generateDepthTexture(int width, int height)
|
private static int generateDepthTexture(int width, int height)
|
||||||
{
|
{
|
||||||
|
|
@ -46,23 +98,6 @@ public class DisplayRender
|
||||||
return depth;
|
return depth;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int generateColorTexture(int width, int height)
|
|
||||||
{
|
|
||||||
int color = GL33.glGenTextures();
|
|
||||||
|
|
||||||
GL33.glBindTexture(GL33.GL_TEXTURE_2D, color);
|
|
||||||
|
|
||||||
GL33.glTexImage2D(
|
|
||||||
GL33.GL_TEXTURE_2D, 0, GL33.GL_RGB, width, height,
|
|
||||||
0, GL33.GL_RGB, GL33.GL_FLOAT, (ByteBuffer) null);
|
|
||||||
|
|
||||||
GL33.glTexParameteri(GL33.GL_TEXTURE_2D, GL33.GL_TEXTURE_MIN_FILTER, GL33.GL_LINEAR);
|
|
||||||
GL33.glTexParameteri(GL33.GL_TEXTURE_2D, GL33.GL_TEXTURE_MAG_FILTER, GL33.GL_LINEAR);
|
|
||||||
GL33.glFramebufferTexture(GL33.GL_FRAMEBUFFER, GL33.GL_COLOR_ATTACHMENT0, color, 0);
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void init()
|
public static void init()
|
||||||
{
|
{
|
||||||
shadow_fbo = GL33.glGenFramebuffers();
|
shadow_fbo = GL33.glGenFramebuffers();
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ public class DisplayWindow implements IMainloopTask
|
||||||
private int height;
|
private int height;
|
||||||
private boolean fullscreen = true;
|
private boolean fullscreen = true;
|
||||||
private boolean mouseVisibility_last = false;
|
private boolean mouseVisibility_last = false;
|
||||||
|
public int texture_max_size;
|
||||||
|
|
||||||
public static int fps = 0;
|
public static int fps = 0;
|
||||||
|
|
||||||
|
|
@ -182,6 +183,12 @@ public class DisplayWindow implements IMainloopTask
|
||||||
glVertexAttribPointer(0, 2, GL_FLOAT, false, Float.BYTES * 2, 0);
|
glVertexAttribPointer(0, 2, GL_FLOAT, false, Float.BYTES * 2, 0);
|
||||||
glEnableVertexAttribArray(0);
|
glEnableVertexAttribArray(0);
|
||||||
|
|
||||||
|
int[] ptr = new int[1];
|
||||||
|
GL33.glGetIntegerv(GL33.GL_MAX_TEXTURE_SIZE, ptr);
|
||||||
|
|
||||||
|
texture_max_size = ptr[0];
|
||||||
|
System.out.println("Max texture size: " + texture_max_size);
|
||||||
|
|
||||||
DisplayRender.init();
|
DisplayRender.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -291,7 +291,7 @@ public class EntityPlayer extends Entity implements
|
||||||
|
|
||||||
if(break_progress > ts.tile.hardness)
|
if(break_progress > ts.tile.hardness)
|
||||||
{
|
{
|
||||||
ItemStack[] stacks = ts.tile.getTileDrops(tile_front);
|
ItemStack[] stacks = ts.tile.getTileDrops(ts);
|
||||||
|
|
||||||
for(ItemStack stack : stacks) {
|
for(ItemStack stack : stacks) {
|
||||||
layer.spawnEntity(new EntityItem(
|
layer.spawnEntity(new EntityItem(
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package projectzombie.menu;
|
||||||
|
|
||||||
import gl_engine.vec.Vec2d;
|
import gl_engine.vec.Vec2d;
|
||||||
import projectzombie.Main;
|
import projectzombie.Main;
|
||||||
|
import projectzombie.display.DisplayRender;
|
||||||
import projectzombie.display.DisplayRenderUI;
|
import projectzombie.display.DisplayRenderUI;
|
||||||
import projectzombie.entity.EntityParticle;
|
import projectzombie.entity.EntityParticle;
|
||||||
import projectzombie.input.types.InputGUI;
|
import projectzombie.input.types.InputGUI;
|
||||||
|
|
@ -14,6 +15,7 @@ import projectzombie.menu.gui.components.ButtonBasic;
|
||||||
import projectzombie.menu.gui.components.ButtonSetting;
|
import projectzombie.menu.gui.components.ButtonSetting;
|
||||||
import projectzombie.menu.gui.components.GUIBackToMenu;
|
import projectzombie.menu.gui.components.GUIBackToMenu;
|
||||||
import projectzombie.menu.gui.components.OverlayBackground;
|
import projectzombie.menu.gui.components.OverlayBackground;
|
||||||
|
import projectzombie.settings.SettingQuality;
|
||||||
import projectzombie.settings.Settings;
|
import projectzombie.settings.Settings;
|
||||||
import projectzombie.world.chunk.Chunk;
|
import projectzombie.world.chunk.Chunk;
|
||||||
|
|
||||||
|
|
@ -22,6 +24,18 @@ public class MenuSettings extends Menu
|
||||||
private GUI gui;
|
private GUI gui;
|
||||||
private Menu menuOld;
|
private Menu menuOld;
|
||||||
|
|
||||||
|
public static String render(SettingQuality setting) {
|
||||||
|
switch(setting)
|
||||||
|
{
|
||||||
|
case HIGH: return "High";
|
||||||
|
case MEDIUM: return "Medium";
|
||||||
|
case LOW: return "Low";
|
||||||
|
case EXTREME: return "Extreme";
|
||||||
|
case LOWEST: return "Lowest";
|
||||||
|
default: return "Unknown";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public MenuSettings(Menu menuOld) {
|
public MenuSettings(Menu menuOld) {
|
||||||
|
|
||||||
this.menuOld = menuOld;
|
this.menuOld = menuOld;
|
||||||
|
|
@ -57,6 +71,37 @@ public class MenuSettings extends Menu
|
||||||
Settings.update();
|
Settings.update();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
group.add(new ButtonSetting("Shadows: " + render(DisplayRender.getShadowQuality()), button ->
|
||||||
|
{
|
||||||
|
SettingQuality quality = DisplayRender.getShadowQuality();
|
||||||
|
|
||||||
|
switch(quality)
|
||||||
|
{
|
||||||
|
case LOWEST:
|
||||||
|
quality = SettingQuality.LOW;
|
||||||
|
break;
|
||||||
|
case LOW:
|
||||||
|
quality = SettingQuality.MEDIUM;
|
||||||
|
break;
|
||||||
|
case MEDIUM:
|
||||||
|
quality = SettingQuality.HIGH;
|
||||||
|
break;
|
||||||
|
case HIGH:
|
||||||
|
quality = SettingQuality.EXTREME;
|
||||||
|
break;
|
||||||
|
case EXTREME:
|
||||||
|
quality = SettingQuality.LOWEST;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
quality = DisplayRender.setShadowQuality(quality);
|
||||||
|
|
||||||
|
DisplayRender.updateShadowQuality();
|
||||||
|
Settings.update();
|
||||||
|
|
||||||
|
button.setText("Shadows: " + render(quality));
|
||||||
|
}));
|
||||||
|
|
||||||
/*group.add(new ButtonSetting("Dynamic Lighting: " + (LightingManager.lightingMode == 0 ? "Fast" : "Fancy"),
|
/*group.add(new ButtonSetting("Dynamic Lighting: " + (LightingManager.lightingMode == 0 ? "Fast" : "Fancy"),
|
||||||
button ->
|
button ->
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
package projectzombie.settings;
|
package projectzombie.settings;
|
||||||
|
|
||||||
public enum SettingQuality {
|
public enum SettingQuality {
|
||||||
OFF, FAST, FANCY
|
LOWEST, LOW, MEDIUM, HIGH, EXTREME
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import bdf.file.BdfFileManager;
|
||||||
import bdf.types.BdfNamedList;
|
import bdf.types.BdfNamedList;
|
||||||
import bdf.types.BdfObject;
|
import bdf.types.BdfObject;
|
||||||
import bdf.types.BdfTypes;
|
import bdf.types.BdfTypes;
|
||||||
|
import projectzombie.display.DisplayRender;
|
||||||
import projectzombie.display.DisplayRenderUI;
|
import projectzombie.display.DisplayRenderUI;
|
||||||
import projectzombie.entity.EntityParticle;
|
import projectzombie.entity.EntityParticle;
|
||||||
import projectzombie.world.chunk.Chunk;
|
import projectzombie.world.chunk.Chunk;
|
||||||
|
|
@ -36,14 +37,73 @@ public class Settings implements IBdfClassManager
|
||||||
} else {
|
} else {
|
||||||
DisplayRenderUI.debug = false;
|
DisplayRenderUI.debug = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(nl.get("shadow_size").getType() == BdfTypes.INTEGER)
|
||||||
|
{
|
||||||
|
SettingQuality quality = DisplayRender.getShadowQuality();
|
||||||
|
|
||||||
|
switch(nl.get("shadow_size").getInteger())
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
quality = SettingQuality.LOWEST;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
quality = SettingQuality.LOW;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
quality = SettingQuality.MEDIUM;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
quality = SettingQuality.HIGH;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
quality = SettingQuality.EXTREME;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
quality = SettingQuality.LOW;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
DisplayRender.setShadowQuality(quality);
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
DisplayRender.setShadowQuality(SettingQuality.LOW);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void BdfClassSave(BdfObject bdf) {
|
public void BdfClassSave(BdfObject bdf)
|
||||||
|
{
|
||||||
|
int shadow_size;
|
||||||
|
|
||||||
|
switch(DisplayRender.getShadowQuality())
|
||||||
|
{
|
||||||
|
case LOWEST:
|
||||||
|
shadow_size = 0;
|
||||||
|
break;
|
||||||
|
case LOW:
|
||||||
|
shadow_size = 1;
|
||||||
|
break;
|
||||||
|
case MEDIUM:
|
||||||
|
shadow_size = 2;
|
||||||
|
break;
|
||||||
|
case HIGH:
|
||||||
|
shadow_size = 3;
|
||||||
|
break;
|
||||||
|
case EXTREME:
|
||||||
|
shadow_size = 4;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
shadow_size = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
BdfNamedList nl = bdf.getNamedList();
|
BdfNamedList nl = bdf.getNamedList();
|
||||||
nl.set("render_distance", BdfObject.withInteger(Chunk.RENDER_DISTANCE));
|
nl.set("render_distance", BdfObject.withInteger(Chunk.RENDER_DISTANCE));
|
||||||
nl.set("show_fps", BdfObject.withBoolean(DisplayRenderUI.showFPS));
|
nl.set("show_fps", BdfObject.withBoolean(DisplayRenderUI.showFPS));
|
||||||
nl.set("debug", BdfObject.withBoolean(DisplayRenderUI.debug));
|
nl.set("debug", BdfObject.withBoolean(DisplayRenderUI.debug));
|
||||||
|
nl.set("shadow_size", BdfObject.withInteger(shadow_size));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void init() {
|
public static void init() {
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,29 @@
|
||||||
package projectzombie.util.math.random;
|
package projectzombie.util.math.random;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import gl_engine.MathHelpers;
|
||||||
|
|
||||||
public class NoiseGeneratorSimplex implements NoiseGenerator
|
public class NoiseGeneratorSimplex implements NoiseGenerator
|
||||||
{
|
{
|
||||||
private OpenSimplexNoise simplex;
|
private OpenSimplexNoise simplex;
|
||||||
|
private double off_x, off_y, off_z;
|
||||||
|
|
||||||
public NoiseGeneratorSimplex(long seed) {
|
public NoiseGeneratorSimplex(Random rand)
|
||||||
simplex = new OpenSimplexNoise(seed);
|
{
|
||||||
|
simplex = new OpenSimplexNoise(rand.nextLong());
|
||||||
|
off_x = MathHelpers.map(rand.nextDouble(), 0, 1, -1024, 1024);
|
||||||
|
off_y = MathHelpers.map(rand.nextDouble(), 0, 1, -1024, 1024);
|
||||||
|
off_z = MathHelpers.map(rand.nextDouble(), 0, 1, -1024, 1024);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double eval(double x, double y) {
|
public double eval(double x, double y) {
|
||||||
return simplex.eval(x, y);
|
return simplex.eval(x + off_x, y + off_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double eval(double x, double y, double z) {
|
public double eval(double x, double y, double z) {
|
||||||
return simplex.eval(x, y, z);
|
return simplex.eval(x + off_x, y + off_y, z + off_z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ public class LayerGenBossArena extends LayerGen implements LayerGenRememberPlaye
|
||||||
super.init(layer);
|
super.init(layer);
|
||||||
|
|
||||||
layer.noise_gens = new NoiseGenerator[] {
|
layer.noise_gens = new NoiseGenerator[] {
|
||||||
new NoiseGeneratorSimplex(rand.nextLong()),
|
new NoiseGeneratorSimplex(rand),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,10 +53,10 @@ public class LayerGenCaves extends LayerGen
|
||||||
Random lrand = new Random(layer.lseed);
|
Random lrand = new Random(layer.lseed);
|
||||||
|
|
||||||
layer.noise_gens = new NoiseGenerator[] {
|
layer.noise_gens = new NoiseGenerator[] {
|
||||||
new NoiseGeneratorSimplex(rand.nextLong()), // Temperature
|
new NoiseGeneratorSimplex(rand), // Temperature
|
||||||
new NoiseGeneratorSimplex(rand.nextLong()), // Humidity
|
new NoiseGeneratorSimplex(rand), // Humidity
|
||||||
new NoiseGeneratorSimplex(lrand.nextLong()), // Cave structure
|
new NoiseGeneratorSimplex(lrand), // Cave structure
|
||||||
new NoiseGeneratorSimplex(lrand.nextLong()), // Caverns
|
new NoiseGeneratorSimplex(lrand), // Caverns
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -68,13 +68,13 @@ public class LayerGenEarth extends LayerGen
|
||||||
|
|
||||||
layer.noise_gens = new NoiseGenerator[]
|
layer.noise_gens = new NoiseGenerator[]
|
||||||
{
|
{
|
||||||
new NoiseGeneratorSimplex(rand.nextLong()), // Temperature
|
new NoiseGeneratorSimplex(rand), // Temperature
|
||||||
new NoiseGeneratorSimplex(rand.nextLong()), // Humidity
|
new NoiseGeneratorSimplex(rand), // Humidity
|
||||||
|
|
||||||
new NoiseGeneratorSimplex(lrand.nextLong()), // Wind
|
new NoiseGeneratorSimplex(lrand), // Wind
|
||||||
new NoiseGeneratorSimplex(lrand.nextLong()), // Wind
|
new NoiseGeneratorSimplex(lrand), // Wind
|
||||||
new NoiseGeneratorSimplex(lrand.nextLong()), // Water
|
new NoiseGeneratorSimplex(lrand), // Water
|
||||||
new NoiseGeneratorSimplex(lrand.nextLong()), // Rocks
|
new NoiseGeneratorSimplex(lrand), // Rocks
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,8 @@ public class LayerGenLavaCaves extends LayerGen
|
||||||
Random rand = new Random(layer.lseed);
|
Random rand = new Random(layer.lseed);
|
||||||
|
|
||||||
layer.noise_gens = new NoiseGenerator[] {
|
layer.noise_gens = new NoiseGenerator[] {
|
||||||
new NoiseGeneratorSimplex(rand.nextLong()),
|
new NoiseGeneratorSimplex(rand),
|
||||||
new NoiseGeneratorSimplex(rand.nextLong()),
|
new NoiseGeneratorSimplex(rand),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue