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

Commit

Permalink
Build-134: New Procedurally Generated Waves. Some Fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Guerra24 committed Dec 13, 2015
1 parent 7c9fbe4 commit 91ff130
Show file tree
Hide file tree
Showing 15 changed files with 62 additions and 33 deletions.
12 changes: 7 additions & 5 deletions assets/game/settings.conf
@@ -1,12 +1,14 @@
#Voxel Settings
#Fri Dec 11 15:56:47 CST 2015
#Sat Dec 12 18:03:29 CST 2015
UPS=30
VSYNC=false
useFXAA=false
useMotionBlur=false
useFXAA=true
DrawDistance=2
SettingsVersion=2
useVolumetricLight=false
SettingsVersion=3
useVolumetricLight=true
TESTXMOD=Hello Voxel
FPS=30
useDOF=false
useHQWater=false
useShadows=false
useShadows=true
6 changes: 3 additions & 3 deletions assets/shaders/FragmentComposite2.glsl
Expand Up @@ -95,12 +95,12 @@ void main(void){
float b = ((max(dot(normal.xyz,lightDir),0.2) + data1.a) - data.a);
b = clamp(b,0.2,1.0);
image = b * image;
if(data.r == 1){
if(data.r == 1)
if(data.a <= 0)
image += pow(max(dot(normal.xyz,vHalfVector),0.0), 100) * 8;
}


}

