Update #48 - Added some features from OptiFine

This commit is contained in:
lax1dude
2025-01-24 18:39:36 -08:00
parent 1f0d593a8c
commit e83a912e38
1056 changed files with 17706 additions and 898 deletions

View File

@ -246,6 +246,7 @@ public class EaglercraftGPU {
public static final 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) {
_wglTexImage2D(target, level, internalFormat, w, h, unused, format, type, pixels);
}else {
@ -256,6 +257,7 @@ public class EaglercraftGPU {
public static final 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) {
_wglTexImage2D(target, level, internalFormat, w, h, unused, format, type, pixels);
}else {
@ -270,6 +272,7 @@ public class EaglercraftGPU {
}
public static final 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);
}else {
@ -914,7 +917,6 @@ public class EaglercraftGPU {
PlatformOpenGL.enterVAOEmulationHook();
GLSLHeader.init();
DrawUtils.init();
SpriteLevelMixer.initialize();
if(instancingCapable) {
InstancedFontRenderer.initialize();
InstancedParticleRenderer.initialize();
@ -928,7 +930,6 @@ public class EaglercraftGPU {
public static final void destroyCache() {
GLSLHeader.destroy();
DrawUtils.destroy();
SpriteLevelMixer.destroy();
InstancedFontRenderer.destroy();
InstancedParticleRenderer.destroy();
EffectPipelineFXAA.destroy();

View File

@ -1,11 +1,13 @@
package net.lax1dude.eaglercraft.v1_8.opengl;
import net.lax1dude.eaglercraft.v1_8.internal.ITextureGL;
import net.lax1dude.eaglercraft.v1_8.internal.buffer.FloatBuffer;
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
import net.lax1dude.eaglercraft.v1_8.vector.Matrix4f;
import net.lax1dude.eaglercraft.v1_8.vector.Vector3f;
import net.lax1dude.eaglercraft.v1_8.vector.Vector4f;
import net.minecraft.util.MathHelper;
import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.*;
import static net.lax1dude.eaglercraft.v1_8.internal.PlatformOpenGL.*;
@ -159,8 +161,8 @@ public class GlStateManager {
static final Matrix4f[][] textureMatrixStack = new Matrix4f[8][8];
static final int[][] textureMatrixStackAccessSerial = new int[8][8];
static int[] textureMatrixAccessSerial = new int[8];
static int[] textureMatrixStackPointer = new int[8];
static final int[] textureMatrixAccessSerial = new int[8];
static final int[] textureMatrixStackPointer = new int[8];
static boolean stateUseExtensionPipeline = false;
@ -821,6 +823,32 @@ public class GlStateManager {
}
}
private static Matrix4f getMatrixIncr() {
Matrix4f mat;
int _i, _j;
switch(stateMatrixMode) {
case GL_MODELVIEW:
_j = modelMatrixStackPointer;
mat = modelMatrixStack[_j];
modelMatrixStackAccessSerial[_j] = ++modelMatrixAccessSerial;
break;
case GL_PROJECTION:
_j = projectionMatrixStackPointer;
mat = projectionMatrixStack[_j];
projectionMatrixStackAccessSerial[_j] = ++projectionMatrixAccessSerial;
break;
case GL_TEXTURE:
_i = activeTexture;
_j = textureMatrixStackPointer[_i];
mat = textureMatrixStack[_i][_j];
textureMatrixStackAccessSerial[_i][_j] = ++textureCoordsAccessSerial[_i];
break;
default:
throw new IllegalStateException();
}
return mat;
}
public static final void getFloat(int pname, float[] params) {
switch(pname) {
case GL_MODELVIEW_MATRIX:
@ -854,24 +882,7 @@ public class GlStateManager {
}
public static final void ortho(double left, double right, double bottom, double top, double zNear, double zFar) {
Matrix4f matrix;
switch(stateMatrixMode) {
case GL_MODELVIEW:
matrix = modelMatrixStack[modelMatrixStackPointer];
modelMatrixStackAccessSerial[modelMatrixStackPointer] = ++modelMatrixAccessSerial;
break;
case GL_PROJECTION:
default:
matrix = projectionMatrixStack[projectionMatrixStackPointer];
projectionMatrixStackAccessSerial[projectionMatrixStackPointer] = ++projectionMatrixAccessSerial;
break;
case GL_TEXTURE:
int ptr = textureMatrixStackPointer[activeTexture];
matrix = textureMatrixStack[activeTexture][ptr];
textureMatrixStackAccessSerial[activeTexture][textureMatrixStackPointer[activeTexture]] =
++textureMatrixAccessSerial[activeTexture];
break;
}
Matrix4f matrix = getMatrixIncr();
paramMatrix.m00 = 2.0f / (float)(right - left);
paramMatrix.m01 = 0.0f;
paramMatrix.m02 = 0.0f;
@ -894,169 +905,200 @@ 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) {
paramVector.x = x;
paramVector.y = y;
paramVector.z = z;
switch(stateMatrixMode) {
case GL_MODELVIEW:
default:
modelMatrixStack[modelMatrixStackPointer].rotate(angle * toRad, paramVector);
modelMatrixStackAccessSerial[modelMatrixStackPointer] = ++modelMatrixAccessSerial;
break;
case GL_PROJECTION:
projectionMatrixStack[projectionMatrixStackPointer].rotate(angle * toRad, paramVector);
projectionMatrixStackAccessSerial[projectionMatrixStackPointer] = ++projectionMatrixAccessSerial;
break;
case GL_TEXTURE:
int ptr = textureMatrixStackPointer[activeTexture];
textureMatrixStack[activeTexture][ptr].rotate(angle * toRad, paramVector);
textureMatrixStackAccessSerial[activeTexture][textureMatrixStackPointer[activeTexture]] =
++textureMatrixAccessSerial[activeTexture];
break;
Matrix4f matrix = getMatrixIncr();
if(x == 0.0f) {
if(y == 0.0f) {
if(z == 1.0f || z == -1.0f) {
_glRotatefZ(matrix, toRad * angle * z);
return;
}
}else if((y == 1.0f || y == -1.0f) && z == 0.0f) {
_glRotatefY(matrix, toRad * angle * y);
return;
}
}else if((x == 1.0f || x == -1.0f) && y == 0.0f && z == 0.0f) {
_glRotatefX(matrix, toRad * angle * x);
return;
}
_glRotatef(matrix, toRad * angle, x, y, z);
}
public static final 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) {
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) {
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) {
Matrix4f matrix = getMatrixIncr();
if(z != 0.0f) _glRotatefZ(matrix, z);
if(y != 0.0f) _glRotatefY(matrix, y);
if(x != 0.0f) _glRotatefX(matrix, x);
}
private static void _glRotatefX(Matrix4f mat, float angle) {
float sin = MathHelper.sin(angle);
float cos = MathHelper.cos(angle);
float lm10 = mat.m10, lm11 = mat.m11, lm12 = mat.m12, lm13 = mat.m13, lm20 = mat.m20, lm21 = mat.m21,
lm22 = mat.m22, lm23 = mat.m23;
mat.m20 = lm10 * -sin + lm20 * cos;
mat.m21 = lm11 * -sin + lm21 * cos;
mat.m22 = lm12 * -sin + lm22 * cos;
mat.m23 = lm13 * -sin + lm23 * cos;
mat.m10 = lm10 * cos + lm20 * sin;
mat.m11 = lm11 * cos + lm21 * sin;
mat.m12 = lm12 * cos + lm22 * sin;
mat.m13 = lm13 * cos + lm23 * sin;
}
private static void _glRotatefY(Matrix4f mat, float angle) {
float sin = MathHelper.sin(angle);
float cos = MathHelper.cos(angle);
float nm00 = mat.m00 * cos + mat.m20 * -sin;
float nm01 = mat.m01 * cos + mat.m21 * -sin;
float nm02 = mat.m02 * cos + mat.m22 * -sin;
float nm03 = mat.m03 * cos + mat.m23 * -sin;
mat.m20 = mat.m00 * sin + mat.m20 * cos;
mat.m21 = mat.m01 * sin + mat.m21 * cos;
mat.m22 = mat.m02 * sin + mat.m22 * cos;
mat.m23 = mat.m03 * sin + mat.m23 * cos;
mat.m00 = nm00;
mat.m01 = nm01;
mat.m02 = nm02;
mat.m03 = nm03;
}
private static void _glRotatefZ(Matrix4f mat, float angle) {
float dirX = MathHelper.sin(angle);
float dirY = MathHelper.cos(angle);
float nm00 = mat.m00 * dirY + mat.m10 * dirX;
float nm01 = mat.m01 * dirY + mat.m11 * dirX;
float nm02 = mat.m02 * dirY + mat.m12 * dirX;
float nm03 = mat.m03 * dirY + mat.m13 * dirX;
mat.m10 = mat.m00 * -dirX + mat.m10 * dirY;
mat.m11 = mat.m01 * -dirX + mat.m11 * dirY;
mat.m12 = mat.m02 * -dirX + mat.m12 * dirY;
mat.m13 = mat.m03 * -dirX + mat.m13 * dirY;
mat.m00 = nm00;
mat.m01 = nm01;
mat.m02 = nm02;
mat.m03 = nm03;
}
private static void _glRotatef(Matrix4f mat, float angle, float x, float y, float z) {
float s = MathHelper.sin(angle);
float c = MathHelper.cos(angle);
float C = 1.0f - c;
float xx = x * x, xy = x * y, xz = x * z;
float yy = y * y, yz = y * z;
float zz = z * z;
float rm00 = xx * C + c;
float rm01 = xy * C + z * s;
float rm02 = xz * C - y * s;
float rm10 = xy * C - z * s;
float rm11 = yy * C + c;
float rm12 = yz * C + x * s;
float rm20 = xz * C + y * s;
float rm21 = yz * C - x * s;
float rm22 = zz * C + c;
float nm00 = mat.m00 * rm00 + mat.m10 * rm01 + mat.m20 * rm02;
float nm01 = mat.m01 * rm00 + mat.m11 * rm01 + mat.m21 * rm02;
float nm02 = mat.m02 * rm00 + mat.m12 * rm01 + mat.m22 * rm02;
float nm03 = mat.m03 * rm00 + mat.m13 * rm01 + mat.m23 * rm02;
float nm10 = mat.m00 * rm10 + mat.m10 * rm11 + mat.m20 * rm12;
float nm11 = mat.m01 * rm10 + mat.m11 * rm11 + mat.m21 * rm12;
float nm12 = mat.m02 * rm10 + mat.m12 * rm11 + mat.m22 * rm12;
float nm13 = mat.m03 * rm10 + mat.m13 * rm11 + mat.m23 * rm12;
mat.m20 = mat.m00 * rm20 + mat.m10 * rm21 + mat.m20 * rm22;
mat.m21 = mat.m01 * rm20 + mat.m11 * rm21 + mat.m21 * rm22;
mat.m22 = mat.m02 * rm20 + mat.m12 * rm21 + mat.m22 * rm22;
mat.m23 = mat.m03 * rm20 + mat.m13 * rm21 + mat.m23 * rm22;
mat.m00 = nm00;
mat.m01 = nm01;
mat.m02 = nm02;
mat.m03 = nm03;
mat.m10 = nm10;
mat.m11 = nm11;
mat.m12 = nm12;
mat.m13 = nm13;
}
public static final void scale(float x, float y, float z) {
paramVector.x = x;
paramVector.y = y;
paramVector.z = z;
switch(stateMatrixMode) {
case GL_MODELVIEW:
default:
modelMatrixStack[modelMatrixStackPointer].scale(paramVector);
modelMatrixStackAccessSerial[modelMatrixStackPointer] = ++modelMatrixAccessSerial;
break;
case GL_PROJECTION:
projectionMatrixStack[projectionMatrixStackPointer].scale(paramVector);
projectionMatrixStackAccessSerial[projectionMatrixStackPointer] = ++projectionMatrixAccessSerial;
break;
case GL_TEXTURE:
int ptr = textureMatrixStackPointer[activeTexture];
textureMatrixStack[activeTexture][ptr].scale(paramVector);
textureMatrixStackAccessSerial[activeTexture][textureMatrixStackPointer[activeTexture]] =
++textureMatrixAccessSerial[activeTexture];
break;
}
Matrix4f matrix = getMatrixIncr();
matrix.m00 *= x;
matrix.m01 *= x;
matrix.m02 *= x;
matrix.m03 *= x;
matrix.m10 *= y;
matrix.m11 *= y;
matrix.m12 *= y;
matrix.m13 *= y;
matrix.m20 *= z;
matrix.m21 *= z;
matrix.m22 *= z;
matrix.m23 *= z;
}
public static final void scale(double x, double y, double z) {
paramVector.x = (float)x;
paramVector.y = (float)y;
paramVector.z = (float)z;
switch(stateMatrixMode) {
case GL_MODELVIEW:
default:
modelMatrixStack[modelMatrixStackPointer].scale(paramVector);
modelMatrixStackAccessSerial[modelMatrixStackPointer] = ++modelMatrixAccessSerial;
break;
case GL_PROJECTION:
projectionMatrixStack[projectionMatrixStackPointer].scale(paramVector);
projectionMatrixStackAccessSerial[projectionMatrixStackPointer] = ++projectionMatrixAccessSerial;
break;
case GL_TEXTURE:
int ptr = textureMatrixStackPointer[activeTexture];
textureMatrixStack[activeTexture][ptr].scale(paramVector);
textureMatrixStackAccessSerial[activeTexture][textureMatrixStackPointer[activeTexture]] =
++textureMatrixAccessSerial[activeTexture];
break;
}
Matrix4f matrix = getMatrixIncr();
matrix.m00 *= x;
matrix.m01 *= x;
matrix.m02 *= x;
matrix.m03 *= x;
matrix.m10 *= y;
matrix.m11 *= y;
matrix.m12 *= y;
matrix.m13 *= y;
matrix.m20 *= z;
matrix.m21 *= z;
matrix.m22 *= z;
matrix.m23 *= z;
}
public static final void translate(float x, float y, float z) {
paramVector.x = x;
paramVector.y = y;
paramVector.z = z;
switch(stateMatrixMode) {
case GL_MODELVIEW:
default:
modelMatrixStack[modelMatrixStackPointer].translate(paramVector);
modelMatrixStackAccessSerial[modelMatrixStackPointer] = ++modelMatrixAccessSerial;
break;
case GL_PROJECTION:
projectionMatrixStack[projectionMatrixStackPointer].translate(paramVector);
projectionMatrixStackAccessSerial[projectionMatrixStackPointer] = ++projectionMatrixAccessSerial;
break;
case GL_TEXTURE:
int ptr = textureMatrixStackPointer[activeTexture];
textureMatrixStack[activeTexture][ptr].translate(paramVector);
textureMatrixStackAccessSerial[activeTexture][textureMatrixStackPointer[activeTexture]] =
++textureMatrixAccessSerial[activeTexture];
break;
}
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;
matrix.m32 = matrix.m02 * x + matrix.m12 * y + matrix.m22 * z + matrix.m32;
matrix.m33 = matrix.m03 * x + matrix.m13 * y + matrix.m23 * z + matrix.m33;
}
public static final void translate(double x, double y, double z) {
paramVector.x = (float)x;
paramVector.y = (float)y;
paramVector.z = (float)z;
switch(stateMatrixMode) {
case GL_MODELVIEW:
default:
modelMatrixStack[modelMatrixStackPointer].translate(paramVector);
modelMatrixStackAccessSerial[modelMatrixStackPointer] = ++modelMatrixAccessSerial;
break;
case GL_PROJECTION:
projectionMatrixStack[projectionMatrixStackPointer].translate(paramVector);
projectionMatrixStackAccessSerial[projectionMatrixStackPointer] = ++projectionMatrixAccessSerial;
break;
case GL_TEXTURE:
int ptr = textureMatrixStackPointer[activeTexture];
textureMatrixStack[activeTexture][ptr].translate(paramVector);
textureMatrixStackAccessSerial[activeTexture][textureMatrixStackPointer[activeTexture]] =
++textureMatrixAccessSerial[activeTexture];
break;
}
float _x = (float)x;
float _y = (float)y;
float _z = (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;
matrix.m32 = matrix.m02 * _x + matrix.m12 * _y + matrix.m22 * _z + matrix.m32;
matrix.m33 = matrix.m03 * _x + matrix.m13 * _y + matrix.m23 * _z + matrix.m33;
}
private static final Matrix4f paramMatrix = new Matrix4f();
public static final void multMatrix(float[] matrix) {
Matrix4f modeMatrix;
switch(stateMatrixMode) {
case GL_MODELVIEW:
default:
modeMatrix = modelMatrixStack[modelMatrixStackPointer];
modelMatrixStackAccessSerial[modelMatrixStackPointer] = ++modelMatrixAccessSerial;
break;
case GL_PROJECTION:
modeMatrix = projectionMatrixStack[projectionMatrixStackPointer];
projectionMatrixStackAccessSerial[projectionMatrixStackPointer] = ++projectionMatrixAccessSerial;
break;
case GL_TEXTURE:
int ptr = textureMatrixStackPointer[activeTexture];
modeMatrix = textureMatrixStack[activeTexture][ptr];
textureMatrixStackAccessSerial[activeTexture][textureMatrixStackPointer[activeTexture]] =
++textureMatrixAccessSerial[activeTexture];
break;
}
paramMatrix.load(matrix);
Matrix4f.mul(modeMatrix, paramMatrix, modeMatrix);
Matrix4f mat = getMatrixIncr();
Matrix4f.mul(mat, paramMatrix, mat);
}
public static final void multMatrix(Matrix4f matrix) {
Matrix4f modeMatrix;
switch(stateMatrixMode) {
case GL_MODELVIEW:
default:
modeMatrix = modelMatrixStack[modelMatrixStackPointer];
modelMatrixStackAccessSerial[modelMatrixStackPointer] = ++modelMatrixAccessSerial;
break;
case GL_PROJECTION:
modeMatrix = projectionMatrixStack[projectionMatrixStackPointer];
projectionMatrixStackAccessSerial[projectionMatrixStackPointer] = ++projectionMatrixAccessSerial;
break;
case GL_TEXTURE:
int ptr = textureMatrixStackPointer[activeTexture];
modeMatrix = textureMatrixStack[activeTexture][ptr];
textureMatrixStackAccessSerial[activeTexture][textureMatrixStackPointer[activeTexture]] =
++textureMatrixAccessSerial[activeTexture];
break;
}
Matrix4f.mul(modeMatrix, matrix, modeMatrix);
Matrix4f mat = getMatrixIncr();
Matrix4f.mul(mat, matrix, mat);
}
public static final void color(float colorRed, float colorGreen, float colorBlue, float colorAlpha) {
@ -1088,24 +1130,7 @@ public class GlStateManager {
}
public static final void gluPerspective(float fovy, float aspect, float zNear, float zFar) {
Matrix4f matrix;
switch(stateMatrixMode) {
case GL_MODELVIEW:
matrix = modelMatrixStack[modelMatrixStackPointer];
modelMatrixStackAccessSerial[modelMatrixStackPointer] = ++modelMatrixAccessSerial;
break;
case GL_PROJECTION:
default:
matrix = projectionMatrixStack[projectionMatrixStackPointer];
projectionMatrixStackAccessSerial[projectionMatrixStackPointer] = ++projectionMatrixAccessSerial;
break;
case GL_TEXTURE:
int ptr = textureMatrixStackPointer[activeTexture];
matrix = textureMatrixStack[activeTexture][ptr];
textureMatrixStackAccessSerial[activeTexture][textureMatrixStackPointer[activeTexture]] =
++textureMatrixAccessSerial[activeTexture];
break;
}
Matrix4f matrix = getMatrixIncr();
float cotangent = (float) Math.cos(fovy * toRad * 0.5f) / (float) Math.sin(fovy * toRad * 0.5f);
paramMatrix.m00 = cotangent / aspect;
paramMatrix.m01 = 0.0f;
@ -1127,24 +1152,7 @@ public class GlStateManager {
}
public static final void gluLookAt(Vector3f eye, Vector3f center, Vector3f up) {
Matrix4f matrix;
switch(stateMatrixMode) {
case GL_MODELVIEW:
matrix = modelMatrixStack[modelMatrixStackPointer];
modelMatrixStackAccessSerial[modelMatrixStackPointer] = ++modelMatrixAccessSerial;
break;
case GL_PROJECTION:
default:
matrix = projectionMatrixStack[projectionMatrixStackPointer];
projectionMatrixStackAccessSerial[projectionMatrixStackPointer] = ++projectionMatrixAccessSerial;
break;
case GL_TEXTURE:
int ptr = textureMatrixStackPointer[activeTexture];
matrix = textureMatrixStack[activeTexture][ptr];
textureMatrixStackAccessSerial[activeTexture][textureMatrixStackPointer[activeTexture]] =
++textureMatrixAccessSerial[activeTexture];
break;
}
Matrix4f matrix = getMatrixIncr();
float x = center.x - eye.x;
float y = center.y - eye.y;
float z = center.z - eye.z;
@ -1262,4 +1270,18 @@ public class GlStateManager {
public static void recompileShaders() {
FixedFunctionPipeline.flushCache();
}
public static int getBoundTexture() {
return boundTexture[activeTexture];
}
static void setTextureCachedSize(int target, int w, int h) {
if(target == GL_TEXTURE_2D) {
ITextureGL tex = EaglercraftGPU.getNativeTexture(boundTexture[activeTexture]);
if(tex != null) {
tex.setCacheSize(w, h);
}
}
}
}

View File

@ -1,6 +1,9 @@
package net.lax1dude.eaglercraft.v1_8.opengl;
import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.*;
import java.util.List;
import static net.lax1dude.eaglercraft.v1_8.internal.PlatformOpenGL.*;
import net.lax1dude.eaglercraft.v1_8.EagRuntime;
@ -10,10 +13,11 @@ import net.lax1dude.eaglercraft.v1_8.internal.IUniformGL;
import net.lax1dude.eaglercraft.v1_8.internal.buffer.FloatBuffer;
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
import net.lax1dude.eaglercraft.v1_8.opengl.VSHInputLayoutParser.ShaderInput;
import net.lax1dude.eaglercraft.v1_8.vector.Matrix3f;
/**
* Copyright (c) 2022-2023 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
@ -39,7 +43,8 @@ public class SpriteLevelMixer {
private static IUniformGL u_textureLod1f = null;
private static IUniformGL u_blendFactor4f = null;
private static IUniformGL u_blendBias4f = null;
private static IUniformGL u_matrixTransform = null;
private static IUniformGL u_srcCoords4f = null;
private static IUniformGL u_dstCoords4f = null;
private static FloatBuffer matrixCopyBuffer = null;
@ -55,12 +60,15 @@ public class SpriteLevelMixer {
private static float biasColorB = 0.0f;
private static float biasColorA = 0.0f;
private static boolean matrixChanged = true;
private static final Matrix3f transformMatrix = new Matrix3f();
private static float srcViewW = 100.0f;
private static float srcViewH = 100.0f;
private static float dstViewW = 50.0f;
private static float dstViewH = 50.0f;
private static final Matrix3f identityMatrix = new Matrix3f();
static void initialize() {
static void initialize(IShaderGL vertexShader, List<ShaderInput> vshSourceLayout) {
String fragmentSource = EagRuntime.getRequiredResourceString(fragmentShaderPath);
IShaderGL frag = _wglCreateShader(GL_FRAGMENT_SHADER);
@ -82,16 +90,16 @@ public class SpriteLevelMixer {
shaderProgram = _wglCreateProgram();
_wglAttachShader(shaderProgram, DrawUtils.vshLocal);
_wglAttachShader(shaderProgram, vertexShader);
_wglAttachShader(shaderProgram, frag);
if(EaglercraftGPU.checkOpenGLESVersion() == 200) {
VSHInputLayoutParser.applyLayout(shaderProgram, DrawUtils.vshLocalLayout);
VSHInputLayoutParser.applyLayout(shaderProgram, vshSourceLayout);
}
_wglLinkProgram(shaderProgram);
_wglDetachShader(shaderProgram, DrawUtils.vshLocal);
_wglDetachShader(shaderProgram, vertexShader);
_wglDetachShader(shaderProgram, frag);
_wglDeleteShader(frag);
@ -115,7 +123,8 @@ public class SpriteLevelMixer {
u_textureLod1f = _wglGetUniformLocation(shaderProgram, "u_textureLod1f");
u_blendFactor4f = _wglGetUniformLocation(shaderProgram, "u_blendFactor4f");
u_blendBias4f = _wglGetUniformLocation(shaderProgram, "u_blendBias4f");
u_matrixTransform = _wglGetUniformLocation(shaderProgram, "u_matrixTransform");
u_srcCoords4f = _wglGetUniformLocation(shaderProgram, "u_srcCoords4f");
u_dstCoords4f = _wglGetUniformLocation(shaderProgram, "u_dstCoords4f");
_wglUniform1i(_wglGetUniformLocation(shaderProgram, "u_inputTexture"), 0);
@ -141,25 +150,31 @@ public class SpriteLevelMixer {
}
}
public static void setIdentityMatrix() {
setMatrix3f(identityMatrix);
public static void srcSize(int w, int h) {
srcViewW = w;
srcViewH = h;
}
public static void setMatrix3f(Matrix3f matrix) {
if(!matrix.equals(transformMatrix)) {
matrixChanged = true;
transformMatrix.load(matrix);
}
public static void dstSize(int w, int h) {
dstViewW = w * 0.5f;
dstViewH = h * 0.5f;
}
public static void drawSprite(float level) {
public static void srcDstSize(int w, int h) {
srcViewW = w;
srcViewH = h;
dstViewW = w * 0.5f;
dstViewH = h * 0.5f;
}
public static void drawSprite(int lvl, int srcX, int srcY, int srcW, int srcH, int dstX, int dstY, int dstW, int dstH) {
EaglercraftGPU.bindGLShaderProgram(shaderProgram);
if(EaglercraftGPU.checkTextureLODCapable()) {
_wglUniform1f(u_textureLod1f, level);
_wglUniform1f(u_textureLod1f, lvl);
}else {
if(level != 0.0f) {
LOGGER.error("Tried to copy from mipmap level {}, but this GPU does not support textureLod!", level);
if(lvl != 0) {
LOGGER.error("Tried to copy from mipmap level {}, but this GPU does not support textureLod!", lvl);
}
_wglUniform1f(u_textureLod1f, 0.0f);
}
@ -174,13 +189,9 @@ public class SpriteLevelMixer {
biasColorChanged = false;
}
if(matrixChanged) {
matrixCopyBuffer.clear();
transformMatrix.store(matrixCopyBuffer);
matrixCopyBuffer.flip();
_wglUniformMatrix3fv(u_matrixTransform, false, matrixCopyBuffer);
matrixChanged = false;
}
_wglUniform4f(u_srcCoords4f, (float)srcX / srcViewW, (float)srcY / srcViewH, (float)srcW / srcViewW, (float)srcH / srcViewH);
_wglUniform4f(u_dstCoords4f, (float) dstX / dstViewW - 1.0f, (float) dstY / dstViewH - 1.0f,
(float) dstW / dstViewW, (float) dstH / dstViewH);
DrawUtils.drawStandardQuad2D();
}
@ -197,7 +208,8 @@ public class SpriteLevelMixer {
u_textureLod1f = null;
u_blendFactor4f = null;
u_blendBias4f = null;
u_matrixTransform = null;
u_srcCoords4f = null;
u_dstCoords4f = null;
}
}

View File

@ -113,6 +113,8 @@ public class TextureCopyUtil {
if(EaglercraftGPU.checkOpenGLESVersion() == 200) {
vshSourceLayout = VSHInputLayoutParser.getShaderInputs(vshSource);
}
SpriteLevelMixer.initialize(vshShader, vshSourceLayout);
}
private static TextureCopyShader compileShader(boolean align, boolean depth) {
@ -283,18 +285,22 @@ public class TextureCopyUtil {
DrawUtils.drawStandardQuad2D();
}
@Deprecated
public static void blitTextureUsingViewports(int srcX, int srcY, int dstX, int dstY, int w, int h) {
blitTextureUsingViewports(0, srcX, srcY, w, h, dstX, dstY, w, h);
}
@Deprecated
public static void blitTextureUsingViewports(int lvl, int srcX, int srcY, int dstX, int dstY, int w, int h) {
blitTextureUsingViewports(lvl, srcX, srcY, w, h, dstX, dstY, w, h);
}
@Deprecated
public static void blitTextureUsingViewports(int srcX, int srcY, int srcW, int srcH, int dstX, int dstY, int dstW, int dstH) {
blitTextureUsingViewports(0, srcX, srcY, srcW, srcH, dstX, dstY, dstW, dstH);
}
@Deprecated
public static void blitTextureUsingViewports(int lvl, int srcX, int srcY, int srcW, int srcH, int dstX, int dstY, int dstW, int dstH) {
TextureCopyShader shaderObj = getShaderObj(isAligned, false);
EaglercraftGPU.bindGLShaderProgram(shaderObj.shaderProgram);
@ -376,18 +382,22 @@ public class TextureCopyUtil {
DrawUtils.drawStandardQuad2D();
}
@Deprecated
public static void blitTextureDepthUsingViewports(int srcX, int srcY, int dstX, int dstY, int w, int h) {
blitTextureDepthUsingViewports(0, srcX, srcY, w, h, dstX, dstY, w, h);
}
@Deprecated
public static void blitTextureDepthUsingViewports(int lvl, int srcX, int srcY, int dstX, int dstY, int w, int h) {
blitTextureDepthUsingViewports(lvl, srcX, srcY, w, h, dstX, dstY, w, h);
}
@Deprecated
public static void blitTextureDepthUsingViewports(int srcX, int srcY, int srcW, int srcH, int dstX, int dstY, int dstW, int dstH) {
blitTextureDepthUsingViewports(0, srcX, srcY, srcW, srcH, dstX, dstY, dstW, dstH);
}
@Deprecated
public static void blitTextureDepthUsingViewports(int lvl, int srcX, int srcY, int srcW, int srcH, int dstX, int dstY, int dstW, int dstH) {
TextureCopyShader shaderObj = getShaderObj(isAligned, true);
EaglercraftGPU.bindGLShaderProgram(shaderObj.shaderProgram);
@ -431,5 +441,6 @@ public class TextureCopyUtil {
textureBlitDepthAligned.destroy();
textureBlitDepthAligned = null;
}
SpriteLevelMixer.destroy();
}
}

View File

@ -12,8 +12,12 @@ 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.vector.Vector3f;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.GLAllocation;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.util.MathHelper;
import net.optifine.render.RenderEnv;
/**
* Copyright (c) 2022-2023 lax1dude, ayunami2000. All Rights Reserved.
@ -50,6 +54,9 @@ public class WorldRenderer {
private boolean hasBeenFreed = false;
private EnumWorldBlockLayer blockLayer = null;
public RenderEnv renderEnv = null;
public WorldRenderer(int bufferSizeIn) {
this.byteBuffer = GLAllocation.createDirectByteBuffer(bufferSizeIn << 2);
this.intBuffer = this.byteBuffer.asIntBuffer();
@ -555,6 +562,20 @@ public class WorldRenderer {
}
public RenderEnv getRenderEnv(IBlockState p_getRenderEnv_1_, BlockPos p_getRenderEnv_2_) {
if (this.renderEnv == null) {
this.renderEnv = new RenderEnv(p_getRenderEnv_1_, p_getRenderEnv_2_);
return this.renderEnv;
} else {
this.renderEnv.reset(p_getRenderEnv_1_, p_getRenderEnv_2_);
return this.renderEnv;
}
}
public EnumWorldBlockLayer getBlockLayer() {
return this.blockLayer;
}
public class State {
private final IntBuffer stateRawBuffer;
private final VertexFormat stateVertexFormat;

View File

@ -2440,6 +2440,15 @@ public class EaglerDeferredPipeline {
GlStateManager.setActiveTexture(GL_TEXTURE10);
GlStateManager.bindTexture(skyIrradianceTexture);
GlStateManager.setActiveTexture(GL_TEXTURE0);
GlStateManager.disableDepth();
GlStateManager.disableBlend();
GlStateManager.depthMask(false);
GlStateManager.bindTexture(envMapSkyTexture);
GlStateManager.viewport(0, 0, 128, 256);
TextureCopyUtil.blitTexture();
GlStateManager.depthMask(true);
GlStateManager.enableBlend();
GlStateManager.enableDepth();
DeferredStateManager.checkGLError("Post: beginDrawEnvMap()");
}
@ -2470,7 +2479,7 @@ public class EaglerDeferredPipeline {
public void beginDrawEnvMapTranslucent() {
DeferredStateManager.checkGLError("Pre: beginDrawEnvMapTranslucent()");
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(GL_ONE, GL_ONE_MINUS_SRC_ALPHA, GL_ONE_MINUS_DST_ALPHA, GL_ONE);
GlStateManager.tryBlendFuncSeparate(GL_ONE, GL_ONE_MINUS_SRC_ALPHA, GL_ZERO, GL_ONE);
bindEnvMapBlockTexture();
DeferredStateManager.checkGLError("Post: beginDrawEnvMapTranslucent()");
}

View File

@ -8,7 +8,6 @@ import com.carrotsearch.hppc.cursors.IntCursor;
import com.google.common.collect.Lists;
import net.lax1dude.eaglercraft.v1_8.HString;
import net.lax1dude.eaglercraft.v1_8.internal.IFramebufferGL;
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
import net.lax1dude.eaglercraft.v1_8.minecraft.EaglerTextureAtlasSprite;
@ -219,7 +218,9 @@ public class EaglerTextureAtlasSpritePBR extends EaglerTextureAtlasSprite {
}
}
public void updateAnimationPBR(IFramebufferGL[] copyColorFramebuffer, IFramebufferGL[] copyMaterialFramebuffer, int materialTexOffset) {
protected IAnimCopyFunction currentAnimUpdaterPBR = null;
public void updateAnimationPBR() {
if(animationCachePBR[0] == null || (!dontAnimateNormals && animationCachePBR[1] == null)
|| (!dontAnimateMaterial && animationCachePBR[2] == null)) {
throw new IllegalStateException("Animation cache for '" + this.iconName + "' was never baked!");
@ -233,9 +234,28 @@ public class EaglerTextureAtlasSpritePBR extends EaglerTextureAtlasSprite {
this.tickCounter = 0;
int k = this.animationMetadata.getFrameIndex(this.frameCounter);
if (i != k && k >= 0 && k < this.frameTextureDataPBR[0].size()) {
animationCachePBR[0].copyFrameLevelsToTex2D(k, this.originX, this.originY, this.width, this.height, copyColorFramebuffer);
if(!dontAnimateNormals) animationCachePBR[1].copyFrameLevelsToTex2D(k, this.originX, this.originY, this.width, this.height, copyMaterialFramebuffer);
if(!dontAnimateMaterial) animationCachePBR[2].copyFrameLevelsToTex2D(k, this.originX, this.originY + materialTexOffset, this.width, this.height, copyMaterialFramebuffer);
currentAnimUpdater = (mapWidth, mapHeight, mapLevel) -> {
animationCachePBR[0].copyFrameToTex2D(k, mapLevel, this.originX >> mapLevel,
this.originY >> mapLevel, this.width >> mapLevel, this.height >> mapLevel, mapWidth,
mapHeight);
};
if(!dontAnimateNormals || !dontAnimateMaterial) {
currentAnimUpdaterPBR = (mapWidth, mapHeight, mapLevel) -> {
if (!dontAnimateNormals)
animationCachePBR[1].copyFrameToTex2D(k, mapLevel, this.originX >> mapLevel,
this.originY >> mapLevel, this.width >> mapLevel, this.height >> mapLevel, mapWidth,
mapHeight);
if (!dontAnimateMaterial)
animationCachePBR[2].copyFrameToTex2D(k, mapLevel, this.originX >> mapLevel,
(this.originY >> mapLevel) + (mapHeight >> 1), this.width >> mapLevel,
this.height >> mapLevel, mapWidth, mapHeight);
};
}else {
currentAnimUpdaterPBR = null;
}
}else {
currentAnimUpdater = null;
currentAnimUpdaterPBR = null;
}
} else if (this.animationMetadata.isInterpolate()) {
float f = 1.0f - (float) this.tickCounter / (float) this.animationMetadata.getFrameTimeSingle(this.frameCounter);
@ -244,9 +264,43 @@ public class EaglerTextureAtlasSpritePBR extends EaglerTextureAtlasSprite {
: this.animationMetadata.getFrameCount();
int k = this.animationMetadata.getFrameIndex((this.frameCounter + 1) % j);
if (i != k && k >= 0 && k < this.frameTextureDataPBR[0].size()) {
animationCachePBR[0].copyInterpolatedFrameLevelsToTex2D(i, k, f, this.originX, this.originY, this.width, this.height, copyColorFramebuffer);
if(!dontAnimateNormals) animationCachePBR[1].copyInterpolatedFrameLevelsToTex2D(i, k, f, this.originX, this.originY, this.width, this.height, copyMaterialFramebuffer);
if(!dontAnimateMaterial) animationCachePBR[2].copyInterpolatedFrameLevelsToTex2D(i, k, f, this.originX, this.originY + materialTexOffset, this.width, this.height, copyMaterialFramebuffer);
currentAnimUpdater = (mapWidth, mapHeight, mapLevel) -> {
animationCachePBR[0].copyInterpolatedFrameToTex2D(i, k, f, mapLevel, this.originX >> mapLevel,
this.originY >> mapLevel, this.width >> mapLevel, this.height >> mapLevel, mapWidth,
mapHeight);
};
if(!dontAnimateNormals || !dontAnimateMaterial) {
currentAnimUpdaterPBR = (mapWidth, mapHeight, mapLevel) -> {
if (!dontAnimateNormals)
animationCachePBR[1].copyInterpolatedFrameToTex2D(i, k, f, mapLevel,
this.originX >> mapLevel, this.originY >> mapLevel, this.width >> mapLevel,
this.height >> mapLevel, mapWidth, mapHeight);
if (!dontAnimateMaterial)
animationCachePBR[2].copyInterpolatedFrameToTex2D(i, k, f, mapLevel,
this.originX >> mapLevel, (this.originY >> mapLevel) + (mapHeight >> 1),
this.width >> mapLevel, this.height >> mapLevel, mapWidth, mapHeight);
};
}else {
currentAnimUpdaterPBR = null;
}
}else {
currentAnimUpdater = null;
currentAnimUpdaterPBR = null;
}
}else {
currentAnimUpdater = null;
currentAnimUpdaterPBR = null;
}
}
public void copyAnimationFramePBR(int pass, int mapWidth, int mapHeight, int mapLevel) {
if(pass == 0) {
if(currentAnimUpdater != null) {
currentAnimUpdater.updateAnimation(mapWidth, mapHeight, mapLevel);
}
}else {
if(currentAnimUpdaterPBR != null) {
currentAnimUpdaterPBR.updateAnimation(mapWidth, mapHeight, mapLevel);
}
}
}
@ -279,7 +333,7 @@ public class EaglerTextureAtlasSpritePBR extends EaglerTextureAtlasSprite {
}
}
public void updateAnimation(IFramebufferGL[] fb) {
public void updateAnimation() {
Throwable t = new UnsupportedOperationException("Cannot call regular updateAnimation in PBR mode, use updateAnimationPBR");
try {
throw t;
@ -288,6 +342,15 @@ public class EaglerTextureAtlasSpritePBR extends EaglerTextureAtlasSprite {
}
}
public void copyAnimationFrame(int mapWidth, int mapHeight, int mapLevel) {
Throwable t = new UnsupportedOperationException("Cannot call regular copyAnimationFrame in PBR mode, use updateAnimationPBR");
try {
throw t;
}catch(Throwable tt) {
logger.error(t);
}
}
protected void resetSprite() {
this.animationMetadata = null;
this.setFramesTextureDataPBR(new List[] { Lists.newArrayList(), Lists.newArrayList(), Lists.newArrayList() });

View File

@ -27,7 +27,7 @@ import net.minecraft.util.ResourceLocation;
*/
public class PBRTextureMapUtils {
public static final ImageData defaultNormalsTexture = new ImageData(1, 1, new int[] { 0 }, true);
public static final ImageData defaultNormalsTexture = new ImageData(1, 1, new int[] { 0xFFFF7F7F }, true);
public static final PBRMaterialConstants blockMaterialConstants = new PBRMaterialConstants(new ResourceLocation("eagler:glsl/deferred/material_block_constants.csv"));
@ -125,13 +125,17 @@ public class PBRTextureMapUtils {
}
}
public static ImageData generateMaterialTextureFor(String iconName) {
public static ImageData generateMaterialTextureFor(String iconName, String iconName2) {
if(iconName.startsWith("minecraft:")) {
iconName = iconName.substring(10);
}
Integer in = blockMaterialConstants.spriteNameToMaterialConstants.get(iconName);
if(in == null) {
return new ImageData(1, 1, new int[] { blockMaterialConstants.defaultMaterial }, true);
if(iconName2 != null) {
return generateMaterialTextureFor(iconName2, null);
}else {
return new ImageData(1, 1, new int[] { blockMaterialConstants.defaultMaterial }, true);
}
}else {
return new ImageData(1, 1, new int[] { in.intValue() }, true);
}
@ -150,8 +154,8 @@ public class PBRTextureMapUtils {
ret[i] = new int[len];
int x, y, s1, s2, s3, s4, c1, c2, c3, c4;
for(int j = 0; j < len; ++j) {
x = (j % len) << 1;
y = (j / len) << 1;
x = (j % lvlW) << 1;
y = (j / lvlW) << 1;
s1 = ret[i - 1][x + y * lvl2W];
s2 = ret[i - 1][x + y * lvl2W + 1];
s3 = ret[i - 1][x + y * lvl2W + lvl2W];

View File

@ -27,7 +27,7 @@ public class TextureClockPBRImpl extends EaglerTextureAtlasSpritePBR {
super(spriteName);
}
public void updateAnimationPBR(IFramebufferGL[] copyColorFramebuffer, IFramebufferGL[] copyMaterialFramebuffer, int materialTexOffset) {
public void updateAnimationPBR() {
if (!this.frameTextureDataPBR[0].isEmpty()) {
Minecraft minecraft = Minecraft.getMinecraft();
double d0 = 0.0;
@ -59,16 +59,32 @@ public class TextureClockPBRImpl extends EaglerTextureAtlasSpritePBR {
if (i != this.frameCounter) {
this.frameCounter = i;
animationCachePBR[0].copyFrameLevelsToTex2D(this.frameCounter, this.originX, this.originY, this.width,
this.height, copyColorFramebuffer);
if (!dontAnimateNormals)
animationCachePBR[1].copyFrameLevelsToTex2D(this.frameCounter, this.originX, this.originY,
this.width, this.height, copyMaterialFramebuffer);
if (!dontAnimateMaterial)
animationCachePBR[2].copyFrameLevelsToTex2D(this.frameCounter, this.originX,
this.originY + materialTexOffset, this.width, this.height, copyMaterialFramebuffer);
currentAnimUpdater = (mapWidth, mapHeight, mapLevel) -> {
animationCachePBR[0].copyFrameToTex2D(this.frameCounter, mapLevel, this.originX >> mapLevel,
this.originY >> mapLevel, this.width >> mapLevel, this.height >> mapLevel, mapWidth,
mapHeight);
};
if(!dontAnimateNormals || !dontAnimateMaterial) {
currentAnimUpdaterPBR = (mapWidth, mapHeight, mapLevel) -> {
if (!dontAnimateNormals)
animationCachePBR[1].copyFrameToTex2D(this.frameCounter, mapLevel, this.originX,
this.originY, this.width, this.height, mapWidth, mapHeight);
if (!dontAnimateMaterial)
animationCachePBR[2].copyFrameToTex2D(this.frameCounter, mapLevel, this.originX >> mapLevel,
(this.originY >> mapLevel) + (mapHeight >> 1), this.width >> mapLevel,
this.height >> mapLevel, mapWidth, mapHeight);
};
}else {
currentAnimUpdaterPBR = null;
}
}else {
currentAnimUpdater = null;
currentAnimUpdaterPBR = null;
}
}else {
currentAnimUpdater = null;
currentAnimUpdaterPBR = null;
}
}

View File

@ -29,18 +29,17 @@ public class TextureCompassPBRImpl extends EaglerTextureAtlasSpritePBR {
super(spriteName);
}
public void updateAnimationPBR(IFramebufferGL[] copyColorFramebuffer, IFramebufferGL[] copyMaterialFramebuffer, int materialOffset) {
public void updateAnimationPBR() {
Minecraft minecraft = Minecraft.getMinecraft();
if (minecraft.theWorld != null && minecraft.thePlayer != null) {
this.updateCompassPBR(minecraft.theWorld, minecraft.thePlayer.posX, minecraft.thePlayer.posZ,
(double) minecraft.thePlayer.rotationYaw, false, copyColorFramebuffer, copyMaterialFramebuffer, materialOffset);
(double) minecraft.thePlayer.rotationYaw, false);
} else {
this.updateCompassPBR((World) null, 0.0, 0.0, 0.0, true, copyColorFramebuffer, copyMaterialFramebuffer, materialOffset);
this.updateCompassPBR((World) null, 0.0, 0.0, 0.0, true);
}
}
public void updateCompassPBR(World worldIn, double playerX, double playerY, double playerZ, boolean noWorld,
IFramebufferGL[] copyColorFramebuffer, IFramebufferGL[] copyMaterialFramebuffer, int materialOffset) {
public void updateCompassPBR(World worldIn, double playerX, double playerY, double playerZ, boolean noWorld) {
if (!this.frameTextureDataPBR[0].isEmpty()) {
double d0 = 0.0;
if (worldIn != null && !noWorld) {
@ -76,15 +75,33 @@ public class TextureCompassPBRImpl extends EaglerTextureAtlasSpritePBR {
if (i != this.frameCounter) {
this.frameCounter = i;
animationCachePBR[0].copyFrameLevelsToTex2D(this.frameCounter, this.originX, this.originY, this.width,
this.height, copyColorFramebuffer);
if (!dontAnimateNormals)
animationCachePBR[1].copyFrameLevelsToTex2D(this.frameCounter, this.originX, this.originY,
this.width, this.height, copyMaterialFramebuffer);
if (!dontAnimateMaterial)
animationCachePBR[2].copyFrameLevelsToTex2D(this.frameCounter, this.originX,
this.originY + materialOffset, this.width, this.height, copyMaterialFramebuffer);
currentAnimUpdater = (mapWidth, mapHeight, mapLevel) -> {
animationCachePBR[0].copyFrameToTex2D(this.frameCounter, mapLevel, this.originX >> mapLevel,
this.originY >> mapLevel, this.width >> mapLevel, this.height >> mapLevel, mapWidth,
mapHeight);
};
if(!dontAnimateNormals || !dontAnimateMaterial) {
currentAnimUpdaterPBR = (mapWidth, mapHeight, mapLevel) -> {
if (!dontAnimateNormals)
animationCachePBR[1].copyFrameToTex2D(this.frameCounter, mapLevel, this.originX >> mapLevel,
this.originY >> mapLevel, this.width >> mapLevel, this.height >> mapLevel, mapWidth,
mapHeight);
if (!dontAnimateMaterial)
animationCachePBR[2].copyFrameToTex2D(this.frameCounter, mapLevel, this.originX >> mapLevel,
(this.originY >> mapLevel) + (mapHeight >> 1), this.width >> mapLevel,
this.height >> mapLevel, mapWidth, mapHeight);
};
}else {
currentAnimUpdaterPBR = null;
}
}else {
currentAnimUpdater = null;
currentAnimUpdaterPBR = null;
}
}else {
currentAnimUpdater = null;
currentAnimUpdaterPBR = null;
}
}