Update #50 - Bug fixes and shader improvements

This commit is contained in:
lax1dude
2025-02-22 16:52:35 -08:00
parent b0a2739fe1
commit 7e772e2502
133 changed files with 3064 additions and 2299 deletions

View File

@ -56,7 +56,6 @@ public final class SunNormalizer {
* {@link java.text.Normalizer.Form#NFKC},
* {@link java.text.Normalizer.Form#NFKD}
* @param option The normalization option;
* {@link sun.text.Normalizer#UNICODE_3_2}
* @return The normalized String
* @throws NullPointerException If <code>src</code> or <code>form</code> is
* null.
@ -75,7 +74,6 @@ public final class SunNormalizer {
* {@link java.text.Normalizer.Form#NFKC},
* {@link java.text.Normalizer.Form#NFKD}
* @param option The normalization option;
* {@link sun.text.Normalizer#UNICODE_3_2}
* @return true if the sequence of char values is normalized; false otherwise.
* @throws NullPointerException If <code>src</code> or <code>form</code> is
* null.

View File

@ -42,6 +42,7 @@ import java.util.Arrays;
import jdk_internal.icu.util.VersionInfo;
import net.lax1dude.eaglercraft.v1_8.EagRuntime;
import net.lax1dude.eaglercraft.v1_8.HString;
public final class ICUBinary {
@ -227,7 +228,7 @@ public final class ICUBinary {
|| bytes.get(14) != (byte) (dataFormat >> 8) || bytes.get(15) != (byte) dataFormat
|| (authenticate != null && !authenticate.isDataVersionAcceptable(formatVersion))) {
throw new IOException(HEADER_AUTHENTICATION_FAILED_
+ String.format("; data format %02x%02x%02x%02x, format version %d.%d.%d.%d", bytes.get(12),
+ HString.format("; data format %02x%02x%02x%02x, format version %d.%d.%d.%d", bytes.get(12),
bytes.get(13), bytes.get(14), bytes.get(15), formatVersion[0] & 0xff,
formatVersion[1] & 0xff, formatVersion[2] & 0xff, formatVersion[3] & 0xff));
}

View File

@ -53,16 +53,20 @@ public class ClientUUIDLoadingCache {
if(ret == null) {
Minecraft mc = Minecraft.getMinecraft();
if(mc != null && mc.thePlayer != null && mc.thePlayer.sendQueue.getEaglerMessageProtocol().ver >= 4) {
ret = PENDING_UUID;
EaglercraftUUID playerUUID = player.getUniqueID();
if(!waitingUUIDs.containsKey(playerUUID) && !evictedUUIDs.containsKey(playerUUID)) {
int reqID = ++requestId & 0x3FFF;
WaitingLookup newLookup = new WaitingLookup(reqID, playerUUID, EagRuntime.steadyTimeMillis(),
(AbstractClientPlayer) player);
waitingIDs.put(reqID, newLookup);
waitingUUIDs.put(playerUUID, newLookup);
mc.thePlayer.sendQueue.sendEaglerMessage(
new CPacketGetOtherClientUUIDV4EAG(reqID, newLookup.uuid.msb, newLookup.uuid.lsb));
if(ignoreNonEaglerPlayers && !player.getGameProfile().getTextures().eaglerPlayer) {
ret = VANILLA_UUID;
}else {
ret = PENDING_UUID;
EaglercraftUUID playerUUID = player.getUniqueID();
if(!waitingUUIDs.containsKey(playerUUID) && !evictedUUIDs.containsKey(playerUUID)) {
int reqID = ++requestId & 0x3FFF;
WaitingLookup newLookup = new WaitingLookup(reqID, playerUUID, EagRuntime.steadyTimeMillis(),
(AbstractClientPlayer) player);
waitingIDs.put(reqID, newLookup);
waitingUUIDs.put(playerUUID, newLookup);
mc.thePlayer.sendQueue.sendEaglerMessage(
new CPacketGetOtherClientUUIDV4EAG(reqID, newLookup.uuid.msb, newLookup.uuid.lsb));
}
}
}
}
@ -82,6 +86,7 @@ public class ClientUUIDLoadingCache {
private static int requestId = 0;
private static long lastFlushReq = EagRuntime.steadyTimeMillis();
private static long lastFlushEvict = EagRuntime.steadyTimeMillis();
private static boolean ignoreNonEaglerPlayers = false;
public static void update() {
long timestamp = EagRuntime.steadyTimeMillis();
@ -117,13 +122,19 @@ public class ClientUUIDLoadingCache {
evictedUUIDs.clear();
}
private static final EaglercraftUUID MAGIC_DISABLE_NON_EAGLER_PLAYERS = new EaglercraftUUID(0xEEEEA64771094C4EL, 0x86E55B81D17E67EBL);
public static void handleResponse(int requestId, EaglercraftUUID clientId) {
WaitingLookup lookup = waitingIDs.remove(requestId);
if(lookup != null) {
lookup.player.clientBrandUUIDCache = clientId;
waitingUUIDs.remove(lookup.uuid);
}else {
logger.warn("Unsolicited client brand UUID lookup response #{} recieved! (Brand UUID: {})", requestId, clientId);
if(requestId == -1 && MAGIC_DISABLE_NON_EAGLER_PLAYERS.equals(clientId)) {
ignoreNonEaglerPlayers = true;
}else {
logger.warn("Unsolicited client brand UUID lookup response #{} recieved! (Brand UUID: {})", requestId, clientId);
}
}
}
@ -135,6 +146,10 @@ public class ClientUUIDLoadingCache {
}
}
public static void resetFlags() {
ignoreNonEaglerPlayers = false;
}
private static class WaitingLookup {
private final int reqID;

View File

@ -10,7 +10,7 @@ public class EaglercraftVersion {
/// Customize these to fit your fork:
public static final String projectForkName = "EaglercraftX";
public static final String projectForkVersion = "u49";
public static final String projectForkVersion = "u50";
public static final String projectForkVendor = "lax1dude";
public static final String projectForkURL = "https://gitlab.com/lax1dude/eaglercraftx-1.8";
@ -20,20 +20,20 @@ public class EaglercraftVersion {
public static final String projectOriginName = "EaglercraftX";
public static final String projectOriginAuthor = "lax1dude";
public static final String projectOriginRevision = "1.8";
public static final String projectOriginVersion = "u49";
public static final String projectOriginVersion = "u50";
public static final String projectOriginURL = "https://gitlab.com/lax1dude/eaglercraftx-1.8"; // rest in peace
// EPK Version Identifier
public static final String EPKVersionIdentifier = "u49"; // Set to null to disable EPK version check
public static final String EPKVersionIdentifier = "u50"; // Set to null to disable EPK version check
// Updating configuration
public static final boolean enableUpdateService = true;
public static final String updateBundlePackageName = "net.lax1dude.eaglercraft.v1_8.client";
public static final int updateBundlePackageVersionInt = 49;
public static final int updateBundlePackageVersionInt = 50;
public static final String updateLatestLocalStorageKey = "latestUpdate_" + updateBundlePackageName;

View File

@ -27,6 +27,8 @@ public abstract class AbstractWebSocketClient implements IWebSocketClient {
protected volatile int availableBinaryFrames = 0;
protected final List<IWebSocketFrame> recievedPacketBuffer = new LinkedList<>();
protected String currentURI;
private boolean strEnable = true;
private boolean binEnable = true;
protected AbstractWebSocketClient(String currentURI) {
this.currentURI = currentURI;
@ -34,6 +36,13 @@ public abstract class AbstractWebSocketClient implements IWebSocketClient {
protected void addRecievedFrame(IWebSocketFrame frame) {
boolean str = frame.isString();
if(str) {
if(!strEnable)
return;
}else {
if(!binEnable)
return;
}
synchronized(recievedPacketBuffer) {
recievedPacketBuffer.add(frame);
if(str) {
@ -225,4 +234,14 @@ public abstract class AbstractWebSocketClient implements IWebSocketClient {
return currentURI;
}
@Override
public void setEnableStringFrames(boolean enable) {
strEnable = enable;
}
@Override
public void setEnableBinaryFrames(boolean enable) {
binEnable = enable;
}
}

View File

@ -16,6 +16,6 @@
package net.lax1dude.eaglercraft.v1_8.internal;
public interface IBufferArrayGL extends IObjectGL {
public interface IVertexArrayGL extends IObjectGL {
}

View File

@ -60,4 +60,8 @@ public interface IWebSocketClient {
String getCurrentURI();
void setEnableStringFrames(boolean enable);
void setEnableBinaryFrames(boolean enable);
}

View File

@ -1,14 +1,11 @@
package net.lax1dude.eaglercraft.v1_8.minecraft;
import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.*;
import java.util.LinkedList;
import java.util.List;
import net.lax1dude.eaglercraft.v1_8.EagRuntime;
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
import net.lax1dude.eaglercraft.v1_8.opengl.EaglercraftGPU;
import net.lax1dude.eaglercraft.v1_8.opengl.WorldRenderer;
import net.lax1dude.eaglercraft.v1_8.opengl.WorldVertexBufferUploader;
import net.minecraft.client.Minecraft;
@ -198,9 +195,7 @@ public class ChunkUpdateManager {
}
private void uploadDisplayList(WorldRenderer chunkRenderer, int parInt1, RenderChunk parRenderChunk) {
EaglercraftGPU.glNewList(parInt1, GL_COMPILE);
WorldVertexBufferUploader.func_181679_a(chunkRenderer);
EaglercraftGPU.glEndList();
WorldVertexBufferUploader.uploadDisplayList(parInt1, chunkRenderer);
}
public boolean isAlreadyQueued(RenderChunk update) {

View File

@ -112,7 +112,7 @@ public class EaglerCloudRenderer {
}
if(newState != RENDER_STATE_FAST) {
GlStateManager.disableCull();
GlStateManager.enableCull();
double d0 = this.mc.renderGlobal.getCloudCounter(partialTicks);
double d1 = (rve.prevPosX + (rve.posX - rve.prevPosX) * (double) partialTicks + d0 * 0.029999999329447746D) / 12.0D;
double d2 = (rve.prevPosZ + (rve.posZ - rve.prevPosZ) * (double) partialTicks) / 12.0D + 0.33000001311302185D;
@ -193,7 +193,7 @@ public class EaglerCloudRenderer {
yy = 1;
}
EaglercraftGPU.glCallList(renderListFancy[(yy + 1) * 3 + xx + 1]);
GlStateManager.callList(renderListFancy[(yy + 1) * 3 + xx + 1]);
GlStateManager.popMatrix();
GlStateManager.matrixMode(GL_MODELVIEW);
@ -220,15 +220,15 @@ public class EaglerCloudRenderer {
GlStateManager.matrixMode(GL_TEXTURE);
GlStateManager.pushMatrix();
GlStateManager.translate(f8, f9, 0.0f);
EaglercraftGPU.glCallList(renderList);
GlStateManager.callList(renderList);
GlStateManager.popMatrix();
GlStateManager.matrixMode(GL_MODELVIEW);
GlStateManager.popMatrix();
GlStateManager.enableCull();
}
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.disableBlend();
GlStateManager.enableCull();
}
private void rebuild(int newState) {
@ -243,11 +243,9 @@ public class EaglerCloudRenderer {
if(renderListFancy[i] == -1) {
renderListFancy[i] = EaglercraftGPU.glGenLists();
}
EaglercraftGPU.glNewList(renderListFancy[i], GL_COMPILE);
worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
generateFancyClouds(worldrenderer, i, newState != RENDER_STATE_FANCY_BELOW, newState != RENDER_STATE_FANCY_ABOVE);
tessellator.draw();
EaglercraftGPU.glEndList();
tessellator.uploadDisplayList(renderListFancy[i]);
}
}else {
if(renderList == -1) {
@ -259,24 +257,32 @@ public class EaglerCloudRenderer {
renderListFancy[i] = -1;
}
}
EaglercraftGPU.glNewList(renderList, GL_COMPILE);
worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX);
final double d = 4.8828125E-4;
worldrenderer.pos(-256.0f, 0.0f, 256.0f).tex(-256.0f * d, 256.0f * d).endVertex();
worldrenderer.pos(256.0f, 0.0f, 256.0f).tex(256.0f * d, 256.0f * d).endVertex();
worldrenderer.pos(256.0f, 0.0f, -256.0f).tex(256.0f * d, -256.0f * d).endVertex();
worldrenderer.pos(-256.0f, 0.0f, -256.0f).tex(-256.0f * d, -256.0f * d).endVertex();
tessellator.draw();
EaglercraftGPU.glEndList();
tessellator.uploadDisplayList(renderList);
}
}
private static void generateFancyClouds(WorldRenderer worldrenderer, int mesh, boolean renderAbove, boolean renderBelow) {
int xx = (mesh % 3) - 1;
int yy = (mesh / 3) - 1;
boolean center = xx == 0 && yy == 0 && renderAbove && renderBelow;
if (renderAbove) {
worldrenderer.pos(0.0f, 0.0f, 8.0f).tex(0.0f, 8.0f * 0.00390625F).color(0.7f, 0.7f, 0.7f, 1.0f).endVertex();
worldrenderer.pos(8.0f, 0.0f, 8.0f).tex(8.0f * 0.00390625f, 8.0f * 0.00390625f).color(0.7f, 0.7f, 0.7f, 1.0f).endVertex();
worldrenderer.pos(8.0f, 0.0f, 0.0f).tex(8.0f * 0.00390625f, 0.0f).color(0.7f, 0.7f, 0.7f, 1.0f).endVertex();
worldrenderer.pos(0.0f, 0.0f, 0.0f).tex(0.0f, 0.0f).color(0.7f, 0.7f, 0.7f, 1.0f).endVertex();
worldrenderer.pos(8.0f, 0.0f, 0.0f).tex(8.0f * 0.00390625f, 0.0f).color(0.7f, 0.7f, 0.7f, 1.0f).endVertex();
worldrenderer.pos(8.0f, 0.0f, 8.0f).tex(8.0f * 0.00390625f, 8.0f * 0.00390625f).color(0.7f, 0.7f, 0.7f, 1.0f).endVertex();
if(center) {
worldrenderer.pos(0.0f, 0.0f, 8.0f).tex(0.0f, 8.0f * 0.00390625F).color(0.7f, 0.7f, 0.7f, 1.0f).endVertex();
worldrenderer.pos(8.0f, 0.0f, 8.0f).tex(8.0f * 0.00390625f, 8.0f * 0.00390625f).color(0.7f, 0.7f, 0.7f, 1.0f).endVertex();
worldrenderer.pos(8.0f, 0.0f, 0.0f).tex(8.0f * 0.00390625f, 0.0f).color(0.7f, 0.7f, 0.7f, 1.0f).endVertex();
worldrenderer.pos(0.0f, 0.0f, 0.0f).tex(0.0f, 0.0f).color(0.7f, 0.7f, 0.7f, 1.0f).endVertex();
}
}
if (renderBelow) {
@ -284,11 +290,14 @@ public class EaglerCloudRenderer {
worldrenderer.pos(8.0f, 4.0f - 9.765625E-4f, 8.0f).tex(8.0f * 0.00390625F, 8.0f * 0.00390625f).color(1.0f, 1.0f, 1.0f, 1.0f).endVertex();
worldrenderer.pos(8.0f, 4.0f - 9.765625E-4f, 0.0f).tex(8.0f * 0.00390625f, 0.0f).color(1.0f, 1.0f, 1.0f, 1.0f).endVertex();
worldrenderer.pos(0.0f, 4.0f - 9.765625E-4f, 0.0f).tex(0.0f, 0.0f).color(1.0f, 1.0f, 1.0f, 1.0f).endVertex();
if(center) {
worldrenderer.pos(0.0f, 4.0f - 9.765625E-4f, 8.0f).tex(0.0f, 8.0f * 0.00390625f).color(1.0f, 1.0f, 1.0f, 1.0f).endVertex();
worldrenderer.pos(0.0f, 4.0f - 9.765625E-4f, 0.0f).tex(0.0f, 0.0f).color(1.0f, 1.0f, 1.0f, 1.0f).endVertex();
worldrenderer.pos(8.0f, 4.0f - 9.765625E-4f, 0.0f).tex(8.0f * 0.00390625f, 0.0f).color(1.0f, 1.0f, 1.0f, 1.0f).endVertex();
worldrenderer.pos(8.0f, 4.0f - 9.765625E-4f, 8.0f).tex(8.0f * 0.00390625F, 8.0f * 0.00390625f).color(1.0f, 1.0f, 1.0f, 1.0f).endVertex();
}
}
int xx = (mesh % 3) - 1;
int yy = (mesh / 3) - 1;
if (xx != -1) {
for (int j1 = 0; j1 < 8; ++j1) {
worldrenderer.pos(j1, 0.0f, 8.0f).tex((j1 + 0.5f) * 0.00390625f, 8.0f * 0.00390625f)
@ -299,6 +308,16 @@ public class EaglerCloudRenderer {
.endVertex();
worldrenderer.pos(j1, 0.0f, 0.0f).tex((j1 + 0.5f) * 0.00390625f, 0.0f).color(0.9f, 0.9f, 0.9f, 1.0f)
.endVertex();
if(center) {
worldrenderer.pos(j1, 0.0f, 8.0f).tex((j1 + 0.5f) * 0.00390625f, 8.0f * 0.00390625f)
.color(0.9f, 0.9f, 0.9f, 1.0f).endVertex();
worldrenderer.pos(j1, 0.0f, 0.0f).tex((j1 + 0.5f) * 0.00390625f, 0.0f).color(0.9f, 0.9f, 0.9f, 1.0f)
.endVertex();
worldrenderer.pos(j1, 4.0f, 0.0f).tex((j1 + 0.5f) * 0.00390625f, 0.0f).color(0.9f, 0.9f, 0.9f, 1.0f)
.endVertex();
worldrenderer.pos(j1, 4.0f, 8.0f).tex((j1 + 0.5f) * 0.00390625f, 8.0f * 0.00390625f)
.color(0.9f, 0.9f, 0.9f, 1.0f).endVertex();
}
}
}
@ -306,12 +325,22 @@ public class EaglerCloudRenderer {
for (int k1 = 0; k1 < 8; ++k1) {
worldrenderer.pos(k1 + 1.0f - 9.765625E-4f, 0.0f, 8.0f)
.tex((k1 + 0.5f) * 0.00390625f, 8.0f * 0.00390625f).color(0.9f, 0.9f, 0.9f, 1.0f).endVertex();
worldrenderer.pos(k1 + 1.0f - 9.765625E-4f, 4.0f, 8.0f)
.tex((k1 + 0.5f) * 0.00390625f, 8.0f * 0.00390625f).color(0.9f, 0.9f, 0.9f, 1.0f).endVertex();
worldrenderer.pos(k1 + 1.0f - 9.765625E-4f, 4.0f, 0.0f).tex((k1 + 0.5f) * 0.00390625f, 0.0f)
.color(0.9f, 0.9f, 0.9f, 1.0f).endVertex();
worldrenderer.pos(k1 + 1.0f - 9.765625E-4f, 0.0f, 0.0f).tex((k1 + 0.5f) * 0.00390625f, 0.0f)
.color(0.9f, 0.9f, 0.9f, 1.0f).endVertex();
worldrenderer.pos(k1 + 1.0f - 9.765625E-4f, 4.0f, 0.0f).tex((k1 + 0.5f) * 0.00390625f, 0.0f)
.color(0.9f, 0.9f, 0.9f, 1.0f).endVertex();
worldrenderer.pos(k1 + 1.0f - 9.765625E-4f, 4.0f, 8.0f)
.tex((k1 + 0.5f) * 0.00390625f, 8.0f * 0.00390625f).color(0.9f, 0.9f, 0.9f, 1.0f).endVertex();
if(center) {
worldrenderer.pos(k1 + 1.0f - 9.765625E-4f, 0.0f, 8.0f)
.tex((k1 + 0.5f) * 0.00390625f, 8.0f * 0.00390625f).color(0.9f, 0.9f, 0.9f, 1.0f).endVertex();
worldrenderer.pos(k1 + 1.0f - 9.765625E-4f, 4.0f, 8.0f)
.tex((k1 + 0.5f) * 0.00390625f, 8.0f * 0.00390625f).color(0.9f, 0.9f, 0.9f, 1.0f).endVertex();
worldrenderer.pos(k1 + 1.0f - 9.765625E-4f, 4.0f, 0.0f).tex((k1 + 0.5f) * 0.00390625f, 0.0f)
.color(0.9f, 0.9f, 0.9f, 1.0f).endVertex();
worldrenderer.pos(k1 + 1.0f - 9.765625E-4f, 0.0f, 0.0f).tex((k1 + 0.5f) * 0.00390625f, 0.0f)
.color(0.9f, 0.9f, 0.9f, 1.0f).endVertex();
}
}
}
@ -325,6 +354,16 @@ public class EaglerCloudRenderer {
.color(0.8f, 0.8f, 0.8f, 1.0f).endVertex();
worldrenderer.pos(0.0f, 0.0f, l1).tex(0.0f, (l1 + 0.5f) * 0.00390625f).color(0.8f, 0.8f, 0.8f, 1.0f)
.endVertex();
if(center) {
worldrenderer.pos(0.0f, 4.0f, l1).tex(0.0f, (l1 + 0.5f) * 0.00390625f).color(0.8f, 0.8f, 0.8f, 1.0f)
.endVertex();
worldrenderer.pos(0.0f, 0.0f, l1).tex(0.0f, (l1 + 0.5f) * 0.00390625f).color(0.8f, 0.8f, 0.8f, 1.0f)
.endVertex();
worldrenderer.pos(8.0f, 0.0f, l1).tex(8.0f * 0.00390625f, (l1 + 0.5f) * 0.00390625f)
.color(0.8f, 0.8f, 0.8f, 1.0f).endVertex();
worldrenderer.pos(8.0f, 4.0f, l1).tex(8.0f * 0.00390625f, (l1 + 0.5f) * 0.00390625f)
.color(0.8f, 0.8f, 0.8f, 1.0f).endVertex();
}
}
}
@ -332,12 +371,22 @@ public class EaglerCloudRenderer {
for (int i2 = 0; i2 < 8; ++i2) {
worldrenderer.pos(0.0f, 4.0f, i2 + 1.0f - 9.765625E-4f).tex(0.0f, (i2 + 0.5f) * 0.00390625f)
.color(0.8f, 0.8f, 0.8f, 1.0f).endVertex();
worldrenderer.pos(8.0f, 4.0f, i2 + 1.0f - 9.765625E-4f)
.tex(8.0f * 0.00390625f, (i2 + 0.5f) * 0.00390625f).color(0.8f, 0.8f, 0.8f, 1.0f).endVertex();
worldrenderer.pos(8.0f, 0.0f, i2 + 1.0f - 9.765625E-4f)
.tex(8.0f * 0.00390625f, (i2 + 0.5f) * 0.00390625f).color(0.8f, 0.8f, 0.8f, 1.0f).endVertex();
worldrenderer.pos(0.0f, 0.0f, i2 + 1.0f - 9.765625E-4f).tex(0.0f, (i2 + 0.5f) * 0.00390625f)
.color(0.8f, 0.8f, 0.8f, 1.0f).endVertex();
worldrenderer.pos(8.0f, 0.0f, i2 + 1.0f - 9.765625E-4f)
.tex(8.0f * 0.00390625f, (i2 + 0.5f) * 0.00390625f).color(0.8f, 0.8f, 0.8f, 1.0f).endVertex();
worldrenderer.pos(8.0f, 4.0f, i2 + 1.0f - 9.765625E-4f)
.tex(8.0f * 0.00390625f, (i2 + 0.5f) * 0.00390625f).color(0.8f, 0.8f, 0.8f, 1.0f).endVertex();
if(center) {
worldrenderer.pos(0.0f, 4.0f, i2 + 1.0f - 9.765625E-4f).tex(0.0f, (i2 + 0.5f) * 0.00390625f)
.color(0.8f, 0.8f, 0.8f, 1.0f).endVertex();
worldrenderer.pos(8.0f, 4.0f, i2 + 1.0f - 9.765625E-4f)
.tex(8.0f * 0.00390625f, (i2 + 0.5f) * 0.00390625f).color(0.8f, 0.8f, 0.8f, 1.0f).endVertex();
worldrenderer.pos(8.0f, 0.0f, i2 + 1.0f - 9.765625E-4f)
.tex(8.0f * 0.00390625f, (i2 + 0.5f) * 0.00390625f).color(0.8f, 0.8f, 0.8f, 1.0f).endVertex();
worldrenderer.pos(0.0f, 0.0f, i2 + 1.0f - 9.765625E-4f).tex(0.0f, (i2 + 0.5f) * 0.00390625f)
.color(0.8f, 0.8f, 0.8f, 1.0f).endVertex();
}
}
}
}

View File

@ -0,0 +1,72 @@
/*
* Copyright (c) 2025 lax1dude. All Rights Reserved.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.lax1dude.eaglercraft.v1_8.minecraft;
import java.io.IOException;
import net.lax1dude.eaglercraft.v1_8.internal.IFramebufferGL;
import net.lax1dude.eaglercraft.v1_8.opengl.EaglercraftGPU;
import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager;
import net.minecraft.client.renderer.texture.AbstractTexture;
import net.minecraft.client.renderer.texture.TextureUtil;
import net.minecraft.client.resources.IResourceManager;
import static net.lax1dude.eaglercraft.v1_8.internal.PlatformOpenGL.*;
import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.*;
public class MainMenuSkyboxTexture extends AbstractTexture {
public static final int _GL_FRAMEBUFFER = 0x8D40;
public static final int _GL_COLOR_ATTACHMENT0 = 0x8CE0;
private IFramebufferGL framebuffer = null;
public MainMenuSkyboxTexture(int width, int height) {
TextureUtil.allocateTexture(this.getGlTextureId(), width, height);
EaglercraftGPU.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
EaglercraftGPU.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
EaglercraftGPU.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
EaglercraftGPU.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
}
@Override
public void loadTexture(IResourceManager var1) throws IOException {
}
public void bindFramebuffer() {
if(framebuffer == null) {
framebuffer = _wglCreateFramebuffer();
_wglBindFramebuffer(_GL_FRAMEBUFFER, framebuffer);
int tex = getGlTextureId();
GlStateManager.bindTexture(tex);
_wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
EaglercraftGPU.getNativeTexture(tex), 0);
}else {
_wglBindFramebuffer(_GL_FRAMEBUFFER, framebuffer);
}
_wglDrawBuffers(new int[] { _GL_COLOR_ATTACHMENT0 });
}
public void deleteGlTexture() {
super.deleteGlTexture();
if(framebuffer != null) {
_wglDeleteFramebuffer(framebuffer);
framebuffer = null;
}
}
}

View File

@ -19,9 +19,6 @@ package net.lax1dude.eaglercraft.v1_8.notifications;
import java.io.IOException;
import java.util.List;
import com.google.common.base.Predicate;
import com.google.common.collect.Collections2;
import net.lax1dude.eaglercraft.v1_8.EaglercraftUUID;
import net.lax1dude.eaglercraft.v1_8.socket.protocol.pkt.server.SPacketNotifBadgeShowV4EAG.EnumBadgePriority;
import net.minecraft.client.Minecraft;
@ -88,12 +85,8 @@ public class GuiScreenNotifications extends GuiScreen {
selectedUUID = lst.get(oldSelectedId).badge.badgeUUID;
}
lst.clear();
lst.addAll(Collections2.transform(Collections2.filter(mgr.getNotifLongHistory(), new Predicate<NotificationBadge>() {
@Override
public boolean apply(NotificationBadge input) {
return input.priority.priority >= priorityOrder[showPriority];
}
}), GuiSlotNotifications.NotifBadgeSlot::new));
mgr.getNotifLongHistory().stream().filter((input) -> input.priority.priority >= priorityOrder[showPriority])
.map(GuiSlotNotifications.NotifBadgeSlot::new).forEach(lst::add);
selected = -1;
if(selectedUUID != null) {
for(int i = 0, l = lst.size(); i < l; ++i) {

View File

@ -16,12 +16,12 @@
package net.lax1dude.eaglercraft.v1_8.opengl;
import net.lax1dude.eaglercraft.v1_8.internal.IBufferArrayGL;
import net.lax1dude.eaglercraft.v1_8.internal.IVertexArrayGL;
import net.lax1dude.eaglercraft.v1_8.internal.IBufferGL;
class DisplayList {
IBufferArrayGL vertexArray = null;
IVertexArrayGL vertexArray = null;
IBufferGL vertexBuffer = null;
int attribs = -1;
int mode = -1;

View File

@ -22,7 +22,7 @@ import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.*;
import java.util.List;
import net.lax1dude.eaglercraft.v1_8.EagRuntime;
import net.lax1dude.eaglercraft.v1_8.internal.IBufferArrayGL;
import net.lax1dude.eaglercraft.v1_8.internal.IVertexArrayGL;
import net.lax1dude.eaglercraft.v1_8.internal.IBufferGL;
import net.lax1dude.eaglercraft.v1_8.internal.IShaderGL;
import net.lax1dude.eaglercraft.v1_8.internal.buffer.FloatBuffer;
@ -32,8 +32,8 @@ public class DrawUtils {
public static final String vertexShaderPath = "/assets/eagler/glsl/local.vsh";
public static final String vertexShaderPrecision = "precision highp float;\n";
public static IBufferArrayGL standardQuad2DVAO = null;
public static IBufferArrayGL standardQuad3DVAO = null;
public static IVertexArrayGL standardQuad2DVAO = null;
public static IVertexArrayGL standardQuad3DVAO = null;
public static IBufferGL standardQuadVBO = null;
public static IShaderGL vshLocal = null;
@ -41,8 +41,8 @@ public class DrawUtils {
static void init() {
if(standardQuad2DVAO == null) {
standardQuad2DVAO = EaglercraftGPU.createGLBufferArray();
standardQuad3DVAO = EaglercraftGPU.createGLBufferArray();
standardQuad2DVAO = EaglercraftGPU.createGLVertexArray();
standardQuad3DVAO = EaglercraftGPU.createGLVertexArray();
standardQuadVBO = _wglGenBuffers();
FloatBuffer verts = EagRuntime.allocateFloatBuffer(18);
@ -56,12 +56,12 @@ public class DrawUtils {
_wglBufferData(GL_ARRAY_BUFFER, verts, GL_STATIC_DRAW);
EagRuntime.freeFloatBuffer(verts);
EaglercraftGPU.bindGLBufferArray(standardQuad2DVAO);
EaglercraftGPU.bindGLVertexArray(standardQuad2DVAO);
EaglercraftGPU.enableVertexAttribArray(0);
EaglercraftGPU.vertexAttribPointer(0, 2, GL_FLOAT, false, 12, 0);
EaglercraftGPU.bindGLBufferArray(standardQuad3DVAO);
EaglercraftGPU.bindGLVertexArray(standardQuad3DVAO);
EaglercraftGPU.enableVertexAttribArray(0);
EaglercraftGPU.vertexAttribPointer(0, 3, GL_FLOAT, false, 12, 0);
@ -92,22 +92,22 @@ public class DrawUtils {
}
public static void drawStandardQuad2D() {
EaglercraftGPU.bindGLBufferArray(standardQuad2DVAO);
EaglercraftGPU.doDrawArrays(GL_TRIANGLES, 0, 6);
EaglercraftGPU.bindGLVertexArray(standardQuad2DVAO);
EaglercraftGPU.drawArrays(GL_TRIANGLES, 0, 6);
}
public static void drawStandardQuad3D() {
EaglercraftGPU.bindGLBufferArray(standardQuad3DVAO);
EaglercraftGPU.doDrawArrays(GL_TRIANGLES, 0, 6);
EaglercraftGPU.bindGLVertexArray(standardQuad3DVAO);
EaglercraftGPU.drawArrays(GL_TRIANGLES, 0, 6);
}
public static void destroy() {
if(standardQuad2DVAO != null) {
EaglercraftGPU.destroyGLBufferArray(standardQuad2DVAO);
EaglercraftGPU.destroyGLVertexArray(standardQuad2DVAO);
standardQuad2DVAO = null;
}
if(standardQuad3DVAO != null) {
EaglercraftGPU.destroyGLBufferArray(standardQuad3DVAO);
EaglercraftGPU.destroyGLVertexArray(standardQuad3DVAO);
standardQuad3DVAO = null;
}
if(standardQuadVBO != null) {

View File

@ -106,13 +106,13 @@ public class EaglerMeshLoader implements IResourceManagerReloadListener {
}
if(meshStruct.vertexArray == null) {
meshStruct.vertexArray = EaglercraftGPU.createGLBufferArray();
meshStruct.vertexArray = EaglercraftGPU.createGLVertexArray();
}
if(meshStruct.vertexBuffer == null) {
meshStruct.vertexBuffer = _wglGenBuffers();
meshStruct.vertexBuffer = EaglercraftGPU.createGLArrayBuffer();
}
if(meshStruct.indexBuffer == null) {
meshStruct.indexBuffer = _wglGenBuffers();
meshStruct.indexBuffer = EaglercraftGPU.createGLElementArrayBuffer();
}
up1.position(0).limit(intsOfVertex);
@ -120,7 +120,7 @@ public class EaglerMeshLoader implements IResourceManagerReloadListener {
EaglercraftGPU.bindVAOGLArrayBufferNow(meshStruct.vertexBuffer);
_wglBufferData(GL_ARRAY_BUFFER, up1, GL_STATIC_DRAW);
EaglercraftGPU.bindGLBufferArray(meshStruct.vertexArray);
EaglercraftGPU.bindGLVertexArray(meshStruct.vertexArray);
up1.position(intsOfVertex).limit(intsTotal);
@ -139,15 +139,15 @@ public class EaglerMeshLoader implements IResourceManagerReloadListener {
EaglercraftGPU.vertexAttribPointer(meshStruct.hasTexture ? 2 : 1, 4, GL_BYTE, true, stride, 12);
}catch(Throwable ex) {
if(meshStruct.vertexArray != null) {
EaglercraftGPU.destroyGLBufferArray(meshStruct.vertexArray);
EaglercraftGPU.destroyGLVertexArray(meshStruct.vertexArray);
meshStruct.vertexArray = null;
}
if(meshStruct.vertexBuffer != null) {
_wglDeleteBuffers(meshStruct.vertexBuffer);
EaglercraftGPU.destroyGLArrayBuffer(meshStruct.vertexBuffer);
meshStruct.vertexBuffer = null;
}
if(meshStruct.indexBuffer != null) {
_wglDeleteBuffers(meshStruct.indexBuffer);
EaglercraftGPU.destroyGLElementArrayBuffer(meshStruct.indexBuffer);
meshStruct.indexBuffer = null;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022-2024 lax1dude. All Rights Reserved.
* Copyright (c) 2022-2025 lax1dude. All Rights Reserved.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@ -28,7 +28,7 @@ import com.carrotsearch.hppc.IntObjectMap;
import net.lax1dude.eaglercraft.v1_8.EagRuntime;
import net.lax1dude.eaglercraft.v1_8.internal.GLObjectMap;
import net.lax1dude.eaglercraft.v1_8.internal.IBufferArrayGL;
import net.lax1dude.eaglercraft.v1_8.internal.IVertexArrayGL;
import net.lax1dude.eaglercraft.v1_8.internal.IBufferGL;
import net.lax1dude.eaglercraft.v1_8.internal.IProgramGL;
import net.lax1dude.eaglercraft.v1_8.internal.IQueryGL;
@ -40,6 +40,48 @@ import static net.lax1dude.eaglercraft.v1_8.internal.PlatformOpenGL.*;
public class EaglercraftGPU {
static final GLObjectRecycler<IBufferGL> arrayBufferRecycler = new GLObjectRecycler<IBufferGL>(32) {
@Override
protected IBufferGL create() {
return _wglGenBuffers();
}
@Override
protected void destroy(IBufferGL object) {
_wglDeleteBuffers(object);
}
};
static final GLObjectRecycler<IBufferGL> elementArrayBufferRecycler = new GLObjectRecycler<IBufferGL>(32) {
@Override
protected IBufferGL create() {
return _wglGenBuffers();
}
@Override
protected void destroy(IBufferGL object) {
_wglDeleteBuffers(object);
}
};
static final GLObjectRecycler<IVertexArrayGL> VAORecycler = new GLObjectRecycler<IVertexArrayGL>(128) {
@Override
protected IVertexArrayGL create() {
return _wglGenVertexArrays();
}
@Override
protected void destroy(IVertexArrayGL object) {
_wglDeleteVertexArrays(object);
}
};
static final GLObjectMap<ITextureGL> mapTexturesGL = new GLObjectMap<>(8192);
static final GLObjectMap<IQueryGL> mapQueriesGL = new GLObjectMap<>(8192);
static final GLObjectMap<DisplayList> mapDisplayListsGL = new GLObjectMap<>(8192);
@ -47,9 +89,9 @@ public class EaglercraftGPU {
static final Logger logger = LogManager.getLogger("EaglercraftGPU");
static boolean emulatedVAOs = false;
static SoftGLBufferState emulatedVAOState = new SoftGLBufferState();
static SoftGLVertexState emulatedVAOState = new SoftGLVertexState();
public static final String gluErrorString(int i) {
public static String gluErrorString(int i) {
switch(i) {
case GL_INVALID_ENUM: return "GL_INVALID_ENUM";
case GL_INVALID_VALUE: return "GL_INVALID_VALUE";
@ -61,22 +103,22 @@ public class EaglercraftGPU {
}
}
public static final void glTexParameteri(int target, int param, int value) {
public static void glTexParameteri(int target, int param, int value) {
_wglTexParameteri(target, param, value);
}
public static final void glTexParameterf(int target, int param, float value) {
public static void glTexParameterf(int target, int param, float value) {
_wglTexParameterf(target, param, value);
}
public static final void glCopyTexSubImage2D(int target, int level, int sx, int sy, int dx, int dy, int w, int h) {
public static void glCopyTexSubImage2D(int target, int level, int sx, int sy, int dx, int dy, int w, int h) {
_wglCopyTexSubImage2D(target, level, sx, sy, dx, dy, w, h);
}
private static DisplayList currentList = null;
private static ByteBuffer displayListBuffer = EagRuntime.allocateByteBuffer(0x100000);
public static final void glNewList(int target, int op) {
public static void glNewList(int target, int op) {
if(currentList != null) {
throw new IllegalStateException("A display list is already being compiled you eagler!");
}
@ -88,18 +130,18 @@ public class EaglercraftGPU {
throw new IllegalArgumentException("Unknown display list: " + target);
}
if(dp.vertexArray != null && dp.attribs > 0) {
EaglercraftGPU.bindGLBufferArray(dp.vertexArray);
EaglercraftGPU.bindGLVertexArray(dp.vertexArray);
int c = 0;
if((dp.attribs & ATTRIB_TEXTURE) == ATTRIB_TEXTURE) {
if((dp.attribs & ATTRIB_TEXTURE) != 0) {
EaglercraftGPU.disableVertexAttribArray(++c);
}
if((dp.attribs & ATTRIB_COLOR) == ATTRIB_COLOR) {
if((dp.attribs & ATTRIB_COLOR) != 0) {
EaglercraftGPU.disableVertexAttribArray(++c);
}
if((dp.attribs & ATTRIB_NORMAL) == ATTRIB_NORMAL) {
if((dp.attribs & ATTRIB_NORMAL) != 0) {
EaglercraftGPU.disableVertexAttribArray(++c);
}
if((dp.attribs & ATTRIB_LIGHTMAP) == ATTRIB_LIGHTMAP) {
if((dp.attribs & ATTRIB_LIGHTMAP) != 0) {
EaglercraftGPU.disableVertexAttribArray(++c);
}
}
@ -108,7 +150,7 @@ public class EaglercraftGPU {
dp.count = 0;
}
private static final void growDisplayListBuffer(int len) {
private static void growDisplayListBuffer(int len) {
int wantSize = displayListBuffer.position() + len;
if(displayListBuffer.capacity() < wantSize) {
int newSize = (wantSize & 0xFFFE0000) + 0x40000;
@ -119,7 +161,7 @@ public class EaglercraftGPU {
}
}
public static final void glEndList() {
public static void glEndList() {
DisplayList dp = currentList;
if(dp == null) {
throw new IllegalStateException("No list is currently being compiled!");
@ -127,11 +169,11 @@ public class EaglercraftGPU {
if(dp.attribs == -1) {
if(dp.vertexArray != null) {
EaglercraftGPU.destroyGLBufferArray(dp.vertexArray);
destroyGLVertexArray(dp.vertexArray);
dp.vertexArray = null;
}
if(dp.vertexBuffer != null) {
_wglDeleteBuffers(dp.vertexBuffer);
destroyGLArrayBuffer(dp.vertexBuffer);
dp.vertexBuffer = null;
}
currentList = null;
@ -139,7 +181,7 @@ public class EaglercraftGPU {
}
if(dp.vertexArray == null) {
dp.vertexArray = createGLBufferArray();
dp.vertexArray = createGLVertexArray();
dp.bindQuad16 = false;
dp.bindQuad32 = false;
}
@ -156,14 +198,56 @@ public class EaglercraftGPU {
currentList = null;
}
public static final void glCallList(int displayList) {
public static void uploadListDirect(int target, ByteBuffer buffer, int attrib, int mode, int count) {
DisplayList dp = mapDisplayListsGL.get(target);
if(dp == null) {
throw new IllegalArgumentException("Unknown display list: " + target);
}
if(dp.vertexArray != null && dp.attribs > 0) {
EaglercraftGPU.bindGLVertexArray(dp.vertexArray);
int c = 0;
if((dp.attribs & ATTRIB_TEXTURE) != 0) {
EaglercraftGPU.disableVertexAttribArray(++c);
}
if((dp.attribs & ATTRIB_COLOR) != 0) {
EaglercraftGPU.disableVertexAttribArray(++c);
}
if((dp.attribs & ATTRIB_NORMAL) != 0) {
EaglercraftGPU.disableVertexAttribArray(++c);
}
if((dp.attribs & ATTRIB_LIGHTMAP) != 0) {
EaglercraftGPU.disableVertexAttribArray(++c);
}
}
if(dp.vertexArray == null) {
dp.vertexArray = createGLVertexArray();
dp.bindQuad16 = false;
dp.bindQuad32 = false;
}
if(dp.vertexBuffer == null) {
dp.vertexBuffer = createGLArrayBuffer();
}
bindVAOGLArrayBufferNow(dp.vertexBuffer);
_wglBufferData(GL_ARRAY_BUFFER, buffer, GL_STATIC_DRAW);
dp.attribs = attrib;
FixedFunctionPipeline.setupDisplayList(dp);
dp.mode = mode;
dp.count = count;
}
public static void glCallList(int displayList) {
DisplayList dp = mapDisplayListsGL.get(displayList);
if(dp == null) {
throw new NullPointerException("Tried to call a display list that does not exist: " + displayList);
}
if(dp.attribs != -1) {
FixedFunctionPipeline p = FixedFunctionPipeline.setupRenderDisplayList(dp.attribs).update();
bindGLBufferArray(dp.vertexArray);
bindGLVertexArray(dp.vertexArray);
if(dp.mode == GL_QUADS) {
int cnt = dp.count;
if(cnt > 0xFFFF) {
@ -191,23 +275,23 @@ public class EaglercraftGPU {
}
}
public static final void flushDisplayList(int displayList) {
public static void flushDisplayList(int displayList) {
DisplayList dp = mapDisplayListsGL.get(displayList);
if(dp == null) {
throw new NullPointerException("Tried to flush a display list that does not exist: " + displayList);
}
dp.attribs = -1;
if(dp.vertexArray != null) {
EaglercraftGPU.destroyGLBufferArray(dp.vertexArray);
EaglercraftGPU.destroyGLVertexArray(dp.vertexArray);
dp.vertexArray = null;
}
if(dp.vertexBuffer != null) {
_wglDeleteBuffers(dp.vertexBuffer);
EaglercraftGPU.destroyGLArrayBuffer(dp.vertexBuffer);
dp.vertexBuffer = null;
}
}
public static final void glNormal3f(float x, float y, float z) {
public static void glNormal3f(float x, float y, float z) {
GlStateManager.stateNormalX = x;
GlStateManager.stateNormalY = y;
GlStateManager.stateNormalZ = z;
@ -216,7 +300,7 @@ public class EaglercraftGPU {
private static final IntObjectMap<String> stringCache = new IntObjectHashMap<>();
public static final String glGetString(int param) {
public static String glGetString(int param) {
String str = stringCache.get(param);
if(str == null) {
str = _wglGetString(param);
@ -228,7 +312,7 @@ public class EaglercraftGPU {
return str.length() == 0 ? null : str;
}
public static final void glGetInteger(int param, int[] values) {
public static void glGetInteger(int param, int[] values) {
switch(param) {
case GL_VIEWPORT:
values[0] = GlStateManager.viewportX;
@ -241,11 +325,11 @@ public class EaglercraftGPU {
}
}
public static final int glGetInteger(int param) {
public static int glGetInteger(int param) {
return _wglGetInteger(param);
}
public static final void glTexImage2D(int target, int level, int internalFormat, int w, int h, int unused,
public static void glTexImage2D(int target, int level, int internalFormat, int w, int h, int unused,
int format, int type, ByteBuffer pixels) {
GlStateManager.setTextureCachedSize(target, w, h);
if(glesVers >= 300) {
@ -256,7 +340,7 @@ public class EaglercraftGPU {
}
}
public static final void glTexImage2D(int target, int level, int internalFormat, int w, int h, int unused,
public static void glTexImage2D(int target, int level, int internalFormat, int w, int h, int unused,
int format, int type, IntBuffer pixels) {
GlStateManager.setTextureCachedSize(target, w, h);
if(glesVers >= 300) {
@ -267,12 +351,12 @@ public class EaglercraftGPU {
}
}
public static final void glTexSubImage2D(int target, int level, int x, int y, int w, int h, int format,
public static void glTexSubImage2D(int target, int level, int x, int y, int w, int h, int format,
int type, IntBuffer pixels) {
_wglTexSubImage2D(target, level, x, y, w, h, format, type, pixels);
}
public static final void glTexStorage2D(int target, int levels, int internalFormat, int w, int h) {
public static void glTexStorage2D(int target, int levels, int internalFormat, int w, int h) {
GlStateManager.setTextureCachedSize(target, w, h);
if(texStorageCapable && (glesVers >= 300 || levels == 1 || (MathHelper.calculateLogBaseTwo(Math.max(w, h)) + 1) == levels)) {
_wglTexStorage2D(target, levels, internalFormat, w, h);
@ -285,7 +369,7 @@ public class EaglercraftGPU {
}
}
public static final void glReadPixels(int x, int y, int width, int height, int format, int type, ByteBuffer buffer) {
public static void glReadPixels(int x, int y, int width, int height, int format, int type, ByteBuffer buffer) {
switch(type) {
case GL_FLOAT:
_wglReadPixels(x, y, width, height, format, GL_FLOAT, buffer.asFloatBuffer());
@ -300,11 +384,11 @@ public class EaglercraftGPU {
}
}
public static final void glLineWidth(float f) {
public static void glLineWidth(float f) {
_wglLineWidth(f);
}
public static final void glFog(int param, FloatBuffer valueBuffer) {
public static void glFog(int param, FloatBuffer valueBuffer) {
int pos = valueBuffer.position();
switch(param) {
case GL_FOG_COLOR:
@ -320,82 +404,94 @@ public class EaglercraftGPU {
valueBuffer.position(pos);
}
public static final void glFogi(int param, int value) {
// I'm not sure what this is for currently
}
public static final int glGenLists() {
public static int glGenLists() {
return mapDisplayListsGL.register(new DisplayList());
}
public static final void glDeleteLists(int id) {
public static void glDeleteLists(int id) {
DisplayList d = mapDisplayListsGL.free(id);
if(d != null) {
if(d.vertexArray != null) {
EaglercraftGPU.destroyGLBufferArray(d.vertexArray);
destroyGLVertexArray(d.vertexArray);
}
if(d.vertexBuffer != null) {
_wglDeleteBuffers(d.vertexBuffer);
destroyGLArrayBuffer(d.vertexBuffer);
}
}
}
public static final int glGetError() {
public static int glGetError() {
return _wglGetError();
}
public static final void glBlendEquation(int equation) {
public static void glBlendEquation(int equation) {
if(equation != GlStateManager.stateBlendEquation) {
_wglBlendEquation(equation);
GlStateManager.stateBlendEquation = equation;
}
}
public static final boolean areVAOsEmulated() {
public static IBufferGL createGLArrayBuffer() {
return arrayBufferRecycler.create();
}
public static void destroyGLArrayBuffer(IBufferGL buffer) {
arrayBufferRecycler.destroy(buffer);
}
public static IBufferGL createGLElementArrayBuffer() {
return elementArrayBufferRecycler.create();
}
public static void destroyGLElementArrayBuffer(IBufferGL buffer) {
elementArrayBufferRecycler.destroy(buffer);
}
public static boolean areVAOsEmulated() {
return emulatedVAOs;
}
public static final IBufferArrayGL createGLBufferArray() {
public static IVertexArrayGL createGLVertexArray() {
if(emulatedVAOs) {
return new SoftGLBufferArray();
return new SoftGLVertexArray();
}else {
return _wglGenVertexArrays();
return VAORecycler.create();
}
}
public static final void destroyGLBufferArray(IBufferArrayGL buffer) {
public static void destroyGLVertexArray(IVertexArrayGL buffer) {
if(!emulatedVAOs) {
_wglDeleteVertexArrays(buffer);
VAORecycler.destroy(buffer);
}
}
public static final void enableVertexAttribArray(int index) {
public static void enableVertexAttribArray(int index) {
if(emulatedVAOs) {
if(currentBufferArray == null) {
if(currentVertexArray == null) {
logger.warn("Skipping enable attrib with emulated VAO because no known VAO is bound!");
return;
}
((SoftGLBufferArray)currentBufferArray).enableAttrib(index, true);
((SoftGLVertexArray)currentVertexArray).enableAttrib(index, true);
}else {
_wglEnableVertexAttribArray(index);
}
}
public static final void disableVertexAttribArray(int index) {
public static void disableVertexAttribArray(int index) {
if(emulatedVAOs) {
if(currentBufferArray == null) {
if(currentVertexArray == null) {
logger.warn("Skipping disable attrib with emulated VAO because no known VAO is bound!");
return;
}
((SoftGLBufferArray)currentBufferArray).enableAttrib(index, false);
((SoftGLVertexArray)currentVertexArray).enableAttrib(index, false);
}else {
_wglDisableVertexAttribArray(index);
}
}
public static final void vertexAttribPointer(int index, int size, int format, boolean normalized, int stride, int offset) {
public static void vertexAttribPointer(int index, int size, int format, boolean normalized, int stride, int offset) {
if(emulatedVAOs) {
if(currentBufferArray == null) {
if(currentVertexArray == null) {
logger.warn("Skipping vertexAttribPointer with emulated VAO because no known VAO is bound!");
return;
}
@ -403,77 +499,77 @@ public class EaglercraftGPU {
logger.warn("Skipping vertexAttribPointer with emulated VAO because no VAO array buffer is bound!");
return;
}
((SoftGLBufferArray)currentBufferArray).setAttrib(currentVAOArrayBuffer, index, size, format, normalized, stride, offset);
((SoftGLVertexArray)currentVertexArray).setAttrib(currentVAOArrayBuffer, index, size, format, normalized, stride, offset);
}else {
_wglVertexAttribPointer(index, size, format, normalized, stride, offset);
}
}
public static final void vertexAttribDivisor(int index, int divisor) {
public static void vertexAttribDivisor(int index, int divisor) {
if(emulatedVAOs) {
if(currentBufferArray == null) {
if(currentVertexArray == null) {
logger.warn("Skipping vertexAttribPointer with emulated VAO because no known VAO is bound!");
return;
}
((SoftGLBufferArray)currentBufferArray).setAttribDivisor(index, divisor);
((SoftGLVertexArray)currentVertexArray).setAttribDivisor(index, divisor);
}else {
_wglVertexAttribDivisor(index, divisor);
}
}
public static final void doDrawArrays(int mode, int first, int count) {
public static void drawArrays(int mode, int first, int count) {
if(emulatedVAOs) {
if(currentBufferArray == null) {
if(currentVertexArray == null) {
logger.warn("Skipping draw call with emulated VAO because no known VAO is bound!");
return;
}
((SoftGLBufferArray)currentBufferArray).transitionToState(emulatedVAOState, false);
((SoftGLVertexArray)currentVertexArray).transitionToState(emulatedVAOState, false);
}
_wglDrawArrays(mode, first, count);
}
public static final void doDrawElements(int mode, int count, int type, int offset) {
public static void drawElements(int mode, int count, int type, int offset) {
if(emulatedVAOs) {
if(currentBufferArray == null) {
if(currentVertexArray == null) {
logger.warn("Skipping draw call with emulated VAO because no known VAO is bound!");
return;
}
((SoftGLBufferArray)currentBufferArray).transitionToState(emulatedVAOState, true);
((SoftGLVertexArray)currentVertexArray).transitionToState(emulatedVAOState, true);
}
_wglDrawElements(mode, count, type, offset);
}
public static final void doDrawArraysInstanced(int mode, int first, int count, int instances) {
public static void drawArraysInstanced(int mode, int first, int count, int instances) {
if(emulatedVAOs) {
if(currentBufferArray == null) {
if(currentVertexArray == null) {
logger.warn("Skipping instanced draw call with emulated VAO because no known VAO is bound!");
return;
}
((SoftGLBufferArray)currentBufferArray).transitionToState(emulatedVAOState, false);
((SoftGLVertexArray)currentVertexArray).transitionToState(emulatedVAOState, false);
}
_wglDrawArraysInstanced(mode, first, count, instances);
}
public static final void doDrawElementsInstanced(int mode, int count, int type, int offset, int instances) {
public static void drawElementsInstanced(int mode, int count, int type, int offset, int instances) {
if(emulatedVAOs) {
if(currentBufferArray == null) {
if(currentVertexArray == null) {
logger.warn("Skipping instanced draw call with emulated VAO because no known VAO is bound!");
return;
}
((SoftGLBufferArray)currentBufferArray).transitionToState(emulatedVAOState, true);
((SoftGLVertexArray)currentVertexArray).transitionToState(emulatedVAOState, true);
}
_wglDrawElementsInstanced(mode, count, type, offset, instances);
}
static IBufferArrayGL currentBufferArray = null;
static IVertexArrayGL currentVertexArray = null;
public static final void bindGLBufferArray(IBufferArrayGL buffer) {
public static void bindGLVertexArray(IVertexArrayGL buffer) {
if(emulatedVAOs) {
currentBufferArray = buffer;
currentVertexArray = buffer;
}else {
if(currentBufferArray != buffer) {
if(currentVertexArray != buffer) {
_wglBindVertexArray(buffer);
currentBufferArray = buffer;
currentVertexArray = buffer;
}
}
}
@ -483,7 +579,10 @@ public class EaglercraftGPU {
// only used when VAOs are emulated
static IBufferGL currentVAOArrayBuffer = null;
public static final void bindVAOGLArrayBuffer(IBufferGL buffer) {
/**
* Binds a buffer to use only for calls to vertexAttribPointer
*/
public static void bindVAOGLArrayBuffer(IBufferGL buffer) {
if(emulatedVAOs) {
currentVAOArrayBuffer = buffer;
}else {
@ -494,7 +593,10 @@ public class EaglercraftGPU {
}
}
public static final void bindVAOGLArrayBufferNow(IBufferGL buffer) {
/**
* Binds a buffer to use for calls to vertexAttribPointer and the GL_ARRAY_BUFFER target
*/
public static void bindVAOGLArrayBufferNow(IBufferGL buffer) {
if(emulatedVAOs) {
currentVAOArrayBuffer = buffer;
}
@ -504,25 +606,28 @@ public class EaglercraftGPU {
}
}
public static final void bindVAOGLElementArrayBuffer(IBufferGL buffer) {
/**
* Binds an index buffer to the current vertex array
*/
public static void bindVAOGLElementArrayBuffer(IBufferGL buffer) {
if(emulatedVAOs) {
if(currentBufferArray == null) {
if(currentVertexArray == null) {
logger.warn("Skipping set element array buffer with emulated VAO because no known VAO is bound!");
return;
}
((SoftGLBufferArray)currentBufferArray).setIndexBuffer(buffer);
((SoftGLVertexArray)currentVertexArray).setIndexBuffer(buffer);
}else {
_wglBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffer);
}
}
static final void bindVAOGLElementArrayBufferNow(IBufferGL buffer) {
static void bindVAOGLElementArrayBufferNow(IBufferGL buffer) {
if(emulatedVAOs) {
if(currentBufferArray == null) {
if(currentVertexArray == null) {
logger.warn("Skipping set element array buffer with emulated VAO because no known VAO is bound!");
return;
}
((SoftGLBufferArray)currentBufferArray).setIndexBuffer(buffer);
((SoftGLVertexArray)currentVertexArray).setIndexBuffer(buffer);
if(currentEmulatedVAOIndexBuffer != buffer) {
_wglBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffer);
currentEmulatedVAOIndexBuffer = buffer;
@ -534,14 +639,17 @@ public class EaglercraftGPU {
static IBufferGL currentEmulatedVAOIndexBuffer = null;
static final void bindEmulatedVAOIndexBuffer(IBufferGL buffer) {
static void bindEmulatedVAOIndexBuffer(IBufferGL buffer) {
if(currentEmulatedVAOIndexBuffer != buffer) {
_wglBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffer);
currentEmulatedVAOIndexBuffer = buffer;
}
}
public static final void bindGLArrayBuffer(IBufferGL buffer) {
/**
* Binds a buffer to the GL_ARRAY_BUFFER target for use not related to vertexAttribPointer
*/
public static void bindGLArrayBuffer(IBufferGL buffer) {
if(currentArrayBuffer != buffer) {
_wglBindBuffer(GL_ARRAY_BUFFER, buffer);
currentArrayBuffer = buffer;
@ -549,8 +657,11 @@ public class EaglercraftGPU {
}
static IBufferGL currentUniformBuffer = null;
public static final void bindGLUniformBuffer(IBufferGL buffer) {
/**
* Binds a buffer to the GL_UNIFORM_BUFFER target
*/
public static void bindGLUniformBuffer(IBufferGL buffer) {
if(currentUniformBuffer != buffer) {
_wglBindBuffer(0x8A11, buffer);
currentUniformBuffer = buffer;
@ -559,7 +670,7 @@ public class EaglercraftGPU {
static IProgramGL currentShaderProgram = null;
public static final void bindGLShaderProgram(IProgramGL prog) {
public static void bindGLShaderProgram(IProgramGL prog) {
if(currentShaderProgram != prog) {
_wglUseProgram(prog);
currentShaderProgram = prog;
@ -570,7 +681,7 @@ public class EaglercraftGPU {
private static final int[] currentUniformBlockBindingOffset = new int[16];
private static final int[] currentUniformBlockBindingSize = new int[16];
public static final void bindUniformBufferRange(int index, IBufferGL buffer, int offset, int size) {
public static void bindUniformBufferRange(int index, IBufferGL buffer, int offset, int size) {
if(currentUniformBlockBindings[index] != buffer || currentUniformBlockBindingOffset[index] != offset
|| currentUniformBlockBindingSize[index] != size) {
_wglBindBufferRange(0x8A11, index, buffer, offset, size);
@ -587,7 +698,7 @@ public class EaglercraftGPU {
public static final int CLEAR_BINDING_ARRAY_BUFFER = 16;
public static final int CLEAR_BINDING_SHADER_PROGRAM = 32;
public static final void clearCurrentBinding(int mask) {
public static void clearCurrentBinding(int mask) {
if((mask & CLEAR_BINDING_TEXTURE) != 0) {
int[] i = GlStateManager.boundTexture;
for(int j = 0; j < i.length; ++j) {
@ -602,7 +713,7 @@ public class EaglercraftGPU {
_wglActiveTexture(GL_TEXTURE0);
}
if((mask & CLEAR_BINDING_BUFFER_ARRAY) != 0) {
currentBufferArray = null;
currentVertexArray = null;
}
if((mask & CLEAR_BINDING_ARRAY_BUFFER) != 0) {
currentArrayBuffer = currentVAOArrayBuffer = null;
@ -617,7 +728,7 @@ public class EaglercraftGPU {
public static final int ATTRIB_NORMAL = 4;
public static final int ATTRIB_LIGHTMAP = 8;
public static final void renderBuffer(ByteBuffer buffer, int attrib, int mode, int count) {
public static void renderBuffer(ByteBuffer buffer, int attrib, int mode, int count) {
if(currentList != null) {
if(currentList.attribs == -1) {
currentList.attribs = attrib;
@ -643,19 +754,27 @@ public class EaglercraftGPU {
}
}
public static final void optimize() {
private static long lastRecyclerFlush = 0l;
public static void optimize() {
FixedFunctionPipeline.optimize();
long millis = EagRuntime.steadyTimeMillis();
if(millis - lastRecyclerFlush > 120000l) {
lastRecyclerFlush = millis;
arrayBufferRecycler.compact();
VAORecycler.compact();
}
}
private static FixedFunctionPipeline lastRender = null;
private static int lastMode = 0;
private static int lastCount = 0;
public static final void renderAgain() {
public static void renderAgain() {
if(lastRender == null) {
throw new UnsupportedOperationException("Cannot render the same verticies twice while generating display list");
}
EaglercraftGPU.bindGLBufferArray(lastRender.getDirectModeBufferArray());
EaglercraftGPU.bindGLVertexArray(lastRender.getDirectModeVertexArray());
lastRender.update().drawDirectArrays(lastMode, 0, lastCount);
}
@ -665,7 +784,7 @@ public class EaglercraftGPU {
private static IBufferGL quad32EmulationBuffer = null;
private static int quad32EmulationBufferSize = 0;
public static final void attachQuad16EmulationBuffer(int vertexCount, boolean bind) {
public static void attachQuad16EmulationBuffer(int vertexCount, boolean bind) {
IBufferGL buf = quad16EmulationBuffer;
if(buf == null) {
quad16EmulationBuffer = buf = _wglGenBuffers();
@ -690,7 +809,7 @@ public class EaglercraftGPU {
}
}
public static final void attachQuad32EmulationBuffer(int vertexCount, boolean bind) {
public static void attachQuad32EmulationBuffer(int vertexCount, boolean bind) {
IBufferGL buf = quad32EmulationBuffer;
if(buf == null) {
quad32EmulationBuffer = buf = _wglGenBuffers();
@ -709,7 +828,7 @@ public class EaglercraftGPU {
}
}
private static final void resizeQuad16EmulationBuffer(int quadCount) {
private static void resizeQuad16EmulationBuffer(int quadCount) {
IntBuffer buf = EagRuntime.allocateIntBuffer(quadCount * 3);
int v1, v2, v3, v4;
for(int i = 0; i < quadCount; ++i) {
@ -726,7 +845,7 @@ public class EaglercraftGPU {
EagRuntime.freeIntBuffer(buf);
}
private static final void resizeQuad32EmulationBuffer(int quadCount) {
private static void resizeQuad32EmulationBuffer(int quadCount) {
IntBuffer buf = EagRuntime.allocateIntBuffer(quadCount * 6);
int v1, v2, v3, v4;
for(int i = 0; i < quadCount; ++i) {
@ -743,11 +862,11 @@ public class EaglercraftGPU {
EagRuntime.freeIntBuffer(buf);
}
public static final ITextureGL getNativeTexture(int tex) {
public static ITextureGL getNativeTexture(int tex) {
return mapTexturesGL.get(tex);
}
public static final void regenerateTexture(int tex) {
public static void regenerateTexture(int tex) {
ITextureGL webglTex = mapTexturesGL.get(tex);
if(webglTex != null) {
GlStateManager.unbindTextureIfCached(tex);
@ -758,12 +877,12 @@ public class EaglercraftGPU {
}
}
public static final void drawHighPoly(HighPolyMesh mesh) {
public static void drawHighPoly(HighPolyMesh mesh) {
if(mesh.vertexCount == 0 || mesh.indexCount == 0 || mesh.vertexArray == null) {
return;
}
FixedFunctionPipeline p = FixedFunctionPipeline.setupRenderDisplayList(mesh.getAttribBits()).update();
EaglercraftGPU.bindGLBufferArray(mesh.vertexArray);
EaglercraftGPU.bindGLVertexArray(mesh.vertexArray);
p.drawElements(GL_TRIANGLES, mesh.indexCount, GL_UNSIGNED_SHORT, 0);
}
@ -781,15 +900,15 @@ public class EaglercraftGPU {
static boolean npotCapable = false;
static int uniformBufferOffsetAlignment = -1;
public static final void createFramebufferHDR16FTexture(int target, int level, int w, int h, int format, boolean allow32bitFallback) {
public static void createFramebufferHDR16FTexture(int target, int level, int w, int h, int format, boolean allow32bitFallback) {
createFramebufferHDR16FTexture(target, level, w, h, format, allow32bitFallback, null);
}
public static final void createFramebufferHDR16FTexture(int target, int level, int w, int h, int format, ByteBuffer pixelData) {
public static void createFramebufferHDR16FTexture(int target, int level, int w, int h, int format, ByteBuffer pixelData) {
createFramebufferHDR16FTexture(target, level, w, h, format, false, pixelData);
}
private static final void createFramebufferHDR16FTexture(int target, int level, int w, int h, int format, boolean allow32bitFallback, ByteBuffer pixelData) {
private static void createFramebufferHDR16FTexture(int target, int level, int w, int h, int format, boolean allow32bitFallback, ByteBuffer pixelData) {
if(hasFramebufferHDR16FSupport) {
int internalFormat;
switch(format) {
@ -825,15 +944,15 @@ public class EaglercraftGPU {
}
}
public static final void createFramebufferHDR32FTexture(int target, int level, int w, int h, int format, boolean allow16bitFallback) {
public static void createFramebufferHDR32FTexture(int target, int level, int w, int h, int format, boolean allow16bitFallback) {
createFramebufferHDR32FTexture(target, level, w, h, format, allow16bitFallback, null);
}
public static final void createFramebufferHDR32FTexture(int target, int level, int w, int h, int format, ByteBuffer pixelData) {
public static void createFramebufferHDR32FTexture(int target, int level, int w, int h, int format, ByteBuffer pixelData) {
createFramebufferHDR32FTexture(target, level, w, h, format, false, pixelData);
}
private static final void createFramebufferHDR32FTexture(int target, int level, int w, int h, int format, boolean allow16bitFallback, ByteBuffer pixelData) {
private static void createFramebufferHDR32FTexture(int target, int level, int w, int h, int format, boolean allow16bitFallback, ByteBuffer pixelData) {
if(hasFramebufferHDR32FSupport) {
int internalFormat;
switch(format) {
@ -864,7 +983,7 @@ public class EaglercraftGPU {
}
}
public static final void warmUpCache() {
public static void warmUpCache() {
EaglercraftGPU.glGetString(7936);
EaglercraftGPU.glGetString(7937);
EaglercraftGPU.glGetString(7938);
@ -914,7 +1033,7 @@ public class EaglercraftGPU {
if(!instancingCapable) {
logger.info("Note: Could not unlock instancing via OpenGL extensions, using slow vanilla font and particle rendering");
}
emulatedVAOState = emulatedVAOs ? new SoftGLBufferState() : null;
emulatedVAOState = emulatedVAOs ? new SoftGLVertexState() : null;
PlatformOpenGL.enterVAOEmulationHook();
GLSLHeader.init();
DrawUtils.init();
@ -928,7 +1047,7 @@ public class EaglercraftGPU {
DrawUtils.vshLocal = null;
}
public static final void destroyCache() {
public static void destroyCache() {
GLSLHeader.destroy();
DrawUtils.destroy();
InstancedFontRenderer.destroy();
@ -952,43 +1071,43 @@ public class EaglercraftGPU {
mapDisplayListsGL.clear();
}
public static final int checkOpenGLESVersion() {
public static int checkOpenGLESVersion() {
return glesVers;
}
public static final boolean checkFBORenderMipmapCapable() {
public static boolean checkFBORenderMipmapCapable() {
return fboRenderMipmapCapable;
}
public static final boolean checkVAOCapable() {
public static boolean checkVAOCapable() {
return vertexArrayCapable;
}
public static final boolean checkInstancingCapable() {
public static boolean checkInstancingCapable() {
return instancingCapable;
}
public static final boolean checkTexStorageCapable() {
public static boolean checkTexStorageCapable() {
return texStorageCapable;
}
public static final boolean checkTextureLODCapable() {
public static boolean checkTextureLODCapable() {
return textureLODCapable;
}
public static final boolean checkShader5Capable() {
public static boolean checkShader5Capable() {
return shader5Capable;
}
public static final boolean checkNPOTCapable() {
public static boolean checkNPOTCapable() {
return npotCapable;
}
public static final int getUniformBufferOffsetAlignment() {
public static int getUniformBufferOffsetAlignment() {
return uniformBufferOffsetAlignment;
}
public static final boolean checkHDRFramebufferSupport(int bits) {
public static boolean checkHDRFramebufferSupport(int bits) {
switch(bits) {
case 16:
return hasFramebufferHDR16FSupport;
@ -999,7 +1118,7 @@ public class EaglercraftGPU {
}
}
public static final boolean checkLinearHDRFilteringSupport(int bits) {
public static boolean checkLinearHDRFilteringSupport(int bits) {
switch(bits) {
case 16:
return hasLinearHDR16FSupport;
@ -1010,16 +1129,16 @@ public class EaglercraftGPU {
}
}
public static final boolean checkHasHDRFramebufferSupport() {
public static boolean checkHasHDRFramebufferSupport() {
return hasFramebufferHDR16FSupport || hasFramebufferHDR32FSupport;
}
public static final boolean checkHasHDRFramebufferSupportWithFilter() {
public static boolean checkHasHDRFramebufferSupportWithFilter() {
return (hasFramebufferHDR16FSupport && hasLinearHDR16FSupport) || (hasFramebufferHDR32FSupport && hasLinearHDR32FSupport);
}
//legacy
public static final boolean checkLinearHDR32FSupport() {
public static boolean checkLinearHDR32FSupport() {
return hasLinearHDR32FSupport;
}

View File

@ -26,7 +26,7 @@ import net.lax1dude.eaglercraft.v1_8.internal.buffer.ByteBuffer;
import net.lax1dude.eaglercraft.v1_8.internal.buffer.FloatBuffer;
import net.lax1dude.eaglercraft.v1_8.EagRuntime;
import net.lax1dude.eaglercraft.v1_8.internal.IBufferArrayGL;
import net.lax1dude.eaglercraft.v1_8.internal.IVertexArrayGL;
import net.lax1dude.eaglercraft.v1_8.internal.IProgramGL;
import net.lax1dude.eaglercraft.v1_8.internal.IShaderGL;
import net.lax1dude.eaglercraft.v1_8.internal.IUniformGL;
@ -47,7 +47,7 @@ public class FixedFunctionPipeline {
private static final Logger LOGGER = LogManager.getLogger("FixedFunctionPipeline");
static final int getFragmentState() {
static int getFragmentState() {
return (GlStateManager.stateTexture[0] ? STATE_ENABLE_TEXTURE2D : 0) |
(GlStateManager.stateTexture[1] ? STATE_ENABLE_LIGHTMAP : 0) |
(GlStateManager.stateAlphaTest ? STATE_ENABLE_ALPHA_TEST : 0) |
@ -77,7 +77,7 @@ public class FixedFunctionPipeline {
StreamBufferInstance sb = self.streamBuffer.getBuffer(buffer.remaining());
self.currentVertexArray = sb;
EaglercraftGPU.bindGLBufferArray(sb.getVertexArray());
EaglercraftGPU.bindGLVertexArray(sb.getVertexArray());
EaglercraftGPU.bindGLArrayBuffer(sb.getVertexBuffer());
_wglBufferSubData(GL_ARRAY_BUFFER, 0, buffer);
@ -98,7 +98,7 @@ public class FixedFunctionPipeline {
self = getPipelineInstanceCore(baseState);
}
EaglercraftGPU.bindGLBufferArray(list.vertexArray);
EaglercraftGPU.bindGLVertexArray(list.vertexArray);
EaglercraftGPU.bindVAOGLArrayBuffer(list.vertexBuffer);
EaglercraftGPU.enableVertexAttribArray(0);
@ -146,7 +146,7 @@ public class FixedFunctionPipeline {
void drawArrays(int mode, int offset, int count) {
EaglercraftGPU.bindGLShaderProgram(shaderProgram);
EaglercraftGPU.doDrawArrays(mode, offset, count);
EaglercraftGPU.drawArrays(mode, offset, count);
}
void drawDirectArrays(int mode, int offset, int count) {
@ -161,7 +161,7 @@ public class FixedFunctionPipeline {
}else {
EaglercraftGPU.attachQuad32EmulationBuffer(count, false);
}
EaglercraftGPU.doDrawElements(GL_TRIANGLES, count + (count >> 1),
EaglercraftGPU.drawElements(GL_TRIANGLES, count + (count >> 1),
GL_UNSIGNED_INT, 0);
}else {
if(!sb.bindQuad16) {
@ -171,17 +171,17 @@ public class FixedFunctionPipeline {
}else {
EaglercraftGPU.attachQuad16EmulationBuffer(count, false);
}
EaglercraftGPU.doDrawElements(GL_TRIANGLES, count + (count >> 1),
EaglercraftGPU.drawElements(GL_TRIANGLES, count + (count >> 1),
GL_UNSIGNED_SHORT, 0);
}
}else {
EaglercraftGPU.doDrawArrays(mode, offset, count);
EaglercraftGPU.drawArrays(mode, offset, count);
}
}
void drawElements(int mode, int count, int type, int offset) {
EaglercraftGPU.bindGLShaderProgram(shaderProgram);
EaglercraftGPU.doDrawElements(mode, count, type, offset);
EaglercraftGPU.drawElements(mode, count, type, offset);
}
private static IExtPipelineCompiler extensionProvider;
@ -576,7 +576,7 @@ public class FixedFunctionPipeline {
streamBuffer = new StreamBuffer(FixedFunctionShader.initialSize, FixedFunctionShader.initialCount,
FixedFunctionShader.maxCount, (vertexArray, vertexBuffer) -> {
EaglercraftGPU.bindGLBufferArray(vertexArray);
EaglercraftGPU.bindGLVertexArray(vertexArray);
EaglercraftGPU.bindVAOGLArrayBuffer(vertexBuffer);
EaglercraftGPU.enableVertexAttribArray(0);
@ -1103,7 +1103,7 @@ public class FixedFunctionPipeline {
streamBuffer.destroy();
}
public IBufferArrayGL getDirectModeBufferArray() {
public IVertexArrayGL getDirectModeVertexArray() {
return currentVertexArray.vertexArray;
}
}

View File

@ -0,0 +1,56 @@
/*
* Copyright (c) 2025 lax1dude. All Rights Reserved.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.lax1dude.eaglercraft.v1_8.opengl;
import java.util.ArrayDeque;
import java.util.Deque;
public abstract class GLObjectRecycler<T> {
private Deque<T> deletedObjects;
private final int reserveSize;
public GLObjectRecycler(int reserveSize) {
this.reserveSize = reserveSize;
this.deletedObjects = new ArrayDeque<>(reserveSize << 1);
}
public T createObject() {
T ret = deletedObjects.pollLast();
if(ret != null) {
return ret;
}else {
return create();
}
}
public void destroyObject(T obj) {
deletedObjects.addLast(obj);
}
public void compact() {
while(deletedObjects.size() > reserveSize) {
destroy(deletedObjects.removeFirst());
}
}
protected abstract T create();
protected abstract void destroy(T object);
}

View File

@ -121,10 +121,10 @@ public class GlStateManager {
static int colorMaskBits = 15;
static float clearColorR = 0.0f;
static float clearColorG = 0.0f;
static float clearColorB = 0.0f;
static float clearColorA = 1.0f;
static float clearColorR = -999.0f;
static float clearColorG = -999.0f;
static float clearColorB = -999.0f;
static float clearColorA = -999.0f;
static float clearDepth = -999.0f;
@ -196,7 +196,7 @@ public class GlStateManager {
}
}
public static final void pushLightCoords() {
public static void pushLightCoords() {
int push = stateLightsStackPointer + 1;
if(push < stateLightsStack.length) {
Vector4f[] copyFrom = stateLightsStack[stateLightsStackPointer];
@ -220,7 +220,7 @@ public class GlStateManager {
}
}
public static final void popLightCoords() {
public static void popLightCoords() {
if(stateLightsStackPointer > 0) {
--stateLightsStackPointer;
}else {
@ -230,15 +230,15 @@ public class GlStateManager {
}
}
public static final void disableAlpha() {
public static void disableAlpha() {
stateAlphaTest = false;
}
public static final void enableAlpha() {
public static void enableAlpha() {
stateAlphaTest = true;
}
public static final void alphaFunc(int func, float ref) {
public static void alphaFunc(int func, float ref) {
if(func != GL_GREATER) {
throw new UnsupportedOperationException("Only GL_GREATER alphaFunc is supported");
}else {
@ -246,28 +246,28 @@ public class GlStateManager {
}
}
public static final void enableLighting() {
public static void enableLighting() {
stateLighting = true;
}
public static final void disableLighting() {
public static void disableLighting() {
stateLighting = false;
}
public static final void enableExtensionPipeline() {
public static void enableExtensionPipeline() {
stateUseExtensionPipeline = true;
}
public static final void disableExtensionPipeline() {
public static void disableExtensionPipeline() {
stateUseExtensionPipeline = false;
}
public static final boolean isExtensionPipeline() {
public static boolean isExtensionPipeline() {
return stateUseExtensionPipeline;
}
private static final Vector4f paramVector4 = new Vector4f();
public static final void enableMCLight(int light, float diffuse, double dirX,
public static void enableMCLight(int light, float diffuse, double dirX,
double dirY, double dirZ, double dirW) {
if(dirW != 0.0) throw new IllegalArgumentException("dirW must be 0.0!");
paramVector4.x = (float)dirX;
@ -287,47 +287,47 @@ public class GlStateManager {
++stateLightingSerial[stateLightsStackPointer];
}
public static final void disableMCLight(int light) {
public static void disableMCLight(int light) {
stateLightsEnabled[stateLightsStackPointer][light] = false;
++stateLightingSerial[stateLightsStackPointer];
}
public static final void setMCLightAmbient(float r, float g, float b) {
public static void setMCLightAmbient(float r, float g, float b) {
stateLightingAmbientR = r;
stateLightingAmbientG = g;
stateLightingAmbientB = b;
++stateLightingAmbientSerial;
}
public static final void enableColorMaterial() {
public static void enableColorMaterial() {
stateMaterial = true;
}
public static final void disableColorMaterial() {
public static void disableColorMaterial() {
stateMaterial = false;
}
public static final void disableDepth() {
public static void disableDepth() {
if(stateDepthTest) {
_wglDisable(GL_DEPTH_TEST);
stateDepthTest = false;
}
}
public static final void enableDepth() {
public static void enableDepth() {
if(!stateDepthTest) {
_wglEnable(GL_DEPTH_TEST);
stateDepthTest = true;
}
}
public static final void eagPushStateForGLES2BlitHack() {
public static void eagPushStateForGLES2BlitHack() {
stateDepthTestStash = stateDepthTest;
stateCullStash = stateCull;
stateBlendStash = stateBlend;
}
public static final void eagPopStateForGLES2BlitHack() {
public static void eagPopStateForGLES2BlitHack() {
if(stateDepthTestStash) {
enableDepth();
}else {
@ -345,7 +345,7 @@ public class GlStateManager {
}
}
public static final void depthFunc(int depthFunc) {
public static void depthFunc(int depthFunc) {
int rev = depthFunc;
switch(depthFunc) {
case GL_GREATER:
@ -370,42 +370,42 @@ public class GlStateManager {
}
}
public static final void depthMask(boolean flagIn) {
public static void depthMask(boolean flagIn) {
if(flagIn != stateDepthMask) {
_wglDepthMask(flagIn);
stateDepthMask = flagIn;
}
}
public static final void disableBlend() {
public static void disableBlend() {
if(stateBlend) {
if(stateGlobalBlend) _wglDisable(GL_BLEND);
stateBlend = false;
}
}
public static final void enableBlend() {
public static void enableBlend() {
if(!stateBlend) {
if(stateGlobalBlend) _wglEnable(GL_BLEND);
stateBlend = true;
}
}
public static final void globalDisableBlend() {
public static void globalDisableBlend() {
if(stateBlend) {
_wglDisable(GL_BLEND);
}
stateGlobalBlend = false;
}
public static final void globalEnableBlend() {
public static void globalEnableBlend() {
if(stateBlend) {
_wglEnable(GL_BLEND);
}
stateGlobalBlend = true;
}
public static final void blendFunc(int srcFactor, int dstFactor) {
public static void blendFunc(int srcFactor, int dstFactor) {
if(stateEnableOverlayFramebufferBlending) {
tryBlendFuncSeparate(srcFactor, dstFactor, 0, 1);
return;
@ -419,7 +419,7 @@ public class GlStateManager {
}
}
public static final void tryBlendFuncSeparate(int srcFactor, int dstFactor, int srcFactorAlpha, int dstFactorAlpha) {
public static void tryBlendFuncSeparate(int srcFactor, int dstFactor, int srcFactorAlpha, int dstFactorAlpha) {
if(stateEnableOverlayFramebufferBlending) { // game overlay framebuffer in EntityRenderer.java
srcFactorAlpha = GL_ONE;
dstFactorAlpha = GL_ONE_MINUS_SRC_ALPHA;
@ -433,15 +433,15 @@ public class GlStateManager {
}
}
public static final void enableOverlayFramebufferBlending() {
public static void enableOverlayFramebufferBlending() {
stateEnableOverlayFramebufferBlending = true;
}
public static final void disableOverlayFramebufferBlending() {
public static void disableOverlayFramebufferBlending() {
stateEnableOverlayFramebufferBlending = false;
}
public static final void setShaderBlendSrc(float r, float g, float b, float a) {
public static void setShaderBlendSrc(float r, float g, float b, float a) {
stateShaderBlendSrcColorR = r;
stateShaderBlendSrcColorG = g;
stateShaderBlendSrcColorB = b;
@ -449,7 +449,7 @@ public class GlStateManager {
++stateShaderBlendColorSerial;
}
public static final void setShaderBlendAdd(float r, float g, float b, float a) {
public static void setShaderBlendAdd(float r, float g, float b, float a) {
stateShaderBlendAddColorR = r;
stateShaderBlendAddColorG = g;
stateShaderBlendAddColorB = b;
@ -457,15 +457,15 @@ public class GlStateManager {
++stateShaderBlendColorSerial;
}
public static final void enableShaderBlendAdd() {
public static void enableShaderBlendAdd() {
stateEnableShaderBlendColor = true;
}
public static final void disableShaderBlendAdd() {
public static void disableShaderBlendAdd() {
stateEnableShaderBlendColor = false;
}
public static final void setBlendConstants(float r, float g, float b, float a) {
public static void setBlendConstants(float r, float g, float b, float a) {
if(r != blendConstantR || g != blendConstantG || b != blendConstantB || a != blendConstantA) {
_wglBlendColor(r, g, b, a);
blendConstantR = r;
@ -475,70 +475,70 @@ public class GlStateManager {
}
}
public static final void enableFog() {
public static void enableFog() {
stateFog = true;
}
public static final void disableFog() {
public static void disableFog() {
stateFog = false;
}
public static final void setFog(int param) {
public static void setFog(int param) {
stateFogEXP = param == GL_EXP;
++stateFogSerial;
}
public static final void setFogDensity(float param) {
public static void setFogDensity(float param) {
stateFogDensity = param;
++stateFogSerial;
}
public static final void setFogStart(float param) {
public static void setFogStart(float param) {
stateFogStart = param;
++stateFogSerial;
}
public static final void setFogEnd(float param) {
public static void setFogEnd(float param) {
stateFogEnd = param;
++stateFogSerial;
}
public static final void enableCull() {
public static void enableCull() {
if(!stateCull) {
_wglEnable(GL_CULL_FACE);
stateCull = true;
}
}
public static final void disableCull() {
public static void disableCull() {
if(stateCull) {
_wglDisable(GL_CULL_FACE);
stateCull = false;
}
}
public static final void cullFace(int mode) {
public static void cullFace(int mode) {
if(stateCullFace != mode) {
_wglCullFace(mode);
stateCullFace = mode;
}
}
public static final void enablePolygonOffset() {
public static void enablePolygonOffset() {
if(!statePolygonOffset) {
_wglEnable(GL_POLYGON_OFFSET_FILL);
statePolygonOffset = true;
}
}
public static final void disablePolygonOffset() {
public static void disablePolygonOffset() {
if(statePolygonOffset) {
_wglDisable(GL_POLYGON_OFFSET_FILL);
statePolygonOffset = false;
}
}
public static final void doPolygonOffset(float factor, float units) {
public static void doPolygonOffset(float factor, float units) {
if(factor != statePolygonOffsetFactor || units != statePolygonOffsetUnits) {
_wglPolygonOffset(-factor, units);
statePolygonOffsetFactor = factor;
@ -546,32 +546,32 @@ public class GlStateManager {
}
}
public static final void enableColorLogic() {
public static void enableColorLogic() {
throw new UnsupportedOperationException("Color logic op is not supported in OpenGL ES!");
}
public static final void disableColorLogic() {
public static void disableColorLogic() {
}
public static final void colorLogicOp(int opcode) {
public static void colorLogicOp(int opcode) {
}
public static final void enableTexGen() {
public static void enableTexGen() {
stateTexGen = true;
}
public static final void disableTexGen() {
public static void disableTexGen() {
stateTexGen = false;
}
public static final void texGen(GlStateManager.TexGen coord, int source) {
public static void texGen(GlStateManager.TexGen coord, int source) {
coord.source = source;
++stateTexGenSerial;
}
public static final void func_179105_a(GlStateManager.TexGen coord, int plane, FloatBuffer vector) {
public static void func_179105_a(GlStateManager.TexGen coord, int plane, FloatBuffer vector) {
coord.plane = plane;
coord.vector.load(vector);
if(plane == GL_EYE_PLANE) {
@ -581,7 +581,7 @@ public class GlStateManager {
++stateTexGenSerial;
}
public static final void setActiveTexture(int texture) {
public static void setActiveTexture(int texture) {
int textureIdx = texture - GL_TEXTURE0;
if(textureIdx != activeTexture) {
_wglActiveTexture(texture);
@ -589,44 +589,44 @@ public class GlStateManager {
}
}
public static final void enableTexture2D() {
public static void enableTexture2D() {
stateTexture[activeTexture] = true;
}
public static final void disableTexture2D() {
public static void disableTexture2D() {
stateTexture[activeTexture] = false;
}
public static final void texCoords2D(float x, float y) {
public static void texCoords2D(float x, float y) {
textureCoordsX[activeTexture] = x;
textureCoordsY[activeTexture] = y;
++textureCoordsAccessSerial[activeTexture];
}
public static final void texCoords2DDirect(int tex, float x, float y) {
public static void texCoords2DDirect(int tex, float x, float y) {
textureCoordsX[tex] = x;
textureCoordsY[tex] = y;
++textureCoordsAccessSerial[tex];
}
public static final float getTexCoordX(int tex) {
public static float getTexCoordX(int tex) {
return textureCoordsX[tex];
}
public static final float getTexCoordY(int tex) {
public static float getTexCoordY(int tex) {
return textureCoordsY[tex];
}
public static final int generateTexture() {
public static int generateTexture() {
return EaglercraftGPU.mapTexturesGL.register(_wglGenTextures());
}
public static final void deleteTexture(int texture) {
public static void deleteTexture(int texture) {
unbindTextureIfCached(texture);
_wglDeleteTextures(EaglercraftGPU.mapTexturesGL.free(texture));
}
static final void unbindTextureIfCached(int texture) {
static void unbindTextureIfCached(int texture) {
boolean f1, f2 = false;
for(int i = 0; i < boundTexture.length; ++i) {
if(boundTexture[i] == texture) {
@ -647,21 +647,21 @@ public class GlStateManager {
}
}
public static final void bindTexture(int texture) {
public static void bindTexture(int texture) {
if(texture != boundTexture[activeTexture]) {
_wglBindTexture(GL_TEXTURE_2D, EaglercraftGPU.mapTexturesGL.get(texture));
boundTexture[activeTexture] = texture;
}
}
public static final void bindTexture3D(int texture) {
public static void bindTexture3D(int texture) {
if(texture != boundTexture[activeTexture]) {
_wglBindTexture(GL_TEXTURE_3D, EaglercraftGPU.mapTexturesGL.get(texture));
boundTexture[activeTexture] = texture;
}
}
public static final void quickBindTexture(int unit, int texture) {
public static void quickBindTexture(int unit, int texture) {
int unitBase = unit - GL_TEXTURE0;
if(texture != boundTexture[unitBase]) {
if(unitBase != activeTexture) {
@ -675,19 +675,19 @@ public class GlStateManager {
}
}
public static final void shadeModel(int mode) {
public static void shadeModel(int mode) {
}
public static final void enableRescaleNormal() {
public static void enableRescaleNormal() {
// still not sure what this is for
}
public static final void disableRescaleNormal() {
public static void disableRescaleNormal() {
}
public static final void viewport(int x, int y, int w, int h) {
public static void viewport(int x, int y, int w, int h) {
if(viewportX != x || viewportY != y || viewportW != w || viewportH != h) {
_wglViewport(x, y, w, h);
viewportX = x;
@ -697,7 +697,7 @@ public class GlStateManager {
}
}
public static final void colorMask(boolean red, boolean green, boolean blue, boolean alpha) {
public static void colorMask(boolean red, boolean green, boolean blue, boolean alpha) {
int bits = (red ? 1 : 0) | (green ? 2 : 0) | (blue ? 4 : 0) | (alpha ? 8 : 0);
if(bits != colorMaskBits) {
_wglColorMask(red, green, blue, alpha);
@ -705,7 +705,7 @@ public class GlStateManager {
}
}
public static final void clearDepth(float depth) {
public static void clearDepth(float depth) {
depth = 1.0f - depth;
if(depth != clearDepth) {
_wglClearDepth(depth);
@ -713,7 +713,7 @@ public class GlStateManager {
}
}
public static final void clearColor(float red, float green, float blue, float alpha) {
public static void clearColor(float red, float green, float blue, float alpha) {
if(red != clearColorR || green != clearColorG || blue != clearColorB || alpha != clearColorA) {
_wglClearColor(red, green, blue, alpha);
clearColorR = red;
@ -723,15 +723,15 @@ public class GlStateManager {
}
}
public static final void clear(int mask) {
public static void clear(int mask) {
_wglClear(mask);
}
public static final void matrixMode(int mode) {
public static void matrixMode(int mode) {
stateMatrixMode = mode;
}
public static final void loadIdentity() {
public static void loadIdentity() {
switch(stateMatrixMode) {
case GL_MODELVIEW:
default:
@ -750,7 +750,7 @@ public class GlStateManager {
}
}
public static final void pushMatrix() {
public static void pushMatrix() {
int push;
switch(stateMatrixMode) {
case GL_MODELVIEW:
@ -794,7 +794,7 @@ public class GlStateManager {
}
}
public static final void popMatrix() {
public static void popMatrix() {
switch(stateMatrixMode) {
case GL_MODELVIEW:
default:
@ -853,7 +853,7 @@ public class GlStateManager {
return mat;
}
public static final void getFloat(int pname, float[] params) {
public static void getFloat(int pname, float[] params) {
switch(pname) {
case GL_MODELVIEW_MATRIX:
modelMatrixStack[modelMatrixStackPointer].store(params);
@ -869,7 +869,7 @@ public class GlStateManager {
}
}
public static final void getFloat(int pname, FloatBuffer params) {
public static void getFloat(int pname, FloatBuffer params) {
switch(pname) {
case GL_MODELVIEW_MATRIX:
modelMatrixStack[modelMatrixStackPointer].store(params);
@ -885,7 +885,7 @@ public class GlStateManager {
}
}
public static final void ortho(double left, double right, double bottom, double top, double zNear, double zFar) {
public static void ortho(double left, double right, double bottom, double top, double zNear, double zFar) {
Matrix4f matrix = getMatrixIncr();
paramMatrix.m00 = 2.0f / (float)(right - left);
paramMatrix.m01 = 0.0f;
@ -908,7 +908,7 @@ public class GlStateManager {
private static final Vector3f paramVector = new Vector3f();
private static final float toRad = 0.0174532925f;
public static final void rotate(float angle, float x, float y, float z) {
public static void rotate(float angle, float x, float y, float z) {
Matrix4f matrix = getMatrixIncr();
if(x == 0.0f) {
if(y == 0.0f) {
@ -927,28 +927,28 @@ public class GlStateManager {
_glRotatef(matrix, toRad * angle, x, y, z);
}
public static final void rotateXYZ(float x, float y, float z) {
public static void rotateXYZ(float x, float y, float z) {
Matrix4f matrix = getMatrixIncr();
if(x != 0.0f) _glRotatefX(matrix, toRad * x);
if(y != 0.0f) _glRotatefY(matrix, toRad * y);
if(z != 0.0f) _glRotatefZ(matrix, toRad * z);
}
public static final void rotateZYX(float x, float y, float z) {
public static void rotateZYX(float x, float y, float z) {
Matrix4f matrix = getMatrixIncr();
if(z != 0.0f) _glRotatefZ(matrix, toRad * z);
if(y != 0.0f) _glRotatefY(matrix, toRad * y);
if(x != 0.0f) _glRotatefX(matrix, toRad * x);
}
public static final void rotateXYZRad(float x, float y, float z) {
public static void rotateXYZRad(float x, float y, float z) {
Matrix4f matrix = getMatrixIncr();
if(x != 0.0f) _glRotatefX(matrix, x);
if(y != 0.0f) _glRotatefY(matrix, y);
if(z != 0.0f) _glRotatefZ(matrix, z);
}
public static final void rotateZYXRad(float x, float y, float z) {
public static void rotateZYXRad(float x, float y, float z) {
Matrix4f matrix = getMatrixIncr();
if(z != 0.0f) _glRotatefZ(matrix, z);
if(y != 0.0f) _glRotatefY(matrix, y);
@ -1042,7 +1042,7 @@ public class GlStateManager {
mat.m13 = nm13;
}
public static final void scale(float x, float y, float z) {
public static void scale(float x, float y, float z) {
Matrix4f matrix = getMatrixIncr();
matrix.m00 *= x;
matrix.m01 *= x;
@ -1058,7 +1058,7 @@ public class GlStateManager {
matrix.m23 *= z;
}
public static final void scale(double x, double y, double z) {
public static void scale(double x, double y, double z) {
Matrix4f matrix = getMatrixIncr();
matrix.m00 *= x;
matrix.m01 *= x;
@ -1074,7 +1074,7 @@ public class GlStateManager {
matrix.m23 *= z;
}
public static final void translate(float x, float y, float z) {
public static void translate(float x, float y, float z) {
Matrix4f matrix = getMatrixIncr();
matrix.m30 = matrix.m00 * x + matrix.m10 * y + matrix.m20 * z + matrix.m30;
matrix.m31 = matrix.m01 * x + matrix.m11 * y + matrix.m21 * z + matrix.m31;
@ -1082,7 +1082,7 @@ public class GlStateManager {
matrix.m33 = matrix.m03 * x + matrix.m13 * y + matrix.m23 * z + matrix.m33;
}
public static final void translate(double x, double y, double z) {
public static void translate(double x, double y, double z) {
float _x = (float)x;
float _y = (float)y;
float _z = (float)z;
@ -1094,18 +1094,18 @@ public class GlStateManager {
}
private static final Matrix4f paramMatrix = new Matrix4f();
public static final void multMatrix(float[] matrix) {
public static void multMatrix(float[] matrix) {
paramMatrix.load(matrix);
Matrix4f mat = getMatrixIncr();
Matrix4f.mul(mat, paramMatrix, mat);
}
public static final void multMatrix(Matrix4f matrix) {
public static void multMatrix(Matrix4f matrix) {
Matrix4f mat = getMatrixIncr();
Matrix4f.mul(mat, matrix, mat);
}
public static final void color(float colorRed, float colorGreen, float colorBlue, float colorAlpha) {
public static void color(float colorRed, float colorGreen, float colorBlue, float colorAlpha) {
stateColorR = colorRed;
stateColorG = colorGreen;
stateColorB = colorBlue;
@ -1113,7 +1113,7 @@ public class GlStateManager {
++stateColorSerial;
}
public static final void color(float colorRed, float colorGreen, float colorBlue) {
public static void color(float colorRed, float colorGreen, float colorBlue) {
stateColorR = colorRed;
stateColorG = colorGreen;
stateColorB = colorBlue;
@ -1121,7 +1121,7 @@ public class GlStateManager {
++stateColorSerial;
}
public static final void resetColor() {
public static void resetColor() {
stateColorR = 1.0f;
stateColorG = 1.0f;
stateColorB = 1.0f;
@ -1129,11 +1129,11 @@ public class GlStateManager {
++stateColorSerial;
}
public static final void callList(int list) {
public static void callList(int list) {
EaglercraftGPU.glCallList(list);
}
public static final void gluPerspective(float fovy, float aspect, float zNear, float zFar) {
public static void gluPerspective(float fovy, float aspect, float zNear, float zFar) {
Matrix4f matrix = getMatrixIncr();
float cotangent = (float) Math.cos(fovy * toRad * 0.5f) / (float) Math.sin(fovy * toRad * 0.5f);
paramMatrix.m00 = cotangent / aspect;
@ -1155,7 +1155,7 @@ public class GlStateManager {
Matrix4f.mul(matrix, paramMatrix, matrix);
}
public static final void gluLookAt(Vector3f eye, Vector3f center, Vector3f up) {
public static void gluLookAt(Vector3f eye, Vector3f center, Vector3f up) {
Matrix4f matrix = getMatrixIncr();
float x = center.x - eye.x;
float y = center.y - eye.y;
@ -1196,7 +1196,7 @@ public class GlStateManager {
Matrix4f.mul(matrix, paramMatrix, matrix);
}
public static final void transform(Vector4f vecIn, Vector4f vecOut) {
public static void transform(Vector4f vecIn, Vector4f vecOut) {
Matrix4f matrix;
switch(stateMatrixMode) {
case GL_MODELVIEW:
@ -1216,7 +1216,7 @@ public class GlStateManager {
private static final Matrix4f unprojA = new Matrix4f();
private static final Matrix4f unprojB = new Matrix4f();
private static final Vector4f unprojC = new Vector4f();
public static final void gluUnProject(float p1, float p2, float p3, float[] modelview, float[] projection,
public static void gluUnProject(float p1, float p2, float p3, float[] modelview, float[] projection,
int[] viewport, float[] objectcoords) {
unprojA.load(modelview);
unprojB.load(projection);
@ -1230,7 +1230,7 @@ public class GlStateManager {
objectcoords[2] = unprojC.z / unprojC.w;
}
public static final void getMatrix(Matrix4f mat) {
public static void getMatrix(Matrix4f mat) {
switch(stateMatrixMode) {
case GL_MODELVIEW:
mat.load(modelMatrixStack[modelMatrixStackPointer]);
@ -1245,7 +1245,7 @@ public class GlStateManager {
}
}
public static final void loadMatrix(Matrix4f mat) {
public static void loadMatrix(Matrix4f mat) {
switch(stateMatrixMode) {
case GL_MODELVIEW:
modelMatrixStack[modelMatrixStackPointer].load(mat);
@ -1263,15 +1263,15 @@ public class GlStateManager {
}
}
public static final int getModelViewSerial() {
public static int getModelViewSerial() {
return modelMatrixStackAccessSerial[modelMatrixStackPointer];
}
public static final Matrix4f getModelViewReference() {
public static Matrix4f getModelViewReference() {
return modelMatrixStack[modelMatrixStackPointer];
}
public static final Matrix4f getProjectionReference() {
public static Matrix4f getProjectionReference() {
return projectionMatrixStack[projectionMatrixStackPointer];
}

View File

@ -16,13 +16,13 @@
package net.lax1dude.eaglercraft.v1_8.opengl;
import net.lax1dude.eaglercraft.v1_8.internal.IBufferArrayGL;
import net.lax1dude.eaglercraft.v1_8.internal.IVertexArrayGL;
import net.lax1dude.eaglercraft.v1_8.internal.IBufferGL;
import net.lax1dude.eaglercraft.v1_8.opengl.FixedFunctionShader.FixedFunctionState;
public class HighPolyMesh {
IBufferArrayGL vertexArray;
IVertexArrayGL vertexArray;
IBufferGL vertexBuffer;
IBufferGL indexBuffer;
@ -31,7 +31,7 @@ public class HighPolyMesh {
boolean hasTexture;
public HighPolyMesh(IBufferArrayGL vertexArray, IBufferGL vertexBuffer, IBufferGL indexBuffer, int vertexCount,
public HighPolyMesh(IVertexArrayGL vertexArray, IBufferGL vertexBuffer, IBufferGL indexBuffer, int vertexCount,
int indexCount, boolean hasTexture) {
this.vertexArray = vertexArray;
this.vertexBuffer = vertexBuffer;

View File

@ -20,7 +20,7 @@ import static net.lax1dude.eaglercraft.v1_8.internal.PlatformOpenGL.*;
import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.*;
import net.lax1dude.eaglercraft.v1_8.EagRuntime;
import net.lax1dude.eaglercraft.v1_8.internal.IBufferArrayGL;
import net.lax1dude.eaglercraft.v1_8.internal.IVertexArrayGL;
import net.lax1dude.eaglercraft.v1_8.internal.IBufferGL;
import net.lax1dude.eaglercraft.v1_8.internal.IProgramGL;
import net.lax1dude.eaglercraft.v1_8.internal.IShaderGL;
@ -54,7 +54,7 @@ public class InstancedFontRenderer {
private static IUniformGL u_color4f = null;
private static IUniformGL u_colorBias4f = null;
private static IBufferArrayGL vertexArray = null;
private static IVertexArrayGL vertexArray = null;
private static IBufferGL vertexBuffer = null;
private static IBufferGL instancesBuffer = null;
@ -160,7 +160,7 @@ public class InstancedFontRenderer {
_wglUniform1i(_wglGetUniformLocation(shaderProgram, "u_inputTexture"), 0);
vertexArray = EaglercraftGPU.createGLBufferArray();
vertexArray = EaglercraftGPU.createGLVertexArray();
vertexBuffer = _wglGenBuffers();
instancesBuffer = _wglGenBuffers();
@ -191,7 +191,7 @@ public class InstancedFontRenderer {
});
verts.flip();
EaglercraftGPU.bindGLBufferArray(vertexArray);
EaglercraftGPU.bindGLVertexArray(vertexArray);
EaglercraftGPU.bindVAOGLArrayBufferNow(vertexBuffer);
_wglBufferData(GL_ARRAY_BUFFER, verts, GL_STATIC_DRAW);
@ -370,7 +370,7 @@ public class InstancedFontRenderer {
}
EaglercraftGPU.bindGLArrayBuffer(instancesBuffer);
EaglercraftGPU.bindGLBufferArray(vertexArray);
EaglercraftGPU.bindGLVertexArray(vertexArray);
if(charactersDrawn > 0) {
int p = fontDataBuffer.position();
@ -382,7 +382,7 @@ public class InstancedFontRenderer {
fontDataBuffer.position(p);
fontDataBuffer.limit(l);
EaglercraftGPU.doDrawArraysInstanced(GL_TRIANGLES, shadow ? 0 : 6, shadow ? 12 : 6, charactersDrawn);
EaglercraftGPU.drawArraysInstanced(GL_TRIANGLES, shadow ? 0 : 6, shadow ? 12 : 6, charactersDrawn);
}
if(boldCharactersDrawn > 0) {
@ -395,7 +395,7 @@ public class InstancedFontRenderer {
fontBoldDataBuffer.position(p);
fontBoldDataBuffer.limit(l);
EaglercraftGPU.doDrawArraysInstanced(GL_TRIANGLES, shadow ? 12 : 24, shadow ? 24 : 12, boldCharactersDrawn);
EaglercraftGPU.drawArraysInstanced(GL_TRIANGLES, shadow ? 12 : 24, shadow ? 24 : 12, boldCharactersDrawn);
}
}
@ -449,7 +449,7 @@ public class InstancedFontRenderer {
}
}
private static final void updateBounds(int x, int y) {
private static void updateBounds(int x, int y) {
if(x < widthCalcLeast || widthCalcLeast == Integer.MAX_VALUE) widthCalcLeast = x;
if(x > widthCalcMost || widthCalcMost == Integer.MAX_VALUE) widthCalcMost = x;
if(y < heightCalcLeast || heightCalcLeast == Integer.MAX_VALUE) heightCalcLeast = y;
@ -479,7 +479,7 @@ public class InstancedFontRenderer {
u_color4f = null;
u_colorBias4f = null;
if(vertexArray != null) {
EaglercraftGPU.destroyGLBufferArray(vertexArray);
EaglercraftGPU.destroyGLVertexArray(vertexArray);
vertexArray = null;
}
if(vertexBuffer != null) {

View File

@ -20,7 +20,7 @@ import static net.lax1dude.eaglercraft.v1_8.internal.PlatformOpenGL.*;
import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.*;
import net.lax1dude.eaglercraft.v1_8.EagRuntime;
import net.lax1dude.eaglercraft.v1_8.internal.IBufferArrayGL;
import net.lax1dude.eaglercraft.v1_8.internal.IVertexArrayGL;
import net.lax1dude.eaglercraft.v1_8.internal.IBufferGL;
import net.lax1dude.eaglercraft.v1_8.internal.IProgramGL;
import net.lax1dude.eaglercraft.v1_8.internal.IShaderGL;
@ -56,7 +56,7 @@ public class InstancedParticleRenderer {
private static IUniformGL u_transformParam_3_4_f = null;
private static IUniformGL u_color4f = null;
private static IBufferArrayGL vertexArray = null;
private static IVertexArrayGL vertexArray = null;
private static IBufferGL vertexBuffer = null;
private static IBufferGL instancesBuffer = null;
@ -161,7 +161,7 @@ public class InstancedParticleRenderer {
_wglUniform1i(_wglGetUniformLocation(shaderProgram, "u_inputTexture"), 0);
_wglUniform1i(_wglGetUniformLocation(shaderProgram, "u_lightmapTexture"), 1);
vertexArray = EaglercraftGPU.createGLBufferArray();
vertexArray = EaglercraftGPU.createGLVertexArray();
vertexBuffer = _wglGenBuffers();
instancesBuffer = _wglGenBuffers();
@ -172,7 +172,7 @@ public class InstancedParticleRenderer {
});
verts.flip();
EaglercraftGPU.bindGLBufferArray(vertexArray);
EaglercraftGPU.bindGLVertexArray(vertexArray);
EaglercraftGPU.bindVAOGLArrayBufferNow(vertexBuffer);
_wglBufferData(GL_ARRAY_BUFFER, verts, GL_STATIC_DRAW);
@ -305,7 +305,7 @@ public class InstancedParticleRenderer {
}
EaglercraftGPU.bindGLArrayBuffer(instancesBuffer);
EaglercraftGPU.bindGLBufferArray(vertexArray);
EaglercraftGPU.bindGLVertexArray(vertexArray);
int p = particleBuffer.position();
int l = particleBuffer.limit();
@ -316,7 +316,7 @@ public class InstancedParticleRenderer {
particleBuffer.position(p);
particleBuffer.limit(l);
EaglercraftGPU.doDrawArraysInstanced(GL_TRIANGLES, 0, 6, particleCount);
EaglercraftGPU.drawArraysInstanced(GL_TRIANGLES, 0, 6, particleCount);
}
public static void stupidColorSetHack(IUniformGL color4f) {
@ -342,7 +342,7 @@ public class InstancedParticleRenderer {
u_transformParam_3_4_f = null;
u_color4f = null;
if(vertexArray != null) {
EaglercraftGPU.destroyGLBufferArray(vertexArray);
EaglercraftGPU.destroyGLVertexArray(vertexArray);
vertexArray = null;
}
if(vertexBuffer != null) {

View File

@ -16,12 +16,12 @@
package net.lax1dude.eaglercraft.v1_8.opengl;
import net.lax1dude.eaglercraft.v1_8.internal.IBufferArrayGL;
import net.lax1dude.eaglercraft.v1_8.internal.IVertexArrayGL;
import net.lax1dude.eaglercraft.v1_8.internal.IBufferGL;
import static net.lax1dude.eaglercraft.v1_8.internal.PlatformOpenGL.*;
class SoftGLBufferArray implements IBufferArrayGL {
class SoftGLVertexArray implements IVertexArrayGL {
Attrib[] attribs = new Attrib[4];
int[] attribDivisors = null;
@ -30,7 +30,7 @@ class SoftGLBufferArray implements IBufferArrayGL {
int enabledCnt = -1;
IBufferGL indexBuffer = null;
SoftGLBufferArray() {
SoftGLVertexArray() {
}
void setAttrib(IBufferGL buffer, int index, int size, int format, boolean normalized, int stride, int offset) {
@ -87,7 +87,7 @@ class SoftGLBufferArray implements IBufferArrayGL {
indexBuffer = buffer;
}
void transitionToState(SoftGLBufferState previousState, boolean elements) {
void transitionToState(SoftGLVertexState previousState, boolean elements) {
int oldEnabled = previousState.oldEnabled;
int oldEnabledCnt = previousState.oldEnabledCnt;
int[] oldAttribDivisors = previousState.attribDivisors;

View File

@ -16,9 +16,9 @@
package net.lax1dude.eaglercraft.v1_8.opengl;
import net.lax1dude.eaglercraft.v1_8.opengl.SoftGLBufferArray.Attrib;
import net.lax1dude.eaglercraft.v1_8.opengl.SoftGLVertexArray.Attrib;
class SoftGLBufferState {
class SoftGLVertexState {
final Attrib[] attribs = new Attrib[24];
int[] attribDivisors = new int[24];
@ -26,7 +26,7 @@ class SoftGLBufferState {
int oldEnabled = 0;
int oldEnabledCnt = -1;
SoftGLBufferState() {
SoftGLVertexState() {
}
}

View File

@ -16,7 +16,7 @@
package net.lax1dude.eaglercraft.v1_8.opengl;
import net.lax1dude.eaglercraft.v1_8.internal.IBufferArrayGL;
import net.lax1dude.eaglercraft.v1_8.internal.IVertexArrayGL;
import net.lax1dude.eaglercraft.v1_8.internal.IBufferGL;
import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.*;
@ -76,12 +76,12 @@ public class StreamBuffer {
public static class StreamBufferInstance {
protected PoolInstance poolInstance = null;
protected IBufferArrayGL vertexArray = null;
protected IVertexArrayGL vertexArray = null;
public boolean bindQuad16 = false;
public boolean bindQuad32 = false;
public IBufferArrayGL getVertexArray() {
public IVertexArrayGL getVertexArray() {
return vertexArray;
}
@ -92,7 +92,7 @@ public class StreamBuffer {
}
public static interface IStreamBufferInitializer {
void initialize(IBufferArrayGL vertexArray, IBufferGL vertexBuffer);
void initialize(IVertexArrayGL vertexArray, IBufferGL vertexBuffer);
}
public StreamBuffer(int initialSize, int initialCount, int maxCount, IStreamBufferInitializer initializer) {
@ -115,7 +115,7 @@ public class StreamBuffer {
StreamBufferInstance next = buffers[(currentBufferId++) % buffers.length];
resizeInstance(next.poolInstance, requiredMemory);
if(next.vertexArray == null) {
next.vertexArray = EaglercraftGPU.createGLBufferArray();
next.vertexArray = EaglercraftGPU.createGLVertexArray();
initializer.initialize(next.vertexArray, next.poolInstance.vertexBuffer);
}
return next;
@ -135,7 +135,7 @@ public class StreamBuffer {
newArray[i] = buffers[i];
}else {
if(buffers[i].vertexArray != null) {
EaglercraftGPU.destroyGLBufferArray(buffers[i].vertexArray);
EaglercraftGPU.destroyGLVertexArray(buffers[i].vertexArray);
}
}
}
@ -186,7 +186,7 @@ public class StreamBuffer {
for(int i = 0; i < buffers.length; ++i) {
StreamBufferInstance next = buffers[i];
if(next.vertexArray != null) {
EaglercraftGPU.destroyGLBufferArray(next.vertexArray);
EaglercraftGPU.destroyGLVertexArray(next.vertexArray);
}
}
buffers = new StreamBufferInstance[initialCount];

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 lax1dude. All Rights Reserved.
* Copyright (c) 2022-2025 lax1dude. All Rights Reserved.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@ -19,6 +19,7 @@ package net.lax1dude.eaglercraft.v1_8.opengl;
import net.lax1dude.eaglercraft.v1_8.internal.buffer.ByteBuffer;
public class WorldVertexBufferUploader {
public static void func_181679_a(WorldRenderer parWorldRenderer) {
int cunt = parWorldRenderer.getVertexCount();
if (cunt > 0) {
@ -30,4 +31,18 @@ public class WorldVertexBufferUploader {
parWorldRenderer.reset();
}
}
public static void uploadDisplayList(int displayList, WorldRenderer worldRenderer) {
int cunt = worldRenderer.getVertexCount();
if (cunt > 0) {
VertexFormat fmt = worldRenderer.getVertexFormat();
ByteBuffer buf = worldRenderer.getByteBuffer();
buf.position(0).limit(cunt * fmt.attribStride);
EaglercraftGPU.uploadListDirect(displayList, buf, fmt.eaglercraftAttribBits, worldRenderer.getDrawMode(), cunt);
worldRenderer.reset();
}else {
EaglercraftGPU.flushDisplayList(displayList);
}
}
}

View File

@ -83,7 +83,7 @@ public class DebugFramebufferView {
(new DebugFramebufferView("Sun Shadow Depth: LOD 1", (pipeline) -> {
if(pipeline.config.is_rendering_shadowsSun_clamped < 1) throw new NoDataException();
PipelineShaderGBufferDebugView dbv = pipeline.useDebugViewShader(5);
_wglUniform2f(dbv.uniforms.u_depthSliceStartEnd2f, 1.0f / pipeline.config.is_rendering_shadowsSun_clamped, 0.0f);
_wglUniform2f(dbv.uniforms.u_depthSliceStartEnd2f, 1.0f / Math.min(pipeline.config.is_rendering_shadowsSun_clamped, 3), 0.0f);
GlStateManager.setActiveTexture(GL_TEXTURE0);
GlStateManager.bindTexture(pipeline.sunShadowDepthBuffer);
_wglTexParameteri(GL_TEXTURE_2D, _GL_TEXTURE_COMPARE_MODE, GL_NONE);
@ -93,7 +93,7 @@ public class DebugFramebufferView {
(new DebugFramebufferView("Sun Shadow Color: LOD 1", (pipeline) -> {
if(pipeline.config.is_rendering_shadowsSun_clamped < 1 || !pipeline.config.is_rendering_shadowsColored) throw new NoDataException();
PipelineShaderGBufferDebugView dbv = pipeline.useDebugViewShader(10);
_wglUniform2f(dbv.uniforms.u_depthSliceStartEnd2f, 1.0f / pipeline.config.is_rendering_shadowsSun_clamped, 0.0f);
_wglUniform2f(dbv.uniforms.u_depthSliceStartEnd2f, 1.0f / Math.min(pipeline.config.is_rendering_shadowsSun_clamped, 3), 0.0f);
GlStateManager.setActiveTexture(GL_TEXTURE1);
GlStateManager.bindTexture(pipeline.sunShadowColorBuffer);
GlStateManager.setActiveTexture(GL_TEXTURE0);
@ -105,7 +105,7 @@ public class DebugFramebufferView {
(new DebugFramebufferView("Sun Shadow Depth: LOD 2", (pipeline) -> {
if(pipeline.config.is_rendering_shadowsSun_clamped < 2) throw new NoDataException();
PipelineShaderGBufferDebugView dbv = pipeline.useDebugViewShader(5);
_wglUniform2f(dbv.uniforms.u_depthSliceStartEnd2f, 1.0f / pipeline.config.is_rendering_shadowsSun_clamped, 1.0f);
_wglUniform2f(dbv.uniforms.u_depthSliceStartEnd2f, 1.0f / Math.min(pipeline.config.is_rendering_shadowsSun_clamped, 3), 1.0f);
GlStateManager.setActiveTexture(GL_TEXTURE0);
GlStateManager.bindTexture(pipeline.sunShadowDepthBuffer);
_wglTexParameteri(GL_TEXTURE_2D, _GL_TEXTURE_COMPARE_MODE, GL_NONE);
@ -115,7 +115,7 @@ public class DebugFramebufferView {
(new DebugFramebufferView("Sun Shadow Color: LOD 2", (pipeline) -> {
if(pipeline.config.is_rendering_shadowsSun_clamped < 2 || !pipeline.config.is_rendering_shadowsColored) throw new NoDataException();
PipelineShaderGBufferDebugView dbv = pipeline.useDebugViewShader(10);
_wglUniform2f(dbv.uniforms.u_depthSliceStartEnd2f, 1.0f / pipeline.config.is_rendering_shadowsSun_clamped, 1.0f);
_wglUniform2f(dbv.uniforms.u_depthSliceStartEnd2f, 1.0f / Math.min(pipeline.config.is_rendering_shadowsSun_clamped, 3), 1.0f);
GlStateManager.setActiveTexture(GL_TEXTURE1);
GlStateManager.bindTexture(pipeline.sunShadowColorBuffer);
GlStateManager.setActiveTexture(GL_TEXTURE0);
@ -127,7 +127,7 @@ public class DebugFramebufferView {
(new DebugFramebufferView("Sun Shadow Depth: LOD 3", (pipeline) -> {
if(pipeline.config.is_rendering_shadowsSun_clamped < 3) throw new NoDataException();
PipelineShaderGBufferDebugView dbv = pipeline.useDebugViewShader(5);
_wglUniform2f(dbv.uniforms.u_depthSliceStartEnd2f, 1.0f / pipeline.config.is_rendering_shadowsSun_clamped, 2.0f);
_wglUniform2f(dbv.uniforms.u_depthSliceStartEnd2f, 1.0f / Math.min(pipeline.config.is_rendering_shadowsSun_clamped, 3), 2.0f);
GlStateManager.setActiveTexture(GL_TEXTURE0);
GlStateManager.bindTexture(pipeline.sunShadowDepthBuffer);
_wglTexParameteri(GL_TEXTURE_2D, _GL_TEXTURE_COMPARE_MODE, GL_NONE);
@ -145,6 +145,13 @@ public class DebugFramebufferView {
GlStateManager.bindTexture(pipeline.sunLightingShadowTexture);
DrawUtils.drawStandardQuad2D();
})),
(new DebugFramebufferView("GBuffer Subsurface Scattering", (pipeline) -> {
if(!pipeline.config.is_rendering_subsurfaceScattering || Minecraft.getMinecraft().theWorld.provider.getDimensionId() != 0) throw new NoDataException();
pipeline.useDebugViewShader(6);
GlStateManager.setActiveTexture(GL_TEXTURE0);
GlStateManager.bindTexture(pipeline.subsurfaceScatteringTexture);
DrawUtils.drawStandardQuad2D();
})),
(new DebugFramebufferView("Light Shafts Buffer", (pipeline) -> {
if(!pipeline.config.is_rendering_lightShafts) throw new NoDataException();
pipeline.useDebugViewShader(6);

View File

@ -46,6 +46,7 @@ public class DeferredStateManager {
static float materialConstantsRoughness = 0.5f;
static float materialConstantsMetalness = 0.02f;
static float materialConstantsEmission = 0.0f;
static float materialConstantsSubsurfScatting = 0.0f;
static boolean materialConstantsUseEnvMap = false;
static int wavingBlockOffsetSerial = 0;
@ -103,46 +104,47 @@ public class DeferredStateManager {
public static boolean doCheckErrors = false;
public static final boolean isDeferredRenderer() {
public static boolean isDeferredRenderer() {
return EaglerDeferredPipeline.instance != null;
}
public static final boolean isInDeferredPass() {
public static boolean isInDeferredPass() {
return EaglerDeferredPipeline.instance != null && GlStateManager.isExtensionPipeline();
}
public static final boolean isInForwardPass() {
public static boolean isInForwardPass() {
return enableForwardRender && !enableShadowRender;
}
public static final boolean isInParaboloidPass() {
public static boolean isInParaboloidPass() {
return enableParaboloidRender;
}
public static final boolean isRenderingRealisticWater() {
public static boolean isRenderingRealisticWater() {
return EaglerDeferredPipeline.instance != null && EaglerDeferredPipeline.instance.config.is_rendering_realisticWater;
}
public static final boolean isRenderingGlassHighlights() {
public static boolean isRenderingGlassHighlights() {
return EaglerDeferredPipeline.instance != null && EaglerDeferredPipeline.instance.config.is_rendering_useEnvMap;
}
public static final void setDefaultMaterialConstants() {
public static void setDefaultMaterialConstants() {
materialConstantsRoughness = 0.5f;
materialConstantsMetalness = 0.02f;
materialConstantsEmission = 0.0f;
materialConstantsSubsurfScatting = 0.0f;
++materialConstantsSerial;
}
public static final void startUsingEnvMap() {
public static void startUsingEnvMap() {
materialConstantsUseEnvMap = true;
}
public static final void endUsingEnvMap() {
public static void endUsingEnvMap() {
materialConstantsUseEnvMap = false;
}
public static final void reportForwardRenderObjectPosition(int centerX, int centerY, int centerZ) {
public static void reportForwardRenderObjectPosition(int centerX, int centerY, int centerZ) {
EaglerDeferredPipeline instance = EaglerDeferredPipeline.instance;
if(instance != null && enableForwardRender) {
EaglerDeferredConfig cfg = instance.config;
@ -153,7 +155,7 @@ public class DeferredStateManager {
}
}
public static final void reportForwardRenderObjectPosition2(float x, float y, float z) {
public static void reportForwardRenderObjectPosition2(float x, float y, float z) {
EaglerDeferredPipeline instance = EaglerDeferredPipeline.instance;
if(instance != null && enableForwardRender) {
EaglerDeferredConfig cfg = instance.config;
@ -167,114 +169,114 @@ public class DeferredStateManager {
}
}
public static final void setHDRTranslucentPassBlendFunc() {
public static void setHDRTranslucentPassBlendFunc() {
GlStateManager.tryBlendFuncSeparate(GL_ONE, GL_ONE_MINUS_SRC_ALPHA, GL_ZERO, GL_ZERO);
}
public static final void enableMaterialTexture() {
public static void enableMaterialTexture() {
enableMaterialMapTexture = true;
}
public static final void disableMaterialTexture() {
public static void disableMaterialTexture() {
enableMaterialMapTexture = false;
}
public static final void enableForwardRender() {
public static void enableForwardRender() {
enableForwardRender = true;
}
public static final void disableForwardRender() {
public static void disableForwardRender() {
enableForwardRender = false;
}
public static final void enableParaboloidRender() {
public static void enableParaboloidRender() {
enableParaboloidRender = true;
}
public static final void disableParaboloidRender() {
public static void disableParaboloidRender() {
enableParaboloidRender = false;
}
public static final void enableShadowRender() {
public static void enableShadowRender() {
enableShadowRender = true;
}
public static final void disableShadowRender() {
public static void disableShadowRender() {
enableShadowRender = false;
}
public static final boolean isEnableShadowRender() {
public static boolean isEnableShadowRender() {
return enableShadowRender;
}
public static final void enableClipPlane() {
public static void enableClipPlane() {
enableClipPlane = true;
}
public static final void disableClipPlane() {
public static void disableClipPlane() {
enableClipPlane = false;
}
public static final void setClipPlaneY(float yValue) {
public static void setClipPlaneY(float yValue) {
clipPlaneY = yValue;
}
public static final void enableDrawWavingBlocks() {
public static void enableDrawWavingBlocks() {
enableDrawWavingBlocks = true;
}
public static final void disableDrawWavingBlocks() {
public static void disableDrawWavingBlocks() {
enableDrawWavingBlocks = false;
}
public static final boolean isEnableDrawWavingBlocks() {
public static boolean isEnableDrawWavingBlocks() {
return enableDrawWavingBlocks;
}
public static final void enableDrawRealisticWaterMask() {
public static void enableDrawRealisticWaterMask() {
enableDrawRealisticWaterMask = true;
}
public static final void disableDrawRealisticWaterMask() {
public static void disableDrawRealisticWaterMask() {
enableDrawRealisticWaterMask = false;
}
public static final boolean isDrawRealisticWaterMask() {
public static boolean isDrawRealisticWaterMask() {
return enableDrawRealisticWaterMask;
}
public static final void enableDrawRealisticWaterRender() {
public static void enableDrawRealisticWaterRender() {
enableDrawRealisticWaterRender = true;
}
public static final void disableDrawRealisticWaterRender() {
public static void disableDrawRealisticWaterRender() {
enableDrawRealisticWaterRender = false;
}
public static final boolean isDrawRealisticWaterRender() {
public static boolean isDrawRealisticWaterRender() {
return enableDrawRealisticWaterRender;
}
public static final void enableDrawGlassHighlightsRender() {
public static void enableDrawGlassHighlightsRender() {
enableDrawGlassHighlightsRender = true;
}
public static final void disableDrawGlassHighlightsRender() {
public static void disableDrawGlassHighlightsRender() {
enableDrawGlassHighlightsRender = false;
}
public static final boolean isDrawGlassHighlightsRender() {
public static boolean isDrawGlassHighlightsRender() {
return enableDrawGlassHighlightsRender;
}
public static final void setWavingBlockOffset(float x, float y, float z) {
public static void setWavingBlockOffset(float x, float y, float z) {
wavingBlockOffsetX = x;
wavingBlockOffsetY = y;
wavingBlockOffsetZ = z;
++wavingBlockOffsetSerial;
}
public static final void setWavingBlockParams(float x, float y, float z, float w) {
public static void setWavingBlockParams(float x, float y, float z, float w) {
wavingBlockParamX = x;
wavingBlockParamY = y;
wavingBlockParamZ = z;
@ -282,34 +284,39 @@ public class DeferredStateManager {
++wavingBlockParamSerial;
}
public static final void setRoughnessConstant(float roughness) {
public static void setRoughnessConstant(float roughness) {
materialConstantsRoughness = roughness;
++materialConstantsSerial;
}
public static final void setMetalnessConstant(float metalness) {
public static void setMetalnessConstant(float metalness) {
materialConstantsMetalness = metalness;
++materialConstantsSerial;
}
public static final void setEmissionConstant(float emission) {
public static void setEmissionConstant(float emission) {
materialConstantsEmission = emission;
++materialConstantsSerial;
}
public static final void setBlockConstant(int blockId) {
public static void setSubsurfScatteringConstant(float sss) {
materialConstantsSubsurfScatting = sss;
++materialConstantsSerial;
}
public static void setBlockConstant(int blockId) {
constantBlock = blockId;
}
public static final AxisAlignedBB getShadowMapBounds() {
public static AxisAlignedBB getShadowMapBounds() {
return shadowMapBounds;
}
public static final void setShadowMapBounds(AxisAlignedBB newShadowMapBounds) {
public static void setShadowMapBounds(AxisAlignedBB newShadowMapBounds) {
shadowMapBounds = newShadowMapBounds;
}
public static final void loadGBufferViewMatrix() {
public static void loadGBufferViewMatrix() {
loadPassViewMatrix();
viewMatrix.load(passViewMatrix);
inverseViewMatrix.load(passInverseViewMatrix);
@ -323,7 +330,7 @@ public class DeferredStateManager {
projMatrixSerial = passProjMatrixSerial;
}
public static final void loadPassViewMatrix() {
public static void loadPassViewMatrix() {
GlStateManager.getFloat(GL_MODELVIEW_MATRIX, matrixCopyBuffer);
passViewMatrix.load(matrixCopyBuffer);
Matrix4f.invert(passViewMatrix, passInverseViewMatrix);
@ -338,7 +345,7 @@ public class DeferredStateManager {
++passProjMatrixSerial;
}
public static final void loadShadowPassViewMatrix() {
public static void loadShadowPassViewMatrix() {
GlStateManager.getFloat(GL_PROJECTION_MATRIX, matrixCopyBuffer);
passViewMatrix.load(matrixCopyBuffer);
Matrix4f.invert(passViewMatrix, passInverseViewMatrix);
@ -347,7 +354,7 @@ public class DeferredStateManager {
isShadowPassMatrixLoaded = true;
}
public static final void setPassMatrixToGBuffer() {
public static void setPassMatrixToGBuffer() {
passViewMatrix.load(viewMatrix);
passInverseViewMatrix.load(inverseViewMatrix);
passProjMatrix.load(projMatrix);
@ -378,39 +385,39 @@ public class DeferredStateManager {
}
}
public static final void loadSunShadowMatrixLOD0() {
public static void loadSunShadowMatrixLOD0() {
GlStateManager.getFloat(GL_PROJECTION_MATRIX, matrixCopyBuffer);
sunShadowMatrix0.load(matrixCopyBuffer);
}
public static final void loadSunShadowMatrixLOD1() {
public static void loadSunShadowMatrixLOD1() {
GlStateManager.getFloat(GL_PROJECTION_MATRIX, matrixCopyBuffer);
sunShadowMatrix1.load(matrixCopyBuffer);
}
public static final void loadSunShadowMatrixLOD2() {
public static void loadSunShadowMatrixLOD2() {
GlStateManager.getFloat(GL_PROJECTION_MATRIX, matrixCopyBuffer);
sunShadowMatrix2.load(matrixCopyBuffer);
}
public static final Matrix4f getSunShadowMatrixLOD0() {
public static Matrix4f getSunShadowMatrixLOD0() {
return sunShadowMatrix0;
}
public static final Matrix4f getSunShadowMatrixLOD1() {
public static Matrix4f getSunShadowMatrixLOD1() {
return sunShadowMatrix1;
}
public static final Matrix4f getSunShadowMatrixLOD2() {
public static Matrix4f getSunShadowMatrixLOD2() {
return sunShadowMatrix2;
}
public static final void setGBufferNearFarPlanes(float zNear, float zFar) {
public static void setGBufferNearFarPlanes(float zNear, float zFar) {
gbufferNearPlane = zNear;
gbufferFarPlane = zFar;
}
public static final void setWaterWindOffset(float sx, float sy, float fx, float fy) {
public static void setWaterWindOffset(float sx, float sy, float fx, float fy) {
++waterWindOffsetSerial;
u_waterWindOffset4f.x = sx;
u_waterWindOffset4f.y = sy;
@ -435,7 +442,7 @@ public class DeferredStateManager {
static float fogColorDarkB = 1.0f;
static float fogColorDarkA = 1.0f;
public static final void enableFogLinear(float near, float far, boolean atmosphere, float colorLightR,
public static void enableFogLinear(float near, float far, boolean atmosphere, float colorLightR,
float colorLightG, float colorLightB, float colorLightA, float colorDarkR, float colorDarkG,
float colorDarkB, float colorDarkA) {
fogLinearExp = atmosphere ? 5 : 1;
@ -451,7 +458,7 @@ public class DeferredStateManager {
fogColorDarkA = colorDarkA;
}
public static final void enableFogExp(float density, boolean atmosphere, float colorLightR, float colorLightG,
public static void enableFogExp(float density, boolean atmosphere, float colorLightR, float colorLightG,
float colorLightB, float colorLightA, float colorDarkR, float colorDarkG, float colorDarkB,
float colorDarkA) {
fogLinearExp = atmosphere ? 6 : 2;
@ -466,11 +473,11 @@ public class DeferredStateManager {
fogColorDarkA = colorDarkA;
}
public static final void disableFog() {
public static void disableFog() {
fogLinearExp = 0;
}
public static final void disableAll() {
public static void disableAll() {
enableMaterialMapTexture = false;
materialConstantsUseEnvMap = false;
enableForwardRender = false;

View File

@ -49,6 +49,7 @@ public class EaglerDeferredConfig {
public boolean lensFlares = true;
public boolean bloom = false;
public boolean fxaa = true;
public boolean subsurfaceScattering = true;
public boolean is_rendering_wavingBlocks = true;
public boolean is_rendering_dynamicLights = true;
@ -65,6 +66,7 @@ public class EaglerDeferredConfig {
public boolean is_rendering_lensFlares = true;
public boolean is_rendering_bloom = false;
public boolean is_rendering_fxaa = true;
public boolean is_rendering_subsurfaceScattering = true;
public void readOption(String key, String value) {
switch(key) {
@ -110,6 +112,9 @@ public class EaglerDeferredConfig {
case "shaders_deferred_fxaa":
fxaa = value.equals("true");
break;
case "shaders_deferred_subsurfaceScattering":
subsurfaceScattering = value.equals("true");
break;
default:
break;
}
@ -130,6 +135,7 @@ public class EaglerDeferredConfig {
output.println("shaders_deferred_lensFlares:" + lensFlares);
output.println("shaders_deferred_bloom:" + bloom);
output.println("shaders_deferred_fxaa:" + fxaa);
output.println("shaders_deferred_subsurfaceScattering:" + subsurfaceScattering);
}
public void reloadShaderPackInfo(IResourceManager mgr) throws IOException {
@ -159,6 +165,7 @@ public class EaglerDeferredConfig {
is_rendering_lensFlares = lensFlares && shaderPackInfo.POST_LENS_FLARES;
is_rendering_bloom = bloom && shaderPackInfo.POST_BLOOM;
is_rendering_fxaa = fxaa && shaderPackInfo.POST_FXAA;
is_rendering_subsurfaceScattering = subsurfaceScattering && is_rendering_shadowsSun_clamped > 0 && shaderPackInfo.SUBSURFACE_SCATTERING;
}
}

View File

@ -59,6 +59,7 @@ import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.program.PipelineShaderS
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.program.PipelineShaderSkyboxIrradiance;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.program.PipelineShaderSkyboxRender;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.program.PipelineShaderSkyboxRenderEnd;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.program.PipelineShaderSubsurfaceScattering;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.program.PipelineShaderTonemap;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.program.ShaderMissingException;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.texture.MetalsLUT;
@ -150,6 +151,9 @@ public class EaglerDeferredPipeline {
public IFramebufferGL sunLightingShadowFramebuffer = null;
public int sunLightingShadowTexture = -1;
public IFramebufferGL subsurfaceScatteringFramebuffer = null;
public int subsurfaceScatteringTexture = -1;
public IFramebufferGL ssaoGenerateFramebuffer = null;
public int ssaoGenerateTexture = -1;
@ -157,6 +161,9 @@ public class EaglerDeferredPipeline {
public int ssaoNoiseTexture = -1;
public IFramebufferGL skyFramebuffer = null;
public int skyTexture = -1;
public IFramebufferGL lightingHDRFramebuffer = null;
public int lightingHDRFramebufferColorTexture = -1;
public int lightingHDRFramebufferDepthTexture = -1;
@ -297,6 +304,7 @@ public class EaglerDeferredPipeline {
public PipelineShaderRealisticWaterNormalsMix shader_realistic_water_normals_mix = null;
public PipelineShaderHandDepthMask shader_hand_depth_mask = null;
public PipelineShaderFXAA shader_post_fxaa = null;
public PipelineShaderSubsurfaceScattering shader_subsurface_scattering = null;
public SkyboxRenderer skybox = null;
public LightSourceMesh pointLightMesh = null;
public final GBufferAcceleratedEffectRenderer gbufferEffectRenderer = new GBufferAcceleratedEffectRenderer();
@ -456,6 +464,16 @@ public class EaglerDeferredPipeline {
GlStateManager.bindTexture(sunLightingShadowTexture);
setNearest();
_wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, EaglercraftGPU.getNativeTexture(sunLightingShadowTexture), 0);
if(config.is_rendering_subsurfaceScattering) {
shader_subsurface_scattering = PipelineShaderSubsurfaceScattering.compile(lods, sunShadowDepthBufferRes, sunShadowDepthBufferRes * lods);
shader_subsurface_scattering.loadUniforms();
subsurfaceScatteringFramebuffer = _wglCreateFramebuffer();
_wglBindFramebuffer(_GL_FRAMEBUFFER, subsurfaceScatteringFramebuffer);
subsurfaceScatteringTexture = GlStateManager.generateTexture();
GlStateManager.bindTexture(subsurfaceScatteringTexture);
setNearest();
_wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, EaglercraftGPU.getNativeTexture(subsurfaceScatteringTexture), 0);
}
if(config.is_rendering_shadowsColored) {
sunShadowColorFramebuffer = _wglCreateFramebuffer();
_wglBindFramebuffer(_GL_FRAMEBUFFER, sunShadowColorFramebuffer);
@ -594,6 +612,13 @@ public class EaglerDeferredPipeline {
setNearest();
_wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, EaglercraftGPU.getNativeTexture(lightingHDRFramebufferDepthTexture), 0);
skyFramebuffer = _wglCreateFramebuffer();
_wglBindFramebuffer(_GL_FRAMEBUFFER, skyFramebuffer);
skyTexture = GlStateManager.generateTexture();
GlStateManager.bindTexture(skyTexture);
setLinear();
_wglFramebufferTexture2D(_GL_FRAMEBUFFER, _GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, EaglercraftGPU.getNativeTexture(skyTexture), 0);
handRenderFramebuffer = _wglCreateFramebuffer();
_wglBindFramebuffer(_GL_FRAMEBUFFER, handRenderFramebuffer);
GlStateManager.bindTexture(lightingHDRFramebufferColorTexture);
@ -641,7 +666,7 @@ public class EaglerDeferredPipeline {
DeferredStateManager.checkGLError("Post: rebuild pipeline: dither8x8Texture");
shader_lighting_sun = PipelineShaderLightingSun.compile(shadowsSun ? config.is_rendering_shadowsSun_clamped : 0,
config.is_rendering_shadowsColored);
config.is_rendering_shadowsColored, config.is_rendering_subsurfaceScattering);
shader_lighting_sun.loadUniforms();
if(shadowsSun) {
shader_shadows_sun = PipelineShaderShadowsSun.compile(config.is_rendering_shadowsSun_clamped,
@ -1233,12 +1258,21 @@ public class EaglerDeferredPipeline {
DeferredStateManager.checkGLError("Post: resize pipeline: lightShafts");
}
if(config.is_rendering_subsurfaceScattering) {
GlStateManager.bindTexture(subsurfaceScatteringTexture);
_wglTexImage2D(GL_TEXTURE_2D, 0, _GL_R8, reprojectionTexWidth, reprojectionTexHeight, 0, GL_RED, GL_UNSIGNED_BYTE, (ByteBuffer)null);
DeferredStateManager.checkGLError("Post: resize pipeline: subsurfaceScattering");
}
GlStateManager.bindTexture(lightingHDRFramebufferColorTexture);
EaglercraftGPU.createFramebufferHDR16FTexture(GL_TEXTURE_2D, 0, w, h, GL_RGBA, true); // USE RGBA! WebGL won't render to RGB16F
GlStateManager.bindTexture(lightingHDRFramebufferDepthTexture);
_wglTexImage2D(GL_TEXTURE_2D, 0, _GL_DEPTH_COMPONENT32F, w, h, 0, _GL_DEPTH_COMPONENT, GL_FLOAT, (ByteBuffer)null);
GlStateManager.bindTexture(skyTexture);
EaglercraftGPU.createFramebufferHDR16FTexture(GL_TEXTURE_2D, 0, reprojectionTexWidth, reprojectionTexHeight, GL_RGBA, true);
GlStateManager.bindTexture(handRenderFramebufferDepthTexture);
_wglTexImage2D(GL_TEXTURE_2D, 0, _GL_DEPTH_COMPONENT32F, w, h, 0, _GL_DEPTH_COMPONENT, GL_FLOAT, (ByteBuffer)null);
@ -1367,8 +1401,8 @@ public class EaglerDeferredPipeline {
resize(mc.displayWidth, mc.displayHeight);
_wglBindFramebuffer(_GL_FRAMEBUFFER, gBufferFramebuffer);
_wglDrawBuffers(gBufferDrawBuffers);
_wglClearColor(0.0f, 0.0f, 0.0f, 0.0f);
_wglClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
GlStateManager.clearColor(0.0f, 0.0f, 0.0f, 0.0f);
GlStateManager.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f);
GlStateManager.viewport(0, 0, currentWidth, currentHeight);
GlStateManager.colorMask(true, true, true, true);
@ -1422,7 +1456,7 @@ public class EaglerDeferredPipeline {
GlStateManager.clear(GL_DEPTH_BUFFER_BIT);
}
GlStateManager.enableCull();
GlStateManager.cullFace(GL_FRONT);
//GlStateManager.cullFace(GL_FRONT);
DeferredStateManager.enableShadowRender();
GlStateManager.colorMask(false, false, false, false);
DeferredStateManager.checkGLError("Post: beginDrawMainShadowMap()");
@ -1431,7 +1465,7 @@ public class EaglerDeferredPipeline {
public void endDrawMainShadowMap() {
DeferredStateManager.checkGLError("Pre: endDrawMainShadowMap()");
GlStateManager.viewport(0, 0, currentWidth, currentHeight);
GlStateManager.cullFace(GL_BACK);
//GlStateManager.cullFace(GL_BACK);
DeferredStateManager.disableShadowRender();
GlStateManager.colorMask(true, true, true, true);
DeferredStateManager.checkGLError("Post: endDrawMainShadowMap()");
@ -1653,7 +1687,7 @@ public class EaglerDeferredPipeline {
// =============== NETHER SKY REFLECTION MAP ================ //
_wglBindFramebuffer(_GL_FRAMEBUFFER, envMapSkyFramebuffer);
GlStateManager.clearColor(0.55f, 0.25f, 0.05f, 1.0f);
GlStateManager.clearColor(0.055f, 0.025f, 0.005f, 1.0f);
GlStateManager.clear(GL_COLOR_BUFFER_BIT);
DeferredStateManager.checkGLError("combineGBuffersAndIlluminate(): NETHER SKY REFLECTION MAP");
@ -1908,6 +1942,17 @@ public class EaglerDeferredPipeline {
uniformMatrixHelper(shader_shadows_sun.uniforms.u_inverseViewMatrix4f, DeferredStateManager.inverseViewMatrix);
uniformMatrixHelper(shader_shadows_sun.uniforms.u_inverseViewProjMatrix4f, tmpMatrixInverseViewProj);
Matrix4f.mul(tmpClipToTexSpaceMatLeft, DeferredStateManager.sunShadowMatrix0, tmpShadowLOD0MatrixTexSpace);
uniformMatrixHelper(shader_shadows_sun.uniforms.u_sunShadowMatrixLOD04f, tmpShadowLOD0MatrixTexSpace);
if(config.is_rendering_shadowsSun_clamped > 1) {
Matrix4f.mul(tmpClipToTexSpaceMatLeft, DeferredStateManager.sunShadowMatrix1, tmpShadowLOD1MatrixTexSpace);
uniformMatrixHelper(shader_shadows_sun.uniforms.u_sunShadowMatrixLOD14f, tmpShadowLOD1MatrixTexSpace);
if(config.is_rendering_shadowsSun_clamped > 2) {
Matrix4f.mul(tmpClipToTexSpaceMatLeft, DeferredStateManager.sunShadowMatrix2, tmpShadowLOD2MatrixTexSpace);
uniformMatrixHelper(shader_shadows_sun.uniforms.u_sunShadowMatrixLOD24f, tmpShadowLOD2MatrixTexSpace);
}
}
if(config.is_rendering_shadowsColored) {
GlStateManager.setActiveTexture(GL_TEXTURE3);
GlStateManager.bindTexture(sunShadowColorBuffer);
@ -1921,16 +1966,6 @@ public class EaglerDeferredPipeline {
GlStateManager.bindTexture(gBufferDepthTexture);
GlStateManager.setActiveTexture(GL_TEXTURE0);
GlStateManager.bindTexture(gBufferNormalsTexture);
Matrix4f.mul(tmpClipToTexSpaceMatLeft, DeferredStateManager.sunShadowMatrix0, tmpShadowLOD0MatrixTexSpace);
uniformMatrixHelper(shader_shadows_sun.uniforms.u_sunShadowMatrixLOD04f, tmpShadowLOD0MatrixTexSpace);
if(config.is_rendering_shadowsSun_clamped > 1) {
Matrix4f.mul(tmpClipToTexSpaceMatLeft, DeferredStateManager.sunShadowMatrix1, tmpShadowLOD1MatrixTexSpace);
uniformMatrixHelper(shader_shadows_sun.uniforms.u_sunShadowMatrixLOD14f, tmpShadowLOD1MatrixTexSpace);
if(config.is_rendering_shadowsSun_clamped > 2) {
Matrix4f.mul(tmpClipToTexSpaceMatLeft, DeferredStateManager.sunShadowMatrix2, tmpShadowLOD2MatrixTexSpace);
uniformMatrixHelper(shader_shadows_sun.uniforms.u_sunShadowMatrixLOD24f, tmpShadowLOD2MatrixTexSpace);
}
}
Vector3f currentSunShadowAngle = DeferredStateManager.currentSunLightAngle;
_wglUniform3f(shader_shadows_sun.uniforms.u_sunDirection3f, -currentSunShadowAngle.x, -currentSunShadowAngle.y, -currentSunShadowAngle.z);
@ -1943,28 +1978,175 @@ public class EaglerDeferredPipeline {
}
DeferredStateManager.checkGLError("combineGBuffersAndIlluminate(): RENDER SUNLIGHT SHADOWS");
if(config.is_rendering_subsurfaceScattering && dim == 0) {
// ==================== RENDER SUBSURFACE SCATTERING ===================== //
_wglBindFramebuffer(_GL_FRAMEBUFFER, subsurfaceScatteringFramebuffer);
GlStateManager.viewport(0, 0, reprojectionTexWidth, reprojectionTexHeight);
shader_subsurface_scattering.useProgram();
uniformMatrixHelper(shader_subsurface_scattering.uniforms.u_inverseViewMatrix4f, DeferredStateManager.inverseViewMatrix);
uniformMatrixHelper(shader_subsurface_scattering.uniforms.u_inverseViewProjMatrix4f, tmpMatrixInverseViewProj);
uniformMatrixHelper(shader_subsurface_scattering.uniforms.u_sunShadowMatrixLOD04f, tmpShadowLOD0MatrixTexSpace);
if(config.is_rendering_shadowsSun_clamped > 1) {
uniformMatrixHelper(shader_subsurface_scattering.uniforms.u_sunShadowMatrixLOD14f, tmpShadowLOD1MatrixTexSpace);
if(config.is_rendering_shadowsSun_clamped > 2) {
uniformMatrixHelper(shader_subsurface_scattering.uniforms.u_sunShadowMatrixLOD24f, tmpShadowLOD2MatrixTexSpace);
}
}
_wglUniform3f(shader_subsurface_scattering.uniforms.u_sunDirection3f, -currentSunShadowAngle.x, -currentSunShadowAngle.y, -currentSunShadowAngle.z);
GlStateManager.setActiveTexture(GL_TEXTURE3);
GlStateManager.bindTexture(sunShadowDepthBuffer);
_wglTexParameteri(GL_TEXTURE_2D, _GL_TEXTURE_COMPARE_MODE, GL_NONE);
GlStateManager.setActiveTexture(GL_TEXTURE2);
GlStateManager.bindTexture(gBufferMaterialTexture);
GlStateManager.setActiveTexture(GL_TEXTURE1);
GlStateManager.bindTexture(gBufferDepthTexture);
GlStateManager.setActiveTexture(GL_TEXTURE0);
GlStateManager.bindTexture(gBufferNormalsTexture);
DrawUtils.drawStandardQuad2D();
GlStateManager.setActiveTexture(GL_TEXTURE3);
_wglTexParameteri(GL_TEXTURE_2D, _GL_TEXTURE_COMPARE_MODE, _GL_COMPARE_REF_TO_TEXTURE);
DeferredStateManager.checkGLError("combineGBuffersAndIlluminate(): RENDER SUBSURFACE SCATTERING");
}
}
// ================ INITIALIZE HDR FRAMEBUFFER ================== //
// =================== RENDER SKYBOX MESH =================== //
_wglBindFramebuffer(_GL_FRAMEBUFFER, skyFramebuffer);
GlStateManager.viewport(0, 0, reprojectionTexWidth, reprojectionTexHeight);
if(dim == 0) {
GlStateManager.disableDepth();
GlStateManager.setActiveTexture(GL_TEXTURE3);
GlStateManager.bindTexture(gBufferDepthTexture);
GlStateManager.setActiveTexture(GL_TEXTURE2);
GlStateManager.bindTexture(CloudRenderWorker.cloudOcclusionTexture);
GlStateManager.setActiveTexture(GL_TEXTURE1);
CloudRenderWorker.bindParaboloid();
GlStateManager.setActiveTexture(GL_TEXTURE0);
GlStateManager.bindTexture(atmosphereHDRFramebufferColorTexture);
shader_skybox_render.useProgram();
uniformMatrixHelper(shader_skybox_render.uniforms.u_viewMatrix4f, DeferredStateManager.viewMatrix);
uniformMatrixHelper(shader_skybox_render.uniforms.u_projMatrix4f, DeferredStateManager.projMatrix);
_wglUniform3f(shader_skybox_render.uniforms.u_sunDirection3f, -currentSunAngle.x, -currentSunAngle.y, -currentSunAngle.z);
float mag = 25.0f;
float[] sunRGB2 = TemperaturesLUT.getColorTemperature((int)sunKelvin - 1000);
_wglUniform3f(shader_skybox_render.uniforms.u_sunColor3f, sunRGB2[0] * mag, sunRGB2[1] * mag, sunRGB2[2] * mag);
if (mc.theWorld.getLastLightningBolt() > 0) {
float f = 0.3f + fff;
_wglUniform4f(shader_skybox_render.uniforms.u_lightningColor4f, 0.02f * f, 0.02f * f, 0.02f * f, 1.0f - f * 0.25f);
}else {
_wglUniform4f(shader_skybox_render.uniforms.u_lightningColor4f, 0.0f, 0.0f, 0.0f, 1.0f);
}
skybox.drawFull();
DeferredStateManager.checkGLError("combineGBuffersAndIlluminate(): RENDER SKYBOX MESH");
}else if(dim == 1) {
GlStateManager.disableDepth();
GlStateManager.setActiveTexture(GL_TEXTURE0);
mc.getTextureManager().bindTexture(locationEndSkyPng);
if(shader_skybox_render_end == null) {
shader_skybox_render_end = PipelineShaderSkyboxRenderEnd.compile();
shader_skybox_render_end.loadUniforms();
}
shader_skybox_render_end.useProgram();
uniformMatrixHelper(shader_skybox_render_end.uniforms.u_viewMatrix4f, DeferredStateManager.viewMatrix);
uniformMatrixHelper(shader_skybox_render_end.uniforms.u_projMatrix4f, DeferredStateManager.projMatrix);
_wglUniform2f(shader_skybox_render_end.uniforms.u_skyTextureScale2f, 4.0f, 4.0f);
skybox.drawFull();
DeferredStateManager.checkGLError("combineGBuffersAndIlluminate(): RENDER SKYBOX MESH");
}else if(dim == -1) {
GlStateManager.clearColor(0.055f, 0.025f, 0.005f, 1.0f);
GlStateManager.clear(GL_COLOR_BUFFER_BIT);
}
// ================ INITIALIZE DEPTH BUFFER ================== //
GlStateManager.viewport(0, 0, currentWidth, currentHeight);
_wglBindFramebuffer(_GL_READ_FRAMEBUFFER, gBufferFramebuffer);
_wglBindFramebuffer(_GL_DRAW_FRAMEBUFFER, lightingHDRFramebuffer);
_wglBlitFramebuffer(0, 0, currentWidth, currentHeight, 0, 0, currentWidth, currentHeight, GL_DEPTH_BUFFER_BIT, GL_NEAREST);
_wglBindFramebuffer(_GL_FRAMEBUFFER, lightingHDRFramebuffer);
if(dim == -1) {
float f = 0.13f;
GlStateManager.clearColor(0.57f * 0.57f * f, 0.38f * 0.38f * f, 0.20f * 0.20f * f, 0.0f);
}else {
GlStateManager.clearColor(0.0f, 0.0f, 0.0f, 0.0f);
}
GlStateManager.clear(GL_COLOR_BUFFER_BIT);
DeferredStateManager.checkGLError("combineGBuffersAndIlluminate(): INITIALIZE DEPTH BUFFER");
DeferredStateManager.checkGLError("combineGBuffersAndIlluminate(): INITIALIZE HDR FRAMEBUFFER");
// ===================== COPY SKY TEXTURE ====================== //
_wglBindFramebuffer(_GL_FRAMEBUFFER, lightingHDRFramebuffer);
GlStateManager.viewport(0, 0, currentWidth, currentHeight);
GlStateManager.setActiveTexture(GL_TEXTURE0);
GlStateManager.bindTexture(skyTexture);
TextureCopyUtil.blitTexture();
if(dim == 0 && fff < 1.0f) {
// ===================== RENDER MOON ====================== //
GlStateManager.enableDepth();
Matrix4f moonMatrix = tmpMatrix2;
moonMatrix.setIdentity();
tmpVector3.set(-1.0f, -1.0f, 1.0f);
Matrix4f.scale(tmpVector3, moonMatrix, moonMatrix);
tmpVector3.set(0.0f, 0.0f, 1.0f);
Matrix4f.rotate(2.7f, tmpVector3, moonMatrix, moonMatrix);
tmpVector3.set(-1.0f, 0.0f, 0.0f);
tmpVector4.set(currentSunAngle);
tmpVector4.scale(-1.0f);
Vector3f.cross(tmpVector3, tmpVector4, tmpVector1);
Vector3f.cross(tmpVector4, tmpVector1, tmpVector3);
moonMatrix = tmpMatrix1;
moonMatrix.setIdentity();
moonMatrix.m00 = tmpVector1.x;
moonMatrix.m01 = tmpVector1.y;
moonMatrix.m02 = tmpVector1.z;
moonMatrix.m10 = tmpVector3.x;
moonMatrix.m11 = tmpVector3.y;
moonMatrix.m12 = tmpVector3.z;
moonMatrix.m20 = tmpVector4.x;
moonMatrix.m21 = tmpVector4.y;
moonMatrix.m22 = tmpVector4.z;
Matrix4f.mul(moonMatrix, tmpMatrix2, moonMatrix);
GlStateManager.bindTexture(moonTextures);
shader_moon_render.useProgram();
uniformMatrixHelper(shader_moon_render.uniforms.u_modelMatrix4f, moonMatrix);
uniformMatrixHelper(shader_moon_render.uniforms.u_viewMatrix4f, DeferredStateManager.viewMatrix);
uniformMatrixHelper(shader_moon_render.uniforms.u_projMatrix4f, DeferredStateManager.projMatrix);
float fffff = 0.1f + MathHelper.clamp_float((-currentSunAngle.y + 0.1f) * 6.0f, 0.0f, 0.375f);
_wglUniform3f(shader_moon_render.uniforms.u_moonColor3f, 1.4f * fffff, 1.2f * fffff, 1.0f * fffff);
float f = (float)(Minecraft.getMinecraft().theWorld.getWorldTime() - 18000f) / 24000f / 4f * 3.14159f;
_wglUniform3f(shader_moon_render.uniforms.u_lightDir3f, MathHelper.sin(f), 0.0f, MathHelper.cos(f));
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(GL_ONE, GL_ONE, GL_ZERO, GL_ZERO);
DrawUtils.drawStandardQuad2D();
GlStateManager.disableDepth();
DeferredStateManager.checkGLError("combineGBuffersAndIlluminate(): RENDER MOON");
}
// ================= RENDER AMBIENT LIGHTING ==================== //
GlStateManager.disableBlend();
GlStateManager.setActiveTexture(GL_TEXTURE9);
GlStateManager.bindTexture(MetalsLUT.getGLTexture());
GlStateManager.setActiveTexture(GL_TEXTURE8);
@ -2020,6 +2202,11 @@ public class EaglerDeferredPipeline {
shader_lighting_sun.useProgram();
uniformMatrixHelper(shader_lighting_sun.uniforms.u_inverseViewMatrix4f, DeferredStateManager.inverseViewMatrix);
uniformMatrixHelper(shader_lighting_sun.uniforms.u_inverseProjectionMatrix4f, DeferredStateManager.inverseProjMatrix);
if(config.is_rendering_subsurfaceScattering) {
GlStateManager.setActiveTexture(GL_TEXTURE6);
GlStateManager.bindTexture(subsurfaceScatteringTexture);
}
_wglTexParameteri(GL_TEXTURE_2D, _GL_TEXTURE_COMPARE_MODE, GL_NONE);
GlStateManager.setActiveTexture(GL_TEXTURE5);
GlStateManager.bindTexture(MetalsLUT.getGLTexture());
GlStateManager.setActiveTexture(GL_TEXTURE4);
@ -2029,7 +2216,7 @@ public class EaglerDeferredPipeline {
GlStateManager.bindTexture(-1);
}
GlStateManager.setActiveTexture(GL_TEXTURE0);
float ffff = getSkyBrightnessParam();
float[] sunRGB;
if(currentSunAngle.y < 0.05f) {
@ -2047,11 +2234,11 @@ public class EaglerDeferredPipeline {
currentSunLightColor3f.z = sunRGB[2] * 0.3f * (0.2f + ffff * 0.8f);
_wglUniform3f(shader_lighting_sun.uniforms.u_sunColor3f, sunRGB[0] * 0.1f * (0.5f + ffff * 0.5f), sunRGB[1] * 0.1f * (0.5f + ffff * 0.5f), sunRGB[2] * 0.1f * (0.5f + ffff * 0.5f));
}
_wglUniform3f(shader_lighting_sun.uniforms.u_sunDirection3f, -DeferredStateManager.currentSunLightAngle.x, -DeferredStateManager.currentSunLightAngle.y, -DeferredStateManager.currentSunLightAngle.z);
DrawUtils.drawStandardQuad2D();
DeferredStateManager.checkGLError("combineGBuffersAndIlluminate(): RENDER SUNLIGHT");
}else {
DeferredStateManager.currentSunLightColor.set(0.0f, 0.0f, 0.0f);
@ -2124,101 +2311,6 @@ public class EaglerDeferredPipeline {
_wglBindFramebuffer(_GL_FRAMEBUFFER, lightingHDRFramebuffer);
// =================== RENDER SKYBOX MESH =================== //
if(dim == 0) {
GlStateManager.enableDepth();
GlStateManager.setActiveTexture(GL_TEXTURE2);
GlStateManager.bindTexture(CloudRenderWorker.cloudOcclusionTexture);
GlStateManager.setActiveTexture(GL_TEXTURE1);
CloudRenderWorker.bindParaboloid();
GlStateManager.setActiveTexture(GL_TEXTURE0);
GlStateManager.bindTexture(atmosphereHDRFramebufferColorTexture);
shader_skybox_render.useProgram();
uniformMatrixHelper(shader_skybox_render.uniforms.u_viewMatrix4f, DeferredStateManager.viewMatrix);
uniformMatrixHelper(shader_skybox_render.uniforms.u_projMatrix4f, DeferredStateManager.projMatrix);
_wglUniform3f(shader_skybox_render.uniforms.u_sunDirection3f, -currentSunAngle.x, -currentSunAngle.y, -currentSunAngle.z);
float mag = 25.0f;
float[] sunRGB2 = TemperaturesLUT.getColorTemperature((int)sunKelvin - 1000);
_wglUniform3f(shader_skybox_render.uniforms.u_sunColor3f, sunRGB2[0] * mag, sunRGB2[1] * mag, sunRGB2[2] * mag);
if (mc.theWorld.getLastLightningBolt() > 0) {
float f = 0.3f + fff;
_wglUniform4f(shader_skybox_render.uniforms.u_lightningColor4f, 0.02f * f, 0.02f * f, 0.02f * f, 1.0f - f * 0.25f);
}else {
_wglUniform4f(shader_skybox_render.uniforms.u_lightningColor4f, 0.0f, 0.0f, 0.0f, 1.0f);
}
skybox.drawFull();
DeferredStateManager.checkGLError("combineGBuffersAndIlluminate(): RENDER SKYBOX MESH");
}else if(dim == 1) {
GlStateManager.enableDepth();
GlStateManager.setActiveTexture(GL_TEXTURE0);
mc.getTextureManager().bindTexture(locationEndSkyPng);
if(shader_skybox_render_end == null) {
shader_skybox_render_end = PipelineShaderSkyboxRenderEnd.compile();
shader_skybox_render_end.loadUniforms();
}
shader_skybox_render_end.useProgram();
uniformMatrixHelper(shader_skybox_render_end.uniforms.u_viewMatrix4f, DeferredStateManager.viewMatrix);
uniformMatrixHelper(shader_skybox_render_end.uniforms.u_projMatrix4f, DeferredStateManager.projMatrix);
_wglUniform2f(shader_skybox_render_end.uniforms.u_skyTextureScale2f, 4.0f, 4.0f);
skybox.drawFull();
DeferredStateManager.checkGLError("combineGBuffersAndIlluminate(): RENDER SKYBOX MESH");
}
if(dim == 0 && fff < 1.0f) {
// ===================== RENDER MOON ====================== //
Matrix4f moonMatrix = tmpMatrix2;
moonMatrix.setIdentity();
tmpVector3.set(-1.0f, -1.0f, 1.0f);
Matrix4f.scale(tmpVector3, moonMatrix, moonMatrix);
tmpVector3.set(0.0f, 0.0f, 1.0f);
Matrix4f.rotate(2.7f, tmpVector3, moonMatrix, moonMatrix);
tmpVector3.set(-1.0f, 0.0f, 0.0f);
tmpVector4.set(currentSunAngle);
tmpVector4.scale(-1.0f);
Vector3f.cross(tmpVector3, tmpVector4, tmpVector1);
Vector3f.cross(tmpVector4, tmpVector1, tmpVector3);
moonMatrix = tmpMatrix1;
moonMatrix.setIdentity();
moonMatrix.m00 = tmpVector1.x;
moonMatrix.m01 = tmpVector1.y;
moonMatrix.m02 = tmpVector1.z;
moonMatrix.m10 = tmpVector3.x;
moonMatrix.m11 = tmpVector3.y;
moonMatrix.m12 = tmpVector3.z;
moonMatrix.m20 = tmpVector4.x;
moonMatrix.m21 = tmpVector4.y;
moonMatrix.m22 = tmpVector4.z;
Matrix4f.mul(moonMatrix, tmpMatrix2, moonMatrix);
GlStateManager.bindTexture(moonTextures);
shader_moon_render.useProgram();
uniformMatrixHelper(shader_moon_render.uniforms.u_modelMatrix4f, moonMatrix);
uniformMatrixHelper(shader_moon_render.uniforms.u_viewMatrix4f, DeferredStateManager.viewMatrix);
uniformMatrixHelper(shader_moon_render.uniforms.u_projMatrix4f, DeferredStateManager.projMatrix);
float fffff = 0.1f + MathHelper.clamp_float((-currentSunAngle.y + 0.1f) * 8.0f, 0.0f, 0.5f);
_wglUniform3f(shader_moon_render.uniforms.u_moonColor3f, 1.4f * fffff, 1.2f * fffff, 1.0f * fffff);
float f = (float)(Minecraft.getMinecraft().theWorld.getWorldTime() - 18000f) / 24000f / 4f * 3.14159f;
_wglUniform3f(shader_moon_render.uniforms.u_lightDir3f, MathHelper.sin(f), 0.0f, MathHelper.cos(f));
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(GL_ONE, GL_ONE, GL_ZERO, GL_ZERO);
DrawUtils.drawStandardQuad2D();
DeferredStateManager.checkGLError("combineGBuffersAndIlluminate(): RENDER MOON");
}
GlStateManager.disableDepth();
GlStateManager.depthMask(true);
GlStateManager.disableBlend();
@ -2883,6 +2975,8 @@ public class EaglerDeferredPipeline {
_wglBindFramebuffer(_GL_DRAW_FRAMEBUFFER, fogDepthCopyBuffer);
_wglBlitFramebuffer(0, 0, currentWidth, currentHeight, 0, 0, currentWidth, currentHeight, GL_DEPTH_BUFFER_BIT, GL_NEAREST);
_wglBindFramebuffer(_GL_FRAMEBUFFER, lightingHDRFramebuffer);
GlStateManager.setActiveTexture(GL_TEXTURE5);
GlStateManager.bindTexture(skyTexture);
if(config.is_rendering_lightShafts) {
GlStateManager.setActiveTexture(GL_TEXTURE4);
GlStateManager.bindTexture(lightShaftsTexture);
@ -3038,6 +3132,10 @@ public class EaglerDeferredPipeline {
public void beginDrawTranslucentEntities() {
DeferredStateManager.checkGLError("Pre: beginDrawTranslucentEntities()");
if(config.is_rendering_useEnvMap) {
GlStateManager.setActiveTexture(GL_TEXTURE5);
GlStateManager.bindTexture(envMapColorTexture);
}
GlStateManager.setActiveTexture(GL_TEXTURE4);
if(config.is_rendering_shadowsSun_clamped > 0) {
GlStateManager.bindTexture(sunShadowDepthBuffer);
@ -3559,6 +3657,14 @@ public class EaglerDeferredPipeline {
GlStateManager.deleteTexture(sunLightingShadowTexture);
sunLightingShadowTexture = -1;
}
if(subsurfaceScatteringFramebuffer != null) {
_wglDeleteFramebuffer(subsurfaceScatteringFramebuffer);
subsurfaceScatteringFramebuffer = null;
}
if(subsurfaceScatteringTexture != -1) {
GlStateManager.deleteTexture(subsurfaceScatteringTexture);
subsurfaceScatteringTexture = -1;
}
if(ssaoGenerateFramebuffer != null) {
_wglDeleteFramebuffer(ssaoGenerateFramebuffer);
ssaoGenerateFramebuffer = null;
@ -3627,6 +3733,14 @@ public class EaglerDeferredPipeline {
GlStateManager.deleteTexture(lastFrameGBufferDepthTexture);
lastFrameGBufferDepthTexture = -1;
}
if(skyFramebuffer != null) {
_wglDeleteFramebuffer(skyFramebuffer);
skyFramebuffer = null;
}
if(skyTexture != -1) {
GlStateManager.deleteTexture(skyTexture);
skyTexture = -1;
}
if(lightingHDRFramebuffer != null) {
_wglDeleteFramebuffer(lightingHDRFramebuffer);
lightingHDRFramebuffer = null;
@ -3887,6 +4001,10 @@ public class EaglerDeferredPipeline {
shader_post_fxaa.destroy();
shader_post_fxaa = null;
}
if(shader_subsurface_scattering != null) {
shader_subsurface_scattering.destroy();
shader_subsurface_scattering = null;
}
if(shader_skybox_render_paraboloid != null) {
shader_skybox_render_paraboloid.destroy();
shader_skybox_render_paraboloid = null;
@ -4069,11 +4187,11 @@ public class EaglerDeferredPipeline {
}
}
public static final boolean isSupported() {
public static boolean isSupported() {
return EaglercraftGPU.checkOpenGLESVersion() >= 300 && EaglercraftGPU.checkHasHDRFramebufferSupportWithFilter();
}
public static final String getReasonUnsupported() {
public static String getReasonUnsupported() {
if(EaglercraftGPU.checkOpenGLESVersion() < 300) {
return I18n.format("shaders.gui.unsupported.reason.oldOpenGLVersion");
}else if(!EaglercraftGPU.checkHasHDRFramebufferSupportWithFilter()) {
@ -4083,7 +4201,7 @@ public class EaglerDeferredPipeline {
}
}
public static final void renderSuspended() {
public static void renderSuspended() {
_wglBindFramebuffer(_GL_FRAMEBUFFER, null);
GlStateManager.globalEnableBlend();
Minecraft mc = Minecraft.getMinecraft();

View File

@ -20,7 +20,7 @@ import static net.lax1dude.eaglercraft.v1_8.internal.PlatformOpenGL.*;
import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.*;
import net.lax1dude.eaglercraft.v1_8.EagRuntime;
import net.lax1dude.eaglercraft.v1_8.internal.IBufferArrayGL;
import net.lax1dude.eaglercraft.v1_8.internal.IVertexArrayGL;
import net.lax1dude.eaglercraft.v1_8.internal.IBufferGL;
import net.lax1dude.eaglercraft.v1_8.internal.buffer.ByteBuffer;
import net.lax1dude.eaglercraft.v1_8.internal.buffer.FloatBuffer;
@ -46,7 +46,7 @@ public class ForwardAcceleratedEffectRenderer extends AbstractAcceleratedEffectR
private PipelineShaderAccelParticleForward shaderProgram = null;
private IBufferArrayGL vertexArray = null;
private IVertexArrayGL vertexArray = null;
private IBufferGL vertexBuffer = null;
private IBufferGL instancesBuffer = null;
@ -80,7 +80,7 @@ public class ForwardAcceleratedEffectRenderer extends AbstractAcceleratedEffectR
});
verts.flip();
EaglercraftGPU.bindGLBufferArray(vertexArray);
EaglercraftGPU.bindGLVertexArray(vertexArray);
EaglercraftGPU.bindGLArrayBuffer(vertexBuffer);
_wglBufferData(GL_ARRAY_BUFFER, verts, GL_STATIC_DRAW);
@ -143,7 +143,7 @@ public class ForwardAcceleratedEffectRenderer extends AbstractAcceleratedEffectR
EaglerDeferredPipeline.uniformMatrixHelper(shaderProgram.uniforms.u_inverseViewMatrix4f, DeferredStateManager.passInverseViewMatrix);
EaglercraftGPU.bindGLArrayBuffer(instancesBuffer);
EaglercraftGPU.bindGLBufferArray(vertexArray);
EaglercraftGPU.bindGLVertexArray(vertexArray);
int p = particleBuffer.position();
int l = particleBuffer.limit();

View File

@ -20,7 +20,7 @@ import static net.lax1dude.eaglercraft.v1_8.internal.PlatformOpenGL.*;
import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.*;
import net.lax1dude.eaglercraft.v1_8.EagRuntime;
import net.lax1dude.eaglercraft.v1_8.internal.IBufferArrayGL;
import net.lax1dude.eaglercraft.v1_8.internal.IVertexArrayGL;
import net.lax1dude.eaglercraft.v1_8.internal.IBufferGL;
import net.lax1dude.eaglercraft.v1_8.internal.buffer.ByteBuffer;
import net.lax1dude.eaglercraft.v1_8.internal.buffer.FloatBuffer;
@ -46,7 +46,7 @@ public class GBufferAcceleratedEffectRenderer extends AbstractAcceleratedEffectR
private PipelineShaderAccelParticleGBuffer shaderProgram = null;
private IBufferArrayGL vertexArray = null;
private IVertexArrayGL vertexArray = null;
private IBufferGL vertexBuffer = null;
private IBufferGL instancesBuffer = null;
@ -80,7 +80,7 @@ public class GBufferAcceleratedEffectRenderer extends AbstractAcceleratedEffectR
});
verts.flip();
EaglercraftGPU.bindGLBufferArray(vertexArray);
EaglercraftGPU.bindGLVertexArray(vertexArray);
EaglercraftGPU.bindGLArrayBuffer(vertexBuffer);
_wglBufferData(GL_ARRAY_BUFFER, verts, GL_STATIC_DRAW);
@ -142,7 +142,7 @@ public class GBufferAcceleratedEffectRenderer extends AbstractAcceleratedEffectR
EaglerDeferredPipeline.uniformMatrixHelper(shaderProgram.uniforms.u_matrixTransform, tmpMatrix);
EaglercraftGPU.bindGLArrayBuffer(instancesBuffer);
EaglercraftGPU.bindGLBufferArray(vertexArray);
EaglercraftGPU.bindGLVertexArray(vertexArray);
int p = particleBuffer.position();
int l = particleBuffer.limit();

View File

@ -128,6 +128,9 @@ public class GBufferPipelineCompiler implements IExtPipelineCompiler {
if(conf.is_rendering_useEnvMap) {
macros.append("#define COMPILE_PARABOLOID_ENV_MAP\n");
}
if(conf.is_rendering_subsurfaceScattering) {
macros.append("#define COMPILE_SUBSURFACE_SCATTERING\n");
}
}
if(conf.is_rendering_dynamicLights) {
macros.append("#define COMPILE_DYNAMIC_LIGHTS\n");
@ -166,6 +169,9 @@ public class GBufferPipelineCompiler implements IExtPipelineCompiler {
if((stateExtBits & STATE_WAVING_BLOCKS) != 0) {
macros.append("#define COMPILE_STATE_WAVING_BLOCKS\n");
}
if(conf.is_rendering_subsurfaceScattering) {
macros.append("#define COMPILE_SUBSURFACE_SCATTERING\n");
}
logger.info("Compiling program for core state: {}, ext state: {}", visualizeBits(stateCoreBits), visualizeBits(stateExtBits));
logger.info(" - {}", ShaderSource.deferred_core_vsh);
@ -232,12 +238,24 @@ public class GBufferPipelineCompiler implements IExtPipelineCompiler {
float roughness = 1.0f - DeferredStateManager.materialConstantsRoughness;
float metalness = DeferredStateManager.materialConstantsMetalness;
float emission = DeferredStateManager.materialConstantsEmission;
if(uniforms.materialConstantsRoughness != roughness || uniforms.materialConstantsMetalness != metalness
|| uniforms.materialConstantsEmission != emission) {
uniforms.materialConstantsRoughness = roughness;
uniforms.materialConstantsMetalness = metalness;
uniforms.materialConstantsEmission = emission;
_wglUniform3f(uniforms.u_materialConstants3f, roughness, metalness, emission);
if(uniforms.u_materialConstants4f != null) {
float subsurfScattering = 1.0f - DeferredStateManager.materialConstantsSubsurfScatting;
if(uniforms.materialConstantsRoughness != roughness || uniforms.materialConstantsMetalness != metalness
|| uniforms.materialConstantsEmission != emission || uniforms.materialConstantsSubsurfScattering != subsurfScattering) {
uniforms.materialConstantsRoughness = roughness;
uniforms.materialConstantsMetalness = metalness;
uniforms.materialConstantsEmission = emission;
uniforms.materialConstantsSubsurfScattering = subsurfScattering;
_wglUniform4f(uniforms.u_materialConstants4f, roughness, metalness, emission, subsurfScattering);
}
}else {
if(uniforms.materialConstantsRoughness != roughness || uniforms.materialConstantsMetalness != metalness
|| uniforms.materialConstantsEmission != emission) {
uniforms.materialConstantsRoughness = roughness;
uniforms.materialConstantsMetalness = metalness;
uniforms.materialConstantsEmission = emission;
_wglUniform3f(uniforms.u_materialConstants3f, roughness, metalness, emission);
}
}
}
}

View File

@ -24,7 +24,7 @@ import java.io.DataInputStream;
import java.io.IOException;
import net.lax1dude.eaglercraft.v1_8.EagRuntime;
import net.lax1dude.eaglercraft.v1_8.internal.IBufferArrayGL;
import net.lax1dude.eaglercraft.v1_8.internal.IVertexArrayGL;
import net.lax1dude.eaglercraft.v1_8.internal.IBufferGL;
import net.lax1dude.eaglercraft.v1_8.internal.buffer.ByteBuffer;
import net.lax1dude.eaglercraft.v1_8.opengl.DrawUtils;
@ -43,10 +43,10 @@ public class LensFlareMeshRenderer {
public static final ResourceLocation ghostsTextureLocation = new ResourceLocation("eagler:glsl/deferred/lens_ghosts.bmp");
public static final int ghostsSpriteCount = 4;
static IBufferArrayGL streaksVertexArray = null;
static IVertexArrayGL streaksVertexArray = null;
static IBufferGL streaksVertexBuffer = null;
static IBufferArrayGL ghostsVertexArray = null;
static IVertexArrayGL ghostsVertexArray = null;
static IBufferGL ghostsVertexBuffer = null;
static PipelineShaderLensFlares streaksProgram = null;
@ -88,7 +88,7 @@ public class LensFlareMeshRenderer {
_wglBufferData(GL_ARRAY_BUFFER, copyBuffer, GL_STATIC_DRAW);
streaksVertexArray = _wglGenVertexArrays();
EaglercraftGPU.bindGLBufferArray(streaksVertexArray);
EaglercraftGPU.bindGLVertexArray(streaksVertexArray);
EaglercraftGPU.attachQuad16EmulationBuffer(16, true);
_wglEnableVertexAttribArray(0);
@ -133,7 +133,7 @@ public class LensFlareMeshRenderer {
copyBuffer.flip();
ghostsVertexArray = _wglGenVertexArrays();
EaglercraftGPU.bindGLBufferArray(ghostsVertexArray);
EaglercraftGPU.bindGLVertexArray(ghostsVertexArray);
EaglercraftGPU.bindGLArrayBuffer(DrawUtils.standardQuadVBO);
_wglEnableVertexAttribArray(0);
@ -315,7 +315,7 @@ public class LensFlareMeshRenderer {
mag = 0.003f * (1.0f + mag * mag * mag * 4.0f);
_wglUniform3f(streaksProgram.uniforms.u_flareColor3f, v.x * mag * 0.5f, v.y * mag * 0.5f, v.z * mag * 0.5f);
EaglercraftGPU.bindGLBufferArray(streaksVertexArray);
EaglercraftGPU.bindGLVertexArray(streaksVertexArray);
_wglDrawElements(GL_TRIANGLES, streaksVertexCount + (streaksVertexCount >> 1), GL_UNSIGNED_SHORT, 0);
ghostsProgram.useProgram();
@ -328,7 +328,7 @@ public class LensFlareMeshRenderer {
_wglUniform2f(ghostsProgram.uniforms.u_sunPosition2f, sunScreenX, sunScreenY);
_wglUniform1f(ghostsProgram.uniforms.u_baseScale1f, fov);
EaglercraftGPU.bindGLBufferArray(ghostsVertexArray);
EaglercraftGPU.bindGLVertexArray(ghostsVertexArray);
_wglDrawArraysInstanced(GL_TRIANGLES, 0, 6, ghostsInstanceCount);
GlStateManager.disableBlend();

View File

@ -26,7 +26,7 @@ import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import net.lax1dude.eaglercraft.v1_8.EagRuntime;
import net.lax1dude.eaglercraft.v1_8.internal.IBufferArrayGL;
import net.lax1dude.eaglercraft.v1_8.internal.IVertexArrayGL;
import net.lax1dude.eaglercraft.v1_8.internal.IBufferGL;
import net.lax1dude.eaglercraft.v1_8.internal.buffer.ByteBuffer;
import net.lax1dude.eaglercraft.v1_8.opengl.EaglercraftGPU;
@ -40,7 +40,7 @@ public class LightSourceMesh {
private IBufferGL meshVBO = null;
private IBufferGL meshIBO = null;
private IBufferArrayGL meshVAO = null;
private IVertexArrayGL meshVAO = null;
private int meshIndexType = -1;
private int meshIndexCount = -1;
@ -102,7 +102,7 @@ public class LightSourceMesh {
buf.flip();
meshVAO = _wglGenVertexArrays();
EaglercraftGPU.bindGLBufferArray(meshVAO);
EaglercraftGPU.bindGLVertexArray(meshVAO);
meshIBO = _wglGenBuffers();
_wglBindBuffer(GL_ELEMENT_ARRAY_BUFFER, meshIBO);
@ -117,7 +117,7 @@ public class LightSourceMesh {
}
public void drawMeshVAO() {
EaglercraftGPU.bindGLBufferArray(meshVAO);
EaglercraftGPU.bindGLVertexArray(meshVAO);
_wglDrawElements(GL_TRIANGLES, meshIndexCount, meshIndexType, 0);
}

View File

@ -46,6 +46,7 @@ public class ShaderPackInfo {
public final boolean POST_LENS_FLARES;
public final boolean POST_BLOOM;
public final boolean POST_FXAA;
public final boolean SUBSURFACE_SCATTERING;
public ShaderPackInfo(JSONObject json) {
name = json.optString("name", "Untitled");
@ -75,6 +76,7 @@ public class ShaderPackInfo {
POST_LENS_FLARES = supportedFeatures.contains("POST_LENS_FLARES");
POST_BLOOM = supportedFeatures.contains("POST_BLOOM");
POST_FXAA = supportedFeatures.contains("POST_FXAA");
SUBSURFACE_SCATTERING = supportedFeatures.contains("SUBSURFACE_SCATTERING");
}
}

View File

@ -26,7 +26,7 @@ import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import net.lax1dude.eaglercraft.v1_8.EagRuntime;
import net.lax1dude.eaglercraft.v1_8.internal.IBufferArrayGL;
import net.lax1dude.eaglercraft.v1_8.internal.IVertexArrayGL;
import net.lax1dude.eaglercraft.v1_8.internal.IBufferGL;
import net.lax1dude.eaglercraft.v1_8.internal.buffer.ByteBuffer;
import net.lax1dude.eaglercraft.v1_8.opengl.EaglercraftGPU;
@ -40,7 +40,7 @@ public class SkyboxRenderer {
private IBufferGL skyboxVBO = null;
private IBufferGL skyboxIBO = null;
private IBufferArrayGL skyboxVAO = null;
private IVertexArrayGL skyboxVAO = null;
private int normalsLUT = -1;
private int atmosphereLUTWidth = -1;
private int atmosphereLUTHeight = -1;
@ -136,7 +136,7 @@ public class SkyboxRenderer {
buf.flip();
skyboxVAO = _wglGenVertexArrays();
EaglercraftGPU.bindGLBufferArray(skyboxVAO);
EaglercraftGPU.bindGLVertexArray(skyboxVAO);
skyboxIBO = _wglGenBuffers();
_wglBindBuffer(GL_ELEMENT_ARRAY_BUFFER, skyboxIBO);
@ -166,17 +166,17 @@ public class SkyboxRenderer {
}
public void drawTop() {
EaglercraftGPU.bindGLBufferArray(skyboxVAO);
EaglercraftGPU.bindGLVertexArray(skyboxVAO);
_wglDrawElements(GL_TRIANGLES, skyboxTopIndexCount, skyboxIndexType, skyboxTopIndexOffset * skyboxIndexStride);
}
public void drawBottom() {
EaglercraftGPU.bindGLBufferArray(skyboxVAO);
EaglercraftGPU.bindGLVertexArray(skyboxVAO);
_wglDrawElements(GL_TRIANGLES, skyboxBottomIndexCount, skyboxIndexType, skyboxBottomIndexOffset * skyboxIndexStride);
}
public void drawFull() {
EaglercraftGPU.bindGLBufferArray(skyboxVAO);
EaglercraftGPU.bindGLVertexArray(skyboxVAO);
_wglDrawElements(GL_TRIANGLES, skyboxIndexCount, skyboxIndexType, 0);
}

View File

@ -217,6 +217,23 @@ public class GuiShaderConfigList extends GuiListExtended {
}
});
}
if(conf.shaderPackInfo.SUBSURFACE_SCATTERING) {
opts.add(new ShaderOption(loadShaderLbl("SUBSURFACE_SCATTERING"), loadShaderDesc("SUBSURFACE_SCATTERING")) {
private final boolean originalValue = conf.subsurfaceScattering;
@Override
protected String getDisplayValue() {
return getColoredOnOff(conf.subsurfaceScattering, EnumChatFormatting.GREEN, EnumChatFormatting.RED);
}
@Override
protected void toggleOption(GuiButton button, int dir) {
conf.subsurfaceScattering = !conf.subsurfaceScattering;
}
@Override
protected boolean getDirty() {
return conf.subsurfaceScattering != originalValue;
}
});
}
if(conf.shaderPackInfo.POST_LENS_FLARES) {
opts.add(new ShaderOption(loadShaderLbl("POST_LENS_FLARES"), loadShaderDesc("POST_LENS_FLARES")) {
private final boolean originalValue = conf.lensFlares;

View File

@ -39,9 +39,11 @@ public class GBufferExtPipelineShader extends ShaderProgram<GBufferExtPipelineSh
public float materialConstantsRoughness = -999.0f;
public float materialConstantsMetalness = -999.0f;
public float materialConstantsEmission = -999.0f;
public float materialConstantsSubsurfScattering = -999.0f;
public float materialConstantsUseEnvMap = -999.0f;
public IUniformGL u_materialConstants3f = null;
public IUniformGL u_materialConstants4f = null;
public IUniformGL u_useEnvMap1f = null;
public int constantBlock = -999;
@ -91,6 +93,7 @@ public class GBufferExtPipelineShader extends ShaderProgram<GBufferExtPipelineSh
@Override
public void loadUniforms(IProgramGL prog) {
u_materialConstants3f = _wglGetUniformLocation(prog, "u_materialConstants3f");
u_materialConstants4f = _wglGetUniformLocation(prog, "u_materialConstants4f");
u_useEnvMap1f = _wglGetUniformLocation(prog, "u_useEnvMap1f");
u_blockConstant1f = _wglGetUniformLocation(prog, "u_blockConstant1f");
u_clipPlaneY1f = _wglGetUniformLocation(prog, "u_clipPlaneY1f");

View File

@ -80,6 +80,7 @@ public class PipelineShaderGBufferFog extends ShaderProgram<PipelineShaderGBuffe
_wglUniform1i(_wglGetUniformLocation(prog, "u_fogDepthTexture"), 2);
_wglUniform1i(_wglGetUniformLocation(prog, "u_environmentMap"), 3);
_wglUniform1i(_wglGetUniformLocation(prog, "u_lightShaftsTexture"), 4);
_wglUniform1i(_wglGetUniformLocation(prog, "u_skyTexture"), 5);
}
}

View File

@ -28,20 +28,28 @@ import net.lax1dude.eaglercraft.v1_8.internal.IUniformGL;
public class PipelineShaderLightingSun extends ShaderProgram<PipelineShaderLightingSun.Uniforms> {
public static PipelineShaderLightingSun compile(int shadowsSun, boolean coloredShadows) throws ShaderException {
public static PipelineShaderLightingSun compile(int shadowsSun, boolean coloredShadows, boolean subsurfaceScattering) throws ShaderException {
IShaderGL sunShader = null;
List<String> compileFlags = new ArrayList<>(1);
if(shadowsSun > 0) {
compileFlags.add("COMPILE_SUN_SHADOW");
}
int lods = shadowsSun - 1;
if(lods > 2) {
lods = 2;
}
compileFlags.add("COMPILE_SUN_SHADOW_LOD" + lods);
if(coloredShadows) {
compileFlags.add("COMPILE_COLORED_SHADOW");
}
if(subsurfaceScattering) {
compileFlags.add("COMPILE_SUBSURFACE_SCATTERING");
}
sunShader = ShaderCompiler.compileShader("lighting_sun", GL_FRAGMENT_SHADER,
ShaderSource.lighting_sun_fsh, compileFlags);
try {
IProgramGL prog = ShaderCompiler.linkProgram("lighting_sun", SharedPipelineShaders.deferred_local, sunShader);
return new PipelineShaderLightingSun(prog, shadowsSun);
return new PipelineShaderLightingSun(prog, shadowsSun, subsurfaceScattering);
}finally {
if(sunShader != null) {
sunShader.free();
@ -49,20 +57,23 @@ public class PipelineShaderLightingSun extends ShaderProgram<PipelineShaderLight
}
}
private PipelineShaderLightingSun(IProgramGL program, int shadowsSun) {
super(program, new Uniforms(shadowsSun));
private PipelineShaderLightingSun(IProgramGL program, int shadowsSun, boolean subsurfaceScattering) {
super(program, new Uniforms(shadowsSun, subsurfaceScattering));
}
public static class Uniforms implements IProgramUniforms {
public final int shadowsSun;
public IUniformGL u_inverseViewMatrix4f;
public IUniformGL u_inverseProjectionMatrix4f;
public IUniformGL u_sunDirection3f;
public IUniformGL u_sunColor3f;
private Uniforms(int shadowsSun) {
public final int shadowsSun;
public final boolean subsurfaceScattering;
private Uniforms(int shadowsSun, boolean subsurfaceScattering) {
this.shadowsSun = shadowsSun;
this.subsurfaceScattering = subsurfaceScattering;
}
@Override
@ -73,6 +84,7 @@ public class PipelineShaderLightingSun extends ShaderProgram<PipelineShaderLight
_wglUniform1i(_wglGetUniformLocation(prog, "u_gbufferDepthTexture"), 3);
_wglUniform1i(_wglGetUniformLocation(prog, "u_sunShadowTexture"), 4);
_wglUniform1i(_wglGetUniformLocation(prog, "u_metalsLUT"), 5);
_wglUniform1i(_wglGetUniformLocation(prog, "u_subsurfaceScatteringTexture"), 6);
u_inverseViewMatrix4f = _wglGetUniformLocation(prog, "u_inverseViewMatrix4f");
u_inverseProjectionMatrix4f = _wglGetUniformLocation(prog, "u_inverseProjectionMatrix4f");
u_sunDirection3f = _wglGetUniformLocation(prog, "u_sunDirection3f");

View File

@ -84,6 +84,7 @@ public class PipelineShaderSkyboxRender extends ShaderProgram<PipelineShaderSkyb
_wglUniform1i(_wglGetUniformLocation(prog, "u_renderedAtmosphere"), 0);
_wglUniform1i(_wglGetUniformLocation(prog, "u_cloudsTexture"), 1);
_wglUniform1i(_wglGetUniformLocation(prog, "u_sunOcclusion"), 2);
_wglUniform1i(_wglGetUniformLocation(prog, "u_gbufferDepthTexture"), 3);
}
}

View File

@ -0,0 +1,95 @@
/*
* Copyright (c) 2025 lax1dude. All Rights Reserved.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.program;
import static net.lax1dude.eaglercraft.v1_8.internal.PlatformOpenGL._wglGetUniformLocation;
import static net.lax1dude.eaglercraft.v1_8.internal.PlatformOpenGL._wglUniform1i;
import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.*;
import java.util.ArrayList;
import java.util.List;
import net.lax1dude.eaglercraft.v1_8.internal.IProgramGL;
import net.lax1dude.eaglercraft.v1_8.internal.IShaderGL;
import net.lax1dude.eaglercraft.v1_8.internal.IUniformGL;
public class PipelineShaderSubsurfaceScattering extends ShaderProgram<PipelineShaderSubsurfaceScattering.Uniforms> {
public static PipelineShaderSubsurfaceScattering compile(int shadowsSun, float texW, float texH) throws ShaderException {
IShaderGL shadowShader = null;
List<String> compileFlags = new ArrayList<>(3);
if(shadowsSun == 0) {
throw new IllegalStateException("Enable shadows to compile this shader");
}
int lods = shadowsSun - 1;
if(lods > 2) {
lods = 2;
}
compileFlags.add("COMPILE_SUN_SHADOW_LOD" + lods);
compileFlags.add("SUN_SHADOW_DEPTH_SIZE_2F_X " + texW);
compileFlags.add("SUN_SHADOW_DEPTH_SIZE_2F_Y " + texH);
shadowShader = ShaderCompiler.compileShader("subsurface_scattering", GL_FRAGMENT_SHADER,
ShaderSource.subsurface_scattering_fsh, compileFlags);
try {
IProgramGL prog = ShaderCompiler.linkProgram("subsurface_scattering", SharedPipelineShaders.deferred_local, shadowShader);
return new PipelineShaderSubsurfaceScattering(prog, shadowsSun, texW, texH);
}finally {
if(shadowShader != null) {
shadowShader.free();
}
}
}
private PipelineShaderSubsurfaceScattering(IProgramGL program, int shadowsSun, float texW, float texH) {
super(program, new Uniforms(shadowsSun, texW, texH));
}
public static class Uniforms implements IProgramUniforms {
public final int shadowsSun;
public final float texW;
public final float texH;
public IUniformGL u_inverseViewMatrix4f;
public IUniformGL u_inverseViewProjMatrix4f;
public IUniformGL u_sunShadowMatrixLOD04f;
public IUniformGL u_sunShadowMatrixLOD14f;
public IUniformGL u_sunShadowMatrixLOD24f;
public IUniformGL u_sunDirection3f;
private Uniforms(int shadowsSun, float texW, float texH) {
this.shadowsSun = shadowsSun;
this.texW = texW;
this.texH = texH;
}
@Override
public void loadUniforms(IProgramGL prog) {
_wglUniform1i(_wglGetUniformLocation(prog, "u_gbufferNormalTexture"), 0);
_wglUniform1i(_wglGetUniformLocation(prog, "u_gbufferDepthTexture"), 1);
_wglUniform1i(_wglGetUniformLocation(prog, "u_gbufferMaterialTexture"), 2);
_wglUniform1i(_wglGetUniformLocation(prog, "u_sunShadowDepthTexture"), 3);
u_inverseViewMatrix4f = _wglGetUniformLocation(prog, "u_inverseViewMatrix4f");
u_inverseViewProjMatrix4f = _wglGetUniformLocation(prog, "u_inverseViewProjMatrix4f");
u_sunShadowMatrixLOD04f = _wglGetUniformLocation(prog, "u_sunShadowMatrixLOD04f");
u_sunShadowMatrixLOD14f = _wglGetUniformLocation(prog, "u_sunShadowMatrixLOD14f");
u_sunShadowMatrixLOD24f = _wglGetUniformLocation(prog, "u_sunShadowMatrixLOD24f");
u_sunDirection3f = _wglGetUniformLocation(prog, "u_sunDirection3f");
}
}
}

View File

@ -93,6 +93,7 @@ public class ShaderSource {
public static final ResourceLocation reproject_ssr_fsh = new ResourceLocation("eagler:glsl/deferred/reproject_ssr.fsh");
public static final ResourceLocation post_fxaa_fsh = new ResourceLocation("eagler:glsl/deferred/post_fxaa.fsh");
public static final ResourceLocation hand_depth_mask_fsh = new ResourceLocation("eagler:glsl/deferred/hand_depth_mask.fsh");
public static final ResourceLocation subsurface_scattering_fsh = new ResourceLocation("eagler:glsl/deferred/subsurface_scattering.fsh");
public static final ResourceLocation core_dynamiclights_vsh = new ResourceLocation("eagler:glsl/dynamiclights/core_dynamiclights.vsh");
public static final ResourceLocation core_dynamiclights_fsh = new ResourceLocation("eagler:glsl/dynamiclights/core_dynamiclights.fsh");

View File

@ -37,7 +37,7 @@ public class PBRMaterialConstants implements IResourceManagerReloadListener {
public final ResourceLocation resourceLocation;
public final Map<String,Integer> spriteNameToMaterialConstants = new HashMap<>();
public int defaultMaterial = 0x00000A77;
public int defaultMaterial = 0xFF000A77;
public PBRMaterialConstants(ResourceLocation resourceLocation) {
this.resourceLocation = resourceLocation;
@ -59,9 +59,14 @@ public class PBRMaterialConstants implements IResourceManagerReloadListener {
continue;
}
String[] cols = line.split(",");
if(cols.length == 4) {
if(cols.length == 4 || cols.length == 5) {
try {
int value = Integer.parseInt(cols[1]) | (Integer.parseInt(cols[2]) << 8) | (Integer.parseInt(cols[3]) << 16);
if(cols.length == 5) {
value |= ((255 - Integer.parseInt(cols[4])) << 24);
}else {
value |= 0xFF000000;
}
if(cols[0].equals("default")) {
defaultMaterial = value;
}else {

View File

@ -20,7 +20,7 @@ import static net.lax1dude.eaglercraft.v1_8.internal.PlatformOpenGL.*;
import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.*;
import net.lax1dude.eaglercraft.v1_8.EagRuntime;
import net.lax1dude.eaglercraft.v1_8.internal.IBufferArrayGL;
import net.lax1dude.eaglercraft.v1_8.internal.IVertexArrayGL;
import net.lax1dude.eaglercraft.v1_8.internal.IBufferGL;
import net.lax1dude.eaglercraft.v1_8.internal.buffer.ByteBuffer;
import net.lax1dude.eaglercraft.v1_8.internal.buffer.FloatBuffer;
@ -49,7 +49,7 @@ public class DynamicLightsAcceleratedEffectRenderer extends AbstractAcceleratedE
private DynamicLightsAccelParticleShader shaderProgram = null;
private IBufferArrayGL vertexArray = null;
private IVertexArrayGL vertexArray = null;
private IBufferGL vertexBuffer = null;
private IBufferGL instancesBuffer = null;
@ -85,7 +85,7 @@ public class DynamicLightsAcceleratedEffectRenderer extends AbstractAcceleratedE
});
verts.flip();
EaglercraftGPU.bindGLBufferArray(vertexArray);
EaglercraftGPU.bindGLVertexArray(vertexArray);
EaglercraftGPU.bindGLArrayBuffer(vertexBuffer);
_wglBufferData(GL_ARRAY_BUFFER, verts, GL_STATIC_DRAW);
@ -149,7 +149,7 @@ public class DynamicLightsAcceleratedEffectRenderer extends AbstractAcceleratedE
_wglUniformMatrix4fv(shaderProgram.uniforms.u_inverseViewMatrix4f, false, buf);
EaglercraftGPU.bindGLArrayBuffer(instancesBuffer);
EaglercraftGPU.bindGLBufferArray(vertexArray);
EaglercraftGPU.bindGLVertexArray(vertexArray);
int p = particleBuffer.position();
int l = particleBuffer.limit();

View File

@ -44,7 +44,7 @@ public class DynamicLightsStateManager {
static int lastTotal = 0;
private static long lastTick = 0l;
public static final void enableDynamicLightsRender() {
public static void enableDynamicLightsRender() {
if(bucketLoader == null) {
bucketLoader = new DynamicLightBucketLoader();
bucketLoader.initialize();
@ -60,11 +60,11 @@ public class DynamicLightsStateManager {
maxListLengthTracker = 0;
}
public static final void bindAcceleratedEffectRenderer(EffectRenderer renderer) {
public static void bindAcceleratedEffectRenderer(EffectRenderer renderer) {
renderer.acceleratedParticleRenderer = accelParticleRenderer;
}
public static final void disableDynamicLightsRender(boolean unloadPipeline) {
public static void disableDynamicLightsRender(boolean unloadPipeline) {
if(bucketLoader != null) {
bucketLoader.destroy();
bucketLoader = null;
@ -82,21 +82,21 @@ public class DynamicLightsStateManager {
maxListLengthTracker = 0;
}
public static final boolean isDynamicLightsRender() {
public static boolean isDynamicLightsRender() {
return bucketLoader != null;
}
public static final boolean isInDynamicLightsPass() {
public static boolean isInDynamicLightsPass() {
return GlStateManager.isExtensionPipeline() && bucketLoader != null;
}
public static final void reportForwardRenderObjectPosition(int centerX, int centerY, int centerZ) {
public static void reportForwardRenderObjectPosition(int centerX, int centerY, int centerZ) {
if(bucketLoader != null) {
bucketLoader.bindLightSourceBucket(centerX, centerY, centerZ, 0);
}
}
public static final void reportForwardRenderObjectPosition2(float x, float y, float z) {
public static void reportForwardRenderObjectPosition2(float x, float y, float z) {
if(bucketLoader != null) {
float posX = (float)((x + TileEntityRendererDispatcher.staticPlayerX) - (MathHelper.floor_double(TileEntityRendererDispatcher.staticPlayerX / 16.0) << 4));
float posY = (float)((y + TileEntityRendererDispatcher.staticPlayerY) - (MathHelper.floor_double(TileEntityRendererDispatcher.staticPlayerY / 16.0) << 4));
@ -105,7 +105,7 @@ public class DynamicLightsStateManager {
}
}
public static final void renderDynamicLight(String lightName, double posX, double posY, double posZ, float radius) {
public static void renderDynamicLight(String lightName, double posX, double posY, double posZ, float radius) {
if(bucketLoader != null) {
DynamicLightInstance dl;
if(instancePoolIndex < lightInstancePool.size()) {
@ -119,7 +119,7 @@ public class DynamicLightsStateManager {
}
}
public static final void clearRenderList() {
public static void clearRenderList() {
if(instancePoolIndex > maxListLengthTracker) {
maxListLengthTracker = instancePoolIndex;
}
@ -127,7 +127,7 @@ public class DynamicLightsStateManager {
instancePoolIndex = 0;
}
public static final void commitLightSourceBuckets(double renderPosX, double renderPosY, double renderPosZ) {
public static void commitLightSourceBuckets(double renderPosX, double renderPosY, double renderPosZ) {
lastTotal = lightRenderList.size();
if(bucketLoader != null) {
bucketLoader.clearBuckets();
@ -149,12 +149,12 @@ public class DynamicLightsStateManager {
clearRenderList();
}
public static final void setupInverseViewMatrix() {
public static void setupInverseViewMatrix() {
Matrix4f.invert(GlStateManager.getModelViewReference(), inverseViewMatrix);
inverseViewMatrixSerial = GlStateManager.getModelViewSerial();
}
private static final void updateTimers() {
private static void updateTimers() {
long millis = EagRuntime.steadyTimeMillis();
if(millis - lastTick > 5000l) {
lastTick = millis;
@ -169,7 +169,7 @@ public class DynamicLightsStateManager {
}
}
public static final void destroyAll() {
public static void destroyAll() {
lightInstancePool = new ArrayList<>();
}

View File

@ -27,6 +27,7 @@ import java.util.Map;
import java.util.Map.Entry;
import net.lax1dude.eaglercraft.v1_8.ArrayUtils;
import net.lax1dude.eaglercraft.v1_8.ClientUUIDLoadingCache;
import net.lax1dude.eaglercraft.v1_8.EagRuntime;
import net.lax1dude.eaglercraft.v1_8.EagUtils;
import net.lax1dude.eaglercraft.v1_8.EaglerInputStream;
@ -83,6 +84,7 @@ public class ConnectionHandshake {
try {
EaglerProfile.clearServerSkinOverride();
PauseMenuCustomizeState.reset();
ClientUUIDLoadingCache.resetFlags();
pluginVersion = null;
pluginBrand = null;
protocolVersion = -1;

View File

@ -19,6 +19,7 @@ package net.lax1dude.eaglercraft.v1_8.sp.ipc;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
public class IPCPacket15Crashed implements IPCPacketBase {
@ -35,12 +36,17 @@ public class IPCPacket15Crashed implements IPCPacketBase {
@Override
public void deserialize(DataInput bin) throws IOException {
crashReport = bin.readUTF();
int len = bin.readInt();
byte[] bytes = new byte[len];
bin.readFully(bytes);
crashReport = new String(bytes, StandardCharsets.UTF_8);
}
@Override
public void serialize(DataOutput bin) throws IOException {
bin.writeUTF(crashReport);
byte[] bytes = crashReport.getBytes(StandardCharsets.UTF_8);
bin.writeInt(bytes.length);
bin.write(bytes);
}
@Override
@ -50,7 +56,7 @@ public class IPCPacket15Crashed implements IPCPacketBase {
@Override
public int size() {
return IPCPacketBase.strLen(crashReport);
return IPCPacketBase.strLen(crashReport) + 2;
}
}

View File

@ -66,6 +66,7 @@ public class RelayQueryImpl implements RelayQuery {
try {
connectionOpenedAt = EagRuntime.steadyTimeMillis();
s = PlatformNetworking.openWebSocketUnsafe(uri);
s.setEnableStringFrames(false);
}catch(Throwable t) {
connectionOpenedAt = 0l;
sock = null;
@ -79,10 +80,6 @@ public class RelayQueryImpl implements RelayQuery {
@Override
public void update() {
if(sock == null) return;
if(sock.availableStringFrames() > 0) {
logger.warn("[{}] discarding {} string frames recieved on a binary connection", uri, sock.availableStringFrames());
sock.clearStringFrames();
}
List<IWebSocketFrame> frames = sock.getNextBinaryFrames();
if(frames != null) {
for(int i = 0, l = frames.size(); i < l; ++i) {

View File

@ -51,6 +51,7 @@ public class RelayServerSocketImpl implements RelayServerSocket {
IWebSocketClient s;
try {
s = PlatformNetworking.openWebSocketUnsafe(uri);
s.setEnableStringFrames(false);
}catch(Throwable t) {
exceptions.add(t);
sock = null;
@ -63,10 +64,6 @@ public class RelayServerSocketImpl implements RelayServerSocket {
@Override
public void update() {
if(sock == null) return;
if(sock.availableStringFrames() > 0) {
logger.warn("[{}] discarding {} string frames recieved on a binary connection", uri, sock.availableStringFrames());
sock.clearStringFrames();
}
List<IWebSocketFrame> frames = sock.getNextBinaryFrames();
if(frames != null) {
for(int i = 0, l = frames.size(); i < l; ++i) {

View File

@ -62,6 +62,7 @@ public class RelayWorldsQueryImpl implements RelayWorldsQuery {
try {
openedAt = EagRuntime.steadyTimeMillis();
s = PlatformNetworking.openWebSocketUnsafe(uri);
s.setEnableStringFrames(false);
}catch(Throwable t) {
sock = null;
failed = true;
@ -73,10 +74,6 @@ public class RelayWorldsQueryImpl implements RelayWorldsQuery {
@Override
public void update() {
if(sock == null) return;
if(sock.availableStringFrames() > 0) {
logger.warn("[{}] discarding {} string frames recieved on a binary connection", uri, sock.availableStringFrames());
sock.clearStringFrames();
}
List<IWebSocketFrame> frames = sock.getNextBinaryFrames();
if(frames != null) {
for(int i = 0, l = frames.size(); i < l; ++i) {

View File

@ -87,7 +87,8 @@ public class EaglerIntegratedServerWorker {
}
}
}
if(ServerPlatformSingleplayer.isTabAboutToCloseWASM() && !isServerStopped()) {
if (!ServerPlatformSingleplayer.isSingleThreadMode() && ServerPlatformSingleplayer.isTabAboutToCloseWASM()
&& !isServerStopped()) {
logger.info("Autosaving worlds because the tab is about to close!");
currentProcess.getConfigurationManager().saveAllPlayerData();
currentProcess.saveAllWorlds(false);

View File

@ -65,15 +65,15 @@ public class Config {
}
public static boolean isTreesFancy() {
return gameSettings.fancyGraphics;
return gameSettings.fancyGraphics || gameSettings.shaders;
}
public static boolean isTreesSmart() {
return gameSettings.fancyGraphics && gameSettings.smartLeavesOF;
return (gameSettings.fancyGraphics || gameSettings.shaders) && gameSettings.smartLeavesOF;
}
public static boolean isCullFacesLeaves() {
return !gameSettings.fancyGraphics;
return !gameSettings.fancyGraphics || gameSettings.shaders;
}
public static boolean isCustomItems() {