Page 1 of 1

The "secrets" of nvdxt

Posted: 19.03.2004, 21:50
by jim
Hi all,

I've notice that a lot people have problems to use Nvidea's nvdxt commandline tool. Therefore I will try to explain it a bit. I'd used for my examples the version 6.54 of nvdxt.

You get this tools here: http://developer.nvidia.com/object/nv_t ... tools.html
There is also a useful html documentation.

What can nvdxt do for Celestia?

1. It convert textures to DDS format,

- input formats: tga, bmp, gif, ppm, jpg, tif, cel, dds ,png ,psd
but these formats was tested:
    - jpg: works only with '-swap' correct
    - png: only the 32bit format (with alpha) and with '-swap' works correct (common tools like Irfanview save only 24bit png's!)
    - tif: 24/32bit works (with and without alpha)
    - tga: 24/32bit works (with and without alpha)
- output formats (for Celestia):
    - dxt1a : 1bit alpha, fewer colors than dxt1c
    - dxt1c : use same compression as dxt3/5 but no alpha channel, all Nvidea cards show this with less colors because of a bug!
    - dxt3 : 4bit uncompressed alpha channel that means only 16 level!
    - dxt5 : compressed alpha channel allows 256 levels (theoretical 1792)
    - u888 : a simple uncompressed 24 bit RGB picture with 8bit per channel
    - u8888 : 32bit RGBA picture, includes 8bit alpha Channel

2. generates and filters mip maps,

3. does batch processing, extrem useful for virtual textures !

Now a list of useful parameters (there is no order):

    -file: input file to process. Accepts wild cards
    -deep [directory]: include all subdirectories
    -outdir : output directory
    -outsamedir : output directory same as input

    -nomipmap : don't generate MIP maps (use with virtual textures)
    -Cubic : create MIP maps with cubic filtering (use always except for VT's (there are a lote more filters but 'Cubic' is the best compromise of performence and quality)
    -dither : add dithering (smoother colors but adds noise !)
    -swap : swap rgb (must be used with jpg and png images because of a bug)

    the switch for the output format:
    -dxt1a ( only for special cases e.g. earth country borders )
    -24 dxt1c ( for textures without alpha, but on Nvidea hardware with reduced colors)
    -dxt3 ( best format without alpha (black alpha) on Nvidea hardware)
    -dxt5 ( the best format for textures with alpha channel)
    -u888 (useful for high quality normal maps)
    -u8888 ( only for "hifi" freaks, very large files on disc and memory )


There are many more parameters of nvdxt. Further it's possible to build normal maps but only from 8bit bump maps.

Examples: (of course the dimensions of all input files must be power of two)

nvdxt -file jupiter2k.jpg -swap -Cubic -24 dxt1c
- build a dxt1c dds file with mipmaps
- the mipmaps are build with cubic resample,
- the '-swap' switch corrects a bug of nvdxt concern all 'jpg' and 'png' files

nvdxt -file earth-clouds.png -swap -Cubic -dxt5
- build a dxt5 dds file with alpha (transparency) information and mipmaps
- the input png file must be 32bit (24bit color + 8 bit alpha channel)
- the '-swap' switch corrects a bug of nvdxt concern all 'jpg' and 'png' files

nvdxt -file tx_*.jpg -swap -deep -outsamedir -nomipmap -24 dxt1c
- this example shall show how all 'jpg' tiles of complete virtual texture can be converted to dds dxt1c
- place nvdxt and the bat file in front of the level folders

nvdxt -file tx_*.tga -deep -outsamedir -nomipmap -u888
(you have a nice normal map and has build the tiles for a VT in tga format)
- this example shows how all tiles of a VT in tga format can be converted to dds u888

tips:
- Copy 'nvdxt.exe' always to the place where your texture is.
- Build there a little 'bat' file with your nvdxt command.
- A 'bat' file can be build and edited with Notpad. To create such a file save it with the extension 'bat' instead of 'txt'. If you have still problems send greetings to MS and thanks for hideing file extensions by default. ;-)
- Start the conversion with double click on your 'bat' file.
- Nvdxt works very fast if no mipmaps are generated and compress always with a good quality.

Sorry all Linux or Mac user this is (win)DOS only. Maybe a dos emulator works on your sytem?

Bye Jens

Posted: 20.03.2004, 09:30
by t00fri
Let me also make a few remarks about my experiences with (recent) nvdxt tools.

After quite a number of emails with Doug, the author of nvdxt, they still cannot handle 16k textures and using the proper nvdxt mode, take /very/ long for DXT conversion (>15min or so on my machine for 8k). Moreover, until recently at least, the input was restricted to .tga format etc.

So I have essentially given up on these tools.

Based on the most interesting DeVIL graphics libs, I then wrote my own converter that works very well for me and does a few other things as well (see below). While until recently, the DeVIL lib had a few important bugs in the DXT conversion, this is gone.

Doug apparently has also tried to incorporate a /fast/ conversion routine, based on the much superior DeVIL code. I never found this mode very convincing in nvdxt.

My converter also handles big textures and that /very/ fast! About 30 sec (!) for a 8k DXT3 conversion.
Here is what my program texconvert can do:

Code: Select all

usage : texconvert  [-options] <input file> [output file]

options:
--------

 -x xsize   [px]
 -y ysize   [px]
 -f resize  {l=linear b=box, t=triangle, q=bell, B=B-spline=DEFAULT,
             h=hermite, L=Lanczos3, m=Mitchell}
 -d j        j=1=DEFAULT <=> DXT1, j=3 <=> DXT3, j=5 <=> DXT5 encoding
 -n          <=> nomipmaps
 -s sharpen {sharpen  for: 1.0 < s < 2.5,
             blurring for: 0.0 < s < 1.0}

input files:
------------

 .bmp .cut .dcx .dds .ico .jpg .lbm .lif .mdl .pcd .pcx
 .pic .png .pnm .psd .psp .raw .sgi .tga .tif .wal .act
 .pal Doom graphics

output files:
------------

 .bmp .dds .jpg .pcx .png .pnm .raw .sgi .tga .tif .pal

default output file is test.dds



I have offered it to people using Linux or Cygwin, but presently have unfortunately no time to port it to native Windows, although the DeVIL libs exist also for Windows. I also don't have the time to deal with many questions from people who do not know how to compile and link such a simple task...

Apart from these restrictions everyone is welcome to get and use my code. It is crucial however, to install the latest CVS version of DeVIL 1.66 or newer...

Bye Fridger

PS: let me add for completeness that I also coded a simple dds viewer (showgl), based on OpenGL and DevIL, but there are other solutions, for viewing DXT texture.

Posted: 20.03.2004, 19:51
by jim
Hi Fridger,

t00fri wrote:After quite a number of emails with Doug, the author of nvdxt, they still cannot handle 16k textures...
Now since Celestia supports virtual textures my biggest texture is 4k (for earth clouds and DSO's) :roll: :?:

t00fri wrote:... and using the proper nvdxt mode, take /very/ long for DXT conversion (>15min or so on my machine for 8k).
Not correct! Nvdxt needs round 2 minutes to comress a 8k tga texture to dxt1c on my slow 900MHz Duron and without useing the "-quick" option. The trick is the make the compression without building mipmaps because this works really slow. For this reson I've written a year ago a little DOS srip by useing 'Irfanview' and 'stitch' that build a complete 8k dxt1 texture with all mipmaps within 5 minutes.

Only a question: build Devil textures with mipmaps?

t00fri wrote:Moreover, until recently at least, the input was restricted to .tga format etc.

See my previous post I can say jpg, tif and 32bit png works very nice but other formats was not tested by me. ;-)
General can be said that only imput formats with 24 or 32 bit work.

I think nvdxt has some big advantages:
- It needs no dll's , additional software (Cygwin) or something else. It works simple everywhere and everytime on Windows.
- You can with one little command line all images in a folder or all subfolders convert. -> extrem useful for VT's

A complete 32k virtual texture (2730 tiles with 512 tile size) is compressed to dxt1c form jpg, tif or tga within 20 minutes on my little PC! :-)
I don't know an other tool that this can.

