Dynamic visibility

Discussion area about developing with Ogre-Next (2.1, 2.2 and beyond)


User avatar
bishopnator
Gnome
Posts: 334
Joined: Thu Apr 26, 2007 11:43 am
Location: Slovakia / Switzerland
x 16

Dynamic visibility

Post by bishopnator »

Hi, I am trying to setup a scene which is rendered in different cameras differently. Similar question I asked already here viewtopic.php?t=97330 and a visibility mask was suggested. However I think for my current problem, I need different approach. I have a scene where I can setup in my HLMS through properties whether line styles (line pattern along the connected lines) are rendered in world units or screen units. For the screen interpolation I have a custom scene pass, where I render all the lines and store the pixel distances in UAV buffer. Then in the main scene pass I accumulate the stored distances from the beginning of the connected lines. However for the world line styles interpolation, I don't need to render the objects in the 1st scene pass.

If I split the interpolation of the line styles strictly - one camera render all objects with world interpolation and another camera with screen interpolation, then I can simply create 2 compositors - one with a single scene pass (world interpolation) and another compositor with 2 scene passes (computation of screen distances + rendering in the second pass). However I would like to have also a mixture in the single camera. Consider following (crazy?) scenario:

Window A with camera A renders object X with world interpolation and Y with screen interpolation
Window B with camera B renders object X with screen interpolation and Y with world interpolation

On the Item I set list of properties which the item supports - e.g. rendering with line styles, screen and world interpolation. In the camera/viewport I set "render mode" - the instructions how the objects should be rendered. In my HLMS's calculateHashForPreCreate I access all the information and set the corresponding properties to select requested rendering. However at this point I know that certain object shouldn't be rendered according to the properties, but it is too late.

In CAD-like applications, a user can create many windows with many rendering settings and the visibility mask is just not enough. In our current library, there is support for "custom" visibility callback through which it is possible to hide/show the currently visited object in the currently rendered camera. In Ogre I don't see any similar listener or support.

jwwalker
Goblin
Posts: 269
Joined: Thu Aug 12, 2021 10:06 pm
Location: San Diego, CA, USA
x 19

Re: Dynamic visibility

Post by jwwalker »

You could let each window have its own instance of SceneManager, with its own tree of nodes and items. I'm not saying that's the best approach for your purposes, but it would give you complete control over what renders in each window.

User avatar
bishopnator
Gnome
Posts: 334
Joined: Thu Apr 26, 2007 11:43 am
Location: Slovakia / Switzerland
x 16

Re: Dynamic visibility

Post by bishopnator »

This really far from ideal :-( The scene is complex and I would need to replicate it many many times. If anything changes in the scene, I would need to update multiple scene managers. I am at the moment considering using a USER_UNIFORM_SCALABLE_TASK in the scene manager which I could fire somewhere during rendering a frame (e.g. using RenderQueueListener::renderQueueStarted - but in SceneManager::_cullPhase01 it is written that the listener is hacky and should be removed; another option is the usage of CompositorWorkspaceListener::passPreExecute...).

Anyway, I need somehow to iterate the whole scene before the rendering and set visibility of the movable objects. As the iteration is already done in SceneManager::cullFrustum, I would like to reuse it and update the visibility of the collected objects, but there is no customization point (I would like to avoid modification of the Ogre).