Jump to content

46 posts in this topic Last Reply

Highlighted Posts

Posted:
Last Online:  
 

This is a tool I wrote to convert multiple png / bmp images into fsh images.

It takes a list of images and converts each image into a fsh file of the same name.

batfsh458.png?raw=1

The "Automatically process Mips" function generates Mipmaps for the different zoom levels.

The "Compress dat" function compresses the items when inserting them into the dat.

The simplest way to create a batch list is to drag and drop a group of images onto the list.

Draging and droping a group of images onto the "Add" button will add them to the existing list.

The other way to insert images is the "Add" function, this relies on "Groupid.txt" for the Group to assign the pngs to and "instRange.txt" for the Instance range to use.

The program will look for the alpha map in the same folder as the image with a filename like "filename<b>_a</b>.png" or if the image is a png that contains transparency the program will use the transparency to generate the alpha map if no alpha is found and the image is not transparent it will generate a plain white alpha.

In the "Add" function the Group id in the Group box overrides the one in "Groupid.txt" and if the image contain transparency and the file name begins with hd it will be a 32-bit hd fsh, if the image is not transparent and the file name begins with hd it will be a 24-bit hd fsh.

If the file name begins with 0x it will use the file name as the Instance.

To change the group, instance or Fsh Type of an image you must select that image in the list.

Download: PngtoFshBatch

I hope it is useful. 2.gif

  • Like 1

Share this post


