Vertically flipping PVRTC compressed image data

This topic contains 4 replies, has 2 voices, and was last updated by  Richard 4 years, 12 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #30994

    Richard
    Member
    This question is also posted on StackOverflow:

    I have some PVRTC 4bpp image data that needs to be flipped vertically in-place without decompression. The code I have written is mostly working but the flip currently introduces small artefacts and I’m unsure exactly why.

    The PVRTC flip code first moves the 8-byte 4×4 compression blocks to their flipped position as calculated by the TwiddleUV() function from PVRTDecompress.cpp in the PowerVR SDK. This part appears to be correct.

    Second, the code iterates through all the 8-byte compression blocks reversing the order of the second 4 bytes which contain the 4×4 modulation data stored in 2bpp. The first 4 bytes of the block contains color data which is left unchanged.

    This seems to be very close to correct, but it leaves small artefacts in the flipped image that weren’t there in the original and which manifest mostly as small greyish horizontal lines. If the flipping code is run twice then the artefacts go away and the image is unchanged from the original.

    Can anyone with some PVRTC experience explain what else needs to be done to flip the compressed image data? I think the problem may be to do with the flipping of modulation data, but my forays into the PVRTC documentation haven’t yielded the answer at this stage.

    Many thanks,
    Richard

    #36205

    Joe Davis
    Member

    Hi Richard,

    I’ve seen that Simon has been discussing this with you on StackOverflow post. Do you have any follow up questions?

    Thanks,
    Joe

    #36206

    Richard
    Member

    Hi Joe,

    Given that a vertical flip will always alter the contents we will have to do something else instead. I had thought it wouldn’t be a big deal to do the flip, but I know better now!
    Thanks,
    Richard
    #36207

    Joe Davis
    Member

    Hi Richard,

    Is there any reason you can’t flip the original image before it is compressed? Can you flip the image by altering the texture coordinates used in the shaders, as Simon suggested?

    Thanks,
    Joe

    #36208

    Richard
    Member

    Yes I am fully aware of both those options! I was hoping to do it ‘manually’ in some offline texture processing tools, but we’ll just do it another way, no big deal.

    Many thanks,
    Richard
Viewing 5 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic.