Compare commits

..

6 Commits

Author SHA1 Message Date
James Seibel 7a3497d44c Update and improve Access Transformer
Remove old unneeded transformations and add useful comments.
2021-03-04 21:55:26 -06:00
James Seibel 873034f7e4 Merge branch '1.16.4' of gitlab.com:jeseibel/minecraft-lod-mod into 1.16.4 2021-03-04 21:30:33 -06:00
James Seibel a151054b48 Fix issue #7 (screen space distortions not be applied) 2021-03-04 21:30:19 -06:00
James Seibel 14c69971f6 Fix a bug with holding grass blocks
For some reason hold grass blocks (and presumably other biome colored blocks)  would look gray if GL_COLOR_MATERIAL is disabled
2021-03-04 21:16:41 -06:00
James Seibel edc3858699 Add the youtube demo video 2021-03-03 16:16:47 +00:00
James Seibel bdaf33b80b Add a simplified description to the readme 2021-03-03 03:48:13 +00:00
3 changed files with 52 additions and 41 deletions
+4
View File
@@ -2,6 +2,10 @@ This mod adds a Level Of Detail (LOD) system to Minecraft.
This implementation renders simplified chunks outside the normal render distance
allowing for an increased view distance without harming performance.
Or in other words: this mod let's you see farther without turning your game into a slide show.
If you want to see a quick demo, check out the video I made here:
https://youtu.be/v61iOYZQWCs
Forge version: 1.16.4-35.1.4
@@ -310,7 +310,6 @@ public class LodRenderer
GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glDisable(LOD_GL_LIGHT_NUMBER);
GL11.glDisable(GL11.GL_COLOR_MATERIAL);
// this can't be called until after the buffers are built
// because otherwise the buffers may be set to the wrong size
@@ -331,9 +330,6 @@ public class LodRenderer
// get all relevant camera info
ActiveRenderInfo renderInfo = mc.gameRenderer.getActiveRenderInfo();
Vector3d projectedView = renderInfo.getProjectedView();
double cameraX = projectedView.x;
double cameraY = projectedView.y;
double cameraZ = projectedView.z;
// generate the model view matrix
@@ -342,23 +338,7 @@ public class LodRenderer
// translate and rotate to the current camera location
matrixStack.rotate(Vector3f.XP.rotationDegrees(renderInfo.getPitch()));
matrixStack.rotate(Vector3f.YP.rotationDegrees(renderInfo.getYaw() + 180));
matrixStack.translate(-cameraX, -cameraY, -cameraZ);
// this isn't a great solution to nausea or portal spinning
// but i'm not sure what to do otherwise
float f = 0.23f * MathHelper.lerp(partialTicks, this.mc.player.prevTimeInPortal, this.mc.player.timeInPortal) * this.mc.gameSettings.screenEffectScale * this.mc.gameSettings.screenEffectScale;
if (f > 0.0F) {
int i = this.mc.player.isPotionActive(Effects.NAUSEA) ? 7 : 20;
float f1 = 5.0F / (f * f + 5.0F) - f * 0.04F;
f1 = f1 * f1;
Vector3f vector3f = new Vector3f(0.0F, MathHelper.SQRT_2 / 2.0F, MathHelper.SQRT_2 / 2.0F);
matrixStack.rotate(vector3f.rotationDegrees((mc.gameRenderer.rendererUpdateCount + partialTicks) * i));
matrixStack.scale(1.01F / f1, 1.0F, 1.0F);
float f2 = -(mc.gameRenderer.rendererUpdateCount + partialTicks) * i;
matrixStack.rotate(vector3f.rotationDegrees(f2));
}
matrixStack.translate(-projectedView.x, -projectedView.y, -projectedView.z);
return matrixStack.getLast().getMatrix();
}
@@ -458,10 +438,47 @@ public class LodRenderer
/**
* create a new projection matrix and send it over to the GPU
* <br><br>
* A lot of this code is copied from renderWorld (line 578)
* in the GameRender class. The code copied is anything with
* a matrixStack and is responsible for making sure the LOD
* objects distort correctly relative to the rest of the world.
* Distortions are caused by: standing in a nether portal,
* nausea potion effect, walking bobbing.
*
* @param partialTicks how many ticks into the frame we are
*/
private void setupProjectionMatrix(float partialTicks)
{
// Note: if the LOD objects don't distort correctly
// compared to regular minecraft terrain, make sure
// all the transformations in renderWorld are here too
MatrixStack matrixStack = new MatrixStack();
matrixStack.push();
gameRender.hurtCameraEffect(matrixStack, partialTicks);
if (this.mc.gameSettings.viewBobbing) {
gameRender.applyBobbing(matrixStack, partialTicks);
}
// potion and nausea effects
float f = MathHelper.lerp(partialTicks, mc.player.prevTimeInPortal, mc.player.timeInPortal) * mc.gameSettings.screenEffectScale * mc.gameSettings.screenEffectScale;
if (f > 0.0F) {
int i = this.mc.player.isPotionActive(Effects.NAUSEA) ? 7 : 20;
float f1 = 5.0F / (f * f + 5.0F) - f * 0.04F;
f1 = f1 * f1;
Vector3f vector3f = new Vector3f(0.0F, MathHelper.SQRT_2 / 2.0F, MathHelper.SQRT_2 / 2.0F);
matrixStack.rotate(vector3f.rotationDegrees((gameRender.rendererUpdateCount + partialTicks) * i));
matrixStack.scale(1.0F / f1, 1.0F, 1.0F);
float f2 = -(gameRender.rendererUpdateCount + partialTicks) * i;
matrixStack.rotate(vector3f.rotationDegrees(f2));
}
// this projection matrix allows us to see past the normal
// world render distance
Matrix4f projectionMatrix =
Matrix4f.perspective(
getFov(partialTicks, true),
@@ -469,8 +486,9 @@ public class LodRenderer
0.5F,
this.farPlaneDistance * LOD_CHUNK_DISTANCE_RADIUS * 2);
// add the screen space distortions
projectionMatrix.mul(matrixStack.getLast().getMatrix());
gameRender.resetProjectionMatrix(projectionMatrix);
return;
}
@@ -1,34 +1,23 @@
# Note: to update code in eclipse run the "eclipse" command in graldew
# make public the method getFOVModifier
# used when creating the projection matrix
public net.minecraft.client.renderer.GameRenderer func_215311_a(Lnet/minecraft/client/renderer/ActiveRenderInfo;FZ)D # getFOVModifier
public net.minecraft.client.renderer.GameRenderer field_78529_t # rendererUpdateCount
public net.minecraft.client.renderer.GameRenderer func_228380_a_(Lcom/mojang/blaze3d/matrix/MatrixStack;F)V # hurtCameraEffect
public net.minecraft.client.renderer.GameRenderer func_228383_b_(Lcom/mojang/blaze3d/matrix/MatrixStack;F)V # applyBobbing
# make public the byteBuffer in BufferBuilder
# used when accessing built byteBuffers
public net.minecraft.client.renderer.BufferBuilder field_179001_a # byteBuffer
# make public the cameraZoom in the GameRenderer
public net.minecraft.client.renderer.GameRenderer field_78503_V # cameraZoom
# make public the cameraYaw in the GameRenderer
public net.minecraft.client.renderer.GameRenderer field_228376_w_ # cameraYaw
# make public the cameraPitch in the GameRenderer
public net.minecraft.client.renderer.GameRenderer field_228377_x_ # cameraPitch
# make public the folder in the DimensionSavedDataManager
# used when determining where to save files too
public net.minecraft.world.storage.DimensionSavedDataManager field_215759_d # folder
# make public the ambiantLight field in DimensionType
public net.minecraft.world.DimensionType field_236017_x_ # ambientLight
# make public the renderUpdateCount in GameRenderer
public net.minecraft.client.renderer.GameRenderer field_78529_t # rendererUpdateCount
# make public the materialColor in AbstractBlockState
# used when generating LodChunks
public net.minecraft.block.AbstractBlock$AbstractBlockState field_235704_h_ # materialColor
#=====================#
# Examples from Forge #
#=====================#