[TUTORIAL] Texture batch conversion and modification (Albedo-ready)

Discussion in 'Modding' started by FuNK!, Jul 15, 2018.

  1. philrob

    philrob Registered

    Joined:
    Jan 12, 2012
    Messages:
    572
    Likes Received:
    1,204
    Lazza,
    i usually use a couple of scripts in Photoshop but just used your file and it worked great, good job on the exe.
     
    Mauro likes this.
  2. Lazza

    Lazza Registered

    Joined:
    Oct 5, 2010
    Messages:
    12,345
    Likes Received:
    6,572
    @philrob Yeah, I tended to use PS for this (not CS2; @FuNK! I'd only seen the 'headlines' back when that CS2 happened, I've only now read up and seen what the reality was, shame it got reported wrong on tech sites) but still got annoyed at having to separate the different formats. I sort of shortcutted it by using a file search tool and searching for the dxt strings in the files (which should almost always work out correct anyway), but since I was still pulling them into PS and batching them that way it didn't seem worthwhile trying to do it better. But with command line tools it suddenly made more sense to make it happen :D

    It's a shame we can't automate separating out normal and spec images. Filenames can be a clue but I've seen some tracks where mult and spec are named the wrong way round lol
     
    Mauro likes this.
  3. philrob

    philrob Registered

    Joined:
    Jan 12, 2012
    Messages:
    572
    Likes Received:
    1,204
    @Lazza
    thanks for your reply, i agree regarding bumps, specs, mult etc.

    The new tools make it so much quicker to get a running updated track.You can then isolate any troublesome texture and adjust it manually.Working on a track update at the moment and it has really sped up the job.
     
    Last edited: Aug 1, 2018
    Mauro and FuNK! like this.
  4. FuNK!

    FuNK! Registered

    Joined:
    May 26, 2013
    Messages:
    626
    Likes Received:
    491
    That was the plan! Glad to hear this worked out ;) But of course let us know any observations!
     
    Mauro likes this.
  5. lagg

    lagg Registered

    Joined:
    Oct 1, 2012
    Messages:
    3,043
    Likes Received:
    1,958
    Thank you very much @Lazza . I was going to do the same.
    I didn't know AutoIt, but seems easy.
    I have to run the command as "magick mogrify", too.
    I suppose that this is an environment variables issue.
     
  6. lagg

    lagg Registered

    Joined:
    Oct 1, 2012
    Messages:
    3,043
    Likes Received:
    1,958
    A couple of questions @FuNK!
    You use these parameters for dxt1and dxt5 formats
    • -format png
    • -define png:compression-level=0
    • -define png:compression-filter=5
    • -define png:compression-strategy=2
    • -depth 8
    • -channel RGB +level 7.8%,78.4%
    Is it correct to use the same parameters for both formats?

    I've found some dds in dxt3 format ¿Do we have to use the same parameters for these files too?

    Thanks
     
  7. FuNK!

    FuNK! Registered

    Joined:
    May 26, 2013
    Messages:
    626
    Likes Received:
    491
    Some comments on the parameters:

    format png
    the PNG format is used because it allows graphics with or without compression and all channels RGB + alpha, so this is just perfect for dealing with the different textures...I don't know all the details, but DXT1 and DXT5 have some main difference: One important is the alpha as DXT1 has none but DXT5 does and DXT3 has an alpha too but AFAIK has another compression...again, PNG is the perfect format to keep the alpha if there is any
    png:compression-level=0
    null compression, to not reduce the quality of the already compressed original texture again before conversion
    png:compression-filter=5 + png:compression-strategy=2
    these two were suggested in context of loss-less or loss-free conversion to PNG, I cannot really rephrase what they do, but reading they are the best for this purpose was enough for me :D
    depth 8
    ImageMagick works with 16 bit by default but the DDS textures use 8 bit, so this mainly avoids any trouble with the conversion/manipulation
    channel RGB
    the command "channel RGB" limits the following manipulation to the RGB channels - RGBA would manipulate the alpha channel too, but we don't want this here
    +level 7.8%,78.4%
    these are the translated RGB values in percentage for black-point 20 and white-point 200, "+" instead of "-" will cause the operator to do the reverse of the level adjustment (this is required to achieve the wanted effect)
     
    philrob, lagg and Mauro like this.
  8. philrob

    philrob Registered

    Joined:
    Jan 12, 2012
    Messages:
    572
    Likes Received:
    1,204
    Funk!
    thanks for the great explanation, this is turning into a great thread for very many people, i think.
     
    FuNK! likes this.
  9. FuNK!

    FuNK! Registered

    Joined:
    May 26, 2013
    Messages:
    626
    Likes Received:
    491
    Just a small update to the first post: I've added separated commands for DXT1 and DXT5 conversion because the combined command will fail in case there is only one source format (i.e. one folder is empty).
     
    Last edited: Aug 12, 2018
    philrob and Mauro like this.
  10. svictor

    svictor Registered

    Joined:
    Jan 20, 2019
    Messages:
    923
    Likes Received:
    6,275
    Thanks for the tutorial, have been using for a few month now, saved so much time.

    Here is some additional useful commands for imagemagick, modify value is in bold, also add link to detailed description from official site.
    ----------------------------------------
    Change texture opacity (sometimes a lot old mod texture isn't 100% opacity. "multiply 2" means original opacity is doubled, 0.5 would be halved):
    -alpha set -channel Alpha -evaluate multiply 2

    Increase darkness (note difference compare to +level):
    -level 3%,100%,1

    Increase overall darkness without affect saturating highlights or shadows:
    +sigmoidal-contrast 3x0%

    Make certain color transparent (HEX color code):
    -transparent #878787

    Change brightness, saturation, hue:
    -modulate 100,80,100

    Change gamma (less than 1.0 darkens the image, greater than 1.0 lightens it):
    -gamma 1.0

    Add alpha channel (ex. batch converting BMP to PNG won't automatically add alpha channel):
    -alpha on

    Change output DDS compression to lossless (if you don't want to have some purple/red artifacts from other lossy compression like DXT1 DXT5, note file size will be LARGE):
    texconv -nologo -timing -y -f R8G8B8A8_UNORM

    Add color tint (might useful to fix some color issues):
    -fill rgb(0,10,80) -tint 15

    Resize or scale image (note they are not exact same, detailed tutorial):
    -resize 50%
    -scale 400%
    Note you can add filter type before -resize
    :
    -filter Lanczos2 -resize 50%
    ----------------------------------------
    And last, opensource tool to upscale low resolution texture with AI Neural Networks upscaling:
    1. ESRGAN Installation Guide for Windows
    2. Using ESRGAN, Links, And Other Information (recommand to use IEU.Winforms which has GUI)
    3. Get pretrained Model for your image, different model suits different type of photo or image

    Good luck!
     
    Last edited: Mar 27, 2020
    philrob, Gilles Benoit, FuNK! and 2 others like this.
  11. Silvano Silva

    Silvano Silva Registered

    Joined:
    Jul 11, 2020
    Messages:
    9
    Likes Received:
    1
    Great Tutorial I'm doing the conversions through Photoshop, it has been very useful to me. A doubt, after I converted and installed the new textures, the shine of the rubber on the asphalt that reflects with the sun, are gone. What can I do inside the .Json file to return the asphalt shine? Or any specific texture for that?
     
  12. svictor

    svictor Registered

    Joined:
    Jan 20, 2019
    Messages:
    923
    Likes Received:
    6,275
    You may want to exclude real road textures from batch conversion. Check you racesurface GMT material (real road), and find the texture names (maybe exclude main texture), then restore those textures to original ones. Usually those textures called Asphalt_MULT, Asphalt_NORM, Asphalt_SPEC, racegroove, marble. If you are using new PBR/json, it probably uses different texture names, you can find names in json file.
     
  13. Leonardo1962

    Leonardo1962 Registered

    Joined:
    Feb 12, 2012
    Messages:
    246
    Likes Received:
    69
    for my texture conversions i use the dds tools from nvidia https://developer.nvidia.com/legacy-texture-tools
    .. there is also a "command-line binary version", the nvDXT.exe, that i use vor (Batch) generating f.e
    icons : nvdxt -dxt3 -file *.PNG -outdir ..\ -nomipmap -quality_highest
    solid dds: nvdxt -dxt3 -file *.BMP -outdir ..\ -quality_highest
    transparent dds: nvdxt -dxt5 -file *.tga -outdir ..\ -quality_highest
    As source (BMP, PNG, TGA, TIF) i use any kind of bitmaps (including selfmade albedos) comming from any grafic tool.

    May be, that could be helpful :)
     
    Last edited: Aug 7, 2020
    FuNK! likes this.

Share This Page