vec4 raysColor = texture(composite, texcoord);
image.rgb = mix(image.rgb, raysColor.rgb, raysColor.a);
if(useVolumetricLight == 1){
Expand Down
3 changes: 3 additions & 0 deletions assets/shaders/FragmentCompositeFinal0.glsl
Expand Up @@ -43,6 +43,7 @@ uniform mat4 inverseViewMatrix;
uniform mat4 previousViewMatrix;
uniform sampler2D composite;
uniform sampler2D gDepth;
uniform sampler2D gData0;

uniform int useDOF;
uniform int useMotionBlur;
Expand All @@ -58,6 +59,7 @@ uniform int useMotionBlur;
void main(void){
vec2 texcoord = textureCoords;
vec4 textureColour = texture(composite, texcoord);
vec4 data = texture(gData0, texcoord);
if(useDOF == 1){
vec3 sum = textureColour.rgb;
float bias = min(abs(texture(gDepth, texcoord).x - texture(gDepth, vec2(0.5)).x) * .02, .01);
Expand Down Expand Up @@ -95,5 +97,6 @@ void main(void){
sum = sum/samples;
textureColour = vec4(sum, 1.0);
}

out_Color = textureColour;
}
2 changes: 1 addition & 1 deletion assets/shaders/FragmentWater.glsl
Expand Up @@ -50,7 +50,7 @@ void main(void) {
vec3 normal = vec3(normalMapColour.r * 2.0 - 1.0,normalMapColour.b,normalMapColour.g * 2.0 - 1.0);
out_Color[2] = vec4(normal.xyz, 0.0);
} else {
out_Color[2] = vec4(0.0, 1.0, 0.0, 0.0);
out_Color[2] = vec4(sin(pass_position.x + moveFactor) * 0.05, 1.0, cos(pass_position.z + moveFactor) * 0.02, 0.0);
}
out_Color[3] = vec4(1.0, 0.0, 0.0, 0.0);
out_Color[4] = vec4(0.0,0.0,0.0,0.0);
Expand Down
4 changes: 4 additions & 0 deletions assets/shaders/VertexWater.glsl
Expand Up @@ -37,11 +37,15 @@ uniform mat4 modelMatrix;
uniform vec3 cameraPosition;
uniform vec3 directLightDirection;
uniform float fogDensity;
uniform float moveFactor;

const float tiling = 0.5;

void main(void) {
vec4 worldPosition = modelMatrix * vec4(position.x, 0.0, position.y, 1.0);
float sina = sin(worldPosition.x + moveFactor) * 0.05;
float sinb = cos(worldPosition.z + moveFactor) * 0.02;
worldPosition += vec4(0.0, sina + sinb, 0.0, 0.0);
clipSpace = projectionMatrix * viewMatrix * worldPosition;
gl_Position = clipSpace;
pass_position = worldPosition.xyz;
Expand Down
10 changes: 4 additions & 6 deletions src/main/java/net/guerra24/voxel/client/bootstrap/Bootstrap.java
Expand Up @@ -190,24 +190,22 @@ private static void parseArgs(String[] args) {
case "-useFXAA":
if (gaveFXAA)
throw new IllegalStateException("FXAA already given");
if (VoxelVariables.useDOF || VoxelVariables.useMotionBlur)
throw new IllegalArgumentException("FXAA only be activated if DOF and Motion Blur is disabled");
VoxelVariables.useFXAA = true;
gaveFXAA = true;
break;
case "-useDOF":
if (gaveDOF)
throw new IllegalStateException("DOF already given");
if (VoxelVariables.useFXAA || VoxelVariables.useMotionBlur)
throw new IllegalArgumentException("DOF only be activated if FXAA and Motion Blur is disabled");
if (VoxelVariables.useMotionBlur)
throw new IllegalArgumentException("DOF only be activated if Motion Blur is disabled");
VoxelVariables.useDOF = true;
gaveDOF = true;
break;
case "-useMotionBlur":
if (gaveMotionBlur)
throw new IllegalStateException("Motion Blur already given");
if (VoxelVariables.useDOF || VoxelVariables.useFXAA)
throw new IllegalArgumentException("Motion Blur only be activated if DOF and FXAA is disabled");
if (VoxelVariables.useDOF)
throw new IllegalArgumentException("Motion Blur only be activated if DOF is disabled");
VoxelVariables.useMotionBlur = true;
gaveMotionBlur = true;
break;
Expand Down
15 changes: 14 additions & 1 deletion src/main/java/net/guerra24/voxel/client/core/GameSettings.java
Expand Up @@ -12,7 +12,7 @@ public class GameSettings {
private Properties prop;
private File settings;

private int version = 2;
private int version = 3;

public GameSettings() {
settings = new File(VoxelVariables.settings);
Expand Down Expand Up @@ -40,6 +40,17 @@ public GameSettings() {
VoxelVariables.FPS = Integer.parseInt(getValue("FPS"));
VoxelVariables.UPS = Integer.parseInt(getValue("UPS"));
VoxelVariables.radius = Integer.parseInt(getValue("DrawDistance"));
} else if (getVersion() == 3) {
VoxelVariables.useShadows = Boolean.parseBoolean(getValue("useShadows"));
VoxelVariables.useVolumetricLight = Boolean.parseBoolean(getValue("useVolumetricLight"));
VoxelVariables.useHQWater = Boolean.parseBoolean(getValue("useHQWater"));
VoxelVariables.useFXAA = Boolean.parseBoolean(getValue("useFXAA"));
VoxelVariables.useMotionBlur = Boolean.parseBoolean(getValue("useMotionBlur"));
VoxelVariables.useDOF = Boolean.parseBoolean(getValue("useDOF"));
VoxelVariables.VSYNC = Boolean.parseBoolean(getValue("VSYNC"));
VoxelVariables.FPS = Integer.parseInt(getValue("FPS"));
VoxelVariables.UPS = Integer.parseInt(getValue("UPS"));
VoxelVariables.radius = Integer.parseInt(getValue("DrawDistance"));
} else {
updateSetting();
save();
Expand Down Expand Up @@ -82,6 +93,8 @@ public void updateSetting() {
registerValue("useVolumetricLight", Boolean.toString(VoxelVariables.useVolumetricLight));
registerValue("useHQWater", Boolean.toString(VoxelVariables.useHQWater));
registerValue("useFXAA", Boolean.toString(VoxelVariables.useFXAA));
registerValue("useMotionBlur", Boolean.toString(VoxelVariables.useMotionBlur));
registerValue("useDOF", Boolean.toString(VoxelVariables.useDOF));
registerValue("VSYNC", Boolean.toString(VoxelVariables.VSYNC));
registerValue("FPS", Integer.toString(VoxelVariables.FPS));
registerValue("UPS", Integer.toString(VoxelVariables.UPS));
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 = 133;
public static final int build = 134;
public static int FOV = 90;
public static int WIDTH = 1280;
public static int HEIGHT = 720;
Expand Down Expand Up @@ -87,7 +87,7 @@ public class VoxelVariables {
/**
* Graphics Settings
*/
public static final float WAVE_SPEED = 0.03f;
public static final float WAVE_SPEED = 4f;
public static final float SIZE = 500f;
public static final float ROTATE_SPEED = 0.2f;
/**
Expand Down
Expand Up @@ -27,7 +27,7 @@
* @category Kernel
*/
public class GameSPState extends State {

public GameSPState() {
super(2);
}
Expand All @@ -40,6 +40,9 @@ public void update(Voxel voxel, GlobalStates states, float delta) {
ModInitialization api = voxel.getApi();
Display display = voxel.getDisplay();

gm.getCamera().update(delta, gm, worlds.getActiveWorld(), api, voxel.getClient());
gm.getPhysics().getMobManager().getPlayer().update(delta, gm, voxel.getGuiResources(), worlds.getActiveWorld(),
api);
worlds.getActiveWorld().updateChunksGeneration(gm, api, delta);
gm.getPhysics().getMobManager().update(delta, gm, gi, worlds.getActiveWorld(), api);
gm.update(gm.getSkyboxRenderer().update(delta));
Expand All @@ -59,9 +62,6 @@ public void render(Voxel voxel, GlobalStates states, float delta) {
ModInitialization api = voxel.getApi();

worlds.getActiveWorld().lighting();
gm.getCamera().update(delta, gm, worlds.getActiveWorld(), api, voxel.getClient());
gm.getPhysics().getMobManager().getPlayer().update(delta, gm, voxel.getGuiResources(), worlds.getActiveWorld(),
api);
gm.getFrustum().calculateFrustum(gm.getRenderer().getProjectionMatrix(), gm.getCamera());
gm.getSun_Camera().setPosition(gm.getCamera().getPosition());
if (VoxelVariables.useShadows) {
Expand Down
Expand Up @@ -15,7 +15,6 @@
import static org.lwjgl.opengl.GL11.glGenTextures;
import static org.lwjgl.opengl.GL11.glTexImage2D;
import static org.lwjgl.opengl.GL11.glTexParameteri;
import static org.lwjgl.opengl.GL11.GL_REPEAT;
import static org.lwjgl.opengl.GL12.GL_CLAMP_TO_EDGE;
import static org.lwjgl.opengl.GL20.glDrawBuffers;
import static org.lwjgl.opengl.GL30.GL_COLOR_ATTACHMENT0;
Expand Down Expand Up @@ -98,8 +97,8 @@ private void init(int width, int height) {
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, (ByteBuffer) null);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, diffuseTex, 0);

positionTex = glGenTextures();
Expand Down
Expand Up @@ -46,6 +46,7 @@
import static org.lwjgl.opengl.GL11.glTexParameterfv;
import static org.lwjgl.opengl.GL11.glTexParameteri;
import static org.lwjgl.opengl.GL11.glViewport;
import static org.lwjgl.opengl.GL12.GL_CLAMP_TO_EDGE;
import static org.lwjgl.opengl.GL13.GL_CLAMP_TO_BORDER;
import static org.lwjgl.opengl.GL30.GL_COLOR_ATTACHMENT0;
import static org.lwjgl.opengl.GL30.GL_DEPTH_ATTACHMENT;
Expand Down Expand Up @@ -125,8 +126,10 @@ private int createTextureAttachment(int width, int height) {
int texture = glGenTextures();
glBindTexture(GL_TEXTURE_2D, texture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, (ByteBuffer) null);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, texture, 0);
return texture;
}
Expand All @@ -136,8 +139,8 @@ private int createDepthTextureAttachment(int width, int height) {
glBindTexture(GL_TEXTURE_2D, texture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, width, height, 0, GL_DEPTH_COMPONENT, GL_FLOAT,
(ByteBuffer) null);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
float borderColor[] = { 1.0f, 1.0f, 1.0f, 1.0f };
Expand Down
@@ -1,5 +1,9 @@
package net.guerra24.voxel.client.graphics;

import static org.lwjgl.opengl.GL11.GL_BACK;
import static org.lwjgl.opengl.GL11.GL_FRONT;
import static org.lwjgl.opengl.GL11.glCullFace;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -32,11 +36,11 @@ public MasterShadowRenderer() {
shader = new ShadowShader();
projectionMatrix = Maths.orthographic(-30, 30, -30, 30, -100, 100);
renderer = new ShadowRenderer(shader, projectionMatrix);
fbo = new FrameBuffer(true, 2048, 2048);
fbo = new FrameBuffer(true, 4096, 4096);
}

public void being() {
fbo.begin(2048,2048);
fbo.begin(4096, 4096);
}

public void end() {
Expand Down Expand Up @@ -70,11 +74,13 @@ public void renderChunk(Queue<Object> cubes, GameResources gm) {
* A Camera
*/
private void renderBlocks(GameResources gm) {
glCullFace(GL_FRONT);
shader.start();
shader.loadviewMatrix(gm.getSun_Camera());
renderer.renderBlockEntity(blockEntities, gm);
shader.stop();
blockEntities.clear();
glCullFace(GL_BACK);
}

/**
Expand Down
Expand Up @@ -146,7 +146,7 @@ public void render(float r, float g, float b, float delta, GameResources gm) {
* Delta
*/
public float update(float delta) {
time += delta * 100;
time += delta * 10;
time %= 24000;
float res = time * 0.015f;
return res - 90;
Expand Down
Expand Up @@ -135,7 +135,7 @@ private void prepareRender(GameResources gm) {
*/
public void update(float delta) {
moveFactor += VoxelVariables.WAVE_SPEED * delta;
moveFactor %= 1;
moveFactor %= 6.3f;
}

/**
Expand Down
Expand Up @@ -134,6 +134,7 @@ public void connectTextureUnits() {
public void loadUnderWater(boolean value) {
super.loadBoolean(loc_camUnderWater, value);
super.loadFloat(loc_camUnderWaterOffset, time += 0.1f);
time %= 10;
}

public void loadSkyColor(Vector3f color) {
Expand Down

0 comments on commit 91ff130

Please sign in to comment.