Hi Sebastian, At first I transformed from the camera coordinate system [Xc,Yc,Zc] to the pinhole image projecting system [X=Xc/Zc, Y=Yc/Zc]. Then the distorting is processed based [X,Y]. At last, the projection matrix is mutiplied and the pixel coordinate is getten in this way.
Since the input are the 3d camera coordinates and the output are the pixel coordinates, I wonder could I implement this function using the shaders? Should I implement the distortion in the vertex shader or in the fragment shader? Thank you very much, Ying SMesserschmidt wrote: > Hi Ying, > > > > > Hi Sebastian , > > > > The distortion value is a function of the position, and it's for per > > vextex. It won't change over time. To be more details, the distortion > > function would calculate pixel coordinates(2d) based on vertex > > positions(3d). > > > Okay, I somehow don't understand how this could be useful. Usually > distortion doesn't change the domain. So either the distortion maps 2d > -> 2d in the pixel domain or 3d vertex positions to 3d vertex positions. > The 3d -> 2d is usually done by the projection matrix, but you can of > course apply any projection function in the vertex shader. Maybe you > need to reformulate your question in a way I can understand what you are > really after. > > > So usually in the vertex shader: > > local vertex position(3d) * ModelViewMatrix -> global vertex position > relative to view * ProjectionMatrix -> Eyespace position > > The eyespace then is transformed into 2d coordinates before > rasterization (window matrix etc). > The point is, that you can basically do anything in the vertex shader to > change the 2d position of the vertex, but the edges will stay straight > lines. > If you need to do some non-linear distortion per pixel you will have to > use the fragment shader to distort the resulting image. This is usually > done to perform some projection onto curved surfaces or to model some > "fishlens" etc. > > So If you can explain what you are after, we might be able to point you > into the right direction how to do it with OSG. > > Cheers > Sebastian > > > > > > > Now I'm really confused about this problem. I found some tutorials and > > sample code about Frame Buffer Object and rendering to texture, but there's > > no this kind of functions in these code. Since I don't have much experience > > in OpenGL and osg, I'm a little lost now. > > > > > > > > > I would be appreciate if you could give me some suggestions :) > > > > Thanks, > > Ying > > > > > > > > SMesserschmidt wrote: > > > > > Hi Ying, > > > > > > > > > > Hi Sebastian , > > > > > > > > The distortion will be applied to the 3D model's vertexes. So each > > > > vertex will be changed to a different position. I wonder how could I > > > > achieve this? Should I use 3D texture, and then applying the distortion > > > > to the coordinates of the 3D texture? > > > > > > > > > > > I'm aware how distortion work I rather wanted to know if the distortion > > > value is per vertex and is constant or changes over time. > > > So we need to know if the distortion is a function of time, vertex > > > index, position or whatever. > > > > > > Try to describe the problem more in depth so we can get an idea of what > > > you are trying to achieve. > > > > > > Cheers > > > Sebastian > > > > > > > > > > Thank you for the answer! :) > > > > > > > > Cheers, > > > > Ying > > > > > > > > ------------------ > > > > Read this topic online here: > > > > http://forum.openscenegraph.org/viewtopic.php?p=59951#59951 > > > > > > > > > > > > > > > > > > > > > > > > _______________________________________________ > > > > 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=60079#60079 > > > > > > > > > > > > _______________________________________________ > > 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=60226#60226 _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

