mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-29 23:39:26 -05:00
Merge
This commit is contained in:
@@ -62,7 +62,7 @@ namespace openspace {
|
||||
|
||||
// Calculate desired level based on distance
|
||||
Scalar distanceToPatch = glm::length(cameraToChunk);
|
||||
Scalar distance = distanceToPatch - heights.min; // distance to actual minimum heights
|
||||
Scalar distance = distanceToPatch -heights.min; // distance to actual minimum heights
|
||||
|
||||
Scalar scaleFactor = globe->lodScaleFactor * ellipsoid.minimumRadius();
|
||||
Scalar projectedScaleFactor = scaleFactor / distance;
|
||||
|
||||
@@ -257,6 +257,16 @@ namespace openspace {
|
||||
texUnits[category][i].blendTexture2,
|
||||
tileAndTransformParent2);
|
||||
}
|
||||
|
||||
/*
|
||||
if (category == LayeredTextures::HeightMaps && tileAndTransform.tile.preprocessData) {
|
||||
//auto preprocessingData = tileAndTransform.tile.preprocessData;
|
||||
//float noDataValue = preprocessingData->noDataValues[0];
|
||||
programObject->setUniform(
|
||||
"minimumValidHeight[" + std::to_string(i) + "]",
|
||||
-100000);
|
||||
}
|
||||
*/
|
||||
i++;
|
||||
}
|
||||
}
|
||||
@@ -278,6 +288,23 @@ namespace openspace {
|
||||
i++;
|
||||
}
|
||||
|
||||
// Go through all the height map overlays and set depth tranforms
|
||||
i = 0;
|
||||
it = tileProviders[LayeredTextures::HeightMapOverlays].begin();
|
||||
end = tileProviders[LayeredTextures::HeightMapOverlays].end();
|
||||
for (; it != end; it++) {
|
||||
auto tileProvider = *it;
|
||||
|
||||
TileDepthTransform depthTransform = tileProvider->depthTransform();
|
||||
setDepthTransformUniforms(
|
||||
programUniformHandler,
|
||||
LayeredTextures::TextureCategory::HeightMapOverlays,
|
||||
LayeredTextureShaderUniformIdHandler::BlendLayerSuffix::none,
|
||||
i,
|
||||
depthTransform);
|
||||
i++;
|
||||
}
|
||||
|
||||
// The length of the skirts is proportional to its size
|
||||
programObject->setUniform("skirtLength", min(static_cast<float>(chunk.surfacePatch().halfSize().lat * 1000000), 8700.0f));
|
||||
programObject->setUniform("xSegments", _grid->xSegments());
|
||||
@@ -285,7 +312,7 @@ namespace openspace {
|
||||
if (tileProviders[LayeredTextures::ColorTextures].size() == 0) {
|
||||
programObject->setUniform("vertexResolution", glm::vec2(_grid->xSegments(), _grid->ySegments()));
|
||||
}
|
||||
|
||||
|
||||
return programObject;
|
||||
}
|
||||
|
||||
|
||||
@@ -96,6 +96,7 @@ Fragment getFragment() {
|
||||
#if USE_HEIGHTMAP
|
||||
frag.color.r += tileResolution(fs_uv, HeightMaps[0]) > 0.9 ? 1 : 0;
|
||||
#endif
|
||||
//frag.color = frag.color * 0.001 + vec4(0,0,0,1);
|
||||
#endif // USE_COLORTEXTURE
|
||||
|
||||
#if USE_GRAYSCALE_OVERLAY
|
||||
|
||||
@@ -45,6 +45,12 @@ uniform Tile HeightMapsParent1[NUMLAYERS_HEIGHTMAP];
|
||||
uniform Tile HeightMapsParent2[NUMLAYERS_HEIGHTMAP];
|
||||
#endif // USE_HEIGHTMAP
|
||||
|
||||
#if USE_HEIGHTMAP_OVERLAY
|
||||
uniform Tile HeightMapOverlays[NUMLAYERS_HEIGHTMAP_OVERLAY];
|
||||
uniform Tile HeightMapOverlaysParent1[NUMLAYERS_HEIGHTMAP_OVERLAY];
|
||||
uniform Tile HeightMapOverlaysParent2[NUMLAYERS_HEIGHTMAP_OVERLAY];
|
||||
#endif // USE_HEIGHTMAP_OVERLAY
|
||||
|
||||
uniform vec3 cameraPosition;
|
||||
uniform float distanceScaleFactor;
|
||||
uniform int chunkLevel;
|
||||
@@ -77,7 +83,6 @@ void main()
|
||||
float height = 0;
|
||||
|
||||
#if USE_HEIGHTMAP
|
||||
|
||||
// Calculate desired level based on distance to the vertex on the ellipsoid
|
||||
// Before any heightmapping is done
|
||||
height = calculateHeight(
|
||||
@@ -87,6 +92,15 @@ void main()
|
||||
|
||||
#endif // USE_HEIGHTMAP
|
||||
|
||||
#if USE_HEIGHTMAP_OVERLAY
|
||||
height = calculateHeightOverlay(
|
||||
height,
|
||||
in_uv,
|
||||
levelWeights, // Variable to determine which texture to sample from
|
||||
HeightMapOverlays, HeightMapOverlaysParent1, HeightMapOverlaysParent2); // Three textures to sample from
|
||||
|
||||
#endif // USE_HEIGHTMAP_OVERLAY
|
||||
|
||||
// Skirts
|
||||
int vertexIDx = gl_VertexID % (xSegments + 3);
|
||||
int vertexIDy = gl_VertexID / (xSegments + 3);
|
||||
|
||||
@@ -44,6 +44,12 @@ uniform Tile HeightMapsParent1[NUMLAYERS_HEIGHTMAP];
|
||||
uniform Tile HeightMapsParent2[NUMLAYERS_HEIGHTMAP];
|
||||
#endif // USE_HEIGHTMAP
|
||||
|
||||
#if USE_HEIGHTMAP_OVERLAY
|
||||
uniform Tile HeightMapOverlays[NUMLAYERS_HEIGHTMAP_OVERLAY];
|
||||
uniform Tile HeightMapOverlaysParent1[NUMLAYERS_HEIGHTMAP_OVERLAY];
|
||||
uniform Tile HeightMapOverlaysParent2[NUMLAYERS_HEIGHTMAP_OVERLAY];
|
||||
#endif // USE_HEIGHTMAP_OVERLAY
|
||||
|
||||
uniform int xSegments;
|
||||
uniform float skirtLength;
|
||||
|
||||
@@ -92,6 +98,16 @@ void main()
|
||||
HeightMaps, HeightMapsParent1, HeightMapsParent2); // Three textures to sample from
|
||||
|
||||
#endif // USE_HEIGHTMAP
|
||||
|
||||
#if USE_HEIGHTMAP_OVERLAY
|
||||
// Calculate desired level based on distance to the vertex on the ellipsoid
|
||||
// Before any heightmapping is done
|
||||
height = calculateHeightOverlay(
|
||||
height,
|
||||
in_uv,
|
||||
levelWeights, // Variable to determine which texture to sample from
|
||||
HeightMapOverlays, HeightMapOverlaysParent1, HeightMapOverlaysParent2); // Three textures to sample from
|
||||
#endif // USE_HEIGHTMAP_OVERLAY
|
||||
|
||||
// Skirts
|
||||
int vertexIDx = gl_VertexID % (xSegments + 3);
|
||||
|
||||
@@ -33,6 +33,11 @@
|
||||
#define USE_HEIGHTMAP #{useHeightMaps}
|
||||
#define HEIGHTMAP_BLENDING_ENABLED #{blendHeightMaps}
|
||||
|
||||
// First layer type from LayeredTextureShaderProvider is height map
|
||||
#define NUMLAYERS_HEIGHTMAP_OVERLAY #{lastLayerIndexHeightMapOverlays} + 1
|
||||
#define USE_HEIGHTMAP_OVERLAY #{useHeightMapOverlays}
|
||||
#define HEIGHTMAP_OVERLAY_BLENDING_ENABLED #{blendHeightMapOverlays}
|
||||
|
||||
// Second layer type from LayeredTextureShaderProvider is color texture
|
||||
#define NUMLAYERS_COLORTEXTURE #{lastLayerIndexColorTextures} + 1
|
||||
#define USE_COLORTEXTURE #{useColorTextures}
|
||||
@@ -77,7 +82,7 @@ float calculateHeight(
|
||||
levelWeights = getDefaultLevelWeights();
|
||||
#endif // HEIGHTMAP_BLENDING_ENABLED
|
||||
|
||||
|
||||
|
||||
#for i in 0..#{lastLayerIndexHeightMaps}
|
||||
{
|
||||
float untransformedHeight =
|
||||
@@ -85,11 +90,43 @@ float calculateHeight(
|
||||
levelWeights.w2 * getTexVal(heightTilesParent1[#{i}], uv).r +
|
||||
levelWeights.w3 * getTexVal(heightTilesParent2[#{i}], uv).r;
|
||||
|
||||
// OBS! Only the values from the last height map will be used!
|
||||
height = getTransformedTexVal(heightTiles[#{i}].depthTransform, untransformedHeight);
|
||||
float heightSample = getTransformedTexVal(heightTiles[#{i}].depthTransform, untransformedHeight);
|
||||
if (heightSample > -100000)
|
||||
height = heightSample;
|
||||
}
|
||||
#endfor
|
||||
return height;
|
||||
}
|
||||
|
||||
float calculateHeightOverlay(
|
||||
float currentHeight,
|
||||
vec2 uv,
|
||||
LevelWeights levelWeights,
|
||||
const Tile heightOverlayTiles[NUMLAYERS_HEIGHTMAP_OVERLAY],
|
||||
const Tile heightOverlayTilesParent1[NUMLAYERS_HEIGHTMAP_OVERLAY],
|
||||
const Tile heightOverlayTilesParent2[NUMLAYERS_HEIGHTMAP_OVERLAY]) {
|
||||
|
||||
float height = currentHeight;
|
||||
|
||||
// The shader compiler will remove unused code when variables are multiplied by
|
||||
// a constant 0
|
||||
#if !HEIGHTMAP_OVERLAY_BLENDING_ENABLED
|
||||
levelWeights = getDefaultLevelWeights();
|
||||
#endif // HEIGHTMAP_OVERLAY_BLENDING_ENABLED
|
||||
|
||||
#for i in 0..#{lastLayerIndexHeightMapOverlays}
|
||||
{
|
||||
vec4 untransformedHeightSample =
|
||||
levelWeights.w1 * getTexVal(heightOverlayTiles[#{i}], uv) +
|
||||
levelWeights.w2 * getTexVal(heightOverlayTilesParent1[#{i}], uv) +
|
||||
levelWeights.w3 * getTexVal(heightOverlayTilesParent2[#{i}], uv);
|
||||
|
||||
float heightSample = getTransformedTexVal(heightOverlayTiles[#{i}].depthTransform, untransformedHeightSample.r);
|
||||
if (untransformedHeightSample.g > 0.5)
|
||||
height = heightSample;
|
||||
}
|
||||
#endfor
|
||||
|
||||
return height;
|
||||
}
|
||||
|
||||
@@ -240,12 +277,11 @@ vec4 calculateGrayScaleOverlay(
|
||||
}
|
||||
#endfor
|
||||
|
||||
|
||||
/*
|
||||
// HSV blending
|
||||
vec3 hsvCurrent = rgb2hsv(currentColor.rgb);
|
||||
vec3 hsvNew = vec3(hsvCurrent.x, hsvCurrent.y, colorGrayScale.r);
|
||||
vec3 rgbNew = hsv2rgb(hsvNew);
|
||||
/*
|
||||
|
||||
// HSL blending
|
||||
vec3 hslCurrent = rgb2hsl(currentColor.rgb);
|
||||
@@ -254,7 +290,7 @@ vec4 calculateGrayScaleOverlay(
|
||||
vec3 rgbNew = hsl2rgb(hslNew);
|
||||
*/
|
||||
// No color blending, use grayscale
|
||||
//vec3 rgbNew = colorGrayScale.rgb;
|
||||
vec3 rgbNew = colorGrayScale.rgb;
|
||||
vec4 color = blendOver(currentColor, vec4(rgbNew, colorGrayScale.a));
|
||||
|
||||
return color;
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace openspace {
|
||||
else if (i == LayeredTextures::Overlays) {
|
||||
initData.minimumPixelSize = textureInitDictionary.value<double>("OverlayMinimumSize");
|
||||
}
|
||||
else if (i == LayeredTextures::HeightMaps) {
|
||||
else if (i == LayeredTextures::HeightMaps || i == LayeredTextures::HeightMapOverlays) {
|
||||
initData.minimumPixelSize = textureInitDictionary.value<double>("HeightMapMinimumSize");
|
||||
}
|
||||
else {
|
||||
@@ -73,7 +73,9 @@ namespace openspace {
|
||||
initData.threads = 1;
|
||||
initData.cacheSize = 500;
|
||||
initData.framesUntilRequestQueueFlush = 60;
|
||||
initData.preprocessTiles = i == LayeredTextures::HeightMaps; // Only preprocess height maps.
|
||||
initData.preprocessTiles =
|
||||
i == LayeredTextures::HeightMaps ||
|
||||
i == LayeredTextures::HeightMapOverlays; // Only preprocess height maps.
|
||||
|
||||
initTexures(
|
||||
_layerCategories[i],
|
||||
|
||||
@@ -39,11 +39,12 @@ namespace openspace {
|
||||
const std::string LayeredTextures::TEXTURE_CATEGORY_NAMES[NUM_TEXTURE_CATEGORIES] =
|
||||
{
|
||||
"ColorTextures",
|
||||
"GrayScaleOverlays",
|
||||
"NightTextures",
|
||||
"HeightMaps",
|
||||
"WaterMasks",
|
||||
"Overlays",
|
||||
"GrayScaleOverlays"
|
||||
"HeightMaps",
|
||||
"HeightMapOverlays",
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -35,16 +35,17 @@ 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,
|
||||
GrayScaleOverlays,
|
||||
NightTextures,
|
||||
HeightMaps,
|
||||
WaterMasks,
|
||||
Overlays,
|
||||
GrayScaleOverlays,
|
||||
HeightMaps,
|
||||
HeightMapOverlays,
|
||||
};
|
||||
|
||||
static const std::string TEXTURE_CATEGORY_NAMES[NUM_TEXTURE_CATEGORIES];
|
||||
|
||||
@@ -84,8 +84,8 @@ namespace openspace {
|
||||
ratio.y = write.region.numPixels.y / (double) read.region.numPixels.y;
|
||||
|
||||
double ratioRatio = ratio.x / ratio.y;
|
||||
//ghoul_assert(glm::abs(ratioRatio - 1.0) < 0.001, "Different read/write aspect ratio!");
|
||||
|
||||
//ghoul_assert(glm::abs(ratioRatio - 1.0) < 0.01, "Different read/write aspect ratio!");
|
||||
|
||||
IODescription whatCameOff = *this;
|
||||
whatCameOff.read.region = read.region.globalCut(side, pos);
|
||||
@@ -426,7 +426,6 @@ namespace openspace {
|
||||
return geodetic;
|
||||
}
|
||||
|
||||
|
||||
IODescription TileDataset::getIODescription(const ChunkIndex& chunkIndex) const {
|
||||
IODescription io;
|
||||
io.read.region = gdalPixelRegion(chunkIndex);
|
||||
@@ -663,22 +662,29 @@ namespace openspace {
|
||||
preprocessData->maxValues.resize(_dataLayout.numRasters);
|
||||
preprocessData->minValues.resize(_dataLayout.numRasters);
|
||||
|
||||
std::vector<float> noDataValues;
|
||||
noDataValues.resize(_dataLayout.numRasters);
|
||||
|
||||
for (size_t c = 0; c < _dataLayout.numRasters; c++) {
|
||||
preprocessData->maxValues[c] = -FLT_MAX;
|
||||
preprocessData->minValues[c] = FLT_MAX;
|
||||
noDataValues[c] = _dataset->GetRasterBand(1)->GetNoDataValue();
|
||||
}
|
||||
|
||||
float noDataValue = _dataset->GetRasterBand(1)->GetNoDataValue();
|
||||
|
||||
for (size_t y = 0; y < region.numPixels.y; y++) {
|
||||
size_t yi_flipped = y * bytesPerLine;
|
||||
size_t yi = (region.numPixels.y - 1 - y) * bytesPerLine;
|
||||
size_t i = 0;
|
||||
for (size_t x = 0; x < region.numPixels.x; x++) {
|
||||
for (size_t c = 0; c < _dataLayout.numRasters; c++) {
|
||||
|
||||
float val = TileDataType::interpretFloat(_dataLayout.gdalType, &(result->imageData[yi + i]));
|
||||
preprocessData->maxValues[c] = std::max(val, preprocessData->maxValues[c]);
|
||||
preprocessData->minValues[c] = std::min(val, preprocessData->minValues[c]);
|
||||
|
||||
|
||||
if (val != noDataValue) {
|
||||
preprocessData->maxValues[c] = std::max(val, preprocessData->maxValues[c]);
|
||||
preprocessData->minValues[c] = std::min(val, preprocessData->minValues[c]);
|
||||
}
|
||||
i += _dataLayout.bytesPerDatum;
|
||||
}
|
||||
}
|
||||
@@ -695,15 +701,18 @@ namespace openspace {
|
||||
|
||||
CPLErr TileDataset::postProcessErrorCheck(std::shared_ptr<const TileIOResult> result, const IODescription& io) const{
|
||||
int success;
|
||||
|
||||
double missingDataValue = gdalRasterBand(io.read.overview)->GetNoDataValue(&success);
|
||||
if (!success) {
|
||||
missingDataValue = 32767; // missing data value for TERRAIN.wms. Should be specified in xml
|
||||
}
|
||||
|
||||
bool hasMissingData = false;
|
||||
|
||||
for (size_t c = 0; c < _dataLayout.numRasters; c++) {
|
||||
hasMissingData |= result->preprocessData->maxValues[c] == missingDataValue;
|
||||
}
|
||||
|
||||
bool onHighLevel = result->chunkIndex.level > 6;
|
||||
if (hasMissingData && onHighLevel) {
|
||||
return CE_Fatal;
|
||||
|
||||
Reference in New Issue
Block a user