Re: [osg-users] problem with blending when using floating point FBO

2009-07-07 Thread Thrall, Bryan
Jonathan Richard wrote on Tuesday, July 07, 2009 7:28 AM:

>   >Glad you got it working!
> 
>   >Is there a reason you didn't just attach an osg::Texture to
your camera
>   >and set the number of samples greater than 1 in the attach
call?
> 
> 
> Well I did attach a texture to my camera and set the number of samples
> greater than 1...see: 
> 
> osg::ref_ptr offscreenTexture = new
> osg::TextureRectangle; 
> offscreenTexture->setTextureSize(WIDTH, HEIGHT);
>
offscreenTexture->setFilter(osg::TextureRectangle::MIN_FILTER,osg::Textu
re2D::LINEAR);
>
offscreenTexture->setFilter(osg::TextureRectangle::MAG_FILTER,osg::Textu
re2D::LINEAR);
> offscreenTexture->setSourceFormat(GL_RGBA);
> offscreenTexture->setSourceType(GL_FLOAT);
> offscreenTexture->setInternalFormat(GL_FLOAT_RGBA32_NV);
> 
> osg::Camera* camera=m_viewer->getCamera();
> camera->setClearColor(osg::Vec4f(0,0.0f,0.0f,1.0f));
> camera->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
>
camera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);
> camera->attach(osg::Camera::COLOR_BUFFER0,
> offscreenTexture.get(),0,0,false,8,4); 
> 
> 
> then in my draw call back I just get the resolved fbo that osg fills
with the
> glBlitFramebufferEXT call. This seems to work, I don't know if there
is
> better or "cleaner" solution to my problem. By the way I was wondering
why
> osg do not bind the resolved fbo instead of the multisampled fbo in
order to
> allow subsequent glReadPixels call. If not I don't understand why the
> glBlitFramebufferEXT is automatically performed. 

When you attach a texture, OSG will fill the texture with the contents
of the FBO automatically; you don't need to do the glReadPixels, just
use the texture.

>   >By the way, if you change OpenGL state, be careful that you
restore the
>   >previous state or tell OpenSceneGraph about the changes you
make (via
>   >haveAppliedMode(), haveAppliedAttribute(), etc.); otherwise
>   >OpenSceneGraph will get confused about what the current OpenGL
state is.
> 
> 
> 
> you are refering to the binding call (
> fbo->apply(state,osg::FrameBufferObject::READ_FRAMEBUFFER))? As I said
before
> I'm not sure if my approach is the best one. I just looked at the osg
code
> and found a way to get my own working. I saw (with your held) that a
resolved
> fbo was automatically generated when drawing to a multisampled fbo so
I just
> get it in my draw callback (getMultisampleResolveFramebufferObject())
then
> bind it in order to be able to read it.  

Yes, binding the fbo (and any other OpenGL state changes you do) should
be reported to OSG or restored to their original state before leaving
the draw callback.

HTH,
-- 
Bryan Thrall
FlightSafety International
bryan.thr...@flightsafety.com
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] problem with blending when using floating point FBO

2009-07-07 Thread Jonathan Richard
> >Glad you got it working!
>
> >Is there a reason you didn't just attach an osg::Texture to your camera
> >and set the number of samples greater than 1 in the attach call?


Well I did attach a texture to my camera and set the number of samples
greater than 1...see:

osg::ref_ptr offscreenTexture = new
osg::TextureRectangle;
offscreenTexture->setTextureSize(WIDTH, HEIGHT);
offscreenTexture->setFilter(osg::TextureRectangle::MIN_FILTER,osg::Texture2D::LINEAR);
offscreenTexture->setFilter(osg::TextureRectangle::MAG_FILTER,osg::Texture2D::LINEAR);
offscreenTexture->setSourceFormat(GL_RGBA);
offscreenTexture->setSourceType(GL_FLOAT);
offscreenTexture->setInternalFormat(GL_FLOAT_RGBA32_NV);

osg::Camera* camera=m_viewer->getCamera();
camera->setClearColor(osg::Vec4f(0,0.0f,0.0f,1.0f));
camera->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
camera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);
camera->attach(osg::Camera::COLOR_BUFFER0,
offscreenTexture.get(),0,0,false,8,4);


then in my draw call back I just get the resolved fbo that osg fills with
the glBlitFramebufferEXT call. This seems to work, I don't know if there is
better or "cleaner" solution to my problem. By the way I was wondering why
osg do not bind the resolved fbo instead of the multisampled fbo in order to
allow subsequent glReadPixels call. If not I don't understand why the
glBlitFramebufferEXT is automatically performed.


>
> >By the way, if you change OpenGL state, be careful that you restore the
> >previous state or tell OpenSceneGraph about the changes you make (via
> >haveAppliedMode(), haveAppliedAttribute(), etc.); otherwise
> >OpenSceneGraph will get confused about what the current OpenGL state is.
>

you are refering to the binding call (
fbo->apply(state,osg::FrameBufferObject::READ_FRAMEBUFFER))? As I said
before I'm not sure if my approach is the best one. I just looked at the osg
code and found a way to get my own working. I saw (with your held) that a
resolved fbo was automatically generated when drawing to a multisampled fbo
so I just get it in my draw callback
(getMultisampleResolveFramebufferObject()) then bind it in order to be able
to read it.


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


Re: [osg-users] problem with blending when using floating point FBO

2009-07-06 Thread Thrall, Bryan
Jonathan Richard wrote on Monday, July 06, 2009 4:04 PM:
> Ok I was able to get it working by getting the resolved fbo using the 
> RenderStage::getMultisampleResolveFramebufferObject method. Here a
subset of
> my code in the draw callback:  
> 
> 
>   osgViewer::Renderer * renderer =
>
static_cast(renderInfo.getCurrentCamera()->getRend
erer());
> 
> osg::FrameBufferObject *fbo=NULL;
> 
>
>
fbo=renderer->getSceneView(0)->getRenderStage()->getMultisampleResolveFr
amebufferObject();
> 
> // Bind the fbo to be read
> fbo->apply(state,osg::FrameBufferObject::READ_FRAMEBUFFER);
> 
> // Specify a color buffer as the source for the subsequent call of
> glReadPixel glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
> 
>   float* tempbuf32Bits = new float[WIDTH*HEIGHT];
>  glReadPixels(0, 0, WIDTH, HEIGHT, GL_RED, GL_FLOAT, tempbuf32Bits);

Glad you got it working!

Is there a reason you didn't just attach an osg::Texture to your camera
and set the number of samples greater than 1 in the attach call?

By the way, if you change OpenGL state, be careful that you restore the
previous state or tell OpenSceneGraph about the changes you make (via
haveAppliedMode(), haveAppliedAttribute(), etc.); otherwise
OpenSceneGraph will get confused about what the current OpenGL state is.

-- 
Bryan Thrall
FlightSafety International
bryan.thr...@flightsafety.com
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] problem with blending when using floating point FBO

2009-07-06 Thread Jonathan Richard
Ok I was able to get it working by getting the resolved fbo using the
RenderStage::getMultisampleResolveFramebufferObject method. Here a subset of
my code in the draw callback:


  osgViewer::Renderer * renderer =
