skratchy lines on the edge sprites

This topic contains 5 replies, has 2 voices, and was last updated by  Gordon 7 years, 10 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #29988

    lefty
    Member

    I’m getting skratchy lines drawn on the edge of my sprites. The sprites are packed into a texture atlas which uses PVR texture compressed.
    What is the best solution to this problem? I assume it’s adding a border, but what is the smallest border that fixes the problem?

    #33555

    Gordon
    Moderator

    I’d suggest, examining your atlas in PVRTexTool or similar and verifying whether there is actually overspill from the sections of your texture. Another thing to do would be to use uncompressed textures to verify that it is the compresion that is causing the problem.

    I suggest this as I’ve seen the same problems myself. Due to the way OpenGL samples textures it’s often the case that pixels from outside the area you require actually contribute to the output of your sprites. If you’re not scaling your sprites then I would suggest switching to GL_NEAREST filtering and possibly restricting your vertex coordinates to integers.

    If it is actually PVRTC then the most border you should need would be 4 texels (PVRTC4bpp works on 4×4 texel blocks). That should be sufficient, although you may find that less is required.

    For PVRTC sprites in general, cleaning up the RGB channels in transparent areas can be beneficial and using the border/bleed function in PVRTexTool can also help.

    Please post again if these ideas don’t help.

    #33556

    lefty
    Member

    Thanks for your answer.
    Since then I put in a border of 2 pixels and the problem seems to have gone away.
    I see there is a setting for bleed colour, but I don’t understand how that works.
    Also, could you explain what you mean by “cleaning up” transparent areas?

    #33557

    Gordon
    Moderator

    In a sprite image with RGBA data then there will be information stored in the RGB portion of the image that is invisible due to its alpha value. Unfortunately, PVRTC attempts to retain the RGB data such as this and in doing so can produce unsightly artifacts that wouldn’t be necessary if the RGB data in these transparent pixels was chosen to match the visible pixels.

    It’s something we’ve looked at automating in our recent PVRTC work, but right now it needs to be done by hand.

    The bleed operation is intended to help with preparing textures in this way (or filtering) by expanding information from surrounding pixels into the chosen (transparent in this case) colour and thus helping the compressor.

    #33558

    lefty
    Member

    Sounds to me that you would need an intricate understanding of the compression algorithm to choose the correct colour.

    #33559

    Gordon
    Moderator

    In some cases it may be easy – if the edges of your sprite are all black then make the tranparent areas black as well.

    To use the bleeding operation set the transparent pixels to a distinctive colour and then apply the bleeding operation to that colour (possibly more than once).

    I’ll admit that this isn’t a perfect solution, but it may help.

Viewing 6 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic.