Search Unity

Panoramic Skybox Shader having a seam/line

Discussion in 'AR/VR (XR) Discussion' started by Hunubul, Feb 14, 2019.

  1. Hunubul

    Hunubul

    Joined:
    Dec 17, 2018
    Posts:
    65
    Hey!
    So there is this issue, I created the skybox material to put panoramic 360 videos/pictures to the skybox.

    The problem is, that there is a line where the edge is supposed to be, behind the camera.

    Does anyone know how to make it disappear? Here is the problem, there is no picture/video selected, so it seems the material itself has this problem.

    I started using the built in Panoramic Shader, but the issue is the exact same.

    Is there a Unity settings I can set to make it disappear? Or is there a code fix for it? Anything?
     

    Attached Files:

  2. BrainWilder

    BrainWilder

    Joined:
    Jul 24, 2018
    Posts:
    1
  3. PanayotCankov

    PanayotCankov

    Joined:
    May 28, 2018
    Posts:
    16
    Long story short - uncheck "generate mipmaps".
     
  4. m_nejatish

    m_nejatish

    Joined:
    Mar 16, 2020
    Posts:
    2
    Thanks. This works! Just select the texture, look under the Advanced and uncheck "generate mipmaps".
     
  5. menguzat

    menguzat

    Joined:
    Aug 20, 2017
    Posts:
    15
    my skybox texture is a 360 degree hdri image and the shader type is selected "skybox/panoramic".

    there is no option not to generate mipmaps as far as I can see. what would you suggest?
     
  6. samf1111

    samf1111

    Joined:
    Sep 18, 2019
    Posts:
    16
    this is an option on the image your using under the "Advanced" dropdown.
     
  7. dumbat

    dumbat

    Joined:
    Apr 24, 2014
    Posts:
    11
    I don't see an Advanced dropdown on my editor, either on the material's Inspector, or on the Select Texture window, and there's no right-click menu I can find with it. No sign of a Generate MipMaps checkbox either.
     

    Attached Files:

  8. arfish

    arfish

    Joined:
    Jan 28, 2017
    Posts:
    782
    That's probably because the setting is for the Texture, not the shader.
     
    dumbat likes this.
  9. NodeProject

    NodeProject

    Joined:
    Jul 12, 2017
    Posts:
    1
    3 years late but I'm here just to thank you guys for this!
     
  10. jons190

    jons190

    Joined:
    Sep 13, 2016
    Posts:
    260
    And the long reach.............. I just needed this answer. Thanx all!
     
  11. IllidanS4

    IllidanS4

    Joined:
    Jul 23, 2013
    Posts:
    7
    The reason this happens is that the panoramic shader calls tex2D to retrieve the color from the texture, but that function automatically calculates the mipmap level based on the surrounding pixels and it breaks at the seam, since the x coordinate jumps from 1 back to 0 there. The shader could be fixed if tex2Dlod was called instead.
     
  12. bordeleaum

    bordeleaum

    Joined:
    Jan 19, 2020
    Posts:
    7
    Have the same problem but as the texture is loaded from url I don't see how I can uncheck "Generate Mipmaps". Any idea?
     
  13. krakendono

    krakendono

    Joined:
    Jun 5, 2016
    Posts:
    15
    thank you
     
  14. alec1o

    alec1o

    Joined:
    Jul 15, 2021
    Posts:
    2
    Thanks! ;)
     
  15. NABALOCH

    NABALOCH

    Joined:
    Apr 8, 2023
    Posts:
    1
    love it!
     
  16. wesleywh

    wesleywh

    Joined:
    Jun 8, 2014
    Posts:
    19
    I know this is old but if someone comes across this when they're attempting to dynamically load a new skybox at runtime from a dynamically loaded image, you can do it like the following (where "textureBytes" is the bytes of the loaded image):

    Code (CSharp):
    1. Texture2D loaded = new Texture2D(2, 2);
    2. loaded.LoadImage(textureBytes);
    3.  
    4. // Create a new texture with mipmaps disabled
    5. // This removes the seem in panoramic loaded shaders
    6. _texture = new Texture2D(loaded.width, loaded.height, loaded.format, false);
    7. _texture.SetPixels(loaded.GetPixels());
    8. _texture.Apply();
    9.  
    10. Material _skyboxMaterial = new Material(Shader.Find("Skybox/Panoramic"));
    11. _skyboxMaterial.SetTexture("_MainTex", texture);
     
    Luferau likes this.
  17. IllidanS4

    IllidanS4

    Joined:
    Jul 23, 2013
    Posts:
    7
    A better solution that I came up with is to use the overload of
    tex2D
    that takes precomputed derivatives, and just compute them manually. Something that works is this:
    Code (CSharp):
    1.             float4 tex2Dwrap(sampler2D samp, float2 s)
    2.             {
    3.                 float2 dx1 = ddx(s);
    4.                 float2 dy1 = ddy(s);
    5.                 float2 s2 = float2((s.x + 0.5) % 1, s.y);
    6.                 float2 dx2 = ddx(s2);
    7.                 float2 dy2 = ddy(s2);
    8.                 bool first = abs(s2.x - 0.5) > 0.25;
    9.                 return tex2D(samp, s, first ? dx1 : dx2, first ? dy1 : dy2);
    10.             }
    Assuming that the discontinuity is at
    x = 1
    going back to
    x = 0
    , this basically moves it to
    x = 0.5
    and then picks the pair of derivatives that is farther from the discontinuity. The derivatives have to be computed up front and then chosen from because otherwise
    ddx
    /
    ddy
    would have caused another seam at the point they are split at.