From 3edcb212fe311f9eb61a188b94219e1dc158fb7e Mon Sep 17 00:00:00 2001 From: Glenn Waldron Date: Mon, 20 Nov 2023 14:17:59 -0500 Subject: [PATCH] disable GPU culling on the NVGL path for FMG and XMG, for better performance and no artifacts --- src/osgEarth/Chonk.cpp | 2 ++ src/osgEarth/Chonk.glsl | 6 +++--- src/osgEarth/FeatureModelGraph.cpp | 5 +++++ src/osgEarth/XYZModelGraph.cpp | 4 ++++ tests/viewpoints.xml | 9 +++++++++ 5 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/osgEarth/Chonk.cpp b/src/osgEarth/Chonk.cpp index 6353531cee..3eac9b318f 100644 --- a/src/osgEarth/Chonk.cpp +++ b/src/osgEarth/Chonk.cpp @@ -1275,6 +1275,8 @@ ChonkDrawable::GLObjects::draw(osg::State& state) else _instanceInputBuf->bindBufferBase(0); + _ext->glMemoryBarrier(GL_SHADER_STORAGE_BARRIER_BIT); // ...maybe + GLenum elementType = sizeof(Chonk::element_t) == sizeof(GLushort) ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT; diff --git a/src/osgEarth/Chonk.glsl b/src/osgEarth/Chonk.glsl index 9640d6ac85..215de67867 100644 --- a/src/osgEarth/Chonk.glsl +++ b/src/osgEarth/Chonk.glsl @@ -195,9 +195,9 @@ void oe_chonk_default_fragment(inout vec4 color) // apply the high fade from the instancer if (oe_fade <= 1.0) color.a *= oe_fade; - else if (oe_fade <= 2.0) color.rgb = vec3(1, 0, 0); - else if (oe_fade <= 3.0) color.rgb = vec3(1, 1, 0); - else if (oe_fade <= 4.0) color.rgb = vec3(0, 1, 0); + else if (oe_fade <= 2.0) color.rgb = vec3(1, 0, 0); // REASON_FRUSTUM + else if (oe_fade <= 3.0) color.rgb = vec3(1, 1, 0); // REASON_SSE + else if (oe_fade <= 4.0) color.rgb = vec3(0, 1, 0); // REASON_NEARCLIP else color.rgb = vec3(1, 0, 1); // should never happen :) #elif defined(OE_USE_ALPHA_TO_COVERAGE) diff --git a/src/osgEarth/FeatureModelGraph.cpp b/src/osgEarth/FeatureModelGraph.cpp index a110f11275..e64519baab 100644 --- a/src/osgEarth/FeatureModelGraph.cpp +++ b/src/osgEarth/FeatureModelGraph.cpp @@ -1758,8 +1758,13 @@ FeatureModelGraph::createOrUpdateNode(FeatureCursor* cursor, _texturesCache, _texturesCacheMutex)); osg::ref_ptr drawable = new ChonkDrawable(); + + // culling by osg tile will be sufficient here. + drawable->setUseGPUCulling(false); + if (xform) { + for (unsigned i = 0; i < xform->getNumChildren(); ++i) { drawable->add(xform->getChild(i), factory); diff --git a/src/osgEarth/XYZModelGraph.cpp b/src/osgEarth/XYZModelGraph.cpp index 382e6b9471..d8dbc37a28 100644 --- a/src/osgEarth/XYZModelGraph.cpp +++ b/src/osgEarth/XYZModelGraph.cpp @@ -148,6 +148,10 @@ XYZModelGraph::createNode(const TileKey& key, ProgressCallback* progress) _texturesCache, _texturesCacheMutex)); osg::ref_ptr drawable = new ChonkDrawable(); + + // culling by osg tile will be sufficient here. + drawable->setUseGPUCulling(false); + if (xform) { for (unsigned i = 0; i < xform->getNumChildren(); ++i) diff --git a/tests/viewpoints.xml b/tests/viewpoints.xml index 964e30d260..10ae96eb4d 100644 --- a/tests/viewpoints.xml +++ b/tests/viewpoints.xml @@ -129,4 +129,13 @@ -12.0398843260482 +proj=longlat +datum=WGS84 +no_defs + + 0.109355 + -20.3288 + 4697.58m + -79.3900928274749 + 43.65526709145713 + 72.19622826110572 + +proj=longlat +datum=WGS84 +no_defs +