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<osg::Geometry*>(aDrawable);
aDrawableColor =
dynamic_cast<osg::Vec4Array*>(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<osgViewer::Renderer*>(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<osg::TextureRectangle> 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" <[email protected]> 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
[email protected] 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" [email protected]> 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
>
>
>
> [email protected] 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
>
> [email protected]
>
>
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
>
> [email protected]
>
>
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
------------------------------------------------------------------------
_______________________________________________
osg-users mailing list
[email protected]
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
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org