static_cast(renderInfo.getCurrentCamera()->getRenderer());

osg::FrameBufferObject *fbo=NULL;


fbo=renderer->getSceneView(0)->getRenderStage()->getMultisampleResolveFramebufferObject();

// Bind the fbo to be read
fbo->apply(state,osg::FrameBufferObject::READ_FRAMEBUFFER);

// Specify a color buffer as the source for the subsequent call of
glReadPixel
glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);

  float* tempbuf32Bits = new float[WIDTH*HEIGHT];
 glReadPixels(0, 0, WIDTH, HEIGHT, GL_RED, GL_FLOAT, tempbuf32Bits);


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


Re: [osg-users] problem with blending when using floating point FBO

2009-06-30 Thread Thrall, Bryan
Jonathan Richard wrote on Tuesday, June 30, 2009 3:09 PM:

>> The result is an FBO without multisampling whose buffers are filled
by
>> combining the multiple samples from the multisample FBO together.
> 
> Ok so the FBO multisampling is supported but not directly as it said
on
> http://www.opengl.org/wiki/GL_EXT_framebuffer_object_More_about_FBOs
> 
> "Are multisample Render_To_Texture (RTT) supported? Not directly. You
need
> GL_EXT_framebuffer_multisample and you would have to copy the contents
of the
> AA-FBO to a standard RTT."  
> 
>>> you have to use glBlitFramebuffer to
>>> copy the multisample FBO to a FBO without multisampling to resolve
the
>>> samples to a texture; this is what osgUtil::RenderStage does when
you
>>> attach an osg::Texture and set the samples to > 1.
> 
> I looked at the code in the osgUtil::RenderStage::DrawInner method but
it
> seems to depend on a call of the
>
osgUtil::RenderStage::setMultisampleResolveFramebufferObject(osg::FrameB
ufferObject*
> fbo) that seems to be never called. Does it means that I have to call
it by
> myself? Maybe I could perform the blit by myselft instead of calling
this
> method? I saw an old post about that (see the post named Setting the
resolve
> FBO for multisampled RTT on 8/27/08)  but it was not clear what to do.


You do not have to call setMultisampleResolveFramebufferObject().

See RenderStage::runCameraSetUp(), which handles cameras with
attachments. In particular, _resolveFbo is set due to multisampling on
line 495 or so. The blit happens on line 910.

-- 
Bryan Thrall
FlightSafety International
bryan.thr...@flightsafety.com
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] problem with blending when using floating point FBO

2009-06-30 Thread Jonathan Richard
>The result is an FBO without multisampling whose buffers are filled by
>combining the multiple samples from the multisample FBO together.

Ok so the FBO multisampling is supported but not directly as it said on
http://www.opengl.org/wiki/GL_EXT_framebuffer_object_More_about_FBOs
"Are multisample Render_To_Texture (RTT) supported? Not directly. You need
GL_EXT_framebuffer_multisample and you would have to copy the contents of
the AA-FBO to a standard RTT."

>> you have to use glBlitFramebuffer to
>> copy the multisample FBO to a FBO without multisampling to resolve the
>> samples to a texture; this is what osgUtil::RenderStage does when you
>> attach an osg::Texture and set the samples to > 1.

I looked at the code in the osgUtil::RenderStage::DrawInner method but it
seems to depend on a call of the
osgUtil::RenderStage::setMultisampleResolveFramebufferObject(osg::FrameBufferObject*
fbo) that seems to be never called. Does it means that I have to call it by
myself? Maybe I could perform the blit by myselft instead of calling this
method? I saw an old post about that (see the post named Setting the resolve
FBO for multisampled RTT on 8/27/08)  but it was not clear what to do.

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


Re: [osg-users] problem with blending when using floating point FBO

2009-06-30 Thread Thrall, Bryan
Jonathan Richard wrote on Tuesday, June 30, 2009 10:36 AM:
>> you have to use glBlitFramebuffer to
>> copy the multisample FBO to a FBO without multisampling to resolve
the
>> samples to a texture; this is what osgUtil::RenderStage does when you
>> attach an osg::Texture and set the samples to > 1.
> 
> I'm not sure about the result of the glBlitFramebuffer
operation...what is
> the result of this copy? Is it the original FBO without beeing
multisampled? 

The result is an FBO without multisampling whose buffers are filled by
combining the multiple samples from the multisample FBO together.

>> If you just want to render to multisample buffers and never need to
read
>> back from those buffers (such as in a shader), you can do it;
otherwise,
>> I think you are out of luck.
> 
> What do you mean by never need to read back from those buffers such as
in a
> shader? 

You can render to multisample buffers, but to use the results in a
shader or read back the data for use on the CPU, you must resolve them
to a non-multisample form (Image or Texture). For example, if you render
your scene to a depth buffer using a FBO, you either attach a
(non-multisample) Texture, or you can attach a multisample RenderBuffer.
If you want to use the latter depth buffer in a shader, you need to blit
it to another FBO with a Texture attached, at which point it will no
longer be multisampled.

> In the release note of osg 2.6.1 it says:
> OpenGL Multi-sample FrameBufferObject support. In fact what does it
means? I
> do not really undestand in what configuration the multisample FBO can
be
> used.  

It means you can render to multisample RenderBuffers. This is useful
because now you can (for example) render to a multisample depth buffer
in FBO and then use that as the depth buffer for the actual scene
render, whereas before if you used an FBO, you could only get a
non-multisample depth buffer (which causes problems when your actual
scene render is multisampled). I haven't tried that particular usage
(and again, I'm not an expert), though.

HTH,
-- 
Bryan Thrall
FlightSafety International
bryan.thr...@flightsafety.com
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] problem with blending when using floating point FBO

2009-06-30 Thread Jonathan Richard
>glReadPixels does not work with a multisample FBO (check glGetError
>after your glReadPixels to see);

yes you are right, I get a GL_INVALID_OPERATION after the call of
glReadPixels

>you have to use glBlitFramebuffer to
>copy the multisample FBO to a FBO without multisampling to resolve the
>samples to a texture; this is what osgUtil::RenderStage does when you
>attach an osg::Texture and set the samples to > 1.

I'm not sure about the result of the glBlitFramebuffer operation...what is
the result of this copy? Is it the original FBO without beeing multisampled?



>If you just want to render to multisample buffers and never need to read
>back from those buffers (such as in a shader), you can do it; otherwise,
>I think you are out of luck.

What do you mean by never need to read back from those buffers *such as in a
shader*?


In the release note of osg 2.6.1 it says: OpenGL Multi-sample
FrameBufferObject support. In fact what does it means? I do not really
undestand in what configuration the multisample FBO can be used.


Thanks for your help
Jonathan
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] problem with blending when using floating point FBO

2009-06-29 Thread Thrall, Bryan
Jonathan Richard wrote on Monday, June 29, 2009 2:19 PM:

>> How did you test that setting both to 4 didn't work?
> 
> This is how I tested it:
...
> // code in MyCameraDrawCallback
> glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
> float* tempbuf32Bits = NULL;
> tempbuf32Bits = new float[500*500];
> glReadPixels(0, 0, WIDTH, HEIGHT, GL_RED, GL_FLOAT, tempbuf32Bits);
> 
> 
> All pixels that I read back are set to -431602080 (not the intended
value).
> If I called camera->attach(osg::Camera::COLOR_BUFFER0,
> offscreenTexture.get(),0,0,false,0,0) it is working (without
multisampling)  

