sigh, another attempt at fixing normal shading for android

This commit is contained in:
Shredder
2026-04-12 02:09:42 +05:00
parent c188fa0ce2
commit e1c2210621
7 changed files with 36 additions and 25 deletions

View File

@@ -606,7 +606,7 @@ void Gui::renderProgressIndicator( const bool isTouchInterface, const int screen
glBlendFunc2(GL_ONE_MINUS_DST_COLOR, GL_ONE_MINUS_SRC_COLOR); glBlendFunc2(GL_ONE_MINUS_DST_COLOR, GL_ONE_MINUS_SRC_COLOR);
blit(screenWidth/2 - 8, screenHeight/2 - 8, 0, 0, 16, 16); blit(screenWidth/2 - 8, screenHeight/2 - 8, 0, 0, 16, 16);
glDisable(GL_BLEND); glDisable(GL_BLEND);
} else if(!bowEquipped) { } else if((!bowEquipped) || (!minecraft->options.getBooleanValue(OPTIONS_IS_JOY_TOUCH_AREA))) {
const float tprogress = minecraft->gameMode->destroyProgress; const float tprogress = minecraft->gameMode->destroyProgress;
const float alpha = Mth::clamp(minecraft->inputHolder->alpha, 0.0f, 1.0f); const float alpha = Mth::clamp(minecraft->inputHolder->alpha, 0.0f, 1.0f);
//LOGI("alpha: %f\n", alpha); //LOGI("alpha: %f\n", alpha);

View File

@@ -203,7 +203,7 @@ void ModelPart::compile( float scale )
void ModelPart::draw() void ModelPart::draw()
{ {
#ifdef OPENGL_ES #ifdef OPENGL_ES
drawArrayVTN_NoState(vboId, cubes.size() * 2 * 3 * 6, 28); drawArrayVTN_NoState(vboId, cubes.size() * 2 * 3 * 6, 36);
#else #else
glCallList(list); glCallList(list);
#endif #endif

View File

@@ -20,7 +20,7 @@ Tesselator::Tesselator( int size )
_noColor(false), _noColor(false),
mode(0), mode(0),
xo(0), yo(0), zo(0), xo(0), yo(0), zo(0),
_normal(0), _nx(0), _ny(0), _nz(0),
_sx(1), _sy(1), _sx(1), _sy(1),
tesselating(false), tesselating(false),
@@ -112,7 +112,7 @@ RenderChunk Tesselator::end( bool useMine, int bufferId )
glEnableClientState2(GL_COLOR_ARRAY); glEnableClientState2(GL_COLOR_ARRAY);
} }
if (hasNormal) { if (hasNormal) {
glNormalPointer(GL_BYTE, VertexSizeBytes, (GLvoid*) (6 * 4)); glNormalPointer(GL_FLOAT, VertexSizeBytes, (GLvoid*) (6 * 4));
glEnableClientState2(GL_NORMAL_ARRAY); glEnableClientState2(GL_NORMAL_ARRAY);
} }
glVertexPointer2(3, GL_FLOAT, VertexSizeBytes, 0); glVertexPointer2(3, GL_FLOAT, VertexSizeBytes, 0);
@@ -279,7 +279,9 @@ void Tesselator::vertex( float x, float y, float z )
dst.color = src.color; dst.color = src.color;
} }
if (hasNormal) { if (hasNormal) {
dst.normal = src.normal; dst.nx = src.nx;
dst.ny = src.ny;
dst.nz = src.nz;
} }
dst.x = src.x; dst.x = src.x;
@@ -302,7 +304,9 @@ void Tesselator::vertex( float x, float y, float z )
vertex.color = _color; vertex.color = _color;
} }
if (hasNormal) { if (hasNormal) {
vertex.normal = _normal; vertex.nx = _nx;
vertex.ny = _ny;
vertex.nz = _nz;
} }
vertex.x = _sx * (x + xo); vertex.x = _sx * (x + xo);
@@ -339,11 +343,15 @@ void Tesselator::normal( float x, float y, float z )
if (!tesselating) printf("But.."); if (!tesselating) printf("But..");
hasNormal = true; hasNormal = true;
char xx = (char) (x * 128); //char xx = (char) (x * 128);
char yy = (char) (y * 127); //char yy = (char) (y * 127);
char zz = (char) (z * 127); //char zz = (char) (z * 127);
_normal = xx | (yy << 8) | (zz << 16); //_normal = xx | (yy << 8) | (zz << 16);
// trying a new thing hopefully works
this->_nx = x;
this->_ny = y;
this->_nz = z;
} }
void Tesselator::offset( float xo, float yo, float zo ) { void Tesselator::offset( float xo, float yo, float zo ) {
@@ -405,7 +413,7 @@ void Tesselator::draw()
glEnableClientState2(GL_COLOR_ARRAY); glEnableClientState2(GL_COLOR_ARRAY);
} }
if (hasNormal) { if (hasNormal) {
glNormalPointer(GL_BYTE, VertexSizeBytes, (GLvoid*) (6 * 4)); glNormalPointer(GL_FLOAT, VertexSizeBytes, (GLvoid*) (6 * 4));
glEnableClientState2(GL_NORMAL_ARRAY); glEnableClientState2(GL_NORMAL_ARRAY);
} }
//glVertexPointer2(3, GL_FLOAT, VertexSizeBytes, (GLvoid*)&_varray); //glVertexPointer2(3, GL_FLOAT, VertexSizeBytes, (GLvoid*)&_varray);

