diff --git a/modules/globebrowsing/CMakeLists.txt b/modules/globebrowsing/CMakeLists.txt index 1a78c34378..3e90d40d90 100644 --- a/modules/globebrowsing/CMakeLists.txt +++ b/modules/globebrowsing/CMakeLists.txt @@ -38,6 +38,7 @@ set(HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/meshes/trianglesoup.h ${CMAKE_CURRENT_SOURCE_DIR}/meshes/grid.h ${CMAKE_CURRENT_SOURCE_DIR}/meshes/basicgrid.h + ${CMAKE_CURRENT_SOURCE_DIR}/meshes/skirtedgrid.h ${CMAKE_CURRENT_SOURCE_DIR}/meshes/clipmapgrid.h ${CMAKE_CURRENT_SOURCE_DIR}/geodetics/geodetic2.h @@ -75,6 +76,7 @@ set(SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/meshes/trianglesoup.cpp ${CMAKE_CURRENT_SOURCE_DIR}/meshes/grid.cpp ${CMAKE_CURRENT_SOURCE_DIR}/meshes/basicgrid.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/meshes/skirtedgrid.cpp ${CMAKE_CURRENT_SOURCE_DIR}/meshes/clipmapgrid.cpp ${CMAKE_CURRENT_SOURCE_DIR}/geodetics/geodetic2.cpp diff --git a/modules/globebrowsing/globes/chunkedlodglobe.cpp b/modules/globebrowsing/globes/chunkedlodglobe.cpp index 0cbc980667..1c425b685f 100644 --- a/modules/globebrowsing/globes/chunkedlodglobe.cpp +++ b/modules/globebrowsing/globes/chunkedlodglobe.cpp @@ -24,7 +24,7 @@ #include -#include +#include // open space includes #include @@ -63,7 +63,7 @@ namespace openspace { , _savedCamera(nullptr) { - auto geometry = std::shared_ptr(new BasicGrid( + auto geometry = std::shared_ptr(new SkirtedGrid( segmentsPerPatch, segmentsPerPatch, TriangleSoup::Positions::No, diff --git a/modules/globebrowsing/rendering/patchrenderer.cpp b/modules/globebrowsing/rendering/patchrenderer.cpp index e73116991f..f50d03991a 100644 --- a/modules/globebrowsing/rendering/patchrenderer.cpp +++ b/modules/globebrowsing/rendering/patchrenderer.cpp @@ -247,6 +247,7 @@ namespace openspace { programObject->setUniform("minLatLon", vec2(swCorner.toLonLatVec2())); programObject->setUniform("lonLatScalingFactor", vec2(patchSize.toLonLatVec2())); programObject->setUniform("radiiSquared", vec3(ellipsoid.radiiSquared())); + programObject->setUniform("xSegments", _grid->xSegments()); // OpenGL rendering settings glEnable(GL_DEPTH_TEST); @@ -481,6 +482,8 @@ namespace openspace { "projectionTransform", data.camera.projectionMatrix()); + programObject->setUniform("xSegments", _grid->xSegments()); + // OpenGL rendering settings glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); diff --git a/modules/globebrowsing/shaders/globalchunkedlodpatch_vs.glsl b/modules/globebrowsing/shaders/globalchunkedlodpatch_vs.glsl index 990e36e388..da7f692152 100644 --- a/modules/globebrowsing/shaders/globalchunkedlodpatch_vs.glsl +++ b/modules/globebrowsing/shaders/globalchunkedlodpatch_vs.glsl @@ -37,6 +37,9 @@ uniform vec3 radiiSquared; uniform vec2 minLatLon; uniform vec2 lonLatScalingFactor; +uniform int xSegments; +uniform int ySegments; + uniform TextureTile heightTiles[NUMLAYERS_HEIGHTMAP]; layout(location = 1) in vec2 in_uv; @@ -70,6 +73,16 @@ void main() height = (sampledValue * heightTiles[#{i}].depthTransform.depthScale + heightTiles[#{i}].depthTransform.depthOffset); + + // Skirts + int vertexIDx = gl_VertexID % (xSegments + 3); + int vertexIDy = gl_VertexID / (xSegments + 3); + if (vertexIDx == 0 || + vertexIDy == 0 || + vertexIDx == (xSegments + 2) || + vertexIDy == (xSegments + 2) ) { + height = 0; + } } #endfor diff --git a/modules/globebrowsing/shaders/localchunkedlodpatch_vs.glsl b/modules/globebrowsing/shaders/localchunkedlodpatch_vs.glsl index 1eb32ce24b..51128d0a7e 100644 --- a/modules/globebrowsing/shaders/localchunkedlodpatch_vs.glsl +++ b/modules/globebrowsing/shaders/localchunkedlodpatch_vs.glsl @@ -42,6 +42,9 @@ uniform vec3 patchNormalCameraSpace; uniform TextureTile heightTiles[NUMLAYERS_HEIGHTMAP]; +uniform int xSegments; +uniform int ySegments; + layout(location = 1) in vec2 in_uv; out vec2 fs_uv; @@ -74,6 +77,16 @@ void main() height = (sampledValue * heightTiles[#{i}].depthTransform.depthScale + heightTiles[#{i}].depthTransform.depthOffset); + + // Skirts + int vertexIDx = gl_VertexID % (xSegments + 3); + int vertexIDy = gl_VertexID / (xSegments + 3); + if (vertexIDx == 0 || + vertexIDy == 0 || + vertexIDx == (xSegments + 2) || + vertexIDy == (xSegments + 2) ) { + height = 0; + } } #endfor