Different appearance of scene per camera/window Topic is solved

Problems building or running the engine, queries about how to use features etc.
User avatar
bishopnator
Goblin
Posts: 299
Joined: Thu Apr 26, 2007 11:43 am
Location: Slovakia / Switzerland
x 11

Different appearance of scene per camera/window

Post by bishopnator »

Ogre Version: 2.3.3
Operating System: Windows11
Render System: D3D11

Hi everyone,
how is it possible to achieve rendering of the same scene differently in different windows within the same application with Ogre 2.x? Let's consider following output:

Image

There are 6 windows displaying identical scene - actually there are only triangular meshes (no duplicates with the lines geometry - conversion is done in geometry shaders).

First row:

  • hidden lines render mode - hidden lines rendered with constant color, pattern is set to "dotted" (or short lines)

  • hidden lines render mode - hidden lines rendered with object's color, pattern is set to "dashed"

  • hidden lines render mode - hidden lines are not rendered

Second row:

  • shaded - faces use color from the edges

  • shaded - faces use transparency, edges are not visible

  • shaded - faces use transparency, edges are visible and use different color

In Ogre 1.x I can imagine that it is possible through the materials with multiple techniques and Ogre::Renderable::getTechnique is virtual so it is them possible to write own class inherited from Ogre::Renderable which supports returning different techniques from the materials based on camera/window settings.

In Ogre 2.x however there is no virtual entry point - or at least I didn't find it. The only way which I think should work, is to overwrite the data blocks of collected renderables in Ogre::RenderQueue just before rendering the collected objects - e.g. in SceneManager::_renderPhase02 where there is also access to the camera. Unfortunately there is no listener where it can be done. Is there any more suitable way how to achieve such rendering without duplicating whole scene graph?

paroj
OGRE Team Member
OGRE Team Member
Posts: 2106
Joined: Sun Mar 30, 2014 2:51 pm
x 1132

Re: Different appearance of scene per camera/window

Post by paroj »

bishopnator wrote: Wed May 22, 2024 10:27 am

In Ogre 1.x I can imagine that it is possible through the materials with multiple techniques and Ogre::Renderable::getTechnique is virtual so it is them possible to write own class inherited from Ogre::Renderable which supports returning different techniques from the materials based on camera/window settings.

actually, this is already built in via schemes:
https://ogrecave.github.io/ogre/api/lat ... otoc_md121

you can set a scheme per viewport and then the matching technique will get picked. You can also register a listener to generate the techniques on the fly. Actually, this is how the RTSS is integrated.
Maybe this still works with 2.x.

User avatar
bishopnator
Goblin
Posts: 299
Joined: Thu Apr 26, 2007 11:43 am
Location: Slovakia / Switzerland
x 11

Re: Different appearance of scene per camera/window

Post by bishopnator »

Yes, I forgot - it is done through schemes in Ogre 1.x - in Ogre 2.x maybe it will work with classes in Ogre::v1 namespace - but is there a way how to bring it to life with HLMS/compositors/Ogre::Item instead of using Ogre::Material/Ogre::v1::Entity?

Is there still advantage of using Ogre 2.x with Ogre::v1::Entity/old-fashioned materials compared to using Ogre 1.x directly?

It is recommended for the new apps to use Ogre 2.x, that's the reason I want to give it a try instead of sticking to Ogre 1.x

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5433
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1341

Re: Different appearance of scene per camera/window

Post by dark_sylinc »

Hi!

In gz-rendering (aka rendering's component of Gazebo, which uses OgreNext) I had to face the same problem and after careful study I had to conclude:

  1. One way is what Gazebo originally did, which is to iterate all objects and switch materials. This is heavily inefficient because OgreNext assumes materials don't change often after assignment.
  2. The solution I implemented is to use an HlmsListener (or customize HlmsPbs) using custom pieces.

Basically in HlmsListener::preparePassHash you set a property to indicate which special mode you want e.g.

Code: Select all

void MyHlmsListener::preparePassHash(const CompositorShadowNode *_shadowNode,
                                       bool _casterPass, bool _dualParaboloid,
                                       SceneManager *_sceneManager, Hlms *_hlms) override
{
     if( special_mode ) // This is set by you before the workspace starts rendering your pass
     {
           _hlms->_setProperty("special_mode", 1);
     }
} 

Then a custom shader piece performs the modifications you want.

I haven't merged these samples into master yet, but you can take a look at branch ParticleFX2 Tutorial_Hlms01_Customization (and all the other Tutorial_Hlms\*\* tutorials) which show how to customize an Hlms implementation.

User avatar
bishopnator
Goblin
Posts: 299
Joined: Thu Apr 26, 2007 11:43 am
Location: Slovakia / Switzerland
x 11

Re: Different appearance of scene per camera/window

Post by bishopnator »

Thanks, this looks exactly like I need.