Jump to content


ApanLoon

Member Since 11 Jun 2017
Offline Last Active Today, 02:13 AM
-----

Posts I've Made

In Topic: [TOOL] KotOR Stuff

19 July 2017 - 01:25 PM

Assistance requested:

 

This will be a long post. It contains some tips about how to use the tpc tool but also questions about further development of the tool.

 

I just added the possibility to extract the TXI to a separate file when reading a TPC and conversely, to read the TXI from a separate file when creating a TPC. However, the command line options are a bit weird at the moment. I would like to get feedback on how these should be changed to make them more intuitive.

 

For the rest of this post, I will be talking about the current development branch on GitHub and NOT the currently released version. It behaves differently in regards to TXI.

 

The current help info looks like this:

$ ./tpc -h
Usage: tpc.exe [OPTIONS]+ [FILE]+

Operate on files in the Bioware TPC format.

Options:
  -n, --nofile               Don't output to a file, instead use stdout.
  -o, --output=VALUE         The format of the output file(s). Possible
                               options are: png, tif, raw, hex, tpc, none
  -i, --image=VALUE          The index of the image to extract.
  -s, --subimage=VALUE       The index of the sub image to extract or the
                               number of sub images to generate in new TPC.
  -t, --txi[=VALUE]          Dump the texture info or add TXI attribute to
                               new TPC. When adding an attribute, use the form -
                               -txi="key value..."
      --txipath=VALUE        Create this separate TXI file when reading a TPC
                               or read this separate TXI file when creating a
                               TPC.
  -c, --compress             Use DXT compression when creating new TPC.
  -f, --format=VALUE         Pixel format for new TPC. Possible options are:
                               Gray, RGB, RGBA, BGRA
  -p, --outpath=VALUE        Path and file name of output. Default is the
                               same as the input with a new extension.
  -h, --help                 Show this message and exit

Unless the nofile option is given, tpc.exe prints information about the file
on stdout. This example explains what is shown:

zc   64   64  6  7 42 RGBA         1 CM_rakata.tpc

  Flags:                      z=DXT compression, c=Cube map

  Width Height:               Of the full-size version of the image(s).
                              Each additional sub image, if any is reduced
                              in size by half width and half height.

  Number of images:           The number of full-size images. Cube maps have
                              six images.

  Sub images per image:       The number of sub images for each image.
                              The first is the full-size image, subsequent
                              sub images are mip maps.

  Total number of sub images: The header of some files indicate more sub
                              images than there is data for in the file.
                              This shows how many sub images there actually
                              are.

  Pixel format:               Gray, RGB, RGBA, SwizzledBGRA

  Unknown1:                   Float value of unknown purpose.

  Full path to the file

I realise that not many of you have even tested this yet, but I would like to have a cleaner way to tell the tool what type of output to generate and where to put that output.

 

The tool basically outputs three things: Info, Image and TXI

 

I think that he most common usage would be to output the image and TXI to files and print the info on stdout. Currently, this is what happens if you, for example, run this:

tpc -o png -t PO_PFHA3d.tpc C_HoloDodonna.tpc

The new files will be named PO_PFHA3d.png, PO_PFHA3d.txi, C_HoloDodonna.png and C_HoloDodonna.txi respectively and the info for the two TPCs are printed on stdout.

 

It is possible that, in some situations, you would want the image data to be sent to stdout instead of a file. An example of this would be if you want to rotate an image with something like ImageMagick before storing the file:

tpc -n -o png CM_HawkBay.tpc | convert - -rotate 90 CM_HawkBay.png

I don't know if this works in Windows "cmd" application, but I do know that it works in "bash" on Linux, OSX and Cygwin under Windows.

 

You also might want to filter stuff out from the info:

tpc -o none *.tpc | grep "RGB "

only lists the info for RGB files. Note the extra space at the end of the grep to make sure that it doesn't also match RGBA.

 

We can also get the TXI on stdout:

tpc -n -o none -t C_HoloDodonna.tpc | grep proceduretype

When you specify that the tool should not send output to a file with -n, the tool won't output the info as that would interfere with the image or TXI output. "convert", for example, would fail to read the png if the data also contained the text of the info.

 

Now we arrive at the more complex situations. What if we want both the info and the TXI on stdout? Like the currently released version does with -t?

It would be nice to see what TXI belongs to what TPC file when listing more than one. We might try:

tpc -n -o none -t *.tpc | grep proceduretype

But this doesn't do exactly what we want. From the result of this we will get a list of all proceduretype attributes, and that could be useful too, especially if you add " | sort | uniq" to the command line. However, we won't see which file has which attribute and that would probably be useful. There is no way to do this yet.

 

Question 1 to you is: What options should we have to make this happen?

 

Note that, when working on a lot of files, you might get an error such as this:

-bash: ./tpc: Argument list too long

If that happens, you should embed your command in a "find":

find AllTPCs/ -exec tpc -n -o none -t "{}" "+" | grep proceduretype | sort | uniq

The "+" will make find call tpc multiple times with an optimal(?) number of files each time.

 

Question 2 to you is: Are there other combinations of outputs that would be useful? Sending TXI to a file while sending the image to stdout or sending the info to a file, or...

 

Question 3 to you is: What additional options do we need? One I know already is that we should have a way to specify the unknown float that is put into new TPCs. Currently, this simply defaults to 1.0.

 

Question 4 to you is: What features/bugs need to be addressed and in what order? I.e. What features are most important to you?


In Topic: [TOOL] KotOR Stuff

18 July 2017 - 09:37 PM

Cool. I am happy that you like it. :D

 

There are still some types of TPC files that this tool can't read and there are some questionable assumptions in the current code. I would appreciate any and all assistance making the code better and more complete.

 

I was told that TGA support is kind of important, so I might look into ways to add that. The library I use can't do TGA - only BMP, EMF, EXIF, GIF, ICO, JPEG, PNG, TIF and WMF. Adding more of those would be trivial, adding TGA is a bit of work but not too complicated, I think.


In Topic: [TOOL] KotOR Stuff

18 July 2017 - 03:39 PM

UPDATE: v0.3

 

The tpc tool can now convert PNG files to uncompressed TPC files.

 

The following example creates an uncompressed RGB file with two sub images (One full scale and one half-scale mip map) and a couple of TXI attributes:

tpc -o tpc -s2 --outpath PO_PFHA3d.tpc -txi="proceduretype cycle" -txi="channelscale 4 0.1 0.2 0.3 0.4" PO_PFHA3d.png

Note that it might still not be possible to create cyclic procedurals with this tool, I just added those TXI attributes to illustrate how it should be done.

 

To get some more info about what TXI attributes are used in game and how they need to be formatted for this tool, use the following command to examine an existing TPC file:

tpc -o none -t PO_PFHA3d.tpc

Run this on one, some or all the files in the texture pack to see what's in there.


In Topic: Apan Loon joined the forum

16 June 2017 - 02:32 PM

That depends on what is still needed. I don't have any specific plans for anything. I do know that the current version of mdlops and kotorblender doesn't exactly do what I want them to so I started talking with Purifier about the latter. I will take it from there and we will see. If anyone has suggestions, I am open to them.

 

I don't exactly know who currently maintains the tools and how contributing to them works, but I would like to know.


In Topic: Apan Loon joined the forum

16 June 2017 - 11:55 AM

Actually, both. :-)

 

I used older versions of these tools years ago but now I have a new pet project for which I would like to use the up-to-date and beyond versions of the tools. If there is anything I can do to help improve the tools, I would be happy to try.