[GameState] Now using render distance as projection far plane.

This commit is contained in:
Quentin Bazin 2020-07-02 02:33:11 +02:00
parent 439eb2124b
commit ff1d34cd8d
3 changed files with 7 additions and 5 deletions

View File

@ -10,7 +10,6 @@ varying float v_blockFace;
varying float v_dist;
uniform int u_renderDistance;
uniform sampler2D u_tex;
// Get light color
@ -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) {

View File

@ -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() {

View File

@ -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() {