Re: [osg-users] Render to FBO and multiSamples

2014-02-25 Thread fengyun
Hi,
when using multiple camera configured with multisample, i get black screen 
without any warning, without multisample it works fine.
In my test code, two rtt camera render different node to same depth buffer and 
color buffer, it works fine if configure only first camera with multisample, 
configure both camera with multisample will cause black screen. 

the test code is as follow, the shader is simple texfetch.


Code:
#include 
#include 
#include 
#include 
#include 
#include 


/*
*   multisample.
*/
osg::Program* createProgram(std::string vertSource, std::string fragSource)
{
osg::ref_ptr vert = 
osgDB::readShaderFile(osg::Shader::VERTEX, vertSource);
osg::ref_ptr frag = 
osgDB::readShaderFile(osg::Shader::FRAGMENT, fragSource);

osg::ref_ptr prog = new osg::Program;
if (!prog->addShader(vert.get()))
std::cout<<"add vertex shader failed!\n";
if (!prog->addShader(frag.get()))
std::cout<<"add fragment shader failed!\n";

return prog.release();
}

int main(void)
{
osg::ref_ptr scene = new osg::Group;

osg::ref_ptr node = osgDB::readNodeFile("../media/cow.ive");
{
osg::ref_ptr prog = createProgram("base.vert", 
"base.frag");

osg::ref_ptr set = node->getOrCreateStateSet();

set->setAttributeAndModes(prog, osg::StateAttribute::ON);

osg::ref_ptr texUniform = new 
osg::Uniform("renderTex", 0);
set->addUniform(texUniform.get());

}

osg::ref_ptr baseTex = new osg::Texture2D;
{   
baseTex->setTextureSize(800, 600);
baseTex->setInternalFormat(GL_RGBA);//important.
}
osg::ref_ptr depthTex = new osg::Texture2D;
{   
depthTex->setTextureSize(800, 600);
depthTex->setSourceFormat(GL_DEPTH_COMPONENT);
depthTex->setSourceType(GL_UNSIGNED_BYTE);
depthTex->setInternalFormat(GL_DEPTH_COMPONENT24);
}
{// first RTT camera
osg::ref_ptr camera = new osg::Camera;
camera->addChild(node.get());
scene->addChild(camera.get());

camera->setClearColor(osg::Vec4f(0.0f, 0.0f, 1.0f, 1.0f));
camera->setClearDepth(1.0);
camera->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

camera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);
camera->setRenderOrder(osg::Camera::PRE_RENDER);
camera->attach(osg::Camera::COLOR_BUFFER0, baseTex.get(), 0, 0, 
false, 4, 0);
camera->attach(osg::Camera::DEPTH_BUFFER, depthTex.get(), 0, 0, 
false, 4, 0);
camera->setViewport(0, 0, baseTex->getTextureWidth(), 
baseTex->getTextureHeight());
camera->setReferenceFrame(osg::Transform::RELATIVE_RF);


camera->setComputeNearFarMode(osg::Camera::DO_NOT_COMPUTE_NEAR_FAR);
camera->setCullingMode(osg::CullSettings::NO_CULLING);
}
{// second RTT camera
osg::ref_ptr camera = new osg::Camera;
osg::Matrixf translate;
translate.makeTranslate(osg::Vec3f(0.0f, 0.0f, 10.0f));
osg::ref_ptr matrixTransform = new 
osg::MatrixTransform;
matrixTransform->setMatrix(translate);
matrixTransform->addChild(node.get());
camera->addChild(matrixTransform.get());
scene->addChild(camera.get());

//  camera->setClearColor(osg::Vec4f(0.0f, 0.0f, 1.0f, 1.0f));
//  camera->setClearDepth(1.0);
camera->setClearMask(0);

camera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);
camera->setRenderOrder(osg::Camera::PRE_RENDER);
camera->attach(osg::Camera::COLOR_BUFFER0, baseTex.get(), 0, 0, 
false, 0, 0);
camera->attach(osg::Camera::DEPTH_BUFFER, depthTex.get(), 0, 0, 
false, 0, 0);
camera->setViewport(0, 0, baseTex->getTextureWidth(), 
baseTex->getTextureHeight());
camera->setReferenceFrame(osg::Transform::RELATIVE_RF);


