Author Topic: Seamless skybox texture  (Read 1059 times)

Offline ilich

  • byte
  • *
  • Posts: 5
    • View Profile
Seamless skybox texture
« on: December 12, 2014, 01:15:43 pm »
Hello!
I develop a panoramas engine based on JPCT. Adding textures for skybox (one texture per side), I get a black seams on skybox planes joins. Is there any way to make skybox seamless?
Thanks


Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
Re: Seamless skybox texture
« Reply #1 on: December 12, 2014, 02:17:08 pm »
That's caused by flaws in the subpixel accuracy of the gpu combined with rounding errors when creating the sky box. I've never seen it being so obvious though. Which size have you used for the sky box? A quick hack would be to not clear the frame buffer but only the zbuffer at each frame. That doesn't really fix it of course, but it might become less obvious. I'll look into the issue in more detail later.

Offline ilich

  • byte
  • *
  • Posts: 5
    • View Profile
Re: Seamless skybox texture
« Reply #2 on: December 12, 2014, 02:28:29 pm »
Skybox size is 1024. But it doesn't matter - problem ocured both for 256 skybox as 65536 skybox. All textures are 256x256.
I have tried your workaround like this
Code: [Select]
        @Override
        public void onDrawFrame(GL10 gl) {
...
            //fb.clear(Color.WHITE);
            fb.clearZBufferOnly();
...
}
but it takes no effect.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
Re: Seamless skybox texture
« Reply #3 on: December 12, 2014, 03:10:31 pm »
If your framebuffer's color was white before, then this can't be the issue. Because your lines are obviously not white. Can you upload your textures in native resolution somewhere? Maybe it's an issue with them.   

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
Re: Seamless skybox texture
« Reply #4 on: December 12, 2014, 03:48:32 pm »
Looking at the right side of your screen shot, it actually looks like as if parts from the opposite side of the texture are bleeding in. This can happen only if clamping has been disabled on the textures. By default, the SkyBox class enables it. Are you disabling it afterwards or are you replacing the textures?
« Last Edit: December 16, 2014, 07:47:42 am by EgonOlsen »

Offline ilich

  • byte
  • *
  • Posts: 5
    • View Profile
Re: Seamless skybox texture
« Reply #5 on: December 16, 2014, 07:35:48 am »
I have enabled bleeding and GOT SOME MAGIC - joins goes seamless. Looks like problem solved. Thanks a lot!

Offline ilich

  • byte
  • *
  • Posts: 5
    • View Profile
Re: Seamless skybox texture
« Reply #6 on: December 16, 2014, 07:36:56 am »
Egon, could you tell me for stronger understanding what bleeding realy do?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
Re: Seamless skybox texture
« Reply #7 on: December 16, 2014, 07:50:23 am »
You mean clamping? It limits the actual texture coordinates to a [0..1] interval. The sky boy uses texture coordinates between [0..1] but the bilinear filtering usually makes the coordinates go slightly below 0 and above 1 (the mentioned "bleeding"). When clamping is disabled (which is default), these coordinates will wrap to the other side of the texture. With clamping enabled, they will be clamped at 0 and 1.
The SkyBox class actually enables clamping for the textures that the sky box uses, but if one changes them afterwards, it can't do it for those textures.

Offline ilich

  • byte
  • *
  • Posts: 5
    • View Profile
Re: Seamless skybox texture
« Reply #8 on: December 16, 2014, 08:22:06 am »
You mean clamping?

Yes, of course. Thanks for explanation.