mirror of
https://github.com/overte-org/overte.git
synced 2025-08-11 16:53:08 +02:00
Drafting the support for gloss map
This commit is contained in:
parent
3ee6f9d6f2
commit
d64b9bb6d9
5 changed files with 50 additions and 3 deletions
|
@ -364,7 +364,9 @@ static NetworkMaterial* buildNetworkMaterial(NetworkGeometry* geometry, const FB
|
||||||
}
|
}
|
||||||
if (!material.roughnessTexture.filename.isEmpty()) {
|
if (!material.roughnessTexture.filename.isEmpty()) {
|
||||||
// FIXME: COnvert from gloss to roughness if material.roughnessTexture.isGlossmap;
|
// FIXME: COnvert from gloss to roughness if material.roughnessTexture.isGlossmap;
|
||||||
networkMaterial->roughnessTexture = textureCache->getTexture(textureBaseUrl.resolved(QUrl(material.roughnessTexture.filename)), ROUGHNESS_TEXTURE, material.roughnessTexture.content);
|
networkMaterial->roughnessTexture = textureCache->getTexture(textureBaseUrl.resolved(QUrl(material.roughnessTexture.filename)),
|
||||||
|
(material.roughnessTexture.isGlossmap ? GLOSS_TEXTURE : ROUGHNESS_TEXTURE),
|
||||||
|
material.roughnessTexture.content);
|
||||||
networkMaterial->roughnessTextureName = material.roughnessTexture.name;
|
networkMaterial->roughnessTextureName = material.roughnessTexture.name;
|
||||||
|
|
||||||
auto roughnessMap = model::TextureMapPointer(new model::TextureMap());
|
auto roughnessMap = model::TextureMapPointer(new model::TextureMap());
|
||||||
|
|
|
@ -216,6 +216,10 @@ NetworkTexture::TextureLoaderFunc NetworkTexture::getTextureLoader() const {
|
||||||
return TextureLoaderFunc(model::TextureUsage::createRoughnessTextureFromImage);
|
return TextureLoaderFunc(model::TextureUsage::createRoughnessTextureFromImage);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case GLOSS_TEXTURE: {
|
||||||
|
return TextureLoaderFunc(model::TextureUsage::createRoughnessTextureFromGlossImage);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case SPECULAR_TEXTURE: {
|
case SPECULAR_TEXTURE: {
|
||||||
return TextureLoaderFunc(model::TextureUsage::createMetallicTextureFromImage);
|
return TextureLoaderFunc(model::TextureUsage::createMetallicTextureFromImage);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -29,8 +29,18 @@ class NetworkTexture;
|
||||||
|
|
||||||
typedef QSharedPointer<NetworkTexture> NetworkTexturePointer;
|
typedef QSharedPointer<NetworkTexture> NetworkTexturePointer;
|
||||||
|
|
||||||
enum TextureType { DEFAULT_TEXTURE, NORMAL_TEXTURE, BUMP_TEXTURE, SPECULAR_TEXTURE, ROUGHNESS_TEXTURE, EMISSIVE_TEXTURE,
|
enum TextureType {
|
||||||
CUBE_TEXTURE, OCCLUSION_TEXTURE, LIGHTMAP_TEXTURE, CUSTOM_TEXTURE
|
DEFAULT_TEXTURE,
|
||||||
|
NORMAL_TEXTURE,
|
||||||
|
BUMP_TEXTURE,
|
||||||
|
SPECULAR_TEXTURE,
|
||||||
|
ROUGHNESS_TEXTURE,
|
||||||
|
GLOSS_TEXTURE,
|
||||||
|
EMISSIVE_TEXTURE,
|
||||||
|
CUBE_TEXTURE,
|
||||||
|
OCCLUSION_TEXTURE,
|
||||||
|
LIGHTMAP_TEXTURE,
|
||||||
|
CUSTOM_TEXTURE
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Stores cached textures, including render-to-texture targets.
|
/// Stores cached textures, including render-to-texture targets.
|
||||||
|
|
|
@ -280,6 +280,36 @@ gpu::Texture* TextureUsage::createRoughnessTextureFromImage(const QImage& srcIma
|
||||||
return theTexture;
|
return theTexture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gpu::Texture* TextureUsage::createRoughnessTextureFromGlossImage(const QImage& srcImage, const std::string& srcImageName) {
|
||||||
|
QImage image = srcImage;
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
image = image.convertToFormat(QImage::Format_Grayscale8);
|
||||||
|
|
||||||
|
gpu::Texture* theTexture = nullptr;
|
||||||
|
if ((image.width() > 0) && (image.height() > 0)) {
|
||||||
|
|
||||||
|
gpu::Element formatGPU = gpu::Element(gpu::SCALAR, gpu::NUINT8, gpu::RGB);
|
||||||
|
gpu::Element formatMip = gpu::Element(gpu::SCALAR, gpu::NUINT8, gpu::RGB);
|
||||||
|
|
||||||
|
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->autoGenerateMips(-1);
|
||||||
|
|
||||||
|
// FIXME queue for transfer to GPU and block on completion
|
||||||
|
}
|
||||||
|
|
||||||
|
return theTexture;
|
||||||
|
}
|
||||||
|
|
||||||
gpu::Texture* TextureUsage::createMetallicTextureFromImage(const QImage& srcImage, const std::string& srcImageName) {
|
gpu::Texture* TextureUsage::createMetallicTextureFromImage(const QImage& srcImage, const std::string& srcImageName) {
|
||||||
QImage image = srcImage;
|
QImage image = srcImage;
|
||||||
if (!image.hasAlphaChannel()) {
|
if (!image.hasAlphaChannel()) {
|
||||||
|
|
|
@ -35,6 +35,7 @@ public:
|
||||||
static gpu::Texture* createNormalTextureFromNormalImage(const QImage& image, const std::string& srcImageName);
|
static gpu::Texture* createNormalTextureFromNormalImage(const QImage& image, const std::string& srcImageName);
|
||||||
static gpu::Texture* createNormalTextureFromBumpImage(const QImage& image, const std::string& srcImageName);
|
static gpu::Texture* createNormalTextureFromBumpImage(const QImage& image, const std::string& srcImageName);
|
||||||
static gpu::Texture* createRoughnessTextureFromImage(const QImage& image, const std::string& srcImageName);
|
static gpu::Texture* createRoughnessTextureFromImage(const QImage& image, const std::string& srcImageName);
|
||||||
|
static gpu::Texture* createRoughnessTextureFromGlossImage(const QImage& image, const std::string& srcImageName);
|
||||||
static gpu::Texture* createMetallicTextureFromImage(const QImage& image, const std::string& srcImageName);
|
static gpu::Texture* createMetallicTextureFromImage(const QImage& image, const std::string& srcImageName);
|
||||||
static gpu::Texture* createCubeTextureFromImage(const QImage& image, const std::string& srcImageName);
|
static gpu::Texture* createCubeTextureFromImage(const QImage& image, const std::string& srcImageName);
|
||||||
static gpu::Texture* createLightmapTextureFromImage(const QImage& image, const std::string& srcImageName);
|
static gpu::Texture* createLightmapTextureFromImage(const QImage& image, const std::string& srcImageName);
|
||||||
|
|
Loading…
Reference in a new issue