[osg-users] help for warping

Gianni Ambrosio g.ambrosio+osg at gmail.com
Thu Nov 3 02:44:35 PDT 2016


Hi All,
I'm struggling with a warping implementation to show a 3D scene to a curved screen.

I gave a look at osgdistortion example and implemented a RTT camera just like in that example.
So now I have a render to texture camera that generates a texture of the 3D scene. Then a HUD camera with a geode as child where its geometry is attached to the texture.

I have a csv file that describes the screen shape as mesh of points. The file contains the following data: x,y,z,u,v.
Each line represents the x,y,z patial coordinates of a screen point.

For a different project that uses Unity and C#, a colleague implemented the warping basically in this way:


Code:

Vector2[] uvs = new Vector2[mesh.vertices.Count()];
for (int i = 0; i < mesh.vertices.Count(); i++) {
    Vector3 pos = camera.WorldToViewportPoint(mesh3d.vertices[i]);
    uvs[i] = new Vector2(pos.x, pos.y);
}
mesh.uv = uvs;



I didn't find a WorldToViewportPoint method in OSG but I find some references on the web to implement it.

On the other hand it seems the osgdistortion example is implemented differently.

One more thing I have to say is that projectors and curved screen are fixed while the observer is sitting on a moving platform. So I have to correct the camera frustum first.

Anyway, could you please suggest and explain me how to implement the warping considering that it would be also nice to use a shader to improve performance (if possible)?

Cheers,
Gianni

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=69219#69219








More information about the osg-users mailing list