Skip to content

Commit

Permalink
disable GPU culling on the NVGL path for FMG and XMG, for better perf…
Browse files Browse the repository at this point in the history
…ormance and no artifacts
  • Loading branch information
gwaldron committed Nov 20, 2023
1 parent 9c73978 commit 3edcb21
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/osgEarth/Chonk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/osgEarth/Chonk.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions src/osgEarth/FeatureModelGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1758,8 +1758,13 @@ FeatureModelGraph::createOrUpdateNode(FeatureCursor* cursor,
_texturesCache, _texturesCacheMutex));

osg::ref_ptr<ChonkDrawable> 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);
Expand Down
4 changes: 4 additions & 0 deletions src/osgEarth/XYZModelGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ XYZModelGraph::createNode(const TileKey& key, ProgressCallback* progress)
_texturesCache, _texturesCacheMutex));

osg::ref_ptr<ChonkDrawable> drawable = new ChonkDrawable();

// culling by osg tile will be sufficient here.
drawable->setUseGPUCulling(false);

if (xform)
{
for (unsigned i = 0; i < xform->getNumChildren(); ++i)
Expand Down
9 changes: 9 additions & 0 deletions tests/viewpoints.xml
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,13 @@
<height>-12.0398843260482</height>
<srs>+proj=longlat +datum=WGS84 +no_defs</srs>
</viewpoint>
<viewpoint name="Toronto">
<heading>0.109355</heading>
<pitch>-20.3288</pitch>
<range>4697.58m</range>
<long>-79.3900928274749</long>
<lat>43.65526709145713</lat>
<height>72.19622826110572</height>
<srs>+proj=longlat +datum=WGS84 +no_defs</srs>
</viewpoint>
</viewpoints>

0 comments on commit 3edcb21

Please sign in to comment.