From aea7b0cb74eb85d12554562d30347a8d51d0c9ba Mon Sep 17 00:00:00 2001 From: Jeremy Hu Date: Sun, 18 Nov 2018 07:30:26 +0800 Subject: [PATCH] Switch the order of ORM combined texture Red: Ambient Occlusion Green: Roughness Blue: Metallic --- shaders/pbr-qt.frag | 8 ++++++-- src/texturegenerator.cpp | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/shaders/pbr-qt.frag b/shaders/pbr-qt.frag index b89d1b3f..6f95cb46 100644 --- a/shaders/pbr-qt.frag +++ b/shaders/pbr-qt.frag @@ -328,6 +328,10 @@ void main() normal = normalize(normal * 2.0 - 1.0); } + // Red: Ambient Occlusion + // Green: Roughness + // Blue: Metallic + float metalness = vertMetalness; if (metalnessMapEnabled == 1) { metalness = texture2D(metalnessRoughnessAmbientOcclusionMapId, vertTexCoord).b; @@ -335,12 +339,12 @@ void main() float roughness = vertRoughness; if (roughnessMapEnabled == 1) { - roughness = texture2D(metalnessRoughnessAmbientOcclusionMapId, vertTexCoord).r; + roughness = texture2D(metalnessRoughnessAmbientOcclusionMapId, vertTexCoord).g; } float ambientOcclusion = 1.0; if (ambientOcclusionMapEnabled == 1) { - ambientOcclusion = texture2D(metalnessRoughnessAmbientOcclusionMapId, vertTexCoord).g; + ambientOcclusion = texture2D(metalnessRoughnessAmbientOcclusionMapId, vertTexCoord).r; } roughness = min(0.99, roughness); diff --git a/src/texturegenerator.cpp b/src/texturegenerator.cpp index aa2e6a03..94ef88c1 100644 --- a/src/texturegenerator.cpp +++ b/src/texturegenerator.cpp @@ -380,9 +380,9 @@ void TextureGenerator::generate() if (hasMetalnessMap) color.setBlue(qGray(m_resultTextureMetalnessImage->pixel(col, row))); if (hasRoughnessMap) - color.setRed(qGray(m_resultTextureRoughnessImage->pixel(col, row))); + color.setGreen(qGray(m_resultTextureRoughnessImage->pixel(col, row))); if (hasAmbientOcclusionMap) - color.setGreen(qGray(m_resultTextureAmbientOcclusionImage->pixel(col, row))); + color.setRed(qGray(m_resultTextureAmbientOcclusionImage->pixel(col, row))); m_resultTextureMetalnessRoughnessAmbientOcclusionImage->setPixelColor(col, row, color); } }