For vectors, You can use the model view matrix,  but omit the translation
component.  I believe the call is Matrix::transform3x3.
 On Aug 11, 2014 12:40 PM, "Bram Vaessen" <bram.vaes...@gmail.com> wrote:

> Hi,
>
> In my shader I would like to have the direction of the light (sunlight) in
> eye-space, and since it doesn't vary per vertex I would like to
> pre-calculate it in OSG.
>
> I'm not sure how to do this, I thought it would make sense to multiply the
> view matrix with the direction of the light like this, but I feel like I'm
> not sure what I'm doing. Anyone can help me out with this?
>
>
> Code:
>
> //to set up
> osg::Vec3f lightDir(1.f,2.f,-2.f);
> lightDir.normalize();
>
> //and then each step...
> osg::Vec4 lightDirEye = worldCamera->getViewMatrix() *
> osg::Vec4(lightDir,1);
> lightDirUniform->set(osg::Vec3(lightDirEye.x(), lightDirEye.y(),
> lightDirEye.z()));
>
>
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=60630#60630
>
>
>
>
>
> _______________________________________________
> 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