camera->setComputeNearFarMode(osg::Camera::DO_NOT_COMPUTE_NEAR_FAR);
camera->setCullingMode(osg::CullSettings::NO_CULLING);
}
{
osg::ref_ptr screenQuad = 
drawScreenQuad(baseTex.get());
scene->addChild(screenQuad.get());

osg::ref_ptr prog = 
createProgram("screenQuad.vert", "screenQuad.frag");

osg::ref_ptr set = 
screenQuad->getOrCreateStateSet();

set->setAttributeAndModes(prog, osg::StateAttribute::ON);

osg::ref_ptr baseTexUniform = new 
osg::Uniform("renderTex", 0);
set->addUniform(baseTexUniform.get());
}

o

Re: [osg-users] Render to FBO and multiSamples

2012-01-26 Thread Sergey Polischuk
Hi

About 3rd point - i think fixed pipeline opengl lighting may screw that.

26.01.2012, 20:32, "Aurelien Albert" :
> Hi,
>
> I solved my problem, but I don't really understand how.
>
> What I did :
>
> 1. attach the same depth buffer FBO to all cameras
> 2. configure multisamples only on the first camera color buffer attachment
> 3. always use a shader program to render post processing, even if there is no 
> post processing
>
> Point 1 : I really don't understand what difference it makes
>
> Point 2 : I use a color buffer shared between 2 cameras, it seems I can only 
> configure multisamples for the firs one
>
> Point 3 : really strange : if I render the textured quad to screen whitout 
> any shader, all screen become darker when the camera is very close to an 
> object
>
> Cheers,
> Aurelien
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=45047#45047
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Render to FBO and multiSamples

2012-01-26 Thread Aurelien Albert
Hi,

I solved my problem, but I don't really understand how.

What I did :

1. attach the same depth buffer FBO to all cameras
2. configure multisamples only on the first camera color buffer attachment
3. always use a shader program to render post processing, even if there is no 
post processing

Point 1 : I really don't understand what difference it makes

Point 2 : I use a color buffer shared between 2 cameras, it seems I can only 
configure multisamples for the firs one

Point 3 : really strange : if I render the textured quad to screen whitout any 
shader, all screen become darker when the camera is very close to an object



Cheers,
Aurelien

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





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


Re: [osg-users] Render to FBO and multiSamples

2012-01-26 Thread Aurelien Albert
I'm still investigating on it, and it's really weird : the depth buffer seems 
to be drawn over the color buffer : when I come close to my model, the image 
because darker...

This doesn't appear with FRAME_BUFFER render target.

Is that possible ? I saw some messages on the forum about implicit 
attachment... is there any link with my problem ?

My full render graph  is below (the problem seems to be in the post process 
camera) :


Code:
- Main camera (color / depth render to FBO)
|
|--- main scene
  |
  |--- Post process camera (render a quad using main camera color texture to a 
new FBO)
  |  |
  |  |-- Quad
  |
  |--- No post process camera (color / depth render to FBO,  color FBO is 
shared with post process camera, depth FBO is shared with main camera)
  |  |
  |  |-- Objects without post processing
  |
  |
  |--- Render to screen camera (render a quad to screen using post process 
camera color texture)
  |  |
  |  |-- Quad



Aurelien

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





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


Re: [osg-users] Render to FBO and multiSamples

2012-01-26 Thread J.P. Delport

Hi,

maybe check code in osgfpdepth example.

jp

On 26/01/2012 12:13, Aurelien Albert wrote:

Hi,

I've done all the tests, and they are all ok.

May the problem comes from the depth buffer attachment ?

When I use :


Code:
p_camera->attach(osg::Camera::COLOR_BUFFER, p_renderTextureColor, 0, 0, false, 
4, 4);
p_camera->attach(osg::Camera::DEPTH_BUFFER, p_renderTextureDepth, 0, 0, false, 
4, 4);

or :

p_camera->attach(osg::Camera::COLOR_BUFFER, p_renderTextureColor, 0, 0, false, 
4, 4);
p_camera->attach(osg::Camera::DEPTH_BUFFER, p_renderTextureDepth);




There is black screen, but if I don't attach depth buffer, I got something rendered and 
no "Warning: detected OpenGL error 'invalid operation' at after 
RenderBin::draw(..)" errors in the console.

Here is how I create my textures :


