Skip to content

Commit

Permalink
Fix texture mapping of normal blocks.
Browse files Browse the repository at this point in the history
  • Loading branch information
ThatRedox committed Sep 1, 2024
1 parent 79fde6a commit f2eb153
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/main/opencl/kernel/include/block.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ bool BlockPalette_intersectNormalizedBlock(BlockPalette self, image2d_array_t at
hit = AABB_full_intersect(box, tempRay, &tempRecord);
tempRecord.material = modelPointer;
if (hit) {
if (tempRecord.normal.x > 0 || tempRecord.normal.z < 0) {
tempRecord.texCoord.x = 1 - tempRecord.texCoord.x;
}
if (tempRecord.normal.y > 0) {
tempRecord.texCoord.y = 1 - tempRecord.texCoord.y;
}

Material material = Material_get(materialPalette, tempRecord.material);
hit = Material_sample(material, atlas, tempRecord.texCoord, sample);
if (hit) {
Expand Down

0 comments on commit f2eb153

Please # to comment.