- Home /
sphere texture rotation around pivot (eye)
I'm trying to rotate an eye texture, with sphere projection, around the eye's center.
A similar subject is discussed earlier in this thread, and there is mentioned the need to position the pivot point for the rotation.
I've done several more complex tests, but does not make sense to make it more complicate if I can't make it work with the eye in the center of the world.
Can anyone help me to make it work in this simplified attached project?
Answer by Paulius-Liekis · Sep 20, 2010 at 08:57 AM
Are you sure you need to use transformation of texture coordinates instead of transformation of the object itself? i.e. why can't you rotate the sphere itself?
As far as your code goes it does exactly what it written to do :) If was making eye movements in this way I would just two away rotation and just use X and Y offsets, because they do what you want them to do - move eye up/down and left/right. Except that there is one problem - when you move it up/down the iris (it that correct word) gets squeezed, because of texture is mappen on a spehere, but there is nothing you can do about it - there is always deformation when you map texture to a sphere.
BTW: if you need just texture offset there is such property on a material (I thinkg it is called textureOffset, and there are textureScale and textureRotation IIRC), but I'm not sure they work with custom shaders.
Another thing: your eye is misaligned even when game is not running - mare sure the iris is aligned with one of the axis when no offset is set.
If this doesn't answer your question, could you give more details: what kind of result do you expect? some screenshots/drawings would help.