Code:
// Main color texture
p_renderTextureColor = new osg::Texture2D();
p_renderTextureColor->setTextureSize(p_osgViewport->width(), 
p_osgViewport->height());
p_renderTextureColor->setInternalFormat(GL_RGBA32F_ARB);
p_renderTextureColor->setSourceFormat(GL_RGBA);
p_renderTextureColor->setSourceType(GL_FLOAT);
p_renderTextureColor->setFilter(osg::Texture2D::MIN_FILTER, 
osg::Texture2D::LINEAR);
p_renderTextureColor->setFilter(osg::Texture2D::MAG_FILTER, 
osg::Texture2D::LINEAR);
p_renderTextureColor->setWrap(osg::Texture::WRAP_S, 
osg::Texture::CLAMP_TO_EDGE);
p_renderTextureColor->setWrap(osg::Texture::WRAP_T, 
osg::Texture::CLAMP_TO_EDGE);
p_renderTextureColor->setDataVariance(osg::Object::DYNAMIC);
p_renderTextureColor->setUseHardwareMipMapGeneration(false);
p_renderTextureColor->setResizeNonPowerOfTwoHint(false);

// Main depth texture
p_renderTextureDepth = new osg::Texture2D();
p_renderTextureDepth->setTextureSize(p_osgViewport->width(), 
p_osgViewport->height());
p_renderTextureDepth->setSourceFormat(GL_DEPTH_COMPONENT);
p_renderTextureDepth->setSourceType(GL_FLOAT);
p_renderTextureDepth->setInternalFormat(GL_DEPTH_COMPONENT32F);
p_renderTextureDepth->setFilter(osg::Texture2D::MIN_FILTER, 
osg::Texture2D::LINEAR);
p_renderTextureDepth->setFilter(osg::Texture2D::MAG_FILTER, 
osg::Texture2D::LINEAR);
p_renderTextureDepth->setWrap(osg::Texture::WRAP_S, 
osg::Texture::CLAMP_TO_EDGE);
p_renderTextureDepth->setWrap(osg::Texture::WRAP_T, 
osg::Texture::CLAMP_TO_EDGE);
p_renderTextureDepth->setDataVariance(osg::Object::DYNAMIC);
p_renderTextureDepth->setUseHardwareMipMapGeneration(false);
p_renderTextureDepth->setResizeNonPowerOfTwoHint(false);





Thank you!

Cheers,
Aurelien[/code]

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





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


--
This message is subject to the CSIR's copyright terms and conditions, e-mail legal notice, and implemented Open Document Format (ODF) standard. 
The full disclaimer details can be found at http://www.csir.co.za/disclaimer.html.


This message has been scanned for viruses and dangerous content by MailScanner, 
and is believed to be clean.


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


Re: [osg-users] Render to FBO and multiSamples

2012-01-26 Thread Robert Osfield
Hi Aurelien,

I'm afraid I can't spot what might be wrong at your end.

Robert.

