Search Unity

Photoshop tool for easily exporting texure maps from PSD

Discussion in 'General Graphics' started by GetUpKidAK, Aug 23, 2015.

  1. GetUpKidAK

    GetUpKidAK

    Joined:
    Apr 9, 2013
    Posts:
    84
    Hi all,

    So, I like to keep all my texture maps for a model in one file, and after creating and tweaking a lot of texture maps recently I found myself getting a bit annoyed at doing the same task over and over again, especially when the texture needed an alpha channel. Being a lover of useful tools, I decided to make a "quick" Photoshop script to do all the hard work for me.

    Days later, I finally finished, and thought I'd share so no one else has to suffer my pain: https://gist.github.com/GetUpKidAK/f3b4c36d7761264255d2

    Basically, it scans the top-level Layer Groups of a document and adds them to lists for the default Unity maps (Albedo, Metallic, etc.). You can then choose a folder to export to and a few options related to the exported file and it will save the files out, ready for use in Unity (or whatever engine you want to use, really). It's relatively easy to customise the requirements for each map if you want to change them, too.

    Here's a screenshot of the UI at the moment:



    And an example of my PSD Layer hierarchy, so that the exporter can find the right maps by default:



    To install, just put the script in the Presets/Scipts folder under your Photoshop install directory and it will appear in your File/Scripts menu in Photoshop (after an application restart). You can also use Photoshop Actions to set a keyboard shortcut up, too.

    I had to rewire my brain to write in Javascript so it's far from perfect, and my knowledge of JS has always been a basic grasp of the syntax at best, but it's working nicely so far. Obviously happy for any suggestions and feedback, just don't tell me if there's a tool that already does *exactly* this, because I didn't bother looking and now I'm too scared to!

    Thanks!
     
    Last edited: Aug 23, 2015
    theANMATOR2b and EliasMasche like this.
  2. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,782
    I'm sorry for having to ask this question - I'm a github novice (artist).
    Do I need to copy the code on the page and put it in a txt file? Or is there a file to download?

    Thanks in advance. This looks like a very cool tool to overcome a very human error prone process.
     
  3. GetUpKidAK

    GetUpKidAK

    Joined:
    Apr 9, 2013
    Posts:
    84
    You can download the file in a zip file with the button on the right, or you can copy the code into a text editor as long as the file is saved with a .jsx extension.

    Hope it's useful!
     
    theANMATOR2b likes this.
  4. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,782
    Doh!
    Thanks - I intentionally overlook that area due to force fed advertising on all other frequented websites.
     
  5. Martin_H

    Martin_H

    Joined:
    Jul 11, 2015
    Posts:
    3,954
    Let's just say in general before you invest a few days coding a custom solution for such a task you absolutely should spend at least half an hour searching if something like that already exists.
     
  6. GetUpKidAK

    GetUpKidAK

    Joined:
    Apr 9, 2013
    Posts:
    84
    A brief search doesn't find anything that does quite the same thing, but I'm glad of the practice anyway.

    I'd much rather have written a tool that fits my workflow, too.
     
  7. PixelMind

    PixelMind

    Joined:
    Aug 16, 2013
    Posts:
    100
    Looks really useful! These kinds of little helper tools can shave off surprising number of workhours in a long run.
    Thanks for sharing.
     
    Last edited: Aug 31, 2015
  8. GetUpKidAK

    GetUpKidAK

    Joined:
    Apr 9, 2013
    Posts:
    84
    Hi all, just wanted to update anyone that found this useful that it's had some updates recently.

    In summary:

    - The export path is saved between sessions
    - Quickly disable exporting for any maps you don't want
    - It's a little quicker

    Bit more detail:

    I'm now saving a small file to the Documents folder (defaults to /TextureExporter/settings.cfg) which includes the path you last exported to, so if you're tweaking any textures then you don't need to worry about selecting the path every time.

    There are also checkboxes if you're working on one particular map and don't want to keep exporting the ones you're happy with. These could be disabled before but it involved either changing the dropdowns (if you use the default layer names) or temporarily renaming your layer groups. It's now just a few tickboxes and you're done.

    I've removed the logic that remembers which layers were active before you exported for now, I'll probably add it back when I've improved it a little.

    I've also commented and cleaned up the code if that sort of thing is of any interest to you.
     
    Last edited: Sep 28, 2015
    theANMATOR2b likes this.
  9. Thall33

    Thall33

    Joined:
    Sep 18, 2013
    Posts:
    57
unityunity