Simplify the ability to add more per layer settings and move layered rendering src files to separate folder.

This commit is contained in:
kalbl
2016-10-15 03:04:09 +02:00
parent ba8066c3ed
commit 2f13b9e9f4
14 changed files with 351 additions and 220 deletions
+9 -7
View File
@@ -25,7 +25,6 @@
include(${OPENSPACE_CMAKE_EXT_DIR}/module_definition.cmake)
set(HEADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/globes/renderableglobe.h
${CMAKE_CURRENT_SOURCE_DIR}/chunk/chunkedlodglobe.h
@@ -63,8 +62,6 @@ set(HEADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/tile/tileioresult.h
${CMAKE_CURRENT_SOURCE_DIR}/tile/asynctilereader.h
${CMAKE_CURRENT_SOURCE_DIR}/tile/tileprovidermanager.h
${CMAKE_CURRENT_SOURCE_DIR}/tile/layeredtextureshaderprovider.h
${CMAKE_CURRENT_SOURCE_DIR}/tile/layeredtextures.h
${CMAKE_CURRENT_SOURCE_DIR}/tile/pixelregion.h
${CMAKE_CURRENT_SOURCE_DIR}/other/distanceswitch.h
@@ -74,7 +71,9 @@ set(HEADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/other/statscollector.h
${CMAKE_CURRENT_SOURCE_DIR}/other/threadpool.h
${CMAKE_CURRENT_SOURCE_DIR}/layered_rendering/layeredtextureshaderprovider.h
${CMAKE_CURRENT_SOURCE_DIR}/layered_rendering/layeredtextures.h
${CMAKE_CURRENT_SOURCE_DIR}/layered_rendering/perlayersetting.h
)
set(SOURCE_FILES
@@ -114,16 +113,17 @@ set(SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/tile/tileioresult.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tile/asynctilereader.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tile/tileprovidermanager.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tile/layeredtextureshaderprovider.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tile/layeredtextures.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tile/pixelregion.cpp
${CMAKE_CURRENT_SOURCE_DIR}/other/distanceswitch.cpp
${CMAKE_CURRENT_SOURCE_DIR}/other/lrucache.inl
${CMAKE_CURRENT_SOURCE_DIR}/other/concurrentjobmanager.inl
${CMAKE_CURRENT_SOURCE_DIR}/other/statscollector.cpp
${CMAKE_CURRENT_SOURCE_DIR}/other/threadpool.cpp
${CMAKE_CURRENT_SOURCE_DIR}/layered_rendering/layeredtextureshaderprovider.cpp
${CMAKE_CURRENT_SOURCE_DIR}/layered_rendering/layeredtextures.cpp
${CMAKE_CURRENT_SOURCE_DIR}/layered_rendering/perlayersetting.cpp
)
source_group("Source Files" FILES ${SOURCE_FILES})
@@ -132,6 +132,8 @@ set(SHADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/shaders/ellipsoid.hglsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/tile.hglsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/texturetilemapping.hglsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/tilefragcolor.hglsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/tilevertexheight.hglsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/globalchunkedlodpatch_vs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/shaders/globalchunkedlodpatch_fs.glsl
+1 -1
View File
@@ -30,7 +30,7 @@
#include <modules/globebrowsing/chunk/chunk.h>
#include <modules/globebrowsing/globes/renderableglobe.h>
#include <modules/globebrowsing/chunk/chunkedlodglobe.h>
#include <modules/globebrowsing/tile/layeredtextures.h>
#include <modules/globebrowsing/layered_rendering/layeredtextures.h>
#include <modules/globebrowsing/tile/tileioresult.h>
#include <algorithm>
@@ -31,7 +31,7 @@
#include <modules/globebrowsing/chunk/chunk.h>
#include <modules/globebrowsing/chunk/chunkedlodglobe.h>
#include <modules/globebrowsing/globes/renderableglobe.h>
#include <modules/globebrowsing/tile/layeredtextures.h>
#include <modules/globebrowsing/layered_rendering/layeredtextures.h>
#include <algorithm>
+21 -30
View File
@@ -26,7 +26,7 @@
#include <modules/globebrowsing/chunk/chunkrenderer.h>
#include <modules/globebrowsing/chunk/chunkedlodglobe.h>
#include <modules/globebrowsing/globes/renderableglobe.h>
#include <modules/globebrowsing/tile/layeredtextures.h>
#include <modules/globebrowsing/layered_rendering/layeredtextures.h>
#include <modules/globebrowsing/tile/tileprovidermanager.h>
// open space includes
@@ -95,7 +95,7 @@ namespace openspace {
void ChunkRenderer::setDepthTransformUniforms(
std::shared_ptr<LayeredTextureShaderUniformIdHandler> uniformIdHandler,
LayeredTextures::TextureCategory textureCategory,
LayeredTextureShaderUniformIdHandler::BlendLayerSuffixes blendLayerSuffix,
LayeredTextures::BlendLayerSuffixes blendLayerSuffix,
size_t layerIndex,
const TileDepthTransform& tileDepthTransform)
{
@@ -104,7 +104,7 @@ namespace openspace {
textureCategory,
blendLayerSuffix,
layerIndex,
LayeredTextureShaderUniformIdHandler::GlslTileDataId::depthTransform_depthScale),
LayeredTextures::GlslTileDataId::depthTransform_depthScale),
tileDepthTransform.depthScale);
uniformIdHandler->programObject().setUniform(
@@ -112,7 +112,7 @@ namespace openspace {
textureCategory,
blendLayerSuffix,
layerIndex,
LayeredTextureShaderUniformIdHandler::GlslTileDataId::depthTransform_depthOffset),
LayeredTextures::GlslTileDataId::depthTransform_depthOffset),
tileDepthTransform.depthOffset);
}
@@ -120,7 +120,7 @@ namespace openspace {
void ChunkRenderer::activateTileAndSetTileUniforms(
std::shared_ptr<LayeredTextureShaderUniformIdHandler> uniformIdHandler,
LayeredTextures::TextureCategory textureCategory,
LayeredTextureShaderUniformIdHandler::BlendLayerSuffixes blendLayerSuffix,
LayeredTextures::BlendLayerSuffixes blendLayerSuffix,
size_t layerIndex,
ghoul::opengl::TextureUnit& texUnit,
const TileAndTransform& tileAndTransform)
@@ -136,21 +136,21 @@ namespace openspace {
textureCategory,
blendLayerSuffix,
layerIndex,
LayeredTextureShaderUniformIdHandler::GlslTileDataId::textureSampler),
LayeredTextures::GlslTileDataId::textureSampler),
texUnit);
uniformIdHandler->programObject().setUniform(
uniformIdHandler->getId(
textureCategory,
blendLayerSuffix,
layerIndex,
LayeredTextureShaderUniformIdHandler::GlslTileDataId::uvTransform_uvScale),
LayeredTextures::GlslTileDataId::uvTransform_uvScale),
tileAndTransform.uvTransform.uvScale);
uniformIdHandler->programObject().setUniform(
uniformIdHandler->getId(
textureCategory,
blendLayerSuffix,
layerIndex,
LayeredTextureShaderUniformIdHandler::GlslTileDataId::uvTransform_uvOffset),
LayeredTextures::GlslTileDataId::uvTransform_uvOffset),
tileAndTransform.uvTransform.uvOffset);
}
@@ -159,24 +159,15 @@ namespace openspace {
LayeredTextures::TextureCategory textureCategory,
size_t layerIndex,
PerLayerSettings settings) {
uniformIdHandler->programObject().setUniform(
uniformIdHandler->getSettingsId(
textureCategory,
layerIndex,
LayeredTextureShaderUniformIdHandler::LayerSettingsIds::opacity),
settings.opacity);
uniformIdHandler->programObject().setUniform(
uniformIdHandler->getSettingsId(
textureCategory,
layerIndex,
LayeredTextureShaderUniformIdHandler::LayerSettingsIds::gamma),
settings.gamma);
uniformIdHandler->programObject().setUniform(
uniformIdHandler->getSettingsId(
textureCategory,
layerIndex,
LayeredTextureShaderUniformIdHandler::LayerSettingsIds::multiplier),
settings.multiplier);
for (int i = 0; i < settings.array.size(); i++) {
settings.array[i]->uploadUniform(
&uniformIdHandler->programObject(),
uniformIdHandler->getSettingsId(
textureCategory,
layerIndex,
LayeredTextures::LayerSettingsIds(i)));
}
}
ProgramObject* ChunkRenderer::getActivatedProgramWithTileData(
@@ -272,7 +263,7 @@ namespace openspace {
activateTileAndSetTileUniforms(
programUniformHandler,
LayeredTextures::TextureCategory(category),
LayeredTextureShaderUniformIdHandler::BlendLayerSuffixes::none,
LayeredTextures::BlendLayerSuffixes::none,
i,
texUnits[category][i].blendTexture0,
tileAndTransform);
@@ -286,7 +277,7 @@ namespace openspace {
activateTileAndSetTileUniforms(
programUniformHandler,
LayeredTextures::TextureCategory(category),
LayeredTextureShaderUniformIdHandler::BlendLayerSuffixes::Parent1,
LayeredTextures::BlendLayerSuffixes::Parent1,
i,
texUnits[category][i].blendTexture1,
tileAndTransformParent1);
@@ -298,7 +289,7 @@ namespace openspace {
activateTileAndSetTileUniforms(
programUniformHandler,
LayeredTextures::TextureCategory(category),
LayeredTextureShaderUniformIdHandler::BlendLayerSuffixes::Parent2,
LayeredTextures::BlendLayerSuffixes::Parent2,
i,
texUnits[category][i].blendTexture2,
tileAndTransformParent2);
@@ -334,7 +325,7 @@ namespace openspace {
setDepthTransformUniforms(
programUniformHandler,
LayeredTextures::TextureCategory::HeightMaps,
LayeredTextureShaderUniformIdHandler::BlendLayerSuffixes::none,
LayeredTextures::BlendLayerSuffixes::none,
i,
depthTransform);
i++;
+3 -3
View File
@@ -36,7 +36,7 @@
#include <modules/globebrowsing/meshes/grid.h>
#include <modules/globebrowsing/tile/layeredtextureshaderprovider.h>
#include <modules/globebrowsing/layered_rendering/layeredtextureshaderprovider.h>
#include <modules/globebrowsing/tile/tileselector.h>
#include <modules/globebrowsing/chunk/chunknode.h>
@@ -68,14 +68,14 @@ namespace openspace {
void setDepthTransformUniforms(
std::shared_ptr<LayeredTextureShaderUniformIdHandler> uniformIdHandler,
LayeredTextures::TextureCategory textureCategory,
LayeredTextureShaderUniformIdHandler::BlendLayerSuffixes blendLayerSuffix,
LayeredTextures::BlendLayerSuffixes blendLayerSuffix,
size_t layerIndex,
const TileDepthTransform& tileDepthTransform);
void activateTileAndSetTileUniforms(
std::shared_ptr<LayeredTextureShaderUniformIdHandler> uniformIdHandler,
LayeredTextures::TextureCategory textureCategory,
LayeredTextureShaderUniformIdHandler::BlendLayerSuffixes blendLayerSuffix,
LayeredTextures::BlendLayerSuffixes blendLayerSuffix,
size_t layerIndex,
ghoul::opengl::TextureUnit& texUnit,
const TileAndTransform& tileAndTransform);
@@ -59,15 +59,9 @@ namespace {
namespace openspace {
SingleTexturePropertyOwner::SingleTexturePropertyOwner(std::string name)
: isEnabled("isEnabled", "isEnabled", true)
, opacity("opacity", "opacity", 1, 0, 1)
, gamma("gamma", "gamma", 1, 0, 5)
, multiplier("multiplier", "multiplier", 1, 0, 20) {
: isEnabled("isEnabled", "isEnabled", true) {
setName(name);
addProperty(isEnabled);
addProperty(opacity);
addProperty(gamma);
addProperty(multiplier);
}
SingleTexturePropertyOwner::~SingleTexturePropertyOwner() {
@@ -96,21 +90,11 @@ namespace openspace {
prop.isEnabled.onChange([&]{
tileProvider.isActive = prop.isEnabled;
});
prop.opacity.set(tileProvider.settings.opacity);
prop.opacity.onChange([&]{
tileProvider.settings.opacity = prop.opacity;
});
prop.gamma.set(tileProvider.settings.gamma);
prop.gamma.onChange([&]{
tileProvider.settings.gamma = prop.gamma;
});
prop.multiplier.set(tileProvider.settings.multiplier);
prop.multiplier.onChange([&]{
tileProvider.settings.multiplier = prop.multiplier;
});
for (auto setting : tileProvider.settings.array) {
prop.addProperty(setting->property());
}
addPropertySubOwner(prop);
}
@@ -37,7 +37,7 @@
#include <modules/globebrowsing/meshes/trianglesoup.h>
#include <modules/globebrowsing/geometry/ellipsoid.h>
#include <modules/globebrowsing/tile/layeredtextures.h>
#include <modules/globebrowsing/layered_rendering/layeredtextures.h>
#include <modules/globebrowsing/other/distanceswitch.h>
#include <unordered_map>
@@ -46,7 +46,7 @@ namespace openspace {
class ChunkedLodGlobe;
class TileProviderManager;
class SingleTexturePropertyOwner : public properties::PropertyOwner
{
public:
@@ -54,9 +54,6 @@ public:
~SingleTexturePropertyOwner();
properties::BoolProperty isEnabled;
properties::FloatProperty opacity;
properties::FloatProperty gamma;
properties::FloatProperty multiplier;
};
class LayeredCategoryPropertyOwner : public properties::PropertyOwner
@@ -22,19 +22,20 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <modules/globebrowsing/tile/layeredtextures.h>
#include <modules/globebrowsing/layered_rendering/layeredtextures.h>
namespace {
const std::string _loggerCat = "LayeredTextures";
}
namespace openspace {
const size_t LayeredTextures::NUM_TEXTURE_CATEGORIES;
const size_t LayeredTextures::MAX_NUM_TEXTURES_PER_CATEGORY;
const size_t LayeredTextures::NUM_SETTINGS_PER_CATEGORY;
const size_t LayeredTextures::NUM_TILE_DATA_VARIABLES;
const size_t LayeredTextures::NUM_BLEND_TEXTURES;
const size_t LayeredTextures::NUM_LAYER_SETTINGS_VARIABLES;
const std::string LayeredTextures::TEXTURE_CATEGORY_NAMES[NUM_TEXTURE_CATEGORIES] =
{
@@ -47,4 +48,37 @@ namespace openspace {
"HeightMaps",
};
const std::string LayeredTextures::glslKeyPrefixes[NUM_SETTINGS_PER_CATEGORY] =
{
"lastLayerIndex",
"use",
"blend",
};
const std::string LayeredTextures::glslTileDataNames[
NUM_TILE_DATA_VARIABLES] =
{
"textureSampler",
"depthTransform.depthScale",
"depthTransform.depthOffset",
"uvTransform.uvOffset",
"uvTransform.uvScale"
};
const std::string LayeredTextures::blendLayerSuffixes[
NUM_BLEND_TEXTURES] =
{
"",
"Parent1",
"Parent2",
};
const std::string LayeredTextures::layerSettingsIds[
NUM_LAYER_SETTINGS_VARIABLES] =
{
"opacity",
"gamma",
"multiplier",
};
} // namespace openspace
@@ -0,0 +1,161 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2016 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __LAYERED_TEXTURES_H__
#define __LAYERED_TEXTURES_H__
#include <memory>
#include <vector>
#include <string>
#include <ghoul/opengl/programobject.h>
#include <openspace/properties/propertyowner.h>
#include <openspace/properties/scalarproperty.h>
#include <modules/globebrowsing/layered_rendering/perlayersetting.h>
namespace openspace {
class LayeredTextures {
public:
static const size_t NUM_TEXTURE_CATEGORIES = 7;
static const size_t MAX_NUM_TEXTURES_PER_CATEGORY = 5;
static const size_t NUM_SETTINGS_PER_CATEGORY = 3;
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 = 3;
enum GlslKeyPrefixes
{
lastLayerIndex,
use,
blend,
};
enum TextureCategory {
ColorTextures,
GrayScaleTextures,
GrayScaleOverlays,
NightTextures,
WaterMasks,
Overlays,
HeightMaps,
};
/**
* Each texture can have these uniform variables associated with it in the shader
* code.
*
* <code>textureSampler</code> is the actual texture that can be sampled in the
* shader program. The associated GLSL type is <code>sampler2D</code>.
* <code>depthTransform_depthScale</code> specifies the scale part of the depth
* transform. Useful for height maps. The associated GLSL type is
* <code>float</code>.
* <code>depthTransform_depthOffset</code> specifies the offset part of the depth
* transform. Useful for height maps. The associated GLSL type is
* <code>float</code>.
* <code>uvTransform_uvOffset</code> specifies an offset that can be used when
* sampling from the texture. The associated GLSL type is <code>vec2</code>.
* <code>uvTransform_uvScale</code> specifies a scale that can be used when
* sampling from the texture. The associated GLSL type is <code>vec2</code>.
*
* The corresponding struct in GLSL code for storing these data is a
* <code>Tile</code>. The names of the uniforms are the ones specified in
* <code>glslTileDataNames</code>.
*/
enum GlslTileDataId {
textureSampler,
depthTransform_depthScale,
depthTransform_depthOffset,
uvTransform_uvOffset,
uvTransform_uvScale,
};
/**
* These suffixes are used when naming <code>Tile</code>s in GLSL code. The names
* of the <code>Tile</code>s is one of
* <code>LayeredTextures::TEXTURE_CATEGORY_NAMES</code> followed by the suffixes
* defined in <code>blendLayerSuffixes</code>.
*/
enum BlendLayerSuffixes {
none,
Parent1,
Parent2,
};
enum LayerSettingsIds {
opacity,
gamma,
multiplier,
};
static const std::string glslKeyPrefixes[NUM_SETTINGS_PER_CATEGORY];
static const std::string TEXTURE_CATEGORY_NAMES[NUM_TEXTURE_CATEGORIES];
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];
};
class PerLayerSettings {
public:
PerLayerSettings()
{
// Here, all the per layer settings are specified and added
array[LayeredTextures::LayerSettingsIds::opacity] = std::make_shared<PerLayerFloatSetting>(
LayeredTextures::layerSettingsIds[LayeredTextures::LayerSettingsIds::opacity],
LayeredTextures::layerSettingsIds[LayeredTextures::LayerSettingsIds::opacity],
1,
0,
1);
array[LayeredTextures::LayerSettingsIds::gamma] = std::make_shared<PerLayerFloatSetting>(
LayeredTextures::layerSettingsIds[LayeredTextures::LayerSettingsIds::gamma],
LayeredTextures::layerSettingsIds[LayeredTextures::LayerSettingsIds::gamma],
1,
0,
5);
array[LayeredTextures::LayerSettingsIds::multiplier] = std::make_shared<PerLayerFloatSetting>(
LayeredTextures::layerSettingsIds[LayeredTextures::LayerSettingsIds::multiplier],
LayeredTextures::layerSettingsIds[LayeredTextures::LayerSettingsIds::multiplier],
1,
0,
20);
// Make sure all settings have been spacified and added
for (int i = 0; i < LayeredTextures::NUM_LAYER_SETTINGS_VARIABLES; ++i) {
ghoul_assert(array[i], "The setting " +
LayeredTextures::layerSettingsIds[i] + "is not specified!");
}
}
std::array<std::shared_ptr<PerLayerSetting>,
LayeredTextures::NUM_LAYER_SETTINGS_VARIABLES> array;
};
} // namespace openspace
#endif // __LAYERED_TEXTURES_H__
@@ -22,7 +22,7 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <modules/globebrowsing/tile/layeredtextureshaderprovider.h>
#include <modules/globebrowsing/layered_rendering/layeredtextureshaderprovider.h>
#include <openspace/rendering/renderengine.h>
#include <openspace/engine/openspaceengine.h>
@@ -37,13 +37,6 @@ namespace {
namespace openspace {
const std::string LayeredTextureInfo::glslKeyPrefixes[NUM_SETTINGS_PER_CATEGORY] =
{
"lastLayerIndex",
"use",
"blend",
};
bool LayeredTextureInfo::operator==(const LayeredTextureInfo& other) const
{
return
@@ -118,18 +111,18 @@ namespace openspace {
// lastLayerIndex must be at least 0 for the shader to compile,
// the layer type is inactivated by setting use to false
shaderDictionary.setValue(
LayeredTextureInfo::glslKeyPrefixes[
LayeredTextureInfo::GlslKeyPrefixes::lastLayerIndex] +
LayeredTextures::glslKeyPrefixes[
LayeredTextures::GlslKeyPrefixes::lastLayerIndex] +
LayeredTextures::TEXTURE_CATEGORY_NAMES[i],
glm::max(textureTypes[i].lastLayerIdx, 0));
shaderDictionary.setValue(
LayeredTextureInfo::glslKeyPrefixes[
LayeredTextureInfo::GlslKeyPrefixes::use] +
LayeredTextures::glslKeyPrefixes[
LayeredTextures::GlslKeyPrefixes::use] +
LayeredTextures::TEXTURE_CATEGORY_NAMES[i],
textureTypes[i].lastLayerIdx >= 0);
shaderDictionary.setValue(
LayeredTextureInfo::glslKeyPrefixes[
LayeredTextureInfo::GlslKeyPrefixes::blend] +
LayeredTextures::glslKeyPrefixes[
LayeredTextures::GlslKeyPrefixes::blend] +
LayeredTextures::TEXTURE_CATEGORY_NAMES[i],
textureTypes[i].layerBlendingEnabled);
}
@@ -158,33 +151,6 @@ namespace openspace {
return _updatedOnLastCall;
}
const std::string LayeredTextureShaderUniformIdHandler::glslTileDataNames[
NUM_TILE_DATA_VARIABLES] =
{
"textureSampler",
"depthTransform.depthScale",
"depthTransform.depthOffset",
"uvTransform.uvOffset",
"uvTransform.uvScale"
};
const std::string LayeredTextureShaderUniformIdHandler::blendLayerSuffixes[
NUM_BLEND_TEXTURES] =
{
"",
"Parent1",
"Parent2",
};
const std::string LayeredTextureShaderUniformIdHandler::layerSettingsIds[
NUM_LAYER_SETTINGS_VARIABLES] =
{
"opacity",
"gamma",
"multiplier",
};
LayeredTextureShaderUniformIdHandler::LayeredTextureShaderUniformIdHandler()
{
@@ -206,19 +172,19 @@ namespace openspace {
ProgramObject::IgnoreError::Yes);
for (size_t i = 0; i < LayeredTextures::NUM_TEXTURE_CATEGORIES; i++)
{
for (size_t j = 0; j < NUM_BLEND_TEXTURES; j++)
for (size_t j = 0; j < LayeredTextures::NUM_BLEND_TEXTURES; j++)
{
for (size_t k = 0; k < LayeredTextures::MAX_NUM_TEXTURES_PER_CATEGORY;
k++)
{
for (size_t l = 0; l < NUM_TILE_DATA_VARIABLES; l++)
for (size_t l = 0; l < LayeredTextures::NUM_TILE_DATA_VARIABLES; l++)
{
_tileUniformIds[i][j][k][l] =
_shaderProvider->_programObject->uniformLocation(
LayeredTextures::TEXTURE_CATEGORY_NAMES[i] +
blendLayerSuffixes[j] +
LayeredTextures::blendLayerSuffixes[j] +
"[" + std::to_string(k) + "]." +
glslTileDataNames[l]);
LayeredTextures::glslTileDataNames[l]);
}
}
}
@@ -228,14 +194,14 @@ namespace openspace {
for (size_t k = 0; k < LayeredTextures::MAX_NUM_TEXTURES_PER_CATEGORY;
k++)
{
for (size_t l = 0; l < NUM_LAYER_SETTINGS_VARIABLES; l++)
for (size_t l = 0; l < LayeredTextures::NUM_LAYER_SETTINGS_VARIABLES; l++)
{
_layerSettingsUniformIds[i][k][l] =
_shaderProvider->_programObject->uniformLocation(
LayeredTextures::TEXTURE_CATEGORY_NAMES[i] +
"Settings" +
"[" + std::to_string(k) + "]." +
layerSettingsIds[l]);
LayeredTextures::layerSettingsIds[l]);
}
}
}
@@ -249,7 +215,7 @@ namespace openspace {
LayeredTextures::TextureCategory category,
size_t blendLayer,
size_t layerIndex,
GlslTileDataId tileDataId)
LayeredTextures::GlslTileDataId tileDataId)
{
return _tileUniformIds[category][blendLayer][layerIndex][tileDataId];
}
@@ -257,7 +223,7 @@ namespace openspace {
GLint LayeredTextureShaderUniformIdHandler::getSettingsId(
LayeredTextures::TextureCategory category,
size_t layerIndex,
LayerSettingsIds layerSettingsId)
LayeredTextures::LayerSettingsIds layerSettingsId)
{
return _layerSettingsUniformIds[category][layerIndex][layerSettingsId];
}
@@ -25,7 +25,7 @@
#ifndef __LAYERED_TEXTURE_SHADER_PROVIDER__
#define __LAYERED_TEXTURE_SHADER_PROVIDER__
#include <modules/globebrowsing/tile/layeredtextures.h>
#include <modules/globebrowsing/layered_rendering/layeredtextures.h>
#include "ghoul/opengl/programobject.h"
@@ -47,15 +47,6 @@ namespace openspace {
*/
struct LayeredTextureInfo
{
static const size_t NUM_SETTINGS_PER_CATEGORY = 3;
enum GlslKeyPrefixes
{
lastLayerIndex,
use,
blend,
};
static const std::string glslKeyPrefixes[NUM_SETTINGS_PER_CATEGORY];
int lastLayerIdx;
bool layerBlendingEnabled;
@@ -123,56 +114,6 @@ namespace openspace {
class LayeredTextureShaderUniformIdHandler
{
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 = 3;
/**
* Each texture can have these uniform variables associated with it in the shader
* code.
*
* <code>textureSampler</code> is the actual texture that can be sampled in the
* shader program. The associated GLSL type is <code>sampler2D</code>.
* <code>depthTransform_depthScale</code> specifies the scale part of the depth
* transform. Useful for height maps. The associated GLSL type is
* <code>float</code>.
* <code>depthTransform_depthOffset</code> specifies the offset part of the depth
* transform. Useful for height maps. The associated GLSL type is
* <code>float</code>.
* <code>uvTransform_uvOffset</code> specifies an offset that can be used when
* sampling from the texture. The associated GLSL type is <code>vec2</code>.
* <code>uvTransform_uvScale</code> specifies a scale that can be used when
* sampling from the texture. The associated GLSL type is <code>vec2</code>.
*
* The corresponding struct in GLSL code for storing these data is a
* <code>Tile</code>. The names of the uniforms are the ones specified in
* <code>glslTileDataNames</code>.
*/
enum GlslTileDataId {
textureSampler,
depthTransform_depthScale,
depthTransform_depthOffset,
uvTransform_uvOffset,
uvTransform_uvScale,
};
/**
* These suffixes are used when naming <code>Tile</code>s in GLSL code. The names
* of the <code>Tile</code>s is one of
* <code>LayeredTextures::TEXTURE_CATEGORY_NAMES</code> followed by the suffixes
* defined in <code>blendLayerSuffixes</code>.
*/
enum BlendLayerSuffixes {
none,
Parent1,
Parent2,
};
enum LayerSettingsIds {
opacity,
gamma,
multiplier,
};
LayeredTextureShaderUniformIdHandler();
~LayeredTextureShaderUniformIdHandler();
@@ -198,25 +139,22 @@ namespace openspace {
LayeredTextures::TextureCategory category,
size_t blendLayer,
size_t layerIndex,
GlslTileDataId tileDataId);
LayeredTextures::GlslTileDataId tileDataId);
GLint getSettingsId(
LayeredTextures::TextureCategory category,
size_t layerIndex,
LayerSettingsIds layerSettingsId);
LayeredTextures::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<
std::array<
std::array<
GLint,
NUM_TILE_DATA_VARIABLES>,
LayeredTextures::NUM_TILE_DATA_VARIABLES>,
LayeredTextures::MAX_NUM_TEXTURES_PER_CATEGORY>,
NUM_BLEND_TEXTURES>,
LayeredTextures::NUM_BLEND_TEXTURES>,
LayeredTextures::NUM_TEXTURE_CATEGORIES>
_tileUniformIds;
@@ -225,7 +163,7 @@ namespace openspace {
std::array<
std::array<
GLint,
NUM_LAYER_SETTINGS_VARIABLES>,
LayeredTextures::NUM_LAYER_SETTINGS_VARIABLES>,
LayeredTextures::MAX_NUM_TEXTURES_PER_CATEGORY>,
LayeredTextures::NUM_TEXTURE_CATEGORIES>
_layerSettingsUniformIds;
@@ -22,34 +22,30 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __LAYERED_TEXTURES_H__
#define __LAYERED_TEXTURES_H__
#include <memory>
#include <vector>
#include <string>
#include <modules/globebrowsing/layered_rendering/perlayersetting.h>
namespace openspace {
class LayeredTextures {
PerLayerSetting::PerLayerSetting() {}
PerLayerSetting::~PerLayerSetting() {}
public:
PerLayerFloatSetting::PerLayerFloatSetting(
std::string name,
std::string guiName,
float defaultValue,
float minimumValue,
float maximumValue)
: _property(name, guiName, defaultValue, minimumValue, maximumValue) { }
PerLayerFloatSetting::~PerLayerFloatSetting(){};
static const size_t NUM_TEXTURE_CATEGORIES = 7;
static const size_t MAX_NUM_TEXTURES_PER_CATEGORY = 5;
void PerLayerFloatSetting::uploadUniform(
ProgramObject* programObject,
GLint settingsId) {
programObject->setUniform(settingsId, _property);
}
enum TextureCategory {
ColorTextures,
GrayScaleTextures,
GrayScaleOverlays,
NightTextures,
WaterMasks,
Overlays,
HeightMaps,
};
static const std::string TEXTURE_CATEGORY_NAMES[NUM_TEXTURE_CATEGORIES];
};
properties::Property* PerLayerFloatSetting::property() {
return &_property;
}
} // namespace openspace
#endif // __LAYERED_TEXTURES_H__
@@ -0,0 +1,66 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2016 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __PER_LAYER_SETTING_H__
#define __PER_LAYER_SETTING_H__
#include <string>
#include <ghoul/opengl/programobject.h>
#include <openspace/properties/scalarproperty.h>
namespace openspace {
using namespace ghoul::opengl;
class PerLayerSetting {
public:
PerLayerSetting();
~PerLayerSetting();
virtual void uploadUniform(
ProgramObject* programObject,
GLint settingsId) = 0;
virtual properties::Property* property() = 0;
private:
};
class PerLayerFloatSetting : public PerLayerSetting {
public:
PerLayerFloatSetting(
std::string name,
std::string guiName,
float defaultValue,
float minimumValue,
float maximumValue);
~PerLayerFloatSetting();
virtual void uploadUniform(ProgramObject* programObject, GLint settingsId);
virtual properties::Property* property();
private:
properties::FloatProperty _property;
};
} // namespace openspace
#endif // __PER_LAYER_SETTING_H__
@@ -27,9 +27,10 @@
#include <modules/globebrowsing/tile/tileprovider/tileprovider.h>
#include <modules/globebrowsing/tile/layeredtextures.h>
#include <modules/globebrowsing/layered_rendering/layeredtextures.h>
#include <ghoul/misc/dictionary.h>
#include <ghoul/misc/assert.h>
#include <memory>
#include <vector>
@@ -37,17 +38,12 @@
namespace openspace {
struct PerLayerSettings {
float opacity = 1;
float gamma = 1;
float multiplier = 1;
};
struct NamedTileProvider {
std::string name;
std::shared_ptr<TileProvider> tileProvider;
bool isActive;
PerLayerSettings settings;
};