Skip to content

Commit

Permalink
[GameState] Now using render distance as projection far plane.
Browse files Browse the repository at this point in the history
  • Loading branch information
Unarelith committed Jul 2, 2020
1 parent 439eb21 commit ff1d34c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 0 additions & 4 deletions resources/shaders/game.f.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ varying float v_blockFace;
varying float v_dist;

uniform int u_renderDistance;

uniform sampler2D u_tex;

// Get light color
Expand All @@ -25,9 +24,6 @@ void main() {
float blockFace = floor(v_blockFace + 0.5);
float lightCheck = floor(v_lightValue.x + 0.5);

// Discard if the pixel is too far away
if(blockFace > -1. && v_dist > u_renderDistance) discard;

// Get current pixel color and apply multiplier on grayscale textures
vec4 color = v_color;
if (v_texCoord.x > -0.99 && v_texCoord.y > -0.99) {
Expand Down
1 change: 0 additions & 1 deletion resources/shaders/game.v.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ uniform mat4 u_modelMatrix;
uniform mat4 u_projectionMatrix;
uniform mat4 u_viewMatrix;

uniform int u_renderDistance;
// uniform int u_time;

void main() {
Expand Down
7 changes: 7 additions & 0 deletions source/client/states/GameState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,13 @@ void GameState::update() {
}

m_client.update();

// Update far plane using render distance
static u16 oldRenderDistance = Config::renderDistance;
if (Config::renderDistance != oldRenderDistance) {
m_camera.setFarClippingPlane(Config::renderDistance * CHUNK_SIZE);
oldRenderDistance = Config::renderDistance;
}
}

void GameState::initShaders() {
Expand Down

0 comments on commit ff1d34c

Please sign in to comment.