Camera render order and Threading models

20 views
Skip to first unread message

Riccardo Corsi

unread,
Jan 7, 2021, 8:15:18 AM1/7/21
to osg-...@googlegroups.com
Hi all,

I'm facing an issue when using multiple cameras and different threading models.
In my scene I have a slave camera which renders to a texture (using FBO + texture attachment) in PRE_RENDER order; the texture is then attached to a geometry which in turns is rendered by the main viewer camera. 
I have verified that both cameras' view matrices are updated consistently during the same frame update traversal (as they are linked one another).

When I run this setup with SingleThreaded model, everything works as expected. 

If I run it with DrawThreadPerContext (default on Windows), there is a one-frame delay of the RTT camera result, meaning that during frame N the main camera sees the render result of frame N-1 in the FBO camera texture attachment.

I don't think this is an expected behavior.
Is there a way to fix the issue without switching to SingleThreaded mode?

Thank you,
Riccardo

Robert Osfield

unread,
Jan 7, 2021, 12:45:13 PM1/7/21
to OpenSceneGraph Users, OpenSceneGraph Users
Hi Ricard,

Both the RTT Camera and the main Camera should both be traversed in the cull traversal within the same frame and accumulated modelview matrices cached in the rendering backend to sent to the GPU as part of the draw traversal together.  Ordinarily this system should prevent problems like your describe as the rendering backend is double buffered so that the cull writes to the currently recording frames rendering backend, while the draw traverses the previous rendering backend structures.

The behaviour you describe makes it seem like some state is being modified across the frames, I don't have your app or data so can't say what this might be.  The best I can suggest is to investigate what state seems to be changed inappropriately.  It might be that you need to double buffer the state that is being updated whilst it's being used for rendering.

Robert

Riccardo Corsi

unread,
Jan 12, 2021, 3:35:55 AM1/12/21
to osg-...@googlegroups.com, OpenSceneGraph Users
Hi Robert,

I've tried to reproduce the issue with a minimal example, without success so far, even though the essential bits should be the same.
I'm also thinking it might have something to do with the data variance of the affected geometries, I'll double check.
If I find something I'll report back here,
Thanks,
Riccardo



Riccardo Corsi  co-founder, software engineering
Kairos3D srl  Via Agostino da Montefeltro 2, 10134 Torino Italy

This e-mail is confidential and intended only for the use of the above named addressee. If you have received this e-mail in error, please delete it immediately and notify us by e-mail or telephone.


--
You received this message because you are subscribed to the Google Groups "OpenSceneGraph Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to osg-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/osg-users/CAFN7Y%2BWM4Cn4KooZoHxnv2nncmpHtrftT1aNEjGNnwows06OGA%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages