Occlusion queries. How are they intended to work?

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Occlusion queries. How are they intended to work?

Post by Mel »

I've seen the example, and i really don't get much logic out of their implementation, or perhaps i don't understand really how the occlusion queries work. Say that for instance, i want to create a series of occlusion queries on a hierarchic structure, so nodes/meshes inside a certain, random, bounding box of this structure are culled if the box is culled.

Taking a peek, the occlusion queries work in irrlicht as a static list of nodes, with a mesh attached, which you can use to query their occlusion, running and updating their occlusion states. So far, so good, but sounds restrictive. What if i want to perform the occlusion query of a random mesh without a node tied to it, perhaps, but not only, a screen aligned rectangle. What if i want to update this list of queries dynamically? Is there a way to obtain a similar functionality in Irrlicht? or am i missing how the occlusion queries work?
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Occlusion queries. How are they intended to work?

Post by Vectrotek »

There is this example on Lens-Flare which works quite well, but as soon as I render
to a render target so that it can be Post Processed, the occlusion of the lens flare
stops working for the Quake2 level object. It still seems to work when the Light
causing the Lens Flare leaves the frustum or the screen.
Any opinion?

Some code:

Code: Select all

 
     if (EffectsStatus)
      {// Here I change the render target to a texture in the Post Processor Class..
       TheDriver->setRenderTarget(ScreenQuadPostProcessor.GetAlterTextFirst (), true, true, video::SColor( 255 , 207 , 223 , 169 ));
       lensFlareNode->SetNormalOrTargetMode(true); // PP..
      } 
     else 
      {lensFlareNode->SetNormalOrTargetMode(false); // No PP..
     }
    TheSceneManager->drawAll();
    if (EffectsStatus)
     {ScreenQuadPostProcessor.RenderPassesThenToScreen(); // Render all Post Processing Passes, then finally to screen..
     }
 
    // Run occlusion query..
    // DOES THIS USE THE DEPTH BUFFER IN ANY WAY?
    // IF SO, DOES MY P-P RENDERING TO RENDERTARGET DESTROY ANY UNSEEN INFORMATION?
    // WHAT HAPPENS IN THE PP RENDERING THAT DISABLES A PART OF OCCULDING?
    TheDriver->runAllOcclusionQueries(false); 
    TheDriver->updateAllOcclusionQueries(false);
    u32 occlusionQueryResult = TheDriver->getOcclusionQueryResult(sunMeshNode);
    // update strength of the lensflare
    // IF PP IS RENDERED THEN ONLY OFF-SCREEN SEEMS TO WORK, BUT FLARE NOT OCCLUDED BY OBJECTS LIKE A Q2 MAP..
    if(occlusionQueryResult!= 0xffffffff) lensFlareNode->setStrength(f32(occlusionQueryResult)/8000.f);
    // finish scene rendering as usual
    TheDriver->endScene();
 
devsh
Competition winner
Posts: 2057
Joined: Tue Dec 09, 2008 6:00 pm
Location: UK
Contact:

Re: Occlusion queries. How are they intended to work?

Post by devsh »

Occlusion queries in Irrlicht 1.8.x are really badly implemented, everytime you retrieve a result it searches in a list for a query attached to a node... we had 1000 nodes and it took 25% of the frametime just for that XD
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Occlusion queries. How are they intended to work?

Post by Vectrotek »

Thanks! That's good to know, and I'll try a different approach like having an unseen-
low poly count version of the occluder, or fire rays etc, but why don't
the occlusion mechanisms kick in when you render the scene to a given target texture?
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Occlusion queries. How are they intended to work?

Post by Vectrotek »

In image 1, I render to a 320 x 240 texture.
(very small just to check out the FXAA)
The Lens Flare is occluded when it exits the View Frustum, but
NO occlusion occurs when it is behind the Level.

Image

In image 2, which is a normal render everything works.
Why does the Frustum Occlusion occur but not the Geometry Occlusion?

Image

How does BAW handle it? Through the G buffers?
Just asking..
Post Reply