OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

How to use osgPPU in an environment withz several slave cameras?


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> osgPPU [osgPPU]
View previous topic :: View next topic  
Author Message
wernerM
User


Joined: 06 Feb 2013
Posts: 60

PostPosted: Wed Feb 06, 2013 2:32 pm    Post subject:
How to use osgPPU in an environment withz several slave cameras?
Reply with quote

Hi,

in my application I use a camera to create a static background image in a PRERENDER stage.
Also afte the scene rendering I use another camera to display something on top of the scene in a POSTRENDER stage (HUD with text).
both cameras are slaves of the main camera.

I need seting up a PPU chain which has the complete output of all cameras as input.
So far I can only see the rendered scene without background and text on top.

Can anybody give me a hint how to arrange this? I couldn't find anything in the lists or via Gooogle.
Thanks for any help.

Thank you!

Cheers,
Werner
Back to top
View user's profile Send private message
wernerM
User


Joined: 06 Feb 2013
Posts: 60

PostPosted: Tue Mar 19, 2013 5:08 pm    Post subject:
Reply with quote

Oh, I'm waiting so unpatiently for someone to reply here.
I need this working very urgently.

Thank you!

Cheers,
Werner
Back to top
View user's profile Send private message
danoo
Appreciator


Joined: 16 Dec 2011
Posts: 146

PostPosted: Wed Mar 27, 2013 6:14 am    Post subject:
Reply with quote

Hi wernerM

Could you please provide some example code of how you are doing things? I have a prerender camera rendering part of the scene which is applied in a ppu unit over the main scene.

Are both background and hud text missing?

For hud text please have a look all the statistic and help handler, they show very vell how do to huds...


Thank you!

Cheers,
Daniel
Back to top
View user's profile Send private message
wernerM
User


Joined: 06 Feb 2013
Posts: 60

PostPosted: Wed Mar 27, 2013 8:03 am    Post subject:
Reply with quote

Hi Daniel,

the text HUD shows up correctly.
Only the wallpaper is missing. I create it by a separate camera in PRE-RENDERmode. Here ist the code snippplet:

===============================================

/** This method creates a HUD-Window for a wallpaper */
void Cl_3Dview_osg::createWallpaper(const QString &_path) {
osgViewer::Viewer::Windows windows;
view->getWindows(windows);
if (windows.empty()) return;

// ===========================================
// Create camera
// ===========================================
// create a camera to set up the projection and model view matrices,
// and the subgraph to drawn in the HUD
osg::Camera* camera = new osg::Camera;

// set the projection matrix
camera->setProjectionMatrix(osg::Matrix::ortho2D(0,1,0,1));
camera->setProjectionResizePolicy(osg::Camera::FIXED);

// set the view matrix
camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
camera->setViewMatrix(osg::Matrix::identity());

// only clear the depth buffer
camera->setClearMask(GL_COLOR_BUFFER_BIT |
GL_DEPTH_BUFFER_BIT);

// draw subgraph before main camera view.
camera->setRenderOrder(osg::Camera::PRE_RENDER);

// we don't want the camera to grab event focus from
// the viewers main camera(s).
camera->setAllowEventFocus(false);

// set up cameras to rendering on the first window available.
camera->setGraphicsContext(windows[0]);
camera->setViewport(0,0,windows[0]->getTraits()->width,
windows[0]->getTraits()->height);

view->addSlave(camera, false);

wallpaperCamera = camera;
if (!_path.isEmpty())
setWallpaper(_path);
// The main camera should not wipe out the wallpaper
view->getCamera()->setClearMask(GL_DEPTH_BUFFER_BIT);
}
===============================================

Is there any better method to do this job, maybe by a separate node in a low numbered render bin? But what about the transformations then and the resize handling of the viewport?


Thank you!

Cheers,
Werner
Back to top
View user's profile Send private message
wernerM
User


Joined: 06 Feb 2013
Posts: 60

PostPosted: Sun Mar 31, 2013 11:19 am    Post subject:
Reply with quote

Here is how I prepare the camera(s) for PPU:

/** Setup the camera to do the render to texture */
void Cl_3Dview_osg::setupCameraForPipeline() {
// setup viewer's default camera
osg::Camera* camera = view->getCamera();
osg::Viewport* vp = camera->getViewport();

// create texture to render to
osg::Texture* texture = createRenderTexture(
(int)vp->width(), (int)vp->height(), false);
osg::Texture* depthTexture = createRenderTexture(
(int)vp->width(), (int)vp->height(), true);

// tell the camera to use OpenGL frame buffer object where supported.
camera->setRenderTargetImplementation(
osg::Camera::FRAME_BUFFER_OBJECT);
// attach the texture and use it as the color buffer.
camera->attach(osg::Camera::COLOR_BUFFER, texture);
camera->attach(osg::Camera::DEPTH_BUFFER, depthTexture);
// if (wallpaperCamera.valid()) {
// wallpaperCamera->setRenderTargetImplementation(
// osg::Camera::FRAME_BUFFER_OBJECT);
// wallpaperCamera->attach(
// osg::Camera::COLOR_BUFFER, texture);
// }
}

Commenting in our out of the last part does not do any difference. But why?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> osgPPU [osgPPU] All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts How do cameras handle the render target? wernerM General 3 Wed Mar 15, 2017 9:59 am View latest post
No new posts Multiple cameras sharing multisample fbo ravidavi General 1 Sat Mar 11, 2017 8:17 am View latest post
No new posts About separate rendering of a slave c... wernerM General 0 Tue Mar 07, 2017 3:14 pm View latest post
No new posts How to handle cameras in the scene gr... wernerM General 7 Fri Feb 24, 2017 4:47 pm View latest post
No new posts Rendering in-scene camera from differ... Riccardo Corsi General 3 Thu Aug 04, 2016 11:11 am View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP