Reduce render event GC pressure
This commit is contained in:
+4
-5
@@ -64,8 +64,6 @@ public class BlazeDebugWireframeRenderer extends AbstractDebugWireframeRenderer
|
|||||||
|
|
||||||
public static BlazeDebugWireframeRenderer INSTANCE = new BlazeDebugWireframeRenderer();
|
public static BlazeDebugWireframeRenderer INSTANCE = new BlazeDebugWireframeRenderer();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** A box from 0,0,0 to 1,1,1 */
|
/** A box from 0,0,0 to 1,1,1 */
|
||||||
private static final float[] BOX_VERTICES = {
|
private static final float[] BOX_VERTICES = {
|
||||||
//region
|
//region
|
||||||
@@ -100,6 +98,7 @@ public class BlazeDebugWireframeRenderer extends AbstractDebugWireframeRenderer
|
|||||||
//endregion
|
//endregion
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private static final Mat4f TRANSFORM_MATRIX = new Mat4f();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -268,13 +267,13 @@ public class BlazeDebugWireframeRenderer extends AbstractDebugWireframeRenderer
|
|||||||
box.maxPos.y - box.minPos.y,
|
box.maxPos.y - box.minPos.y,
|
||||||
box.maxPos.z - box.minPos.z));
|
box.maxPos.z - box.minPos.z));
|
||||||
|
|
||||||
Mat4f transformMatrix = this.dhMvmProjMatrixThisFrame.copy();
|
TRANSFORM_MATRIX.set(this.dhMvmProjMatrixThisFrame);
|
||||||
transformMatrix.multiply(boxTransform);
|
TRANSFORM_MATRIX.multiply(boxTransform);
|
||||||
|
|
||||||
|
|
||||||
// upload data //
|
// upload data //
|
||||||
this.uniformBufferWrapper
|
this.uniformBufferWrapper
|
||||||
.putMat4f(transformMatrix) // uTransform
|
.putMat4f(TRANSFORM_MATRIX) // uTransform
|
||||||
.putVec4f(
|
.putVec4f(
|
||||||
box.color.getRed() / 255.0f,
|
box.color.getRed() / 255.0f,
|
||||||
box.color.getGreen() / 255.0f,
|
box.color.getGreen() / 255.0f,
|
||||||
|
|||||||
+8
-2
@@ -36,6 +36,7 @@ import com.seibel.distanthorizons.api.interfaces.render.IDhApiRenderableBoxGroup
|
|||||||
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBeforeGenericObjectRenderEvent;
|
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBeforeGenericObjectRenderEvent;
|
||||||
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBeforeGenericRenderCleanupEvent;
|
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBeforeGenericRenderCleanupEvent;
|
||||||
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBeforeGenericRenderSetupEvent;
|
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBeforeGenericRenderSetupEvent;
|
||||||
|
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiRenderParam;
|
||||||
import com.seibel.distanthorizons.api.objects.math.DhApiVec3d;
|
import com.seibel.distanthorizons.api.objects.math.DhApiVec3d;
|
||||||
import com.seibel.distanthorizons.api.objects.render.DhApiRenderableBox;
|
import com.seibel.distanthorizons.api.objects.render.DhApiRenderableBox;
|
||||||
import com.seibel.distanthorizons.api.objects.render.DhApiRenderableBoxGroupShading;
|
import com.seibel.distanthorizons.api.objects.render.DhApiRenderableBoxGroupShading;
|
||||||
@@ -96,6 +97,10 @@ public class BlazeDhGenericObjectRenderer implements IDhGenericRenderer
|
|||||||
*/
|
*/
|
||||||
public static final boolean RENDER_DEBUG_OBJECTS = false;
|
public static final boolean RENDER_DEBUG_OBJECTS = false;
|
||||||
|
|
||||||
|
private static final DhApiBeforeGenericObjectRenderEvent.EventParam EVENT_PARAM = new DhApiBeforeGenericObjectRenderEvent.EventParam();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private final ConcurrentHashMap<Long, RenderableBoxGroup> boxGroupById = new ConcurrentHashMap<>();
|
private final ConcurrentHashMap<Long, RenderableBoxGroup> boxGroupById = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
|
||||||
@@ -343,7 +348,7 @@ public class BlazeDhGenericObjectRenderer implements IDhGenericRenderer
|
|||||||
|
|
||||||
this.init();
|
this.init();
|
||||||
|
|
||||||
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeGenericRenderSetupEvent.class, renderEventParam);
|
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeGenericRenderSetupEvent.class, renderEventParam.apiCopy);
|
||||||
|
|
||||||
Vec3d camPos = MC_RENDER.getCameraExactPosition();
|
Vec3d camPos = MC_RENDER.getCameraExactPosition();
|
||||||
|
|
||||||
@@ -389,7 +394,8 @@ public class BlazeDhGenericObjectRenderer implements IDhGenericRenderer
|
|||||||
}
|
}
|
||||||
|
|
||||||
// allow API users to cancel this object's rendering
|
// allow API users to cancel this object's rendering
|
||||||
boolean cancelRendering = ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeGenericObjectRenderEvent.class, new DhApiBeforeGenericObjectRenderEvent.EventParam(renderEventParam, boxGroup));
|
EVENT_PARAM.update(renderEventParam, boxGroup);
|
||||||
|
boolean cancelRendering = ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeGenericObjectRenderEvent.class, EVENT_PARAM);
|
||||||
if (cancelRendering)
|
if (cancelRendering)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
+9
-3
@@ -13,6 +13,7 @@ import com.mojang.blaze3d.systems.RenderSystem;
|
|||||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||||
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBeforeBufferRenderEvent;
|
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBeforeBufferRenderEvent;
|
||||||
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBeforeRenderPassEvent;
|
import com.seibel.distanthorizons.api.methods.events.abstractEvents.DhApiBeforeRenderPassEvent;
|
||||||
|
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiRenderParam;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.util.BlazeDhVertexFormatUtil;
|
import com.seibel.distanthorizons.common.render.blaze.util.BlazeDhVertexFormatUtil;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.BlazeVertexFormatBuilder;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.BlazeVertexFormatBuilder;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPassWrapper;
|
import com.seibel.distanthorizons.common.render.blaze.wrappers.RenderPassWrapper;
|
||||||
@@ -53,6 +54,10 @@ public class BlazeDhTerrainRenderer implements IDhTerrainRenderer
|
|||||||
|
|
||||||
public static final BlazeDhTerrainRenderer INSTANCE = new BlazeDhTerrainRenderer();
|
public static final BlazeDhTerrainRenderer INSTANCE = new BlazeDhTerrainRenderer();
|
||||||
|
|
||||||
|
private static final Vec3f MODEL_POS = new Vec3f();
|
||||||
|
/** single event object used to reduce GC pressure */
|
||||||
|
private static final DhApiBeforeBufferRenderEvent.EventParam BEFORE_BUFFER_RENDER_EVENT_PARAM = new DhApiBeforeBufferRenderEvent.EventParam();
|
||||||
|
|
||||||
|
|
||||||
private RenderPipeline opaquePipeline;
|
private RenderPipeline opaquePipeline;
|
||||||
private RenderPipeline transparentPipeline;
|
private RenderPipeline transparentPipeline;
|
||||||
@@ -240,7 +245,7 @@ public class BlazeDhTerrainRenderer implements IDhTerrainRenderer
|
|||||||
{
|
{
|
||||||
profiler.popPush("rendering");
|
profiler.popPush("rendering");
|
||||||
|
|
||||||
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeRenderPassEvent.class, renderEventParam);
|
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeRenderPassEvent.class, renderEventParam.apiCopy);
|
||||||
|
|
||||||
// create a render pass
|
// create a render pass
|
||||||
try (RenderPassWrapper renderPassWrapper = new RenderPassWrapper(
|
try (RenderPassWrapper renderPassWrapper = new RenderPassWrapper(
|
||||||
@@ -300,11 +305,12 @@ public class BlazeDhTerrainRenderer implements IDhTerrainRenderer
|
|||||||
// fire render event
|
// fire render event
|
||||||
{
|
{
|
||||||
Vec3d camPos = renderEventParam.exactCameraPosition;
|
Vec3d camPos = renderEventParam.exactCameraPosition;
|
||||||
Vec3f modelPos = new Vec3f(
|
MODEL_POS.set(
|
||||||
(float) (bufferContainer.minCornerBlockPos.getX() - camPos.x),
|
(float) (bufferContainer.minCornerBlockPos.getX() - camPos.x),
|
||||||
(float) (bufferContainer.minCornerBlockPos.getY() - camPos.y),
|
(float) (bufferContainer.minCornerBlockPos.getY() - camPos.y),
|
||||||
(float) (bufferContainer.minCornerBlockPos.getZ() - camPos.z));
|
(float) (bufferContainer.minCornerBlockPos.getZ() - camPos.z));
|
||||||
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeBufferRenderEvent.class, new DhApiBeforeBufferRenderEvent.EventParam(renderEventParam, modelPos));
|
BEFORE_BUFFER_RENDER_EVENT_PARAM.update(renderEventParam, MODEL_POS);
|
||||||
|
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeBufferRenderEvent.class, BEFORE_BUFFER_RENDER_EVENT_PARAM);
|
||||||
}
|
}
|
||||||
|
|
||||||
renderPassWrapper.setIndexBuffer(bufferWrapper.getIndexGpuBuffer());
|
renderPassWrapper.setIndexBuffer(bufferWrapper.getIndexGpuBuffer());
|
||||||
|
|||||||
+1
-10
@@ -159,20 +159,11 @@ public class BlazeDhFarFadeRenderer implements IDhFarFadeRenderer
|
|||||||
float fadeEndDistance = dhFarClipDistance * 0.9f;
|
float fadeEndDistance = dhFarClipDistance * 0.9f;
|
||||||
|
|
||||||
|
|
||||||
Mat4f dhProjectionMatrix = RenderUtil.createLodProjectionMatrix(renderParams.mcProjectionMatrix);
|
|
||||||
Mat4f dhModelViewMatrix = RenderUtil.createLodModelViewMatrix(renderParams.mcModelViewMatrix);
|
|
||||||
|
|
||||||
Mat4f inverseDhMvmProjMatrix = new Mat4f(dhProjectionMatrix);
|
|
||||||
inverseDhMvmProjMatrix.multiply(dhModelViewMatrix);
|
|
||||||
inverseDhMvmProjMatrix.invert();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// upload data //
|
// upload data //
|
||||||
fragUniformBufferWrapper
|
fragUniformBufferWrapper
|
||||||
.putFloat(fadeStartDistance) // uStartFadeBlockDistance
|
.putFloat(fadeStartDistance) // uStartFadeBlockDistance
|
||||||
.putFloat(fadeEndDistance) // uEndFadeBlockDistance
|
.putFloat(fadeEndDistance) // uEndFadeBlockDistance
|
||||||
.putMat4f(inverseDhMvmProjMatrix) // uDhInvMvmProj
|
.putMat4f(renderParams.dhInverseMvmProjectionMatrix) // uDhInvMvmProj
|
||||||
.putInt((RENDER_API_DEF.getRenderDepth() == EDhRenderDepth.REVERSE_Z) ? 1 : 0) // uIsReverseZDepth
|
.putInt((RENDER_API_DEF.getRenderDepth() == EDhRenderDepth.REVERSE_Z) ? 1 : 0) // uIsReverseZDepth
|
||||||
.finishAndUpload()
|
.finishAndUpload()
|
||||||
;
|
;
|
||||||
|
|||||||
+3
-2
@@ -12,6 +12,7 @@ import com.mojang.blaze3d.buffers.Std140SizeCalculator;
|
|||||||
import com.mojang.blaze3d.systems.CommandEncoder;
|
import com.mojang.blaze3d.systems.CommandEncoder;
|
||||||
import com.mojang.blaze3d.systems.GpuDevice;
|
import com.mojang.blaze3d.systems.GpuDevice;
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
import com.seibel.distanthorizons.api.objects.math.DhApiMat4f;
|
||||||
import com.seibel.distanthorizons.common.render.blaze.util.BlazeUniformUtil;
|
import com.seibel.distanthorizons.common.render.blaze.util.BlazeUniformUtil;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||||
@@ -91,10 +92,10 @@ public class BlazeUniformBufferWrapper implements AutoCloseable
|
|||||||
this.uniformBufferBuilder.putVec4(x,y,z,w);
|
this.uniformBufferBuilder.putVec4(x,y,z,w);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public BlazeUniformBufferWrapper putMat4f(Mat4f matrix)
|
public BlazeUniformBufferWrapper putMat4f(DhApiMat4f matrix)
|
||||||
{
|
{
|
||||||
this.putElement(EUniformElement.MAT4f);
|
this.putElement(EUniformElement.MAT4f);
|
||||||
this.uniformBufferBuilder.putMat4f(matrix.createJomlMatrix());
|
this.uniformBufferBuilder.putMat4f(Mat4f.createJomlMatrix(matrix));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public BlazeUniformBufferWrapper putFloat(float f)
|
public BlazeUniformBufferWrapper putFloat(float f)
|
||||||
|
|||||||
+5
-3
@@ -75,6 +75,7 @@ public class GlGenericObjectRenderer implements IDhGenericRenderer
|
|||||||
|
|
||||||
private static final DhApiRenderableBoxGroupShading DEFAULT_SHADING = DhApiRenderableBoxGroupShading.getUnshaded();
|
private static final DhApiRenderableBoxGroupShading DEFAULT_SHADING = DhApiRenderableBoxGroupShading.getUnshaded();
|
||||||
|
|
||||||
|
private static final DhApiBeforeGenericObjectRenderEvent.EventParam EVENT_PARAM = new DhApiBeforeGenericObjectRenderEvent.EventParam();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Can be used to troubleshoot the renderer.
|
* Can be used to troubleshoot the renderer.
|
||||||
@@ -418,7 +419,7 @@ public class GlGenericObjectRenderer implements IDhGenericRenderer
|
|||||||
|
|
||||||
this.init();
|
this.init();
|
||||||
|
|
||||||
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeGenericRenderSetupEvent.class, renderEventParam);
|
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeGenericRenderSetupEvent.class, renderEventParam.apiCopy);
|
||||||
|
|
||||||
|
|
||||||
boolean renderWireframe = Config.Client.Advanced.Debugging.renderWireframe.get();
|
boolean renderWireframe = Config.Client.Advanced.Debugging.renderWireframe.get();
|
||||||
@@ -482,7 +483,8 @@ public class GlGenericObjectRenderer implements IDhGenericRenderer
|
|||||||
}
|
}
|
||||||
|
|
||||||
// allow API users to cancel this object's rendering
|
// allow API users to cancel this object's rendering
|
||||||
boolean cancelRendering = ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeGenericObjectRenderEvent.class, new DhApiBeforeGenericObjectRenderEvent.EventParam(renderEventParam, boxGroup));
|
EVENT_PARAM.update(renderEventParam, boxGroup);
|
||||||
|
boolean cancelRendering = ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeGenericObjectRenderEvent.class, EVENT_PARAM);
|
||||||
if (cancelRendering)
|
if (cancelRendering)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -529,7 +531,7 @@ public class GlGenericObjectRenderer implements IDhGenericRenderer
|
|||||||
|
|
||||||
profiler.popPush("cleanup");
|
profiler.popPush("cleanup");
|
||||||
|
|
||||||
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeGenericRenderCleanupEvent.class, renderEventParam);
|
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeGenericRenderCleanupEvent.class, renderEventParam.apiCopy);
|
||||||
|
|
||||||
if (renderWireframe)
|
if (renderWireframe)
|
||||||
{
|
{
|
||||||
|
|||||||
+30
-5
@@ -22,6 +22,7 @@ package com.seibel.distanthorizons.common.render.openGl.glObject.shader;
|
|||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.nio.FloatBuffer;
|
import java.nio.FloatBuffer;
|
||||||
|
|
||||||
|
import com.seibel.distanthorizons.api.objects.math.DhApiMat4f;
|
||||||
import com.seibel.distanthorizons.api.objects.math.DhApiVec3i;
|
import com.seibel.distanthorizons.api.objects.math.DhApiVec3i;
|
||||||
import org.lwjgl.opengl.GL32;
|
import org.lwjgl.opengl.GL32;
|
||||||
import org.lwjgl.system.MemoryStack;
|
import org.lwjgl.system.MemoryStack;
|
||||||
@@ -187,20 +188,44 @@ public class GlShaderProgram
|
|||||||
|
|
||||||
/** Requires a bound ShaderProgram. */
|
/** Requires a bound ShaderProgram. */
|
||||||
public void setUniform(int location, DhApiVec3i value) { GL32.glUniform3i(location, value.x, value.y, value.z); }
|
public void setUniform(int location, DhApiVec3i value) { GL32.glUniform3i(location, value.x, value.y, value.z); }
|
||||||
/** @see GlShaderProgram#setUniform(int, Mat4f) */
|
/** @see GlShaderProgram#setUniform(int, DhApiMat4f) */
|
||||||
public void trySetUniform(int location, DhApiVec3i value) { if (location != -1) { this.setUniform(location, value); } }
|
public void trySetUniform(int location, DhApiVec3i value) { if (location != -1) { this.setUniform(location, value); } }
|
||||||
|
|
||||||
/** Requires a bound ShaderProgram. */
|
/** Requires a bound ShaderProgram. */
|
||||||
public void setUniform(int location, Mat4f value)
|
public void setUniform(int location, DhApiMat4f value)
|
||||||
{
|
{
|
||||||
try (MemoryStack stack = MemoryStack.stackPush())
|
try (MemoryStack stack = MemoryStack.stackPush())
|
||||||
{
|
{
|
||||||
FloatBuffer buffer = stack.mallocFloat(4 * 4);
|
FloatBuffer buffer = stack.mallocFloat(16);
|
||||||
value.store(buffer);
|
storeMatrixInBuffer(value, buffer);
|
||||||
GL32.glUniformMatrix4fv(location, false, buffer);
|
GL32.glUniformMatrix4fv(location, false, buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/** @see GlShaderProgram#setUniform(int, Mat4f) */
|
private static void storeMatrixInBuffer(DhApiMat4f matrix, FloatBuffer floatBuffer)
|
||||||
|
{
|
||||||
|
floatBuffer.put(bufferIndex(0, 0), matrix.m00);
|
||||||
|
floatBuffer.put(bufferIndex(0, 1), matrix.m01);
|
||||||
|
floatBuffer.put(bufferIndex(0, 2), matrix.m02);
|
||||||
|
floatBuffer.put(bufferIndex(0, 3), matrix.m03);
|
||||||
|
|
||||||
|
floatBuffer.put(bufferIndex(1, 0), matrix.m10);
|
||||||
|
floatBuffer.put(bufferIndex(1, 1), matrix.m11);
|
||||||
|
floatBuffer.put(bufferIndex(1, 2), matrix.m12);
|
||||||
|
floatBuffer.put(bufferIndex(1, 3), matrix.m13);
|
||||||
|
|
||||||
|
floatBuffer.put(bufferIndex(2, 0), matrix.m20);
|
||||||
|
floatBuffer.put(bufferIndex(2, 1), matrix.m21);
|
||||||
|
floatBuffer.put(bufferIndex(2, 2), matrix.m22);
|
||||||
|
floatBuffer.put(bufferIndex(2, 3), matrix.m23);
|
||||||
|
|
||||||
|
floatBuffer.put(bufferIndex(3, 0), matrix.m30);
|
||||||
|
floatBuffer.put(bufferIndex(3, 1), matrix.m31);
|
||||||
|
floatBuffer.put(bufferIndex(3, 2), matrix.m32);
|
||||||
|
floatBuffer.put(bufferIndex(3, 3), matrix.m33);
|
||||||
|
}
|
||||||
|
private static int bufferIndex(int xIndex, int zIndex) { return (zIndex * 4) + xIndex; }
|
||||||
|
|
||||||
|
/** @see GlShaderProgram#setUniform(int, DhApiMat4f) */
|
||||||
public void trySetUniform(int location, Mat4f value) { if (location != -1) { this.setUniform(location, value); } }
|
public void trySetUniform(int location, Mat4f value) { if (location != -1) { this.setUniform(location, value); } }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+1
-1
@@ -136,7 +136,7 @@ public class GlDhFarFadeRenderer implements IDhFarFadeRenderer
|
|||||||
|
|
||||||
|
|
||||||
GlDhFarFadeShader.INSTANCE.frameBuffer = this.fadeFramebuffer;
|
GlDhFarFadeShader.INSTANCE.frameBuffer = this.fadeFramebuffer;
|
||||||
GlDhFarFadeShader.INSTANCE.setProjectionMatrix(renderParams.mcModelViewMatrix, renderParams.mcProjectionMatrix);
|
GlDhFarFadeShader.INSTANCE.setProjectionMatrix(renderParams);
|
||||||
GlDhFarFadeShader.INSTANCE.render(renderParams);
|
GlDhFarFadeShader.INSTANCE.render(renderParams);
|
||||||
|
|
||||||
GlDhFarFadeApplyShader.INSTANCE.fadeTexture = this.fadeTexture;
|
GlDhFarFadeApplyShader.INSTANCE.fadeTexture = this.fadeTexture;
|
||||||
|
|||||||
+3
-9
@@ -42,7 +42,7 @@ public class GlDhFarFadeShader extends GlAbstractShaderRenderer
|
|||||||
|
|
||||||
public int frameBuffer = -1;
|
public int frameBuffer = -1;
|
||||||
|
|
||||||
private Mat4f inverseDhMvmProjMatrix;
|
private DhApiMat4f inverseDhMvmProjMatrix;
|
||||||
|
|
||||||
|
|
||||||
// Uniforms
|
// Uniforms
|
||||||
@@ -110,15 +110,9 @@ public class GlDhFarFadeShader extends GlAbstractShaderRenderer
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProjectionMatrix(DhApiMat4f mcModelViewMatrix, DhApiMat4f mcProjectionMatrix)
|
public void setProjectionMatrix(RenderParams renderParams)
|
||||||
{
|
{
|
||||||
Mat4f dhProjectionMatrix = RenderUtil.createLodProjectionMatrix(mcProjectionMatrix);
|
this.inverseDhMvmProjMatrix = renderParams.dhInverseMvmProjectionMatrix;
|
||||||
Mat4f dhModelViewMatrix = RenderUtil.createLodModelViewMatrix(mcModelViewMatrix);
|
|
||||||
|
|
||||||
Mat4f inverseDhModelViewProjectionMatrix = new Mat4f(dhProjectionMatrix);
|
|
||||||
inverseDhModelViewProjectionMatrix.multiply(dhModelViewMatrix);
|
|
||||||
inverseDhModelViewProjectionMatrix.invert();
|
|
||||||
this.inverseDhMvmProjMatrix = inverseDhModelViewProjectionMatrix;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+5
-16
@@ -43,8 +43,8 @@ public class GlDhVanillaFadeShader extends GlAbstractShaderRenderer
|
|||||||
|
|
||||||
public int frameBuffer = -1;
|
public int frameBuffer = -1;
|
||||||
|
|
||||||
private Mat4f inverseMcMvmProjMatrix;
|
private DhApiMat4f inverseMcMvmProjMatrix;
|
||||||
private Mat4f inverseDhMvmProjMatrix;
|
private DhApiMat4f inverseDhMvmProjMatrix;
|
||||||
private float levelMaxHeight;
|
private float levelMaxHeight;
|
||||||
|
|
||||||
|
|
||||||
@@ -136,21 +136,10 @@ public class GlDhVanillaFadeShader extends GlAbstractShaderRenderer
|
|||||||
this.shader.setUniform(this.uOnlyRenderLods, Config.Client.Advanced.Debugging.lodOnlyMode.get());
|
this.shader.setUniform(this.uOnlyRenderLods, Config.Client.Advanced.Debugging.lodOnlyMode.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProjectionMatrix(DhApiMat4f mcModelViewMatrix, DhApiMat4f mcProjectionMatrix)
|
public void setProjectionMatrix(RenderParams renderParams)
|
||||||
{
|
{
|
||||||
Mat4f inverseMcModelViewProjectionMatrix = new Mat4f(mcProjectionMatrix);
|
this.inverseMcMvmProjMatrix = renderParams.mcInverseMvmProjectionMatrix;
|
||||||
inverseMcModelViewProjectionMatrix.multiply(mcModelViewMatrix);
|
this.inverseDhMvmProjMatrix = renderParams.dhInverseMvmProjectionMatrix;
|
||||||
inverseMcModelViewProjectionMatrix.invert();
|
|
||||||
this.inverseMcMvmProjMatrix = inverseMcModelViewProjectionMatrix;
|
|
||||||
|
|
||||||
|
|
||||||
Mat4f dhProjectionMatrix = RenderUtil.createLodProjectionMatrix(mcProjectionMatrix);
|
|
||||||
Mat4f dhModelViewMatrix = RenderUtil.createLodModelViewMatrix(mcModelViewMatrix);
|
|
||||||
|
|
||||||
Mat4f inverseDhModelViewProjectionMatrix = new Mat4f(dhProjectionMatrix);
|
|
||||||
inverseDhModelViewProjectionMatrix.multiply(dhModelViewMatrix);
|
|
||||||
inverseDhModelViewProjectionMatrix.invert();
|
|
||||||
this.inverseDhMvmProjMatrix = inverseDhModelViewProjectionMatrix;
|
|
||||||
}
|
}
|
||||||
public void setLevelMaxHeight(int levelMaxHeight) { this.levelMaxHeight = levelMaxHeight; }
|
public void setLevelMaxHeight(int levelMaxHeight) { this.levelMaxHeight = levelMaxHeight; }
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -152,7 +152,7 @@ public class GlVanillaFadeRenderer implements IDhVanillaFadeRenderer
|
|||||||
|
|
||||||
|
|
||||||
GlDhVanillaFadeShader.INSTANCE.frameBuffer = this.fadeFramebuffer;
|
GlDhVanillaFadeShader.INSTANCE.frameBuffer = this.fadeFramebuffer;
|
||||||
GlDhVanillaFadeShader.INSTANCE.setProjectionMatrix(renderParams.mcModelViewMatrix, renderParams.mcProjectionMatrix);
|
GlDhVanillaFadeShader.INSTANCE.setProjectionMatrix(renderParams);
|
||||||
GlDhVanillaFadeShader.INSTANCE.setLevelMaxHeight(renderParams.clientLevelWrapper.getMaxHeight());
|
GlDhVanillaFadeShader.INSTANCE.setLevelMaxHeight(renderParams.clientLevelWrapper.getMaxHeight());
|
||||||
GlDhVanillaFadeShader.INSTANCE.render(renderParams);
|
GlDhVanillaFadeShader.INSTANCE.render(renderParams);
|
||||||
|
|
||||||
|
|||||||
+10
-4
@@ -46,6 +46,11 @@ public class GlDhTerrainShaderProgram extends GlShaderProgram implements IDhApiS
|
|||||||
private static final MinecraftGLWrapper GLMC = MinecraftGLWrapper.INSTANCE;
|
private static final MinecraftGLWrapper GLMC = MinecraftGLWrapper.INSTANCE;
|
||||||
private static final IIrisAccessor IRIS_ACCESSOR = ModAccessorInjector.INSTANCE.get(IIrisAccessor.class);
|
private static final IIrisAccessor IRIS_ACCESSOR = ModAccessorInjector.INSTANCE.get(IIrisAccessor.class);
|
||||||
|
|
||||||
|
private static final Vec3f MODEL_POS = new Vec3f();
|
||||||
|
/** single event object used to reduce GC pressure */
|
||||||
|
private static final DhApiBeforeBufferRenderEvent.EventParam BEFORE_BUFFER_RENDER_EVENT_PARAM = new DhApiBeforeBufferRenderEvent.EventParam();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private boolean init = false;
|
private boolean init = false;
|
||||||
|
|
||||||
@@ -291,7 +296,7 @@ public class GlDhTerrainShaderProgram extends GlShaderProgram implements IDhApiS
|
|||||||
|
|
||||||
// needs to be triggered after DH attempts to set the GL state so that Iris
|
// needs to be triggered after DH attempts to set the GL state so that Iris
|
||||||
// can override it as needed
|
// can override it as needed
|
||||||
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeRenderPassEvent.class, renderEventParam);
|
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeRenderPassEvent.class, renderEventParam.apiCopy);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -324,15 +329,16 @@ public class GlDhTerrainShaderProgram extends GlShaderProgram implements IDhApiS
|
|||||||
// set uniforms and fire events
|
// set uniforms and fire events
|
||||||
{
|
{
|
||||||
Vec3d camPos = renderEventParam.exactCameraPosition;
|
Vec3d camPos = renderEventParam.exactCameraPosition;
|
||||||
Vec3f modelPos = new Vec3f(
|
MODEL_POS.set(
|
||||||
(float) (bufferContainer.minCornerBlockPos.getX() - camPos.x),
|
(float) (bufferContainer.minCornerBlockPos.getX() - camPos.x),
|
||||||
(float) (bufferContainer.minCornerBlockPos.getY() - camPos.y),
|
(float) (bufferContainer.minCornerBlockPos.getY() - camPos.y),
|
||||||
(float) (bufferContainer.minCornerBlockPos.getZ() - camPos.z));
|
(float) (bufferContainer.minCornerBlockPos.getZ() - camPos.z));
|
||||||
|
BEFORE_BUFFER_RENDER_EVENT_PARAM.update(renderEventParam, MODEL_POS);
|
||||||
|
|
||||||
GlDhMetaRenderer.INSTANCE.shaderProgramForThisFrame.bind();
|
GlDhMetaRenderer.INSTANCE.shaderProgramForThisFrame.bind();
|
||||||
GlDhMetaRenderer.INSTANCE.shaderProgramForThisFrame.setModelOffsetPos(modelPos);
|
GlDhMetaRenderer.INSTANCE.shaderProgramForThisFrame.setModelOffsetPos(MODEL_POS);
|
||||||
|
|
||||||
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeBufferRenderEvent.class, new DhApiBeforeBufferRenderEvent.EventParam(renderEventParam, modelPos));
|
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeBufferRenderEvent.class, BEFORE_BUFFER_RENDER_EVENT_PARAM);
|
||||||
}
|
}
|
||||||
|
|
||||||
IVertexBufferWrapper[] vertexBuffers = (opaquePass ? bufferContainer.vboOpaqueWrappers : bufferContainer.vboTransparentWrappers);
|
IVertexBufferWrapper[] vertexBuffers = (opaquePass ? bufferContainer.vboOpaqueWrappers : bufferContainer.vboTransparentWrappers);
|
||||||
|
|||||||
+1
-1
Submodule coreSubProjects updated: 8cd926f4ac...95e4db2998
Reference in New Issue
Block a user