Author Topic: Texture Flipping  (Read 7350 times)

Offline dear_stephen

  • byte
  • *
  • Posts: 32
  • 'day mate
    • View Profile
    • Fluidforms ~ Individual Design
Texture Flipping
« on: May 30, 2007, 10:57:08 am »
Hi there!

It appears that textures are tiled by default. How would I go about flipping the texture instead of tiling it as my uv coordinates run over the edges of my texture?


Cheers,
Stephen

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Texture Flipping
« Reply #1 on: May 30, 2007, 06:29:53 pm »
You can't. OpenGL supports tiling (default) and clamping. Software (in OpenGL-look-alike-mode) supports tiling only. How about adding the "flipping" effect to the texture itself if changing the texture coordinates accordingly isn't an option for whatever reason.

Offline dear_stephen

  • byte
  • *
  • Posts: 32
  • 'day mate
    • View Profile
    • Fluidforms ~ Individual Design
Re: Texture Flipping
« Reply #2 on: May 30, 2007, 06:49:00 pm »
I originally had the flipping code working in another graphics engine. However I had strange artifacts in JPCT. I guess it should work as you say though. I was just hoping there might be a method like object.setTextureMode(Object3D.FLIP).

I'll have another look at getting my old code working in JPCT.

Thanks

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Texture Flipping
« Reply #3 on: May 30, 2007, 07:10:06 pm »
Maybe you can post a screenshot just to make sure that we are talking of the same thing when speaking about flipping and tiling. I'm not sure that we do...

Offline ToddMcF2002

  • long
  • ***
  • Posts: 103
    • View Profile
Re: Texture Flipping
« Reply #4 on: May 30, 2007, 08:24:51 pm »
I've been pretty puzzled about UV texture manipulation too.  For example - I've seen some GL engines implementing a waterfall by moving a seamless water texture across a plane object.  Looks very effective and it can't be too expensive.  They have to be manipulating the UV!  unless they are simply moving/resizing the plane but I don't think so....

There has to be a way to do it.
 


Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Texture Flipping
« Reply #5 on: May 30, 2007, 09:20:51 pm »
There has to be a way to do it.
Of course there is. You can use the PolygonManager for this. But i don't think that this is, what Stephen is talking about.

Offline ToddMcF2002

  • long
  • ***
  • Posts: 103
    • View Profile
Re: Texture Flipping
« Reply #6 on: May 30, 2007, 10:12:39 pm »
Yup I guess I'm confused about the difference between moving and flipping.

Offline dear_stephen

  • byte
  • *
  • Posts: 32
  • 'day mate
    • View Profile
    • Fluidforms ~ Individual Design
Re: Texture Flipping
« Reply #7 on: June 01, 2007, 06:12:09 pm »
Hi Guys

Lets say this is my texture.


Then tiled would looke like...


...and flipped like...



However I realise now that tiling gives a better result. With flipping, when the coordinates run toward the ends of the texture uneven stretching can occur. In the worst case two neighbouring verticies can have the same texture  coordinate, resulting in pixels being stretched from on vertex to the next.

It is better to use tiling and to make the textures seamless.



Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Texture Flipping
« Reply #8 on: June 01, 2007, 06:45:36 pm »
Yep, it's better to do it that way. "Flipping" is also unknown to OpenGL. There are clamping, clamping to edge and tiling only.