Bye Jens

Posted: 20.03.2004, 22:12
by t00fri
jim wrote:...
A complete 32k virtual texture (2730 tiles with 512 tile size) is compressed to dxt1c form jpg, tif or tga within 20 minutes on my little PC! :-)
I don't know an other tool that this can.

Bye Jens


Jens,

would I be completely wrong if I claim that you have no other program besides nvdxt at your disposal for comparison? :wink:


Bye Fridger

Posted: 20.03.2004, 22:20
by t00fri
jim wrote:Hi Fridger,

t00fri wrote:After quite a number of emails with Doug, the author of nvdxt, they still cannot handle 16k textures...
Now since Celestia supports virtual textures my biggest texture is 4k (for earth clouds and DSO's) :roll: :?:

t00fri wrote:... and using the proper nvdxt mode, take /very/ long for DXT conversion (>15min or so on my machine for 8k).
Not correct! Nvdxt needs round 2 minutes to comress a 8k tga texture to dxt1c on my slow 900MHz Duron and without useing the "-quick" option. The trick is the make the compression without building mipmaps because this works really slow. For this reson I've written a year ago a little DOS srip by useing 'Irfanview' and 'stitch' that build a complete 8k dxt1 texture with all mipmaps within 5 minutes.

Only a question: build Devil textures with mipmaps?

t00fri wrote:Moreover, until recently at least, the input was restricted to .tga format etc.
See my previous post I can say jpg, tif and 32bit png works very nice but other formats was not tested by me. ;-)
General can be said that only imput formats with 24 or 32 bit work.

