Capture off-screen / Aux buffer in PostDrawCallback?

Hi all,

I have a multiple render target setup where a texture is attached to an FBO on GL_COLOR_ATTACHMENT2. The
other target is simply the frame buffer on GL_COLOR_ATTACHMENT0. Both targets are the same size and
format. 

A fragment shader uses glFragData[0] and glFragData[2] to write to the targets and I'm getting the
expected onscreen data from glFragData[0]. The problem comes in when I try to use a PostDrawCallback to
read from GL_COLOR_ATTACHMENT2 so I can move it to an image and manipulate the data on the CPU. 

In the code below, if I have glReadBuffer(GL_COLOR_ATTACHMENT2) then I get an "Warning: detected OpenGL
error 'invalid enumerant' at end of SceneView::draw()".  glReadBuffer(GL_BACK) works fine but that's
not the data I want. 

Is this because the FBO is already detached when the callback is invoked? Is there another place I can 'hook
in' to do this? I've tried simply attaching an osg::image as the secondary render target but I don't need to
do this on every frame and it's too big of a performance hit.

Callback code:

Code:

virtual void operator()(osg::RenderInfo& renderInfo) const {
osg::GraphicsContext* gc = renderInfo.getCurrentCamera()->getGraphicsContext();
osg::GLBufferObject::Extensions* ext = osg::GLBufferObject::getExtensions(
     gc->getState()->getContextID(),true);
int width = gc->getTraits()->width;
int height = gc->getTraits()->height;

if( m_starMapImage->s() != width || m_starMapImage->t() != height ) {
(Continue reading)

Utkarsh Patankar | 21 May 20:56
Picon
Favicon

Setting camera position

Hi,

I am using a Trackball Manipulator in my application. I want the camera to have a fixed look-at direction
along the negative z-axis, and a fixed up direction along the positive y-axis. But I want the camera to
change its position according to an array.

Eg:- Consider the array of positions to be as follows:
0,0,0
10,10,10
20,10,10

So, I want the camera to be positioned at (0,0,0), then at (10,10,10), and finally at (20,10,10).

How can this be done?

Thank you!

Cheers,
Utkarsh

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=47792#47792

Fred Smith | 21 May 18:17
Picon
Favicon

Multiple MatrixTransforms, single geometry

Hi,

I have some geometry that is making use of a VBO. The VBO contains an extremely large number of vertices.
Similarly, I have an element buffer (EBO) that contains a large amount of indices. I need to render some
"objects" that reference selected vertices of the VBO and selected indices of the EBO, sequentially, but
under different model-view transformations.

Basically, what I am trying to achieve with OSG is the following OpenGL code:

Code:
glBindBuffer(my_huge_vbo)
glBindBuffer(my_huge_ebo)

glLoadMatrix(...); // transformation 1
glDrawElements(GL_TRIANGLES, 10, ........, offset_to_EBO_indices_for_object1); // draw the first
object under transformation 1
glLoadMatrix(...); // transformation 2
glDrawElements(GL_TRIANGLES, 50, ........, offset_to_EBO_indices_for_object2); // draw the first
object under transformation 2
glLoadMatrix(...); // transformation 3
glDrawElements(GL_TRIANGLES, 8, ........, offset_to_EBO_indices_for_object3); // draw the first
object under transformation 3
and so on

My problem is that if I have the following scene graph (see below), I will have many VBO/EBO buffer bindings,
which is what I want to avoid.

Code:
- MatrixTransform
  - Geode 
(Continue reading)

Thomas Hogarth | 20 May 12:28
Picon

[ANN] My first IPhone/IPad app (it's free)

Hi All

Well I've been very busy lately and have finally managed to release my own app on the iOS appstore.

http://itunes.apple.com/us/app/stereomagic/id495427905?mt=8

It called StereoMagic and uses Render to texture to render interactive stereogram images (magiceyes) in realtime.

You get 8 scenes free with the app and can use in app purchase to unlock an additional 12.

An android port will be coming soon.

Thanks 
Tom

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=47781#47781

Massimo Tarantini | 20 May 10:48
Picon
Favicon

OSG for Android with Necessitas?

Hi,

i have recompiled OSG 3.0.1 for Android wint Ubuntu 11,
and now i'm trying to compiled the osgviewerQT example
under Windows, using Necessitas (QT Android porting).

I have some problems with EGL initializations. I get eglMakeCurrent:674 error 3002 (EGL_BAD_ACCESS). 

Someone has been using Necessitas with OSG? Some tricks and tips?

Thank you!

Cheers,
Massimo

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=47779#47779

Joel Graff | 20 May 06:06
Picon

Re: Problem using OSG GLSL uniforms and vertex attributes

Just as a followup, I did discover why OSG was adding the MVP and Vertex declarations to the vertex file.  I had
previously started with version 120 code that included the line

Code:

gl_Position = ftransform();

In my effort to carefully transition from 120 to 140+, I only commented out the ftransform() statement - I
didn't remove it.  

Thus, my transitioned code looked like:

Code:

gl_Position = osg_ModelViewProjectionMatrix * osg_Vetex; //ftransform(); 

The automatic conversion, then, saw the call to ftransform() and did what it was supposed to do - replaced
ftranform() with osg_MVP * osg_Vertex and declared both at the start of the file.  The end result would be
that osg_MVP and osg_Vertex get declared twice (once by me and once by the auto converter) and the
gl_Position statement ends up looking like:

Code:

gl_Position = osg_ModelViewProjectionMatrix * osg_Vertex; //osg_ModelViewProjectionMatrix * osg_Vertex;

I suppose that's a bug, which requires detecting commented code in the source string to fix, but I can't
imagine anyone else but me would go to the effort to create the condition that caused it...

Anyway, the moral of the story is: don't leave any commented out calls to ftransform() in legacy shader code!

(Continue reading)

Frederic Bouvier | 19 May 17:03
Picon
Favicon

Multiple GPU/monitor issue on Windows 7/NVidia

Hi,

I am pretty sure it has been discussed before, but I am unable to 
retrieve the right thread, so ...

I have a dual card setup, each driving a single monitor. When I start 
osgViewer, the viewer span on both screen, an initial image is displayed 
on both too, but only the primary display is updated when I change the 
camera view with the mouse. Clicking on the frozen screen and then on 
the live screen update the image on the frozen screen but only for one 
frame.

I have the last WHDL NVidia driver. Cards are 2 GF GTX470 and I tried 
with and without SLI enabled. The same problem occurs in a multiscreen 
setup of FlightGear.

Any idea ?

Regards,
-Fred

Bernd Kampl | 18 May 22:26
Picon

[osgPlugins] [osgAndroid-Question] How to get .ply files to work?

Hi dear OSG Dev Community :)
I'm working with the Android Implementation of OSG, namely the osgAndroidExampleGLES1. I figured out how
to include the plugins like jpeg, png, curl, freetype, mainly thanks to this thread: http://forum.openscenegraph.org/viewtopic.php?t=10415
(For those who don't know: the Android.mk and the OsgMainApp.hpp have to be modified).

But here comes my problem: i want to use .ply Files. I know there is a plugin for it. But when i try to include it
like i do with with the other plugins i get the error "cannot find -losgdb_ply". maybe someone could point
me in the right direction.
thanks very much in advance, this dev community is absolutely awesome!

Cheers,
Bernd

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=47767#47767

wang shuiying | 18 May 18:19
Picon
Picon
Favicon

Help: how does lightSource with referenceFrame of osg::LightSource::ABSOLUTE_RF work?

Hello,

I have 2 questions about the lightSource node.

(1) Does lightSource affect all the geode nodes in the scenedata  or 
only the ones that are under it in the sceneData structure?
(2) In my application, a lightSource is attached to the main sceneNode, 
and this lightSource has a osg::group node (NodeA)as its child which 
contains several 3D models . There is also a pre render camera attached 
to the lightSource, and that pre render camera also has NodeA as child. 
When I set 
lightSource->setReferenceFrame(osg::LightSource::ABSOLUTE_RF), the color 
of the texture from the prerender camera varies as I use mouse to change 
the orientation of master camera displaying the 3D view. I don't know 
what is happening here. In my opinion, as the position and orientation 
of the pre render camera relative to the static 3D objects stay the 
same, the texture color should be the same too.

When  Relative_RF is assigned, then the texture keeps the same however I 
change the master camera.

Can anyone give me some hints on that?

Thanks a lot in advance!

Best regards

Shuiying
Thomas Hogarth | 17 May 01:14
Picon

[ANN] OSG Based Android Game Released (it's free)

Hi All

A game I developed originally on iOS for AppToyz has now been successfully ported to Android and is
available on GooglePlay

https://play.google.com/store/apps/details?id=com.AppToyz.AlienAttack&feature=nav_result#?t=W251bGwsMSwyLDNd

It uses your phones camera and gyro for basic video overlay style augmented reality.

Hope you enjoy it.
Tom

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=47747#47747

Aurelien Albert | 16 May 09:17
Picon
Favicon

Render a sub part of the viewport

Hi,

I've made a render graph with a main camera and several RTT cameras.

One of these cameras is disabled by default and is used to compute informations about the fragments (shader
program is used to compute image signal parameters, not visible colors)

When the user activate a "read info" mode, for each click on the viewer :
- this special "fragment info" camera is enabled
- the "fragment info" camera matrices (view and projection) are copied from the main camera (to get the same
point of view)
- the "fragment info" camera viewport is copied from the main camera (to get the "same" image)
- a frame is rendered => the "fragment info" camera write informations into a framebuffer
- the informations from the "fragment info" pixel under the mouse are read and displayed to the user

This works well, but I have a performance issue :
- the "fragment info" shaders are complex
- the "fragment info" framebuffer is the same size as the main viewer, which is useless since I have to read
only a few pixels

So I'm looking for a way to compute :
- the "fragment info" camera matrices (view and projection)  from the main camera matrices
- the "fragment info" camera viewport from the main camera matrices

to get :
- only a 9x9 pixels image
- the center pixel of this image centered with the mouse cursor coordinate

Thank you!

(Continue reading)


Gmane