Skip to content

[MOD][BETA] EE AI Denoised Areas

LeiluLeilu Member Posts: 67
edited May 2022 in General Modding
Hi,

I am looking into creating a mod with AI upscaled or at least denoised and blurless area images.
I am using NearInfinity to extract TIS/PVRZ files to PNG files.

The images are AI upscaled x4 and then downscaled back to the original resolution (as a starting point because I don't how to increase in-game resolution and if it's possible).

Download latest version
BGEE 279/329 areas 100% done. 50 remaining areas with "small animations" (mostly doors) to fix.
BG2EE 159/353 areas 100% done. 194 remaining areas with "small animations" (mostly doors) to fix.

Original
9vfyy5ksrlc4.png
Denoised
ssxwtx0tymob.png

Another example:
Original
j5lx0n79oa3m.png
Denoised
6lpu02naruq2.png
I tried converting back my edited images to TIS files with the same number of tiles and putting these files in the override folder, but it doesn't work.
I can't get them back into the game without a black render or a crash. The tiling gets messed up in the process and I don't understand why.
Fixed! Shout-out to argent77

9oj5hbpjcav1.png

Speaking of the number of tiles, is it possible to change the number of tiles (it is set in the .WED referent file if I understand it well) to potentially increase the resolution of the images used by the game (provided I keep a multiple of 64) to further increase in-game quality?

0vez4fdtolap.png

Large area (right-click, open in a new tab to view full sized version):
Original
vnmydskp0qu2.png
Denoised
xah83paowf9p.png

300% zoomed (right-click, open in a new tab to view full sized version):
Original
byjvskr5ogha.png
Denoised
9h3ovxz8cm0a.png

300% zoomed (right-click, open in a new tab to view full sized version):
Original
t4isxld2n3hk.png
Denoised
har6amzj7lj7.png

Obviously, it's early tests. I think it will need some manual tweaks to bring back some grain with photoshop on some elements, but it won't be that tedious to do.
The result is kinda nice but as expected I must work on the TIS files instead. At PVRZ file level I get visible tile borders unfortunately (look for horizontal and vertical lines). Animated tiles like fireplaces are really noticeable.

7jlafvxjqady.png
right-click, open in a new tab to notice tilling lines
9faoef5lnzab.png

A solution to avoid this issue of visible tiles would be to start by reassembling all the tiles by hand to form one large area in a single image ready for upscale at that time and then re-cut as it was originally.
I hope I can find another solution to this because it won't take me one single night to do this.

Manual tilling is no fun at all.
aiaak1j9am6m.png

It took me around 90-100 minutes to do manually only one area with an animated fireplace (I had to manage the tiles of both fireplaces six times in total so that the borders of these animated tiles could not be seen).
In game result (right-click, open in a new tab to view full sized version):
5cslxuvlpa2j.png
100% fixed for static areas.

I could certainly be faster on the following ones with some automated tasks but it's going to be a lot of work. Probably 500+ hours for BGEE only, considering the number of areas.
Is it even worth it? Personally, I prefer this AI denoised render vs original render but it's true that for some surfaces, the loss of grain makes things a bit too smooth. The stone now looks like clay in some places. Wood also lacks grain.
And it's complicated to have a noticeable increase in quality while keeping the same resolution.

If only I could increase the in-game resolution by a factor of 2, it would really be worth the effort, I think. Why only X2? Because my X4 upscaled folder is 64GB diskspace. I think X2 will be the right spot between quality and disk space. It will be detailed enough to be able to zoom in at a usual playing distance without seeing any blur.

I need help from NearInfinity experts, but I don't want to disturb them either.
I have two (or three) big questions.
  1. Would it be possible to work at the TIS level to skip the extremely tedious manual tilling process I do at the PVRZ file level? This would leave me to reassemble only the areas that have animations. A hell of a lot of time saved.
  2. Would it be possible to control the tiling to increase the number of tiles per TIS file to increase the resolution of the in-game areas?
  3. (off topic) What I do for areas, would it be possible to do for characters to smooth their aliased edges while making them sharper? The number of frames doesn't matter because I can work on an unlimited number of files at a time, but I still need to be able to extract and re-import them easily.
    I didn't really understand how the character sprites worked in the game. When I look at a particular character's BAM file, some frames are empty. My understanding is that the bright colors I see are masks to which the real colors are then applied.

