fix view -IMS

This commit is contained in:
IThundxr 2024-08-10 10:31:20 -04:00
parent 68393d11bb
commit 475b1d8d7d
Failed to generate hash of commit
4 changed files with 10 additions and 12 deletions

View file

@ -16,7 +16,7 @@ public interface RenderContext {
RenderBuffers buffers();
PoseStack stack();
Matrix4fc modelView();
Matrix4fc projection();

View file

@ -71,7 +71,7 @@ public final class FrameUniforms extends UniformWriter {
var camY = (float) (cameraPos.y - renderOrigin.getY());
var camZ = (float) (cameraPos.z - renderOrigin.getZ());
VIEW.set(context.stack().last().pose());
VIEW.set(context.modelView());
VIEW.translate(-camX, -camY, -camZ);
PROJECTION.set(context.projection());
VIEW_PROJECTION.set(context.viewProjection());

View file

@ -11,14 +11,13 @@ import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.renderer.LevelRenderer;
import net.minecraft.client.renderer.RenderBuffers;
public record RenderContextImpl(LevelRenderer renderer, ClientLevel level, RenderBuffers buffers, PoseStack stack,
public record RenderContextImpl(LevelRenderer renderer, ClientLevel level, RenderBuffers buffers, Matrix4fc modelView,
Matrix4fc projection, Matrix4fc viewProjection, Camera camera,
float partialTick) implements RenderContext {
public static RenderContextImpl create(LevelRenderer renderer, ClientLevel level, RenderBuffers buffers, PoseStack stack, Matrix4f projection, Camera camera, float partialTick) {
public static RenderContextImpl create(LevelRenderer renderer, ClientLevel level, RenderBuffers buffers, Matrix4fc modelView, Matrix4f projection, Camera camera, float partialTick) {
Matrix4f viewProjection = new Matrix4f(projection);
viewProjection.mul(stack.last()
.pose());
viewProjection.mul(modelView);
return new RenderContextImpl(renderer, level, buffers, stack, projection, viewProjection, camera, partialTick);
return new RenderContextImpl(renderer, level, buffers, modelView, projection, viewProjection, camera, partialTick);
}
}

View file

@ -51,9 +51,8 @@ abstract class LevelRendererMixin {
// @Inject(method = "renderLevel", at = @At("HEAD"))
@Inject(method = "renderLevel", at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/world/level/lighting/LevelLightEngine;runLightUpdates()I"))
private void flywheel$beginRender(DeltaTracker deltaTracker, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f frustumMatrix, Matrix4f projectionMatrix, CallbackInfo ci, @Share("flywheel$poseStack") LocalRef<PoseStack> poseStack) {
PoseStack flywheel$poseStack = new PoseStack();
flywheel$renderContext = RenderContextImpl.create((LevelRenderer) (Object) this, level, renderBuffers, flywheel$poseStack, projectionMatrix, camera, deltaTracker.getGameTimeDeltaTicks());
private void flywheel$beginRender(DeltaTracker deltaTracker, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f modelMatrix, Matrix4f projectionMatrix, CallbackInfo ci) {
flywheel$renderContext = RenderContextImpl.create((LevelRenderer) (Object) this, level, renderBuffers, modelMatrix, projectionMatrix, camera, deltaTracker.getGameTimeDeltaTicks());
VisualizationManager manager = VisualizationManager.get(level);
if (manager != null) {
@ -114,8 +113,8 @@ abstract class LevelRendererMixin {
}
}
@Group(name = "afterParticles")
@Inject(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/particle/ParticleEngine;render(Lnet/minecraft/client/renderer/LightTexture;Lnet/minecraft/client/Camera;FLnet/minecraft/client/renderer/culling/Frustum;Ljava/util/function/Predicate;)V", shift = Shift.AFTER))
//@Group(name = "afterParticles")
//@Inject(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/particle/ParticleEngine;render(Lnet/minecraft/client/renderer/LightTexture;Lnet/minecraft/client/Camera;FLnet/minecraft/client/renderer/culling/Frustum;Ljava/util/function/Predicate;)V", shift = Shift.AFTER))
private void flywheel$afterParticles$forge(CallbackInfo ci) {
if (flywheel$renderContext != null) {
VisualizationManager manager = VisualizationManager.get(level);