[osg-users] Scale problem while transforming object in vertex shader

Sebastian Messerschmidt sebastian.messerschmidt at gmx.de
Tue Apr 18 00:23:56 PDT 2017


Hi Yura
> Hi,
>
> I have a transform matrix and I want to apply it in shader. I pass it into uniform and set gl_Position = gl_ModelViewProjectionMatrix*my_transfrom_matrix*gl_Vertex.
> If I set translate only, everything is ok. If I set translate and scale - translate multiplies by scale and transform is wrong (object is too far if scale>1.0). If I apply this transform not using shader (by SetMatrix) everything is ok. What I am doing wrong?
Matrix multiplication is not cummutative in every case.
Try
gl_Position = gl_ModelViewMatrix * matrix * gl_ProjectionMatrix * 
gl_Vertex.

Cheers
Sebastian
>
>
> Thank you!
>
> Cheers,
> Yura
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=70768#70768
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>



More information about the osg-users mailing list