f3d icon indicating copy to clipboard operation
f3d copied to clipboard

Implements texture transforms

Open Meakk opened this issue 1 year ago • 9 comments

It's already possible to specify custom textures in both F3D and libf3d --texture-XXX options.
Some file formats are expecting textures to be Y-flipped like GLTF for example (Flipping the texture is already done in the GLTF importer, but not the reader).
It could be useful to allow the user to transform the texture coordinates to do take that into account.
VTK supports texture coordinates transform, by setting a specific key on the actor, like the code below:

  double mat[] = { 1, 0, 0, 0, 0, -1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1 };
  actor->GetPropertyKeys()->Set(vtkProp::GeneralTextureTransform(), mat, 16);

VTK expects a 4x4 matrix, but in our case we only support 2D texture coordinates, so we should expose the option as a 3x3 matrix.
Suggested F3D option is --textures-transform, suggested libf3d option is model.textures_transform.
Ideally, the option should be a new type transform2d_t defined in types.h storing 9 float values, and parsing methods should support things like:

  • flipY -> 1, 0, 0, 0, -1, 0, 0, 0, 1
  • rotate(x) -> cos(x), -sin(x), 0, sin(x), cos(x), 0, 0, 0, 1
  • translate(x, y) -> 1, 0, 0, 0, 1, 0, x, y, 1
  • scale(x, y) -> x, 0, 0, 0, y, 0, 0, 0, 1

Meakk avatar Sep 30 '24 08:09 Meakk

Is anyone working on this issue? If not I would like to work on it.

Yogesh9000 avatar Sep 30 '24 19:09 Yogesh9000

you can start looking at it but it may conflicts with my ongoing work: https://github.com/f3d-app/f3d/pull/1609, so you may want to wait for this to be merged before actually implementting this.

mwestphal avatar Oct 01 '24 05:10 mwestphal

@Yogesh9000 any news on this ?

mwestphal avatar Nov 01 '24 11:11 mwestphal

No feedback from @Yogesh9000 , unassigning for now.

mwestphal avatar Nov 17 '24 12:11 mwestphal

I'm going to start looking into this

samoncrief avatar Apr 13 '25 19:04 samoncrief

Sure, just assigned to you!

mwestphal avatar Apr 14 '25 06:04 mwestphal

Hi @samoncrief

Do you need help moving forward ?

mwestphal avatar Apr 21 '25 06:04 mwestphal

Hi @samoncrief

Do you need help moving forward ?

Not at this time, I got absolutely swamped at work this past week and had little spare time

samoncrief avatar Apr 21 '25 07:04 samoncrief

No worries! Thanks for the feedback.

mwestphal avatar Apr 21 '25 08:04 mwestphal