glReadPixels does not work with a multisample FBO (check glGetError
after your glReadPixels to see); you have to use glBlitFramebuffer to
copy the multisample FBO to a FBO without multisampling to resolve the
samples to a texture; this is what osgUtil::RenderStage does when you
attach an osg::Texture and set the samples to > 1.

>> Note that the osg::Texture will not be multisampled because the
multisample
>> RenderBuffers are resolved during the blit to texture.
> 
> You mean that this is no way to get multisample when using my
> osg::TextureRectangle? It so, what are the alternatives? Using a
osg::Image?
> Ideally I need to support 32 bits floating point blending and
multisampling
> in my project. Do you think this is possible?   

In OpenGL, AFAIK, there is no way to get a multisample texture (and
OpenGL doesn't do multisampling when it samples a texture either).

If you just want to render to multisample buffers and never need to read
back from those buffers (such as in a shader), you can do it; otherwise,
I think you are out of luck.

Wish it were different, because I'd love to have the ability to read
multisample textures too!
-- 
Bryan Thrall
FlightSafety International
bryan.thr...@flightsafety.com
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] problem with blending when using floating point FBO

2009-06-29 Thread Jonathan Richard
 >How did you test that setting both to 4 didn't work?

This is how I tested it:

// Reading back the FBO does not work when it is disabled after render -->
set this property of the
// renderStage to false. A workaround is to enable
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, frameBufferObjectID) in the draw
callback
osgViewer::Renderer * renderer =
static_cast(camera->getRenderer());
renderer->getSceneView(0)->getRenderStage()->setDisableFboAfterRender(false);
renderer->getSceneView(1)->getRenderStage()->setDisableFboAfterRender(false);

...

// Camera and texture setup
osg::ref_ptr offscreenTexture = new
osg::TextureRectangle;
offscreenTexture->setTextureSize(500, 500);
offscreenTexture->setSourceFormat(GL_RGBA);
offscreenTexture->setSourceType(GL_FLOAT);
offscreenTexture->setInternalFormat(GL_FLOAT_RGBA32_NV);

camera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);
camera->attach(osg::Camera::COLOR_BUFFER0,
offscreenTexture.get(),0,0,false,4,4);
camera->setFinalDrawCallback(new MyCameraDrawCallback(precision));

...

// the color is set by using a fragment shader and a uniform variable
osg::Vec4 geodeColorf = osg::Vec4(56.13,0,0,1);
osg::ref_ptr redColor = new osg::Uniform( "Color",
geodeColorf);
stateset->addUniform(redColor.get());
stateset->setAttributeAndModes( program.get(), osg::StateAttribute::ON |
osg::StateAttribute::OVERRIDE );
aDrawable->setStateSet(stateset);

// Code in my fragment shader
uniform vec4 Color;
void main (void)
{
gl_FragColor = Color;
}

...

// code in MyCameraDrawCallback
glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
float* tempbuf32Bits = NULL;
tempbuf32Bits = new float[500*500];
glReadPixels(0, 0, WIDTH, HEIGHT, GL_RED, GL_FLOAT, tempbuf32Bits);


All pixels that I read back are set to -431602080 (not the intended value).
If I called camera->attach(osg::Camera::COLOR_BUFFER0,
offscreenTexture.get(),0,0,false,0,0) it is working (without multisampling)

>Note that the osg::Texture will not be multisampled because the multisample
>RenderBuffers are resolved during the blit to texture.

You mean that this is no way to get multisample when using my
osg::TextureRectangle? It so, what are the alternatives? Using a osg::Image?
Ideally I need to support 32 bits floating point blending and multisampling
in my project. Do you think this is possible?

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


Re: [osg-users] problem with blending when using floating point FBO

2009-06-26 Thread Thrall, Bryan
Jonathan Richard wrote on Friday, June 26, 2009 3:30 PM:

> Hi, I set the color by using a fragment shader and the 32 bits
floating point
> blending seems to be working now. 
> 
> I would like to use multisampling in my FBO. How can I configure that?
Is it
> only by setting the method: 
> 
> Camera::attach(BufferComponent buffer, osg::Texture* texture, unsigned
int
> level, unsigned int face, bool mipMapGeneration, unsigned int
> multisampleSamples, unsigned int multisampleColorSamples) ?  
> 
> What is the difference between the parameter multisampleSamples and
> multisampleColorSamples? 
> 
> I tried to set both at 4 but that did not work.

I'm not an expert, but I recently dug into FBOs, so hopefully I can
help. Yes, that's the way to configure multisample FBOs.

See
http://www.opengl.org/registry/specs/NV/framebuffer_multisample_coverage
.txt for the difference between multisampleSampls and
multisampleColorSamples

How did you test that setting both to 4 didn't work? Note that the
osg::Texture will not be multisampled because the multisample
RenderBuffers are resolved during the blit to texture.

> On Tue, May 26, 2009 at 11:09 AM, Jonathan Richard
>  wrote: 
> 
> 
>   Ok thank you for the advice. I'm not very familiar with the
shader
> programming yet, but I'm suppose to get into it soon. The problem that
I see
> is how to get access to the facet from the shader. If I'm into a
fragment
> shader I'll probably have no idea from which facet come each fragment.
Is it
> right? Maybe I have to use a geometry shader? Or maybe I can perform
the
> blending by myself into a fragment shader? You can tell me if you have
any
> clue about that.  
> 
> 
>   I'll give you a little more of precision about my problem. The
blending
> seems to be working when the alpha of the front facet is different
from 1.
> For exemple if I define  
> 
> 
> 
>   Rd = (2e-3,  0.0,   0.0,   1.0) // RGBA
> 
>   Rs = (6e-9, 0.0,   0.0,   0.4) //RGBA
> 
> 
> 
> 
>   In theory:
> 
> 
> 
> 
>   Rd = Rs + (1-As)Rd
> 
> 
> 
>   Rd = 6e-9 + (1-0.4)*2e-3 = 1.26e-3
> 
> 
> 
>   In practice I get: 0.001259
> 
> 
> 
> 
>   For now, the problem seems to occur only when As =1.
> 
> 
> 
> 
>   Thanks,
>   Jonathan
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
>   2009/5/26 J.P. Delport 
> 
> 
>   Hi,
> 
> 
>   Jonathan Richard wrote:
>   >
>   > |// Tell to sort the mesh before displaying it
>   > |AFAIK OSG does not sort at the triangle level, there
is an option to
>   > make the sorting happen at a primitive level, but I
think the default is
>   > sorting on bounding sphere.
>   >
>   > I take this line (and the comment) from the
osgblendequation example.
>   > You think that I should not do this call?
> 
> 
>   No, the call is fine. What I'm saying is that blending
and transparency
>   is (depending on the blend equation) dependent on the
order in which
>   things are rendered, so one cannot assume (when making
off-line
>   calculations) that all the geometry is perfectly sorted
(think e.g.
>   intersecting objects).
> 
> 
>   >
>   > |offscreenTexture->setSourceType( GL_UNSIGNED_BYTE);
>   > |Should this not also be GL_FLOAT?
>   >
>   > yes sorry it is a "copy paste" error. I call
>   > offscreenTexture->setSourceType(GL_FLOAT) and
>   >
offscreenTexture->setInternalFormat(GL_FLOAT_RGBA32_NV).
>   >
>   > |I can also not see from the code if OpenGL lighting
is enabled. Do you
>   > disable lighting in your app?
>   >
>   > No I wasn't but I disable it now and I see no change
in the result
> 
> 
>   OK.
> 
>   I'm running out of ideas to try help. I cannot from just
reading the
>   code see any more problems. I'd suggest using the ARB
modes and trying a
>   few other machines. I'll also try find some of our test
code for float
>   blending.
> 
>   Another option is to use shaders to explicitly set the
colours of two
>   facets (to eliminate any fixed function interference)
and see how they
>   blend.
> 
>   jp
> 
> 
> 
>   >
>   >
>   > Here a update of the code with the correction in
yellow:
>   >
>   >
>   > The colors are attached by setting the ColorArray of
the drawables of
>   > each Geode like this:
>   >
>   >
>   >
>   > int geodesNb = m_entityVectorOfGeodeVector[0].size();
>   >
>   >
>   >
>   > osg::Geode* aGeode;
>   >
>   > in