On 26 January 2012 10:13, Aurelien Albert  wrote:
> Hi,
>
> I've done all the tests, and they are all ok.
>
> May the problem comes from the depth buffer attachment ?
>
> When I use :
>
>
> Code:
> p_camera->attach(osg::Camera::COLOR_BUFFER, p_renderTextureColor, 0, 0, 
> false, 4, 4);
> p_camera->attach(osg::Camera::DEPTH_BUFFER, p_renderTextureDepth, 0, 0, 
> false, 4, 4);
>
> or :
>
> p_camera->attach(osg::Camera::COLOR_BUFFER, p_renderTextureColor, 0, 0, 
> false, 4, 4);
> p_camera->attach(osg::Camera::DEPTH_BUFFER, p_renderTextureDepth);
>
>
>
>
> There is black screen, but if I don't attach depth buffer, I got something 
> rendered and no "Warning: detected OpenGL error 'invalid operation' at after 
> RenderBin::draw(..)" errors in the console.
>
> Here is how I create my textures :
>
>
> Code:
> // Main color texture
> p_renderTextureColor = new osg::Texture2D();
> p_renderTextureColor->setTextureSize(p_osgViewport->width(), 
> p_osgViewport->height());
> p_renderTextureColor->setInternalFormat(GL_RGBA32F_ARB);
> p_renderTextureColor->setSourceFormat(GL_RGBA);
> p_renderTextureColor->setSourceType(GL_FLOAT);
> p_renderTextureColor->setFilter(osg::Texture2D::MIN_FILTER, 
> osg::Texture2D::LINEAR);
> p_renderTextureColor->setFilter(osg::Texture2D::MAG_FILTER, 
> osg::Texture2D::LINEAR);
> p_renderTextureColor->setWrap(osg::Texture::WRAP_S, 
> osg::Texture::CLAMP_TO_EDGE);
> p_renderTextureColor->setWrap(osg::Texture::WRAP_T, 
> osg::Texture::CLAMP_TO_EDGE);
> p_renderTextureColor->setDataVariance(osg::Object::DYNAMIC);
> p_renderTextureColor->setUseHardwareMipMapGeneration(false);
> p_renderTextureColor->setResizeNonPowerOfTwoHint(false);
>
> // Main depth texture
> p_renderTextureDepth = new osg::Texture2D();
> p_renderTextureDepth->setTextureSize(p_osgViewport->width(), 
> p_osgViewport->height());
> p_renderTextureDepth->setSourceFormat(GL_DEPTH_COMPONENT);
> p_renderTextureDepth->setSourceType(GL_FLOAT);
> p_renderTextureDepth->setInternalFormat(GL_DEPTH_COMPONENT32F);
> p_renderTextureDepth->setFilter(osg::Texture2D::MIN_FILTER, 
> osg::Texture2D::LINEAR);
> p_renderTextureDepth->setFilter(osg::Texture2D::MAG_FILTER, 
> osg::Texture2D::LINEAR);
> p_renderTextureDepth->setWrap(osg::Texture::WRAP_S, 
> osg::Texture::CLAMP_TO_EDGE);
> p_renderTextureDepth->setWrap(osg::Texture::WRAP_T, 
> osg::Texture::CLAMP_TO_EDGE);
> p_renderTextureDepth->setDataVariance(osg::Object::DYNAMIC);
> p_renderTextureDepth->setUseHardwareMipMapGeneration(false);
> p_renderTextureDepth->setResizeNonPowerOfTwoHint(false);
>
>
>
>
>
> Thank you!
>
> Cheers,
> Aurelien[/code]
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=45036#45036
>
>
>
>
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Render to FBO and multiSamples

2012-01-26 Thread Aurelien Albert
Hi,

I've done all the tests, and they are all ok.

May the problem comes from the depth buffer attachment ?

When I use :


Code:
p_camera->attach(osg::Camera::COLOR_BUFFER, p_renderTextureColor, 0, 0, false, 
4, 4);
p_camera->attach(osg::Camera::DEPTH_BUFFER, p_renderTextureDepth, 0, 0, false, 
4, 4);

or :

p_camera->attach(osg::Camera::COLOR_BUFFER, p_renderTextureColor, 0, 0, false, 
4, 4);
p_camera->attach(osg::Camera::DEPTH_BUFFER, p_renderTextureDepth);




There is black screen, but if I don't attach depth buffer, I got something 
rendered and no "Warning: detected OpenGL error 'invalid operation' at after 
RenderBin::draw(..)" errors in the console.

Here is how I create my textures :


Code:
// Main color texture
p_renderTextureColor = new osg::Texture2D();
p_renderTextureColor->setTextureSize(p_osgViewport->width(), 
p_osgViewport->height());
p_renderTextureColor->setInternalFormat(GL_RGBA32F_ARB);
p_renderTextureColor->setSourceFormat(GL_RGBA);
p_renderTextureColor->setSourceType(GL_FLOAT);
p_renderTextureColor->setFilter(osg::Texture2D::MIN_FILTER, 
osg::Texture2D::LINEAR);
p_renderTextureColor->setFilter(osg::Texture2D::MAG_FILTER, 
osg::Texture2D::LINEAR);
p_renderTextureColor->setWrap(osg::Texture::WRAP_S, 
osg::Texture::CLAMP_TO_EDGE);
p_renderTextureColor->setWrap(osg::Texture::WRAP_T, 
osg::Texture::CLAMP_TO_EDGE);
p_renderTextureColor->setDataVariance(osg::Object::DYNAMIC); 
p_renderTextureColor->setUseHardwareMipMapGeneration(false);
p_renderTextureColor->setResizeNonPowerOfTwoHint(false);

