mirror of
https://github.com/overte-org/overte.git
synced 2025-04-25 20:36:38 +02:00
Trying ti debug the bad normal maps
This commit is contained in:
parent
63468f8faa
commit
a9fefcc802
3 changed files with 17 additions and 4 deletions
|
@ -399,11 +399,9 @@ GLTexelFormat GLTexelFormat::evalGLTexelFormat(const Element& dstFormat, const E
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case gpu::SRGB:
|
case gpu::SRGB:
|
||||||
texel.format = GL_RGB;
|
|
||||||
texel.internalFormat = GL_SRGB8;
|
texel.internalFormat = GL_SRGB8;
|
||||||
break;
|
break;
|
||||||
case gpu::SRGBA:
|
case gpu::SRGBA:
|
||||||
texel.format = GL_RGBA;
|
|
||||||
texel.internalFormat = GL_SRGB8_ALPHA8; // standard 2.2 gamma correction color
|
texel.internalFormat = GL_SRGB8_ALPHA8; // standard 2.2 gamma correction color
|
||||||
break;
|
break;
|
||||||
case gpu::COMPRESSED_RGBA:
|
case gpu::COMPRESSED_RGBA:
|
||||||
|
|
|
@ -497,7 +497,8 @@ void NetworkMaterial::setTextures(const QVariantMap& textureMap) {
|
||||||
|
|
||||||
if (!normalName.isEmpty()) {
|
if (!normalName.isEmpty()) {
|
||||||
auto url = textureMap.contains(normalName) ? textureMap[normalName].toUrl() : QUrl();
|
auto url = textureMap.contains(normalName) ? textureMap[normalName].toUrl() : QUrl();
|
||||||
auto map = fetchTextureMap(url, NORMAL_TEXTURE, MapChannel::NORMAL_MAP);
|
// auto map = fetchTextureMap(url, NORMAL_TEXTURE, MapChannel::NORMAL_MAP);
|
||||||
|
auto map = fetchTextureMap(url, DEFAULT_TEXTURE, MapChannel::NORMAL_MAP);
|
||||||
setTextureMap(MapChannel::NORMAL_MAP, map);
|
setTextureMap(MapChannel::NORMAL_MAP, map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -198,8 +198,18 @@ gpu::Texture* TextureUsage::createLightmapTextureFromImage(const QImage& srcImag
|
||||||
gpu::Texture* TextureUsage::createNormalTextureFromNormalImage(const QImage& srcImage, const std::string& srcImageName) {
|
gpu::Texture* TextureUsage::createNormalTextureFromNormalImage(const QImage& srcImage, const std::string& srcImageName) {
|
||||||
QImage image = srcImage;
|
QImage image = srcImage;
|
||||||
|
|
||||||
if (image.format() != QImage::Format_RGB888) {
|
/* if (image.format() != QImage::Format_RGB888) {
|
||||||
image = image.convertToFormat(QImage::Format_RGB888);
|
image = image.convertToFormat(QImage::Format_RGB888);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
if (!image.hasAlphaChannel()) {
|
||||||
|
if (image.format() != QImage::Format_RGB888) {
|
||||||
|
image = image.convertToFormat(QImage::Format_RGB888);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (image.format() != QImage::Format_ARGB32) {
|
||||||
|
image = image.convertToFormat(QImage::Format_ARGB32);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gpu::Texture* theTexture = nullptr;
|
gpu::Texture* theTexture = nullptr;
|
||||||
|
@ -208,6 +218,10 @@ gpu::Texture* TextureUsage::createNormalTextureFromNormalImage(const QImage& src
|
||||||
gpu::Element formatGPU = gpu::Element(gpu::VEC3, gpu::NUINT8, gpu::RGB);
|
gpu::Element formatGPU = gpu::Element(gpu::VEC3, gpu::NUINT8, gpu::RGB);
|
||||||
gpu::Element formatMip = gpu::Element(gpu::VEC3, gpu::NUINT8, gpu::RGB);
|
gpu::Element formatMip = gpu::Element(gpu::VEC3, gpu::NUINT8, gpu::RGB);
|
||||||
|
|
||||||
|
if (image.hasAlphaChannel()) {
|
||||||
|
formatGPU = gpu::Element(gpu::VEC4, gpu::NUINT8, gpu::RGBA);
|
||||||
|
formatMip = gpu::Element(gpu::VEC4, gpu::NUINT8, gpu::BGRA);
|
||||||
|
}
|
||||||
|
|
||||||
theTexture = (gpu::Texture::create2D(formatGPU, image.width(), image.height(), gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_MIP_LINEAR)));
|
theTexture = (gpu::Texture::create2D(formatGPU, image.width(), image.height(), gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_MIP_LINEAR)));
|
||||||
theTexture->assignStoredMip(0, formatMip, image.byteCount(), image.constBits());
|
theTexture->assignStoredMip(0, formatMip, image.byteCount(), image.constBits());
|
||||||
|
|
Loading…
Reference in a new issue