mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-21 18:38:20 -05:00
Enable blending between ties of different levels to avoid some of the poping artifacts.
This commit is contained in:
@@ -145,10 +145,18 @@ namespace openspace {
|
||||
programObject->activate();
|
||||
|
||||
std::vector<ghoul::opengl::TextureUnit> texUnitHeight;
|
||||
std::vector<ghoul::opengl::TextureUnit> texUnitHeightParent1;
|
||||
std::vector<ghoul::opengl::TextureUnit> texUnitHeightParent2;
|
||||
std::vector<ghoul::opengl::TextureUnit> texUnitColor;
|
||||
std::vector<ghoul::opengl::TextureUnit> texUnitColorParent1;
|
||||
std::vector<ghoul::opengl::TextureUnit> texUnitColorParent2;
|
||||
|
||||
texUnitHeight.resize(numHeightMapProviders);
|
||||
texUnitHeightParent1.resize(numHeightMapProviders);
|
||||
texUnitHeightParent2.resize(numHeightMapProviders);
|
||||
texUnitColor.resize(numColorTextureProviders);
|
||||
texUnitColorParent1.resize(numColorTextureProviders);
|
||||
texUnitColorParent2.resize(numColorTextureProviders);
|
||||
|
||||
|
||||
// Go through all the height map providers
|
||||
@@ -159,11 +167,12 @@ namespace openspace {
|
||||
auto tileProvider = it->get();
|
||||
// Get the texture that should be used for rendering
|
||||
Tile tile = tileProvider->getHighestResolutionTile(chunk.index());
|
||||
Tile tileParent1 = tileProvider->getHighestResolutionParentTile(chunk.index(), 1);
|
||||
Tile tileParent2 = tileProvider->getHighestResolutionParentTile(chunk.index(), 2);
|
||||
TileDepthTransform depthTransform = tileProvider->depthTransform();
|
||||
|
||||
// The texture needs a unit to sample from
|
||||
texUnitHeight[i].activate();
|
||||
int hej = 0;
|
||||
tile.texture->bind();
|
||||
|
||||
std::string indexedTileKey = "heightTiles[" + std::to_string(i) + "]";
|
||||
@@ -177,6 +186,41 @@ namespace openspace {
|
||||
indexedTileKey + ".uvTransform.uvOffset",
|
||||
tile.uvTransform.uvOffset);
|
||||
|
||||
// Blend tile with two parents
|
||||
// The texture needs a unit to sample from
|
||||
texUnitHeightParent1[i].activate();
|
||||
tileParent1.texture->bind();
|
||||
|
||||
std::string indexedTileKeyParent1 = "heightTilesParent1[" + std::to_string(i) + "]";
|
||||
// Send uniforms for the tile to the shader
|
||||
programObject->setUniform(indexedTileKeyParent1 + ".textureSampler", texUnitHeightParent1[i]);
|
||||
|
||||
programObject->setUniform(
|
||||
indexedTileKeyParent1 + ".uvTransform.uvScale",
|
||||
tileParent1.uvTransform.uvScale);
|
||||
programObject->setUniform(
|
||||
indexedTileKeyParent1 + ".uvTransform.uvOffset",
|
||||
tileParent1.uvTransform.uvOffset);
|
||||
|
||||
|
||||
|
||||
// The texture needs a unit to sample from
|
||||
texUnitHeightParent2[i].activate();
|
||||
tileParent2.texture->bind();
|
||||
|
||||
std::string indexedTileKeyParent2 = "heightTilesParent2[" + std::to_string(i) + "]";
|
||||
// Send uniforms for the tile to the shader
|
||||
programObject->setUniform(indexedTileKeyParent2 + ".textureSampler", texUnitHeightParent2[i]);
|
||||
|
||||
programObject->setUniform(
|
||||
indexedTileKeyParent2 + ".uvTransform.uvScale",
|
||||
tileParent2.uvTransform.uvScale);
|
||||
programObject->setUniform(
|
||||
indexedTileKeyParent2 + ".uvTransform.uvOffset",
|
||||
tileParent2.uvTransform.uvOffset);
|
||||
|
||||
|
||||
|
||||
programObject->setUniform(
|
||||
indexedTileKey + ".depthTransform.depthScale",
|
||||
depthTransform.depthScale);
|
||||
@@ -194,6 +238,8 @@ namespace openspace {
|
||||
auto tileProvider = it->get();
|
||||
// Get the texture that should be used for rendering
|
||||
Tile tile = tileProvider->getHighestResolutionTile(chunk.index());
|
||||
Tile tileParent1 = tileProvider->getHighestResolutionParentTile(chunk.index(), 1);
|
||||
Tile tileParent2 = tileProvider->getHighestResolutionParentTile(chunk.index(), 2);
|
||||
|
||||
// The texture needs a unit to sample from
|
||||
texUnitColor[i].activate();
|
||||
@@ -209,6 +255,38 @@ namespace openspace {
|
||||
programObject->setUniform(
|
||||
indexedTileKey + ".uvTransform.uvOffset",
|
||||
tile.uvTransform.uvOffset);
|
||||
|
||||
// Blend tile with two parents
|
||||
// The texture needs a unit to sample from
|
||||
texUnitColorParent1[i].activate();
|
||||
tileParent1.texture->bind();
|
||||
|
||||
std::string indexedTileKeyParent1 = "colorTilesParent1[" + std::to_string(i) + "]";
|
||||
// Send uniforms for the tile to the shader
|
||||
programObject->setUniform(indexedTileKeyParent1 + ".textureSampler", texUnitColorParent1[i]);
|
||||
|
||||
programObject->setUniform(
|
||||
indexedTileKeyParent1 + ".uvTransform.uvScale",
|
||||
tileParent1.uvTransform.uvScale);
|
||||
programObject->setUniform(
|
||||
indexedTileKeyParent1 + ".uvTransform.uvOffset",
|
||||
tileParent1.uvTransform.uvOffset);
|
||||
|
||||
|
||||
// The texture needs a unit to sample from
|
||||
texUnitColorParent2[i].activate();
|
||||
tileParent2.texture->bind();
|
||||
|
||||
std::string indexedTileKeyParent2 = "colorTilesParent2[" + std::to_string(i) + "]";
|
||||
// Send uniforms for the tile to the shader
|
||||
programObject->setUniform(indexedTileKeyParent2 + ".textureSampler", texUnitColorParent2[i]);
|
||||
|
||||
programObject->setUniform(
|
||||
indexedTileKeyParent2 + ".uvTransform.uvScale",
|
||||
tileParent2.uvTransform.uvScale);
|
||||
programObject->setUniform(
|
||||
indexedTileKeyParent2 + ".uvTransform.uvOffset",
|
||||
tileParent2.uvTransform.uvOffset);
|
||||
|
||||
i++;
|
||||
}
|
||||
@@ -224,6 +302,12 @@ namespace openspace {
|
||||
* viewTransform * modelTransform;
|
||||
const Ellipsoid& ellipsoid = chunk.owner()->ellipsoid();
|
||||
|
||||
vec3 pointClosestToCamera = chunk.owner()->ellipsoid().cartesianSurfacePosition(chunk.surfacePatch().closestPoint(chunk.owner()->ellipsoid().cartesianToGeodetic2(data.camera.positionVec3())));
|
||||
|
||||
|
||||
|
||||
float distanceScaleFactor = chunk.owner()->lodScaleFactor * chunk.owner()->ellipsoid().minimumRadius();
|
||||
|
||||
// Upload the uniform variables
|
||||
programObject->setUniform("modelViewProjectionTransform", modelViewProjectionTransform);
|
||||
programObject->setUniform("minLatLon", vec2(swCorner.toLonLatVec2()));
|
||||
@@ -232,6 +316,11 @@ namespace openspace {
|
||||
programObject->setUniform("xSegments", _grid->xSegments());
|
||||
// The length of the skirts is proportional to its size
|
||||
programObject->setUniform("skirtLength", static_cast<float>(chunk.surfacePatch().halfSize().lat * 1000000));
|
||||
|
||||
programObject->setUniform("cameraPosition", vec3(data.camera.positionVec3()));
|
||||
programObject->setUniform("distanceScaleFactor", distanceScaleFactor);
|
||||
programObject->setUniform("chunkLevel", chunk.index().level);
|
||||
|
||||
|
||||
// OpenGL rendering settings
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
@@ -278,22 +367,31 @@ namespace openspace {
|
||||
// Activate the shader program
|
||||
programObject->activate();
|
||||
|
||||
|
||||
std::vector<ghoul::opengl::TextureUnit> texUnitHeight;
|
||||
std::vector<ghoul::opengl::TextureUnit> texUnitHeightParent1;
|
||||
std::vector<ghoul::opengl::TextureUnit> texUnitHeightParent2;
|
||||
std::vector<ghoul::opengl::TextureUnit> texUnitColor;
|
||||
std::vector<ghoul::opengl::TextureUnit> texUnitColorParent1;
|
||||
std::vector<ghoul::opengl::TextureUnit> texUnitColorParent2;
|
||||
|
||||
texUnitHeight.resize(numHeightMapProviders);
|
||||
texUnitHeightParent1.resize(numHeightMapProviders);
|
||||
texUnitHeightParent2.resize(numHeightMapProviders);
|
||||
texUnitColor.resize(numColorTextureProviders);
|
||||
texUnitColorParent1.resize(numColorTextureProviders);
|
||||
texUnitColorParent2.resize(numColorTextureProviders);
|
||||
|
||||
|
||||
// Go through all the height map providers
|
||||
int i = 0;
|
||||
for (auto it = heightMapProviders.begin(); it != heightMapProviders.end(); it++)
|
||||
{
|
||||
texUnitHeight.push_back(ghoul::opengl::TextureUnit());
|
||||
auto tileProvider = it->get();
|
||||
|
||||
// Get the texture that should be used for rendering
|
||||
Tile tile = tileProvider->getHighestResolutionTile(chunk.index());
|
||||
Tile tileParent1 = tileProvider->getHighestResolutionParentTile(chunk.index(), 1);
|
||||
Tile tileParent2 = tileProvider->getHighestResolutionParentTile(chunk.index(), 2);
|
||||
TileDepthTransform depthTransform = tileProvider->depthTransform();
|
||||
|
||||
// The texture needs a unit to sample from
|
||||
@@ -311,6 +409,40 @@ namespace openspace {
|
||||
indexedTileKey + ".uvTransform.uvOffset",
|
||||
tile.uvTransform.uvOffset);
|
||||
|
||||
// Blend tile with two parents
|
||||
// The texture needs a unit to sample from
|
||||
texUnitHeightParent1[i].activate();
|
||||
tileParent1.texture->bind();
|
||||
|
||||
std::string indexedTileKeyParent1 = "heightTilesParent1[" + std::to_string(i) + "]";
|
||||
// Send uniforms for the tile to the shader
|
||||
programObject->setUniform(indexedTileKeyParent1 + ".textureSampler", texUnitHeightParent1[i]);
|
||||
|
||||
programObject->setUniform(
|
||||
indexedTileKeyParent1 + ".uvTransform.uvScale",
|
||||
tileParent1.uvTransform.uvScale);
|
||||
programObject->setUniform(
|
||||
indexedTileKeyParent1 + ".uvTransform.uvOffset",
|
||||
tileParent1.uvTransform.uvOffset);
|
||||
|
||||
|
||||
// The texture needs a unit to sample from
|
||||
texUnitHeightParent2[i].activate();
|
||||
tileParent2.texture->bind();
|
||||
|
||||
std::string indexedTileKeyParent2 = "heightTilesParent2[" + std::to_string(i) + "]";
|
||||
// Send uniforms for the tile to the shader
|
||||
programObject->setUniform(indexedTileKeyParent2 + ".textureSampler", texUnitHeightParent2[i]);
|
||||
|
||||
programObject->setUniform(
|
||||
indexedTileKeyParent2 + ".uvTransform.uvScale",
|
||||
tileParent2.uvTransform.uvScale);
|
||||
programObject->setUniform(
|
||||
indexedTileKeyParent2 + ".uvTransform.uvOffset",
|
||||
tileParent2.uvTransform.uvOffset);
|
||||
|
||||
|
||||
|
||||
programObject->setUniform(
|
||||
indexedTileKey + ".depthTransform.depthScale",
|
||||
depthTransform.depthScale);
|
||||
@@ -326,9 +458,10 @@ namespace openspace {
|
||||
for (auto it = colorTextureProviders.begin(); it != colorTextureProviders.end(); it++)
|
||||
{
|
||||
auto tileProvider = it->get();
|
||||
|
||||
// Get the texture that should be used for rendering
|
||||
Tile tile = tileProvider->getHighestResolutionTile(chunk.index());
|
||||
Tile tileParent1 = tileProvider->getHighestResolutionParentTile(chunk.index(), 1);
|
||||
Tile tileParent2 = tileProvider->getHighestResolutionParentTile(chunk.index(), 2);
|
||||
|
||||
// The texture needs a unit to sample from
|
||||
texUnitColor[i].activate();
|
||||
@@ -345,6 +478,38 @@ namespace openspace {
|
||||
indexedTileKey + ".uvTransform.uvOffset",
|
||||
tile.uvTransform.uvOffset);
|
||||
|
||||
// Blend tile with two parents
|
||||
// The texture needs a unit to sample from
|
||||
texUnitColorParent1[i].activate();
|
||||
tileParent1.texture->bind();
|
||||
|
||||
std::string indexedTileKeyParent1 = "colorTilesParent1[" + std::to_string(i) + "]";
|
||||
// Send uniforms for the tile to the shader
|
||||
programObject->setUniform(indexedTileKeyParent1 + ".textureSampler", texUnitColorParent1[i]);
|
||||
|
||||
programObject->setUniform(
|
||||
indexedTileKeyParent1 + ".uvTransform.uvScale",
|
||||
tileParent1.uvTransform.uvScale);
|
||||
programObject->setUniform(
|
||||
indexedTileKeyParent1 + ".uvTransform.uvOffset",
|
||||
tileParent1.uvTransform.uvOffset);
|
||||
|
||||
|
||||
// The texture needs a unit to sample from
|
||||
texUnitColorParent2[i].activate();
|
||||
tileParent2.texture->bind();
|
||||
|
||||
std::string indexedTileKeyParent2 = "colorTilesParent2[" + std::to_string(i) + "]";
|
||||
// Send uniforms for the tile to the shader
|
||||
programObject->setUniform(indexedTileKeyParent2 + ".textureSampler", texUnitColorParent2[i]);
|
||||
|
||||
programObject->setUniform(
|
||||
indexedTileKeyParent2 + ".uvTransform.uvScale",
|
||||
tileParent2.uvTransform.uvScale);
|
||||
programObject->setUniform(
|
||||
indexedTileKeyParent2 + ".uvTransform.uvOffset",
|
||||
tileParent2.uvTransform.uvOffset);
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
@@ -397,6 +562,9 @@ namespace openspace {
|
||||
// The length of the skirts is proportional to its size
|
||||
programObject->setUniform("skirtLength", static_cast<float>(chunk.surfacePatch().halfSize().lat * 1000000));
|
||||
|
||||
float distanceScaleFactor = chunk.owner()->lodScaleFactor * chunk.owner()->ellipsoid().minimumRadius();
|
||||
programObject->setUniform("distanceScaleFactor", distanceScaleFactor);
|
||||
programObject->setUniform("chunkLevel", chunk.index().level);
|
||||
|
||||
// OpenGL rendering settings
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
Reference in New Issue
Block a user