ZBrushCentral

New Script: Material Baker v1 (Lighting, Shading, Wireframe baker)

Hi, I had need for a script that would let me bake in the shading and material of my model into a texture, so I created this script. It bakes in the shading of your model in a way similar to projection master with drop/pick shading, but it doesn’t burn overlapping areas. It also rotates the lights with the model so that the lighting remains consistent across the baked texture.

Special thanks to Sven and Pixolator for helping me get started with ZScript.

The script and a tutorial on how to use it can be found at my website at http://www.davidikeda.com/materialbaker.html.

Sweet! Thanks for sharing this script!!

NP. If you create any textures with it, I’d love to see them! By the way, load material_baker.txt from the ZScript panel to start the script. The other files are included from that script and shouldn’t be loaded up directly.

I added a little tip to the site. You can also use the script to bake in your model’s wireframe. Here’s the result after a minute of baking:

wireframe_bake.jpg

Hi CJM,

Wow, that was quick. Results look great!

I’m curious about your strategy for light positioning. Must have a look at that. I’ll give you any feedback on that I can.

Well done.

Again, welcome to the hunt and thanks for sharing!

Sven

Hey Sven, the source is included with the zip if you want to check it out. The light positioning is done using simple transformation functions in ikeda_math.txt.

The only ones I use are RotateX and RotateY:


[RoutineDef, "RotateY",
	[VarDef, tX][VarSet, tX, ( (sin(#angle) * #z) + (cos(#angle) * #x) )]
	[VarDef, tZ][VarSet, tZ, ( (cos(#angle) * #z) - (sin(#angle) * #x) )]
	[VarSet, x, tX]
	[VarSet, z, tZ]
, x, y, z, angle]

This rotates a vector/point about the Y axis. The light positions are recorded into an array when the user hits Start and absolute rotations are performed based on the yaw setting. Front, Back, Left, and Right just affect yaw.

For top and bottom views, I just hardcoded the light positions to RotateX with 90 degrees and -90 degrees.


[RoutineDef, "RotateX",
	[VarDef, tY][VarSet, tY, ( (cos(#angle) * #y) - (sin(#angle) * #z) )]
	[VarDef, tZ][VarSet, tZ, ( (sin(#angle) * #y) + (cos(#angle) * #z) )]
	[VarSet, y, tY]
	[VarSet, z, tZ]
, x, y, z, angle]

I have yet to find a solution where the user can orient the model any way he/she likes and have the lights synchronize when baking. It has to do with the complex rotational angles that ZBrush provides. I can’t figure them out.

This is a great script! Many thanks!:+1:

Wow! Awesome script! I’ve been wanting something like this for a long time! You’ve just made me a super happy man! Thank you so much for sharing this… Awesome.

I’m going to use it right now!

CJM … very nice and usefull script. Thx a lot.

Very intriguing. I am anxious to give it a try. Thank you for your commitment and hard work! :+1: :+1: :+1: :+1: :+1:

Wow!!!
Great idea and good script.
Thanks for share.

cameyo

I tested this this morning, and I must say it’s a neat concept. I’m not sure if it would replace painting textures exclusively, but I do think it is a great way to start your textures.

Again, thanks for sharing this!

Thanks all, I’m glad you guys fnd it worthwhile. The script still produces some ‘soft seams’ (dark light areas on the baking silhouette) in the areas that overlap (this is why you should bake in order from least important angles to most important), but it’s the best solution I’ve come up with so far. Before this, I spent hours and hours painting in missing areas and combining image maps (I made two or more because projection master was overbaking and composited them in 2D in photoshop). I also tried painting out areas and masking so that projection master would pick up only the areas I liked, but that was equally tedious to pick out areas that were unbaked perfectly (otherwise they the baked areas would get overbaked).

I wish that ZBrush would come up with a surface baker feature that bakes in the entire surface in one click without being limited to viewport resolutions and so forth.

Another feature that could really make this script work much better for the time being is if there’s a curve we could edit for 3DCopy’s A.I. feature or a simple threshold slider so that you can control how much to occlude polygons that are facing away from you. If 3DCopy could be configured to just copy polygons that are facing almost directly at you, you should be able to do multiple overlapping bakes without any problems at all. I think people would find this useful for all sorts of other reasons too, including texture master. Right now I think it picks up too many side-facing polygons, and that’s the main reason this script currently produces those soft, dark/light regions on the edges of the baking.

Now this looks great! Thanks for your hard work, custom_junk_mail.

Wow this looks pretty damn cool…with some great possibilities…the idea machine is rolling already!!:smiley:

Thanks for sharing this…I’ve been looking for or to do something very similar but couldn’t quite figure out how to get rid of those overlap shadows!

Can’t wait to test it out shortly!

Thanks again!!

Very nice results. Thanks for sharing. Glad to see you aboard the zscript ship:)

David, the download link needs updated on your main page.

It’s missing a folder.

It’s http://www.davidikeda.com/zscripts/materialbakerv1.zip

Great idea for a script but I used your script exactly as it said and got a bunch of textures but no one texture where all views are baked into one. I used GUVtiles for the UV mapping and the images just seem to be snapshots of each view. Is there a step I am missing? What do I need to do after the baking to get 1 image to use in an external renderer?
Thanks ruby

It sometimes does that. Just redo it.

Does it everytime… I have tried and tried…sniff…