Mesh using Image.texture is upside-down

63 views
Skip to first unread message

Arlo

unread,
Feb 23, 2015, 1:56:33 PM2/23/15
to kivy-...@googlegroups.com
I've just started with Kivy (1.8.0) and am trying to work with Meshes. I've been surprised to find that Image textures are flipped upside down in a Mesh. This is due to image files inverting the y-axis. Kivy flips the texture with Texture.flip_vertical() for such image files when loading the Image. Some canvas elements such as Rectangle read these modified tex_coords and display the Image right-side-up. However, Mesh does not use Texture.tex_coords, resulting in an upside-down image.

I'm surprised no one else has encountered this; I haven't found anything online about it.
I created a GitHub issue here: https://github.com/kivy/kivy/issues/3065

I can think of 3 solutions:

  1. Mesh does the math to adjust vertices u,v based on the tex_coords when they are set and whenever they change.

  2. Mesh does a Scale() and Translate() to achieve the same result, putting the work on the GPU.

  3. When Mesh gets a texture with modified tex_coords, it modifies the texture itself according to tex_coords and restores its tex_coords to normal so it doesn't need to recalculate vertices whenever they change in the future. (Longer creation time, No performance impact on vertice changes) By modifying the Texture and its tex_coords, other Mesh's using the texture won't have to repeat the task.


Are there better solutions? Am I missing something? Have others solved this issue in another way?


-Arlo

Reply all
Reply to author
Forward
0 new messages