Re: [osg-users] Help: can the fourth element of gl_FragColor be changed by shader?

2012-01-04 Thread Paul Martz
On 1/3/2012 11:43 PM, J.P. Delport wrote: Hi, On 03/01/2012 23:39, wang shuiying wrote: As can be seen from the source code, I attach an image to the camera, and access data from the image, I am rendering to an FBO. I don't think you are rendering to an FBO with the above code. I have to

Re: [osg-users] Help: can the fourth element of gl_FragColor be changed by shader?

2012-01-04 Thread wang shuiying
Hi, J.P. I am really confused now. I just want to get pre-rendering information from a camera through an image, which is attached to the camera. But I don't want to draw the image onto a texture. The rendering process goes through programmable shader and I need to write four different

Re: [osg-users] Help: can the fourth element of gl_FragColor be changed by shader?

2012-01-04 Thread wang shuiying
Hi, To J.P. and Paul: Thank you both very much ! After I change the renderTargetImplementation from FRAME_BUFFER to FRAME_BUFFER_OBJECT , it works! That is, I can get the fourth element of gl_FragColor modified in Fragment Shader though image. Plus, the camera in question is a pre-render

[osg-users] Help: can the fourth element of gl_FragColor be changed by shader?

2012-01-03 Thread wang shuiying
Hello, In my programme, the fourth element of gl_FragColor is changed by fragment shader to be a random number between 0 and 1. But when I access this element by the corresponding image, the element is always 1. I got to know that in the rendering pipeline after fragment operation, there

Re: [osg-users] Help: can the fourth element of gl_FragColor be changed by shader?

2012-01-03 Thread J.P. Delport
Hi, On 03/01/2012 15:55, wang shuiying wrote: Hello, In my programme, the fourth element of gl_FragColor is changed by fragment shader to be a random number between 0 and 1. But when I access this element by the corresponding image, the element is always 1. What image are you talking about

Re: [osg-users] Help: can the fourth element of gl_FragColor be changed by shader?

2012-01-03 Thread Paul Martz
If you are trying to read the alpha value from a framebuffer that has only RGB, then you will always read 1.0 for alpha, per OpenGL spec. -Paul On 1/3/2012 6:55 AM, wang shuiying wrote: Hello, In my programme, the fourth element of gl_FragColor is changed by fragment shader to be a

Re: [osg-users] Help: can the fourth element of gl_FragColor be changed by shader?

2012-01-03 Thread wang shuiying
Hello, (1)to J.P. the related source code is as following: // camera and image setup osg::Camera::RenderTargetImplementation renderTargetImplementation; renderTargetImplementation = osg::CameraNode::FRAME_BUFFER; osg::Program * program = new osg::Program();

Re: [osg-users] Help: can the fourth element of gl_FragColor be changed by shader?

2012-01-03 Thread wang shuiying
Hello, Sorry, the third line of 'access data' part should be : float color_a= color[3]; Shuiying ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Re: [osg-users] Help: can the fourth element of gl_FragColor be changed by shader?

2012-01-03 Thread J.P. Delport
Hi, On 03/01/2012 23:39, wang shuiying wrote: Hello, (1)to J.P. the related source code is as following: // camera and image setup osg::Camera::RenderTargetImplementation renderTargetImplementation; renderTargetImplementation = osg::CameraNode::FRAME_BUFFER; ^ If you want FBO, you probably