osgearth icon indicating copy to clipboard operation
osgearth copied to clipboard

cull callback for featureNode doesn't work.

Open keince opened this issue 2 years ago • 8 comments

Adding a cull callback via the call addCullCallback() to a FeatureNode doesn't appear to work with view frustum culling. When I pan away from the FeatureNode on the map so that the FeatureNode is outside of the field of view, the cull callback continues to execute which it shouldn't.

I added the call setCullingActive(true) to the FeatureNode which has no effect.

I also noticed that a similar issue #989 addressed something similar in where it was stated that it was fixed. My FeatureNode is also using GPU clamping.

Is there something more that needs to be done so that the cull callback works?

I'm using osgEarth 3.1 on Windows 10 x64.

-Shayne

keince avatar May 25 '22 04:05 keince

So...it appears that if I comment out the line

feature->style()->getOrCreate<AltitudeSymbol>()->TECHNIQUE_GPU;

The cull callback starts to work as expected.

keince avatar May 25 '22 14:05 keince

Strange. Is that line in your code?

gwaldron avatar Jun 02 '22 13:06 gwaldron

Well...it was, until I commented it out to get my cull callback to work.

keince avatar Jun 06 '22 14:06 keince

I only asked because the line itself doesn't appear to do anything; it's just referencing an enum.

gwaldron avatar Jun 06 '22 14:06 gwaldron

Once I get my computer back online, I will double check. I may have copied it wrong since the code is on another computer that has no access to the internet.

On 06/06/2022 8:11 AM Glenn ***@***.***> wrote:




I only asked because the line itself doesn't appear to do anything; it's just referencing an enum.

—
Reply to this email directly, view it on GitHub https://github.com/gwaldron/osgearth/issues/2074#issuecomment-1147491110 , or unsubscribe https://github.com/notifications/unsubscribe-auth/ATC464MJSBJCZMBBJVYA45LVNYBHNANCNFSM5W3X2XTQ .
You are receiving this because you authored the thread.Message ID: ***@***.***>

keince avatar Jun 06 '22 14:06 keince

Here's the actual code...

AltitudeSymbol* alt = _feature->style()->getOrCreate<AltltudeSymbol>(); alt->clamping() = alt->CLAMP_TO_TERRAIN; alt->technique() = alt->TECHNIQUE_GPU;

If I comment out the 3rd line alt->technique() = alt->TECHNIQUE_GPU;, the cull callback set on the featureNode begins to work as expected. If I leave the line uncommented, the cull callback always gets executed even though the featureNode is completely culled away by the view frustum.

keince avatar Jun 06 '22 15:06 keince

OK, I see what you are saying now. The thing about GPU clamping is that a shader will move the geometry to a new location at render time. OSG has no way of knowing where the final location will be, so we have to disable the standard OSG bounding-sphere-based culling. This happens in ClampableNode. This means that OSG will always invoke your cull callback since it has to assume the node is potentially visible.

gwaldron avatar Jun 06 '22 16:06 gwaldron

That makes sense. I'll just leave GPU clamping disabled for now...

Thanks for the detailed feedback.

keince avatar Jun 06 '22 16:06 keince