diff --git a/modules/globebrowsing/shaders/interpolate_fs.glsl b/modules/globebrowsing/shaders/interpolate_fs.glsl index 062f629a41..8aa590ed38 100644 --- a/modules/globebrowsing/shaders/interpolate_fs.glsl +++ b/modules/globebrowsing/shaders/interpolate_fs.glsl @@ -26,25 +26,23 @@ uniform sampler2D prevTexture; uniform sampler2D nextTexture; -uniform sampler2D colormapTexture; +uniform sampler1D colormapTexture; uniform float blendFactor; in vec2 texCoord; Fragment getFragment() { - vec4 texel0 = texture2D(prevTexture, texCoord); - vec4 texel1 = texture2D(nextTexture, texCoord); + vec4 texel0 = texture(prevTexture, texCoord); + vec4 texel1 = texture(nextTexture, texCoord); vec4 mixedTexture = mix(texel0, texel1, blendFactor); Fragment frag; if (mixedTexture.r > 0.999) { - vec2 position = vec2(mixedTexture.r - 0.01, 0.5); - frag.color = texture2D(colormapTexture, position); + frag.color = texture(colormapTexture, mixedTexture.r - 0.01); } else { - vec2 position = vec2(mixedTexture.r , 0.5); - frag.color = texture2D(colormapTexture, position); + frag.color = texture(colormapTexture, mixedTexture.r); } frag.color.a = mixedTexture.a; diff --git a/modules/globebrowsing/src/tileprovider/temporaltileprovider.cpp b/modules/globebrowsing/src/tileprovider/temporaltileprovider.cpp index 21e1f2df04..2da27c59ba 100644 --- a/modules/globebrowsing/src/tileprovider/temporaltileprovider.cpp +++ b/modules/globebrowsing/src/tileprovider/temporaltileprovider.cpp @@ -35,15 +35,14 @@ #include #include #include +#include #include #include -#include "cpl_minixml.h" -#include namespace { constexpr const char* KeyBasePath = "BasePath"; - constexpr const char* UrlTimePlaceholder = "${OpenSpaceTimeId}"; + constexpr const char* TimePlaceholder = "${OpenSpaceTimeId}"; constexpr openspace::properties::Property::PropertyInfo FilePathInfo = { "FilePath", @@ -193,12 +192,13 @@ TemporalTileProvider::TemporalTileProvider(const ghoul::Dictionary& dictionary) if (_interpolation) { _interpolateTileProvider = std::make_unique(dictionary); - _interpolateTileProvider->colormap = _colormap; _interpolateTileProvider->initialize(); - ghoul::Dictionary dict; - dict.setValue("FilePath", _colormap); - _interpolateTileProvider->singleImageProvider = - std::make_unique(dict); + _interpolateTileProvider->colormap = + ghoul::io::TextureReader::ref().loadTexture(_colormap, 1); + _interpolateTileProvider->colormap->uploadTexture(); + _interpolateTileProvider->colormap->setFilter( + ghoul::opengl::Texture::FilterMode::AnisotropicMipMap + ); } } @@ -270,15 +270,21 @@ std::unique_ptr TemporalTileProvider::initTileProvider( std::string prototype = _prototype; - const size_t pos = prototype.find(UrlTimePlaceholder); - const size_t numChars = std::string_view(UrlTimePlaceholder).size(); - // @FRAGILE: This will only find the first instance. Dangerous if that instance is - // commented out ---abock - std::string xml = prototype.replace(pos, numChars, timekey); + while (true) { + const size_t pos = prototype.find(TimePlaceholder); - xml = FileSys.expandPathTokens(std::move(xml), IgnoredTokens).string(); + if (pos == std::string::npos) { + break; + } + + const size_t numChars = std::string_view(TimePlaceholder).size(); + prototype = prototype.replace(pos, numChars, timekey); + } - _initDict.setValue("FilePath", xml); + + prototype = FileSys.expandPathTokens(std::move(prototype), IgnoredTokens).string(); + + _initDict.setValue("FilePath", prototype); return std::make_unique(_initDict); } @@ -507,7 +513,7 @@ Tile TemporalTileProvider::InterpolateTileProvider::tile(const TileIndex& tileIn // There is a previous and next texture to interpolate between so do the interpolation // The texture that will give the color for the interpolated texture - ghoul::opengl::Texture* colormapTexture = singleImageProvider->tile(tileIndex).texture; + ghoul::opengl::Texture* colormapTexture = colormap.get(); // The data for initializing the texture TileTextureInitData initData( diff --git a/modules/globebrowsing/src/tileprovider/temporaltileprovider.h b/modules/globebrowsing/src/tileprovider/temporaltileprovider.h index ecd58eca62..bdb5847016 100644 --- a/modules/globebrowsing/src/tileprovider/temporaltileprovider.h +++ b/modules/globebrowsing/src/tileprovider/temporaltileprovider.h @@ -77,9 +77,8 @@ private: GLuint vaoQuad = 0; GLuint vboQuad = 0; GLuint fbo = 0; - std::string colormap; std::unique_ptr shaderProgram; - std::unique_ptr singleImageProvider; + std::unique_ptr colormap; cache::MemoryAwareTileCache* tileCache = nullptr; };