diff --git a/modules/globebrowsing/chunk/chunkrenderer.cpp b/modules/globebrowsing/chunk/chunkrenderer.cpp index 88292e8a18..947a77e6d6 100644 --- a/modules/globebrowsing/chunk/chunkrenderer.cpp +++ b/modules/globebrowsing/chunk/chunkrenderer.cpp @@ -92,7 +92,6 @@ namespace openspace { // unued atm. Could be used for caching or precalculating } - void ChunkRenderer::setDepthTransformUniforms( std::shared_ptr uniformIdHandler, LayeredTextures::TextureCategory textureCategory, @@ -155,6 +154,18 @@ namespace openspace { tileAndTransform.uvTransform.uvOffset); } + void ChunkRenderer::setLayerSettingsUniforms( + std::shared_ptr uniformIdHandler, + LayeredTextures::TextureCategory textureCategory, + size_t layerIndex, + PerLayerSettings settings) { + uniformIdHandler->programObject().setUniform( + uniformIdHandler->getSettingsId( + textureCategory, + layerIndex, + LayeredTextureShaderUniformIdHandler::LayerSettingsIds::opacity), + settings.opacity); + } ProgramObject* ChunkRenderer::getActivatedProgramWithTileData( LayeredTextureShaderProvider* layeredTextureShaderProvider, @@ -280,6 +291,12 @@ namespace openspace { texUnits[category][i].blendTexture2, tileAndTransformParent2); } + + setLayerSettingsUniforms( + programUniformHandler, + LayeredTextures::TextureCategory(category), + i, + _tileProviderManager->getTileProviderGroup(category).getActiveNamedTileProviders()[i].settings); /* if (category == LayeredTextures::HeightMaps && tileAndTransform.tile.preprocessData) { diff --git a/modules/globebrowsing/chunk/chunkrenderer.h b/modules/globebrowsing/chunk/chunkrenderer.h index cd45c41d2d..13f2047e02 100644 --- a/modules/globebrowsing/chunk/chunkrenderer.h +++ b/modules/globebrowsing/chunk/chunkrenderer.h @@ -61,7 +61,7 @@ namespace openspace { void update(); private: - + void renderChunkGlobally(const Chunk& chunk, const RenderData& data); void renderChunkLocally(const Chunk& chunk, const RenderData& data); @@ -79,6 +79,12 @@ namespace openspace { size_t layerIndex, ghoul::opengl::TextureUnit& texUnit, const TileAndTransform& tileAndTransform); + + void setLayerSettingsUniforms( + std::shared_ptr uniformIdHandler, + LayeredTextures::TextureCategory textureCategory, + size_t layerIndex, + PerLayerSettings settings); ProgramObject* getActivatedProgramWithTileData( LayeredTextureShaderProvider* layeredTextureShaderProvider, @@ -102,4 +108,4 @@ namespace openspace { } // namespace openspace -#endif // __CHUNK_RENDERER_H__ \ No newline at end of file +#endif // __CHUNK_RENDERER_H__ diff --git a/modules/globebrowsing/globes/renderableglobe.cpp b/modules/globebrowsing/globes/renderableglobe.cpp index b2c37ffa35..4deff67a7c 100644 --- a/modules/globebrowsing/globes/renderableglobe.cpp +++ b/modules/globebrowsing/globes/renderableglobe.cpp @@ -92,6 +92,11 @@ namespace openspace { prop.isEnabled.onChange([&]{ tileProvider.isActive = prop.isEnabled; }); + prop.opacity.set(tileProvider.settings.opacity); + prop.opacity.onChange([&]{ + tileProvider.settings.opacity = prop.opacity; + }); + addPropertySubOwner(prop); } diff --git a/modules/globebrowsing/shaders/texturetilemapping.hglsl b/modules/globebrowsing/shaders/texturetilemapping.hglsl index 91d0c40586..b8e7171142 100644 --- a/modules/globebrowsing/shaders/texturetilemapping.hglsl +++ b/modules/globebrowsing/shaders/texturetilemapping.hglsl @@ -72,13 +72,31 @@ #define SHOW_HEIGHT_RESOLUTION #{showHeightResolution} #define SHOW_HEIGHT_INTENSITIES #{showHeightIntensities} +float performLayerSettings(float currentValue, PerLayerSettings settings) { + float newValue; + + newValue = currentValue * settings.opacity; + + return newValue; +} + +vec4 performLayerSettings(vec4 currentValue, PerLayerSettings settings) { + vec4 newValue = vec4( + performLayerSettings(currentValue.r, settings), + performLayerSettings(currentValue.g, settings), + performLayerSettings(currentValue.b, settings), + performLayerSettings(currentValue.a, settings)); + + return newValue; +} float calculateUntransformedHeight( vec2 uv, LevelWeights levelWeights, const Tile heightTiles[NUMLAYERS_HEIGHTMAP], const Tile heightTilesParent1[NUMLAYERS_HEIGHTMAP], - const Tile heightTilesParent2[NUMLAYERS_HEIGHTMAP]) { + const Tile heightTilesParent2[NUMLAYERS_HEIGHTMAP], + const PerLayerSettings layerSettings[NUMLAYERS_HEIGHTMAP]) { float height = 0; @@ -95,6 +113,8 @@ float calculateUntransformedHeight( levelWeights.w1 * getTexVal(heightTiles[#{i}], uv).r + levelWeights.w2 * getTexVal(heightTilesParent1[#{i}], uv).r + levelWeights.w3 * getTexVal(heightTilesParent2[#{i}], uv).r; + + height = performLayerSettings(height, layerSettings[#{i}]); } #endfor return height; @@ -105,7 +125,8 @@ float calculateHeight( LevelWeights levelWeights, const Tile heightTiles[NUMLAYERS_HEIGHTMAP], const Tile heightTilesParent1[NUMLAYERS_HEIGHTMAP], - const Tile heightTilesParent2[NUMLAYERS_HEIGHTMAP]) { + const Tile heightTilesParent2[NUMLAYERS_HEIGHTMAP], + const PerLayerSettings layerSettings[NUMLAYERS_HEIGHTMAP]) { float height = 0; @@ -124,8 +145,10 @@ float calculateHeight( levelWeights.w3 * getTexVal(heightTilesParent2[#{i}], uv).r; float heightSample = getTransformedTexVal(heightTiles[#{i}].depthTransform, untransformedHeight); - if (heightSample > -100000) + if (heightSample > -100000) { + heightSample = performLayerSettings(heightSample, layerSettings[#{i}]); height = heightSample; + } } #endfor return height; @@ -136,7 +159,8 @@ vec4 calculateColor( LevelWeights levelWeights, const Tile colorTiles[NUMLAYERS_COLORTEXTURE], const Tile colorTilesParent1[NUMLAYERS_COLORTEXTURE], - const Tile colorTilesParent2[NUMLAYERS_COLORTEXTURE]) { + const Tile colorTilesParent2[NUMLAYERS_COLORTEXTURE], + const PerLayerSettings layerSettings[NUMLAYERS_COLORTEXTURE]) { vec4 color = vec4(0); @@ -153,6 +177,8 @@ vec4 calculateColor( levelWeights.w2 * getTexVal(colorTilesParent1[#{i}], uv) + levelWeights.w3 * getTexVal(colorTilesParent2[#{i}], uv); + colorSample = performLayerSettings(colorSample, layerSettings[#{i}]); + color = blendOver(color, colorSample); } #endfor @@ -166,7 +192,8 @@ vec4 calculateGrayScale( LevelWeights levelWeights, const Tile grayscaleTextureTiles[NUMLAYERS_GRAYSCALETEXTURE], const Tile grayscaleTextureTilesParent1[NUMLAYERS_GRAYSCALETEXTURE], - const Tile grayscaleTextureTilesParent2[NUMLAYERS_GRAYSCALETEXTURE]) { + const Tile grayscaleTextureTilesParent2[NUMLAYERS_GRAYSCALETEXTURE], + const PerLayerSettings layerSettings[NUMLAYERS_GRAYSCALETEXTURE]) { vec4 colorGrayScale = currentColor; @@ -184,6 +211,8 @@ vec4 calculateGrayScale( levelWeights.w3 * getTexVal(grayscaleTextureTilesParent2[#{i}], uv); colorSample = vec4(colorSample.r, colorSample.r, colorSample.r, 1); + colorSample = performLayerSettings(colorSample, layerSettings[#{i}]); + colorGrayScale = blendOver(colorGrayScale, colorSample); } #endfor @@ -221,6 +250,7 @@ vec4 calculateNight( const Tile nightTiles[NUMLAYERS_NIGHTTEXTURE], const Tile nightTilesParent1[NUMLAYERS_NIGHTTEXTURE], const Tile nightTilesParent2[NUMLAYERS_NIGHTTEXTURE], + const PerLayerSettings layerSettings[NUMLAYERS_NIGHTTEXTURE], const vec3 ellipsoidNormalCameraSpace, const vec3 lightDirectionCameraSpace) { @@ -238,6 +268,7 @@ vec4 calculateNight( levelWeights.w1 * getTexVal(nightTiles[#{i}], uv) + levelWeights.w2 * getTexVal(nightTilesParent1[#{i}], uv) + levelWeights.w3 * getTexVal(nightTilesParent2[#{i}], uv); + colorSample = performLayerSettings(colorSample, layerSettings[#{i}]); nightColor = blendOver(nightColor, colorSample); } @@ -265,7 +296,7 @@ vec4 calculateShadedColor( vec3 n = normalize(ellipsoidNormalCameraSpace); vec3 l = lightDirectionCameraSpace; - float cosineFactor = clamp(dot(-l, n) * 4, 0, 1); + float cosineFactor = clamp(dot(-l, n) * 3, 0, 1); // Blend shaded color with base color vec4 color = vec4(cosineFactor * currentColor.xyz + (1 - cosineFactor) * shadedColor, currentColor.a); @@ -278,7 +309,8 @@ vec4 calculateOverlay( LevelWeights levelWeights, const Tile overlayTiles[NUMLAYERS_OVERLAY], const Tile overlayTilesParent1[NUMLAYERS_OVERLAY], - const Tile overlayTilesParent2[NUMLAYERS_OVERLAY]) { + const Tile overlayTilesParent2[NUMLAYERS_OVERLAY], + const PerLayerSettings layerSettings[NUMLAYERS_OVERLAY]) { vec4 color = currentColor; @@ -294,6 +326,7 @@ vec4 calculateOverlay( levelWeights.w1 * getTexVal(overlayTiles[#{i}], uv) + levelWeights.w2 * getTexVal(overlayTilesParent1[#{i}], uv) + levelWeights.w3 * getTexVal(overlayTilesParent2[#{i}], uv); + colorSample = performLayerSettings(colorSample, layerSettings[#{i}]); color = blendOver(color, colorSample); } @@ -308,7 +341,8 @@ vec4 calculateGrayScaleOverlay( LevelWeights levelWeights, const Tile grayscaleOverlayTiles[NUMLAYERS_GRAYSCALE_OVERLAY], const Tile grayscaleOverlayTilesParent1[NUMLAYERS_GRAYSCALE_OVERLAY], - const Tile grayscaleOverlayTilesParent2[NUMLAYERS_GRAYSCALE_OVERLAY]) { + const Tile grayscaleOverlayTilesParent2[NUMLAYERS_GRAYSCALE_OVERLAY], + const PerLayerSettings layerSettings[NUMLAYERS_GRAYSCALE_OVERLAY]) { vec4 colorGrayScale = currentColor; @@ -326,6 +360,8 @@ vec4 calculateGrayScaleOverlay( levelWeights.w3 * getTexVal(grayscaleOverlayTilesParent2[#{i}], uv); colorSample = vec4(colorSample.r, colorSample.r, colorSample.r, colorSample.g); + colorSample = performLayerSettings(colorSample, layerSettings[#{i}]); + colorGrayScale = blendOver(colorGrayScale, colorSample); } #endfor @@ -355,6 +391,7 @@ vec4 calculateWater( const Tile waterTiles[NUMLAYERS_WATERMASK], const Tile waterTilesParent1[NUMLAYERS_WATERMASK], const Tile waterTilesParent2[NUMLAYERS_WATERMASK], + const PerLayerSettings layerSettings[NUMLAYERS_WATERMASK], const vec3 ellipsoidNormalCameraSpace, const vec3 lightDirectionCameraSpace, const vec3 positionCameraSpace) { @@ -374,6 +411,8 @@ vec4 calculateWater( levelWeights.w2 * getTexVal(waterTilesParent1[#{i}], uv) + levelWeights.w3 * getTexVal(waterTilesParent2[#{i}], uv); + colorSample = performLayerSettings(colorSample, layerSettings[#{i}]); + waterColor = blendOver(waterColor, colorSample); } #endfor diff --git a/modules/globebrowsing/shaders/tile.hglsl b/modules/globebrowsing/shaders/tile.hglsl index cc91d50657..2ed3cc2bd9 100644 --- a/modules/globebrowsing/shaders/tile.hglsl +++ b/modules/globebrowsing/shaders/tile.hglsl @@ -139,6 +139,9 @@ vec4 getTexVal(const MultiLevelTile multiLevelTile, const LevelWeights w, const w.w3 * getTexVal(multiLevelTile.tile2, uv); } - +// PerLayerSettings +struct PerLayerSettings { + float opacity; +}; #endif // TEXTURETILE_HGLSL \ No newline at end of file diff --git a/modules/globebrowsing/shaders/tilefragcolor.hglsl b/modules/globebrowsing/shaders/tilefragcolor.hglsl index b9c7dddddf..f70acf392f 100644 --- a/modules/globebrowsing/shaders/tilefragcolor.hglsl +++ b/modules/globebrowsing/shaders/tilefragcolor.hglsl @@ -37,36 +37,42 @@ uniform Tile ColorTextures[NUMLAYERS_COLORTEXTURE]; uniform Tile ColorTexturesParent1[NUMLAYERS_COLORTEXTURE]; uniform Tile ColorTexturesParent2[NUMLAYERS_COLORTEXTURE]; +uniform PerLayerSettings ColorTexturesSettings[NUMLAYERS_COLORTEXTURE]; #endif // USE_COLORTEXTURE #if USE_GRAYSCALETEXTURE uniform Tile GrayScaleTextures[NUMLAYERS_GRAYSCALETEXTURE]; uniform Tile GrayScaleTexturesParent1[NUMLAYERS_GRAYSCALETEXTURE]; uniform Tile GrayScaleTexturesParent2[NUMLAYERS_GRAYSCALETEXTURE]; +uniform PerLayerSettings GrayScaleTexturesSettings[NUMLAYERS_GRAYSCALETEXTURE]; #endif // USE_GRAYSCALETEXTURE #if USE_NIGHTTEXTURE uniform Tile NightTextures[NUMLAYERS_NIGHTTEXTURE]; uniform Tile NightTexturesParent1[NUMLAYERS_NIGHTTEXTURE]; uniform Tile NightTexturesParent2[NUMLAYERS_NIGHTTEXTURE]; +uniform PerLayerSettings NightTexturesSettings[NUMLAYERS_NIGHTTEXTURE]; #endif // USE_NIGHTTEXTURE #if USE_OVERLAY uniform Tile Overlays[NUMLAYERS_OVERLAY]; uniform Tile OverlaysParent1[NUMLAYERS_OVERLAY]; uniform Tile OverlaysParent2[NUMLAYERS_OVERLAY]; +uniform PerLayerSettings OverlaysSettings[NUMLAYERS_OVERLAY]; #endif // USE_OVERLAY #if USE_GRAYSCALE_OVERLAY uniform Tile GrayScaleOverlays[NUMLAYERS_GRAYSCALE_OVERLAY]; uniform Tile GrayScaleOverlaysParent1[NUMLAYERS_GRAYSCALE_OVERLAY]; uniform Tile GrayScaleOverlaysParent2[NUMLAYERS_GRAYSCALE_OVERLAY]; +uniform PerLayerSettings GrayScaleOverlaysSettings[NUMLAYERS_GRAYSCALE_OVERLAY]; #endif // USE_GRAYSCALE_OVERLAY #if USE_WATERMASK uniform Tile WaterMasks[NUMLAYERS_WATERMASK]; uniform Tile WaterMasksParent1[NUMLAYERS_WATERMASK]; uniform Tile WaterMasksParent2[NUMLAYERS_WATERMASK]; +uniform PerLayerSettings WaterMasksSettings[NUMLAYERS_WATERMASK]; #endif // USE_WATERMASK #if SHOW_HEIGHT_RESOLUTION @@ -102,6 +108,7 @@ in LevelWeights levelWeights; uniform Tile HeightMaps[NUMLAYERS_HEIGHTMAP]; uniform Tile HeightMapsParent1[NUMLAYERS_HEIGHTMAP]; uniform Tile HeightMapsParent2[NUMLAYERS_HEIGHTMAP]; +uniform PerLayerSettings HeightMapsSettings[NUMLAYERS_HEIGHTMAP]; #endif // USE_HEIGHTMAP float getUntransformedTileVertexHeight(vec2 uv, LevelWeights levelWeights){ @@ -113,7 +120,7 @@ float getUntransformedTileVertexHeight(vec2 uv, LevelWeights levelWeights){ height = calculateUntransformedHeight( uv, levelWeights, // Variable to determine which texture to sample from - HeightMaps, HeightMapsParent1, HeightMapsParent2); // Three textures to sample from + HeightMaps, HeightMapsParent1, HeightMapsParent2, HeightMapsSettings); // Three textures to sample from #endif // USE_HEIGHTMAP @@ -141,7 +148,8 @@ vec4 getTileFragColor(){ levelWeights, ColorTextures, ColorTexturesParent1, - ColorTexturesParent2); + ColorTexturesParent2, + ColorTexturesSettings); #endif // USE_COLORTEXTURE #if USE_GRAYSCALETEXTURE @@ -151,7 +159,8 @@ vec4 getTileFragColor(){ levelWeights, GrayScaleTextures, GrayScaleTexturesParent1, - GrayScaleTexturesParent2); + GrayScaleTexturesParent2, + GrayScaleTexturesSettings); #endif // USE_GRAYSCALETEXTURE #if USE_GRAYSCALE_OVERLAY @@ -162,7 +171,8 @@ vec4 getTileFragColor(){ levelWeights, GrayScaleOverlays, GrayScaleOverlaysParent1, - GrayScaleOverlaysParent2); + GrayScaleOverlaysParent2, + GrayScaleOverlaysSettings); #endif // USE_COLORTEXTURE @@ -174,6 +184,7 @@ vec4 getTileFragColor(){ WaterMasks, WaterMasksParent1, WaterMasksParent2, + WaterMasksSettings, normalize(ellipsoidNormalCameraSpace), lightDirectionCameraSpace, // Should already be normalized positionCameraSpace); @@ -188,6 +199,7 @@ vec4 getTileFragColor(){ NightTextures, NightTexturesParent1, NightTexturesParent2, + NightTexturesSettings, normalize(ellipsoidNormalCameraSpace), lightDirectionCameraSpace); // Should already be normalized @@ -227,7 +239,8 @@ vec4 getTileFragColor(){ levelWeights, Overlays, OverlaysParent1, - OverlaysParent2); + OverlaysParent2, + OverlaysSettings); #endif // USE_OVERLAY diff --git a/modules/globebrowsing/shaders/tilevertexheight.hglsl b/modules/globebrowsing/shaders/tilevertexheight.hglsl index 6ea6003dcc..377dd92d01 100644 --- a/modules/globebrowsing/shaders/tilevertexheight.hglsl +++ b/modules/globebrowsing/shaders/tilevertexheight.hglsl @@ -34,6 +34,7 @@ uniform Tile HeightMaps[NUMLAYERS_HEIGHTMAP]; uniform Tile HeightMapsParent1[NUMLAYERS_HEIGHTMAP]; uniform Tile HeightMapsParent2[NUMLAYERS_HEIGHTMAP]; +uniform PerLayerSettings HeightMapsSettings[NUMLAYERS_HEIGHTMAP]; #endif // USE_HEIGHTMAP uniform int xSegments; @@ -52,7 +53,7 @@ float getUntransformedTileVertexHeight(vec2 uv, LevelWeights levelWeights){ height = calculateUntransformedHeight( uv, levelWeights, // Variable to determine which texture to sample from - HeightMaps, HeightMapsParent1, HeightMapsParent2); // Three textures to sample from + HeightMaps, HeightMapsParent1, HeightMapsParent2, HeightMapsSettings); // Three textures to sample from #endif // USE_HEIGHTMAP @@ -69,13 +70,51 @@ float getTileVertexHeight(vec2 uv, LevelWeights levelWeights){ height = calculateHeight( uv, levelWeights, // Variable to determine which texture to sample from - HeightMaps, HeightMapsParent1, HeightMapsParent2); // Three textures to sample from + HeightMaps, HeightMapsParent1, HeightMapsParent2, HeightMapsSettings); // Three textures to sample from #endif // USE_HEIGHTMAP return height; } +// This function is currently not correct +vec3 getTileVertexNormal( + vec2 uv, + LevelWeights levelWeights, + vec3 ellipsoidNormal) { + vec3 normal = ellipsoidNormal; + +#if USE_HEIGHTMAP + float sampleDelta = 1.0 / xSegments; + + float heightCenter = calculateHeight( + uv, + levelWeights, + HeightMaps, HeightMapsParent1, HeightMapsParent2, HeightMapsSettings); + float heightOffsetX = calculateHeight( + uv + vec2(sampleDelta, 0.0), + levelWeights, + HeightMaps, HeightMapsParent1, HeightMapsParent2, HeightMapsSettings); + float heightOffsetY = calculateHeight( + uv + vec2(0.0, sampleDelta), + levelWeights, + HeightMaps, HeightMapsParent1, HeightMapsParent2, HeightMapsSettings); + + vec3 e0 = normalize(cross(vec3(0,0,1), ellipsoidNormal)); + vec3 e1 = cross(ellipsoidNormal, e0); + vec3 e2 = ellipsoidNormal; + + vec3 v0 = e0 * sampleDelta * 3000000 + e2 * heightOffsetX; + vec3 v1 = e1 * sampleDelta * 3000000 + e2 * heightOffsetY; + + vec3 n = cross(v0, v1); + + normal = normalize(n); + +#endif // USE_HEIGHTMAP + return normal; +} + bool tileVertexIsSkirtVertex(){ int vertexIDx = gl_VertexID % (xSegments + 3); int vertexIDy = gl_VertexID / (xSegments + 3); diff --git a/modules/globebrowsing/tile/layeredtextureshaderprovider.cpp b/modules/globebrowsing/tile/layeredtextureshaderprovider.cpp index a7af680705..664e0353b9 100644 --- a/modules/globebrowsing/tile/layeredtextureshaderprovider.cpp +++ b/modules/globebrowsing/tile/layeredtextureshaderprovider.cpp @@ -176,6 +176,12 @@ namespace openspace { "Parent1", "Parent2", }; + + const std::string LayeredTextureShaderUniformIdHandler::layerSettingsIds[ + NUM_LAYER_SETTINGS_VARIABLES] = + { + "opacity", + }; LayeredTextureShaderUniformIdHandler::LayeredTextureShaderUniformIdHandler() { @@ -215,6 +221,22 @@ namespace openspace { } } } + for (size_t i = 0; i < LayeredTextures::NUM_TEXTURE_CATEGORIES; i++) + { + for (size_t k = 0; k < LayeredTextures::MAX_NUM_TEXTURES_PER_CATEGORY; + k++) + { + for (size_t l = 0; l < NUM_LAYER_SETTINGS_VARIABLES; l++) + { + _layerSettingsUniformIds[i][k][l] = + _shaderProvider->_programObject->uniformLocation( + LayeredTextures::TEXTURE_CATEGORY_NAMES[i] + + "Settings" + + "[" + std::to_string(k) + "]." + + layerSettingsIds[l]); + } + } + } // Reset ignore errors _shaderProvider->_programObject->setIgnoreUniformLocationError( ProgramObject::IgnoreError::No); @@ -230,6 +252,13 @@ namespace openspace { return _tileUniformIds[category][blendLayer][layerIndex][tileDataId]; } + GLint LayeredTextureShaderUniformIdHandler::getSettingsId( + LayeredTextures::TextureCategory category, + size_t layerIndex, + LayerSettingsIds layerSettingsId) + { + return _layerSettingsUniformIds[category][layerIndex][layerSettingsId]; + } ProgramObject& LayeredTextureShaderUniformIdHandler::programObject() { diff --git a/modules/globebrowsing/tile/layeredtextureshaderprovider.h b/modules/globebrowsing/tile/layeredtextureshaderprovider.h index 841afd7ace..dfb9f61dad 100644 --- a/modules/globebrowsing/tile/layeredtextureshaderprovider.h +++ b/modules/globebrowsing/tile/layeredtextureshaderprovider.h @@ -125,6 +125,7 @@ namespace openspace { public: static const size_t NUM_TILE_DATA_VARIABLES = 5; static const size_t NUM_BLEND_TEXTURES = 3; + static const size_t NUM_LAYER_SETTINGS_VARIABLES = 1; /** * Each texture can have these uniform variables associated with it in the shader @@ -166,6 +167,10 @@ namespace openspace { Parent1, Parent2, }; + + enum LayerSettingsIds { + opacity, + }; LayeredTextureShaderUniformIdHandler(); ~LayeredTextureShaderUniformIdHandler(); @@ -192,10 +197,15 @@ namespace openspace { size_t blendLayer, size_t layerIndex, GlslTileDataId tileDataId); + GLint getSettingsId( + LayeredTextures::TextureCategory category, + size_t layerIndex, + LayerSettingsIds layerSettingsId); ProgramObject& programObject(); private: static const std::string glslTileDataNames[NUM_TILE_DATA_VARIABLES]; static const std::string blendLayerSuffixes[NUM_BLEND_TEXTURES]; + static const std::string layerSettingsIds[NUM_LAYER_SETTINGS_VARIABLES]; std::array< std::array< @@ -207,9 +217,19 @@ namespace openspace { NUM_BLEND_TEXTURES>, LayeredTextures::NUM_TEXTURE_CATEGORIES> _tileUniformIds; + + + std::array< + std::array< + std::array< + GLint, + NUM_LAYER_SETTINGS_VARIABLES>, + LayeredTextures::MAX_NUM_TEXTURES_PER_CATEGORY>, + LayeredTextures::NUM_TEXTURE_CATEGORIES> + _layerSettingsUniformIds; LayeredTextureShaderProvider* _shaderProvider; }; } // namespace openspace -#endif // __LAYERED_TEXTURE_SHADER_PROVIDER__ \ No newline at end of file +#endif // __LAYERED_TEXTURE_SHADER_PROVIDER__ diff --git a/modules/globebrowsing/tile/tileprovidermanager.cpp b/modules/globebrowsing/tile/tileprovidermanager.cpp index c395398074..4faf0b4302 100644 --- a/modules/globebrowsing/tile/tileprovidermanager.cpp +++ b/modules/globebrowsing/tile/tileprovidermanager.cpp @@ -62,6 +62,16 @@ namespace openspace { return activeTileProviders; } + const std::vector TileProviderGroup::getActiveNamedTileProviders() const { + std::vector activeTileProviders; + for (auto tileProviderWithName : tileProviders) { + if (tileProviderWithName.isActive) { + activeTileProviders.push_back(tileProviderWithName); + } + } + return activeTileProviders; + } + ////////////////////////////////////////////////////////////////////////////////////// // Tile Provider Manager // ////////////////////////////////////////////////////////////////////////////////////// diff --git a/modules/globebrowsing/tile/tileprovidermanager.h b/modules/globebrowsing/tile/tileprovidermanager.h index 805d659ce9..9da4a9e4c5 100644 --- a/modules/globebrowsing/tile/tileprovidermanager.h +++ b/modules/globebrowsing/tile/tileprovidermanager.h @@ -38,11 +38,15 @@ namespace openspace { + struct PerLayerSettings { + float opacity = 1; + }; struct NamedTileProvider { std::string name; std::shared_ptr tileProvider; bool isActive; + PerLayerSettings settings; }; @@ -51,6 +55,7 @@ namespace openspace { void update(); const std::vector> getActiveTileProviders() const; + const std::vector getActiveNamedTileProviders() const; std::vector tileProviders;