View File

@@ -98,7 +98,9 @@ private:
float xo, yo, zo; float xo, yo, zo;
float u, v; float u, v;
unsigned int _color; unsigned int _color;
int _normal; // int _normal; // trying a new thing
float _nx, _ny, _nz;
float _sx, _sy; float _sx, _sy;
bool hasColor; bool hasColor;

View File

@@ -14,7 +14,8 @@ typedef struct VertexDeclPTCN
GLfloat x, y, z; GLfloat x, y, z;
GLfloat u, v; GLfloat u, v;
GLuint color; GLuint color;
GLuint normal; // GLuint normal; // trying a new thing
GLfloat nx, ny, nz;
} VertexDeclPTCN; } VertexDeclPTCN;

View File

@@ -128,7 +128,7 @@ void drawArrayVTN(int bufferId, int vertices, int vertexSize /* = 24 */) {
glVertexPointer2( 3, GL_FLOAT, vertexSize, 0); glVertexPointer2( 3, GL_FLOAT, vertexSize, 0);
glTexCoordPointer2(2, GL_FLOAT, vertexSize, (GLvoid*) (3 * 4)); glTexCoordPointer2(2, GL_FLOAT, vertexSize, (GLvoid*) (3 * 4));
//glColorPointer2(4, GL_UNSIGNED_BYTE, vertexSize, (GLvoid*) (5*4)); //glColorPointer2(4, GL_UNSIGNED_BYTE, vertexSize, (GLvoid*) (5*4));
glNormalPointer(GL_BYTE, vertexSize, (GLvoid*) (6 * 4)); glNormalPointer(GL_FLOAT, vertexSize, (GLvoid*) (6 * 4));
glDrawArrays2(GL_TRIANGLES, 0, vertices); glDrawArrays2(GL_TRIANGLES, 0, vertices);
@@ -145,7 +145,7 @@ void drawArrayVTCN_NoState(int bufferId, int vertices, int vertexSize /* = 24 */
glVertexPointer2( 3, GL_FLOAT, vertexSize, 0); glVertexPointer2( 3, GL_FLOAT, vertexSize, 0);
glTexCoordPointer2(2, GL_FLOAT, vertexSize, (GLvoid*) (3 * 4)); glTexCoordPointer2(2, GL_FLOAT, vertexSize, (GLvoid*) (3 * 4));
//glColorPointer2(4, GL_UNSIGNED_BYTE, vertexSize, (GLvoid*) (5*4)); //glColorPointer2(4, GL_UNSIGNED_BYTE, vertexSize, (GLvoid*) (5*4));
glNormalPointer(GL_BYTE, vertexSize, (GLvoid*) (6 * 4)); glNormalPointer(GL_FLOAT, vertexSize, (GLvoid*) (6 * 4));
glDrawArrays2(GL_TRIANGLES, 0, vertices); glDrawArrays2(GL_TRIANGLES, 0, vertices);
} }

View File

@@ -60,17 +60,17 @@ void anGenBuffers(GLsizei n, GLuint* buffer);
#define drawArrayVT_NoState drawArrayVT #define drawArrayVT_NoState drawArrayVT
#define drawArrayVTC_NoState drawArrayVTC #define drawArrayVTC_NoState drawArrayVTC
#define drawArrayVTN_NoState drawArrayVTN #define drawArrayVTN_NoState drawArrayVTN
void drawArrayVT(int bufferId, int vertices, int vertexSize = 28, unsigned int mode = GL_TRIANGLES); void drawArrayVT(int bufferId, int vertices, int vertexSize = 36, unsigned int mode = GL_TRIANGLES);
#ifndef drawArrayVT_NoState #ifndef drawArrayVT_NoState
//void drawArrayVT_NoState(int bufferId, int vertices, int vertexSize = 28); //void drawArrayVT_NoState(int bufferId, int vertices, int vertexSize = 36);
#endif #endif
void drawArrayVTC(int bufferId, int vertices, int vertexSize = 28); void drawArrayVTC(int bufferId, int vertices, int vertexSize = 36);
#ifndef drawArrayVTC_NoState #ifndef drawArrayVTC_NoState
void drawArrayVTC_NoState(int bufferId, int vertices, int vertexSize = 28); void drawArrayVTC_NoState(int bufferId, int vertices, int vertexSize = 36);
#endif #endif
void drawArrayVTN(int bufferId, int vertices, int vertexSize = 28); void drawArrayVTN(int bufferId, int vertices, int vertexSize = 36);
#ifndef drawArrayVTN_NoState #ifndef drawArrayVTN_NoState
void drawArrayVTCN_NoState(int bufferId, int vertices, int vertexSize = 28); void drawArrayVTCN_NoState(int bufferId, int vertices, int vertexSize = 36);
#endif #endif
#endif #endif