mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-20 02:58:31 -05:00
Set preferred size of tiles for tile provider.
This commit is contained in:
@@ -50,7 +50,7 @@ namespace openspace {
|
||||
, _ellipsoid(ellipsoid)
|
||||
{
|
||||
_tileProvider = shared_ptr<TileProvider>(new TileProvider(
|
||||
"map_service_configs/TERRAIN.wms", 100));
|
||||
"map_service_configs/TERRAIN.wms", 5000, 512));
|
||||
// init Renderer
|
||||
auto outerPatchRenderer = new ClipMapPatchRenderer(
|
||||
shared_ptr<OuterClipMapGrid>(new OuterClipMapGrid(512)),
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace openspace {
|
||||
dictionary.getValue(keyRadii, radii);
|
||||
_ellipsoid = Ellipsoid(radii);
|
||||
|
||||
//addSwitchValue(std::shared_ptr<ClipMapGlobe>(new ClipMapGlobe(_ellipsoid)), 1e8);
|
||||
addSwitchValue(std::shared_ptr<ClipMapGlobe>(new ClipMapGlobe(_ellipsoid)), 1e8);
|
||||
addSwitchValue(std::shared_ptr<ChunkLodGlobe>(new ChunkLodGlobe(_ellipsoid)), 1e9);
|
||||
addSwitchValue(std::shared_ptr<GlobeMesh>(new GlobeMesh()), 1e10);
|
||||
}
|
||||
|
||||
@@ -80,7 +80,8 @@ namespace openspace {
|
||||
|
||||
std::shared_ptr<UninitializedTextureTile> getUninitializedTextureTile(
|
||||
GDALDataset * dataSet,
|
||||
const GeodeticTileIndex & tileIndex);
|
||||
const GeodeticTileIndex & tileIndex,
|
||||
int minNumPixelsRequired);
|
||||
|
||||
UninitializedTextureTile::TextureFormat getTextureFormatFromRasterCount(
|
||||
int rasterCount);
|
||||
|
||||
@@ -44,7 +44,8 @@ namespace openspace {
|
||||
template<class T>
|
||||
std::shared_ptr<UninitializedTextureTile> GdalDataConverter<T>::getUninitializedTextureTile(
|
||||
GDALDataset* dataSet,
|
||||
const GeodeticTileIndex& tileIndex) {
|
||||
const GeodeticTileIndex& tileIndex,
|
||||
int minNumPixelsRequired) {
|
||||
int nRasters = dataSet->GetRasterCount();
|
||||
|
||||
ghoul_assert(nRasters > 0, "Bad dataset. Contains no rasterband.");
|
||||
@@ -67,7 +68,6 @@ namespace openspace {
|
||||
|
||||
int minNumPixels0 = glm::min(numberOfPixels0.x, numberOfPixels0.y);
|
||||
|
||||
int minNumPixelsRequired = 512;
|
||||
int ov = log2(minNumPixels0) - log2(minNumPixelsRequired + 1);
|
||||
|
||||
ov = glm::clamp(ov, 0, numOverviews - 1);
|
||||
|
||||
@@ -44,21 +44,6 @@ namespace openspace {
|
||||
, _offsetLevel0(offsetLevel0)
|
||||
, _depth(depth)
|
||||
{
|
||||
// Set e texture to test
|
||||
std::string fileName = "textures/earth_bluemarble.jpg";
|
||||
//std::string fileName = "../../../build/tiles/tile5_8_12.png";
|
||||
//std::string fileName = "tile5_8_12.png";
|
||||
_tempTexture = std::move(ghoul::io::TextureReader::ref().loadTexture(absPath(fileName)));
|
||||
|
||||
if (_tempTexture) {
|
||||
LDEBUG("Loaded texture from '" << "textures/earth_bluemarble.jpg" << "'");
|
||||
_tempTexture->uploadTexture();
|
||||
|
||||
// Textures of planets looks much smoother with AnisotropicMipMap rather than linear
|
||||
// TODO: AnisotropicMipMap crashes on ATI cards ---abock
|
||||
//_testTexture->setFilter(ghoul::opengl::Texture::FilterMode::AnisotropicMipMap);
|
||||
_tempTexture->setFilter(ghoul::opengl::Texture::FilterMode::Linear);
|
||||
}
|
||||
}
|
||||
|
||||
PatchCoverageProvider::~PatchCoverageProvider(){
|
||||
@@ -164,7 +149,7 @@ namespace openspace {
|
||||
if (patchCoverageToReturn.textureTransformPairs[linearIdx].first == nullptr)
|
||||
{
|
||||
patchCoverageToReturn.textureTransformPairs[linearIdx].first =
|
||||
_tempTexture;
|
||||
_tileProvider->getTemporaryTexture();
|
||||
patchCoverageToReturn.textureTransformPairs[linearIdx].second =
|
||||
glm::mat3(1);
|
||||
}
|
||||
|
||||
@@ -87,10 +87,6 @@ namespace openspace {
|
||||
Geodetic2 _sizeLevel0;
|
||||
Geodetic2 _offsetLevel0;
|
||||
int _depth;
|
||||
|
||||
std::shared_ptr<Texture> _tempTexture;
|
||||
|
||||
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -45,10 +45,29 @@ namespace openspace {
|
||||
|
||||
bool TileProvider::hasInitializedGDAL = false;
|
||||
|
||||
TileProvider::TileProvider(const std::string& filePath, int tileCacheSize)
|
||||
TileProvider::TileProvider(
|
||||
const std::string& filePath,
|
||||
int tileCacheSize,
|
||||
int minimumPixelSize)
|
||||
: _filePath(filePath)
|
||||
, _tileCache(tileCacheSize) // setting cache size
|
||||
, _minimumPixelSize(minimumPixelSize)
|
||||
{
|
||||
// Set a temporary texture
|
||||
std::string fileName = "textures/earth_bluemarble.jpg";
|
||||
_tempTexture = std::move(ghoul::io::TextureReader::ref().loadTexture(absPath(fileName)));
|
||||
|
||||
if (_tempTexture) {
|
||||
LDEBUG("Loaded texture from '" << fileName << "'");
|
||||
_tempTexture->uploadTexture();
|
||||
|
||||
// Textures of planets looks much smoother with AnisotropicMipMap rather than linear
|
||||
// TODO: AnisotropicMipMap crashes on ATI cards ---abock
|
||||
//_testTexture->setFilter(ghoul::opengl::Texture::FilterMode::AnisotropicMipMap);
|
||||
_tempTexture->setFilter(ghoul::opengl::Texture::FilterMode::Linear);
|
||||
}
|
||||
|
||||
|
||||
int downloadApplicationVersion = 1;
|
||||
if (!DownloadManager::isInitialized()) {
|
||||
DownloadManager::initialize(
|
||||
@@ -102,6 +121,10 @@ namespace openspace {
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<Texture> TileProvider::getTemporaryTexture() {
|
||||
return _tempTexture;
|
||||
}
|
||||
|
||||
std::shared_ptr<UninitializedTextureTile> TileProvider::getUninitializedTextureTile(
|
||||
const GeodeticTileIndex& tileIndex) {
|
||||
|
||||
@@ -111,25 +134,46 @@ namespace openspace {
|
||||
switch (gdalType)
|
||||
{
|
||||
case GDT_Byte:
|
||||
return _uByteConverter.getUninitializedTextureTile(_gdalDataSet, tileIndex);
|
||||
return _uByteConverter.getUninitializedTextureTile(
|
||||
_gdalDataSet,
|
||||
tileIndex,
|
||||
_minimumPixelSize);
|
||||
break;
|
||||
case GDT_UInt16:
|
||||
return _uShortConverter.getUninitializedTextureTile(_gdalDataSet, tileIndex);
|
||||
return _uShortConverter.getUninitializedTextureTile(
|
||||
_gdalDataSet,
|
||||
tileIndex,
|
||||
_minimumPixelSize);
|
||||
break;
|
||||
case GDT_Int16:
|
||||
return _shortConverter.getUninitializedTextureTile(_gdalDataSet, tileIndex);
|
||||
return _shortConverter.getUninitializedTextureTile(
|
||||
_gdalDataSet,
|
||||
tileIndex,
|
||||
_minimumPixelSize);
|
||||
break;
|
||||
case GDT_UInt32:
|
||||
return _uIntConverter.getUninitializedTextureTile(_gdalDataSet, tileIndex);
|
||||
return _uIntConverter.getUninitializedTextureTile(
|
||||
_gdalDataSet,
|
||||
tileIndex,
|
||||
_minimumPixelSize);
|
||||
break;
|
||||
case GDT_Int32:
|
||||
return _intConverter.getUninitializedTextureTile(_gdalDataSet, tileIndex);
|
||||
return _intConverter.getUninitializedTextureTile(
|
||||
_gdalDataSet,
|
||||
tileIndex,
|
||||
_minimumPixelSize);
|
||||
break;
|
||||
case GDT_Float32:
|
||||
return _floatConverter.getUninitializedTextureTile(_gdalDataSet, tileIndex);
|
||||
return _floatConverter.getUninitializedTextureTile(
|
||||
_gdalDataSet,
|
||||
tileIndex,
|
||||
_minimumPixelSize);
|
||||
break;
|
||||
case GDT_Float64:
|
||||
return _doubleConverter.getUninitializedTextureTile(_gdalDataSet, tileIndex);
|
||||
return _doubleConverter.getUninitializedTextureTile(
|
||||
_gdalDataSet,
|
||||
tileIndex,
|
||||
_minimumPixelSize);
|
||||
break;
|
||||
default:
|
||||
LERROR("GDAL data type unknown to OpenGL: " << gdalType);
|
||||
|
||||
@@ -53,10 +53,14 @@ namespace openspace {
|
||||
*/
|
||||
class TileProvider {
|
||||
public:
|
||||
TileProvider(const std::string& fileName, int tileCacheSize);
|
||||
TileProvider(
|
||||
const std::string& fileName,
|
||||
int tileCacheSize,
|
||||
int minimumPixelsize);
|
||||
~TileProvider();
|
||||
|
||||
std::shared_ptr<Texture> getTile(const GeodeticTileIndex& tileIndex);
|
||||
std::shared_ptr<Texture> getTemporaryTexture();
|
||||
|
||||
void prerender();
|
||||
|
||||
@@ -93,6 +97,9 @@ namespace openspace {
|
||||
GdalDataConverter<GLdouble> _doubleConverter;
|
||||
|
||||
ConcurrentJobManager<UninitializedTextureTile> _tileLoadManager;
|
||||
|
||||
std::shared_ptr<Texture> _tempTexture;
|
||||
int _minimumPixelSize;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace openspace {
|
||||
LatLonPatchRenderer::LatLonPatchRenderer(shared_ptr<Grid> grid)
|
||||
: PatchRenderer()
|
||||
, _grid(grid)
|
||||
, tileProvider("map_service_configs/TERRAIN.wms" , 5000)
|
||||
, tileProvider("map_service_configs/TERRAIN.wms" , 5000, 128)
|
||||
//, tileProvider("map_service_configs/frmt_wms_virtualearth.xml", 5000)
|
||||
//, tileProvider("textures/earth_bluemarble.jpg", 5000)
|
||||
{
|
||||
@@ -126,7 +126,6 @@ namespace openspace {
|
||||
mat4 modelViewProjectionTransform = data.camera.projectionMatrix()
|
||||
* viewTransform * modelTransform;
|
||||
|
||||
|
||||
// activate shader
|
||||
_programObject->activate();
|
||||
|
||||
@@ -135,19 +134,17 @@ namespace openspace {
|
||||
bool usingTile = true;
|
||||
tile00 = tileProvider.getTile(tileIndex);
|
||||
|
||||
if (tile00 != nullptr) {
|
||||
//tile00 = _tileSet.getTile(tileIndex);
|
||||
usingTile = false;
|
||||
|
||||
glm::mat3 uvTransform = glm::mat3(1);
|
||||
// Bind and use the texture
|
||||
ghoul::opengl::TextureUnit texUnit;
|
||||
texUnit.activate();
|
||||
tile00->bind();
|
||||
_programObject->setUniform("textureSampler00", texUnit);
|
||||
_programObject->setUniform("uvTransformPatchToTile00", uvTransform);
|
||||
|
||||
if (tile00 == nullptr) {
|
||||
tile00 = tileProvider.getTemporaryTexture();
|
||||
}
|
||||
|
||||
glm::mat3 uvTransform = glm::mat3(1);
|
||||
// Bind and use the texture
|
||||
ghoul::opengl::TextureUnit texUnit;
|
||||
texUnit.activate();
|
||||
tile00->bind();
|
||||
_programObject->setUniform("textureSampler00", texUnit);
|
||||
_programObject->setUniform("uvTransformPatchToTile00", uvTransform);
|
||||
|
||||
|
||||
Geodetic2 swCorner = newPatch.southWestCorner();
|
||||
|
||||
@@ -73,10 +73,8 @@ void main()
|
||||
|
||||
PositionNormalPair pair = globalInterpolation(fs_uv);
|
||||
|
||||
|
||||
float sampledHeight00, sampledHeight10, sampledHeight01, sampledHeight11;
|
||||
|
||||
|
||||
vec2 uv00 = vec2(uvTransformPatchToTile00 * vec3(fs_uv.s, fs_uv.t, 1));
|
||||
sampledHeight00 = texture(textureSampler00, uv00).r;
|
||||
vec2 uv10 = vec2(uvTransformPatchToTile10 * vec3(fs_uv.s, fs_uv.t, 1));
|
||||
|
||||
@@ -30,6 +30,8 @@ uniform vec3 radiiSquared;
|
||||
uniform vec2 minLatLon;
|
||||
uniform vec2 lonLatScalingFactor;
|
||||
|
||||
uniform sampler2D textureSampler00;
|
||||
|
||||
layout(location = 1) in vec2 in_UV;
|
||||
|
||||
out vec4 vs_position;
|
||||
@@ -38,20 +40,23 @@ out vec2 fs_uv;
|
||||
#include "PowerScaling/powerScaling_vs.hglsl"
|
||||
#include <${MODULE_GLOBEBROWSING}/shaders/ellipsoid.hglsl>
|
||||
|
||||
vec3 globalInterpolation() {
|
||||
PositionNormalPair globalInterpolation() {
|
||||
vec2 lonLatInput;
|
||||
lonLatInput.y = minLatLon.y + lonLatScalingFactor.y * in_UV.y; // Lat
|
||||
lonLatInput.x = minLatLon.x + lonLatScalingFactor.x * in_UV.x; // Lon
|
||||
PositionNormalPair positionPairModelSpace = geodetic2ToCartesian(lonLatInput.y, lonLatInput.x, radiiSquared);// latLonToCartesian(lonLatInput.y, lonLatInput.x, globeRadius);
|
||||
return positionPairModelSpace.position;
|
||||
return positionPairModelSpace;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
fs_uv = in_UV;
|
||||
vec3 p = globalInterpolation();
|
||||
PositionNormalPair pair = globalInterpolation();
|
||||
|
||||
vec4 position = modelViewProjectionTransform * vec4(p, 1);
|
||||
float sampledHeight = texture(textureSampler00, fs_uv).r;
|
||||
pair.position += pair.normal * sampledHeight * 1e5;
|
||||
|
||||
vec4 position = modelViewProjectionTransform * vec4(pair.position, 1);
|
||||
|
||||
vs_position = z_normalization(position);
|
||||
gl_Position = vs_position;
|
||||
|
||||
@@ -74,9 +74,6 @@ Fragment getFragment() {
|
||||
|
||||
frag.color = max(color00, max(color10, max(color01, color11))) * 10;
|
||||
|
||||
//frag.color = frag.color * 0.5 + 0.999*texture(textureSampler, fs_uv);
|
||||
//frag.color /= 4;
|
||||
|
||||
vec4 uvColor = vec4(fract(fs_uv * segmentsPerPatch), 0.4,1);
|
||||
frag.color = frag.color.a < 0.1 ? uvColor * 0.5 : frag.color;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user