// Main depth texture
p_renderTextureDepth = new osg::Texture2D();
p_renderTextureDepth->setTextureSize(p_osgViewport->width(), 
p_osgViewport->height());
p_renderTextureDepth->setSourceFormat(GL_DEPTH_COMPONENT);
p_renderTextureDepth->setSourceType(GL_FLOAT);
p_renderTextureDepth->setInternalFormat(GL_DEPTH_COMPONENT32F);
p_renderTextureDepth->setFilter(osg::Texture2D::MIN_FILTER, 
osg::Texture2D::LINEAR);
p_renderTextureDepth->setFilter(osg::Texture2D::MAG_FILTER, 
osg::Texture2D::LINEAR);
p_renderTextureDepth->setWrap(osg::Texture::WRAP_S, 
osg::Texture::CLAMP_TO_EDGE);
p_renderTextureDepth->setWrap(osg::Texture::WRAP_T, 
osg::Texture::CLAMP_TO_EDGE);
p_renderTextureDepth->setDataVariance(osg::Object::DYNAMIC); 
p_renderTextureDepth->setUseHardwareMipMapGeneration(false);
p_renderTextureDepth->setResizeNonPowerOfTwoHint(false);





Thank you!

Cheers,
Aurelien[/code]

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





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


Re: [osg-users] Render to FBO and multiSamples

2012-01-26 Thread Robert Osfield
Hi Aurelien,

Could you try tests using the standard examples, for FSAA try:

Without FSAA:
   osgviewer cow.osg

Wih FSAA:

  osgviewer cow.osg --samples 2

Have a look around the edges of the cow for the classic stair stepping
in the non FSAA image and then compare to the FSAA one to see if it's
functioning correctly.  --samples sets both the Traits::samplesBuffers
and Traits::samples to the user specified value.

  osgprerender cow.osg  --fbo-samples 2 --color-samples 2

Then try enabling the use of multi-sampled FBO in the osgprerender example:

  osgprerender cow.osg  --fbo-samples 2 --color-samples 2

Finally add in the --samples 2 option to enable FSAA as well:

  osgprerender cow.osg  --fbo-samples 2 --color-samples 2 --samples 2

I've done this on my system and all the above tests work and observe
the expected reduction in stair stepping on the outlines of the cow
and flag respectively.

If all the above work fine on your system then the error will be
somewhere in your own code, if they don't work then it points to a
problem in the driver.

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


Re: [osg-users] Render to FBO and multiSamples

2012-01-26 Thread Aurelien Albert
Hi Robert,

I've try with :

p_camera->attach(osg::Camera::COLOR_BUFFER, p_renderTextureColor, 0, 0, false, 
2, 2); 
p_camera->attach(osg::Camera::DEPTH_BUFFER, p_renderTextureDepth, 0, 0, false, 
2, 2); 

and 0 for "sampleBuffers" and "samples" on the traits, but the problem is still 
there.

(My video card is a Quadro FX 4800)

Is there anything else to configure ?

What is the difference between the parameters "sampleBuffers" and "samples" ?

Thanks,
Aurelien

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





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


Re: [osg-users] Render to FBO and multiSamples

2012-01-26 Thread Robert Osfield
Hi Aurelien,

Try using more modest values for the sampleBuffers and samples values
when you are setting up the graphics context.  BTW, you won't need a
multi-sampled graphics context to use multi-sampling on the FBO and
visa-versa, these are decoupled and you can mix and match them.

Robert.

