From e18906b178c6dc3b2af5b418d90ea08bd571f540 Mon Sep 17 00:00:00 2001 From: Ian Chen Date: Wed, 30 Aug 2023 20:01:22 -0700 Subject: [PATCH] Fix glTF metalness and roughness map orientation (#532) Signed-off-by: Ian Chen --- graphics/src/AssimpLoader.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/graphics/src/AssimpLoader.cc b/graphics/src/AssimpLoader.cc index f38da665..eeac1bee 100644 --- a/graphics/src/AssimpLoader.cc +++ b/graphics/src/AssimpLoader.cc @@ -507,13 +507,13 @@ std::pair std::vector metalnessData(width * height * bytesPerPixel); std::vector roughnessData(width * height * bytesPerPixel); - for (unsigned int x = 0; x < width; ++x) + for (unsigned int y = 0; y < height; ++y) { - for (unsigned int y = 0; y < height; ++y) + for (unsigned int x = 0; x < width; ++x) { // RGBA so 4 bytes per pixel, alpha fully opaque - auto baseIndex = bytesPerPixel * (x * height + y); - auto color = _img.Pixel(x, y); + auto baseIndex = bytesPerPixel * (y * width + x); + auto color = _img.Pixel(x, (height - y - 1)); metalnessData[baseIndex] = color.B() * 255.0; metalnessData[baseIndex + 1] = color.B() * 255.0; metalnessData[baseIndex + 2] = color.B() * 255.0;