mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
web textures work on image entities, create supports negative materialMappingScale
This commit is contained in:
parent
a87d6e5182
commit
7ff796af3e
6 changed files with 30 additions and 15 deletions
|
@ -274,6 +274,7 @@ void WebEntityRenderer::doRender(RenderArgs* args) {
|
|||
|
||||
// Try to update the texture
|
||||
OffscreenQmlSurface::TextureAndFence newTextureAndFence;
|
||||
QSize windowSize;
|
||||
bool newTextureAvailable = false;
|
||||
if (!resultWithReadLock<bool>([&] {
|
||||
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);
|
||||
|
|
|
@ -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<gpu::TexturePointer()> textureOperator) {
|
||||
void TextureSource::resetTextureOperator(const std::function<gpu::TexturePointer()>& textureOperator) {
|
||||
_gpuTexture = nullptr;
|
||||
_gpuTextureOperator = textureOperator;
|
||||
}
|
||||
|
|
|
@ -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<gpu::TexturePointer()> textureOperator);
|
||||
void resetTexture(const gpu::TexturePointer& texture);
|
||||
void resetTextureOperator(const std::function<gpu::TexturePointer()>& textureOperator);
|
||||
|
||||
bool isDefined() const;
|
||||
std::function<gpu::TexturePointer()> getTextureOperator() const { return _gpuTextureOperator; }
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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 };
|
||||
|
|
|
@ -918,7 +918,6 @@ const GROUPS = [
|
|||
label: "Material Scale",
|
||||
type: "vec2",
|
||||
vec2Type: "xyz",
|
||||
min: 0,
|
||||
step: 0.1,
|
||||
decimals: 4,
|
||||
subLabels: [ "x", "y" ],
|
||||
|
|
Loading…
Reference in a new issue