Pvr2Image v.1.1 converter ( .pvr --> .png/.tga/.bmp)

Moderators: pcwzrd13, deluxux, VasiliyRS

Post Reply
User avatar
VincentNL
blackout!
Posts: 130
Joined: Sat Dec 19, 2020 1:03 pm
Contact:

Pvr2Image v.1.1 converter ( .pvr --> .png/.tga/.bmp)

Post by VincentNL »

Image

Due to NaomiLib experience, had to learn how obscure .PVR formats were processed and convert them to RGBA formats.
A number of types which existed in SDK (alias,BGRA,bump,YUV420), were never addressed by existing converters so just decided to write one to cover all official variations.

Pvr2Image is a very simple app that converts every .PVR type in standard RGBA images (.png by default) without efforts!

* Select one or multiple .PVR / .PVP and choose an extraction folder, you'll get .png and .act files, that's all!

Win release:
https://github.com/VincentNLOBJ/pvr2image/releases

Git:
https://github.com/VincentNLOBJ/pvr2image

Pip:

Code: Select all

pip install pvr2img==1.1.0
Credits to:
* Egregiousguy for YUV420 to YUV420p conversion
* Kion for VQ handling and logic
* tvspelsfreak for SR conversion info on Bump to normal map

Supported PVR types

Code: Select all

[Texture Format:]

ARGB_1555
RGB_565
ARGB_4444
YUV_422
BUMP
RGB_555
ARGB_8888
YUV_420

[Pixel Format]:

TWIDDLED
TWIDDLED_MM
VQ
VQ_MM
PALETTIZE4
PALETTIZE4_MM
PALETTIZE8
PALETTIZE8_MM
RECTANGLE
STRIDE
TWIDDLED_RECTANGLE
ABGR
ABGR_MM
SMALLVQ
SMALLVQ_MM
TWIDDLED_MM_DMA
Last edited by VincentNL on Thu Dec 07, 2023 5:06 pm, edited 1 time in total.
If you like my work or just want to show some love:
https://ko-fi.com/vincentnl
https://www.patreon.com/VincentNL
colgate
Doom
Posts: 185
Joined: Sun Jan 03, 2016 2:30 pm
Dreamcast Games you play Online: PSO

Re: Pvr2Image v.1.1 converter ( .pvr --> .png/.tga/.bmp)

Post by colgate »

This is awesome!
User avatar
ateam
Animated Violence
Posts: 490
Joined: Mon Dec 02, 2013 8:06 am

Re: Pvr2Image v.1.1 converter ( .pvr --> .png/.tga/.bmp)

Post by ateam »

Great work, man! Thank you for this.
Find me on...

DreamcastForever.com
GitHub
Reddit
SegaXtreme
Twitter
YouTube
• Discord: derek.ateam
cbnj
brutal
Posts: 248
Joined: Sat Sep 16, 2023 6:17 am

Re: Pvr2Image v.1.1 converter ( .pvr --> .png/.tga/.bmp)

Post by cbnj »

This little thing will ease much work for extracting textures, i have a question tough.. does automatically un-prs the zombie revenge pvr textures at converssion? Probably this question is more related to the pvr extractor.
PkR
rebel
Posts: 22
Joined: Wed May 24, 2017 3:59 pm
Dreamcast Games you play Online: Phantasy Star Online

Re: Pvr2Image v.1.1 converter ( .pvr --> .png/.tga/.bmp)

Post by PkR »

Hi Vincent, thank you for your work. I haven't seen YUV420 supported previously, but all the other pixel codecs were added in a VRSharp fork in the Shenmue modding SDK several years ago: https://github.com/Shenmue-Mods/Shenmue ... elCodec.cs

Using those as a base with some fixes, recently Texture Editor in SA Tools was updated to handle all of those pixel codecs as well, again except YUV420.

I think it would be a good idea to have a set of sample textures to test various PVR texture formats. I can contribute samples of almost all those pixel and data formats, but I've never seen an actual NJD_TEXFMT_ABGR and NJD_TEXFMT_ABGR_MM texture, have you seen any games using this format?
User avatar
VincentNL
blackout!
Posts: 130
Joined: Sat Dec 19, 2020 1:03 pm
Contact:

