diff --git a/libraries/entities-renderer/src/RenderableWebEntityItem.cpp b/libraries/entities-renderer/src/RenderableWebEntityItem.cpp index 7932a19110..6e436a0dcd 100644 --- a/libraries/entities-renderer/src/RenderableWebEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableWebEntityItem.cpp @@ -274,6 +274,7 @@ void WebEntityRenderer::doRender(RenderArgs* args) { // Try to update the texture OffscreenQmlSurface::TextureAndFence newTextureAndFence; + QSize windowSize; bool newTextureAvailable = false; if (!resultWithReadLock([&] { if (!_webSurface) { @@ -281,6 +282,7 @@ void WebEntityRenderer::doRender(RenderArgs* args) { } newTextureAvailable = _webSurface->fetchTexture(newTextureAndFence); + windowSize = _webSurface->size(); return true; })) { return; @@ -288,6 +290,8 @@ void WebEntityRenderer::doRender(RenderArgs* args) { if (newTextureAvailable) { _texture->setExternalTexture(newTextureAndFence.first, newTextureAndFence.second); + _texture->setSize(windowSize.width(), windowSize.height()); + _texture->setOriginalSize(windowSize.width(), windowSize.height()); } static const glm::vec2 texMin(0.0f), texMax(1.0f), topLeft(-0.5f), bottomRight(0.5f); diff --git a/libraries/gpu/src/gpu/Texture.cpp b/libraries/gpu/src/gpu/Texture.cpp index 28d68f6271..099d6dc0d8 100755 --- a/libraries/gpu/src/gpu/Texture.cpp +++ b/libraries/gpu/src/gpu/Texture.cpp @@ -322,6 +322,16 @@ bool Texture::isDepthStencilRenderTarget() const { return (_texelFormat.getSemantic() == gpu::DEPTH) || (_texelFormat.getSemantic() == gpu::DEPTH_STENCIL); } +void Texture::setSize(int width, int height) { + _width = width; + _height = height; +} + +void Texture::setOriginalSize(int width, int height) { + _originalWidth = width; + _originalHeight = height; +} + uint16 Texture::evalDimMaxNumMips(uint16 size) { double largerDim = size; double val = log(largerDim)/log(2.0); @@ -894,12 +904,12 @@ const gpu::TexturePointer TextureSource::getGPUTexture() const { return _gpuTexture; } -void TextureSource::resetTexture(gpu::TexturePointer texture) { +void TextureSource::resetTexture(const gpu::TexturePointer& texture) { _gpuTexture = texture; _gpuTextureOperator = nullptr; } -void TextureSource::resetTextureOperator(std::function textureOperator) { +void TextureSource::resetTextureOperator(const std::function& textureOperator) { _gpuTexture = nullptr; _gpuTextureOperator = textureOperator; } diff --git a/libraries/gpu/src/gpu/Texture.h b/libraries/gpu/src/gpu/Texture.h index 63c2d4c0b6..750141ecf6 100755 --- a/libraries/gpu/src/gpu/Texture.h +++ b/libraries/gpu/src/gpu/Texture.h @@ -417,11 +417,16 @@ public: Element getTexelFormat() const { return _texelFormat; } + void setSize(int width, int height); Vec3u getDimensions() const { return Vec3u(_width, _height, _depth); } uint16 getWidth() const { return _width; } uint16 getHeight() const { return _height; } uint16 getDepth() const { return _depth; } + void setOriginalSize(int width, int height); + int getOriginalWidth() const { return _originalWidth; } + int getOriginalHeight() const { return _originalHeight; } + // The number of faces is mostly used for cube map, and maybe for stereo ? otherwise it's 1 // For cube maps, this means the pixels of the different faces are supposed to be packed back to back in a mip // as if the height was NUM_FACES time bigger. @@ -615,6 +620,8 @@ protected: uint16 _width { 1 }; uint16 _height { 1 }; uint16 _depth { 1 }; + int _originalWidth { 0 }; + int _originalHeight { 0 }; uint16 _numSamples { 1 }; @@ -711,8 +718,8 @@ public: void setType(int type) { _type = type; } int getType() const { return _type; } - void resetTexture(gpu::TexturePointer texture); - void resetTextureOperator(std::function textureOperator); + void resetTexture(const gpu::TexturePointer& texture); + void resetTextureOperator(const std::function& textureOperator); bool isDefined() const; std::function getTextureOperator() const { return _gpuTextureOperator; } diff --git a/libraries/material-networking/src/material-networking/TextureCache.cpp b/libraries/material-networking/src/material-networking/TextureCache.cpp index 288d35c0f6..459eaff2a4 100644 --- a/libraries/material-networking/src/material-networking/TextureCache.cpp +++ b/libraries/material-networking/src/material-networking/TextureCache.cpp @@ -390,8 +390,6 @@ NetworkTexture::NetworkTexture(const NetworkTexture& other) : _type(other._type), _sourceChannel(other._sourceChannel), _currentlyLoadingResourceType(other._currentlyLoadingResourceType), - _originalWidth(other._originalWidth), - _originalHeight(other._originalHeight), _width(other._width), _height(other._height), _maxNumPixels(other._maxNumPixels), @@ -467,13 +465,12 @@ void NetworkTexture::setExtra(void* extra) { void NetworkTexture::setImage(gpu::TexturePointer texture, int originalWidth, int originalHeight) { - _originalWidth = originalWidth; - _originalHeight = originalHeight; // Passing ownership _textureSource->resetTexture(texture); if (texture) { + texture->setOriginalSize(originalWidth, originalHeight); _width = texture->getWidth(); _height = texture->getHeight(); setSize(texture->getStoredSize()); diff --git a/libraries/material-networking/src/material-networking/TextureCache.h b/libraries/material-networking/src/material-networking/TextureCache.h index adf600d810..40b3d1e124 100644 --- a/libraries/material-networking/src/material-networking/TextureCache.h +++ b/libraries/material-networking/src/material-networking/TextureCache.h @@ -58,10 +58,10 @@ public: QString getType() const override { return "NetworkTexture"; } - int getOriginalWidth() const { return _originalWidth; } - int getOriginalHeight() const { return _originalHeight; } - int getWidth() const { return _width; } - int getHeight() const { return _height; } + int getOriginalWidth() const { return _textureSource->getGPUTexture() ? _textureSource->getGPUTexture()->getOriginalWidth() : 0; } + int getOriginalHeight() const { return _textureSource->getGPUTexture() ? _textureSource->getGPUTexture()->getOriginalHeight() : 0; } + int getWidth() const { return _textureSource->getGPUTexture() ? _textureSource->getGPUTexture()->getWidth() : 0; } + int getHeight() const { return _textureSource->getGPUTexture() ? _textureSource->getGPUTexture()->getHeight() : 0; } image::TextureUsage::Type getTextureType() const { return _type; } gpu::TexturePointer getFallbackTexture() const; @@ -143,8 +143,6 @@ private: // mip offsets to change. ktx::KTXDescriptorPointer _originalKtxDescriptor; - int _originalWidth { 0 }; - int _originalHeight { 0 }; int _width { 0 }; int _height { 0 }; int _maxNumPixels { ABSOLUTE_MAX_TEXTURE_NUM_PIXELS }; diff --git a/scripts/system/create/entityProperties/html/js/entityProperties.js b/scripts/system/create/entityProperties/html/js/entityProperties.js index a7800b3e73..68e3fdc7c3 100644 --- a/scripts/system/create/entityProperties/html/js/entityProperties.js +++ b/scripts/system/create/entityProperties/html/js/entityProperties.js @@ -918,7 +918,6 @@ const GROUPS = [ label: "Material Scale", type: "vec2", vec2Type: "xyz", - min: 0, step: 0.1, decimals: 4, subLabels: [ "x", "y" ],