# How to increase render distance?

I've been trying to find the source of why my render distance is so low (I'm new at using LWJGL and don't know the complete basics yet) and I believe it falls down into this code. My idea for my game (Well, this is more of a practice run to get used to coding 3D games.) is going to be a small island with a size of around 800 which seems extremely low however it is only loading a small portion which I'd estimate to be 600. The code for my MasterRenderer class is below. createProjectionMatrix() is called in the constructor and prepare() is called at the beginning of every render.

private static final float FOV = 70;
private static final float NEAR_PLANE = 0.01f;
private static final float FAR_PLANE = 1000f;

public void prepare() {
GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
GL11.glClearColor(0.49f, 89f, 0.98f, 1);
}

private void createProjectionMatrix() {
float aspectRatio = (float) Display.getWidth() / (float) Display.getHeight();
float y_scale = (float) ((1f / Math.tan(Math.toRadians(FOV / 2f))) * aspectRatio);
float x_scale = y_scale / aspectRatio;
float frustum_length = (FAR_PLANE - NEAR_PLANE);

projectionMatrix = new Matrix4f();
projectionMatrix.m00 = x_scale;
projectionMatrix.m11 = y_scale;
projectionMatrix.m22 = -((FAR_PLANE + NEAR_PLANE) / frustum_length);
projectionMatrix.m23 = -1;
projectionMatrix.m32 = -((2 * NEAR_PLANE * FAR_PLANE) / frustum_length);
projectionMatrix.m33 = 0;
}


I've tried altering the FAR_PLANE and NEAR_PLANE with no results other than some minor bugs with changing the NEAR_PLANE to a small number.

• Your near plane is too low, the ratio between near and far is important. Try increasing it to at least 1. Jul 3, 2017 at 7:13

I have discovered the problem - my skybox was cutting out the terrain prematurely. A simple increase in the size of said skybox fixed the issue.

No!

First render your skybox, then clear the depth bit after rendering the skybox, and finally render everything else. That way the depth of the skybox won't affect the scene.

Note: I am thinking on the old pipeline, thinking on shaders is still alien to me.

• glDepthrange(1,1) - no need for any trickery, skybox is always behind everything else, can be rendered after everything else. Jul 3, 2017 at 7:12
• Unless there is transparency, the skybox should mostly be rendered last AND depth should be honored, by using reasonable values and alternating near/far. But there are ofc many ways, and if something w0rks well, then it's ok :-). Jul 3, 2017 at 9:28
• My skybox is a bit different than normal and it WAS the cause of what I thought to be a rendering problem, however your reply is helpful. Jul 3, 2017 at 12:01

I have discovered the problem - my skybox was cutting out the terrain prematurely. A simple increase in the size of said skybox fixed the issue.