Have a look in the mail archive for osgcubemapprerender/(or
osgprerendercubemap). There is a sample attached in one of the mail that do
that. Was in the recent discussion ...
-Nick


On Tue, Feb 9, 2010 at 4:13 PM, Sebastien Nerig <overse...@hotmail.com>wrote:

> Hi,
>
> I am trying to make a dynamic cube with osg.
> The idea is to render into a cube map the +X, -X, +Y, -Y, +Z and -Z view
> from the camera view point at each frame.
> Then the cube map is textured on a reflector surface (a plane) within a
> shader. I would like to see other objects (sphere, cube) reflecting in my
> plane as it was a mirror.
> I managed to make the cube map and to texture it on my plane but the
> reflection is not correct, and I need some ideas to correct my app.
>
> Ok, so I build a cubemap texture with osg, then I create 6 camera nodes.
> theses cameras are looking at +X, -X, +Y, -Y, +Z and -Z directions and are
> attached with a callback to the main camera position.
> I use this command to attach the cube map texture for each camera :
>
> Code:
> camera->attach(osg::Camera::COLOR_BUFFER, m_textureEnvMap, 0, i);
>
>
>
> Then I use this fragment shader to map the cube map on the plane :
>
> Code:
> // world space eye vector
> vec3 E = normalize(posWorld.xyz - cameraPosWorld);
> // plane world vector (hadcoding!)
> vec3 N = vec3(0,1,0);
> vec3 coord = reflect(E, N);
> vec3 reflectColor = textureCube(cubeMap, vec3(coord.x, coord.y,
> coord.z)).rgb;
>
>
>
> posWorld is the current fragment world position (posWorld = modelMatWorld *
> gl_Vertex); cameraPosWorld is the camera world position (passed with
> uniform).
>
> I would like to have some advice and ideas about my program.  Did anyone
> already try to make dynamic cube ? What did I miss ?
>
> Thank you!
>
> Cheers,
> Sebastien
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=23848#23848
>
>
>
>
> Attachments:
> http://forum.openscenegraph.org//files/sans_titre_2_182.jpg
> http://forum.openscenegraph.org//files/sans_titre_243.jpg
>
>
> _______________________________________________
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to