Hi Ying, I am confused why you are trying to use a 3D texture. OpenGL rendering works against a 2D frame buffer and depth texture. You can assign a single plane of 3D texture to a FBO and render to this specific plane, but you can't render to the whole Texture3D at once. The OpenGL warning also suggests your driver doesn't even support Texture3D.
Perhaps you are after recording the colour and the depth of the scene rather than a 3D texture. Robert. On 10 June 2014 16:12, ying song <[email protected]> wrote: > Hi Robret, > > Thanks for the answering. Now I could understand the process of rendering > more or less. > > I´m trying to rendering a scene on a 3D texture and then distorted the scene > by associating 3D texture coordinates to vertices. However, after I changed > all the 2D textures to 3D textures(including all the definitions and > coordinates of the texture) in the osgdistortion example, it doesn´t work > somehow. I wonder whether the way of rendering to 3D texture is the same as > rendering to 2D texture. > > Here is the my code which I wrote based on the "createDistortionSubgraph" > part in the example code: > > int i,j; > for(int z=0;z<256;z++) > { > for(i=0;i<256;++i) > { > for(j=0;j<256;++j) > { > osg::Vec3 cursor(j,i,z); > osg::Vec3 texcoord(j/256.0,i/256.0,z/256.0); > vertices->push_back(cursor); > texcoords->push_back(texcoord); > colors->push_back(osg::Vec4(1.0f,1.0f,1.0f,1.0f)); > } > } > } > > Geom->addPrimitiveSet(new > osg::DrawArrays(osg::PrimitiveSet::QUADS,0,vertices->size())); > > > This code only gives me a blank window and an error: " 3d texture is not > supported by opengl driver". > > Through searching on the internet, I found that there might be some problems > of my graphic card. I would change another graphic card to see what happens. > However, I´m not sure whether it is also due to some errors of my code. Would > anyone tell me whether my code is correct to do this kind of rendering? > > Thanks! > > Cheer, > Ying > > > robertosfield wrote: >> HI Ying, >> >> The osgdistortion example uses a Camera set up to handle Render To >> Texture (RTT) of the main scene graph, rendering to the texture as if >> it were the original frame buffer. This texture is then used when >> rendering within a second Camera that rendering to the normal frame >> buffer but with an orthographic projection. The scene the the second >> Camera rendering is simply a quad osg::Geometry that is screen aligned >> so it takes up the whole window, the vertices on this osg::Geometry >> are set up as a grid to cover the screen with a regular pattern of >> quads. The vertices on this geometry also have texture coordinates >> associated with them these texture coordinates tell the GPU what part >> the texture to use when rendering, if the texture coords were set up >> in a regular pattern like the vertices then you wouldn't see any >> distortion, however, for this example they are shifted so that desired >> distortion is applied. >> >> Robret. >> >> On 6 June 2014 17:00, ying song <> wrote: >> >> > Hi everyone, >> > >> > I'm now going through the osgdistortion example. Based on my >> > understanding, this example is to rendering the scene on the texture >> > istead of the screen. Through distorting the texture, the distorted model >> > could be build and shown. >> > >> > However, I'm a little confused about the rendering process to distort the >> > 3D model. >> > >> > Part of the code is shown below: >> > >> > for(i=0;i<noSteps;++i) >> > { >> > osg::Vec3 cursor = bottom+dy*(float)i; >> > osg::Vec2 texcoord = bottom_texcoord+dy_texcoord*(float)i; >> > for(j=0;j<noSteps;++j) >> > { >> > vertices->push_back(cursor); >> > texcoords->push_back(osg::Vec2((sin(texcoord.x()*osg:: PI-osg:: >> > PI*0.5)+1.0f)*0.5f,(sin(texcoord.y()*osg:: PI-osg:: PI*0.5)+1.0f)*0.5f)); >> > colors->push_back(osg::Vec4(1.0f,1.0f,1.0f,1.0f)); >> > >> > cursor += dx; >> > texcoord += dx_texcoord; >> > } >> > } >> > >> > polyGeom->setVertexArray(vertices); >> > >> > polyGeom->setColorArray(colors); >> > >> > polyGeom->setTexCoordArray(0,texcoords); >> > >> > I'm not sure how the rendering process works. Could anyone tell me that >> > are the original points' coordinates stored in 'vertices', and the >> > distorted points' coordinates stored in 'texcoords'? >> > >> > Another question is that why the texture is defined as 2D? Could I define >> > a 3D texture, then rendering a distorted model on the 3D texture and >> > display it on the screen? >> > >> > Thank you so much for helping me on this! >> > >> > Cheers, >> > Ying >> > >> > ------------------ >> > Read this topic online here: >> > http://forum.openscenegraph.org/viewtopic.php?p=59668#59668 >> > >> > >> > >> > >> > >> > _______________________________________________ >> > osg-users mailing list >> > >> > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org >> > >> _______________________________________________ >> osg-users mailing list >> >> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org >> >> ------------------ >> Post generated by Mail2Forum > > > ------------------ > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=59692#59692 > > > > > > _______________________________________________ > 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