I share my actual work if you want to see the in-game result by yourself. It's only for BGEE for the moment.
I'm not used to Github at all, please bear with me.


SOD areas are untouched because I find them already sharp enough and without noticeable grain. Of course, I'll include SOD areas if I manage, with your help, to find a way to increase in-game areas resolution.

Thank you for reading
Post edited by Leilu on
«1

Comments

  • LeiluLeilu Member Posts: 67
    Same thing but for BG2EE.


    I have excluded the most recent areas from the EE version which do not benefit so much from this treatment, at least at this default resolution. Hexxat quest tomb for example.

    New issue in BG2EE compared to BGEE, some water tiles are extremely visible like here for example:
    5r9ufiluogcc.png
    I haven't tried to find out where this problem comes from, but surely by excluding some images with only water, I could correct it. I still have to find out which images correspond to these ugly tiles.
    And maybe it's just a flaw that will correct itself when I have time to treat each area in full one by one.

    @argent77 Sorry to ping you but it would help me a lot to have answers to my few questions from my previous post and I think that you are certainly the best placed to answer them. Thank you. ;)
  • argent77argent77 Member Posts: 3,478
    The water overlay issue occurs because of the wrong texture encoding format. Your tilesets are encoded as DXT5. Map tilesets have to be encoded as DXT1, however. This will (or should) also remove the aliased edges around transparent pixel blocks, because DXT5 uses an interpolated alpha scheme.
  • LeiluLeilu Member Posts: 67
    edited April 2022
    @argent77 Thank you very much. ;)

    Converting to DXT1!
    jesjacuzj8oz.png

    When you talk about aliased edges, are you only talking about the ones in the Athkatla temple district example or are you implying that the DTX1 format will also solve the vertical and horizontal lines problem visible in my first post examples?
    (e.g.)
    pregw9xzzqae.png
  • GraionDilachGraionDilach Member Posts: 593
    The latter.
  • LeiluLeilu Member Posts: 67
    So great! It's going to save me so much work time.
  • LeiluLeilu Member Posts: 67
    The Athkatla water is well fixed thanks to the solution of @argent77 but unfortunately, as I presented it, there are still the problems of the lines on the edges of the tiles.

    I'm going to have to manually fix this and if I can't work with the assembled images at the TIS level, it's going to take a long, long time. :neutral:
  • GraionDilachGraionDilach Member Posts: 593
    How do you cut up the denoised image to TIS?
  • argent77argent77 Member Posts: 3,478
    I can see the lines clearly even in NI when I open a map with the upscaled tileset (e.g. BG2 map AR0070).

    The visible lines are more likely an issue of your upscaling procedure. I take it you upscaled pvrz textures individually?

    In that case edges wont really fit together since the scaler is unable to take information from adjacent textures into account. I think that can only be solved in a satifactory manner by exporting the tileset as a whole, performing the upscaling, and then manually dividing the tile blocks based on the original pvrz texture layout.
  • LeiluLeilu Member Posts: 67
    Like this.
    am0xbzgrtnf0.png
    Same number of tiles as original TIS file and TIS version PVRZ-based.

    But it doesn't work the way I thought it would.

    As I said in the first post, when I put newly created TIS and PVRZ files in override, I get a black area.
    mlqbwuwxk4mv.png
  • LeiluLeilu Member Posts: 67
    edited April 2022
    argent77 wrote: »
    I can see the lines clearly even in NI when I open a map with the upscaled tileset (e.g. BG2 map AR0070).

    The visible lines are more likely an issue of your upscaling procedure. I take it you upscaled pvrz textures individually?

    In that case edges wont really fit together since the scaler is unable to take information from adjacent textures into account. I think that can only be solved in a satifactory manner by exporting the tileset as a whole, performing the upscaling, and then manually dividing the tile blocks based on the original pvrz texture layout.

    Yes, I knew from the beginning that by working on cut images to upscale them, I would have visible problems when the game will put them together. This is normal because the upscale software can't guess to treat the edges of the tiles correctly as if they were all assembled.

    I want to export the tileset as a whole and I think best file for this is TIS file which is already a whole tileset. The problem is that I can't understand how the game and nearinfinity handle the image to TIS conversion to match the default game tilling and file structure.
  • LeiluLeilu Member Posts: 67
    edited April 2022
    In NI, only first row is correct when I look at the TIS override version I made with the NI "image to TIS" tool.
    7pa7s4t1v3te.png

    Same for the created PVRZ file:
    b8vivhgjtg77.png

    Will I have to manually divide the tile blocks based on the original layout of the pvrz texture like I did with the Beregost forge example in first post? :neutral:
  • argent77argent77 Member Posts: 3,478
    Leilu wrote: »
    argent77 wrote: »
    I can see the lines clearly even in NI when I open a map with the upscaled tileset (e.g. BG2 map AR0070).

    The visible lines are more likely an issue of your upscaling procedure. I take it you upscaled pvrz textures individually?

    In that case edges wont really fit together since the scaler is unable to take information from adjacent textures into account. I think that can only be solved in a satifactory manner by exporting the tileset as a whole, performing the upscaling, and then manually dividing the tile blocks based on the original pvrz texture layout.

    Yes, I knew from the beginning that by working on cut images to upscale them, I would have visible problems when the game will put them together. This is normal because the upscale software can't guess to treat the edges of the tiles correctly as if they were all assembled.

    I want to export the tileset as a whole and I think best file for this is TIS file which is already a whole tileset. The problem is that I can't understand how the game and nearinfinity handle the image to TIS conversion to match the default game tilling and file structure.

    The game itself maps each tile individually in the associated WED file. But that's not a problem, since the regular map can be easily converted to a coherent graphics file with the right map dimensions. Extra tiles (such as opened/closed states of doors or water overlays) have to be processed separately though.

    Processing the whole tileset should work, but because the game renderer itself is somewhat buggy you have to be careful when the upscaled image sources are converted back to tilesets later on without creating annoying lines in the game.

    It might work if you first create palette-based tilesets from your processed image sources (via Tools > Convert > Image to TIS) and then use NI to manually convert them into the pvrz-based variant. If done from the TIS resource view (button Export... > as PVRZ-based TIS) NI will attempt to reduce the line artifacts to a minimum by taking WED file information into account. It would still be a time-consuming task though.
  • LeiluLeilu Member Posts: 67
    Thank you.

    Are you sure the Tools > Convert > Image to TIS tool is working as intended? It looks like only the first row is saved no matter what (legacy or pvrz-based TIS version tested).
    The result I get on the screenshot on my previous post when I browse the new TIS file in NI and his abnormally low file size tells me that. 378Ko for the 960x768px PNG file, only 78Ko for the converted TIS file. Data is clearly lost during conversion to TIS file.
  • argent77argent77 Member Posts: 3,478
    The converter should work fine. Did you change the slider or value for the number of tiles to convert? By default it selects the max. number of tiles provided by the source image.
  • LeiluLeilu Member Posts: 67
    edited April 2022
    Haha, I always matched the number I see on the original TIS file. Dumb :smiley:
    That's working now thanks.

    Edit:
    snhzgrxm6yq4.png
    Nice!

    I still have to work on all the areas where there are small tiles and animations (like here at fireplace) but it will already be much less time consuming than what I intended to do with manual tilling in photoshop for every area.

    Thank you very much.
  • LeiluLeilu Member Posts: 67
    @argent77 Is it possible to do a mass "Image to TIS" in NI?
  • argent77argent77 Member Posts: 3,478
    Leilu wrote: »
    @argent77 Is it possible to do a mass "Image to TIS" in NI?

    No, it's not. The number of tiles does not always match the source image size (usually because the last row of tiles isn't filled completely), so you have to adjust it individually for each conversion.
  • LeiluLeilu Member Posts: 67
    edited April 2022
    I just finished treating all areas of BGEE with the new method with the help of argent77. Too bad mass "Image to TIS" is not possible. Going through each file one by one is far from being fun. :'(
    This should fix all horizontal and vertical line problems except for doors, fireplaces, water and all other animated tiles. All this will be fixed slowly but surely.



    rh5mus406i57.png
    fixed to
    hxk2i6yffboo.png

    I would like to make a weidu mod of it in order to make the installation but especially the uninstallation less prone to error. It can be difficult to know which files to delete in the override folder when you have a lot of other mods installed.
    The problem is that I don't understand anything about weidu. :D
    Post edited by Leilu on
  • silvereaglesilvereagle Member Posts: 19
    Hi,

    I wrote a custom installer for this mod:
    BGEE
    BG2EE

    The installer and mod files are currently in a forked Github repository, send me a message if you want them to be stored differently / elsewhere.
  • LeiluLeilu Member Posts: 67
    @silvereagle Thank you.
    It's ok for me.
    If you could just put "WillScarlettOhara's" somewhere in your exe as a token of appreciation for the work done please.

    BG2EE 100% done on areas without doors, fireplaces, water, flags or any animation tiles.
    Download BG2EE AI Denoised Areas v220419
  • silvereaglesilvereagle Member Posts: 19
    Leilu wrote: »
    If you could just put "WillScarlettOhara's" somewhere in your exe as a token of appreciation for the work done please.

    Of course, I'll update the executable soon. Thanks for the great work!
  • LeiluLeilu Member Posts: 67
    Leilu wrote: »
    If you could just put "WillScarlettOhara's" somewhere in your exe as a token of appreciation for the work done please.

    Of course, I'll update the executable soon. Thanks for the great work!

    Nice ty. Do you plan to integrate an uninstaller? I think this would be the biggest added value of such a program: to be able to delete only the right files from the override folder without the risk of deleting wrong files from other installed mods.
  • silvereaglesilvereagle Member Posts: 19
    It's already there. You need to run it from command prompt with -r or --remove option.
  • LeiluLeilu Member Posts: 67
    Nice.

    BGEE AI Denoised Areas updated to v220420
    I forgot one area.
  • LeiluLeilu Member Posts: 67
    I finally figured out how to make a WEIDU installer.

    Download
  • EndarireEndarire Member Posts: 1,519
    edited August 2022
    @Leilu
    Thankee for sharing these mods!

    Are all the backgrounds now denoised?

    Is the BG1EE version EET compatible? (I assume so, but wish to ask here.)
  • EndarireEndarire Member Posts: 1,519
    @Leilu
    Greetings again!

    At least for your BG2EE denoised areas, it seems easy to add EET compatibility. Change "REQUIRE_PREDICATE GAME_IS ~bg2ee~ @1003" to "REQUIRE_PREDICATE GAME_IS ~bg2ee eet~ @1003".

    For BG1EE (non-SoD) denoised areas, any map name the normally starts with "AR" like "AR1000" instead starts with BG when playing on EET. Thus, AR1000 on BG1 becomes BG1000 on EET.

    There may be more involved in converting these files, but this is at least a good start.

    Thankee!
  • EndarireEndarire Member Posts: 1,519
    edited March 2023
    @Leilu
    After testing it, installing BGEE Denoised Areas on EET scrambles the graphics for the BG2 areas due to the reasons in my previous post. They are VERY not compatible!

    BG2EE Denoised Areas on EET with the aforementioned slight .TP2 edit (adding eet beside bg2ee) worked.

    Thankee!
  • ZquigzZquigz Member Posts: 4
    edited May 2023
    Hey so, I just changed the prefix of the BG EE PVRZ files from Axxxxxx to Bxxxxxx and I changed the ARxxxx.tis files to BGxxxx also updated the TP2 for EET and it seems to work perfectly fine for EET.

    Thank you Leilu!
  • EndarireEndarire Member Posts: 1,519
    @Zquigz
    How do we get these updated files for EET?

    Thankee!
Sign In or Register to comment.