Newer version of Batch-Baking dirtmaps and UV packer

----------UPDATE----------
So I’ve done some of my own changes and updates to the original script.
Download it here, just install it as an addon like usual (might need to remove the old one first if you used it)
http://i.imgur.com/yoC5A.png
The changes in detail:
Options to delete the generated images (the script bakes 3 AO maps and then merges them into a 4th image. This 4th image is the dirtmap, the other 3 are kept, but generally aren’t used for anything)
Ability to pack the UVs of all selected objects into one UV space, with the option to scale it to fit into the whole image, or to leave the scale as is.

I’m sure there’s lots that could be done to improve this addon, I used the old version at least a couple times every day and I’m happy with the stuff I’ve added, but there’s always more to do :slight_smile: so let me know any ideas you’d like me to implement.

----------ORIGINAL POST----------
Hey guys, does anyone know if there’s an updated version of the batch baker script used on Mango for making dirt maps and such?
I’ve got version 0.1 I guess, available here.

I’m wanting some more customization functionality, such as only unwrapping and not baking anything, or baking only one or two of the 3 AO bakes, and deleting all the junk afterwards (the material and the 3 bakes, leaving only the final single mixed dirt map)

My coding skills are limited - I may be able to figure some stuff out and edit it myself to get what I want, but obviously I’d prefer it if there were already a newer version around :slight_smile:

I agree, this tool is super interesting, I hope we can see a much better version as gregzaal said.

Well I’m gonna give a crack at it. I noticed a UV mapping script in that same download from the mango blog that does the UV mapping only, and packs it a little better as well - so that’ll be a great help

Version two is available here:

Or rather, the direct download link is https://github.com/nizu/BatchBake/archive/master.zip

This version works perfectly both with 2.64 official and latest nightly builds.

I’ve been using it to generate dirtmaps for cycles renders the last couple of days, and it works perfectly.

OJ

That seems to be the same version I have

Seems to be some fairly simple code I’m adding, so while I’m at it - does anyone have any feature requests for this?

I think what you suggested initially makes sense - i.e. cleaning it up, getting rid of the stuff you don’t want etc. Perhaps also adding functionality in the script that enables AO in Blender Internal if it isn’t switched on already. I did make a couple of failed, all black bakes due to forgetting that initially.

Updating this script is very much worthwhile - once I started using it, I had a hard time figuring out how the heck I’ve been able to texture anything reasonably realistically in cycles before discovering the AO bake. That being said though - the author does ask for development assistance, and perhaps a “fork” this early might confuse people. Why don’t you offer your assistance to the original author. I might be both more fun and a learning experience :slight_smile:

OJ

Well I’m no expert developer :wink: anything I do today could probably be done in 5 minutes by the original authors. This script was made just for the mango guys, so they probably don’t care to improve it anymore.
But that’s why it being open source is so awesome!

So far all I’ve done is added 3 check-boxes to delete the three generated images. After some initial testing, deleting the generated material and textures has proven a little more challenging, but also not entirely needed. If the object already has a material, the generated one is not assigned to anything, and is thus deleted upon reloading the file.

Oh and a tiny bit that changes the button’s label based on whether the “Auto Unwrap” box is checked.

http://i.imgur.com/mE9N5.png

Next on the todo list is the grab the UV packing script also from mango and add a button for that.
It packs the UV maps of all the selected objects into one UV space, so much like if you could run the batch bake without actually baking, only merging and packing the UVs, only with a better packing algorithm. :slight_smile:

I’ll also add the option to save the final dirt map in the blend’s textures folder and reload the file (to make sure all unused images, textures and materials are killed) [reloading the file without saving the dirt map first will mean losing the image data

Oh and then of course the ability to only bake the AO images without merging them into the final image, which is nice sometimes if you want to paint something before merging. Some planning on the best workflow for this will be needed.

Thank you for your hard work Greg, this will most likely end up in trunk when you are done with it :slight_smile:

Just be careful Greg, that you don’t make it so complicated in the end that people are putt off trying it out. If you want to go all in, I personally prefer having an “Advanced” option that hides/expands the more confusing stuff that you wouldn’t really use in most situations (well, I wouldn’t anyway :slight_smile: ).

That’s the plan :slight_smile:

Oh, and I suddenly thought of something, though this might be “a bridge too far”, but you could have the script also take the material input (i.e. a pull-down where you pick the relevant material you want add the dirt layer to) and add a “AO Dirt” nodegroup to that material.

It would simply be a Image Texture n![/home/Users/olesk/Desktop/Screen Shot 2012-11-21 at 17.01.58](/home/Users/olesk/Desktop/Screen Shot 2012-11-21 at 17.01.58)ode pointing to the final texture (on disk), together with a Color Mix node. You could even ask for the preferred mix (0-1) together with the name of the material. The effect would of course be that you end up seeing the result of the bake immediately in Cycles when you switch back from Internal.

Again, this might be one step too far, but personally I think it would be cool. It would also save some time, as I spent a lot of time going through a lot existing materials, adding that Image Texture/Color Mix nodes, and hooking them up to the right texture file (which currently needs to be saved and named manually). Whaddayathink? :slight_smile:

OJ

PS: I realize that actually connection the node group automatically would be difficult, as most materials have mode than one shader - typically at least a diffuse and a glossy shader, so just leaving the node group unconnected in the material node setup might work better than trying to guess where is should go (normally right after the image texture node if there is only one in the material, but if there are also texture paint, additional textures etc., it becomes pretty impossible to guess the right location)…

PPS: Perhaps the material choice could have one more benefit as well, though this might be getting rather technical: if the unwrap is linked to a single material, it would be possible to put dirtmaps on only parts of a large object, rather than having to unwrap everything and eating up UV space for parts that won’t use it. Just a thought…

An interesting idea, but far beyond me I think :stuck_out_tongue:
I don’t think it’d be used much anyway, dirtmaps are used in much more complicated ways than any automatic system could create - it’s not just darkening the colour or something, it’s normally (in my workflow at least) used as a mask between another bunch of nodes that form the material for the dirt. I also then manipulate the dirt map so it’s not so obviously AO, like having a grunge texture affect the brightness or contrast (or both) of the dirtmap, which often requires very sensitive and specific values to get it to look right.

Well, like I said, perhaps a bridge too far :slight_smile:

My thought was that it would appeal to people with less demanding requirements (I’m doing a rather long animation where the camera is constantly moving, so for me, simply adding an AO layer is nice tradeoff between time and quality), but I think you’re right - it would be of limited benefit with a lot of added work and complexity. And for many users it would even be more confusing I suppose.

You could just render an AO pass :wink:

I know that smartypants :stuck_out_tongue:

It is nevertheless a much nicer result from this script, but like I said: I think your take on this is the right one. Oh, and let me know if you need some beta-testing, I’d be happy to help.

Added in the functionality of Sergey’s (I assume he coded it, no credit is given) UV packing script that packs the UVs of multiple objects into one image space. Sadly it doesn’t take into account the global scale of the faces (like the Average Island Scale operator), but I’m working on that… or trying to at least.

You can now download what I’ve got so far since I’m not sure how much further I can go with this just yet. Check the first post

i think this just helps making textures… you have nicly show… the elements on UV layout because sometimes when you export uv you have to check what is what etc…

any chance of adding in baking the dirtmap to vertexColors? There is a script for Blender that backes a UV’s texture into Vcols already, which could provide a code reference.

Thats not a bad idea sir - not a bad idea at all :slight_smile:
It also gives me the idea to bake the “Dirty Vertex Colors” too.