Re: [osg-users] problem with blending when using floating point FBO

2009-06-26 Thread Jonathan Richard
Hi, I set the color by using a fragment shader and the 32 bits floating
point blending seems to be working now.

I would like to use multisampling in my FBO. How can I configure that? Is it
only by setting the method:

Camera::attach(BufferComponent buffer, osg::Texture* texture, unsigned int
level, unsigned int face, bool mipMapGeneration, unsigned int
multisampleSamples, unsigned int multisampleColorSamples) ?

What is the difference between the parameter multisampleSamples and
multisampleColorSamples?

I tried to set both at 4 but that did not work.

Tanks
Jonathan




On Tue, May 26, 2009 at 11:09 AM, Jonathan Richard <
jonathan.richa...@gmail.com> wrote:

> Ok thank you for the advice. I'm not very familiar with the shader
> programming yet, but I'm suppose to get into it soon. The problem that I see
> is how to get access to the facet from the shader. If I'm into a fragment
> shader I'll probably have no idea from which facet come each fragment. Is it
> right? Maybe I have to use a geometry shader? Or maybe I can perform the
> blending by myself into a fragment shader? You can tell me if you have any
> clue about that.
>
>
> I'll give you a little more of precision about my problem. The blending
> seems to be working when the alpha of the front facet is different from 1.
> For exemple if I define
>
> Rd = (2e-3,  0.0,   0.0,   1.0) // RGBA
>
> Rs = (6e-9, 0.0,   0.0,   0.4) //RGBA
>
>
> In theory:
>
> Rd = Rs + (1-As)Rd
>
> Rd = 6e-9 + (1-0.4)*2e-3 = 1.26e-3
>
> In practice I get: 0.001259
>
>
> For now, the problem seems to occur only when As =1.
>
>
> Thanks,
> Jonathan
>
>
>
>
>
>
>
>
>
> 2009/5/26 J.P. Delport 
>
> Hi,
>>
>> Jonathan Richard wrote:
>> >
>> > |// Tell to sort the mesh before displaying it
>> > |AFAIK OSG does not sort at the triangle level, there is an option to
>> > make the sorting happen at a primitive level, but I think the default is
>> > sorting on bounding sphere.
>> >
>> > I take this line (and the comment) from the osgblendequation example.
>> > You think that I should not do this call?
>>
>> No, the call is fine. What I'm saying is that blending and transparency
>> is (depending on the blend equation) dependent on the order in which
>> things are rendered, so one cannot assume (when making off-line
>> calculations) that all the geometry is perfectly sorted (think e.g.
>> intersecting objects).
>>
>> >
>> > |offscreenTexture->setSourceType( GL_UNSIGNED_BYTE);
>> > |Should this not also be GL_FLOAT?
>> >
>> > yes sorry it is a "copy paste" error. I call
>> > offscreenTexture->setSourceType(GL_FLOAT) and
>> > offscreenTexture->setInternalFormat(GL_FLOAT_RGBA32_NV).
>> >
>> > |I can also not see from the code if OpenGL lighting is enabled. Do you
>> > disable lighting in your app?
>> >
>> > No I wasn't but I disable it now and I see no change in the result
>>
>> OK.
>>
>> I'm running out of ideas to try help. I cannot from just reading the
>> code see any more problems. I'd suggest using the ARB modes and trying a
>> few other machines. I'll also try find some of our test code for float
>> blending.
>>
>> Another option is to use shaders to explicitly set the colours of two
>> facets (to eliminate any fixed function interference) and see how they
>> blend.
>>
>> jp
>>
>>
>> >
>> >
>> > Here a update of the code with the correction in yellow:
>> >
>> >
>> > The colors are attached by setting the ColorArray of the drawables of
>> > each Geode like this:
>> >
>> >
>> >
>> > int geodesNb = m_entityVectorOfGeodeVector[0].size();
>> >
>> >
>> >
>> > osg::Geode* aGeode;
>> >
>> > int drawablesNb;
>> >
>> > osg::Drawable* aDrawable;
>> >
>> > osg::Geometry* aDrawableGeometry;
>> >
>> > osg::Vec4Array* aDrawableColor;
>> >
>> > for (int geodesLoop = 0; geodesLoop < geodesNb; geodesLoop++)
>> >
>> > {
>> >
>> > aGeode = m_entityVectorOfGeodeVector[0][geodesLoop];
>> >
>> > drawablesNb = aGeode->getNumDrawables();
>> >
>> >
>> >
>> > // Update color for each facet (drawable) of a geode
>> >
>> > for (int i = 0; i < drawablesNb; i++)
>> >
>> > {
>> >
>> > aDrawable = aGeode->getDrawable(i);
>> >
>> > aDrawable->dirtyDisplayList();  //
>> > Force color update on next draw
>> >
>> >
>> >
>> > aDrawableGeometry =
>> > dynamic_cast(aDrawable);
>> >
>> >
>> >
>> > aDrawableColor =
>> > dynamic_cast(aDrawableGeometry>getColorArray());
>> >
>> >
>> >
>> >
>> > std::string geodeName=aGeode->getName();
>> >
>> >
>> >
>> > if(!geodeName.compare("p1"))
>> >
>> > {
>> >
>> > // Set the facet color
>> > and transparency (0=invisible)
>> >
>> > (*aDrawableColor)[0] =
>> > m_facet1Color;
>> >
>> >

Re: [osg-users] problem with blending when using floating point FBO

2009-05-26 Thread Jonathan Richard
Ok thank you for the advice. I'm not very familiar with the shader
programming yet, but I'm suppose to get into it soon. The problem that I see
is how to get access to the facet from the shader. If I'm into a fragment
shader I'll probably have no idea from which facet come each fragment. Is it
right? Maybe I have to use a geometry shader? Or maybe I can perform the
blending by myself into a fragment shader? You can tell me if you have any
clue about that.


I'll give you a little more of precision about my problem. The blending
seems to be working when the alpha of the front facet is different from 1.
For exemple if I define

Rd = (2e-3,  0.0,   0.0,   1.0) // RGBA

Rs = (6e-9, 0.0,   0.0,   0.4) //RGBA


In theory:

Rd = Rs + (1-As)Rd

Rd = 6e-9 + (1-0.4)*2e-3 = 1.26e-3

In practice I get: 0.001259


For now, the problem seems to occur only when As =1.


Thanks,
Jonathan









2009/5/26 J.P. Delport 

> Hi,
>
> Jonathan Richard wrote:
> >
> > |// Tell to sort the mesh before displaying it
> > |AFAIK OSG does not sort at the triangle level, there is an option to
> > make the sorting happen at a primitive level, but I think the default is
> > sorting on bounding sphere.
> >
> > I take this line (and the comment) from the osgblendequation example.
> > You think that I should not do this call?
>
> No, the call is fine. What I'm saying is that blending and transparency
> is (depending on the blend equation) dependent on the order in which
> things are rendered, so one cannot assume (when making off-line
> calculations) that all the geometry is perfectly sorted (think e.g.
> intersecting objects).
>
> >
> > |offscreenTexture->setSourceType( GL_UNSIGNED_BYTE);
> > |Should this not also be GL_FLOAT?
> >
> > yes sorry it is a "copy paste" error. I call
> > offscreenTexture->setSourceType(GL_FLOAT) and
> > offscreenTexture->setInternalFormat(GL_FLOAT_RGBA32_NV).
> >
> > |I can also not see from the code if OpenGL lighting is enabled. Do you
> > disable lighting in your app?
> >
> > No I wasn't but I disable it now and I see no change in the result
>
> OK.
>
> I'm running out of ideas to try help. I cannot from just reading the
> code see any more problems. I'd suggest using the ARB modes and trying a
> few other machines. I'll also try find some of our test code for float
> blending.
>
> Another option is to use shaders to explicitly set the colours of two
> facets (to eliminate any fixed function interference) and see how they
> blend.
>
> jp
>
>
> >
> >
> > Here a update of the code with the correction in yellow:
> >
> >
> > The colors are attached by setting the ColorArray of the drawables of
> > each Geode like this:
> >
> >
> >
> > int geodesNb = m_entityVectorOfGeodeVector[0].size();
> >
> >
> >
> > osg::Geode* aGeode;
> >
> > int drawablesNb;
> >
> > osg::Drawable* aDrawable;
> >
> > osg::Geometry* aDrawableGeometry;
> >
> > osg::Vec4Array* aDrawableColor;
> >
> > for (int geodesLoop = 0; geodesLoop < geodesNb; geodesLoop++)
> >
> > {
> >
> > aGeode = m_entityVectorOfGeodeVector[0][geodesLoop];
> >
> > drawablesNb = aGeode->getNumDrawables();
> >
> >
> >
> > // Update color for each facet (drawable) of a geode
> >
> > for (int i = 0; i < drawablesNb; i++)
> >
> > {
> >
> > aDrawable = aGeode->getDrawable(i);
> >
> > aDrawable->dirtyDisplayList();  //
> > Force color update on next draw
> >
> >
> >
> > aDrawableGeometry =
> > dynamic_cast(aDrawable);
> >
> >
> >
> > aDrawableColor =
> > dynamic_cast(aDrawableGeometry>getColorArray());
> >
> >
> >
> >
> > std::string geodeName=aGeode->getName();
> >
> >
> >
> > if(!geodeName.compare("p1"))
> >
> > {
> >
> > // Set the facet color
> > and transparency (0=invisible)
> >
> > (*aDrawableColor)[0] =
> > m_facet1Color;
> >
> >
> >
> > …
> >
> > }
> >
> > }
> >
> > }
> >
> >
> >
> > Where the /entityVectorOfGeodeVector/ is the list of visible geodes that
> > I maintain by using a cull callback.
> >
> >
> >
> >
> >
> > Here a snapshot of my code to setup the viewer and the camera.
> >
> >
> >
> > m_viewer = new osgViewer::Viewer;
> >
> > m_viewer->setUpViewOnSingleScreen();
> >
> > osg::Camera *camera = m_viewer->getCamera();
> >
> >
> >
> > osgViewer::Renderer * renderer =
> > static_cast(camera->getRenderer());
> >
> > // Reading back the FBO does not work when it is disabled after render
> > --> set this property of the
> >
> > // renderStage to false.
> >
> >
> renderer->getSceneView(0)->getRenderStage()->setDisableFboAfterRender(false);
> >
> >
> renderer->getSceneView(1)->getRenderStage()->setDisableFboAfter

Re: [osg-users] problem with blending when using floating point FBO

2009-05-26 Thread J.P. Delport
Hi,

Jonathan Richard wrote:
> 
> |// Tell to sort the mesh before displaying it
> |AFAIK OSG does not sort at the triangle level, there is an option to 
> make the sorting happen at a primitive level, but I think the default is 
> sorting on bounding sphere.
> 
> I take this line (and the comment) from the osgblendequation example. 
> You think that I should not do this call?

No, the call is fine. What I'm saying is that blending and transparency
is (depending on the blend equation) dependent on the order in which
things are rendered, so one cannot assume (when making off-line
calculations) that all the geometry is perfectly sorted (think e.g.
intersecting objects).

> 
> |offscreenTexture->setSourceType( GL_UNSIGNED_BYTE);
> |Should this not also be GL_FLOAT?
> 
> yes sorry it is a "copy paste" error. I call 
> offscreenTexture->setSourceType(GL_FLOAT) and 
> offscreenTexture->setInternalFormat(GL_FLOAT_RGBA32_NV).
> 
> |I can also not see from the code if OpenGL lighting is enabled. Do you 
> disable lighting in your app?
> 
> No I wasn't but I disable it now and I see no change in the result

OK.

I'm running out of ideas to try help. I cannot from just reading the
code see any more problems. I'd suggest using the ARB modes and trying a
few other machines. I'll also try find some of our test code for float
blending.

Another option is to use shaders to explicitly set the colours of two
facets (to eliminate any fixed function interference) and see how they
blend.

jp


> 
> 
> Here a update of the code with the correction in yellow:
> 
> 
> The colors are attached by setting the ColorArray of the drawables of 
> each Geode like this:
> 
>  
> 
> int geodesNb = m_entityVectorOfGeodeVector[0].size();
> 
>  
> 
> osg::Geode* aGeode;
> 
> int drawablesNb;
> 
> osg::Drawable* aDrawable;
> 
> osg::Geometry* aDrawableGeometry;
> 
> osg::Vec4Array* aDrawableColor;
> 
> for (int geodesLoop = 0; geodesLoop < geodesNb; geodesLoop++)
> 
> {
> 
> aGeode = m_entityVectorOfGeodeVector[0][geodesLoop];
> 
> drawablesNb = aGeode->getNumDrawables();
> 
>  
> 
> // Update color for each facet (drawable) of a geode
> 
> for (int i = 0; i < drawablesNb; i++)
> 
> {
> 
> aDrawable = aGeode->getDrawable(i);
> 
> aDrawable->dirtyDisplayList();  // 
> Force color update on next draw
> 
>  
> 
> aDrawableGeometry = 
> dynamic_cast(aDrawable);
> 
>  
> 
> aDrawableColor = 
> dynamic_cast(aDrawableGeometry>getColorArray()); 
> 
> 
>
> 
> std::string geodeName=aGeode->getName();
> 
>
> 
> if(!geodeName.compare("p1"))
> 
> {
> 
> // Set the facet color 
> and transparency (0=invisible)
> 
> (*aDrawableColor)[0] = 
> m_facet1Color;
> 
>
> 
> …
> 
> }
> 
> }
> 
> }
> 
>  
> 
> Where the /entityVectorOfGeodeVector/ is the list of visible geodes that 
> I maintain by using a cull callback.
> 
>  
> 
>  
> 
> Here a snapshot of my code to setup the viewer and the camera.
> 
>  
> 
> m_viewer = new osgViewer::Viewer;
> 
> m_viewer->setUpViewOnSingleScreen();
> 
> osg::Camera *camera = m_viewer->getCamera();
> 
>
> 
> osgViewer::Renderer * renderer = 
> static_cast(camera->getRenderer());
> 
> // Reading back the FBO does not work when it is disabled after render 
> --> set this property of the
> 
> // renderStage to false.
> 
> renderer->getSceneView(0)->getRenderStage()->setDisableFboAfterRender(false);
> 
> renderer->getSceneView(1)->getRenderStage()->setDisableFboAfterRender(false);
> 
>
> 
> m_scene=new osg::Group();
> 
>  
> 
> std::string modelName="C:\\_JO\\LTI\\SIS\\Models\\test_IR\\carre.flt";
> 
>
> 
> LoadModel(modelName); // call m_viewer->SetSceneData
> 
>  
> 
> osg::StateSet* state = m_scene->getOrCreateStateSet();
> 
>  
> 
> // Disable Lighting effects
> 
> state->setMode(GL_LIGHTING, osg::StateAttribute::OVERRIDE | 
> osg::StateAttribute::OFF);
> 
>  
> 
> // Enable transparency
> 
> state->setMode(GL_BLEND, osg::StateAttribute::OVERRIDE | 
> osg::StateAttribute::ON);
> 
> // Tell to sort the mesh before displaying it
> 
> state->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
> 
>
> 
> // Set the blend function (related to the transparency)
> 
> osg::BlendFunc* selectedBlendFunction = new osg::BlendFunc();
> 
> selectedBlendFunction->setDestination(GL_ONE_MINUS_SRC_ALPHA);
> 
> selectedBlendFunction->setSource(GL_ONE);
> 
>
> 
> state->setAttribute(selectedBlendFunction, osg

Re: [osg-users] problem with blending when using floating point FBO

2009-05-26 Thread J.P. Delport

Hi,

I've quickly looked through the code, two lines bugged me:

// Tell to sort the mesh before displaying it

AFAIK OSG does not sort at the triangle level, there is an option to 
make the sorting happen at a primitive level, but I think the default is 
sorting on bounding sphere.


offscreenTexture->setSourceType( GL_UNSIGNED_BYTE);

Should this not also be GL_FLOAT?

---

I can also not see from the code if OpenGL lighting is enabled. Do you 
disable lighting in your app?


jp



jonathan.richa...@gmail.com wrote:

Hi,

The colors are attached by setting the ColorArray of the drawables of 
each Geode like this:


int geodesNb = m_entityVectorOfGeodeVector[0].size();

osg::Geode* aGeode;
int drawablesNb;
osg::Drawable* aDrawable;
osg::Geometry* aDrawableGeometry;
osg::Vec4Array* aDrawableColor;
for (int geodesLoop = 0; geodesLoop < geodesNb; geodesLoop++)
{
aGeode = m_entityVectorOfGeodeVector[0][geodesLoop];
drawablesNb = aGeode->getNumDrawables();

// Update color for each facet (drawable) of a geode
for (int i = 0; i < drawablesNb; i++)
{
aDrawable = aGeode->getDrawable(i);
aDrawable->dirtyDisplayList(); // Force color update on next draw

aDrawableGeometry = dynamic_cast(aDrawable);

aDrawableColor = 
dynamic_cast(aDrawableGeometry>getColorArray());


std::string geodeName=aGeode->getName();

if(!geodeName.compare("p1"))
{
// Set the facet color and transparency (0=invisible)
(*aDrawableColor)[0] = m_facet1Color;

…
}
}
}

Where the entityVectorOfGeodeVector is the list of visible geodes that I 
maintain by using a cull callback.



Here a snapshot of my code to setup the viewer and the camera.

m_viewer = new osgViewer::Viewer;
m_viewer->setUpViewOnSingleScreen();
osg::Camera *camera = m_viewer->getCamera();

osgViewer::Renderer * renderer = 
static_cast(camera->getRenderer());
// Reading back the FBO does not work when it is disabled after render 
--> set this property of the

// renderStage to false.
renderer->getSceneView(0)->getRenderStage()->setDisableFboAfterRender(false);
renderer->getSceneView(1)->getRenderStage()->setDisableFboAfterRender(false);

m_scene=new osg::Group();

std::string modelName="C:\\_JO\\LTI\\SIS\\Models\\test_IR\\carre.flt";

LoadModel(modelName); // call m_viewer->SetSceneData

osg::StateSet* state = m_scene->getOrCreateStateSet();

// Enable transparency
state->setMode(GL_BLEND, osg::StateAttribute::OVERRIDE | 
osg::StateAttribute::ON);

// Tell to sort the mesh before displaying it
state->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);

// Set the blend function (related to the transparency)
osg::BlendFunc* selectedBlendFunction = new osg::BlendFunc();
selectedBlendFunction->setDestination(GL_ONE_MINUS_SRC_ALPHA);
selectedBlendFunction->setSource(GL_ONE);

state->setAttribute(selectedBlendFunction, osg::StateAttribute::OVERRIDE 
| osg::StateAttribute::ON);


osg::Image* offscreenImage = new osg::Image;
osg::ref_ptr offscreenTexture = new 
osg::TextureRectangle;


// Allocate the image
offscreenImage->allocateImage(WIDTH, HEIGHT, 1, GL_RGBA, GL_FLOAT);

// Set the 32 bits texture
offscreenTexture->setImage(offscreenImage);
offscreenTexture->setSourceFormat(GL_RGBA);
offscreenTexture->setSourceType( GL_UNSIGNED_BYTE);
offscreenTexture->setTextureSize(WIDTH, HEIGHT);

// Initialize the background
camera->setClearColor(osg::Vec4f(0.0f,0.0f,0.0f,1.0f));

camera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);
camera->attach(osg::Camera::COLOR_BUFFER0,offscreenTexture.get());
camera->setFinalDrawCallback(new MyCameraDrawCallback(precision));

m_viewer->realize();

// Set the colors R G B A
m_facet1Color = osg::Vec4( 0.2, 0.0, 0.0, 1.0 );
m_facet2Color = osg::Vec4( 0, 0.1, 0.0, 1.0 );
m_facet3Color = osg::Vec4( 4e-6, 0.0, 0.1, 1.0 );
m_facet4Color = osg::Vec4( 5e-5, 0.5, 0.5, 1.0 );
m_facet5Color = osg::Vec4( 6e-9, 0.1, 0.0, 1);

…

// Code of my camera Drawcallback
void MyCameraDrawCallback::operator() (osg::RenderInfo& renderInfo) const
{
glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
m_image->readPixels(0,0,WIDTH,HEIGHT, GL_RGBA,GL_FLOAT);
}

I hope it can help you to help me ;) I could provide you my testing 
project is you want.

Thank you
Jonathan




On 2009-05-25 10:59am, "J.P. Delport"  wrote:
 > Hi,
 >
 >
 >
 > posting some code would prob be best. How are you attaching the 
colours to your "facets"? Texture? Shader?

 >
 >
 >
 > A few things on my checklist normally:
 >
 > Lighting off
 >
 > Background
 >
 > Render order
 >
 > MRT enabled
 >
 > gl_FragData in shaders
 >
 > Texture mode
 >
 >
 >
 > jp
 >
 >
 >
 > jonathan.richa...@gmail.com wrote:
 >
 >
 > Hi,
 >
 >
 >
 > my card is a Nvidia geforce 8800 gtx: 
http://www.nvidia.com/page/8800_tech_specs.html

 >
 >
 >
 >
 >
 > It say "32-bit per component floating point texture filtering and 
blending".

 >
 >
 >
 > Jonathan
 >
 >
 >
 >
 >
 > On 2009-05-25 10:26am, "J.P. Delport" jpdelp...@csir.co.za> wrote:
 >
 >  > Hi,
 >
 >  >
 >
 >  >
 >
 >  >
 >
 >  > are you sure your hardware supports 32-bit blen

Re: [osg-users] problem with blending when using floating point FBO

2009-05-25 Thread Jonathan . Richard0

Hi,

The colors are attached by setting the ColorArray of the drawables of each  
Geode like this:


int geodesNb = m_entityVectorOfGeodeVector[0].size();

osg::Geode* aGeode;
int drawablesNb;
osg::Drawable* aDrawable;
osg::Geometry* aDrawableGeometry;
osg::Vec4Array* aDrawableColor;
for (int geodesLoop = 0; geodesLoop < geodesNb; geodesLoop++)
{
aGeode = m_entityVectorOfGeodeVector[0][geodesLoop];
drawablesNb = aGeode->getNumDrawables();

// Update color for each facet (drawable) of a geode
for (int i = 0; i < drawablesNb; i++)
{
aDrawable = aGeode->getDrawable(i);
aDrawable->dirtyDisplayList(); // Force color update on next draw

aDrawableGeometry = dynamic_cast(aDrawable);

aDrawableColor =  
dynamic_cast(aDrawableGeometry>getColorArray());


std::string geodeName=aGeode->getName();

if(!geodeName.compare("p1"))
{
// Set the facet color and transparency (0=invisible)
(*aDrawableColor)[0] = m_facet1Color;

…
}
}
}

Where the entityVectorOfGeodeVector is the list of visible geodes that I  
maintain by using a cull callback.



Here a snapshot of my code to setup the viewer and the camera.

m_viewer = new osgViewer::Viewer;
m_viewer->setUpViewOnSingleScreen();
osg::Camera *camera = m_viewer->getCamera();

osgViewer::Renderer * renderer =  
static_cast(camera->getRenderer());
// Reading back the FBO does not work when it is disabled after render -->  
set this property of the

// renderStage to false.
renderer->getSceneView(0)->getRenderStage()->setDisableFboAfterRender(false);
renderer->getSceneView(1)->getRenderStage()->setDisableFboAfterRender(false);

m_scene=new osg::Group();

std::string modelName="C:\\_JO\\LTI\\SIS\\Models\\test_IR\\carre.flt";

LoadModel(modelName); // call m_viewer->SetSceneData

osg::StateSet* state = m_scene->getOrCreateStateSet();

// Enable transparency
state->setMode(GL_BLEND, osg::StateAttribute::OVERRIDE |  
osg::StateAttribute::ON);

// Tell to sort the mesh before displaying it
state->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);