I think nvdxt has some big advantages:
- It needs no dll's , additional software (Cygwin) or something else. It works simple everywhere and everytime on Windows.
- You can with one little command line all images in a folder or all subfolders convert. -> extrem useful for VT's

A complete 32k virtual texture (2730 tiles with 512 tile size) is compressed to dxt1c form jpg, tif or tga within 20 minutes on my little PC! :-)
I don't know an other tool that this can.

Bye Jens


Jens,

you may well be right with all your points. I don't care anymore. On my time scale, it all took much too long! Doug did not manage to get his code to perform reasonably fast over a many months' period, the memory management issue was a pain, such that I had plenty of time to write an entirely new code meanwhile. If you are happy with the nvdxt tools: perfect! Just go ahead...

The times I quoted for my texconvert included mipmaps.

Of course I may switch mipmaps off (see my commands list above), then everything becomes even much faster. His 'quick' mode is a recent addition, using the code from the DevIL library as I outlined before. As long as I had interest in nvdxt, I never managed to build an 8k texture in 5mins with my 1GHz PIII/512MB CL2! I normaly judge the code quality from its "default" behaviour, not from playing all sorts of odd tricks with it.

Any UNix program naturally can work on a whole load of input files without special effort. Only DOS command line stuff is usually so limited...

My code does not need Cygwin or anything else. I just don't need Windows, so I have never ported it to Windows. If someone wants to use it under Windows, he/she just needs to install DevIL for Windows and compile it for Windows. That's all. Every stupid Windows compiler does the job.

You said that you don't need to convert more than 4k textures because of VT's. Well, I usually have many critical looks to my textures /as a whole/ within Celestia, before I decide to chop them into VT's. For that purpose I need to convert 16k and 32k textures into dds. Many times. Fast!!

Bye Fridger

Posted: 21.03.2004, 14:42
by jim
Hi Frigder,

I do not say that Devil is not a good tool. Pesonally I think it's the better choise unter Linux. But correct me if I' wrong Devil has some problems with alpha channel and dxt3/5 compression and at the moment I use these formats very often.

May aim was only to demonstrade how easy it is to use nvdxt and that this tools has some nice features. I think a lot people havn't used it because they think it's to complicated and to slow. I use at the moment only the nvdxt and the Photoshop plugin for compression.

t00fri wrote:Only DOS command line stuff is usually so limited...
I know and it's a shame that MS spend Windows not a better script language.
Nevertheless I'd written some useful little scripts (but most of them never released):
- a VT script that build form 8k or 4k maps a complete virtual texture with all level folder's (use Irfanview on commandline)
- a script that convert all dds files of a VT level to tga inlcusive alpha channel
- a resize script for dds files with mipmaps
further some bash sripts for Cygwin and Imagemagic:
- two modified version of your VT scrip ( one especially for hig level VT addons )
- a reverse VT script can be used to build a single image of a part or the hole level of a VT.

t00fri wrote:My code does not need Cygwin or anything else. I just don't need Windows, so I have never ported it to Windows. If someone wants to use it under Windows, he/she just needs to install DevIL for Windows and compile it for Windows. That's all. Every stupid Windows compiler does the job.

This sounds so easy. ;-) We know that a lot people have still problems to edit a ssc file. Pesonally I think it's not an easy stuff to compile something unter Windows. I want not buy an expensive compiler software only for this job.

Bye Jens

Posted: 21.03.2004, 15:14
by t00fri
jim wrote:Hi Frigder,

I do not say that Devil is not a good tool. Pesonally I think it's the better choise unter Linux. But correct me if I' wrong Devil has some problems with alpha channel and dxt3/5 compression and at the moment I use these formats very often.


Jens,

as I mentioned, the DevIL code is independent of the OS, it's thus neither better nor worse for Linux or Windows. Since you are not using my code along with DevIL 166CVS, you probably have tried a DeVIL-based tool, somebody (Brendan?) compiled for Windows some time ago. That used an older version of DevIL and had indeed some problems with DXT3/5 etc.

For that reason I said that one needs to install DevIL 166CVS. DXT-format is for non-Celestians still a relatively rare image format and hence the code is not so well tested.

At least Doug himself stated that the DevIL code is much faster than his own one without sacrificing quality...

Bye Fridger