Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Compressing Equirectangular Skysphere Texture

Discussion in 'General Graphics' started by coxy17, Sep 29, 2017.

  1. coxy17

    coxy17

    Joined:
    Sep 27, 2013
    Posts:
    126
    Hi

    I am building and android test game for uni and I am learning texture compression and so far i have managed to make all textures a power of 2 to optimise textures to the max(so to speak) Except for my Skysphere is not imported as a power of 2, which I understand, but i cant find ways of way of increasing the compression beyond (0.8 MB) without making the resolution smaller of the following texture (screenshot). Any advice or pointers will be great.

    Nick

    Untitled.jpg
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,217
    Unity is converting your sky sphere into a cube map, which is six 512x512 textures. You've already disabled mip maps and aren't using an HDR texture, so you're kind of at the limit of things you can do with out reducing the resolution.
     
  3. coxy17

    coxy17

    Joined:
    Sep 27, 2013
    Posts:
    126
    Hi

    Ok that makes sense now. I couldn't figure out where the size was coming from. I changed to a sky sphere as I needed to save on draw calls. But is there any other options other than a sky box or sky sphere? Out of curiosity.

    Thanks for the explanation

    Nick
     
  4. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,217
    I mean you could use the equirectangular image straight, but crop off the bottom and top and fade to colors, then use a custom shader to adjust the vertical UV. You could save an additional 33% or so. Beyond that there's some advanced packing techniques using individual color channels and a color gradient look up that could get it down to half the size. Or using a lower resolution and a shader to use a better upscaling technique than the standard bilinear which can get you down to 25% or less. Then there's going fully proceedural.

    https://www.shadertoy.com/view/XslGRr

    Really though, why are you trying to do better than a megabyte? That's really tiny already.
     
  5. coxy17

    coxy17

    Joined:
    Sep 27, 2013
    Posts:
    126
    Ok ill take a look at those, thanks. I am trying to get the size down as im building for Android and I am going to ave about 10 of them (possibly more) so its going to add up to alot. So if this was the only skysphere then i wouldnt be bothered about reducing it. But Ive heard that textures is where i can collectively reduce APK size. The links you sent is new to me so i best get reading haha.
     
  6. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,217
    You probably don't want to go proceedural then. Doing a fully proceedural skybox like that is very expensive. You could get away with rendering them at runtime into render textures then using that texture, but that's still worse for performance than just using the 512x512 cube maps.

    Not knowing exactly how you're using these, the clamped equirectangular might work best for you. If you really do need the full sphere then lowering the resolution and using bicubic sampling is kind of your best option. Either way is going to require custom shaders. If that's not something you're comfortable learning, and you're not happy with the 256x256 resolution cube maps, stick with the ones you have as they are and try looking at other textures first.
     
  7. coxy17

    coxy17

    Joined:
    Sep 27, 2013
    Posts:
    126
    Hi, im just using the sky sphere in the Windows>Lighting in each scene (screenshot attached).


    skysphere.jpg
     
  8. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,217
    I meant how your game is using the background. ie: Does your game have a fixed camera like a side scroller, or have full camera control but only the sky above the horizon is visible, or can the camera only spin around an object on one axis? All of these cases don't require a full skycube or skysphere and can getaway with different ways of doing the sky to save memory.
     
  9. coxy17

    coxy17

    Joined:
    Sep 27, 2013
    Posts:
    126
    Oh sorry, well i have a 3D game where the player can move on all axis so they can see all of the sky (above and below the horizon) so i cant save on this unfortunately. Its sucks that there isnt a way reducing this :(. Thanks for the advice though.