// Set the blend function (related to the transparency)
osg::BlendFunc* selectedBlendFunction = new osg::BlendFunc();
selectedBlendFunction->setDestination(GL_ONE_MINUS_SRC_ALPHA);
selectedBlendFunction->setSource(GL_ONE);

state->setAttribute(selectedBlendFunction, osg::StateAttribute::OVERRIDE |  
osg::StateAttribute::ON);


osg::Image* offscreenImage = new osg::Image;
osg::ref_ptr offscreenTexture = new  
osg::TextureRectangle;


// Allocate the image
offscreenImage->allocateImage(WIDTH, HEIGHT, 1, GL_RGBA, GL_FLOAT);

// Set the 32 bits texture
offscreenTexture->setImage(offscreenImage);
offscreenTexture->setSourceFormat(GL_RGBA);
offscreenTexture->setSourceType( GL_UNSIGNED_BYTE);
offscreenTexture->setTextureSize(WIDTH, HEIGHT);

// Initialize the background
camera->setClearColor(osg::Vec4f(0.0f,0.0f,0.0f,1.0f));

camera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);
camera->attach(osg::Camera::COLOR_BUFFER0,offscreenTexture.get());
camera->setFinalDrawCallback(new MyCameraDrawCallback(precision));

m_viewer->realize();

