Thanx guys!<неиAll solved by removing filtering in 1X1 textures. I simply comment this lines and All works fine.<неиfinalluminance->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D ::LINEAR);<неиfinalluminance->setFilter(osg::Texture2D::MAG_FILTER,osg::Text ure2D::LINEAR);<неиThanx <неиBye<неи<неи-----Original Message-----<неиFrom: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Guy<неиSent: Tuesday, April 08, 2008 8:28 PM<неиTo: OpenSceneGraph Users<неиSubject: Re: [osg-users] HDR with osg<неи<неиHello.<неи<неи1x1 texture should be rendered and call the shaders. I did it once in<неиmultipass program that ran some algorithm on the GPU.<неиBe sure that you use orthographic projection and the viewport to be 1x1:<неи<неиcamera->setProjectionMatrixAsOrtho2D(0,1,0,1);<неиcamera->setVie wport(0, 0, 1, 1);<неи<неиGuy.<неи<неи-----Original Message-----<неиFrom: [EMAIL PROTECTED]<неи[mailto:[EMAIL PROTECTED] s.openscenegraph.org] On Behalf Of J.P.<неиDelport<неиSent: Tuesday, April 08, 2008 3:11 PM<неиTo: OpenSceneGraph Users<неиSubject: Re: [osg-users] HDR with osg<неи<неиHi,<неи<неиRoman Grigoriev wrote:<неи> Hi guys!<неи> <неи> I try to implement HDR. And I got some problem when I compute average <неи> luminance<неи> <неи> I have to render it to 1X1 texture and here is the main problem<неи> <неи> When I setup viewport with setVewport(0,0,1,1) - I've got clearcolor <неи> i.e. (1,0,0,0)<неиIs this for a 1x1 target, or for your 2x2 target? I guess your shader is<неи<неиnot executed at all. What are you doing in the vertex shader? I have not<неи<неиtried 1x1 textures myself.<неи<неи> <неи> When I setup viewport with setVewport(0,0,2,2) - I've got average <неи> luminance - but here I've got 2X2 texture but I need 1X1 texture<неиAt some texture size (search gpgpu.org or experiment) it becomes faster <неиto copy the texture to CPU and do final calculation there.<неи<неи> <неи> What should I do?<неиDebug more :) See if your shader is executed for 1x1 case at all. Turn <неиon more OSG (see OSG_NOTIFY_LEVEL) messages to see if there are not <неиother problems, e.g. non-power of two texture resampling. Try texture <неиrectangles...<неи<неиjp<неи<неи> <неи> Here is my source (luminance2 texture has size of 4X4)<неи> <неи> osg::ref_ptr<osg::Texture2D> finalluminance = new osg::Texture2D;<неи> <неи> finalluminance->setTextureSize( 2, 2);<неи> <неи> <неи> <неи> finalluminance->setInternalFormat(GL_RGBA16F_ARB);<неи> <неи> finalluminance->setSourceFormat(GL_RGBA);<неи> <неи> finalluminance->setSourceType(GL_FLOAT);<неи> <неи> <неи> <неи> <неи><неиfinalluminance->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D ::LIN<неиEAR);<неи> <неи> <неи><неиfinalluminance->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D ::LIN<неиEAR);<неи> <неи> finalluminance->setWrap(osg::Texture::WRAP_S, <неи> osg::Texture::CLAMP);<неи> <неи> finalluminance->setWrap(osg::Texture::WRAP_T, <неи> osg::Texture::CLAMP);<неи> <неи> <неи> <неи> osg::ref_ptr<osg::Camera> luminance3Camera = new osg::Camera;<неи> <неи> osg::ref_ptr<osg::Geode> geode = new osg::Geode;<неи> <неи> osg::ref_ptr<osg::Geometry> geom <неи><неи=osg::createTexturedQuadGeometry(osg::Vec3(0,0,-1),osg::Vec3(1.0,0. 0,-1.<неи0),osg::Vec3(0.0,1.0,-1.0));<неи> <неи> <неи><неиgeom->getOrCreateStateSet()->setMode(GL_LIGHTING,osg::StateAttribut e::OF<неиF);<неи> <неи> geode->addDrawable(geom.get());<неи> <неи> luminance3Camera->setName("luminance3");<неи> <неи> <неи> luminance3Camera->setClearColor(osg::Vec4f(1.0f,0.0f,0.0f,1.0f));<неи> <неи> <неи> luminance3Camera->setProjectionMatrix(osg::Matrix::ortho2D(0,1,0,1));<неи> <неи> <неи> luminance3Camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);<неи> <неи><неиluminance3Camera->setViewMatrix(osg::Matrix::identity());<неи> <неи> luminance3Camera->setViewport(0,0,2,2);<неи> <неи> <неи> luminance3Camera->setRenderOrder(osg::Camera::POST_RENDER,13);<неи> <неи> <неи><неиluminance3Camera->setRenderTargetImplementation(osg::Camera::FRAME_ BUFFE<неиR_OBJECT);<неи> <неи> <неи><неиluminance3Camera->attach(osg::Camera::COLOR_BUFFER,finalluminance.g et())<неи;<неи> <неи> luminance3Camera->addChild(geode.get());<неи> <неи> <неи> <неи> osg::ref_ptr<osg::StateSet> luminance3stateset <неи> =luminance3Camera->getOrCreateStateSet();<неи> <неи> <неи><неиluminance3stateset->setTextureAttributeAndModes(0,luminance2.get(), osg::<неиStateAttribute::ON);<неи> <неи> luminance3stateset->setAttribute(clamp, <неи> osg::StateAttribute::ON);<неи> <неи> <неи> <неи> root->addChild(luminance3Camera.get());<неи> <неи> osg::Program* luminance3prg = new<неиosg::Program;<неи> <неи><неиluminance3stateset->setAttribute(luminance3prg);<неи> <неи> <неи><неиluminance3prg->addShader(osg::Shader::readShaderFile(osg::Shader::V ERTEX<неи, <неи> osgDB::findDataFile("Shaders/downLumExp_vp.glsl")));<неи> <неи> <неи><неиluminance3prg->addShader(osg::Shader::readShaderFile(osg::Shader::F RAGME<неиNT, <неи> osgDB::findDataFile("Shaders/downLumExp.glsl")));<неи> <неи> osg::Uniform* DownSampler = new <неи> osg::Uniform("DownSampler",0);<неи> <неи> luminance3stateset->addUniform(DownSampler);<неи> <неи> <неи> <неи> here is downLumExp.glsl<неи> <неи> <неи> <неи> /*FRAGMENT_SHADER*/<неи> <неи> uniform sampler2D DownSampler;<неи> <неи> const vec2 samples[16]={<неи> <неи> -0.375, -0.375, -0.125, -0.375, 0.125, -0.375, 0.375, -0.375, -0.375, <неи> -0.125, -0.125, -0.125, 0.125, -0.125, 0.375, -0.125, -0.375, 0.125, <неи> -0.125, 0.125, 0.125, 0.125, 0.375, 0.125, -0.375, 0.375, -0.125,<неи0.375, <неи> 0.125, 0.375, 0.375, 0.375<неи> <неи> };<неи> <неи> <неи> <неи> void main(void)<неи> <неи> {<неи> <неи> float lum = 0.0;<неи> <неи> float maximum = 0.0;<неи> <неи> vec4 color;<неи> <неи> vec2 sample;<неи> <неи> for(int i = 0; i < 16; i++)<неи> <неи> {<неи> <неи> sample = vec2(samples[i].x,samples[i].y);<неи> <неи> color = texture2D(DownSampler, gl_TexCoord[0].xy + <неи> sample); <неи> <неи> maximum = max( maximum, color.g );<неи> <неи> lum += color.r;<неи> <неи> }<неи> <неи> <неи> <неи> lum *= 0.0625;<неи> <неи> lum = exp(lum);<неи> <неи> gl_FragColor = vec4(lum, maximum, 0.0, 1.0);<неи> <неи> }<неи> <неи> <неи> <неи> <неи><неи------------------------------------------------------------------- -----<неи> <неи> _______________________________________________<неи> osg-users mailing list<неи> [email protected]<неи><неиhttp://lists.openscenegraph.org/l istinfo.cgi/osg-users-openscenegraph.or<неиg<неи<неи-- <неи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.or g/listinfo.cgi/osg-users-openscenegraph.or<неиg<неи_________________________ ______________________<неиosg-users mailing list<[EMAIL PROTECTED]<неиhttp://lists.openscenegraph.or g/listinfo.cgi/osg-users-openscenegraph.org<неи
_______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

