mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 12:28:02 +02:00
THese is not final but we have a basic working framework so let's try to share
This commit is contained in:
parent
72e01a7929
commit
ce5295a55f
9 changed files with 33 additions and 29 deletions
|
@ -3212,12 +3212,6 @@ void Application::displaySide(Camera& theCamera, bool selfAvatarOnly, RenderArgs
|
||||||
} else if (skyStage->getBackgroundMode() == model::SunSkyStage::SKY_BOX) {
|
} else if (skyStage->getBackgroundMode() == model::SunSkyStage::SKY_BOX) {
|
||||||
auto skybox = skyStage->getSkybox();
|
auto skybox = skyStage->getSkybox();
|
||||||
if (skybox) {
|
if (skybox) {
|
||||||
if (!skybox->getCubemap()) {
|
|
||||||
auto texture = DependencyManager::get<TextureCache>()->
|
|
||||||
getTexture(QUrl("https://hifi-public.s3.amazonaws.com/ryan/CloudyDay.png"), CUBE_TEXTURE);
|
|
||||||
skybox->setCubemap(texture->getGPUTexture());
|
|
||||||
}
|
|
||||||
|
|
||||||
gpu::Batch batch;
|
gpu::Batch batch;
|
||||||
model::Skybox::render(batch, _viewFrustum, *skybox);
|
model::Skybox::render(batch, _viewFrustum, *skybox);
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include <PerfStat.h>
|
#include <PerfStat.h>
|
||||||
#include <SceneScriptingInterface.h>
|
#include <SceneScriptingInterface.h>
|
||||||
#include <ScriptEngine.h>
|
#include <ScriptEngine.h>
|
||||||
|
#include <TextureCache.h>
|
||||||
|
|
||||||
#include "EntityTreeRenderer.h"
|
#include "EntityTreeRenderer.h"
|
||||||
|
|
||||||
|
@ -455,7 +456,9 @@ void EntityTreeRenderer::render(RenderArgs::RenderMode renderMode,
|
||||||
if (_bestZone->getSkyboxProperties().getURL().isEmpty()) {
|
if (_bestZone->getSkyboxProperties().getURL().isEmpty()) {
|
||||||
stage->getSkybox()->clearCubemap();
|
stage->getSkybox()->clearCubemap();
|
||||||
} else {
|
} else {
|
||||||
stage->getSkybox()->clearCubemap(); // NOTE: this should be changed to do something to set the cubemap
|
auto cubeMap = DependencyManager::get<TextureCache>()->getTexture(_bestZone->getSkyboxProperties().getURL(), CUBE_TEXTURE);
|
||||||
|
|
||||||
|
stage->getSkybox()->setCubemap(cubeMap->getGPUTexture()); // NOTE: this should be changed to do something to set the cubemap
|
||||||
}
|
}
|
||||||
stage->setBackgroundMode(model::SunSkyStage::SKY_BOX);
|
stage->setBackgroundMode(model::SunSkyStage::SKY_BOX);
|
||||||
}
|
}
|
||||||
|
|
|
@ -370,11 +370,9 @@ GLBackend::GLTexture* GLBackend::syncGPUObject(const Texture& texture) {
|
||||||
glBindTexture(GL_TEXTURE_CUBE_MAP, object->_texture);
|
glBindTexture(GL_TEXTURE_CUBE_MAP, object->_texture);
|
||||||
const int NUM_FACES = 6;
|
const int NUM_FACES = 6;
|
||||||
const GLenum FACE_LAYOUT[] = {
|
const GLenum FACE_LAYOUT[] = {
|
||||||
// GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
|
GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
|
||||||
GL_TEXTURE_CUBE_MAP_NEGATIVE_X, GL_TEXTURE_CUBE_MAP_POSITIVE_X,
|
|
||||||
GL_TEXTURE_CUBE_MAP_POSITIVE_Y, GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
|
GL_TEXTURE_CUBE_MAP_POSITIVE_Y, GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
|
||||||
GL_TEXTURE_CUBE_MAP_POSITIVE_Z, GL_TEXTURE_CUBE_MAP_NEGATIVE_Z };
|
GL_TEXTURE_CUBE_MAP_POSITIVE_Z, GL_TEXTURE_CUBE_MAP_NEGATIVE_Z };
|
||||||
|
|
||||||
if (needUpdate) {
|
if (needUpdate) {
|
||||||
if (texture.isStoredMipAvailable(0)) {
|
if (texture.isStoredMipAvailable(0)) {
|
||||||
Texture::PixelsPointer mip = texture.accessStoredMip(0);
|
Texture::PixelsPointer mip = texture.accessStoredMip(0);
|
||||||
|
|
|
@ -41,6 +41,7 @@ public:
|
||||||
NUM_MAPS,
|
NUM_MAPS,
|
||||||
};
|
};
|
||||||
typedef std::map<MapChannel, TextureView> TextureMap;
|
typedef std::map<MapChannel, TextureView> TextureMap;
|
||||||
|
typedef std::bitset<NUM_MAPS> MapFlags;
|
||||||
|
|
||||||
enum FlagBit {
|
enum FlagBit {
|
||||||
DIFFUSE_BIT = 0,
|
DIFFUSE_BIT = 0,
|
||||||
|
|
|
@ -20,8 +20,8 @@
|
||||||
using namespace model;
|
using namespace model;
|
||||||
|
|
||||||
Skybox::Skybox() {
|
Skybox::Skybox() {
|
||||||
|
/*
|
||||||
/* _cubemap.reset( gpu::Texture::createCube(gpu::Element::COLOR_RGBA_32, 1));
|
_cubemap.reset( gpu::Texture::createCube(gpu::Element::COLOR_RGBA_32, 1));
|
||||||
unsigned char texels[] = {
|
unsigned char texels[] = {
|
||||||
255, 0, 0, 255,
|
255, 0, 0, 255,
|
||||||
0, 255, 255, 255,
|
0, 255, 255, 255,
|
||||||
|
@ -30,7 +30,7 @@ Skybox::Skybox() {
|
||||||
0, 255, 0, 255,
|
0, 255, 0, 255,
|
||||||
255, 0, 255, 255,
|
255, 0, 255, 255,
|
||||||
};
|
};
|
||||||
_cubemap->assignStoredMip(0, gpu::Element::COLOR_RGBA_32, sizeof(texels), texels); */
|
_cubemap->assignStoredMip(0, gpu::Element::COLOR_RGBA_32, sizeof(texels), texels);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void Skybox::setColor(const Color& color) {
|
void Skybox::setColor(const Color& color) {
|
||||||
|
|
|
@ -18,7 +18,8 @@ varying vec3 color;
|
||||||
|
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
vec4 texel = textureCube(cubeMap, normalize(normal));
|
vec3 coord = normalize(normal);
|
||||||
gl_FragData[0] = texel;
|
vec4 texel = textureCube(cubeMap, coord);
|
||||||
// gl_FragData[0] = vec4(normal, 1.0);
|
// gl_FragData[0] = vec4(texel.xyz * color, texel.w);
|
||||||
|
gl_FragData[0] = vec4(texel.xyz, 1.0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,16 +14,15 @@ using namespace model;
|
||||||
using namespace gpu;
|
using namespace gpu;
|
||||||
|
|
||||||
// TextureStorage
|
// TextureStorage
|
||||||
TextureStorage::TextureStorage(const QUrl& url, Texture::Type type ) : Texture::Storage(),
|
TextureStorage::TextureStorage() : Texture::Storage(),
|
||||||
_url(url),
|
_gpuTexture(Texture::createFromStorage(this))
|
||||||
_type(type) {
|
{}
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
TextureStorage::~TextureStorage() {
|
TextureStorage::~TextureStorage() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureStorage::init() {
|
void TextureStorage::reset(const QUrl& url, const TextureUsage& usage) {
|
||||||
_gpuTexture = TexturePointer(Texture::createFromStorage(this));
|
_url = url;
|
||||||
|
_usage = usage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,24 +21,32 @@ namespace model {
|
||||||
|
|
||||||
typedef glm::vec3 Color;
|
typedef glm::vec3 Color;
|
||||||
|
|
||||||
|
class TextureUsage {
|
||||||
|
public:
|
||||||
|
gpu::Texture::Type _type{ gpu::Texture::TEX_2D };
|
||||||
|
Material::MapFlags _materialUsage{ Material::DIFFUSE_MAP };
|
||||||
|
|
||||||
|
int _environmentUsage = 0;
|
||||||
|
};
|
||||||
|
|
||||||
// TextureStorage is a specialized version of the gpu::Texture::Storage
|
// TextureStorage is a specialized version of the gpu::Texture::Storage
|
||||||
// It provides the mechanism to create a texture from a Url and the intended usage
|
// It provides the mechanism to create a texture from a Url and the intended usage
|
||||||
// that guides the internal format used
|
// that guides the internal format used
|
||||||
class TextureStorage : public gpu::Texture::Storage {
|
class TextureStorage : public gpu::Texture::Storage {
|
||||||
public:
|
public:
|
||||||
TextureStorage(const QUrl& url, gpu::Texture::Type type = gpu::Texture::TEX_2D);
|
TextureStorage();
|
||||||
~TextureStorage();
|
~TextureStorage();
|
||||||
|
|
||||||
const QUrl& getUrl() const { return _url; }
|
const QUrl& getUrl() const { return _url; }
|
||||||
const gpu::Texture::Type getType() const { return _type; }
|
const gpu::Texture::Type getType() const { return _usage._type; }
|
||||||
const gpu::TexturePointer& getGPUTexture() const { return _gpuTexture; }
|
const gpu::TexturePointer& getGPUTexture() const { return _gpuTexture; }
|
||||||
|
|
||||||
|
void reset(const QUrl& url, const TextureUsage& usage);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
gpu::TexturePointer _gpuTexture;
|
gpu::TexturePointer _gpuTexture;
|
||||||
|
TextureUsage _usage;
|
||||||
QUrl _url;
|
QUrl _url;
|
||||||
gpu::Texture::Type _type;
|
|
||||||
|
|
||||||
void init();
|
|
||||||
};
|
};
|
||||||
typedef std::shared_ptr< TextureStorage > TextureStoragePointer;
|
typedef std::shared_ptr< TextureStorage > TextureStoragePointer;
|
||||||
|
|
||||||
|
|
|
@ -525,7 +525,7 @@ void NetworkTexture::setImage(const QImage& image, bool translucent, const QColo
|
||||||
|
|
||||||
if (_type == CUBE_TEXTURE) {
|
if (_type == CUBE_TEXTURE) {
|
||||||
if (_height >= (6 * _width)) {
|
if (_height >= (6 * _width)) {
|
||||||
_gpuTexture = gpu::TexturePointer(gpu::Texture::createCube(formatGPU, image.width(), gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_POINT, gpu::Sampler::WRAP_CLAMP)));
|
_gpuTexture = gpu::TexturePointer(gpu::Texture::createCube(formatGPU, image.width(), gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_LINEAR, gpu::Sampler::WRAP_CLAMP)));
|
||||||
_gpuTexture->assignStoredMip(0, formatMip, image.byteCount(), image.constBits());
|
_gpuTexture->assignStoredMip(0, formatMip, image.byteCount(), image.constBits());
|
||||||
_gpuTexture->autoGenerateMips(-1);
|
_gpuTexture->autoGenerateMips(-1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue