A Better Texture

Soul_RiderSoul_Rider Mod Bean Join Date: 2004-06-19 Member: 29388Members, Constellation, Squad Five Blue
edited February 2016 in NS2 General Discussion
NS2 material files (textures) are encoded in the microsoft .dds texture format using the NS2 builder. This builds files using the Nvidia DDS plugin. Paint.Net is a paint program which natively saves to .dds files, and originally being a microsoft student project, it benefits from using better .dds algorithms. I want to show in this post how to drastically reduce the texture file size, and maybe even improve the visual quality of NS2.

UI Improvements

I am going to start with a UI example. Unfortunately, as this uses transparencies, it doesn't quite show up correctly on the forums, but it does provide a good reference comparison between the source file, the actual NS2 builder version of the dds, and the paint.net dds.
alpha%20dds_zpsartlrxhe.png

As you can see, the paint.net dds file is much closer to the original PSD file. It has retained much more information and is less blurry. The most interesting thing about this is the file sizes:

Builder dds - 512KB
Paint.Net dds - 384KB


So for build menu icons and other UI elements, we can save file space and improve image quality. Lets move onto non-alpha textures.

Converting NS2 files

As I don't have any NS2 source files to work from, I took an NS2 dds file, and exported it out directly from paint.net. I was expecting a files size saving, but also some image quality loss, as going from dds-dds. The file I chose was materials\kodiak\kod_bark1

The first thing I am going to mention is the file size difference:

Builder dds - 1024x1024 1.33MB
Paint.net dds - 1024x1024 512KB


That is over a 50% saving. What is more, upon further investigation, at 500% zoom, it turns out the file is a 100% exact pixel for pixel replica of the original NS2 file. Same image quality, less than 50% disk space. this was verified by @Kouji_San

This is all well and good, but what I really need is access to a source file, so I can try and prove image quality improvements AND file size savings. @Kouji_San to the rescue again.

Custom Source Files

Kouji is just about to release his new Primal Fade skin, so he decided to build the dds with the normal Nvidia DDS plugin (used from photoshop rather than builder, but gives same results as same plugin), and Paint.net. Kouji overpaints the original dds files, so while they start off as the same quality as NS2, by the time kouji has finished, the image is a much higher quality. So let's see the results:
24668134461_0b833cf63b_o.jpg

24643809832_384c9e3338_o.jpg

Beautiful work, and this is/will be available to download on the steam workshop now/soon.

As you can see, the Nvidia plugin is blurry, as seen in the textures in NS2 if you look closely at them, yet the paint.net version is sharper, containing a higher level of detail. Even I was surprised by this difference. So what about the file sizes on this one? Well, we have seen an improvement in image quality, and we also see an improvement in filesize, although not as large in the straight dds-dds conversion:

Nvidia DDS plugin - 2048x2048 - 2.73MB - 8MB (Total files for model)
Paint.Net DDS - 2048x2048 - 2.0MB - 6.0MB (Total files for model)


This saving is more in line with the saving received in the UI icons files, indicating improved visual quality does slightly impact on the savings made in filesize.

What Next?

I am currently working through all the textures used in kodiak, and am going to make a mod using straight paint.net converted dds files, to see if as well as install size, the changes have any noticable difference on loading times and texture memory usage. With the current Texture Memory issues, and the want to monetise through cosmetic skins, I think this is something that should be very seriously investigated. I will continue to update this thread with my findings.

Any comments and feedback are much appreciated.
«1

Comments

  • ObraxisObraxis Subnautica Animator & Generalist, NS2 Person Join Date: 2004-07-24 Member: 30071Super Administrators, Forum Admins, NS1 Playtester, Forum Moderators, NS2 Developer, Constellation, NS2 Playtester, Squad Five Silver, WC 2013 - Supporter, Subnautica Developer, Pistachionauts
    edited February 2016
    I'm already working on texture file size reduction for a future patch.
  • IeptBarakatIeptBarakat The most difficult name to speak ingame. Join Date: 2009-07-10 Member: 68107Members, Constellation, NS2 Playtester, Squad Five Blue, NS2 Map Tester, Reinforced - Diamond, Reinforced - Shadow
    edited February 2016
    Obraxis wrote: »
    I'm already working on texture file size reduction for a future patch.

    Can we get some details because so far this thread has more work shown on it than the trello topic has had in the past year.

    This is coming from someone who has texture loading issues and is excited to see what kind of optimizations are in store.
  • Kouji_SanKouji_San Sr. Hινε Uρкεερεг - EUPT Deputy The Netherlands Join Date: 2003-05-13 Member: 16271Members, NS2 Playtester, Squad Five Blue
    edited February 2016
    I would like to have my NS2 footprint changed from 9.2Gb to ~6Gb and with that also less "blurry vision", we already get enough of that from that FXAA nonsense :D

    Also this new DDS plugin can actually convert the files within 2-3 seconds instead of the time it takes for ye'olde 2013 NVIDIA plugin, which is in between 10-15 seconds for 2048x2048 files. On a bloody Overclocked i5 2500K @4.5Ghz with ATI HD5870 nonetheless...



    Sidenote:
    Hehe "just about to release". Well nooooooooo t yet, this was more of a sneakpeak. Right now I am working on a skinpack for all aliens based on the old NS aliens (nostalgia aliens-like), but this time with more detail. And while I'm at it also fixing some texture errors in the original vanilla NS2 DDS files for this one, they kinda popped out like a sore thumb on this black fade

    Primal aliens: These battle hardened veterans have been around since the beginning, indicated by their original skin color. Having endured a lot of battles over the years, they're now covered in scars
  • Kouji_SanKouji_San Sr. Hινε Uρкεερεг - EUPT Deputy The Netherlands Join Date: 2003-05-13 Member: 16271Members, NS2 Playtester, Squad Five Blue
    Been playing around a bit with @GhoulofGSG9's crystalnvcompress and while the filesize is the same as the NS2 files, it does retain more detail. however I'm not entirely convinced it beats Paint.net's detail level. In the darker areas it does, but in the lighter areas it's either a tie or just in favor of Paint.net's DDS file...

    But I'll let you guys judge :)
    24396309829_4956d85549_o.jpg
    24468441450_79c3c184de_o.jpg
    24137118693_7f49dc1bc3_o.jpg
  • 2cough2cough Rocky Mountain High Join Date: 2013-03-14 Member: 183952Members, Reinforced - Shadow, WC 2013 - Supporter
    I only kind of understand what's goin on here, but kudos regardless.
  • NordicNordic Long term camping in Kodiak Join Date: 2012-05-13 Member: 151995Members, NS2 Playtester, NS2 Map Tester, Reinforced - Supporter, Reinforced - Silver, Reinforced - Shadow
    edited February 2016
    You know something is going to be well said when mcglaspie feels the need to make a post. That is quite the informative post. Thank you.

  • AsranielAsraniel Join Date: 2002-06-03 Member: 724Members, Playtest Lead, Forum Moderators, NS2 Playtester, Squad Five Blue, Reinforced - Shadow, WC 2013 - Shadow, Subnautica Playtester, Retired Community Developer
    Well thats a quality thread if i have ever seen one :) keep it going!
  • NordicNordic Long term camping in Kodiak Join Date: 2012-05-13 Member: 151995Members, NS2 Playtester, NS2 Map Tester, Reinforced - Supporter, Reinforced - Silver, Reinforced - Shadow
    I wonder if it would be feasible to shrink all maps and models by maybe 50% and adjust speed to match. It would feel the same in game. Or does it not work that way?
  • ObraxisObraxis Subnautica Animator & Generalist, NS2 Person Join Date: 2004-07-24 Member: 30071Super Administrators, Forum Admins, NS1 Playtester, Forum Moderators, NS2 Developer, Constellation, NS2 Playtester, Squad Five Silver, WC 2013 - Supporter, Subnautica Developer, Pistachionauts
    Soul_Rider wrote: »
    I thought NS2 was now supposed to be about open development, not cryptic one line 'don't bother doing this I'm doing something similar' type remarks

    1) I was in a rush (working on 2 game projects at the same time leaves me with little time), but I wanted to give you a quick heads up so that you didnt spend all your time doing something which ultimately would be futile and done for you.

    2) McGlaspie's post is much more informative and accurate than I could ever give.

    Hope this makes sense.
  • GhoulofGSG9GhoulofGSG9 Join Date: 2013-03-31 Member: 184566Members, Super Administrators, Forum Admins, Forum Moderators, NS2 Developer, NS2 Playtester, Squad Five Blue, Squad Five Silver, Reinforced - Supporter, WC 2013 - Supporter, Pistachionauts
    edited February 2016
    Just wanted to add a few things to McGlaspie comment:

    First of all everyone can download the crystal lib based nvcompress tool here: https://drive.google.com/file/d/0B_AoHvDBSRoDMWlTNTdlUjFGeDA/view?usp=sharing (just extract it into your ns2 install folder) .

    The major advantage of it beside a slightly better quality is that it's up to 10 times faster on PCs that do not have a CUDA compatible GPU (so all AMD/intel cards).

    Beside nvcompress there is also amdcompress: http://developer.amd.com/tools-and-sdks/graphics-development/amdcompress/ which also tends to create slightly better results than nvcompress but can't open psd files.

    Also as the OP pointed out correctly is that nvcompress has indeed problems with the newer version of the psd format. Therefor i recommend to save your source files as tga instead of psd to guarantee the best results ;)
  • McGlaspieMcGlaspie www.team156.com Join Date: 2010-07-26 Member: 73044Members, Super Administrators, Forum Admins, NS2 Developer, NS2 Playtester, Squad Five Blue, Squad Five Silver, Squad Five Gold, Reinforced - Onos, WC 2013 - Gold, Subnautica Playtester
    edited February 2016
    Nordic wrote: »
    I wonder if it would be feasible to shrink all maps and models by maybe 50% and adjust speed to match. It would feel the same in game. Or does it not work that way?
    I'm not sure what you meant by "speed". Reducing the texture resolution of XYZ texture...sure, that's an option...However, said reductions must be carefully balanced between performance considerations and visual fidelity. That balance is preciously what @Obraxis is working towards. ;)

    If you meant speed as in the context of "Units of Measurement-Scale", then...no, we're not even slightly considering such drastic changes. To do so, would impact damn near everything in the game. From LOS calculations to cyst-chain

    FYI, the texture optimizations Obraxis is working on (and has been for over a week), will be _phased in_ (hue hue hue) into future builds as the optimizations merit it (safely).
    We're always on the look-out for potentially memory savings.

    Just wanted to add a few things to McGlaspie comment:

    First of all everyone can download the crystal lib based nvcompress tool here: https://drive.google.com/file/d/0B_AoHvDBSRoDMWlTNTdlUjFGeDA/view?usp=sharing (just extract it into your ns2 install folder) .

    The major advantage of it beside a slightly better quality is that it's up to 10 times faster on PCs that do not have a CUDA compatible GPU (so all AMD/intel cards).

    Beside nvcompress there is also amdcompress: http://developer.amd.com/tools-and-sdks/graphics-development/amdcompress/ which also tends to create slightly better results than nvcompress but can't open psd files.

    Also as the OP pointed out correctly is that nvcompress has indeed problems with the newer version of the psd format. Therefor i recommend to save your source files as tga instead of psd to guarantee the best results ;)

    Pertaining to PSD files, for the usage of mods....always, always, ALWAYS save PSD files in "Maximum Compatibility" format. Otherwise, you run into issues with ncompress (or other programs) not knowing WTF source files are (due to additional data in file header).
  • Kouji_SanKouji_San Sr. Hινε Uρкεερεг - EUPT Deputy The Netherlands Join Date: 2003-05-13 Member: 16271Members, NS2 Playtester, Squad Five Blue
    edited February 2016
    @McGlaspie you know, I was vaguely reminded of mipmaps, but never thought it was the cause here. I was just impressed by the "lower file size+high image quality". I'm guessing it needs 3 mipmaps (High/Medium/Low)? So the higher quality is there because, more of that 2Mb (down from 2.7Mb with mipmaps) is used for the image data.

    @GhoulofGSG9, I do have another question though, the DDSplugin (the slow and old one on non CUDA :D ) has a lot of settings, one of which is a sharpen option. Could a 1px sharpen option get rid of that ugly blur to some extent and if so, can builder somehow pass commands to nvcompress?

    1px or 0.5px smart sharpen (or unsharp mask) in the PSD and then having builder do it's thing, seems to kinda do the trick. It looks similar to the Paint.net increased detail, however with sharpening also comes that tad bit grittier look. At first glance though it looks a lot more detailed and appealing compared to that blurry vision we now have. Besides you can always FXAA the crap out of it anyways :D



    Also it seems most spec maps in NS2 (if not all, I didn't check) are compressed using the DX5 method. Causing double the file size, because of that interpolated alpha, I assume. However when using builder/crystalnvcompress, they seem to be compresses into DX1 (1 bit alpha?) files. If that isn't a problem, there is a lot of filespace to save from there, something around 50% for all those x_spec.dss files

    5.33Mb vs 2.66Mb for 2048x2048 files


    All this talk about TGA files, they seem to be skipped by builder, for whatever reason (tried 16/24/32 bits/pixels uncompressed), I do see the reference in the builder_setup.xml. The "Maximum Compatibility" PSD files do work fine though :tongue:
  • ObraxisObraxis Subnautica Animator & Generalist, NS2 Person Join Date: 2004-07-24 Member: 30071Super Administrators, Forum Admins, NS1 Playtester, Forum Moderators, NS2 Developer, Constellation, NS2 Playtester, Squad Five Silver, WC 2013 - Supporter, Subnautica Developer, Pistachionauts
    Funny @SquishpokePOOPFACE - but some of the NS2 textures are over 4K in size, which is clearly ridiculous. It's needed for both space, RAM and GPU/VRAM savings.
  • Soul_RiderSoul_Rider Mod Bean Join Date: 2004-06-19 Member: 29388Members, Constellation, Squad Five Blue
    edited February 2016
    @McGlaspie - I appreciate the post, however there is one thing you haven't mentioned in all of this - Image Quality.

    So it turns out, when you use Nvidia DDS plugin, it adds a 'blur' to gradients to help hide pixelation. But as you can clearly see from the first image, that blur instead of gradient makes textures a blurry mess.

    So even if paint.net uses the same file size when using mipmaps, it does not blur the images. NS2 being blurry is something that has been complained about since day 1, and the cause it seems is the Nvidia DDS plugin.

    Is there any chance that the new changes will at least use a plugin that doesn't blur gradients?

    Also that can't run paint.net as a command line thing, are you seriously telling me you rebuild the entirety of NS2 materials everytime you make a new NS2 build? I could see a pretty big optimisation in your build process there...

    ---Edit---
    My bad, didn't see the other compression tool Ghoul linked. Certainly an improvement over the standard builder version.
  • BeigeAlertBeigeAlert Texas Join Date: 2013-08-08 Member: 186657Members, Super Administrators, Forum Admins, NS2 Developer, NS2 Playtester, Squad Five Blue, Squad Five Silver, NS2 Map Tester, Reinforced - Diamond, Reinforced - Shadow, Subnautica Playtester, Pistachionauts
    edited February 2016
    Soul_Rider wrote: »
    @McGlaspie - I appreciate the post, however there is one thing you haven't mentioned in all of this - Image Quality.

    So it turns out, when you use Nvidia DDS plugin, it adds a 'blur' to gradients to help hide pixelation. But as you can clearly see from the first image, that blur instead of gradient makes textures a blurry mess.

    So even if paint.net uses the same file size when using mipmaps, it does not blur the images. NS2 being blurry is something that has been complained about since day 1, and the cause it seems is the Nvidia DDS plugin.

    Is there any chance that the new changes will at least use a plugin that doesn't blur gradients?

    Also that can't run paint.net as a command line thing, are you seriously telling me you rebuild the entirety of NS2 materials everytime you make a new NS2 build? I could see a pretty big optimisation in your build process there...

    ---Edit---
    My bad, didn't see the other compression tool Ghoul linked. Certainly an improvement over the standard builder version.

    No, but we are NOT going to have McG re-save all the art assets BY HAND every time it DOES get rebuilt. That's ridiculous to suggest.

    Also, I don't have a clue what you mean by blurring images... it certainly isn't doing any blur operations to the image.

    Here's a small section of "models/props/refinery/docking_clerical_01". PSD on the bottom, dds on the top, magnified by 400%, nearest neighbor resampling. There is NO blurring going on here. Maybe paint.net is doing some kind of sharpening filter?
    VWuHG3J.png

    EDIT: and fyi, I chose this section of the image because when I set the top layer to difference, this section lit up the most... so this is just about the worst case scenario, at least on this image.
  • soccerguy243soccerguy243 Join Date: 2012-12-22 Member: 175920Members, WC 2013 - Supporter
    For what it's worth the OP's first picture the builder icon looks blurry to me.

    Also I made a gif of the fade's he made. The builder skin definitely is smoothed/blurred. This gif is certainly compressed but you can still see.
    http://gifmaker.cc/PlayGIFAnimation.php?folder=2016020204W6ii1M35TEElm59Plm9EJk&file=output_YS0hVh.gif
  • CalegoCalego Join Date: 2013-01-24 Member: 181848Members, NS2 Map Tester
    edited February 2016
    Nordic wrote: »
    I wonder if it would be feasible to shrink all maps and models by maybe 50% and adjust speed to match. It would feel the same in game. Or does it not work that way?

    This is stuff I'm making up so if someone knows better please correct me.

    The "size" of the model doesn't really matter. Since the "size" of everything in the map is relative to itself you end up with the same thing when you scale everything at once. It's just a different arbitrary value of "size". This is why the units in the mapmaker are arbitrary, they are meaningful relative to one another, but not to anything else.

    Some number (say 64) of units in the Editor might be something like 1 meter IRL, but that's only because that scale is observed based on the other models and reference points we have (namely the marine model).

    Anyway, point is, there's two factors that determine a texture size. Dimensions and Complexity.

    Super Simplified demo:
    These .gif files have the dimensions of 128px by 128px.
    lb1OwV2.gif
    Size: 1Kb
    jklGE8o.gif
    Size: 4Kb (even though it's just adding in one more color for half of the image, note that it might be more than one color because gif is dumb and has to dither)

    Similarly, Simply resizing the plain white gif up by 200%:
    YPy4xvL.jpg
    Size: 2Kb

    Big games these days are mostly due to Massive texture files. Because Big textures look gorgeous. The higher the resolution of a texture, the less you realize it's a texture.
  • BeigeAlertBeigeAlert Texas Join Date: 2013-08-08 Member: 186657Members, Super Administrators, Forum Admins, NS2 Developer, NS2 Playtester, Squad Five Blue, Squad Five Silver, NS2 Map Tester, Reinforced - Diamond, Reinforced - Shadow, Subnautica Playtester, Pistachionauts
    Did you just make a GIF to compare texture quality?
  • Kouji_SanKouji_San Sr. Hινε Uρкεερεг - EUPT Deputy The Netherlands Join Date: 2003-05-13 Member: 16271Members, NS2 Playtester, Squad Five Blue
    edited February 2016
    BeigeAlert wrote: »
    Did you just make a GIF to compare texture quality?

    well if comparing gif vs gif, I guess it's legit right
  • CalegoCalego Join Date: 2013-01-24 Member: 181848Members, NS2 Map Tester
    edited February 2016
    BeigeAlert wrote: »
    Did you just make a GIF to compare texture quality?

    Mostly demonstrating how dimension-size and complexity increase an image's filesize (regardless of format or compression methods and such things that make my overly simplified demo more complicated). Since Textures are images at their heart i figured it would show the point :tongue: .
  • ChrisStarkChrisStark Germany Join Date: 2016-02-11 Member: 212895Members, NS2 Playtester
    I would do the resaving by hand! If it is worth it. But did I understand right: The filesize is not the problem, but the resolution, that causes the memory overload? When itis the filesize, gimme the psds and I resave them with Paint.net :smiley:
  • Kouji_SanKouji_San Sr. Hινε Uρкεερεг - EUPT Deputy The Netherlands Join Date: 2003-05-13 Member: 16271Members, NS2 Playtester, Squad Five Blue
    edited March 2016
    ChrisStark wrote: »
    I would do the resaving by hand! If it is worth it. But did I understand right: The filesize is not the problem, but the resolution, that causes the memory overload? When itis the filesize, gimme the psds and I resave them with Paint.net :smiley:

    No it's that Paint.net doesn't create mipmaps, which are needed for various resolutions, that is also the reason is probably retains more detail. It can use that extra dataspace for pixeldetails. The new Builder Crystalnvcompress comes close to the sharpness of Paint.net, can be automated and has mipmaps. So that's what the new way of doing stuff, you do need the nvcompress plugin in your NS2 folder for it to work though.

    They have not yet done this conversion, cause there are a few DXT5 interpolated alpha's in the NS2 material folder that eat up more Mb's than they should, when they aren't even using an alpha mask. But all of em are done that way, cause some do use an alpha mask. That is another area where dataspace could be saved.

    Time for 64-bits yo :D
  • ChrisStarkChrisStark Germany Join Date: 2016-02-11 Member: 212895Members, NS2 Playtester
    Kouji_San wrote: »
    No it's that Paint.net doesn't create mipmaps, which are needed for various resolutions, that is also the reason is probably retains more detail. It can use that extra dataspace for pixeldetails. The new Builder Crystalnvcompress comes close to the sharpness of Paint.net, can be automated and has mipmaps. So that's what the new way of doing stuff, you do need the nvcompress plugin in your NS2 folder for it to work though.

    After rereading the whole thread I got that.
    Kouji_San wrote: »
    They have not yet done this conversion, cause there are a few DXT5 interpolated alpha's in the NS2 material folder that eat up more Mb's than they should, when they aren't even using an alpha mask. But all of em are done that way, cause some do use an alpha mask. That is another area where dataspace could be saved.

    Got that now, too.
    Kouji_San wrote: »
    Time for 64-bits yo :D
    Yeah you are right. How hard would this be btw. @McGlaspie ?
  • Kouji_SanKouji_San Sr. Hινε Uρкεερεг - EUPT Deputy The Netherlands Join Date: 2003-05-13 Member: 16271Members, NS2 Playtester, Squad Five Blue
    Or you know we could go NS2Pixel :D
  • IeptBarakatIeptBarakat The most difficult name to speak ingame. Join Date: 2009-07-10 Member: 68107Members, Constellation, NS2 Playtester, Squad Five Blue, NS2 Map Tester, Reinforced - Diamond, Reinforced - Shadow
    ^ Looks like my game for a minute before the textures load in.
  • Soul_RiderSoul_Rider Mod Bean Join Date: 2004-06-19 Member: 29388Members, Constellation, Squad Five Blue
    Kouji_San wrote: »
    ChrisStark wrote: »
    I would do the resaving by hand! If it is worth it. But did I understand right: The filesize is not the problem, but the resolution, that causes the memory overload? When itis the filesize, gimme the psds and I resave them with Paint.net :smiley:

    No it's that Paint.net doesn't create mipmaps, which are needed for various resolutions, that is also the reason is probably retains more detail. It can use that extra dataspace for pixeldetails.

    @Kouji_San, @ChrisStark

    Paint.net DOES create mipmaps, it's just I wasn't ticking the box, hence why the file size was smaller.

    When you turn MipMaps on in Paint.net, the file size is the same as builder, it is just better quality.

    Hope that clarifies it for you.


  • Kouji_SanKouji_San Sr. Hινε Uρкεερεг - EUPT Deputy The Netherlands Join Date: 2003-05-13 Member: 16271Members, NS2 Playtester, Squad Five Blue
    Soul_Rider wrote: »
    Kouji_San wrote: »
    ChrisStark wrote: »
    I would do the resaving by hand! If it is worth it. But did I understand right: The filesize is not the problem, but the resolution, that causes the memory overload? When itis the filesize, gimme the psds and I resave them with Paint.net :smiley:

    No it's that Paint.net doesn't create mipmaps, which are needed for various resolutions, that is also the reason is probably retains more detail. It can use that extra dataspace for pixeldetails.

    @Kouji_San, @ChrisStark

    Paint.net DOES create mipmaps, it's just I wasn't ticking the box, hence why the file size was smaller.

    When you turn MipMaps on in Paint.net, the file size is the same as builder, it is just better quality.

    Hope that clarifies it for you.


    Alright, but can ya batch it :D
Sign In or Register to comment.