On 25 January 2012 22:10, Aurelien Albert  wrote:
> Hi,
>
> I use a camera to render my main graph to an FBO.
> Then I render this FBO to screen with another camera and a quad.
>
> Like this :
>
>
> Code:
> Main camera (render to FBO)
> |
> |-- Main graph
> |
> |--- Camera (render to screen)
>       |
>       |- Quad
>
>
>
>
> I try to setup multisampling for the main camera :
>
>
> Code:
> p_camera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);
> p_camera->attach(osg::Camera::COLOR_BUFFER, p_renderTextureColor, 0, 0, 
> false, 4, 4);
> p_camera->attach(osg::Camera::DEPTH_BUFFER, p_renderTextureDepth, 0, 0, 
> false, 4, 4);
>
>
>
>
> I also try to set "sampleBuffers" and "samples" on the traits before creating 
> context, but all I get is a black screen.
>
> When I render to screen, MSAA works great, but how to configure it for a FBO 
> target ?
>
> My textures are created as follow :
>
>
> Code:
> // Main color texture
> p_renderTextureColor = new osg::Texture2D();
> p_renderTextureColor->setTextureSize(p_osgViewport->width(), 
> p_osgViewport->height());
> p_renderTextureColor->setInternalFormat(GL_RGBA32F_ARB);
> p_renderTextureColor->setSourceFormat(GL_RGBA);
> p_renderTextureColor->setSourceType(GL_FLOAT);
> p_renderTextureColor->setFilter(osg::Texture2D::MIN_FILTER, 
> osg::Texture2D::NEAREST);
> p_renderTextureColor->setFilter(osg::Texture2D::MAG_FILTER, 
> osg::Texture2D::NEAREST);
> p_renderTextureDepth->setWrap(osg::Texture::WRAP_S, 
> osg::Texture::CLAMP_TO_EDGE);
> p_renderTextureDepth->setWrap(osg::Texture::WRAP_T, 
> osg::Texture::CLAMP_TO_EDGE);
>
> // Main depth texture
> p_renderTextureDepth = new osg::Texture2D();
> p_renderTextureDepth->setTextureSize(p_osgViewport->width(), 
> p_osgViewport->height());
> p_renderTextureDepth->setSourceFormat(GL_DEPTH_COMPONENT);
> p_renderTextureDepth->setSourceType(GL_FLOAT);
> p_renderTextureDepth->setInternalFormat(GL_DEPTH_COMPONENT32F);
> p_renderTextureDepth->setFilter(osg::Texture2D::MIN_FILTER, 
> osg::Texture2D::NEAREST);
> p_renderTextureDepth->setFilter(osg::Texture2D::MAG_FILTER, 
> osg::Texture2D::NEAREST);
> p_renderTextureDepth->setWrap(osg::Texture::WRAP_S, 
> osg::Texture::CLAMP_TO_EDGE);
> p_renderTextureDepth->setWrap(osg::Texture::WRAP_T, 
> osg::Texture::CLAMP_TO_EDGE);
>
>
>
>
> Any help would be greatly appreciated.
>
> Aurelien
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=45024#45024
>
>
>
>
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] Render to FBO and multiSamples

2012-01-25 Thread Aurelien Albert
Hi,

I use a camera to render my main graph to an FBO.
Then I render this FBO to screen with another camera and a quad.

Like this :


Code:
Main camera (render to FBO)
|
|-- Main graph
|
|--- Camera (render to screen)
   |
   |- Quad




I try to setup multisampling for the main camera :


Code:
p_camera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);
p_camera->attach(osg::Camera::COLOR_BUFFER, p_renderTextureColor, 0, 0, false, 
4, 4);
p_camera->attach(osg::Camera::DEPTH_BUFFER, p_renderTextureDepth, 0, 0, false, 
4, 4);




I also try to set "sampleBuffers" and "samples" on the traits before creating 
context, but all I get is a black screen.

When I render to screen, MSAA works great, but how to configure it for a FBO 
target ?

My textures are created as follow :


Code:
// Main color texture
p_renderTextureColor = new osg::Texture2D();
p_renderTextureColor->setTextureSize(p_osgViewport->width(), 
p_osgViewport->height());
p_renderTextureColor->setInternalFormat(GL_RGBA32F_ARB);
p_renderTextureColor->setSourceFormat(GL_RGBA);
p_renderTextureColor->setSourceType(GL_FLOAT);
p_renderTextureColor->setFilter(osg::Texture2D::MIN_FILTER, 
osg::Texture2D::NEAREST);
p_renderTextureColor->setFilter(osg::Texture2D::MAG_FILTER, 
osg::Texture2D::NEAREST);
p_renderTextureDepth->setWrap(osg::Texture::WRAP_S, 
osg::Texture::CLAMP_TO_EDGE);
p_renderTextureDepth->setWrap(osg::Texture::WRAP_T, 
osg::Texture::CLAMP_TO_EDGE);

// Main depth texture
p_renderTextureDepth = new osg::Texture2D();
p_renderTextureDepth->setTextureSize(p_osgViewport->width(), 
p_osgViewport->height());
p_renderTextureDepth->setSourceFormat(GL_DEPTH_COMPONENT);
p_renderTextureDepth->setSourceType(GL_FLOAT);
p_renderTextureDepth->setInternalFormat(GL_DEPTH_COMPONENT32F);
p_renderTextureDepth->setFilter(osg::Texture2D::MIN_FILTER, 
osg::Texture2D::NEAREST);
p_renderTextureDepth->setFilter(osg::Texture2D::MAG_FILTER, 
osg::Texture2D::NEAREST);
p_renderTextureDepth->setWrap(osg::Texture::WRAP_S, 
osg::Texture::CLAMP_TO_EDGE);
p_renderTextureDepth->setWrap(osg::Texture::WRAP_T, 
osg::Texture::CLAMP_TO_EDGE);




Any help would be greatly appreciated.

Aurelien

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





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