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