mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-24 01:24:00 +02:00
Merge pull request #14890 from sabrina-shanman/gltf_mat-support
(case 20980) Add support for Roughness/Metallic in GLTF models
This commit is contained in:
commit
1330b108d6
15 changed files with 117 additions and 18 deletions
|
@ -4,5 +4,6 @@ link_hifi_libraries(shared graphics fbx)
|
||||||
include_hifi_library_headers(networking)
|
include_hifi_library_headers(networking)
|
||||||
include_hifi_library_headers(gpu)
|
include_hifi_library_headers(gpu)
|
||||||
include_hifi_library_headers(hfm)
|
include_hifi_library_headers(hfm)
|
||||||
|
include_hifi_library_headers(image)
|
||||||
|
|
||||||
target_nsight()
|
target_nsight()
|
||||||
|
|
|
@ -154,7 +154,7 @@ void TextureBaker::processTexture() {
|
||||||
gpu::BackendTarget::GLES32
|
gpu::BackendTarget::GLES32
|
||||||
}};
|
}};
|
||||||
for (auto target : BACKEND_TARGETS) {
|
for (auto target : BACKEND_TARGETS) {
|
||||||
auto processedTexture = image::processImage(buffer, _textureURL.toString().toStdString(),
|
auto processedTexture = image::processImage(buffer, _textureURL.toString().toStdString(), image::ColorChannel::NONE,
|
||||||
ABSOLUTE_MAX_TEXTURE_NUM_PIXELS, _textureType, true,
|
ABSOLUTE_MAX_TEXTURE_NUM_PIXELS, _textureType, true,
|
||||||
target, _abortProcessing);
|
target, _abortProcessing);
|
||||||
if (!processedTexture) {
|
if (!processedTexture) {
|
||||||
|
@ -197,7 +197,7 @@ void TextureBaker::processTexture() {
|
||||||
// Uncompressed KTX
|
// Uncompressed KTX
|
||||||
if (_textureType == image::TextureUsage::Type::CUBE_TEXTURE) {
|
if (_textureType == image::TextureUsage::Type::CUBE_TEXTURE) {
|
||||||
buffer->reset();
|
buffer->reset();
|
||||||
auto processedTexture = image::processImage(std::move(buffer), _textureURL.toString().toStdString(),
|
auto processedTexture = image::processImage(std::move(buffer), _textureURL.toString().toStdString(), image::ColorChannel::NONE,
|
||||||
ABSOLUTE_MAX_TEXTURE_NUM_PIXELS, _textureType, false, gpu::BackendTarget::GL45, _abortProcessing);
|
ABSOLUTE_MAX_TEXTURE_NUM_PIXELS, _textureType, false, gpu::BackendTarget::GL45, _abortProcessing);
|
||||||
if (!processedTexture) {
|
if (!processedTexture) {
|
||||||
handleError("Could not process texture " + _textureURL.toString());
|
handleError("Could not process texture " + _textureURL.toString());
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include <NetworkAccessManager.h>
|
#include <NetworkAccessManager.h>
|
||||||
#include <ResourceManager.h>
|
#include <ResourceManager.h>
|
||||||
#include <PathUtils.h>
|
#include <PathUtils.h>
|
||||||
|
#include <image/ColorChannel.h>
|
||||||
|
|
||||||
#include "FBXSerializer.h"
|
#include "FBXSerializer.h"
|
||||||
|
|
||||||
|
@ -1146,8 +1147,10 @@ void GLTFSerializer::setHFMMaterial(HFMMaterial& fbxmat, const GLTFMaterial& mat
|
||||||
}
|
}
|
||||||
if (material.pbrMetallicRoughness.defined["metallicRoughnessTexture"]) {
|
if (material.pbrMetallicRoughness.defined["metallicRoughnessTexture"]) {
|
||||||
fbxmat.roughnessTexture = getHFMTexture(_file.textures[material.pbrMetallicRoughness.metallicRoughnessTexture]);
|
fbxmat.roughnessTexture = getHFMTexture(_file.textures[material.pbrMetallicRoughness.metallicRoughnessTexture]);
|
||||||
|
fbxmat.roughnessTexture.sourceChannel = image::ColorChannel::GREEN;
|
||||||
fbxmat.useRoughnessMap = true;
|
fbxmat.useRoughnessMap = true;
|
||||||
fbxmat.metallicTexture = getHFMTexture(_file.textures[material.pbrMetallicRoughness.metallicRoughnessTexture]);
|
fbxmat.metallicTexture = getHFMTexture(_file.textures[material.pbrMetallicRoughness.metallicRoughnessTexture]);
|
||||||
|
fbxmat.metallicTexture.sourceChannel = image::ColorChannel::BLUE;
|
||||||
fbxmat.useMetallicMap = true;
|
fbxmat.useMetallicMap = true;
|
||||||
}
|
}
|
||||||
if (material.pbrMetallicRoughness.defined["roughnessFactor"]) {
|
if (material.pbrMetallicRoughness.defined["roughnessFactor"]) {
|
||||||
|
|
|
@ -5,3 +5,4 @@ link_hifi_libraries(shared)
|
||||||
|
|
||||||
include_hifi_library_headers(gpu)
|
include_hifi_library_headers(gpu)
|
||||||
include_hifi_library_headers(graphics)
|
include_hifi_library_headers(graphics)
|
||||||
|
include_hifi_library_headers(image)
|
||||||
|
|
|
@ -25,6 +25,8 @@
|
||||||
#include <graphics/Geometry.h>
|
#include <graphics/Geometry.h>
|
||||||
#include <graphics/Material.h>
|
#include <graphics/Material.h>
|
||||||
|
|
||||||
|
#include <image/ColorChannel.h>
|
||||||
|
|
||||||
#if defined(Q_OS_ANDROID)
|
#if defined(Q_OS_ANDROID)
|
||||||
#define HFM_PACK_NORMALS 0
|
#define HFM_PACK_NORMALS 0
|
||||||
#else
|
#else
|
||||||
|
@ -123,6 +125,7 @@ public:
|
||||||
QString name;
|
QString name;
|
||||||
QByteArray filename;
|
QByteArray filename;
|
||||||
QByteArray content;
|
QByteArray content;
|
||||||
|
image::ColorChannel sourceChannel { image::ColorChannel::NONE };
|
||||||
|
|
||||||
Transform transform;
|
Transform transform;
|
||||||
int maxNumPixels { MAX_NUM_PIXELS_FOR_FBX_TEXTURE };
|
int maxNumPixels { MAX_NUM_PIXELS_FOR_FBX_TEXTURE };
|
||||||
|
|
26
libraries/image/src/image/ColorChannel.h
Normal file
26
libraries/image/src/image/ColorChannel.h
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
//
|
||||||
|
// ColorChannel.h
|
||||||
|
// libraries/image/src/image
|
||||||
|
//
|
||||||
|
// Created by Sabrina Shanman on 2019/02/12.
|
||||||
|
// Copyright 2019 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef hifi_image_ColorChannel_h
|
||||||
|
#define hifi_image_ColorChannel_h
|
||||||
|
|
||||||
|
namespace image {
|
||||||
|
enum class ColorChannel {
|
||||||
|
NONE,
|
||||||
|
RED,
|
||||||
|
GREEN,
|
||||||
|
BLUE,
|
||||||
|
ALPHA,
|
||||||
|
COUNT
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // hifi_image_ColorChannel_h
|
|
@ -16,6 +16,7 @@
|
||||||
#include <QtCore/QtGlobal>
|
#include <QtCore/QtGlobal>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
|
#include <QRgb>
|
||||||
#include <QBuffer>
|
#include <QBuffer>
|
||||||
#include <QImageReader>
|
#include <QImageReader>
|
||||||
|
|
||||||
|
@ -221,7 +222,45 @@ QImage processRawImageData(QIODevice& content, const std::string& filename) {
|
||||||
return QImage();
|
return QImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
gpu::TexturePointer processImage(std::shared_ptr<QIODevice> content, const std::string& filename,
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < image.height(); i++) {
|
||||||
|
QRgb* pixel = reinterpret_cast<QRgb*>(image.scanLine(i));
|
||||||
|
// Past end pointer
|
||||||
|
QRgb* lineEnd = pixel + image.width();
|
||||||
|
|
||||||
|
// Transfer channel data from source to target
|
||||||
|
for (; pixel < lineEnd; pixel++) {
|
||||||
|
int colorValue;
|
||||||
|
switch (sourceChannel) {
|
||||||
|
case ColorChannel::RED:
|
||||||
|
colorValue = qRed(*pixel);
|
||||||
|
break;
|
||||||
|
case ColorChannel::GREEN:
|
||||||
|
colorValue = qGreen(*pixel);
|
||||||
|
break;
|
||||||
|
case ColorChannel::BLUE:
|
||||||
|
colorValue = qBlue(*pixel);
|
||||||
|
break;
|
||||||
|
case ColorChannel::ALPHA:
|
||||||
|
colorValue = qAlpha(*pixel);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
colorValue = qRed(*pixel);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dump the color in the red channel, ignore the rest
|
||||||
|
*pixel = qRgba(colorValue, 0, 0, 255);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gpu::TexturePointer processImage(std::shared_ptr<QIODevice> content, const std::string& filename, ColorChannel sourceChannel,
|
||||||
int maxNumPixels, TextureUsage::Type textureType,
|
int maxNumPixels, TextureUsage::Type textureType,
|
||||||
bool compress, BackendTarget target, const std::atomic<bool>& abortProcessing) {
|
bool compress, BackendTarget target, const std::atomic<bool>& abortProcessing) {
|
||||||
|
|
||||||
|
@ -253,6 +292,11 @@ gpu::TexturePointer processImage(std::shared_ptr<QIODevice> content, const std::
|
||||||
QSize(imageWidth, imageHeight) << ")";
|
QSize(imageWidth, imageHeight) << ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Re-map to image with single red channel texture if requested
|
||||||
|
if (sourceChannel != ColorChannel::NONE) {
|
||||||
|
mapToRedChannel(image, sourceChannel);
|
||||||
|
}
|
||||||
|
|
||||||
auto loader = TextureUsage::getTextureLoaderForType(textureType);
|
auto loader = TextureUsage::getTextureLoaderForType(textureType);
|
||||||
auto texture = loader(std::move(image), filename, compress, target, abortProcessing);
|
auto texture = loader(std::move(image), filename, compress, target, abortProcessing);
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
#include <gpu/Texture.h>
|
#include <gpu/Texture.h>
|
||||||
|
|
||||||
|
#include "ColorChannel.h"
|
||||||
|
|
||||||
class QByteArray;
|
class QByteArray;
|
||||||
class QImage;
|
class QImage;
|
||||||
|
|
||||||
|
@ -81,7 +83,7 @@ gpu::TexturePointer processCubeTextureColorFromImage(QImage&& srcImage, const st
|
||||||
|
|
||||||
const QStringList getSupportedFormats();
|
const QStringList getSupportedFormats();
|
||||||
|
|
||||||
gpu::TexturePointer processImage(std::shared_ptr<QIODevice> content, const std::string& url,
|
gpu::TexturePointer processImage(std::shared_ptr<QIODevice> content, const std::string& url, ColorChannel sourceChannel,
|
||||||
int maxNumPixels, TextureUsage::Type textureType,
|
int maxNumPixels, TextureUsage::Type textureType,
|
||||||
bool compress, gpu::BackendTarget target, const std::atomic<bool>& abortProcessing = false);
|
bool compress, gpu::BackendTarget target, const std::atomic<bool>& abortProcessing = false);
|
||||||
|
|
||||||
|
|
|
@ -2,3 +2,5 @@ set(TARGET_NAME model-baker)
|
||||||
setup_hifi_library()
|
setup_hifi_library()
|
||||||
|
|
||||||
link_hifi_libraries(shared task gpu graphics hfm)
|
link_hifi_libraries(shared task gpu graphics hfm)
|
||||||
|
|
||||||
|
include_hifi_library_headers(image)
|
||||||
|
|
|
@ -599,7 +599,7 @@ graphics::TextureMapPointer NetworkMaterial::fetchTextureMap(const QUrl& baseUrl
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto url = getTextureUrl(baseUrl, hfmTexture);
|
const auto url = getTextureUrl(baseUrl, hfmTexture);
|
||||||
const auto texture = DependencyManager::get<TextureCache>()->getTexture(url, type, hfmTexture.content, hfmTexture.maxNumPixels);
|
const auto texture = DependencyManager::get<TextureCache>()->getTexture(url, type, hfmTexture.content, hfmTexture.maxNumPixels, hfmTexture.sourceChannel);
|
||||||
_textures[channel] = Texture { hfmTexture.name, texture };
|
_textures[channel] = Texture { hfmTexture.name, texture };
|
||||||
|
|
||||||
auto map = std::make_shared<graphics::TextureMap>();
|
auto map = std::make_shared<graphics::TextureMap>();
|
||||||
|
|
|
@ -192,6 +192,7 @@ public:
|
||||||
image::TextureUsage::Type type;
|
image::TextureUsage::Type type;
|
||||||
const QByteArray& content;
|
const QByteArray& content;
|
||||||
int maxNumPixels;
|
int maxNumPixels;
|
||||||
|
image::ColorChannel sourceChannel;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace std {
|
namespace std {
|
||||||
|
@ -206,19 +207,19 @@ namespace std {
|
||||||
struct hash<TextureExtra> {
|
struct hash<TextureExtra> {
|
||||||
size_t operator()(const TextureExtra& a) const {
|
size_t operator()(const TextureExtra& a) const {
|
||||||
size_t result = 0;
|
size_t result = 0;
|
||||||
hash_combine(result, (int)a.type, a.content, a.maxNumPixels);
|
hash_combine(result, (int)a.type, a.content, a.maxNumPixels, (int)a.sourceChannel);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
ScriptableResource* TextureCache::prefetch(const QUrl& url, int type, int maxNumPixels) {
|
ScriptableResource* TextureCache::prefetch(const QUrl& url, int type, int maxNumPixels, image::ColorChannel sourceChannel) {
|
||||||
auto byteArray = QByteArray();
|
auto byteArray = QByteArray();
|
||||||
TextureExtra extra = { (image::TextureUsage::Type)type, byteArray, maxNumPixels };
|
TextureExtra extra = { (image::TextureUsage::Type)type, byteArray, maxNumPixels, sourceChannel };
|
||||||
return ResourceCache::prefetch(url, &extra, std::hash<TextureExtra>()(extra));
|
return ResourceCache::prefetch(url, &extra, std::hash<TextureExtra>()(extra));
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkTexturePointer TextureCache::getTexture(const QUrl& url, image::TextureUsage::Type type, const QByteArray& content, int maxNumPixels) {
|
NetworkTexturePointer TextureCache::getTexture(const QUrl& url, image::TextureUsage::Type type, const QByteArray& content, int maxNumPixels, image::ColorChannel sourceChannel) {
|
||||||
if (url.scheme() == RESOURCE_SCHEME) {
|
if (url.scheme() == RESOURCE_SCHEME) {
|
||||||
return getResourceTexture(url);
|
return getResourceTexture(url);
|
||||||
}
|
}
|
||||||
|
@ -228,7 +229,7 @@ NetworkTexturePointer TextureCache::getTexture(const QUrl& url, image::TextureUs
|
||||||
query.addQueryItem("skybox", "");
|
query.addQueryItem("skybox", "");
|
||||||
modifiedUrl.setQuery(query.toString());
|
modifiedUrl.setQuery(query.toString());
|
||||||
}
|
}
|
||||||
TextureExtra extra = { type, content, maxNumPixels };
|
TextureExtra extra = { type, content, maxNumPixels, sourceChannel };
|
||||||
return ResourceCache::getResource(modifiedUrl, QUrl(), &extra, std::hash<TextureExtra>()(extra)).staticCast<NetworkTexture>();
|
return ResourceCache::getResource(modifiedUrl, QUrl(), &extra, std::hash<TextureExtra>()(extra)).staticCast<NetworkTexture>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -346,6 +347,7 @@ NetworkTexture::NetworkTexture(const QUrl& url, bool resourceTexture) :
|
||||||
NetworkTexture::NetworkTexture(const NetworkTexture& other) :
|
NetworkTexture::NetworkTexture(const NetworkTexture& other) :
|
||||||
Resource(other),
|
Resource(other),
|
||||||
_type(other._type),
|
_type(other._type),
|
||||||
|
_sourceChannel(other._sourceChannel),
|
||||||
_currentlyLoadingResourceType(other._currentlyLoadingResourceType),
|
_currentlyLoadingResourceType(other._currentlyLoadingResourceType),
|
||||||
_originalWidth(other._originalWidth),
|
_originalWidth(other._originalWidth),
|
||||||
_originalHeight(other._originalHeight),
|
_originalHeight(other._originalHeight),
|
||||||
|
@ -353,6 +355,11 @@ NetworkTexture::NetworkTexture(const NetworkTexture& other) :
|
||||||
_height(other._height),
|
_height(other._height),
|
||||||
_maxNumPixels(other._maxNumPixels)
|
_maxNumPixels(other._maxNumPixels)
|
||||||
{
|
{
|
||||||
|
if (_width == 0 || _height == 0 ||
|
||||||
|
other._currentlyLoadingResourceType == ResourceType::META ||
|
||||||
|
(other._currentlyLoadingResourceType == ResourceType::KTX && other._ktxResourceState != KTXResourceState::WAITING_FOR_MIP_REQUEST)) {
|
||||||
|
_startedLoading = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isLocalUrl(const QUrl& url) {
|
static bool isLocalUrl(const QUrl& url) {
|
||||||
|
@ -364,6 +371,7 @@ void NetworkTexture::setExtra(void* extra) {
|
||||||
const TextureExtra* textureExtra = static_cast<const TextureExtra*>(extra);
|
const TextureExtra* textureExtra = static_cast<const TextureExtra*>(extra);
|
||||||
_type = textureExtra ? textureExtra->type : image::TextureUsage::DEFAULT_TEXTURE;
|
_type = textureExtra ? textureExtra->type : image::TextureUsage::DEFAULT_TEXTURE;
|
||||||
_maxNumPixels = textureExtra ? textureExtra->maxNumPixels : ABSOLUTE_MAX_TEXTURE_NUM_PIXELS;
|
_maxNumPixels = textureExtra ? textureExtra->maxNumPixels : ABSOLUTE_MAX_TEXTURE_NUM_PIXELS;
|
||||||
|
_sourceChannel = textureExtra ? textureExtra->sourceChannel : image::ColorChannel::NONE;
|
||||||
|
|
||||||
_textureSource = std::make_shared<gpu::TextureSource>(_url, (int)_type);
|
_textureSource = std::make_shared<gpu::TextureSource>(_url, (int)_type);
|
||||||
_lowestRequestedMipLevel = 0;
|
_lowestRequestedMipLevel = 0;
|
||||||
|
@ -425,7 +433,8 @@ gpu::TexturePointer NetworkTexture::getFallbackTexture() const {
|
||||||
class ImageReader : public QRunnable {
|
class ImageReader : public QRunnable {
|
||||||
public:
|
public:
|
||||||
ImageReader(const QWeakPointer<Resource>& resource, const QUrl& url,
|
ImageReader(const QWeakPointer<Resource>& resource, const QUrl& url,
|
||||||
const QByteArray& data, size_t extraHash, int maxNumPixels);
|
const QByteArray& data, size_t extraHash, int maxNumPixels,
|
||||||
|
image::ColorChannel sourceChannel);
|
||||||
void run() override final;
|
void run() override final;
|
||||||
void read();
|
void read();
|
||||||
|
|
||||||
|
@ -437,6 +446,7 @@ private:
|
||||||
QByteArray _content;
|
QByteArray _content;
|
||||||
size_t _extraHash;
|
size_t _extraHash;
|
||||||
int _maxNumPixels;
|
int _maxNumPixels;
|
||||||
|
image::ColorChannel _sourceChannel;
|
||||||
};
|
};
|
||||||
|
|
||||||
NetworkTexture::~NetworkTexture() {
|
NetworkTexture::~NetworkTexture() {
|
||||||
|
@ -1069,7 +1079,7 @@ void NetworkTexture::loadTextureContent(const QByteArray& content) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QThreadPool::globalInstance()->start(new ImageReader(_self, _url, content, _extraHash, _maxNumPixels));
|
QThreadPool::globalInstance()->start(new ImageReader(_self, _url, content, _extraHash, _maxNumPixels, _sourceChannel));
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkTexture::refresh() {
|
void NetworkTexture::refresh() {
|
||||||
|
@ -1094,12 +1104,13 @@ void NetworkTexture::refresh() {
|
||||||
Resource::refresh();
|
Resource::refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageReader::ImageReader(const QWeakPointer<Resource>& resource, const QUrl& url, const QByteArray& data, size_t extraHash, int maxNumPixels) :
|
ImageReader::ImageReader(const QWeakPointer<Resource>& resource, const QUrl& url, const QByteArray& data, size_t extraHash, int maxNumPixels, image::ColorChannel sourceChannel) :
|
||||||
_resource(resource),
|
_resource(resource),
|
||||||
_url(url),
|
_url(url),
|
||||||
_content(data),
|
_content(data),
|
||||||
_extraHash(extraHash),
|
_extraHash(extraHash),
|
||||||
_maxNumPixels(maxNumPixels)
|
_maxNumPixels(maxNumPixels),
|
||||||
|
_sourceChannel(sourceChannel)
|
||||||
{
|
{
|
||||||
DependencyManager::get<StatTracker>()->incrementStat("PendingProcessing");
|
DependencyManager::get<StatTracker>()->incrementStat("PendingProcessing");
|
||||||
listSupportedImageFormats();
|
listSupportedImageFormats();
|
||||||
|
@ -1207,7 +1218,7 @@ void ImageReader::read() {
|
||||||
constexpr bool shouldCompress = false;
|
constexpr bool shouldCompress = false;
|
||||||
#endif
|
#endif
|
||||||
auto target = getBackendTarget();
|
auto target = getBackendTarget();
|
||||||
texture = image::processImage(std::move(buffer), _url.toString().toStdString(), _maxNumPixels, networkTexture->getTextureType(), shouldCompress, target);
|
texture = image::processImage(std::move(buffer), _url.toString().toStdString(), _sourceChannel, _maxNumPixels, networkTexture->getTextureType(), shouldCompress, target);
|
||||||
|
|
||||||
if (!texture) {
|
if (!texture) {
|
||||||
QMetaObject::invokeMethod(resource.data(), "setImage",
|
QMetaObject::invokeMethod(resource.data(), "setImage",
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include <DependencyManager.h>
|
#include <DependencyManager.h>
|
||||||
#include <ResourceCache.h>
|
#include <ResourceCache.h>
|
||||||
#include <graphics/TextureMap.h>
|
#include <graphics/TextureMap.h>
|
||||||
|
#include <image/ColorChannel.h>
|
||||||
#include <image/Image.h>
|
#include <image/Image.h>
|
||||||
#include <ktx/KTX.h>
|
#include <ktx/KTX.h>
|
||||||
#include <TextureMeta.h>
|
#include <TextureMeta.h>
|
||||||
|
@ -96,6 +97,7 @@ private:
|
||||||
friend class ImageReader;
|
friend class ImageReader;
|
||||||
|
|
||||||
image::TextureUsage::Type _type;
|
image::TextureUsage::Type _type;
|
||||||
|
image::ColorChannel _sourceChannel;
|
||||||
|
|
||||||
enum class ResourceType {
|
enum class ResourceType {
|
||||||
META,
|
META,
|
||||||
|
@ -178,7 +180,8 @@ public:
|
||||||
|
|
||||||
/// Loads a texture from the specified URL.
|
/// Loads a texture from the specified URL.
|
||||||
NetworkTexturePointer getTexture(const QUrl& url, image::TextureUsage::Type type = image::TextureUsage::DEFAULT_TEXTURE,
|
NetworkTexturePointer getTexture(const QUrl& url, image::TextureUsage::Type type = image::TextureUsage::DEFAULT_TEXTURE,
|
||||||
const QByteArray& content = QByteArray(), int maxNumPixels = ABSOLUTE_MAX_TEXTURE_NUM_PIXELS);
|
const QByteArray& content = QByteArray(), int maxNumPixels = ABSOLUTE_MAX_TEXTURE_NUM_PIXELS,
|
||||||
|
image::ColorChannel sourceChannel = image::ColorChannel::NONE);
|
||||||
|
|
||||||
gpu::TexturePointer getTextureByHash(const std::string& hash);
|
gpu::TexturePointer getTextureByHash(const std::string& hash);
|
||||||
gpu::TexturePointer cacheTextureByHash(const std::string& hash, const gpu::TexturePointer& texture);
|
gpu::TexturePointer cacheTextureByHash(const std::string& hash, const gpu::TexturePointer& texture);
|
||||||
|
@ -201,7 +204,7 @@ signals:
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// Overload ResourceCache::prefetch to allow specifying texture type for loads
|
// 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);
|
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;
|
virtual QSharedPointer<Resource> createResource(const QUrl& url) override;
|
||||||
QSharedPointer<Resource> createResourceCopy(const QSharedPointer<Resource>& resource) override;
|
QSharedPointer<Resource> createResourceCopy(const QSharedPointer<Resource>& resource) override;
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
set(TARGET_NAME procedural)
|
set(TARGET_NAME procedural)
|
||||||
setup_hifi_library()
|
setup_hifi_library()
|
||||||
link_hifi_libraries(shared gpu shaders networking graphics model-networking ktx image)
|
link_hifi_libraries(shared gpu shaders networking graphics model-networking ktx image)
|
||||||
|
|
||||||
|
|
|
@ -2,3 +2,5 @@ set(TARGET_NAME skeleton-dump)
|
||||||
setup_hifi_project(Core)
|
setup_hifi_project(Core)
|
||||||
setup_memory_debugger()
|
setup_memory_debugger()
|
||||||
link_hifi_libraries(shared fbx hfm graphics gpu gl animation)
|
link_hifi_libraries(shared fbx hfm graphics gpu gl animation)
|
||||||
|
|
||||||
|
include_hifi_library_headers(image)
|
||||||
|
|
|
@ -2,6 +2,8 @@ set(TARGET_NAME vhacd-util)
|
||||||
setup_hifi_project(Core)
|
setup_hifi_project(Core)
|
||||||
link_hifi_libraries(shared fbx hfm graphics gpu gl)
|
link_hifi_libraries(shared fbx hfm graphics gpu gl)
|
||||||
|
|
||||||
|
include_hifi_library_headers(image)
|
||||||
|
|
||||||
add_dependency_external_projects(vhacd)
|
add_dependency_external_projects(vhacd)
|
||||||
|
|
||||||
find_package(VHACD REQUIRED)
|
find_package(VHACD REQUIRED)
|
||||||
|
|
Loading…
Reference in a new issue