mirror of https://github.com/qt/qt3d.git
Don't flip texture coordinates, mirror image instead
If the texture coordinates are flipped, we are going behind the user's back as they may depend upon the loaded texture coordinates being the same as in the source file. Also, flipping the texture coordinates was leading to the w component of the tangent vector being negated. This in turn led to very broken behavior when using normal mapping - which depends upon the tangent vector. Instead we by default mirror the texture image when loaded via QImage. We can add API in 5.8 to allow the user to disable this behavior and allow the user to store the image mirrored on disk which is what should happen - or even better prepare dds/ktx textures. Change-Id: Ia63b4e94c5a7cfb6389659fe9be2c6e426f01886 Reviewed-by: Kevin Ottens <kevin.ottens@kdab.com>
This commit is contained in:
parent
6f7c31fb4f
commit
44f1a92338
|
|
@ -241,8 +241,6 @@ bool ObjLoader::load(::QIODevice *ioDev, const QString &subMesh)
|
|||
// Process texture coordinate
|
||||
float s = tokens.floatAt(1);
|
||||
float t = tokens.floatAt(2);
|
||||
//FlipUVs
|
||||
t = 1.0f - t;
|
||||
texCoords.append(QVector2D( s, t ));
|
||||
} else {
|
||||
texCoordsOffset++;
|
||||
|
|
|
|||
|
|
@ -640,7 +640,7 @@ QTextureImageDataPtr TextureLoadingHelper::loadTextureData(const QUrl &url, bool
|
|||
QImage img;
|
||||
if (img.load(source)) {
|
||||
textureData = QTextureImageDataPtr::create();
|
||||
textureData->setImage(img);
|
||||
textureData->setImage(img.mirrored());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue