nope.. i was wrong.. now i can succesfully take the rendering.. but as
TextureGrabBackground (and Foreground also) use glCopyTexSubImage2D to
copy the rendering, they will clamp the values between [0,1].. so all
i am getting is a LDR render in a float16 image

          "The pixels in the rectangle are processed exactly as if
          glCopyPixels had been called, but the process stops just
          before final conversion.  At this point, all pixel component
          values are clamped to the range [0, 1] and then converted to
          the texture's internal format for storage in the texel
          array."

any suggestions?

2007/4/20, Stefano <[EMAIL PROTECTED]>:
> the problem was solved adding setBindTarget(GL_TEXTURE_RECTANGLE_NV) to the 
> texture.. thanks
>
>
> 2007/4/19, Marcus Lindblom <[EMAIL PROTECTED]>:
>
> >  I think you want a PolygonBackground instead. That has worked for me
> > previously.
> >
> > Try with a SimpleTexturedMaterial and make sure that part of the
> > rendering works before doing anything else.
> >
> > Also, I'm not sure about TextureGrabForeground and resizing. It might
> > resize the image automatically, but if not, try setting it to a larger
> > size than 1,1.
> >
> > Cheers,
> > /Marcus, who's now leaving on vacation in California for two weeks. See
> > all you guys in while! :-)
> >
> >  Stefano wrote:
> > > Hi there!
> > > What I want to do is to:
> > > - render some HDR scene into a viewport (not tone mapped yet!)
> > > - grab the rendering with a TextureGrabForeground
> > > - redraw the rendering using a PolygonForeground with a ShaderMaterial
> > > to do
> > > some blooming and then tone mapping
> > >
> > > is this possible with opensg? i think so..
> > >
> > > this is my simple osg setup code:
> > >
> > >    ImagePtr img = Image::create();
> >  >    addRefCP(img);
> > >    beginEditCP(img);
> > >        img->set(Image::OSG_RGB_PF, 1, 1, 1, 1, 1, 0, NULL,
> > > Image::OSG_FLOAT16_IMAGEDATA);
> > >    endEditCP(img);
> > >
> > >    TextureChunkPtr tex = TextureChunk::create();
> > >    addRefCP(tex);
> > >    beginEditCP(tex);
> > >        tex->setImage(img);
> > >        tex->setTarget(GL_TEXTURE_RECTANGLE_NV);
> > >        tex->setInternalFormat(GL_FLOAT_RGB16_NV);
> > >        tex->setWrapS( GL_CLAMP_TO_EDGE );
> > >        tex->setWrapT( GL_CLAMP_TO_EDGE);
> > >        tex->setMinFilter( GL_NEAREST );
> > >        tex->setMagFilter( GL_NEAREST );
> > >        tex->setScale(false);
> > >    endEditCP(tex);
> > >
> > >    TextureGrabForegroundPtr tg = TextureGrabForeground::create();
> > >    beginEditCP(tg);
> > >        tg->setTexture(tex);
> > >    endEditCP(tg);
> > >
> > >    SHLChunkPtr _vGloomShader = SHLChunk::create();
> > >    beginEditCP(_vGloomShader);
> > >        _vGloomShader->setVertexProgram(Utils::getFile("gloom.vert"));
> > >        _vGloomShader->setFragmentProgram(Utils::getFile("gloom.frag"));
> > >        _vGloomShader->setUniformParameter("image", 0);
> > >    endEditCP(_vGloomShader);
> > >
> > >    ChunkMaterialPtr _vGloomMaterial = ChunkMaterial::create();
> > >    beginEditCP(_vGloomMaterial);
> > >        _vGloomMaterial->addChunk(tex);
> > >        _vGloomMaterial->addChunk(_vGloomShader);
> > >    endEditCP(_vGloomMaterial);
> > >
> > >    PolygonForegroundPtr polyFrgnd =
> > > Utils::makeDefaultPolygonForeground();
> > >    beginEditCP(polyFrgnd);
> > >        polyFrgnd->setMaterial(_vBlurMaterial);
> > >    endEditCP(polyFrgnd);
> > >
> > > ====
> > >
> > > even with a basic shader without any effects like this below all i'm
> > > getting
> > > is a black viewport..
> > >
> > > ((gloom.vert))
> > >
> > > void main(void) {
> > >    gl_Position=ftransform();
> > >    gl_TexCoord[0] = gl_MultiTexCoord0;
> > > }
> > >
> > > (( gloom.frag))
> > >
> > > uniform samplerRECT image;
> > > // hardcoded viewport size.. :P
> > > const int imageTextureWidth = 620;
> > > const int imageTextureHeight = 386;
> > > const float toneMap = 0.332;
> >  > const float gamma = 2.2;
> > > const float invGamma = 1/gamma;
> > >
> > > half3 toneMapping(half3 hdrColor) {
> > >    hdrColor = pow(hdrColor, 0.4545);
> > >    return clamp((hdrColor * toneMap) , 0.0, 1.0 );
> > > }
> > >
> > > void main(void) {
> > >    vec2 pixelCoord;
> > >    pixelCoord[0] = gl_TexCoord[0].x * float(imageTextureWidth);
> > >    pixelCoord[1] = gl_TexCoord[0].y * float(imageTextureHeight);
> >  >
> > >    ivec2 intCoord = floor(pixelCoord);
> > >    half3 color = half3(texture2DRect(image, intCoord));
> > >
> > >    gl_FragColor = half4(toneMapping(color), 1.0);
> > > }
> > >
> > > ===
> > >
> >  > any ideas? am i setting up some wrong parameters to the texture?
> > > thanks in advance
> > >
> > > ------------------------------------------------------------------------
> > >
> > > -------------------------------------------------------------------------
> > > This SF.net email is sponsored by DB2 Express
> > > Download DB2 Express C - the FREE version of DB2 express and take
> > > control of your XML. No limits. Just data. Click to get it now.
> > >  http://sourceforge.net/powerbar/db2/
> > > ------------------------------------------------------------------------
> > >
> > > _______________________________________________
> > > Opensg-users mailing list
> >  > [email protected]
> > > https://lists.sourceforge.net/lists/listinfo/opensg-users
> > >
> >
> >
> > -------------------------------------------------------------------------
> > This SF.net email is sponsored by DB2 Express
> > Download DB2 Express C - the FREE version of DB2 express and take
> > control of your XML. No limits. Just data. Click to get it now.
> > http://sourceforge.net/powerbar/db2/
> > _______________________________________________
> > Opensg-users mailing list
> >  [email protected]
> > https://lists.sourceforge.net/lists/listinfo/opensg-users
> >
>
>
>
> --
> Stefano Verna
> mail/gtalk: [EMAIL PROTECTED]
> skype: steffoz



-- 
Stefano Verna
mail/gtalk: [EMAIL PROTECTED]
skype: steffoz

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to