Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Weird screen space seam (pixel size) when implementing atlas shader (image inside)

Discussion in 'Shaders' started by toglia3d, May 31, 2013.

  1. toglia3d

    toglia3d

    Joined:
    May 7, 2013
    Posts:
    3
    I'm writing a simple atlas shader aware texel bleeding between subtexture regions but I'm not getting that instead I'm getting a horrible seam in screen space the size of pixels.

    I've tried different texture filter modes bilinear (left) and point (right); In the attached image you can also see that I've left some padding so I shouldn't be getting region "bleeding".

    The shader looks like this:

    per vertex
    o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
    o.posMS = abs(v.vertex.xyz);

    per pixel
    float2 fuv = frac(i.posMS.xz)*scale+offset;
    float3 texColor = tex2D(_TextureAtlas, fuv).xyz;
    return float4(texColor, 1);

    $pixelSeam.jpg

    Don't have a clue of what could be happening. Thanks for any hint!
     
    Last edited: May 31, 2013
  2. toglia3d

    toglia3d

    Joined:
    May 7, 2013
    Posts:
    3
    Found it. It's important to disable mip-mapping for that texture by using the "advanced texture type".
     
  3. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    501
    The other problem is that you're using Frac. The texture might still work without it, as long as it's set to repeat and not clamp.