Add texture category GrayScaleTexture for textures with one channel.

This commit is contained in:
kalbl
2016-09-30 01:39:43 +02:00
parent fae89a12a0
commit 619048e3b9
8 changed files with 84 additions and 14 deletions

View File

@@ -80,6 +80,9 @@ return {
FilePath = "map_service_configs/ESRI/ESRI_Imagery_World_2D.wms",
Enabled = true,
}
},
GrayScaleTextures = {
},
GrayScaleOverlays = {

View File

@@ -33,11 +33,11 @@ return {
Radii = marsEllipsoid,
CameraMinHeight = 1000,
InteractionDepthBelowEllipsoid = 10000, -- Useful when having negative height map values
SegmentsPerPatch = 90,
SegmentsPerPatch = 64,
TextureInitData = {
ColorTextureMinimumSize = 512,
OverlayMinimumSize = 512,
HeightMapMinimumSize = 90,
HeightMapMinimumSize = 64,
},
Textures = {
ColorTextures = {
@@ -47,16 +47,23 @@ return {
FilePath = "../debugglobe/textures/test_tile.png",
},
{
Name = "MARS_Viking_MDIM21",
Name = "MARS_Viking",
FilePath = "map_service_configs/MARS_Viking_MDIM21.xml",
Enabled = true,
},
--[[
{
Name = "Mars Viking Clr",
FilePath = "map_datasets/Viking/Mars_Viking_ClrMosaic_global_925m_longlat_full.vrt",
Enabled = true,
},
]]
},
GrayScaleTextures = {
},
GrayScaleOverlays = {
--[[
{
Name = "CTX Mosaic",
FilePath = "map_service_configs/CTX_Mosaic.xml",
@@ -79,6 +86,7 @@ return {
Name = "Part of Area Traversed by the Mars Exploration Rover",
FilePath = "map_datasets/HiRISE/Part_of_Area_Traversed_by_the_Mars_Exploration_Rover_Texture.vrt",
},
]]
},
NightTextures = {
@@ -99,6 +107,14 @@ return {
},
},
HeightMaps = {
{
Name = "Mola Elevation",
FilePath = "map_service_configs/Mars_MGS_MOLA_DEM.xml",
Enabled = true,
MinimumPixelSize = 64,
DoPreProcessing = true,
},
--[[
{
Name = "Mola Elevation",
FilePath = "map_service_configs/Mola_Elevation.xml",
@@ -123,6 +139,7 @@ return {
Name = "Part of Area Traversed by the Mars Exploration Rover",
FilePath = "map_datasets/HiRISE/Part_of_Area_Traversed_by_the_Mars_Exploration_Rover_Heightmap.vrt",
},
]]
},
},
}

View File

@@ -54,6 +54,7 @@ return {
FilePath = "map_service_configs/OnMercuryImage.xml",
},
},
GrayScaleTextures = { },
GrayScaleOverlays = { },
NightTextures = { },
WaterMasks = { },

View File

@@ -29,21 +29,18 @@ return {
},
Textures = {
ColorTextures = {
},
GrayScaleOverlays = {
},
GrayScaleTextures = {
{
Name = "OnMoonColorGrayscale",
FilePath = "map_service_configs/OnMoonColor.xml",
Enabled = true,
},
},
GrayScaleOverlays = {
--[[
{
Name = "OnMoonColorGrayscale",
FilePath = "map_service_configs/OnMoonGrayscaleOverlay.vrt",
Enabled = true,
},
]]
},
NightTextures = {
},

View File

@@ -38,6 +38,10 @@
#define USE_COLORTEXTURE #{useColorTextures}
#define COLORTEXTURE_BLENDING_ENABLED #{blendColorTextures}
#define NUMLAYERS_GRAYSCALETEXTURE #{lastLayerIndexGrayScaleTextures} + 1
#define USE_GRAYSCALETEXTURE #{useGrayScaleTextures}
#define GRAYSCALETEXTURE_BLENDING_ENABLED #{blendGrayScaleTextures}
// Third layer type from LayeredTextureShaderProvider is water mask
#define NUMLAYERS_WATERMASK #{lastLayerIndexWaterMasks} + 1
#define USE_WATERMASK #{useWaterMasks}
@@ -156,6 +160,37 @@ vec4 calculateColor(
return color;
}
vec4 calculateGrayScale(
const vec4 currentColor,
const vec2 uv,
LevelWeights levelWeights,
const Tile grayscaleTextureTiles[NUMLAYERS_GRAYSCALETEXTURE],
const Tile grayscaleTextureTilesParent1[NUMLAYERS_GRAYSCALETEXTURE],
const Tile grayscaleTextureTilesParent2[NUMLAYERS_GRAYSCALETEXTURE]) {
vec4 colorGrayScale = currentColor;
// The shader compiler will remove unused code when variables are multiplied by
// a constant 0
#if !GRAYSCALETEXTURE_BLENDING_ENABLED
levelWeights = getDefaultLevelWeights();
#endif // GRAYSCALE_OVERLAY_BLENDING_ENABLED
#for i in 0..#{lastLayerIndexGrayScaleTextures}
{
vec4 colorSample =
levelWeights.w1 * getTexVal(grayscaleTextureTiles[#{i}], uv) +
levelWeights.w2 * getTexVal(grayscaleTextureTilesParent1[#{i}], uv) +
levelWeights.w3 * getTexVal(grayscaleTextureTilesParent2[#{i}], uv);
colorSample = vec4(colorSample.r, colorSample.r, colorSample.r, 1);
colorGrayScale = blendOver(colorGrayScale, colorSample);
}
#endfor
return colorGrayScale;
}
float gridDots(vec2 uv, vec2 gridResolution){
vec2 uvVertexSpace = fract((gridResolution) * uv) + 0.5;

View File

@@ -39,6 +39,12 @@ uniform Tile ColorTexturesParent1[NUMLAYERS_COLORTEXTURE];
uniform Tile ColorTexturesParent2[NUMLAYERS_COLORTEXTURE];
#endif // USE_COLORTEXTURE
#if USE_GRAYSCALETEXTURE
uniform Tile GrayScaleTextures[NUMLAYERS_GRAYSCALETEXTURE];
uniform Tile GrayScaleTexturesParent1[NUMLAYERS_GRAYSCALETEXTURE];
uniform Tile GrayScaleTexturesParent2[NUMLAYERS_GRAYSCALETEXTURE];
#endif // USE_GRAYSCALETEXTURE
#if USE_NIGHTTEXTURE
uniform Tile NightTextures[NUMLAYERS_NIGHTTEXTURE];
uniform Tile NightTexturesParent1[NUMLAYERS_NIGHTTEXTURE];
@@ -138,6 +144,15 @@ vec4 getTileFragColor(){
ColorTexturesParent2);
#endif // USE_COLORTEXTURE
#if USE_GRAYSCALETEXTURE
color = calculateGrayScale(
color,
fs_uv,
levelWeights,
GrayScaleTextures,
GrayScaleTexturesParent1,
GrayScaleTexturesParent2);
#endif // USE_GRAYSCALETEXTURE
#if USE_GRAYSCALE_OVERLAY

View File

@@ -39,6 +39,7 @@ namespace openspace {
const std::string LayeredTextures::TEXTURE_CATEGORY_NAMES[NUM_TEXTURE_CATEGORIES] =
{
"ColorTextures",
"GrayScaleTextures",
"GrayScaleOverlays",
"NightTextures",
"WaterMasks",

View File

@@ -35,11 +35,12 @@ namespace openspace {
public:
static const size_t NUM_TEXTURE_CATEGORIES = 6;
static const size_t NUM_TEXTURE_CATEGORIES = 7;
static const size_t MAX_NUM_TEXTURES_PER_CATEGORY = 5;
enum TextureCategory {
ColorTextures,
GrayScaleTextures,
GrayScaleOverlays,
NightTextures,
WaterMasks,
@@ -51,4 +52,4 @@ namespace openspace {
};
} // namespace openspace
#endif // __LAYERED_TEXTURES_H__
#endif // __LAYERED_TEXTURES_H__