[GameState] Now using render distance as projection far plane.
This commit is contained in:
parent
439eb2124b
commit
ff1d34cd8d
@ -10,7 +10,6 @@ varying float v_blockFace;
|
|||||||
varying float v_dist;
|
varying float v_dist;
|
||||||
|
|
||||||
uniform int u_renderDistance;
|
uniform int u_renderDistance;
|
||||||
|
|
||||||
uniform sampler2D u_tex;
|
uniform sampler2D u_tex;
|
||||||
|
|
||||||
// Get light color
|
// Get light color
|
||||||
@ -25,9 +24,6 @@ void main() {
|
|||||||
float blockFace = floor(v_blockFace + 0.5);
|
float blockFace = floor(v_blockFace + 0.5);
|
||||||
float lightCheck = floor(v_lightValue.x + 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
|
// Get current pixel color and apply multiplier on grayscale textures
|
||||||
vec4 color = v_color;
|
vec4 color = v_color;
|
||||||
if (v_texCoord.x > -0.99 && v_texCoord.y > -0.99) {
|
if (v_texCoord.x > -0.99 && v_texCoord.y > -0.99) {
|
||||||
|
@ -21,7 +21,6 @@ uniform mat4 u_modelMatrix;
|
|||||||
uniform mat4 u_projectionMatrix;
|
uniform mat4 u_projectionMatrix;
|
||||||
uniform mat4 u_viewMatrix;
|
uniform mat4 u_viewMatrix;
|
||||||
|
|
||||||
uniform int u_renderDistance;
|
|
||||||
// uniform int u_time;
|
// uniform int u_time;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
@ -173,6 +173,13 @@ void GameState::update() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_client.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() {
|
void GameState::initShaders() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user