finally nailed the lighting equation, it's now truly mathematically equivalent to opengl 1.3
This commit is contained in:
parent
905c78f043
commit
aaae98eccf
|
@ -37,11 +37,11 @@ dependencies {
|
|||
teavm {
|
||||
|
||||
compileScopes = null;
|
||||
minifying = false;
|
||||
minifying = true;
|
||||
maxTopLevelNames = 10000;
|
||||
properties = null;
|
||||
debugInformationGenerated = false;
|
||||
sourceMapsGenerated = false;
|
||||
sourceMapsGenerated = true;
|
||||
sourceFilesCopied = false;
|
||||
incremental = false;
|
||||
transformers = null;
|
||||
|
|
Binary file not shown.
14394
javascript/classes.js
14394
javascript/classes.js
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
@ -11,7 +11,6 @@ precision highp float;
|
|||
|
||||
uniform mat4 matrix_m;
|
||||
uniform mat4 matrix_p;
|
||||
uniform mat3 matrix_mn;
|
||||
uniform mat4 matrix_t;
|
||||
|
||||
#ifdef CC_VERT
|
||||
|
@ -84,7 +83,6 @@ uniform vec2 texCoordV1;
|
|||
#ifdef CC_lighting
|
||||
uniform vec3 light0Pos;
|
||||
uniform vec3 light1Pos;
|
||||
uniform vec3 invertNormals;
|
||||
uniform vec3 normalUniform;
|
||||
#endif
|
||||
#ifdef CC_fog
|
||||
|
@ -214,7 +212,7 @@ void main(){
|
|||
#else
|
||||
vec3 normal = normalUniform;
|
||||
#endif
|
||||
normal = normalize(matrix_mn * normal);
|
||||
normal = normalize(mat3(matrix_m) * normal);
|
||||
float ins = max(dot(normal, -light0Pos), 0.0) + max(dot(normal, -light1Pos), 0.0);
|
||||
color.rgb *= min((0.4 + ins * 0.6), 1.0);
|
||||
#endif
|
||||
|
|
|
@ -13,6 +13,7 @@ import net.lax1dude.eaglercraft.glemu.vector.Matrix3f;
|
|||
import net.lax1dude.eaglercraft.glemu.vector.Matrix4f;
|
||||
import net.lax1dude.eaglercraft.glemu.vector.Vector3f;
|
||||
import net.lax1dude.eaglercraft.glemu.vector.Vector4f;
|
||||
import net.minecraft.src.RenderItem;
|
||||
|
||||
public class EaglerAdapterGL30 extends EaglerAdapterImpl2 {
|
||||
|
||||
|
@ -217,8 +218,6 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 {
|
|||
private static int matrixMode = GL_MODELVIEW;
|
||||
|
||||
static Matrix4f[] matModelV = new Matrix4f[32];
|
||||
static Matrix4f matNormV = new Matrix4f();
|
||||
static Matrix3f matNormV3 = new Matrix3f();
|
||||
static int matModelPointer = 0;
|
||||
|
||||
static Matrix4f[] matProjV = new Matrix4f[6];
|
||||
|
@ -494,13 +493,18 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 {
|
|||
lightPos1vec.set(-0.2f, 1.0f, 0.7f, 0.0f); lightPos1vec.normalise();
|
||||
Matrix4f.transform(matModelV[matModelPointer], lightPos0vec, lightPos0vec).normalise();
|
||||
Matrix4f.transform(matModelV[matModelPointer], lightPos1vec, lightPos1vec).normalise();
|
||||
|
||||
if(RenderItem.isRenderInProgress) {
|
||||
System.out.println(""+lightPos0vec+" "+lightPos1vec);
|
||||
Thread.dumpStack();
|
||||
}
|
||||
}
|
||||
public static final void flipLightMatrix() {
|
||||
lightPos0vec0.set(lightPos0vec);
|
||||
lightPos1vec0.set(lightPos1vec);
|
||||
lightPos0vec.x = -lightPos0vec.x;
|
||||
lightPos1vec.x = -lightPos1vec.x;
|
||||
lightPos0vec.y = -lightPos0vec.y;
|
||||
lightPos1vec.y = -lightPos1vec.y;
|
||||
lightPos0vec.z = -lightPos0vec.z;
|
||||
lightPos1vec.z = -lightPos1vec.z;
|
||||
}
|
||||
public static final void revertLightMatrix() {
|
||||
lightPos0vec.set(lightPos0vec0);
|
||||
|
@ -979,13 +983,6 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 {
|
|||
s.setTextureMatrix(matTexV[matTexPointer]);
|
||||
if(enableColorMaterial && enableLighting) {
|
||||
s.setNormal(normalX, normalY, normalZ);
|
||||
Matrix4f matNormV_l = matNormV;
|
||||
Matrix3f matNormV3_l = matNormV3;
|
||||
matNormV_l.load(matModelV[matModelPointer]).invert().transpose();
|
||||
matNormV3_l.m00 = matNormV_l.m00; matNormV3_l.m01 = matNormV_l.m01; matNormV3_l.m02 = matNormV_l.m02;
|
||||
matNormV3_l.m10 = matNormV_l.m10; matNormV3_l.m11 = matNormV_l.m11; matNormV3_l.m12 = matNormV_l.m12;
|
||||
matNormV3_l.m20 = matNormV_l.m20; matNormV3_l.m21 = matNormV_l.m21; matNormV3_l.m22 = matNormV_l.m22;
|
||||
s.setModelNormalMatrix(matNormV3_l);
|
||||
s.setLightPositions(lightPos0vec, lightPos1vec);
|
||||
}
|
||||
s.setTex0Coords(tex0X, tex0Y);
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
package net.lax1dude.eaglercraft.glemu;
|
||||
|
||||
import net.lax1dude.eaglercraft.EaglerAdapter;
|
||||
import net.lax1dude.eaglercraft.glemu.vector.Matrix3f;
|
||||
import net.lax1dude.eaglercraft.glemu.vector.Matrix4f;
|
||||
import net.lax1dude.eaglercraft.glemu.vector.Vector2f;
|
||||
import net.lax1dude.eaglercraft.glemu.vector.Vector3f;
|
||||
import net.lax1dude.eaglercraft.glemu.vector.Vector4f;
|
||||
|
||||
import static net.lax1dude.eaglercraft.glemu.EaglerAdapterGL30.*;
|
||||
|
@ -105,7 +103,6 @@ public class FixedFunctionShader {
|
|||
|
||||
private UniformGL u_matrix_m = null;
|
||||
private UniformGL u_matrix_p = null;
|
||||
private UniformGL u_matrix_mn = null;
|
||||
private UniformGL u_matrix_t = null;
|
||||
|
||||
private UniformGL u_fogColor = null;
|
||||
|
@ -218,7 +215,6 @@ public class FixedFunctionShader {
|
|||
_wglUseProgram(globject);
|
||||
|
||||
u_matrix_m = _wglGetUniformLocation(globject, "matrix_m");
|
||||
u_matrix_mn = _wglGetUniformLocation(globject, "matrix_mn");
|
||||
u_matrix_p = _wglGetUniformLocation(globject, "matrix_p");
|
||||
u_matrix_t = _wglGetUniformLocation(globject, "matrix_t");
|
||||
|
||||
|
@ -338,34 +334,15 @@ public class FixedFunctionShader {
|
|||
private float[] modelBuffer = new float[16];
|
||||
private float[] projectionBuffer = new float[16];
|
||||
private float[] textureBuffer = new float[16];
|
||||
private float[] normalModelBuffer = new float[9];
|
||||
|
||||
private Matrix4f modelMatrix = (Matrix4f) new Matrix4f().setZero();
|
||||
private Matrix4f projectionMatrix = (Matrix4f) new Matrix4f().setZero();
|
||||
private Matrix4f textureMatrix = (Matrix4f) new Matrix4f().setZero();
|
||||
private Matrix3f normalModelMatrix = (Matrix3f) new Matrix3f().setZero();
|
||||
private Matrix4f inverseModelMatrix = (Matrix4f) new Matrix4f().setZero();
|
||||
private Vector4f light0Pos = new Vector4f();
|
||||
private Vector4f light1Pos = new Vector4f();
|
||||
private Vector2f anisotropicFix = new Vector2f(0.0f, 0.0f);
|
||||
|
||||
private boolean bound = false;
|
||||
|
||||
private float invertNormalsX = 0.0f;
|
||||
private float invertNormalsY = 0.0f;
|
||||
private float invertNormalsZ = 0.0f;
|
||||
|
||||
public void setInvertNormals(float x, float y, float z) {
|
||||
/*
|
||||
if(invertNormalsX != x || invertNormalsY != y || invertNormalsZ != z) {
|
||||
invertNormalsX = x;
|
||||
invertNormalsY = y;
|
||||
invertNormalsZ = z;
|
||||
_wglUniform3f(u_invertNormals, x, y, z);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
public void setAnisotropicFix(float x, float y) {
|
||||
if(anisotropicFix.x != x || anisotropicFix.y != y) {
|
||||
anisotropicFix.x = x;
|
||||
|
@ -385,12 +362,6 @@ public class FixedFunctionShader {
|
|||
}
|
||||
}
|
||||
}
|
||||
public void setModelNormalMatrix(Matrix3f mat) {
|
||||
if(!mat.equals(normalModelMatrix)) {
|
||||
normalModelMatrix.load(mat).store(normalModelBuffer);
|
||||
_wglUniformMat3fv(u_matrix_mn, normalModelBuffer);
|
||||
}
|
||||
}
|
||||
public void setProjectionMatrix(Matrix4f mat) {
|
||||
if(!mat.equals(projectionMatrix)) {
|
||||
projectionMatrix.load(mat).store(projectionBuffer);
|
||||
|
|
|
@ -67,7 +67,7 @@ public class ItemRenderer {
|
|||
float var9 = var4.getMaxV();
|
||||
float var10 = 0.0F;
|
||||
float var11 = 0.3F;
|
||||
RenderHelper.enableStandardItemLighting2();
|
||||
EaglerAdapter.flipLightMatrix();
|
||||
EaglerAdapter.glEnable(EaglerAdapter.GL_RESCALE_NORMAL);
|
||||
EaglerAdapter.glTranslatef(-var10, -var11, 0.0F);
|
||||
float var12 = 1.5F;
|
||||
|
@ -108,8 +108,9 @@ public class ItemRenderer {
|
|||
}
|
||||
|
||||
EaglerAdapter.glDisable(EaglerAdapter.GL_RESCALE_NORMAL);
|
||||
EaglerAdapter.revertLightMatrix();
|
||||
}
|
||||
|
||||
EaglerAdapter.flipLightMatrix();
|
||||
|
||||
EaglerAdapter.glPopMatrix();
|
||||
}
|
||||
|
|
|
@ -24,14 +24,17 @@ public class RenderItem extends Render {
|
|||
|
||||
private static final TextureLocation terrain = new TextureLocation("/terrain.png");
|
||||
private static final TextureLocation items = new TextureLocation("/gui/items.png");
|
||||
|
||||
public static boolean isRenderInProgress = false;
|
||||
|
||||
/**
|
||||
* Renders the item
|
||||
*/
|
||||
public void doRenderItem(EntityItem par1EntityItem, double par2, double par4, double par6, float par8, float par9) {
|
||||
isRenderInProgress = true;
|
||||
this.random.setSeed(187L);
|
||||
ItemStack var10 = par1EntityItem.getEntityItem();
|
||||
|
||||
|
||||
if (var10.getItem() != null) {
|
||||
EaglerAdapter.glPushMatrix();
|
||||
float var11 = MathHelper.sin(((float) par1EntityItem.age + par9) / 10.0F + par1EntityItem.hoverStart) * 0.1F + 0.1F;
|
||||
|
@ -56,6 +59,7 @@ public class RenderItem extends Render {
|
|||
|
||||
EaglerAdapter.glTranslatef((float) par2, (float) par4 + var11, (float) par6);
|
||||
EaglerAdapter.glEnable(EaglerAdapter.GL_RESCALE_NORMAL);
|
||||
|
||||
int var17;
|
||||
float var18;
|
||||
float var19;
|
||||
|
@ -64,6 +68,7 @@ public class RenderItem extends Render {
|
|||
if (var10.getItemSpriteNumber() == 0 && Block.blocksList[var10.itemID] != null && RenderBlocks.renderItemIn3d(Block.blocksList[var10.itemID].getRenderType())) {
|
||||
Block var22 = Block.blocksList[var10.itemID];
|
||||
EaglerAdapter.glRotatef(var12, 0.0F, 1.0F, 0.0F);
|
||||
//RenderHelper.enableStandardItemLighting();
|
||||
|
||||
if (renderInFrame) {
|
||||
EaglerAdapter.glScalef(1.25F, 1.25F, 1.25F);
|
||||
|
@ -158,6 +163,7 @@ public class RenderItem extends Render {
|
|||
EaglerAdapter.glDisable(EaglerAdapter.GL_RESCALE_NORMAL);
|
||||
EaglerAdapter.glPopMatrix();
|
||||
}
|
||||
isRenderInProgress = false;
|
||||
}
|
||||
|
||||
private static final TextureLocation glint = new TextureLocation("%blur%/misc/glint.png");
|
||||
|
|
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user