Skip to content
This repository has been archived by the owner on Oct 9, 2019. It is now read-only.

Commit

Permalink
Build-138: Fixes and new features.
Browse files Browse the repository at this point in the history
Fixed NanoVG Crash. New Buttons. Merged features from Infinity.
  • Loading branch information
Guerra24 committed Dec 23, 2015
1 parent 5ce0652 commit f2d4730
Show file tree
Hide file tree
Showing 27 changed files with 209 additions and 228 deletions.
4 changes: 2 additions & 2 deletions assets/game/settings.conf
@@ -1,5 +1,5 @@
#Voxel Settings
#Thu Dec 17 17:31:01 CST 2015
#Wed Dec 23 15:28:53 CST 2015
UPS=30
VSYNC=false
useMotionBlur=false
Expand All @@ -8,6 +8,6 @@ DrawDistance=2
SettingsVersion=3
useVolumetricLight=true
TESTXMOD=Hello Voxel
FPS=30
useDOF=false
FPS=30
useShadows=true
14 changes: 13 additions & 1 deletion assets/shaders/FragmentComposite1.glsl
Expand Up @@ -35,6 +35,7 @@ out vec4 out_Color;

uniform int camUnderWater;
uniform float camUnderWaterOffset;
uniform float skyboxBlendFactor;
uniform vec2 resolution;
uniform vec3 cameraPosition;
uniform vec3 previousCameraPosition;
Expand All @@ -52,6 +53,8 @@ uniform sampler2D gData0;
uniform sampler2D gData1;
uniform sampler2D composite0;
uniform sampler2DShadow gDepth;
uniform samplerCube skyboxDay;
uniform samplerCube skyboxNight;

uniform int useFXAA;
uniform int useDOF;
Expand Down Expand Up @@ -115,7 +118,16 @@ void main(void){
fact = 1.0;
else if (cameraToWorldDist > currentWorldDist)
fact = 1.0;
image = image*fact + newColor*(1-fact);
if(fact != 1.0){
image = image*fact + newColor;
} else {
vec3 I = normalize(position.xyz - cameraPosition);
vec3 R = reflect(I, normalize(normal.xyz));
vec4 imageDay = texture(skyboxDay, R);
vec4 imageNight = texture(skyboxNight, R);
image += mix(imageDay, imageNight, skyboxBlendFactor);
}

}
}

Expand Down
2 changes: 1 addition & 1 deletion assets/shaders/FragmentComposite2.glsl
Expand Up @@ -43,7 +43,7 @@ uniform sampler2D composite1;
/*------------------COMPOSITE 0 CODE----------------------*/
/*--------------------------------------------------------*/

const float weight[8] = float[] (0.227027, 0.1945946, 0.1216216, 0.054054, 0.016216, 0.131548, 0.186473, 0.245784);
const float weight[8] = float[] (0.227027, 0.1945946, 0.1216216, 0.154054, 0.116216, 0.131548, 0.186473, 0.245784);