// Set the colors R G B A
m_facet1Color = osg::Vec4( 0.2, 0.0, 0.0, 1.0 );
m_facet2Color = osg::Vec4( 0, 0.1, 0.0, 1.0 );
m_facet3Color = osg::Vec4( 4e-6, 0.0, 0.1, 1.0 );
m_facet4Color = osg::Vec4( 5e-5, 0.5, 0.5, 1.0 );
m_facet5Color = osg::Vec4( 6e-9, 0.1, 0.0, 1);

…

// Code of my camera Drawcallback
void MyCameraDrawCallback::operator() (osg::RenderInfo& renderInfo) const
{
glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
m_image->readPixels(0,0,WIDTH,HEIGHT, GL_RGBA,GL_FLOAT);
}

I hope it can help you to help me ;) I could provide you my testing project  
is you want.

Thank you
Jonathan




On 2009-05-25 10:59am, "JP Delport"  wrote:

Hi,




posting some code would prob be best. How are you attaching the colours  
to your "facets"? Texture? Shader?





A few things on my checklist normally:



Lighting off



Background



Render order



MRT enabled



gl_FragData in shaders



Texture mode





jp





jonathan.richa...@gmail.com wrote:




Hi,




my card is a Nvidia geforce 8800 gtx:  
http://www.nvidia.com/page/8800_tech_specs.html






