Hi Paul,

well, actually, I'm not exactly rendering directly in eye coordinates
(provided I understand what you mean): the sphere should not rotate with the
camera (in fact I'm not rendering a sphere: rather points representing stars
by the way).

But your idea is very good: until now, I was using something like:

 gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix *
myModifiedVertexPos;

==> I'm computing the modified vertex position by offseting the gl_Vertex by
the camera position in the model frame.

Now that you mention it I realize my error must come from the usage of the
gl_ProjectionMatrix which is the latest projection matrix computed by OSG
(using the initial sphere vertices).

I'm not familiar at all with projection matrices computation, but I will
give it a try tomorrow  :-).

thanks for your help.
Manu.


2009/4/29 Paul Martz <pma...@skew-matrix.com>

>  So you are effectively rendering the sphere in eye coordinates. Have you
> tried simply projecting the coordinates (in the vertex shader) onto the far
> plane and rendering them there? The coordinates will (of course) need to be
> between the near and far plane in order to not be clipped, so just
> projecting them into that range (and ideally onto the far plane) should do
> the trick.
>
> Paul Martz
> *Skew Matrix Software LLC*
> http://www.skew-matrix.com
> +1 303 859 9466
>
>
>  ------------------------------
> *From:* osg-users-boun...@lists.openscenegraph.org [mailto:
> osg-users-boun...@lists.openscenegraph.org] *On Behalf Of *Emmanuel Roche
> *Sent:* Wednesday, April 29, 2009 9:28 AM
> *To:* OSG Users
> *Subject:* [osg-users] frustum culling in shader
>
> Hi everyone,
>
> Just again a simple problem I can't solve myself:
>
> I have an sphere object I want to use as a sky sphere. What's the best wait
> to do that ???
>
> The idea I came to is to use a vertex shader to offset each of the sphere
> vertex by the current position of the camera in the model frame. But then
> nothing is displayed because the moved vertices are behind the near plane
> and are culled :-(
>
> Any idea ?
>
> I guess I'm not the first one trying to render a sky sphere any way ??
>
> thanks for your help.
>
> manu.
>
>
> _______________________________________________
> 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