void main(void){
vec2 texcoord = textureCoords;
Expand Down
2 changes: 1 addition & 1 deletion assets/shaders/FragmentComposite3.glsl
Expand Up @@ -52,7 +52,7 @@ void main(void){
if(data0.b != 1){
image = texture(composite0, texcoord);
float brightness = dot(image.rgb, vec3(0.2126, 0.7152, 0.0722));
if(brightness > 0.8)
if(brightness > 0.99)
result = vec4(image.rgb, 1.0);
out_Color = result;
}
Expand Down
6 changes: 4 additions & 2 deletions assets/shaders/FragmentComposite4.glsl
Expand Up @@ -65,7 +65,7 @@ uniform int useVolumetricLight;
/*--------------------------------------------------------*/

const int NUM_SAMPLES = 50;
const float density = 0.013;
const float density = 0.005;
const float gradient = 2.0;

/*--------------------------------------------------------*/
Expand All @@ -87,7 +87,9 @@ void main(void){
vec3 lightDir = light - position.xyz ;
lightDir = normalize(lightDir);
vec3 eyeDir = normalize(cameraPosition-position.xyz);
float lightDirDOTviewDir = dot(-lightDir,eyeDir);
float lightDirDOTviewDir = 1;
lightDirDOTviewDir = lightDir.y;

if(data1.g != 1){
if(data.b != 1) {
normal = normalize(normal);
Expand Down
7 changes: 5 additions & 2 deletions assets/shaders/FragmentEntity.glsl
Expand Up @@ -37,7 +37,6 @@ uniform sampler2D texture0;
uniform sampler2DShadow depth0;
uniform vec3 skyColour;
uniform vec3 lightPosition;
uniform float entityLight;

uniform int useShadows;

Expand Down Expand Up @@ -68,6 +67,10 @@ void main(void) {
if (texture(depth0, vec3(ShadowCoord.xy + poissonDisk[i]/1600.0 , 0.0), 0) < ShadowCoord.z){
shadow += 0.05;
}
if(ShadowCoord.z > 1.0){
shadow = 0.0;
break;
}
}
}

Expand All @@ -79,5 +82,5 @@ void main(void) {
out_Color[1] = vec4(pass_position.xyz,0);
out_Color[2] = vec4(surfaceNormal.xyz,0);
out_Color[3] = vec4(0.0,1.0,0.0,shadow);
out_Color[4] = vec4(0.0,0.0,0.0,entityLight);
out_Color[4] = vec4(0.0,0.0,0.0,0.0);
}
1 change: 0 additions & 1 deletion src/main/java/net/guerra24/voxel/client/core/Voxel.java
Expand Up @@ -143,7 +143,6 @@ private void postInit() {
gameResources.getSoundSystem().play("menu1");
else
gameResources.getSoundSystem().play("menu2");
gameResources.getMenuSystem().mainMenu.load(gameResources);
}

/**
Expand Down
Expand Up @@ -46,7 +46,7 @@ public class VoxelVariables {
public static final String apiVersion = "0.0.6";
public static final int apiVersionNum = 000006;
public static final String state = "ALPHA";
public static final int build = 137;
public static final int build = 138;
public static int FOV = 90;
public static int WIDTH = 1280;
public static int HEIGHT = 720;
Expand Down Expand Up @@ -88,7 +88,7 @@ public class VoxelVariables {
*/
public static final float WAVE_SPEED = 4f;
public static final float SIZE = 500f;
public static final float ROTATE_SPEED = 0.2f;
public static final float ROTATE_SPEED = 0.0f;
/**
* Shader Files
*/
Expand Down
Expand Up @@ -57,6 +57,7 @@ public void render(Voxel voxel, GlobalStates states, float delta) {
GameResources gm = voxel.getGameResources();
WorldsHandler worlds = voxel.getWorldsHandler();
ModInitialization api = voxel.getApi();
Display display = voxel.getDisplay();

worlds.getActiveWorld().lighting();
gm.getFrustum().calculateFrustum(gm.getRenderer().getProjectionMatrix(), gm.getCamera());
Expand Down
Expand Up @@ -2,10 +2,11 @@

import net.guerra24.voxel.client.core.GlobalStates;
import net.guerra24.voxel.client.core.GlobalStates.GameState;
import net.guerra24.voxel.client.input.Mouse;
import net.guerra24.voxel.client.core.State;
import net.guerra24.voxel.client.core.Voxel;
import net.guerra24.voxel.client.core.VoxelVariables;
import net.guerra24.voxel.client.graphics.opengl.Display;
import net.guerra24.voxel.client.input.Mouse;
import net.guerra24.voxel.client.particle.ParticleMaster;
import net.guerra24.voxel.client.resources.GameResources;
import net.guerra24.voxel.client.world.WorldsHandler;
Expand All @@ -27,8 +28,7 @@ public InPauseState() {
public void update(Voxel voxel, GlobalStates states, float delta) {
GameResources gm = voxel.getGameResources();
while (Mouse.next()) {
if (gm.getMenuSystem().pauseMenu.getBackToMain().pressed()) {
gm.getMenuSystem().mainMenu.load(gm);
if (gm.getMenuSystem().pauseMenu.getExitButton().pressed()) {
voxel.getWorldsHandler().getActiveWorld().clearDimension(gm);
if (gm.getRand().nextBoolean())
gm.getSoundSystem().play("menu1");
Expand All @@ -49,22 +49,9 @@ public void render(Voxel voxel, GlobalStates states, float delta) {
worlds.getActiveWorld().lighting();
gm.getFrustum().calculateFrustum(gm.getRenderer().getProjectionMatrix(), gm.getCamera());
gm.getRenderer().prepare();
worlds.getActiveWorld().updateChunksOcclusion(gm);
if (VoxelVariables.useShadows) {
gm.getMasterShadowRenderer().being();
gm.getRenderer().prepare();
worlds.getActiveWorld().updateChunksShadow(gm);
gm.getMasterShadowRenderer().end();
}
gm.getDeferredShadingRenderer().getPost_fbo().begin();
gm.getRenderer().prepare();
worlds.getActiveWorld().updateChunksRender(gm);
gm.getSkyboxRenderer().render(VoxelVariables.RED, VoxelVariables.GREEN, VoxelVariables.BLUE, delta, gm);
gm.getRenderer().renderEntity(gm.getPhysics().getMobManager().getMobs(), gm);
ParticleMaster.getInstance().render(gm.getCamera());
gm.getDeferredShadingRenderer().getPost_fbo().end();
gm.getRenderer().prepare();
gm.getDeferredShadingRenderer().render(gm);
Display.beingNVGFrame();
gm.getMenuSystem().pauseMenu.render();
Display.endNVGFrame();
}

}
@@ -1,15 +1,9 @@
package net.guerra24.voxel.client.core.states;

import java.nio.ByteBuffer;

import org.lwjgl.nanovg.NVGColor;
import org.lwjgl.nanovg.NanoVG;

import net.guerra24.voxel.client.core.GlobalStates;
import net.guerra24.voxel.client.core.GlobalStates.GameState;
import net.guerra24.voxel.client.core.State;
import net.guerra24.voxel.client.core.Voxel;
import net.guerra24.voxel.client.graphics.MenuRendering;
import net.guerra24.voxel.client.graphics.opengl.Display;
import net.guerra24.voxel.client.resources.GameResources;
import net.guerra24.voxel.universal.util.vector.Vector3f;
Expand All @@ -29,25 +23,22 @@ public MainMenuState() {
@Override
public void render(Voxel voxel, GlobalStates states, float delta) {
GameResources gm = voxel.getGameResources();
Display display = voxel.getDisplay();
gm.getFrustum().calculateFrustum(gm.getRenderer().getProjectionMatrix(), gm.getCamera());
gm.getRenderer().prepare();
display.beingNVGFrame();
Display.beingNVGFrame();
gm.getMenuSystem().mainMenu.render();
display.endNVGFrame();
Display.endNVGFrame();
}

@Override
public void update(Voxel voxel, GlobalStates states, float delta) {
GameResources gm = voxel.getGameResources();

if (gm.getMenuSystem().mainMenu.getPlayButton().pressed()) {
gm.getMenuSystem().gameSP.load(gm);
states.setState(GameState.LOADING_WORLD);
} else if (gm.getMenuSystem().mainMenu.getExitButton().pressed()) {
states.loop = false;
} else if (gm.getMenuSystem().mainMenu.getOptionsButton().pressed()) {
gm.getMenuSystem().optionsMenu.load(gm);
gm.getCamera().setPosition(new Vector3f(-1.4f, -3.4f, 1.4f));
try {
Thread.sleep(100);
Expand Down
Expand Up @@ -5,6 +5,7 @@
import net.guerra24.voxel.client.core.State;
import net.guerra24.voxel.client.core.Voxel;
import net.guerra24.voxel.client.core.VoxelVariables;
import net.guerra24.voxel.client.graphics.opengl.Display;
import net.guerra24.voxel.client.input.Mouse;
import net.guerra24.voxel.client.resources.GameResources;
import net.guerra24.voxel.universal.util.vector.Vector3f;
Expand Down Expand Up @@ -34,7 +35,6 @@ public void update(Voxel voxel, GlobalStates states, float delta) {
VoxelVariables.useVolumetricLight = !VoxelVariables.useVolumetricLight;
}
if (gm.getMenuSystem().optionsMenu.getExitButton().pressed()) {
gm.getMenuSystem().mainMenu.load(gm);
gm.getCamera().setPosition(new Vector3f(0, 0, 1));
gm.getGameSettings().updateSetting();
gm.getGameSettings().save();
Expand All @@ -45,9 +45,11 @@ public void update(Voxel voxel, GlobalStates states, float delta) {
@Override
public void render(Voxel voxel, GlobalStates states, float delta) {
GameResources gm = voxel.getGameResources();
gm.getMenuSystem().optionsMenu.update(gm);
gm.getFrustum().calculateFrustum(gm.getRenderer().getProjectionMatrix(), gm.getCamera());
gm.getRenderer().prepare();
Display.beingNVGFrame();
gm.getMenuSystem().optionsMenu.render();
Display.endNVGFrame();
}

}
Expand Up @@ -36,6 +36,9 @@
import static org.lwjgl.opengl.GL13.GL_TEXTURE5;
import static org.lwjgl.opengl.GL13.GL_TEXTURE6;
import static org.lwjgl.opengl.GL13.GL_TEXTURE7;
import static org.lwjgl.opengl.GL13.GL_TEXTURE8;
import static org.lwjgl.opengl.GL13.GL_TEXTURE9;
import static org.lwjgl.opengl.GL13.GL_TEXTURE_CUBE_MAP;
import static org.lwjgl.opengl.GL13.glActiveTexture;
import static org.lwjgl.opengl.GL20.glDisableVertexAttribArray;
import static org.lwjgl.opengl.GL20.glEnableVertexAttribArray;
Expand Down Expand Up @@ -222,7 +225,7 @@ public void render(GameResources gm) {
previousCameraPosition);
shader3.loadLightPosition(gm.getLightPos());
shader3.loadviewMatrix(gm.getCamera());
shader3.loadResolution(new Vector2f(Display.getWidth() / 2, Display.getHeight() / 2));
shader3.loadResolution(new Vector2f(Display.getWidth(), Display.getHeight()));
shader3.loadSettings();
shader3.loadSunPosition(
Maths.convertTo2F(new Vector3f(gm.getLightPos()), gm.getRenderer().getProjectionMatrix(),
Expand Down Expand Up @@ -299,6 +302,7 @@ public void render(GameResources gm) {
shader1.loadSunPosition(
Maths.convertTo2F(new Vector3f(gm.getLightPos()), gm.getRenderer().getProjectionMatrix(),
Maths.createViewMatrix(gm.getCamera()), Display.getWidth(), Display.getHeight()));
shader1.loadSkyBoxBlending(gm.getSkyboxRenderer().getBlendFactor());
glBindVertexArray(quad.getVaoID());
glEnableVertexAttribArray(0);
glActiveTexture(GL_TEXTURE0);
Expand All @@ -315,6 +319,10 @@ public void render(GameResources gm) {
glBindTexture(GL_TEXTURE_2D, postProcessingFBO.getData1Tex());
glActiveTexture(GL_TEXTURE6);
glBindTexture(GL_TEXTURE_2D, aux1FBO.getTexture());
glActiveTexture(GL_TEXTURE8);
glBindTexture(GL_TEXTURE_CUBE_MAP, gm.getSkyboxRenderer().getDayTexture());
glActiveTexture(GL_TEXTURE9);
glBindTexture(GL_TEXTURE_CUBE_MAP, gm.getSkyboxRenderer().getNightTexture());
glDrawArrays(GL_TRIANGLE_STRIP, 0, quad.getVertexCount());
glDisableVertexAttribArray(0);
glBindVertexArray(0);
Expand Down
Expand Up @@ -2,9 +2,12 @@

import static org.lwjgl.opengl.GL11.GL_BLEND;
import static org.lwjgl.opengl.GL11.GL_DEPTH_TEST;
import static org.lwjgl.opengl.GL11.GL_ONE_MINUS_SRC_ALPHA;
import static org.lwjgl.opengl.GL11.GL_SRC_ALPHA;
import static org.lwjgl.opengl.GL11.GL_TEXTURE_2D;
import static org.lwjgl.opengl.GL11.GL_TRIANGLES;
import static org.lwjgl.opengl.GL11.glBindTexture;
import static org.lwjgl.opengl.GL11.glBlendFunc;
import static org.lwjgl.opengl.GL11.glDisable;
import static org.lwjgl.opengl.GL11.glDrawArrays;
import static org.lwjgl.opengl.GL11.glEnable;
Expand Down Expand Up @@ -43,6 +46,7 @@ public void render(Map<FontType, List<GUIText>> texts) {
private void being() {
glEnable(GL_BLEND);
glDisable(GL_DEPTH_TEST);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
shader.start();
}

Expand Down
Expand Up @@ -199,6 +199,8 @@ private void processEntity(Entity entity) {
public void prepare() {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
glClearColor(VoxelVariables.RED, VoxelVariables.GREEN, VoxelVariables.BLUE, 1);
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
}

/**
Expand Down
Expand Up @@ -33,7 +33,7 @@ public class MasterShadowRenderer {
*/
public MasterShadowRenderer() {
shader = new EntityBasicShader();
projectionMatrix = Maths.orthographic(-30, 30, -30, 30, -100, 100);
projectionMatrix = Maths.orthographic(-80, 80, -80, 80, -100, 100);
renderer = new ShadowRenderer(shader, projectionMatrix);
fbo = new FrameBuffer(true, 4096, 4096);
}
Expand Down

0 comments on commit f2d4730

Please sign in to comment.