Skip to content

Commit

Permalink
Fix issue with previous PR
Browse files Browse the repository at this point in the history
  • Loading branch information
IMS212 committed Aug 1, 2023
1 parent 2a6c4a5 commit ffc8ac9
Showing 1 changed file with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -243,16 +243,6 @@ private void fillExtendedData(int vertexAmount) {
midU /= vertexAmount;
midV /= vertexAmount;

if (vertexAmount == 3) {
// Removed to enable smooth shaded triangles. Mods rendering triangles with bad normals need to recalculate their normals manually or otherwise shading might be inconsistent.
// NormalHelper.computeFaceNormalTri(normal, polygon);
} else {
NormalHelper.computeFaceNormal(normal, polygon);
}
int packedNormal = NormalHelper.packNormal(normal, 0.0f);

int tangent = NormalHelper.computeTangent(normal.x, normal.y, normal.z, polygon);

int midUOffset;
int midVOffset;
int normalOffset;
Expand All @@ -269,6 +259,18 @@ private void fillExtendedData(int vertexAmount) {
tangentOffset = 6;
}

int packedNormal = 0;
if (vertexAmount == 3) {
// Removed to enable smooth shaded triangles. Mods rendering triangles with bad normals need to recalculate their normals manually or otherwise shading might be inconsistent.
// NormalHelper.computeFaceNormalTri(normal, polygon);
packedNormal = buffer.getInt(nextElementByte - normalOffset);
} else {
NormalHelper.computeFaceNormal(normal, polygon);
packedNormal = NormalHelper.packNormal(normal, 0.0f);
}

int tangent = NormalHelper.computeTangent(normal.x, normal.y, normal.z, polygon);

for (int vertex = 0; vertex < vertexAmount; vertex++) {
buffer.putFloat(nextElementByte - midUOffset - stride * vertex, midU);
buffer.putFloat(nextElementByte - midVOffset - stride * vertex, midV);
Expand Down

0 comments on commit ffc8ac9

Please sign in to comment.