Hi
try this image for depth ->
imageDepth->allocateImage((int)subXRes, (int)subYRes, 1,
GL_DEPTH_COMPONENT32,
GL_UNSIGNED_INT);
Also you can use multiple render targets to output up to 4 color
textures(rgba), you need to attach buffers to osg::Camera::COLOR_BUFFER0 (1,2
etc) and output values in shader using syntax
gl_FragData[0] = vec4(...)
gl_FragData[1] = vec4(...)
..
[index] is color buffer number to use.
Cheers
29.01.2012, 20:17, "wang shuiying" <[email protected]>:
> Hello,
>
> I want to record more than four elements by writing to "out variable"
> in fragment shader.
>
> I notice that FBO can connect to many buffers, so I define two images
> which are respectively attached to a color buffer and a depth buffer.
>
> osg source code are as follows:
>
> osg::Image *imageDepth=new osg::Image();
> imageDepth->allocateImage((int)subXRes, (int)subYRes, 1, GL_RGBA,
> GL_FLOAT);
> camera->attach(osg::CameraNode::DEPTH_BUFFER, imageDepth);
>
> osg::Image * image = new osg::Image();
> image->allocateImage((int)subXRes, (int)subYRes, 1, GL_RGBA, GL_FLOAT);
> camera->attach(osg::CameraNode::COLOR_BUFFER, image);
>
> fragment shader is as follows:
>
> gl_FragColor = vec4(1,0,0,1);
>
> gl_FragDepth=0.3;
>
> But it doesn't work: application output:
> Warning: detected OpenGL error 'invalid operation' at after
> RenderBin::draw(..)
>
> then I change the internal format of imagedepth to GL_DEPTH. it still
> doesn't work. and the system says, the framebuffer is attatched to an
> empty image.
>
> So how can I get more than four elements via fragment shader?
>
> Thank you very much in advance!
>
> Shuiying
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org