Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Rendering to a osg::Texture2D using OpenSceneGraph in order to do some post-processing #1356

Open
DeviantGames opened this issue Feb 5, 2025 · 1 comment

Comments

@DeviantGames
Copy link

I am using QT, C++ and obviously OpenSceneGraph. More specifically, I have a C++ class that derives from QOpenGLWidget. This class contains, among other variables, these two:

osg::ref_ptr<osg::Group> m_root;
osg::ref_ptr<osgViewer::Viewer> m_viewer;

The m_root variable contains all of my geometry and is a child of m_viewer.

m_viewer->setSceneData(m_root);

The viewer is also the camera owner.

m_viewer->setCamera(create_camera(width(), height()));

As far as I know, everything is well setup. The application correctly renders my geometry to the window, which the user can access and look at. Here is how I draw to the window:

void MyClass::paintGL()
{
    m_viewer->frame();
}

I am trying to write the frame data to an osg::Texture2D instead of the screen, apply some post-processing shaders to it, and then draw that to the screen.

I have tried a lot of things so far, and none of them worked. AI does not help and the only information I found on google that talks about frame buffers or post-processing dates from 13 years ago and uses OSG 1.2. Please help.

@xarray
Copy link

xarray commented Feb 5, 2025

Have a look at osgverse (https://github.com/xarray/osgverse). It contains full supports of PBR rendering and deferred / postprocessing passes, as well as Qt widget supports. If you wish to implement your own post effects, have a look at osgdeferred example first, which tells how to create a sub camera for RTT use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants