I have some classic texture coordinates and as a normal behaviour they follow the mesh's transformations.

I am trying to use the same texture coordinates behaviour but without being affected by the mesh rotation transformation. The results would be a sort of texture coordinates projection.

I don't know if my explanations are well explained but how could I achieve such effect.

Thanks a lot.

enter image description here

  • \$\begingroup\$ Do you want texture coordinates to be directly attached pixel window coordinates? \$\endgroup\$ – HolyBlackCat Oct 30 '16 at 21:19
  • \$\begingroup\$ I am not sure if I understand you well. The aim is to stick to the texture coordinates (change according to translation, scaling) but when projecting onto the object, the uv should not be affected by the object rotation transformation. \$\endgroup\$ – MaT Oct 30 '16 at 21:38
  • \$\begingroup\$ I added a screenshot. \$\endgroup\$ – MaT Oct 31 '16 at 16:13
  • \$\begingroup\$ I dont understand what is happening exactly. It looks like you are rotating the coords of the texture after the light reflection calculations, am i right? \$\endgroup\$ – Haruko Oct 31 '16 at 16:43
  • \$\begingroup\$ The Occlusion texture is applied in the classical way so if you rotate the eye, it rotates according to the object. But I don't want this behaviour. The Occlusion should be projected on the eye object. \$\endgroup\$ – MaT Oct 31 '16 at 16:45

I think that I got a solution but I would gladly know if there are some optimizations possible.

My UVs and local coordinates values are corresponding. I mean that they are in the same range value. That said, I can use my XY vertices values for sampling the occlusion texture. The main problem is that the local coordinates are dependent to the rotation of my object which doesn't solve anything...

To solve that I am converting my local coordinates into world space using a objectToWorld matrix (inverse of current world matrix). Then I am converting it back into object space using the inverse TRS matrix but without taking into account the rotation of the object.

It's a bit hacky and I think that I could avoid some steps but this is working. Any advice is welcome :)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.