It say "32-bit per component floating point texture filtering and  
blending".





Jonathan







On 2009-05-25 10:26am, "JP Delport" jpdelp...@csir.co.za> wrote:



> Hi,



>



>



>


> are you sure your hardware supports 32-bit blending? What card/drivers  
are you using?



>



>



>


> We've tried identifying the effective resolution of blending on various  
cards. I don't have the results handy, will try to get them.



>



>



>



> jp



>



>



>



> jonathan.richa...@gmail.com wrote:



>



>


> Hi, I'm using the osgViewer ::Viewer to perform floating point  
rendering in an FBO and I have a problem when blending is enabled. My  
blending function is defined by GL_ONE_MINUS_SRC_ALPHA for destination  
and GL_ONE for source. The problem occurs when I draw a facet with a  
small color in front of a facet with a big color. For example let

Re: [osg-users] problem with blending when using floating point FBO

2009-05-25 Thread J.P. Delport

Hi,

posting some code would prob be best. How are you attaching the colours 
to your "facets"? Texture? Shader?


A few things on my checklist normally:
Lighting off
Background
Render order
MRT enabled
gl_FragData in shaders
Texture mode

jp

jonathan.richa...@gmail.com wrote:

Hi,

my card is a Nvidia geforce 8800 gtx: 
http://www.nvidia.com/page/8800_tech_specs.html