Link to post
Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     

    Originally posted by: SimHoTToDDy

    I'm curious what our script savvy BATers can do with this, seems like a useful tool. quote>

    I assume by script you mean to be able to save the files using the command line for example C:\sc4bmps\001.png C:\sc4bmps\002.png /group:1ABE787D /dat:C:\sc4dat\test.dat

    That example would take 001.png and 002.png give them the group id 1ABE787D and the save them into a new dat called test.dat.

    It is not designed to be used that way, but that functionality could be added.

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    errrrm... there is only so much you can do with maxscript - getting maxscript to read and write files is one thing - getting it to launch a exe with commandline instructions I think is beyond its capabilities, unless of course if you can get maxscript to write a batch file that autodoes the commands to the PngtoFsh - bascially we will have two batch files here... hrmmmm


    I love coffee and buildings.

    You can find more info about me here > http://nbixelsimcity.tumblr.com/

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     

    Originally posted by: SimHoTToDDy

    No, I mean using this as opposed to the tools many of us use in 3ds max with BAT4MAX, or even the normal BAT in gmax.quote>

    Which tools do you mean to replace?

    Fsh file creation in the BAT is automatic, as for BAT4MAX  I believe it uses fshtool.

    This tool was designed to quickly convert multiple images after re-texturing.

    It was developed at SC4D:  https://www.sc4devotion.com/forums/index.php?topic=8047.0

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    Would someone please take the time to explain how this tool is used? 

    I managed (apparently by accident) to convert a png to a fsh. But on a second try (and two dozen tries later) I can not repeat this simple task.  I do not understand the interface so I can't begin to analyze the error statement -- "Index was outside the bounds of the array" -- ??? This means nothing to me. As far as I can tell I'm doing the same thing now as I did on the successful try.


    06sSignature.png

    No I; no you; no 'why'.

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     

    Images to be converted can be added to the list using the "Add" button or by dragging a group of images onto the list

    To change the group, instance id(s) and type of fsh the image you want to change must be selected in the list.

    The "Automatically process Mips" option generates the different zoom levels.

    To convert the items in the list the "Process" buton converts the items and saves them in the same folder as the original unless the output folder has been changed.

    The other way to convert items is the "Save dat" button which processes the items and saves them into a new dat.

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    Here is screenie of problem -

    Image2-2.jpg

    I have tried both SaveDat and Process method - both return this same error.


    06sSignature.png

    No I; no you; no 'why'.

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    Looks like you are using his default group...is this for a model?If this is not the intent , you need to change it by altering Groupid.txt (the same goes for instRange.txt) Also, basically the way the tool works (or how I use it) is whatever png id is what I want the FSH id to be, so I name them , then when running program , click on each individual png line and select what ever FSH creation method (no transparency , etc.) The exception report usually happens to me if I try to do a set , save .dat , then try to load another set to convert. The tool is very stable and works well. 

    Jayson


    NAM Associate

    BSC

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     

    Are any of those images 64 x 64 or smaller?

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    All images are 256x256, although some were not exactly square. Intended use is terrain mod. I have had some success but I also have some further questions -

    What are all these additional files ( .TGI)

    tt1.jpg

    Also, I editted Groupid.txt but output is not consistent - my Group ID is now Instance ID for all output files and Group ID is 00000000.

    tt2.jpg


    06sSignature.png

    No I; no you; no 'why'.

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     

    The TGI files are what the Reader uses to assign the TGI ids.

    Is it displaying the correct group and instance id(s) in the list but not in the Reader?

    If there is a group id entered in the group textbox it willl use the group id that instead of the one in "Groupid.txt"

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     

    Command line switches added, "Batch.txt" function removed and multiple bugs fixed.

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     

    The ability to drag and drop folders onto the list and Add button added.

    Multiple bugs fixed, File version updated to 1.4.4.1.

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     

    A few small bugs fixed, File version updated to 1.4.4.3

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    AS a resident expert on all things FSH I bet it is you who could be asked if there is any way to control how FSH images are coded/compressed. I ask because of very noticeable degradation of the image quality due to the conversion from bmp to fsh as shown here:

    77879c8c9f4a.jpg

    This effect is normally most apparent in a very dark (and more uniformly so) sections of the image

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     

    Both Dxt1 and Dxt3 would trim some information when compressing the image the effects of this trimming most visible in the darker areas.

    2569atd.jpg

    24-bit RGB and 32-bit ARGB also seem to distort the image when saving the image on the right

    For some reason the image on the left does not distort when I build the FSH myself.

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     

    I wrote a small tool that build a fsh and inserts the selected bitmap into it, it can only handle 32-bit and 24-bit fsh files and it does not seem to distort them when saving.

    That tool is attached.

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    Well result is... how shall I put it... it's great and all, but... it isn't compressed. basically it is a same BMP file just in FSH cocoon, so to say, right?

    The issue with this solution would be the size of files, since each such FSH will be 4x the size of those compressed (DTX3/DTX1).

    PS

    BTW could your programm be operated with command line

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     

    Saving Dxt1 and Dxt3 fsh images has been  added.

    The command line switches are:  /b: and /a: the alpha switch is optional.

    eg.  fshwrite /b:"C:\sc4bmps\New Folder\image.bmp" /a:"C:\sc4bmps\New Folder\alpha.bmp".

    If the image filename starts with "hd" it will be either a 32-bit or 24-bit fsh depending on if it has an alpha or not.

    If the image is a 32-bit png it will generate the alpha map based on the transparency.

    Paths with spaces may be used if encased in quotes.

     

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    you are the MAN, man! You're the MAN!!!!

    Brilliant converter!!! The DXT3 FSH looks just as good as original BMP and it weighs required 64K!

    Dammit! I should have checked this thread today before I've uploaded new version of Bat4Max to STEX.

    Well...I'll try to incorporate it into Bat4Max now!

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     

    Originally posted by: SimFox

    How can one with command line set the output folder as well as name of the created FSH file???quote>

    The output folder can now be set witn the /outdir: switch and the fsh name can be set with the /fshname: switch.

    eg fshwrite /b:"C:\sc4bmps\New Folder\image.bmp" /a:"C:\sc4bmps\New Folder\alpha.bmp" /outdir:"C:\sc4bmps" /fshname:test.fsh

    The help can be shown with /?.

    The error handling should hopefully catch and display all errors.

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    Originally posted by: SimFox

    you are the MAN, man! You're the MAN!!!!

    Brilliant converter!!! The DXT3 FSH looks just as good as original BMP and it weighs required 64K!

    Dammit! I should have checked this thread today before I've uploaded new version of Bat4Max to STEX.

    Well...I'll try to incorporate it into Bat4Max now!quote>

    Say it ain't so? Need I wait with baited breath to see such sights as these? Oh brave new world of quality!

    Quite the breakthrough Null, I'm dying to see this working with BAT4MAX.

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    ... and the best of luck to you!!

    To call this is a breakthrough would be a bit of an understatement, imagine being able to finally harness Max's rendering capabilities at 100% for SC4.

    Simfox, if you can do this, if I ever have a child, I will name it Simfox. 3.gif


     

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    ok...

    It's done... the quality could be seen in Bat4Max thread, here I just say that it is great.

    however the performance is a bit slow. It isn't anything terrible in absolute terms but in relative it is several times (subjectively I'd say 5-10 times slower than that of FSHtoll). In the end this doesn't really matter as we're talking about few second here anyway, I just wonder if this is normal and to be expected or if it is a sign of something going not to well.

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     

    Part of the speed issue may be the dxt compression, I am using the highest quality but slowest compression (the one on the top left).  

    The one on the top right is the second highest quality compression this is slightly faster and still should look fine.

    dxtcomp.png

    Share this post


    Link to post
    Share on other sites

    Sign In or register to comment...

    To comment in reply, you must be a community member

    Sign In  

    Already have an account? Sign in here.

    Sign In Now

    Create an Account  

    Sign up to join our friendly community. It's easy!  

    Register a New Account


    ×

    Thank You for the Continued Support!

    Simtropolis depends on donations to fund site maintenance costs.
    Without your support, we just would not be in our 24th year online!  You really help make this a great community. *:thumb:

    But we still need your support to stay online. If you're able to, please consider a donation to help us stay up and running. This helps sustain a platform where we can share our community creations for years to come.

    Make a Donation, Get a Gift!

    Expand your city with the best from the Simtropolis Exchange.
    Make a Donation and get one or all three discs today!

    STEX Collections

    By way of a "Thank You" gift, we'd like to send you our STEX Collector's DVD. It's some of the best buildings, lots, maps and mods collected for you over the years. Check out the STEX Collections for more info.

    Each donation helps keep Simtropolis online, open and free!

    Thank you for reading and enjoy the site!

    More About STEX Collections