mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-24 22:24:27 +00:00
Adjust vsync and fps limiters, and fix WSR with player models (#2002)
This commit is contained in:
1 parent
8c31eec525
commit
3659b59db9
36 files changed
+1494
-292
No files matched your search
@@ -0,0 +1,8 @@
|
||||
package com.gtnewhorizons.angelica.mixins.interfaces;
|
||||
|
||||
import net.minecraft.client.model.TexturedQuad;
|
||||
|
||||
public interface ModelBoxQuads {
|
||||
|
||||
TexturedQuad[] angelica$getQuadList();
|
||||
}
|
||||
@@ -106,6 +106,10 @@ public final class ClientProxy extends CommonProxy {
|
||||
return CONFIG;
|
||||
}
|
||||
|
||||
public static void applyVSyncMode(boolean vsyncEnabled) {
|
||||
GLStateManager.setVSyncMode(options().advanced.vsyncMode, vsyncEnabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
ModStatus.preInit();
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
package com.gtnewhorizons.angelica.rendering;
|
||||
|
||||
import com.gtnewhorizons.angelica.AngelicaMod;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import com.gtnewhorizons.angelica.glsm.backend.VSyncMode;
|
||||
|
||||
public final class FramePacer {
|
||||
|
||||
private static final int MIN_PLAUSIBLE_REFRESH_HZ = 20;
|
||||
private static final int MAX_PLAUSIBLE_REFRESH_HZ = 1000;
|
||||
private static final long REFRESH_POLL_NANOS = 1_000_000_000L;
|
||||
|
||||
private static long lastFrameTime;
|
||||
private static long fpsLimitOverhead;
|
||||
|
||||
private static long lastRefreshPollNanos;
|
||||
private static int cachedRefreshHz;
|
||||
private static boolean warnedUnknownRefresh;
|
||||
|
||||
private static VSyncMode lastVSyncMode = VSyncMode.ON;
|
||||
private static int lastCapHz;
|
||||
private static int lastRefreshHz;
|
||||
|
||||
private FramePacer() {}
|
||||
|
||||
public static int plausibleRefreshHz(int hz) {
|
||||
return hz >= MIN_PLAUSIBLE_REFRESH_HZ && hz <= MAX_PLAUSIBLE_REFRESH_HZ ? hz : 0;
|
||||
}
|
||||
|
||||
public static int pacingCeilingHz(VSyncMode mode, int capHz, int refreshHz) {
|
||||
if (mode.blocksOnVBlank()) return 0;
|
||||
final int cap = Math.max(capHz, 0);
|
||||
if (mode != VSyncMode.MAILBOX) return cap;
|
||||
final int refresh = plausibleRefreshHz(refreshHz);
|
||||
if (cap == 0) return refresh;
|
||||
return refresh == 0 ? cap : Math.min(cap, refresh);
|
||||
}
|
||||
|
||||
public static long sleepNanosFor(long targetNanos, long lastWorkNanos, long overheadNanos) {
|
||||
return targetNanos - lastWorkNanos - overheadNanos;
|
||||
}
|
||||
|
||||
public static int updateCeiling(int capHz) {
|
||||
lastVSyncMode = GLStateManager.getEffectiveVSyncMode();
|
||||
lastCapHz = Math.max(capHz, 0);
|
||||
lastRefreshHz = refreshHz();
|
||||
return pacingCeilingHz(lastVSyncMode, lastCapHz, lastRefreshHz);
|
||||
}
|
||||
|
||||
public static long pace(int ceilingHz) {
|
||||
if (ceilingHz > 0) {
|
||||
final long time = System.nanoTime();
|
||||
final long targetNanos = 1_000_000_000L / ceilingHz;
|
||||
|
||||
final long sleepNanos = sleepNanosFor(targetNanos, time - lastFrameTime, fpsLimitOverhead);
|
||||
if (sleepNanos > 0) {
|
||||
try {
|
||||
Thread.sleep(sleepNanos / 1_000_000, (int) sleepNanos % 1_000_000);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
long overhead = System.nanoTime() - time - sleepNanos;
|
||||
if (overhead < 0 || overhead > targetNanos / 2) overhead = 0;
|
||||
fpsLimitOverhead = overhead;
|
||||
}
|
||||
}
|
||||
|
||||
final long time = System.nanoTime();
|
||||
final long period = time - lastFrameTime;
|
||||
lastFrameTime = time;
|
||||
return period;
|
||||
}
|
||||
|
||||
private static int refreshHz() {
|
||||
final long now = System.nanoTime();
|
||||
if (lastRefreshPollNanos == 0L || now - lastRefreshPollNanos >= REFRESH_POLL_NANOS) {
|
||||
lastRefreshPollNanos = now;
|
||||
cachedRefreshHz = GLStateManager.getDisplayRefreshRateHz();
|
||||
}
|
||||
final int hz = plausibleRefreshHz(cachedRefreshHz);
|
||||
|
||||
if (hz == 0 && lastVSyncMode == VSyncMode.MAILBOX && !warnedUnknownRefresh) {
|
||||
warnedUnknownRefresh = true;
|
||||
AngelicaMod.LOGGER.warn("Display refresh rate reported as {}Hz; Mailbox will not be paced to the refresh rate. The Max Framerate setting still applies.", cachedRefreshHz);
|
||||
}
|
||||
return hz;
|
||||
}
|
||||
|
||||
public static String debugIndicator(VSyncMode mode, int refreshHz, int capHz) {
|
||||
final boolean vsync = mode.blocksOnVBlank();
|
||||
final boolean mailbox = mode == VSyncMode.MAILBOX;
|
||||
|
||||
final boolean showCap = capHz > 0 && !vsync;
|
||||
if (!vsync && !mailbox && !showCap) return null;
|
||||
|
||||
final StringBuilder sb = new StringBuilder(" [");
|
||||
if (vsync || mailbox) {
|
||||
sb.append(vsync ? "vsync" : "mailbox");
|
||||
if (refreshHz > 0) sb.append(' ').append(refreshHz);
|
||||
if (showCap) sb.append(", ");
|
||||
}
|
||||
if (showCap) sb.append("cap ").append(capHz);
|
||||
return sb.append(']').toString();
|
||||
}
|
||||
|
||||
public static String debugIndicator() {
|
||||
return debugIndicator(lastVSyncMode, lastRefreshHz, lastCapHz);
|
||||
}
|
||||
|
||||
public static VSyncMode lastVSyncMode() { return lastVSyncMode; }
|
||||
|
||||
public static int lastCapHz() { return lastCapHz; }
|
||||
|
||||
public static int lastRefreshHz() { return lastRefreshHz; }
|
||||
}
|
||||
@@ -5,66 +5,103 @@ import com.gtnewhorizon.gtnhlib.client.renderer.vertex.VertexFlags;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vertex.VertexFormat;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import com.gtnewhorizons.angelica.glsm.QuadConverter;
|
||||
import com.gtnewhorizons.angelica.glsm.profiling.Tracy;
|
||||
import com.gtnewhorizons.angelica.glsm.states.ColorMask;
|
||||
import com.gtnewhorizons.angelica.glsm.texture.TextureInfo;
|
||||
import com.gtnewhorizons.angelica.glsm.texture.TextureInfoCache;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.ModelBoxQuads;
|
||||
import com.gtnewhorizons.angelica.rendering.tesr.PassRebindGate;
|
||||
import lombok.Getter;
|
||||
import net.coderbot.iris.Iris;
|
||||
import net.coderbot.iris.gl.blending.DepthColorStorage;
|
||||
import net.coderbot.iris.gl.image.GlImage;
|
||||
import net.coderbot.iris.pipeline.DeferredWorldRenderingPipeline;
|
||||
import net.coderbot.iris.uniforms.CapturedRenderingState;
|
||||
import net.minecraft.client.model.ModelBiped;
|
||||
import net.minecraft.client.model.ModelBox;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
import net.minecraft.client.model.PositionTextureVertex;
|
||||
import net.minecraft.client.model.TexturedQuad;
|
||||
import net.minecraft.client.renderer.entity.Render;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.entity.RendererLivingEntity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Vector3f;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL13;
|
||||
import org.lwjgl.opengl.GL15;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities.memAddress0;
|
||||
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities.memAlloc;
|
||||
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities.memFree;
|
||||
|
||||
/**
|
||||
* Skins in 1.7.10 are 64x32 while modern has 64x64 textures. We have to address it here.
|
||||
* Feeds the shaderpack's world-space player reflection, which expects the modern 12-box player model:
|
||||
* 288 vertices over a 64x64 skin layout. 1.7.10 has 7 boxes and a 64x32 layout, so both are synthesized here.
|
||||
*/
|
||||
public final class PlayerReflectionCapture {
|
||||
|
||||
public static final int VERTEX_COUNT = 288;
|
||||
public static final int FLOATS_PER_VERTEX = 5; // x, y, z, u, v
|
||||
public static final int PART_COUNT = 12;
|
||||
public static final int VERTICES_PER_PART = VERTEX_COUNT / PART_COUNT;
|
||||
|
||||
private static final int RAW_INTS_PER_VERTEX = 8;
|
||||
|
||||
private static final int ATLAS_LAYOUT = 64;
|
||||
|
||||
private static final int VERTEX_FLAGS = VertexFlags.convertToFlags(true, false, true, false);
|
||||
|
||||
private static final Tracy.ZoneId Z_PLAYER_REFLECTION_FLUSH = Tracy.zoneId("playerReflectionFlush", Tracy.COLOR_IRIS);
|
||||
|
||||
private static boolean active;
|
||||
private static boolean drawnThisCapture;
|
||||
private static boolean captured;
|
||||
@Getter
|
||||
private static Object target;
|
||||
|
||||
@Getter
|
||||
private static EntityPlayer targetEntity;
|
||||
|
||||
private static boolean pending;
|
||||
private static final Matrix4f pendingModelView = new Matrix4f();
|
||||
private static int pendingSkin;
|
||||
private static int pendingEntityId;
|
||||
|
||||
private static int vbo;
|
||||
private static int vao;
|
||||
|
||||
private static int[] rawData;
|
||||
private static float[] vertexScratch;
|
||||
private static int skin64Tex;
|
||||
private static int skin64Size;
|
||||
private static boolean skin64Valid;
|
||||
private static ByteBuffer skinPixels;
|
||||
private static int lastCapturedSkin;
|
||||
private static int lastUploadedAtlas;
|
||||
private static int skinCopyWidth = 64;
|
||||
private static int skinCopyHeight = 32;
|
||||
private static TextureInfo lastCapturedInfo;
|
||||
private static int lastCapturedGeneration = -1;
|
||||
private static TextureInfo lastUploadedAtlasInfo;
|
||||
private static int lastUploadedAtlasGeneration = -1;
|
||||
private static int skinCopyWidth;
|
||||
private static int skinCopyHeight;
|
||||
private static ByteBuffer repackBuffer;
|
||||
private static long repackAddress;
|
||||
private static int repackCapacity;
|
||||
|
||||
private static final ModelRenderer[] partOrder = new ModelRenderer[PART_COUNT];
|
||||
private static final Matrix4f partMatrix = new Matrix4f();
|
||||
private static final Vector3f partVertex = new Vector3f();
|
||||
private static final Matrix4f savedModelView = new Matrix4f();
|
||||
|
||||
private PlayerReflectionCapture() {}
|
||||
|
||||
public static void begin(EntityPlayer player) {
|
||||
active = false;
|
||||
drawnThisCapture = false;
|
||||
captured = false;
|
||||
pending = false;
|
||||
target = null;
|
||||
targetEntity = null;
|
||||
if (player == null) return;
|
||||
@@ -79,24 +116,122 @@ public final class PlayerReflectionCapture {
|
||||
|
||||
public static void end() {
|
||||
active = false;
|
||||
pending = false;
|
||||
target = null;
|
||||
targetEntity = null;
|
||||
}
|
||||
|
||||
public static boolean shouldCapture() {
|
||||
return active && !drawnThisCapture;
|
||||
return active && !captured;
|
||||
}
|
||||
|
||||
/**
|
||||
* Emit the 288-vertex player batch VBO.
|
||||
*/
|
||||
public static void drawPlayerCapture(float[] xyzuv) {
|
||||
if (drawnThisCapture) return;
|
||||
drawnThisCapture = true;
|
||||
public static void emitAndSubmit(ModelBiped model, float scale) {
|
||||
captured = true;
|
||||
|
||||
final float[] data = vertexScratch();
|
||||
emitModel(model, scale, data);
|
||||
|
||||
pendingModelView.set(GLStateManager.getModelViewMatrix());
|
||||
pendingSkin = GLStateManager.getBoundTextureForServerState(0);
|
||||
pendingEntityId = CapturedRenderingState.INSTANCE.getCurrentRenderedEntity();
|
||||
pending = true;
|
||||
}
|
||||
|
||||
public static ModelRenderer[] partOrder(ModelBiped model, ModelRenderer[] out) {
|
||||
out[0] = model.bipedHead;
|
||||
out[1] = model.bipedHeadwear;
|
||||
out[2] = model.bipedRightArm;
|
||||
out[3] = model.bipedRightArm;
|
||||
out[4] = model.bipedLeftLeg;
|
||||
out[5] = model.bipedLeftLeg;
|
||||
out[6] = model.bipedLeftArm;
|
||||
out[7] = model.bipedLeftArm;
|
||||
out[8] = model.bipedRightLeg;
|
||||
out[9] = model.bipedRightLeg;
|
||||
out[10] = model.bipedBody;
|
||||
out[11] = model.bipedBody;
|
||||
return out;
|
||||
}
|
||||
|
||||
private static void emitModel(ModelBiped model, float scale, float[] out) {
|
||||
final ModelRenderer[] parts = partOrder(model, partOrder);
|
||||
int o = 0;
|
||||
for (int i = 0; i < PART_COUNT; i++) {
|
||||
o = emitBox(parts[i], quadsOf(parts[i]), out, o, scale);
|
||||
}
|
||||
}
|
||||
|
||||
private static TexturedQuad[] quadsOf(ModelRenderer part) {
|
||||
if (part == null || part.cubeList == null || part.cubeList.isEmpty()) return null;
|
||||
final ModelBox box = part.cubeList.getFirst();
|
||||
return ((ModelBoxQuads) box).angelica$getQuadList();
|
||||
}
|
||||
|
||||
public static int emitBox(ModelRenderer part, TexturedQuad[] quads, float[] out, int o, float scale) {
|
||||
if (part == null || quads == null || part.isHidden || !part.showModel || part.textureWidth > ATLAS_LAYOUT || part.textureHeight > ATLAS_LAYOUT) {
|
||||
final int end = o + VERTICES_PER_PART * FLOATS_PER_VERTEX;
|
||||
Arrays.fill(out, o, end, 0.0f);
|
||||
return end;
|
||||
}
|
||||
|
||||
final Matrix4f m = partMatrix
|
||||
.rotationZYX(part.rotateAngleZ, part.rotateAngleY, part.rotateAngleX)
|
||||
.setTranslation(
|
||||
part.offsetX + part.rotationPointX * scale,
|
||||
part.offsetY + part.rotationPointY * scale,
|
||||
part.offsetZ + part.rotationPointZ * scale);
|
||||
|
||||
final float uScale = part.textureWidth / ATLAS_LAYOUT;
|
||||
final float vScale = part.textureHeight / ATLAS_LAYOUT;
|
||||
final Vector3f v = partVertex;
|
||||
for (int q = 0; q < 6; q++) {
|
||||
final PositionTextureVertex[] corners = quads[q].vertexPositions;
|
||||
for (int c = 0; c < 4; c++) {
|
||||
final PositionTextureVertex corner = corners[c];
|
||||
v.set((float) corner.vector3D.xCoord * scale,
|
||||
(float) corner.vector3D.yCoord * scale,
|
||||
(float) corner.vector3D.zCoord * scale);
|
||||
m.transformPosition(v);
|
||||
out[o++] = v.x;
|
||||
out[o++] = v.y;
|
||||
out[o++] = v.z;
|
||||
out[o++] = corner.texturePositionX * uScale;
|
||||
out[o++] = corner.texturePositionY * vScale;
|
||||
}
|
||||
}
|
||||
return o;
|
||||
}
|
||||
|
||||
public static void flush() {
|
||||
if (!pending) return;
|
||||
pending = false;
|
||||
if (!Iris.enabled) return;
|
||||
|
||||
final float[] xyzuv = vertexScratch;
|
||||
if (xyzuv == null || xyzuv.length < VERTEX_COUNT * FLOATS_PER_VERTEX) return;
|
||||
|
||||
// Build the Tessellator layout
|
||||
if (rawData == null) rawData = new int[VERTEX_COUNT * RAW_INTS_PER_VERTEX];
|
||||
PassRebindGate.rebindIfDirty();
|
||||
if (!(Iris.getPipelineManager().getPipelineNullable() instanceof DeferredWorldRenderingPipeline pipeline)) return;
|
||||
if (GLStateManager.getActiveProgram() != pipeline.getActivePassProgramId()) return;
|
||||
|
||||
if (Tracy.ENABLED) Tracy.beginZone(Z_PLAYER_REFLECTION_FLUSH);
|
||||
try {
|
||||
flushInner(xyzuv);
|
||||
} finally {
|
||||
if (Tracy.ENABLED) Tracy.endZone();
|
||||
}
|
||||
}
|
||||
|
||||
private static void flushInner(float[] xyzuv) {
|
||||
if (rawData == null) {
|
||||
rawData = new int[VERTEX_COUNT * RAW_INTS_PER_VERTEX];
|
||||
for (int i = 0; i < VERTEX_COUNT; i++) {
|
||||
final int d = i * RAW_INTS_PER_VERTEX;
|
||||
rawData[d + 5] = 0xFFFFFFFF; // color
|
||||
rawData[d + 6] = 0x00008000; // normal
|
||||
rawData[d + 7] = 0x00F000F0; // light
|
||||
}
|
||||
}
|
||||
final int[] raw = rawData;
|
||||
for (int i = 0; i < VERTEX_COUNT; i++) {
|
||||
final int s = i * FLOATS_PER_VERTEX;
|
||||
@@ -106,12 +241,8 @@ public final class PlayerReflectionCapture {
|
||||
raw[d + 2] = Float.floatToRawIntBits(xyzuv[s + 2]);
|
||||
raw[d + 3] = Float.floatToRawIntBits(xyzuv[s + 3]);
|
||||
raw[d + 4] = Float.floatToRawIntBits(xyzuv[s + 4]);
|
||||
raw[d + 5] = 0xFFFFFFFF; // color
|
||||
raw[d + 6] = 0x00008000; // normal
|
||||
raw[d + 7] = 0x00F000F0; // light
|
||||
}
|
||||
|
||||
// Pack into our own native buffer using the player model's vertex format
|
||||
final VertexFormat format = DefaultVertexFormat.ALL_FORMATS[VERTEX_FLAGS];
|
||||
ensureRepackCapacity(VERTEX_COUNT * format.getVertexSize());
|
||||
|
||||
@@ -119,25 +250,33 @@ public final class PlayerReflectionCapture {
|
||||
repackBuffer.position(0);
|
||||
repackBuffer.limit((int) (writePtr - repackAddress));
|
||||
|
||||
// Upload to our dedicated VBO at offset 0
|
||||
ensureVAO(format);
|
||||
GLStateManager.glBindVertexArray(vao);
|
||||
GLStateManager.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbo);
|
||||
GLStateManager.glBufferData(GL15.GL_ARRAY_BUFFER, repackBuffer, GL15.GL_STREAM_DRAW);
|
||||
GLStateManager.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
|
||||
|
||||
// Bind a 64x64 copy of the skin as `tex`
|
||||
final int activeSkin = GLStateManager.getBoundTextureForServerState();
|
||||
final boolean haveSkin = activeSkin != 0 && activeSkin != skin64Tex;
|
||||
if (haveSkin) {
|
||||
ensureSkin64Texture();
|
||||
final int prevUnit = GL13.GL_TEXTURE0 + GLStateManager.getActiveTextureUnitForServerState();
|
||||
GLStateManager.glActiveTexture(GL13.GL_TEXTURE0);
|
||||
final int prevTexture = GLStateManager.getBoundTextureForServerState();
|
||||
|
||||
if (pendingSkin > 0 && pendingSkin != skin64Tex) {
|
||||
final TextureInfo info = TextureInfoCache.INSTANCE.getInfo(pendingSkin);
|
||||
final int skinGeneration = info.getUploadGeneration();
|
||||
final boolean skinChanged = info != lastCapturedInfo || skinGeneration != lastCapturedGeneration;
|
||||
|
||||
final GlImage atlas = GlImage.BY_NAME.get("playerAtlas_img");
|
||||
final int atlasId = atlas != null ? atlas.getId() : 0;
|
||||
final boolean skinChanged = activeSkin != lastCapturedSkin;
|
||||
final TextureInfo atlasInfo = atlasId > 0 ? TextureInfoCache.INSTANCE.getInfo(atlasId) : null;
|
||||
final int atlasGeneration = atlasInfo != null ? atlasInfo.getUploadGeneration() : 0;
|
||||
final boolean atlasChanged = atlasInfo != lastUploadedAtlasInfo || atlasGeneration != lastUploadedAtlasGeneration;
|
||||
|
||||
if (skinChanged) {
|
||||
final TextureInfo info = TextureInfoCache.INSTANCE.getInfo(activeSkin);
|
||||
lastCapturedInfo = info;
|
||||
lastCapturedGeneration = skinGeneration;
|
||||
skinCopyWidth = 0;
|
||||
skinCopyHeight = 0;
|
||||
|
||||
final int srcW = info.getWidth();
|
||||
final int srcH = info.getHeight();
|
||||
if (srcW > 0 && srcH > 0) {
|
||||
@@ -145,48 +284,72 @@ public final class PlayerReflectionCapture {
|
||||
if (skinPixels == null || skinPixels.capacity() < required) {
|
||||
skinPixels = ByteBuffer.allocateDirect(required).order(ByteOrder.nativeOrder());
|
||||
}
|
||||
// The 1.7.10 model UVs only address the top 64x32 region.
|
||||
skinCopyWidth = Math.min(64, srcW);
|
||||
skinCopyHeight = Math.min(32, srcH);
|
||||
|
||||
skinPixels.clear();
|
||||
GLStateManager.glBindTexture(GL11.GL_TEXTURE_2D, activeSkin);
|
||||
GLStateManager.glBindTexture(GL11.GL_TEXTURE_2D, pendingSkin);
|
||||
GLStateManager.glGetTexImage(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, skinPixels);
|
||||
lastCapturedSkin = activeSkin;
|
||||
skinCopyWidth = srcW;
|
||||
skinCopyHeight = srcH;
|
||||
}
|
||||
}
|
||||
|
||||
if (skinPixels != null && (skinChanged || atlasId != lastUploadedAtlas)) {
|
||||
skinPixels.rewind();
|
||||
GLStateManager.glBindTexture(GL11.GL_TEXTURE_2D, skin64Tex);
|
||||
GLStateManager.glTexSubImage2D(GL11.GL_TEXTURE_2D, 0, 0, 0, skinCopyWidth, skinCopyHeight, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, skinPixels);
|
||||
if (skinCopyWidth > 0 && (skinChanged || atlasChanged)) {
|
||||
ensureSkin64Texture(Math.max(skinCopyWidth, skinCopyHeight));
|
||||
|
||||
if (atlas != null) {
|
||||
final int prevRowLength = GLStateManager.glGetInteger(GL11.GL_UNPACK_ROW_LENGTH);
|
||||
GLStateManager.glPixelStorei(GL11.GL_UNPACK_ROW_LENGTH, skinCopyWidth);
|
||||
try {
|
||||
skinPixels.rewind();
|
||||
GLStateManager.glBindTexture(GL11.GL_TEXTURE_2D, atlasId);
|
||||
GLStateManager.glBindTexture(GL11.GL_TEXTURE_2D, skin64Tex);
|
||||
GLStateManager.glTexSubImage2D(GL11.GL_TEXTURE_2D, 0, 0, 0, skinCopyWidth, skinCopyHeight, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, skinPixels);
|
||||
skin64Valid = true;
|
||||
|
||||
if (atlasInfo != null) {
|
||||
final int dstW = Math.min(atlasInfo.getWidth(), skinCopyWidth);
|
||||
final int dstH = Math.min(atlasInfo.getHeight(), skinCopyHeight);
|
||||
if (dstW > 0 && dstH > 0) {
|
||||
skinPixels.rewind();
|
||||
GLStateManager.glBindTexture(GL11.GL_TEXTURE_2D, atlasId);
|
||||
GLStateManager.glTexSubImage2D(GL11.GL_TEXTURE_2D, 0, 0, 0, dstW, dstH, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, skinPixels);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
GLStateManager.glPixelStorei(GL11.GL_UNPACK_ROW_LENGTH, prevRowLength);
|
||||
}
|
||||
lastUploadedAtlas = atlasId;
|
||||
lastUploadedAtlasInfo = atlasInfo;
|
||||
lastUploadedAtlasGeneration = atlasInfo != null ? atlasInfo.getUploadGeneration() : 0;
|
||||
}
|
||||
|
||||
GLStateManager.glBindTexture(GL11.GL_TEXTURE_2D, skin64Tex);
|
||||
if (skin64Valid) GLStateManager.glBindTexture(GL11.GL_TEXTURE_2D, skin64Tex);
|
||||
}
|
||||
|
||||
final boolean maskable = !DepthColorStorage.isDepthColorLocked();
|
||||
final ColorMask prevColor = GLStateManager.getColorMask();
|
||||
final boolean pr = prevColor.red, pg = prevColor.green, pb = prevColor.blue, pa = prevColor.alpha;
|
||||
final boolean prevDepthWrite = GLStateManager.getDepthState().isEnabled();
|
||||
|
||||
GLStateManager.glColorMask(false, false, false, false);
|
||||
GLStateManager.glDepthMask(false);
|
||||
QuadConverter.drawQuadsAsTriangles(0, VERTEX_COUNT);
|
||||
GLStateManager.glDepthMask(prevDepthWrite);
|
||||
GLStateManager.glColorMask(pr, pg, pb, pa);
|
||||
final int prevEntityId = CapturedRenderingState.INSTANCE.getCurrentRenderedEntity();
|
||||
savedModelView.set(GLStateManager.getModelViewMatrix());
|
||||
|
||||
if (haveSkin) {
|
||||
GLStateManager.glBindTexture(GL11.GL_TEXTURE_2D, activeSkin);
|
||||
CapturedRenderingState.INSTANCE.setCurrentEntity(pendingEntityId);
|
||||
GLStateManager.setModelViewMatrix(pendingModelView);
|
||||
if (maskable) {
|
||||
GLStateManager.glColorMask(false, false, false, false);
|
||||
GLStateManager.glDepthMask(false);
|
||||
}
|
||||
try {
|
||||
QuadConverter.drawQuadsAsTriangles(0, VERTEX_COUNT);
|
||||
} finally {
|
||||
if (maskable) {
|
||||
GLStateManager.glDepthMask(prevDepthWrite);
|
||||
GLStateManager.glColorMask(pr, pg, pb, pa);
|
||||
}
|
||||
GLStateManager.setModelViewMatrix(savedModelView);
|
||||
CapturedRenderingState.INSTANCE.setCurrentEntity(prevEntityId);
|
||||
|
||||
GLStateManager.glBindVertexArray(0);
|
||||
GLStateManager.glBindVertexArray(0);
|
||||
GLStateManager.glBindTexture(GL11.GL_TEXTURE_2D, prevTexture);
|
||||
GLStateManager.glActiveTexture(prevUnit);
|
||||
}
|
||||
}
|
||||
|
||||
public static float[] vertexScratch() {
|
||||
@@ -205,16 +368,16 @@ public final class PlayerReflectionCapture {
|
||||
GLStateManager.glBindVertexArray(0);
|
||||
}
|
||||
|
||||
private static void ensureSkin64Texture() {
|
||||
if (skin64Tex != 0) return;
|
||||
final int prev = GLStateManager.getBoundTextureForServerState();
|
||||
skin64Tex = GLStateManager.glGenTextures();
|
||||
private static void ensureSkin64Texture(int size) {
|
||||
if (skin64Tex != 0 && skin64Size == size) return;
|
||||
if (skin64Tex == 0) skin64Tex = GLStateManager.glGenTextures();
|
||||
GLStateManager.glBindTexture(GL11.GL_TEXTURE_2D, skin64Tex);
|
||||
final ByteBuffer zero = ByteBuffer.allocateDirect(64 * 64 * 4);
|
||||
GLStateManager.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA8, 64, 64, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, zero);
|
||||
final ByteBuffer zero = ByteBuffer.allocateDirect(size * size * 4);
|
||||
GLStateManager.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA8, size, size, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, zero);
|
||||
GLStateManager.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
|
||||
GLStateManager.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
|
||||
GLStateManager.glBindTexture(GL11.GL_TEXTURE_2D, prev);
|
||||
skin64Size = size;
|
||||
skin64Valid = false;
|
||||
}
|
||||
|
||||
private static void ensureRepackCapacity(int requiredBytes) {
|
||||
|
||||
+4
@@ -78,6 +78,10 @@ public class CeleritasDebugScreenHandler {
|
||||
if (transferInfo != null) {
|
||||
lines.add(transferInfo);
|
||||
}
|
||||
final String presentInfo = RENDER_BACKEND.getPresentDebugInfo();
|
||||
if (presentInfo != null) {
|
||||
lines.add(presentInfo);
|
||||
}
|
||||
if (SystemProperties.DEBUG_F3_DETAIL) {
|
||||
lines.addAll(TesrBatchRenderer.INSTANCE.getDebugDetailStrings());
|
||||
lines.add(ModelPartBatcher.INSTANCE.getDebugString());
|
||||
|
||||
@@ -3,10 +3,10 @@ package jss.notfine.gui;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import com.gtnewhorizons.angelica.config.SystemProperties;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import jss.notfine.config.NotFineConfig;
|
||||
import jss.notfine.core.Settings;
|
||||
import jss.notfine.core.SettingsManager;
|
||||
import me.jellysquid.mods.sodium.client.gui.FrameRateOptions;
|
||||
import me.jellysquid.mods.sodium.client.gui.SodiumGameOptionPages;
|
||||
import me.jellysquid.mods.sodium.client.gui.SodiumGameOptions;
|
||||
import me.jellysquid.mods.sodium.client.gui.options.OptionFlag;
|
||||
@@ -43,6 +43,7 @@ public class NotFineGameOptionPages {
|
||||
public static OptionPage general() {
|
||||
List<OptionGroup> groups = new ArrayList<>();
|
||||
|
||||
final FrameRateOptions frameRate = FrameRateOptions.create(vanillaOpts, sodiumOpts);
|
||||
groups.add(OptionGroup.createBuilder()
|
||||
.add(OptionImpl.createBuilder(GraphicsMode.class, vanillaOpts)
|
||||
.setName(I18n.format("options.graphics"))
|
||||
@@ -63,16 +64,7 @@ public class NotFineGameOptionPages {
|
||||
.setImpact(OptionImpact.HIGH)
|
||||
.setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD)
|
||||
.build())
|
||||
.add(OptionImpl.createBuilder(boolean.class, vanillaOpts)
|
||||
.setName(I18n.format("options.vsync"))
|
||||
.setTooltip(I18n.format("sodium.options.v_sync.tooltip"))
|
||||
.setControl(TickBoxControl::new)
|
||||
.setBinding((opts, value) -> {
|
||||
opts.enableVsync = value;
|
||||
GLStateManager.setVSyncEnabled(opts.enableVsync);
|
||||
}, opts -> opts.enableVsync)
|
||||
.setImpact(OptionImpact.VARIES)
|
||||
.build())
|
||||
.add(frameRate.vsync())
|
||||
.add(OptionImpl.createBuilder(boolean.class, vanillaOpts)
|
||||
.setName(I18n.format("options.fullscreen"))
|
||||
.setTooltip(I18n.format("sodium.options.fullscreen.tooltip"))
|
||||
@@ -90,12 +82,7 @@ public class NotFineGameOptionPages {
|
||||
.build());
|
||||
|
||||
groups.add(OptionGroup.createBuilder()
|
||||
.add(OptionImpl.createBuilder(int.class, vanillaOpts)
|
||||
.setName(I18n.format("options.framerateLimit"))
|
||||
.setTooltip(I18n.format("sodium.options.fps_limit.tooltip"))
|
||||
.setControl(option -> new SliderControl(option, 5, 260, 1, ControlValueFormatter.fpsLimit()))
|
||||
.setBinding((opts, value) -> opts.limitFramerate = value, opts -> opts.limitFramerate)
|
||||
.build())
|
||||
.add(frameRate.maxFramerate())
|
||||
.build());
|
||||
|
||||
final OptionImpl<GameSettings, Integer> mipmapLevels = OptionImpl.createBuilder(int.class, vanillaOpts)
|
||||
|
||||
@@ -7,19 +7,20 @@ import net.minecraft.client.Minecraft;
|
||||
public class CyclingControlElement<T extends Enum<T>> extends NotFineControlElement<T> {
|
||||
private final T[] allowedValues;
|
||||
private final String[] names;
|
||||
private int currentIndex = 0;
|
||||
|
||||
public CyclingControlElement(Option<T> option, Dim2i dim, T[] allowedValues, String[] names) {
|
||||
super(option, dim);
|
||||
this.allowedValues = allowedValues;
|
||||
this.names = names;
|
||||
}
|
||||
|
||||
private int currentIndex() {
|
||||
for(int i = 0; i < allowedValues.length; ++i) {
|
||||
if(allowedValues[i] == option.getValue()) {
|
||||
currentIndex = i;
|
||||
break;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -31,8 +32,7 @@ public class CyclingControlElement<T extends Enum<T>> extends NotFineControlElem
|
||||
@Override
|
||||
public boolean mousePressed(Minecraft mc, int mouseX, int mouseY) {
|
||||
if(super.mousePressed(mc, mouseX, mouseY)) {
|
||||
currentIndex = (currentIndex + 1) % allowedValues.length;
|
||||
option.setValue(allowedValues[currentIndex]);
|
||||
option.setValue(allowedValues[(currentIndex() + 1) % allowedValues.length]);
|
||||
onOptionValueChanged();
|
||||
return true;
|
||||
} else {
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package me.jellysquid.mods.sodium.client.gui;
|
||||
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import com.gtnewhorizons.angelica.glsm.backend.VSyncMode;
|
||||
import me.jellysquid.mods.sodium.client.gui.options.Option;
|
||||
import me.jellysquid.mods.sodium.client.gui.options.OptionImpact;
|
||||
import me.jellysquid.mods.sodium.client.gui.options.OptionImpl;
|
||||
import me.jellysquid.mods.sodium.client.gui.options.control.ControlValueFormatter;
|
||||
import me.jellysquid.mods.sodium.client.gui.options.control.CyclingControl;
|
||||
import me.jellysquid.mods.sodium.client.gui.options.control.SliderControl;
|
||||
import me.jellysquid.mods.sodium.client.gui.options.storage.MinecraftOptionsStorage;
|
||||
import me.jellysquid.mods.sodium.client.gui.options.storage.SodiumOptionsStorage;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.client.settings.GameSettings;
|
||||
|
||||
public record FrameRateOptions(Option<VSyncMode> vsync, Option<Integer> maxFramerate) {
|
||||
|
||||
public static FrameRateOptions create(MinecraftOptionsStorage vanillaOpts, SodiumOptionsStorage sodiumOpts) {
|
||||
final OptionImpl<SodiumGameOptions, VSyncMode> vsync = OptionImpl.createBuilder(VSyncMode.class, sodiumOpts)
|
||||
.setName(I18n.format("options.vsync"))
|
||||
.setTooltip(I18n.format("sodium.options.v_sync.tooltip"))
|
||||
.setControl(option -> new CyclingControl<>(option, VSyncMode.class,
|
||||
GLStateManager.getSelectableVSyncModes().toArray(new VSyncMode[0]),
|
||||
new String[]{
|
||||
I18n.format("sodium.options.vsync_mode.auto"),
|
||||
I18n.format("sodium.options.vsync_mode.on"),
|
||||
I18n.format("sodium.options.vsync_mode.mailbox"),
|
||||
I18n.format("sodium.options.vsync_mode.off")}))
|
||||
.setBinding((opts, value) -> {
|
||||
opts.advanced.vsyncMode = value;
|
||||
|
||||
final GameSettings settings = Minecraft.getMinecraft().gameSettings;
|
||||
settings.enableVsync = value.tearFree();
|
||||
settings.saveOptions();
|
||||
GLStateManager.setVSyncMode(value, settings.enableVsync);
|
||||
}, opts -> opts.advanced.vsyncMode.resolve(Minecraft.getMinecraft().gameSettings.enableVsync))
|
||||
.setImpact(OptionImpact.VARIES)
|
||||
.build();
|
||||
|
||||
final OptionImpl<GameSettings, Integer> maxFramerate = OptionImpl.createBuilder(int.class, vanillaOpts)
|
||||
.setName(I18n.format("options.framerateLimit"))
|
||||
.setTooltip(I18n.format("sodium.options.fps_limit.tooltip"))
|
||||
.setControl(option -> new SliderControl(option, 5, 260, 5, ControlValueFormatter.fpsLimit()))
|
||||
.setBinding((opts, value) -> opts.limitFramerate = value, opts -> opts.limitFramerate)
|
||||
.build();
|
||||
|
||||
maxFramerate.iris$dynamicallyEnable(() -> !vsync.getValue().blocksOnVBlank());
|
||||
|
||||
return new FrameRateOptions(vsync, maxFramerate);
|
||||
}
|
||||
}
|
||||
@@ -105,6 +105,7 @@ public class SodiumGameOptionPages {
|
||||
groups.add(firstGroupBuilder.build());
|
||||
|
||||
int maxGuiScale = Math.max(3, Math.min(Minecraft.getMinecraft().displayWidth / 320, Minecraft.getMinecraft().displayHeight / 240));
|
||||
final FrameRateOptions frameRate = FrameRateOptions.create(vanillaOpts, sodiumOpts);
|
||||
groups.add(OptionGroup.createBuilder()
|
||||
.add(OptionImpl.createBuilder(int.class, vanillaOpts)
|
||||
.setName(I18n.format("options.guiScale"))
|
||||
@@ -138,22 +139,8 @@ public class SodiumGameOptionPages {
|
||||
}
|
||||
}, (opts) -> opts.fullScreen)
|
||||
.build())
|
||||
.add(OptionImpl.createBuilder(boolean.class, vanillaOpts)
|
||||
.setName(I18n.format("options.vsync"))
|
||||
.setTooltip(I18n.format("sodium.options.v_sync.tooltip"))
|
||||
.setControl(TickBoxControl::new)
|
||||
.setBinding((opts, value) -> {
|
||||
opts.enableVsync = value;
|
||||
GLStateManager.setVSyncEnabled(opts.enableVsync);
|
||||
}, opts -> opts.enableVsync)
|
||||
.setImpact(OptionImpact.VARIES)
|
||||
.build())
|
||||
.add(OptionImpl.createBuilder(int.class, vanillaOpts)
|
||||
.setName(I18n.format("options.framerateLimit"))
|
||||
.setTooltip(I18n.format("sodium.options.fps_limit.tooltip"))
|
||||
.setControl(option -> new SliderControl(option, 5, 260, 5, ControlValueFormatter.fpsLimit()))
|
||||
.setBinding((opts, value) -> opts.limitFramerate = value, opts -> opts.limitFramerate)
|
||||
.build())
|
||||
.add(frameRate.vsync())
|
||||
.add(frameRate.maxFramerate())
|
||||
.build());
|
||||
|
||||
groups.add(OptionGroup.createBuilder()
|
||||
@@ -521,9 +508,12 @@ public class SodiumGameOptionPages {
|
||||
.add(OptionImpl.createBuilder(int.class, sodiumOpts)
|
||||
.setName(I18n.format("sodium.options.cpu_render_ahead_limit.name"))
|
||||
.setTooltip(I18n.format("sodium.options.cpu_render_ahead_limit.tooltip"))
|
||||
.setControl(o -> new SliderControl(o, 0, 9, 1, ControlValueFormatter.quantity("sodium.options.cpu_render_ahead_limit.value")))
|
||||
.setControl(o -> new SliderControl(o, GLStateManager.getMinRenderAhead(), GLStateManager.getMaxRenderAhead(), 1, ControlValueFormatter.quantity("sodium.options.cpu_render_ahead_limit.value")))
|
||||
.setImpact(OptionImpact.MEDIUM)
|
||||
.setBinding((opts, value) -> opts.performance.cpuRenderAheadLimit = value, opts -> opts.performance.cpuRenderAheadLimit)
|
||||
.setBinding((opts, value) -> {
|
||||
opts.performance.cpuRenderAheadLimit = value;
|
||||
GLStateManager.applyRenderAheadLimit(value);
|
||||
}, opts -> GLStateManager.renderAheadLimit(opts.performance.cpuRenderAheadLimit))
|
||||
.setEnabled(GLStateManager.capabilities != null && GLStateManager.capabilities.OpenGL32)
|
||||
.build())
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import com.gtnewhorizons.angelica.AngelicaMod;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import com.gtnewhorizons.angelica.glsm.backend.VSyncMode;
|
||||
import com.gtnewhorizons.angelica.glsm.streaming.StreamingUploader;
|
||||
import com.gtnewhorizons.angelica.proxy.ClientProxy;
|
||||
import me.jellysquid.mods.sodium.client.gui.options.named.GraphicsQuality;
|
||||
@@ -203,6 +204,7 @@ public class SodiumGameOptions {
|
||||
public boolean ignoreDriverBlacklist = false;
|
||||
public StreamingUploader.UploadStrategy streamingUploadStrategy = StreamingUploader.UploadStrategy.MAP_BUFFER_RANGE;
|
||||
public boolean enableDeferredBatching = true;
|
||||
public VSyncMode vsyncMode = VSyncMode.AUTO;
|
||||
}
|
||||
|
||||
public static class PerformanceSettings {
|
||||
|
||||
+11
@@ -27,6 +27,17 @@ public class CyclingControl<T extends Enum<T>> implements Control<T> {
|
||||
this.names = names;
|
||||
}
|
||||
|
||||
public CyclingControl(Option<T> option, Class<T> enumType, T[] allowedValues, String[] names) {
|
||||
final T[] universe = enumType.getEnumConstants();
|
||||
|
||||
Validate.isTrue(universe.length == names.length, "Mismatch between universe length and names array length");
|
||||
Validate.notEmpty(allowedValues, "There must be at least one allowed value");
|
||||
|
||||
this.option = option;
|
||||
this.allowedValues = allowedValues;
|
||||
this.names = names;
|
||||
}
|
||||
|
||||
public CyclingControl(Option<T> option, Class<T> enumType, T[] allowedValues) {
|
||||
final T[] universe = enumType.getEnumConstants();
|
||||
|
||||
|
||||
+8
-10
@@ -27,21 +27,21 @@ public class SodiumControlElementFactory implements ControlElementFactory {
|
||||
private static class CyclingControlElement<T extends Enum<T>> extends SodiumControlElement<T> {
|
||||
private final T[] allowedValues;
|
||||
private final String[] names;
|
||||
private int currentIndex;
|
||||
|
||||
public CyclingControlElement(Option<T> option, Dim2i dim, T[] allowedValues, String[] names) {
|
||||
super(option, dim);
|
||||
|
||||
this.allowedValues = allowedValues;
|
||||
this.names = names;
|
||||
this.currentIndex = 0;
|
||||
}
|
||||
|
||||
for (int i = 0; i < allowedValues.length; i++) {
|
||||
if (allowedValues[i] == option.getValue()) {
|
||||
this.currentIndex = i;
|
||||
break;
|
||||
private int currentIndex() {
|
||||
for (int i = 0; i < this.allowedValues.length; i++) {
|
||||
if (this.allowedValues[i] == this.option.getValue()) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -59,16 +59,14 @@ public class SodiumControlElementFactory implements ControlElementFactory {
|
||||
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||
if(AngelicaConfig.enableReesesSodiumOptions) {
|
||||
if (this.option.isAvailable() && this.dim.containsCursor(mouseX, mouseY) && (button == 0 || button == 1)) {
|
||||
this.currentIndex = Math.floorMod(this.currentIndex + (button == 0 ? 1 : -1), this.allowedValues.length);
|
||||
this.option.setValue(this.allowedValues[this.currentIndex]);
|
||||
this.option.setValue(this.allowedValues[Math.floorMod(this.currentIndex() + (button == 0 ? 1 : -1), this.allowedValues.length)]);
|
||||
this.playClickSound();
|
||||
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (this.option.isAvailable() && button == 0 && this.dim.containsCursor(mouseX, mouseY)) {
|
||||
this.currentIndex = (this.currentIndex + 1) % this.allowedValues.length;
|
||||
this.option.setValue(this.allowedValues[this.currentIndex]);
|
||||
this.option.setValue(this.allowedValues[(this.currentIndex() + 1) % this.allowedValues.length]);
|
||||
this.playClickSound();
|
||||
|
||||
return true;
|
||||
|
||||
@@ -547,11 +547,11 @@ public class ShadowRenderer {
|
||||
profiler.endStartSection("iris_shadow_build_geometry");
|
||||
|
||||
setupEntityShadowState(modelView, cameraX, cameraY, cameraZ);
|
||||
if (playerReflectionCaptureEnabled) {
|
||||
PlayerReflectionCapture.begin(player);
|
||||
}
|
||||
ModelPartBatcher.INSTANCE.begin(ModelPartBatcher.Mode.ENTITIES, true);
|
||||
try {
|
||||
if (playerReflectionCaptureEnabled) {
|
||||
PlayerReflectionCapture.begin(player);
|
||||
}
|
||||
for (Entity entity : renderedEntitiesList) {
|
||||
final long start = Tracy.ENABLED ? System.nanoTime() : 0L;
|
||||
try {
|
||||
@@ -629,7 +629,7 @@ public class ShadowRenderer {
|
||||
// Saved RenderManager position for shadow pass
|
||||
private double savedRenderPosX, savedRenderPosY, savedRenderPosZ;
|
||||
|
||||
/** Flushes shadow-pass batched model parts while GL_POLYGON_OFFSET_FILL is still enabled. */
|
||||
/** Flushes deferred shadow-pass geometry while GL_POLYGON_OFFSET_FILL is still enabled. */
|
||||
private static void flushShadowModelParts() {
|
||||
if (Tracy.ENABLED) Tracy.beginZone(Z_SHADOW_MODEL_PARTS);
|
||||
final boolean alphaEnabled = GLStateManager.getAlphaTest().isEnabled();
|
||||
@@ -637,6 +637,7 @@ public class ShadowRenderer {
|
||||
final float alphaRef = GLStateManager.getAlphaState().getReference();
|
||||
try {
|
||||
ModelPartBatcher.INSTANCE.flush();
|
||||
PlayerReflectionCapture.flush();
|
||||
} finally {
|
||||
if (alphaEnabled) GLStateManager.enableAlphaTest();
|
||||
else GLStateManager.disableAlphaTest();
|
||||
@@ -712,14 +713,11 @@ public class ShadowRenderer {
|
||||
if (playerReflectionCaptureEnabled) {
|
||||
PlayerReflectionCapture.begin(player);
|
||||
}
|
||||
try {
|
||||
RenderManager.instance.renderEntitySimple(player, tickDelta);
|
||||
} finally {
|
||||
PlayerReflectionCapture.end();
|
||||
}
|
||||
RenderManager.instance.renderEntitySimple(player, tickDelta);
|
||||
shadowEntities++;
|
||||
} finally {
|
||||
flushShadowModelParts();
|
||||
PlayerReflectionCapture.end();
|
||||
teardownEntityShadowState();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user