Hi,
look at some of the code paths in osgprerender for where it uses float
data and see if that works for you.
jp
On 27/10/2011 12:17, wang shuiying wrote:
Hi, Robert
Thank you for your reply.
Sorry that I don't think I expressed my problem clearly.
I want to simulate radar using osg camera. The important codes are:
osg::Program * program = new osg::Program();
program->addShader(osg::Shader::readShaderFile(osg::Shader::FRAGMENT,
fragmentShaderPath));
program->addShader(osg::Shader::readShaderFile(osg::Shader::VERTEX,
vertexShaderPath));
osg::Image * image = new osg::Image();
image->allocateImage(xRes, yRes, 1, GL_RGBA, GL_FLOAT);
osg::ref_ptr<osg::CameraNode> camera(new osg::CameraNode());
camera->setComputeNearFarMode(osg::Camera::DO_NOT_COMPUTE_NEAR_FAR);
camera->setViewport(0, 0, xRes, yRes);
camera->setClearColor(osg::Vec4(1000.0f, 1000.0f, 1000.0f, 1000.0f));
camera->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
camera->setProjectionMatrixAsFrustum(-tan( viewYaw), tan(viewYaw),
-tan(viewPitch), tan(viewPitch), zNear,zFar);
camera->setViewMatrix(osg::Matrix::lookAt(osg::Vec3d(0, 0, 1.0f),
osg::Vec3d(-10.0f, 0.0f, 0), osg::Vec3d(0, 0, 1)));
camera->setRenderOrder(osg::CameraNode::PRE_RENDER);
camera->setRenderTargetImplementation(renderTargetImplementation);
camera->attach(osg::CameraNode::COLOR_BUFFER, image);
camera->getOrCreateStateSet()->setAttribute(program,
osg::StateAttribute::ON);
in Fragment shader, I write, e.g:
gl_FragColor = vec4(0.1,0.2,0.3,0.5);
when I get the four elements through image attached to the camera, the
first three elements are just as expected to be 0.1,0.2,0.3
respectively, but the fourth element is 1. No matter what value I assign
to the fourth element, it keeps to be 1.
I cannot figure out why this happens.
So does it still have something do do with graphics context when it
comes to Pre-render camera?
Thank you very much!
Shuiying
_______________________________________________
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.
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org