Re: [osg-users] Copying rendered image before and after post-processing

2013-08-29 Thread Shahar Kosti
Hi Sebastian,

Thanks for your answer.

Eventually I went with a another solution (copy a scaled-down texture), as 
copying with alternating PBOs always resulted in the texture after 
post-processing. Unfortunately I had no more time for this. It could be related 
to old hardware though (GeForce 8800).

Thanks,
Shahar


Sebastian Messerschmidt wrote:
 Hi Shahar,
 
 I guess your scene is being rendered to an FBO already.
 So simply create a camera taking the resulting FBO as input, a new 
 texture as output an attach a simple glsl program to copy.
 Also I guess osgPPU has some copy processor, but I'm not sure.
 
 cheers
 Sebastian
 
  Hi,
  
  I've got an OSG application with a single viewer and camera. The camera is 
  set to render to FBO -
  
  
  Code:
  camera-attach(osg::Camera::COLOR_BUFFER0, m_texture2D);
  camera-setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);
  
  
  
  Rendering consists of the following main steps:
  1) Render scene
  2) Post-processing using osgPPU
  3) In final draw callback, copy the rendered image to the application using 
  two alternating PBOs
  
  Now I'd like to add one more step -
  1.5) Copy the rendered image to application before post-processing
  
  The copied image will only be used in the application (e.g. to save it), 
  and will not be displayed nor copied back to the graphics card (like the 
  osgprerender example). In addition, I don't mind getting it with a delay of 
  a few frames.
  
  How would you recommend implementing this step efficiently, while 
  maintaining the current performance level of the application (runs at 60Hz).
  I guess I could use two separate cameras to render the scene (one without 
  osgPPU), but I wonder if there is a better way.
  
  Thanks,
  Shahar
  
  --
  Read this topic online here:
  http://forum.openscenegraph.org/viewtopic.php?p=55940#55940
  
  
  
  
  
  ___
  osg-users mailing list
  
  http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
  
 
 ___
 osg-users mailing list
 
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
 
  --
 Post generated by Mail2Forum


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





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] Copying rendered image before and after post-processing

2013-08-22 Thread Shahar Kosti
Hi,

I've got an OSG application with a single viewer and camera. The camera is set 
to render to FBO -


Code:
camera-attach(osg::Camera::COLOR_BUFFER0, m_texture2D);
camera-setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);



Rendering consists of the following main steps:
 1) Render scene
 2) Post-processing using osgPPU
 3) In final draw callback, copy the rendered image to the application using 
two alternating PBOs 

Now I'd like to add one more step -
  1.5) Copy the rendered image to application before post-processing

The copied image will only be used in the application (e.g. to save it), and 
will not be displayed nor copied back to the graphics card (like the 
osgprerender example). In addition, I don't mind getting it with a delay of a 
few frames.

How would you recommend implementing this step efficiently, while maintaining 
the current performance level of the application (runs at 60Hz).
I guess I could use two separate cameras to render the scene (one without 
osgPPU), but I wonder if there is a better way.

Thanks,
Shahar

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





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Passing location-based data to a fragment shader

2013-07-01 Thread Shahar Kosti
Hi Sebastian,
Thanks for the detailed explanation and the hints regarding texture/world 
coordinates. I've tried binding at the tile level as you suggested, but 
apparently the additional data source is not fast enough to be used at 
real-time.
At this point, I'm going to have the original terrain model regenerated with 
two textures for each tile, instead of constructing the second texture on the 
fly. As far as I understand, binding a second texture should be possible with 
the OSG and TXP formats.
So thanks again for attempting to help with issue.

Best,
Shahar


Sebastian Messerschmidt wrote:
 You don't really need to bind at a level this deep. Usually if the 
 terrain tile is loaded and represent a LOD you want to work with, you 
 can simple add your data texture(s) as uniform to the stateset of the tile.
 Given you have a texture with the data-image called texture you can do 
 it this way in your callback:
 
 osg::StateSet* state_set = node-getOrCreateStateSet();
 osg::Uniform* sampler = new osg::Uniform(MyDataSamper,  2 
 /*texture unit*/);
 
 state_set-setTextureAttribute(unit, texture ,osg::StateAttribute::ON);
 state_set-addUniform(sampler);
 
 With this you bind the texture to a sampler for your shader, at the 
 texture unit 2. Depending on how many textures are already bound you 
 might need to modify the unit.
 In the fragment shader you can now access the texture via:
 
 uniform sampler2D MyDataSampler
 ..
 ..
 
 main()
 {
 vec2 tex_coord = gl_TexCoord[0].st;
 vec4 data = texture2D(MyDataSampler, tex_coord);
 }
 


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





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Passing location-based data to a fragment shader

2013-07-01 Thread Shahar Kosti
Hi Nick, 

Yes, this is part of what I'm trying to do (I'd like to do the same with osg 
models). I'd be glad if you could elaborate on the different approach, even 
though I would probably go with pre-generating the texture along with the 
archive.

Thanks,
Shahar


Trajce Nikolov NICK wrote:
 Hi Shahar,
 
 I read this post and found it interesting. Just out of curiosity :
 
 
 Each texel in the new texture, should be set based on the world location of 
 the corresponding texel in the current geometry texture
 
 
 
 Are you trying to overlay a texture on top of txp archive and it should be 
 georeferenced? If so, there might be a different approach
 
 
 Nick
 


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





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Passing location-based data to a fragment shader

2013-06-23 Thread Shahar Kosti

Sebastian Messerschmidt wrote:
 Hi Shahar Kosti:
 As you don't provide any exact numbers I can only guess. But usually I'd 
 bind one or more textures per tile of paged set.
 Depending on your hardware bind of 8192x8192 textures is no problem.
 Can you be a bit more specific on how big the set is?
 
 Also for the hidden textures - I don't really get what you mean. My best 
 guess is, that you mean not displayed.
 Therefore write a custom fragment shader and bind the data-textures 
 along with you diffuse or whatever textures to the stateset of the tile.
 
 As the fragment shader is fully programmable, it is your choice what is 
 done with the data.
 
 cheers
 Sebastian
 


Hi Sebastian,

Sorry for my late reply, it took me some time to get the data. 
One TXP I'm currently looking at, represents a 3000 kmĀ² area with texture 
resolution of 5m/pixel. Some areas have better resolution, up to 10 cm/pixel. 
The additional metadata has similar resolution. So obviously wouldn't fit on a 
single texture.

Regarding your suggestions, could you elaborate on the bind one or more 
textures per tile of paged set approach?

My current approach (which doesn't work), is to intercept paged nodes using a 
custom ReadFileCallback, which runs a NodeVisitor. The visitor finds all Geode 
objects and then the underlying geometries. I can bind a new texture to these 
geometries, but I'm not sure how to set the values correctly. 
Each texel in the new texture, should be set based on the world location of the 
corresponding texel in the current geometry texture. I'm not sure how to do 
that using the geometry vertex and texture coordinate indices.
I hope this is clear enough.

Thanks for the help,
Shahar

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





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] Passing location-based data to a fragment shader

2013-06-18 Thread Shahar Kosti
Hi all,

I'm trying to combine two data sources in a shader:
 * Terrain model - a large object in OSG or TXP formats.
 * Metadata grid - a data structure that provides additional information for 2D 
coordinates in the terrain (at a certain resolution).

I'd like to use some of the additional metadata values, in a fragment shader 
that runs on the terrain object. In other words, modify each pixel based on an 
additional value from the metadata grid.

I tried to pass the values as vertex attributes: compute the world location of 
each vertex, and set the vertex attribute from the metadata grid. That didn't 
work very well, as the additional data resolution is very high, almost the same 
as the terrain textures, and the vertices are too far apart from each other.

How would you recommend to pass the required data from the application to the 
shader?

Thanks,
Shahar

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





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Passing location-based data to a fragment shader

2013-06-18 Thread Shahar Kosti
Hi Sebastian,
Thanks for your response.

What if the data does not fit in a single 2D texture? in the worst case 
scenario, the terrain format would be TXP (i.e. paged) and the additional data 
resolution would be close to the textures resolution.
Is there any way to have a set of hidden textures, and access them in the 
fragment shader?

Shahar 


Sebastian Messerschmidt wrote:
 Hi Shahar,
 If the data is 2D and simply projected to x,y you could use a 2D texture 
 and sample it per fragment based on generated texture coordinates
 


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





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] [osgPPU] Perfomance issues with PBO for input textures

2012-02-28 Thread Shahar Kosti
Hi,
I'm new to osgPPU and OSG in general, so please bear with me :)

I'm trying to use the built-in mechanism in osgPPU::Unit for copying the 
rendered textures to the CPU. I'm using a simple tester based on one of the 
osgPPU, and my initialization code is structured like this:

Code:

// Somewhere in the middle of the Processor graph:
osgPPU::Unit* pUnit = new osgPPU::UnitInOut();
pUnit-setUsePBOForInputTexture(0, true);
parentUnit-addChild(pUnit);




With this code the frame rate drops significantlly, from 60 to 10-30 
(dependning on the viewport size). If I comment out the glGetTexImage call 
inside Unit.cpp, everything works as before (but nothing gets copied, of 
course).

Considering I don't mind getting the texture with a delay of a few frames, is 
there any way to improve the performance of the current implementation?
I must say I've read about PBO (http://www.songho.ca/opengl/gl_pbo.html), but 
I'm not sure whether this is the correct approach here, or how to integrate it 
with the existing code base.

Thanks,
Shahar

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





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] Integrating OSG with Qt: QOSGWidget memory consumption

2010-11-04 Thread Shahar Kosti
Hi,

I'm new to OSG and trying to create a Qt-based application with OSG windows 
inside. To do this, I'm following the osgviewerQT example using the 
multi-threaded CompositeViewer mode (--MTCompositeViewer).

When I start the example with a model it seems to be loaded 6 times, which is 
also the number of views. This makes the memory consumption much larger than 
the other modes in that example. Why is the model loaded multiple times? Is it 
possible to load it once for all views?

OSG version - 2.9.9, Qt version - 4.5.1
Command line parameters: osgviewerQT.exe -- QOSGWidget --MTCompositeViewer 
my_model.ive

Thank you!

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





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Integrating OSG with Qt: QOSGWidget memory consumption

2010-11-04 Thread Shahar Kosti
Eventually I went with a modified version of the --CompositeViewer part of 
the example. I'm still not sure what is wrong with the other approach - the 
number of GraphicsContext and View objects is the same.

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





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org