Hi all,
I posted this over at the Unity forums earlier, but realised that I've been registered here for an age without posting, and it'd be an ideal place for it.
So, I like to keep all my texture maps for a model in one file, and after creating and tweaking a lot of them 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!
Replies
Added to the wiki here (don't look!)
http://wiki.polycount.com/wiki/PhotoshopTools#Export_Tools
[ame]http://www.youtube.com/watch?v=5SQvTZ-pFZo[/ame]
@mods:
There already is a thread on this tool (http://www.polycount.com/forum/showthread.php?t=156667), so I suggest you merge this thread with that one.
http://www.polycount.com/forum/showthread.php?t=157483
Good to see that leaving some options exposed was worth it, too.
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.
Apologies for the double post!
If that's the case then you can get them to enable by default by using names for your Photoshop groups that are preset in the options ('albedo', 'normal', 'metallic', etc.). This should auto-fill the drop-downs and can be updated if you'd rather use different names. You can obviously adjust the name slightly with an underscore or something if you'd rather leave the map temporarily.
The export path can be saved on a project basis in the same file, too, and is saved by default in the latest version.
Hope that helps!