Re: Pvr2Image v.1.1 converter ( .pvr --> .png/.tga/.bmp)

Post by VincentNL »

PkR wrote:Hi Vincent, thank you for your work. I haven't seen YUV420 supported previously, but all the other pixel codecs were added in a VRSharp fork in the Shenmue modding SDK several years ago: https://github.com/Shenmue-Mods/Shenmue ... elCodec.cs

Using those as a base with some fixes, recently Texture Editor in SA Tools was updated to handle all of those pixel codecs as well, again except YUV420.

I think it would be a good idea to have a set of sample textures to test various PVR texture formats. I can contribute samples of almost all those pixel and data formats, but I've never seen an actual NJD_TEXFMT_ABGR and NJD_TEXFMT_ABGR_MM texture, have you seen any games using this format?
Thanks for reporting!
Would had loved to have known about SM VRSharp before diving into all the Twiddle VQ and Bump SDK refs, my solution for twiddle came from predetermined autodetect LUT tables for standard and stride, so I'm curious to look into yours!

Image

As per 0xE texture mode, commonly referred as BMP or BGRA can be found as uncompiled .PVR in below mentioned SDK path:

Code: Select all

SDKs\R10.1\Sample\Kamui2\k2Mask
For any tests, let us move our discussion to Discord:
https://discord.gg/PCXJYtt3
cbnj wrote:This little thing will ease much work for extracting textures, i have a question tough.. does automatically un-prs the zombie revenge pvr textures at converssion? Probably this question is more related to the pvr extractor.
Prs compression is well known and supported by other tools afaik, so decompress to buffer before reading should be enough I suppose.
May look into that as an extra parameter if there's enough interest :)
If you like my work or just want to show some love:
https://ko-fi.com/vincentnl
https://www.patreon.com/VincentNL
TapamN
letterbomb
Posts: 149
Joined: Sun Jan 10, 2021 10:52 pm

Re: Pvr2Image v.1.1 converter ( .pvr --> .png/.tga/.bmp)

Post by TapamN »

I wrote a DC texture encoder and compressor that supports all formats the hardware supports (including some formats not supported by tvspelsfreak's convertor), and it can output previews of the resulting texture. The previews are generated by decoding the resulting texture data, so it has a built-in texture decoder for this that might have saved you some trouble. The preview even converts DC spherical normal maps to cartesian normals. It doesn't currently have support for directly converting .PVR to PNG or anything, but it was on the todo list.

The converter is mainly intended to output it's own format, which has more features than .PVR, but it does have some support for generating .PVR files (including small VQ textures), since I used PVR Viewer to help test the output before I had the decoder working and tested. (I found out PVR Viewer's handling of VQ YUV is bugged...) There might be some bugs in the generated .PVR header, though, since I've only tested the resulting files in PVR Viewer.
User avatar
VincentNL
blackout!
Posts: 130
Joined: Sat Dec 19, 2020 1:03 pm
Contact:

Re: Pvr2Image v.1.1 converter ( .pvr --> .png/.tga/.bmp)

Post by VincentNL »

@Pkr @TapamN, did you find any documentation regarding masks?

Texture Mode: [ Ninja /Naomi]

Code: Select all

NJD_TEXFMT_TYPE_MASK / NM_TEXTURE_FORMATMASK          	(0xFF00)
         
Pixel Mode: [ Ninja /Naomi]

Code: Select all

NJD_TEXFMT_COLOR_MASK / NM_TEXTURE_PIXELMASK		(0xFF)
If you like my work or just want to show some love:
https://ko-fi.com/vincentnl
https://www.patreon.com/VincentNL
PkR
rebel
Posts: 22
Joined: Wed May 24, 2017 3:59 pm
Dreamcast Games you play Online: Phantasy Star Online

Re: Pvr2Image v.1.1 converter ( .pvr --> .png/.tga/.bmp)

Post by PkR »

Those are bit masks. They're only used to separate pixel and data format values from each other because those are packed into a single 2-byte value.
Post Reply