Re: [osg-users] Slave camera setup and blit render buffer to framebuffer

2014-11-29 Thread Julien Valentin

mp3butcher wrote:
 I haven't noticed the introduction of osgVolume::VolumeScene.
 It's a great feature. 
 But At first glance, it seams to use an other mecanism than osg::view slave 
 camera in order to copy matmodelview and matproj to the RTT camera...seams 
 managed via uniforms in programs
 
 Further it  seams to use a program (volume_color_depth.frag) in order to copy 
 back texture stored color/depth to the framebuffer.
 
 So it bring me to the question: What is the best?:
 1)use Render to Texture and copy back with a fragment program
 2)use Render to renderbuffer and glBlitFrameBuffer to copyback
 
 (
 To return to my code:
 i've to set camrea graphic context  (i'm dumb) and disable nearfarcomputation
 And i put the blit on the maincamera predraw 
 And i put the _camera as pre_render
 I will post a nicer/cleaner code tomorrow to have your opinion
 The results is good as long as I rotate the maincamera but when translate it, 
 there's artifacts due to znear/zfar discordance..will see this bug later
 
 )
 
 
 robertosfield wrote:
  Hi Julien, 
  I am away from my computer so can't look at you whole post. You description 
  it sound rather like the osgVolume::MultiPassTechnique now part of The 
  svn/trunk version of the Osg. 
  Robert On 28 Nov 2014 19:50, Julien Valentin  () wrote:
   Hi,
   In the frame of mixed geometry/volume rendering, i would like to create 
   depthtexture for a subgraph..this texture is used to stop forward raycast 
   of the volume.
   In order to do that i would like to:
   1)Render subgraph in a fbo with 3 attachements
   -depth to renderbuffer
   -depth to texture
   -color to renderbuffer
   2)Copy back  depth and color render buffers from the fbo to the frame 
   buffer (using glblitframebuffer)
   
   
   Here my current code
   
   Code:
   
   class OSGMULTIGRID_EXPORT RenderDepth2Texture : public osg::Group{
           public:
   virtual         bool addChild(osg::Node*n);
                   RenderDepth2Texture();
                   /** Copy constructor using CopyOp to manage deep vs 
   shallow copy.*/
   
   
                   inline osg::Texture2D*getDepthTexture()const{ return 
   _depthtexture; }
                   inline osg::Uniform*getDepthResolutionUniform()const{ 
   return _rdx; }
                   void setRasterizationResolution(const osg::Vec2ui);
                   const osg::Vec2ui  getRasterizationResolution()const { 
   return _resolution; }
   
                   virtual void traverse(osg::NodeVisitor nv);
                    osg::ref_ptrosg::Texture2D _depthtexture,_colortexture;
                   osg::Vec2ui _resolution;
                   osg::ref_ptrosg::Camera _camera;
                   osg::ref_ptrosg::Uniform  _rdx;
           };
   class PreDrawFBOCallback : public osg::Camera::DrawCallback
   {
   public:
           PreDrawFBOCallback(osg::FrameBufferObject* fbo, 
   osg::FrameBufferObject* source_fbo, unsigned int width, unsigned int 
   height, osg::Texture2D *dt, osg::Texture2D *ct) :
                   _fbo(fbo), _source_fbo(source_fbo), _depthTexture(dt), 
   _colorTexture(ct), _width(width), _height(height) {}
   
           virtual void operator () (osg::RenderInfo renderInfo) const
           {
                   cerr  PreDrawFBOCallback  endl;
                   // switching only the frame buffer attachments is 
   actually faster than switching the framebuffer
   #ifdef USE_PACKED_DEPTH_STENCIL
   #ifdef USE_TEXTURE_RECTANGLE
                   
   _fbo-setAttachment(osg::Camera::PACKED_DEPTH_STENCIL_BUFFER, 
   osg::FrameBufferAttachment((osg::TextureRectangle*)(_depthTexture.get(;
   #else
                   
   _fbo-setAttachment(osg::Camera::PACKED_DEPTH_STENCIL_BUFFER, 
   osg::FrameBufferAttachment((osg::Texture2D*)(_depthTexture.get(;
                   
   _fbo-setAttachment(osg::Camera::PACKED_DEPTH_STENCIL_BUFFER, 
   osg::FrameBufferAttachment(new osg::RenderBuffer(_width, _height, 
   GL_DEPTH24_STENCIL8_EXT)));// A16)));
   #endif
   #else
   #ifdef USE_TEXTURE_RECTANGLE
                   _fbo-setAttachment(osg::Camera::DEPTH_BUFFER, 
   osg::FrameBufferAttachment((osg::TextureRectangle*)(_depthTexture.get(;
   #else
                   _fbo-setAttachment(osg::Camera::DEPTH_BUFFER, 
   osg::FrameBufferAttachment(_depthTexture.get()));// 
   osg::FrameBufferAttachment(new osg::RenderBuffer(_width, _height, 
   GL_RGBA16)));
   #endif
   #endif
   #ifdef USE_TEXTURE_RECTANGLE
                   _fbo-setAttachment(osg::Camera::COLOR_BUFFER0, 
   osg::FrameBufferAttachment((osg::TextureRectangle*)(_colorTexture.get(;
   #else
                   _fbo-setAttachment(osg::Camera::COLOR_BUFFER0, 
   osg::FrameBufferAttachment((_colorTexture.get(;// 
   osg::FrameBufferAttachment(new osg::RenderBuffer(_width, _height, 
   GL_DEPTH_COMPONENT16_ARB)));
   
                   _fbo-setAttachment(osg::Camera::COLOR_BUFFER, 
   osg::FrameBufferAttachment(new osg::RenderBuffer(_width, _height, 
   

Re: [osg-users] [build] OpenThreads/Version and osg/Version

2014-11-29 Thread Christian Ruzicka
Hi,

Thanks Roberts! This makes the handling of our internal OSG repository easier.

Cheers,
Christian

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





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