1. #1

    Post 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.
    Last edited by custom_junk_mail; 09-14-04 at 12:11 PM.

  2. #2
    Senior Member User Gallery
    Join Date
    Mar 2004
    Location
    Indiana, USA
    Posts
    190

    Default

    Sweet! Thanks for sharing this script!!

  3. #3

    Default

    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.

  4. #4

    Default

    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

  5. #5
    Senior Member User Gallery
    Join Date
    Jan 2003
    Location
    NYC
    Posts
    1,625

    Default

    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

  6. #6

    Default

    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:

    Code:
    [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.

    Code:
    [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.

  7. #7
    Moderator User Gallery
    Join Date
    Jun 2004
    Location
    UK
    Posts
    7,730

    Default

    This is a great script! Many thanks!

  8. #8
    Senior Member User Gallery
    Join Date
    Aug 2004
    Location
    San Diego CA
    Age
    36
    Posts
    445

    Default

    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!

  9. #9
    Senior Member User Gallery
    Join Date
    Jul 2002
    Location
    Paris
    Posts
    1,644

    Default

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

  10. #10
    Senior Member
    User Gallery
    Join Date
    Jan 2002
    Location
    In a galaxy far far away
    Posts
    2,943

    Cool Congrats & Thank You!

    Very intriguing. I am anxious to give it a try. Thank you for your commitment and hard work!
    You can follow me on my Facebook Page and visit my website at www.sargentgfx.com

  11. #11
    Senior Member User Gallery
    Join Date
    Apr 2001
    Location
    ITALY
    Posts
    1,270

    Default

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

    cameyo

  12. #12
    Senior Member User Gallery
    Join Date
    Aug 2004
    Location
    San Diego CA
    Age
    36
    Posts
    445

    Default

    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!

  13. #13

    Default

    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.
    Last edited by custom_junk_mail; 09-14-04 at 11:59 AM.

  14. #14
    Senior Member User Gallery
    Join Date
    Apr 2003
    Location
    Perth, Australia
    Posts
    622

    Default

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

  15. #15
    Senior Member User Gallery
    Join Date
    Dec 2003
    Location
    Chicago
    Posts
    5,537

    Default

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

    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!!

Page 1 of 4 1234 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •