mirror of
https://github.com/overte-org/overte.git
synced 2025-04-05 21:12:25 +02:00
Have only one ColorChannel enum as header in image library
This commit is contained in:
parent
1b2cb94b0c
commit
b2af6d1374
10 changed files with 35 additions and 33 deletions
|
@ -154,7 +154,7 @@ void TextureBaker::processTexture() {
|
|||
gpu::BackendTarget::GLES32
|
||||
}};
|
||||
for (auto target : BACKEND_TARGETS) {
|
||||
auto processedTexture = image::processImage(buffer, _textureURL.toString().toStdString(), image::TextureUsage::ColorChannel::NONE,
|
||||
auto processedTexture = image::processImage(buffer, _textureURL.toString().toStdString(), image::ColorChannel::NONE,
|
||||
ABSOLUTE_MAX_TEXTURE_NUM_PIXELS, _textureType, true,
|
||||
target, _abortProcessing);
|
||||
if (!processedTexture) {
|
||||
|
@ -197,7 +197,7 @@ void TextureBaker::processTexture() {
|
|||
// Uncompressed KTX
|
||||
if (_textureType == image::TextureUsage::Type::CUBE_TEXTURE) {
|
||||
buffer->reset();
|
||||
auto processedTexture = image::processImage(std::move(buffer), _textureURL.toString().toStdString(), image::TextureUsage::ColorChannel::NONE,
|
||||
auto processedTexture = image::processImage(std::move(buffer), _textureURL.toString().toStdString(), image::ColorChannel::NONE,
|
||||
ABSOLUTE_MAX_TEXTURE_NUM_PIXELS, _textureType, false, gpu::BackendTarget::GL45, _abortProcessing);
|
||||
if (!processedTexture) {
|
||||
handleError("Could not process texture " + _textureURL.toString());
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include <NetworkAccessManager.h>
|
||||
#include <ResourceManager.h>
|
||||
#include <PathUtils.h>
|
||||
#include <image/ColorChannel.h>
|
||||
|
||||
#include "FBXSerializer.h"
|
||||
|
||||
|
@ -1146,10 +1147,10 @@ void GLTFSerializer::setHFMMaterial(HFMMaterial& fbxmat, const GLTFMaterial& mat
|
|||
}
|
||||
if (material.pbrMetallicRoughness.defined["metallicRoughnessTexture"]) {
|
||||
fbxmat.roughnessTexture = getHFMTexture(_file.textures[material.pbrMetallicRoughness.metallicRoughnessTexture]);
|
||||
fbxmat.roughnessTexture.sourceChannel = hfm::ColorChannel::GREEN;
|
||||
fbxmat.roughnessTexture.sourceChannel = image::ColorChannel::GREEN;
|
||||
fbxmat.useRoughnessMap = true;
|
||||
fbxmat.metallicTexture = getHFMTexture(_file.textures[material.pbrMetallicRoughness.metallicRoughnessTexture]);
|
||||
fbxmat.metallicTexture.sourceChannel = hfm::ColorChannel::BLUE;
|
||||
fbxmat.metallicTexture.sourceChannel = image::ColorChannel::BLUE;
|
||||
fbxmat.useMetallicMap = true;
|
||||
}
|
||||
if (material.pbrMetallicRoughness.defined["roughnessFactor"]) {
|
||||
|
|
|
@ -5,3 +5,4 @@ link_hifi_libraries(shared)
|
|||
|
||||
include_hifi_library_headers(gpu)
|
||||
include_hifi_library_headers(graphics)
|
||||
include_hifi_library_headers(image)
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include <graphics/Geometry.h>
|
||||
#include <graphics/Material.h>
|
||||
|
||||
#include "ColorChannel.h"
|
||||
#include <image/ColorChannel.h>
|
||||
|
||||
#if defined(Q_OS_ANDROID)
|
||||
#define HFM_PACK_NORMALS 0
|
||||
|
@ -125,7 +125,7 @@ public:
|
|||
QString name;
|
||||
QByteArray filename;
|
||||
QByteArray content;
|
||||
ColorChannel sourceChannel { ColorChannel::NONE };
|
||||
image::ColorChannel sourceChannel { image::ColorChannel::NONE };
|
||||
|
||||
Transform transform;
|
||||
int maxNumPixels { MAX_NUM_PIXELS_FOR_FBX_TEXTURE };
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
//
|
||||
// ColorChannel.h
|
||||
// libraries/hfm/src
|
||||
// libraries/image/src/image
|
||||
//
|
||||
// Created by Sabrina Shanman on 2019/02/12.
|
||||
// Copyright 2019 High Fidelity, Inc.
|
||||
|
@ -9,10 +9,10 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#ifndef hifi_hfm_ColorChannel_h
|
||||
#define hifi_hfm_ColorChannel_h
|
||||
#ifndef hifi_image_ColorChannel_h
|
||||
#define hifi_image_ColorChannel_h
|
||||
|
||||
namespace hfm {
|
||||
namespace image {
|
||||
enum class ColorChannel {
|
||||
NONE,
|
||||
RED,
|
||||
|
@ -23,4 +23,4 @@ namespace hfm {
|
|||
};
|
||||
};
|
||||
|
||||
#endif // hifi_hfm_ColorChannel_h
|
||||
#endif // hifi_image_ColorChannel_h
|
|
@ -222,7 +222,7 @@ QImage processRawImageData(QIODevice& content, const std::string& filename) {
|
|||
return QImage();
|
||||
}
|
||||
|
||||
void mapToRedChannel(QImage& image, TextureUsage::ColorChannel sourceChannel) {
|
||||
void mapToRedChannel(QImage& image, ColorChannel sourceChannel) {
|
||||
// Change format of image so we know exactly how to process it
|
||||
if (image.format() != QImage::Format_ARGB32) {
|
||||
image = image.convertToFormat(QImage::Format_ARGB32);
|
||||
|
@ -237,16 +237,16 @@ void mapToRedChannel(QImage& image, TextureUsage::ColorChannel sourceChannel) {
|
|||
for (; pixel < lineEnd; pixel++) {
|
||||
int colorValue;
|
||||
switch (sourceChannel) {
|
||||
case TextureUsage::ColorChannel::RED:
|
||||
case ColorChannel::RED:
|
||||
colorValue = qRed(*pixel);
|
||||
break;
|
||||
case TextureUsage::ColorChannel::GREEN:
|
||||
case ColorChannel::GREEN:
|
||||
colorValue = qGreen(*pixel);
|
||||
break;
|
||||
case TextureUsage::ColorChannel::BLUE:
|
||||
case ColorChannel::BLUE:
|
||||
colorValue = qBlue(*pixel);
|
||||
break;
|
||||
case TextureUsage::ColorChannel::ALPHA:
|
||||
case ColorChannel::ALPHA:
|
||||
colorValue = qAlpha(*pixel);
|
||||
break;
|
||||
default:
|
||||
|
@ -260,7 +260,7 @@ void mapToRedChannel(QImage& image, TextureUsage::ColorChannel sourceChannel) {
|
|||
}
|
||||
}
|
||||
|
||||
gpu::TexturePointer processImage(std::shared_ptr<QIODevice> content, const std::string& filename, TextureUsage::ColorChannel sourceChannel,
|
||||
gpu::TexturePointer processImage(std::shared_ptr<QIODevice> content, const std::string& filename, ColorChannel sourceChannel,
|
||||
int maxNumPixels, TextureUsage::Type textureType,
|
||||
bool compress, BackendTarget target, const std::atomic<bool>& abortProcessing) {
|
||||
|
||||
|
@ -293,7 +293,7 @@ gpu::TexturePointer processImage(std::shared_ptr<QIODevice> content, const std::
|
|||
}
|
||||
|
||||
// Re-map to image with single red channel texture if requested
|
||||
if (sourceChannel != TextureUsage::ColorChannel::NONE) {
|
||||
if (sourceChannel != ColorChannel::NONE) {
|
||||
mapToRedChannel(image, sourceChannel);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
|
||||
#include <gpu/Texture.h>
|
||||
|
||||
#include "ColorChannel.h"
|
||||
|
||||
class QByteArray;
|
||||
class QImage;
|
||||
|
||||
|
@ -90,7 +92,7 @@ gpu::TexturePointer processCubeTextureColorFromImage(QImage&& srcImage, const st
|
|||
|
||||
const QStringList getSupportedFormats();
|
||||
|
||||
gpu::TexturePointer processImage(std::shared_ptr<QIODevice> content, const std::string& url, TextureUsage::ColorChannel sourceChannel,
|
||||
gpu::TexturePointer processImage(std::shared_ptr<QIODevice> content, const std::string& url, ColorChannel sourceChannel,
|
||||
int maxNumPixels, TextureUsage::Type textureType,
|
||||
bool compress, gpu::BackendTarget target, const std::atomic<bool>& abortProcessing = false);
|
||||
|
||||
|
|
|
@ -192,7 +192,7 @@ public:
|
|||
image::TextureUsage::Type type;
|
||||
const QByteArray& content;
|
||||
int maxNumPixels;
|
||||
hfm::ColorChannel sourceChannel;
|
||||
image::ColorChannel sourceChannel;
|
||||
};
|
||||
|
||||
namespace std {
|
||||
|
@ -213,13 +213,13 @@ namespace std {
|
|||
};
|
||||
}
|
||||
|
||||
ScriptableResource* TextureCache::prefetch(const QUrl& url, int type, int maxNumPixels, hfm::ColorChannel sourceChannel) {
|
||||
ScriptableResource* TextureCache::prefetch(const QUrl& url, int type, int maxNumPixels, image::ColorChannel sourceChannel) {
|
||||
auto byteArray = QByteArray();
|
||||
TextureExtra extra = { (image::TextureUsage::Type)type, byteArray, maxNumPixels, sourceChannel };
|
||||
return ResourceCache::prefetch(url, &extra, std::hash<TextureExtra>()(extra));
|
||||
}
|
||||
|
||||
NetworkTexturePointer TextureCache::getTexture(const QUrl& url, image::TextureUsage::Type type, const QByteArray& content, int maxNumPixels, hfm::ColorChannel sourceChannel) {
|
||||
NetworkTexturePointer TextureCache::getTexture(const QUrl& url, image::TextureUsage::Type type, const QByteArray& content, int maxNumPixels, image::ColorChannel sourceChannel) {
|
||||
if (url.scheme() == RESOURCE_SCHEME) {
|
||||
return getResourceTexture(url);
|
||||
}
|
||||
|
@ -371,7 +371,7 @@ void NetworkTexture::setExtra(void* extra) {
|
|||
const TextureExtra* textureExtra = static_cast<const TextureExtra*>(extra);
|
||||
_type = textureExtra ? textureExtra->type : image::TextureUsage::DEFAULT_TEXTURE;
|
||||
_maxNumPixels = textureExtra ? textureExtra->maxNumPixels : ABSOLUTE_MAX_TEXTURE_NUM_PIXELS;
|
||||
_sourceChannel = textureExtra ? textureExtra->sourceChannel : hfm::ColorChannel::NONE;
|
||||
_sourceChannel = textureExtra ? textureExtra->sourceChannel : image::ColorChannel::NONE;
|
||||
|
||||
_textureSource = std::make_shared<gpu::TextureSource>(_url, (int)_type);
|
||||
_lowestRequestedMipLevel = 0;
|
||||
|
@ -434,7 +434,7 @@ class ImageReader : public QRunnable {
|
|||
public:
|
||||
ImageReader(const QWeakPointer<Resource>& resource, const QUrl& url,
|
||||
const QByteArray& data, size_t extraHash, int maxNumPixels,
|
||||
hfm::ColorChannel sourceChannel);
|
||||
image::ColorChannel sourceChannel);
|
||||
void run() override final;
|
||||
void read();
|
||||
|
||||
|
@ -446,7 +446,7 @@ private:
|
|||
QByteArray _content;
|
||||
size_t _extraHash;
|
||||
int _maxNumPixels;
|
||||
hfm::ColorChannel _sourceChannel;
|
||||
image::ColorChannel _sourceChannel;
|
||||
};
|
||||
|
||||
NetworkTexture::~NetworkTexture() {
|
||||
|
@ -1104,7 +1104,7 @@ void NetworkTexture::refresh() {
|
|||
Resource::refresh();
|
||||
}
|
||||
|
||||
ImageReader::ImageReader(const QWeakPointer<Resource>& resource, const QUrl& url, const QByteArray& data, size_t extraHash, int maxNumPixels, hfm::ColorChannel sourceChannel) :
|
||||
ImageReader::ImageReader(const QWeakPointer<Resource>& resource, const QUrl& url, const QByteArray& data, size_t extraHash, int maxNumPixels, image::ColorChannel sourceChannel) :
|
||||
_resource(resource),
|
||||
_url(url),
|
||||
_content(data),
|
||||
|
@ -1218,7 +1218,7 @@ void ImageReader::read() {
|
|||
constexpr bool shouldCompress = false;
|
||||
#endif
|
||||
auto target = getBackendTarget();
|
||||
texture = image::processImage(std::move(buffer), _url.toString().toStdString(), (image::TextureUsage::ColorChannel)_sourceChannel, _maxNumPixels, networkTexture->getTextureType(), shouldCompress, target);
|
||||
texture = image::processImage(std::move(buffer), _url.toString().toStdString(), _sourceChannel, _maxNumPixels, networkTexture->getTextureType(), shouldCompress, target);
|
||||
|
||||
if (!texture) {
|
||||
QMetaObject::invokeMethod(resource.data(), "setImage",
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include <DependencyManager.h>
|
||||
#include <ResourceCache.h>
|
||||
#include <graphics/TextureMap.h>
|
||||
#include <hfm/ColorChannel.h>
|
||||
#include <image/ColorChannel.h>
|
||||
#include <image/Image.h>
|
||||
#include <ktx/KTX.h>
|
||||
#include <TextureMeta.h>
|
||||
|
@ -97,7 +97,7 @@ private:
|
|||
friend class ImageReader;
|
||||
|
||||
image::TextureUsage::Type _type;
|
||||
hfm::ColorChannel _sourceChannel;
|
||||
image::ColorChannel _sourceChannel;
|
||||
|
||||
enum class ResourceType {
|
||||
META,
|
||||
|
@ -181,7 +181,7 @@ public:
|
|||
/// Loads a texture from the specified URL.
|
||||
NetworkTexturePointer getTexture(const QUrl& url, image::TextureUsage::Type type = image::TextureUsage::DEFAULT_TEXTURE,
|
||||
const QByteArray& content = QByteArray(), int maxNumPixels = ABSOLUTE_MAX_TEXTURE_NUM_PIXELS,
|
||||
hfm::ColorChannel sourceChannel = hfm::ColorChannel::NONE);
|
||||
image::ColorChannel sourceChannel = image::ColorChannel::NONE);
|
||||
|
||||
gpu::TexturePointer getTextureByHash(const std::string& hash);
|
||||
gpu::TexturePointer cacheTextureByHash(const std::string& hash, const gpu::TexturePointer& texture);
|
||||
|
@ -204,7 +204,7 @@ signals:
|
|||
protected:
|
||||
|
||||
// Overload ResourceCache::prefetch to allow specifying texture type for loads
|
||||
Q_INVOKABLE ScriptableResource* prefetch(const QUrl& url, int type, int maxNumPixels = ABSOLUTE_MAX_TEXTURE_NUM_PIXELS, hfm::ColorChannel sourceChannel = hfm::ColorChannel::NONE);
|
||||
Q_INVOKABLE ScriptableResource* prefetch(const QUrl& url, int type, int maxNumPixels = ABSOLUTE_MAX_TEXTURE_NUM_PIXELS, image::ColorChannel sourceChannel = image::ColorChannel::NONE);
|
||||
|
||||
virtual QSharedPointer<Resource> createResource(const QUrl& url) override;
|
||||
QSharedPointer<Resource> createResourceCopy(const QSharedPointer<Resource>& resource) override;
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
set(TARGET_NAME procedural)
|
||||
setup_hifi_library()
|
||||
link_hifi_libraries(shared gpu shaders networking graphics model-networking ktx image)
|
||||
|
||||
include_hifi_library_headers(hfm)
|
||||
|
|
Loading…
Reference in a new issue