It say "32-bit per component floating point texture filtering and 
blending".


Jonathan


On 2009-05-25 10:26am, "J.P. Delport"  wrote:
 > Hi,
 >
 >
 >
 > are you sure your hardware supports 32-bit blending? What 
card/drivers are you using?

 >
 >
 >
 > We've tried identifying the effective resolution of blending on 
various cards. I don't have the results handy, will try to get them.

 >
 >
 >
 > jp
 >
 >
 >
 > jonathan.richa...@gmail.com wrote:
 >
 >
 > Hi, I’m using the osgViewer ::Viewer to perform floating point 
rendering in an FBO and I have a problem when blending is enabled. My 
blending function is defined by GL_ONE_MINUS_SRC_ALPHA for destination 
and GL_ONE for source. The problem occurs when I draw a facet with a 
small color in front of a facet with a big color. For example lets define:

 >
 >
 >
 > Rd = (0.2, 0.0, 0.0, 1.0) // RGBA
 >
 > Rs = (6e-9, 0.0, 0.0, 1.0) //RGBA
 >
 >
 >
 > In theory I was expecting to get:
 >
 >
 >
 > Rd = Rs + (1-As)Rd
 >
 > Rd = 6e-9 + (1-1)*0.2
 >
 > Rd = 6e-9 +(0)*0.2 = 6e-9
 >
 >
 >
 > but I get1.7920927e-8
 >
 >
 >
 > Does someone have an idea what is going on? I currently using the 
GL_FLOAT_RGBA32_NV format as internal format of my attached texture. I 
have also tried the GL_FLOAT_RGBA16_NV, GL_RGBA32F_ARB, GL_RGBA16F_ARB 
and I always get the same kind of results. Tell me if you need part of 
my code in order to help me.

 >
 >
 >
 >
 >
 > Thank you
 >
 > Jonathan
 >
 >
 >
 >
 >
 > 
 >
 >
 >
 > ___
 >
 > 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.  MailScanner thanks Transtec 
Computers for their support.

 >
 >
 >
 > ___
 >
 > 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


--
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.  MailScanner thanks Transtec Computers for their support.


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


Re: [osg-users] problem with blending when using floating point FBO

2009-05-25 Thread Jonathan . Richard0

Hi,

my card is a Nvidia geforce 8800 gtx:  
http://www.nvidia.com/page/8800_tech_specs.html



It say "32-bit per component floating point texture filtering and blending".

Jonathan


On 2009-05-25 10:26am, "JP Delport"  wrote:

Hi,




are you sure your hardware supports 32-bit blending? What card/drivers  
are you using?




We've tried identifying the effective resolution of blending on various  
cards. I don't have the results handy, will try to get them.





jp





jonathan.richa...@gmail.com wrote:



Hi, I'm using the osgViewer ::Viewer to perform floating point rendering  
in an FBO and I have a problem when blending is enabled. My blending  
function is defined by GL_ONE_MINUS_SRC_ALPHA for destination and GL_ONE  
for source. The problem occurs when I draw a facet with a small color in  
front of a facet with a big color. For example lets define:





Rd = (0.2, 0.0, 0.0, 1.0) // RGBA



Rs = (6e-9, 0.0, 0.0, 1.0) //RGBA





In theory I was expecting to get:





Rd = Rs + (1-As)Rd



Rd = 6e-9 + (1-1)*0.2



Rd = 6e-9 +(0)*0.2 = 6e-9





but I get1.7920927e-8




Does someone have an idea what is going on? I currently using the  
GL_FLOAT_RGBA32_NV format as internal format of my attached texture. I  
have also tried the GL_FLOAT_RGBA16_NV, GL_RGBA32F_ARB, GL_RGBA16F_ARB  
and I always get the same kind of results. Tell me if you need part of my  
code in order to help me.







Thank you



Jonathan













___



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. MailScanner thanks Transtec  
Computers for their support.





___



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] problem with blending when using floating point FBO

2009-05-25 Thread J.P. Delport

Hi,

are you sure your hardware supports 32-bit blending? What card/drivers 
are you using?


We've tried identifying the effective resolution of blending on various 
cards. I don't have the results handy, will try to get them.


jp

jonathan.richa...@gmail.com wrote:
Hi, I’m using the osgViewer ::Viewer to perform floating point rendering 
in an FBO and I have a problem when blending is enabled. My blending 
function is defined by GL_ONE_MINUS_SRC_ALPHA for destination and GL_ONE 
for source. The problem occurs when I draw a facet with a small color in 
front of a facet with a big color. For example lets define:


Rd = (0.2, 0.0, 0.0, 1.0) // RGBA
Rs = (6e-9, 0.0, 0.0, 1.0) //RGBA

In theory I was expecting to get:

Rd = Rs + (1-As)Rd
Rd = 6e-9 + (1-1)*0.2
Rd = 6e-9 +(0)*0.2 = 6e-9

but I get1.7920927e-8

Does someone have an idea what is going on? I currently using the 
GL_FLOAT_RGBA32_NV format as internal format of my attached texture. I 
have also tried the GL_FLOAT_RGBA16_NV, GL_RGBA32F_ARB, GL_RGBA16F_ARB 
and I always get the same kind of results. Tell me if you need part of 
my code in order to help me.



Thank you
Jonathan




___
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.  MailScanner thanks Transtec Computers for their support.


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


[osg-users] problem with blending when using floating point FBO

2009-05-25 Thread Jonathan . Richard0
Hi, I'm using the osgViewer ::Viewer to perform floating point rendering in  
an FBO and I have a problem when blending is enabled. My blending function  
is defined by GL_ONE_MINUS_SRC_ALPHA for destination and GL_ONE for source.  
The problem occurs when I draw a facet with a small color in front of a  
facet with a big color. For example lets define:


Rd = (0.2, 0.0, 0.0, 1.0) // RGBA
Rs = (6e-9, 0.0, 0.0, 1.0) //RGBA

In theory I was expecting to get:

Rd = Rs + (1-As)Rd
Rd = 6e-9 + (1-1)*0.2
Rd = 6e-9 +(0)*0.2 = 6e-9

but I get1.7920927e-8

Does someone have an idea what is going on? I currently using the  
GL_FLOAT_RGBA32_NV format as internal format of my attached texture. I have  
also tried the GL_FLOAT_RGBA16_NV, GL_RGBA32F_ARB, GL_RGBA16F_ARB and I  
always get the same kind of results. Tell me if you need part of my code in  
order to help me.



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