mastering - download.e-bookshelf.de€¦ · acknowledgments as always, my thanks go first and...

30

Upload: others

Post on 01-Aug-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Mastering - download.e-bookshelf.de€¦ · Acknowledgments As always, my thanks go first and foremost to Ton Roosendaal and all the Blender developers for all their hard work and
Page 2: Mastering - download.e-bookshelf.de€¦ · Acknowledgments As always, my thanks go first and foremost to Ton Roosendaal and all the Blender developers for all their hard work and
Page 3: Mastering - download.e-bookshelf.de€¦ · Acknowledgments As always, my thanks go first and foremost to Ton Roosendaal and all the Blender developers for all their hard work and

Mastering Blender Second Edition

Page 4: Mastering - download.e-bookshelf.de€¦ · Acknowledgments As always, my thanks go first and foremost to Ton Roosendaal and all the Blender developers for all their hard work and
Page 5: Mastering - download.e-bookshelf.de€¦ · Acknowledgments As always, my thanks go first and foremost to Ton Roosendaal and all the Blender developers for all their hard work and

Mastering Blender Second Edition

Tony Mullen

Page 6: Mastering - download.e-bookshelf.de€¦ · Acknowledgments As always, my thanks go first and foremost to Ton Roosendaal and all the Blender developers for all their hard work and

Acquisitions Editor: Mariann BarsoloDevelopment Editor: Laurene SorensenTechnical Editor: Oscar BaechlerProduction Editor: Dassi ZeidelCopy Editor: Linda RecktenwaldEditorial Manager: Pete GaughanProduction Manager: Tim TateVice President and Executive Group Publisher: Richard SwadleyVice President and Publisher: Neil EddeBook Designers: Maureen Forys, Happenstance Type-O-Rama; Judy FungCompositor: Jeff Lytle, Happenstance Type-O-RamaProofreader: Amy J. SchneiderIndexer: Ted LauxProject Coordinator, Cover: Katherine CrockerCover Designer: Ryan SneedCover Image: Jonathan Ball, Poked Studio (www.pokedstudio.com)

Copyright © 2013 by John Wiley & Sons, Inc., Indianapolis, Indiana Published simultaneously in Canada

ISBN: 978-1-118-27540-5 ISBN 978-1-118-33339-6 (ebk.) ISBN: 978-1-118-33056-2 (ebk.) ISBN: 978-1-118-33128-6 (ebk.)

No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appro-priate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008, or online at http://www.wiley.com/go/permissions.

Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with respect to the accuracy or completeness of the contents of this work and specifically disclaim all warranties, including without limitation war-ranties of fitness for a particular purpose. No warranty may be created or extended by sales or promotional materials. The advice and strategies contained herein may not be suitable for every situation. This work is sold with the understanding that the publisher is not engaged in rendering legal, accounting, or other professional services. If professional assistance is required, the services of a competent professional person should be sought. Neither the publisher nor the author shall be liable for damages arising herefrom. The fact that an organization or Web site is referred to in this work as a citation and/or a potential source of further information does not mean that the author or the publisher endorses the information the organization or Web site may provide or recommen-dations it may make. Further, readers should be aware that Internet Web sites listed in this work may have changed or disappeared between when this work was written and when it is read.

For general information on our other products and services or to obtain technical support, please contact our Customer Care Department within the U.S. at (877) 762-2974, outside the U.S. at (317) 572-3993 or fax (317) 572-4002.

Wiley publishes in a variety of print and electronic formats and by print-on-demand. Some material included with standard print versions of this book may not be included in e-books or in print-on-demand. If this book refers to media such as a CD or DVD that is not included in the version you purchased, you may download this material at http://booksupport.wiley.com. For more information about Wiley products, visit www.wiley.com.

Library of Congress Control Number: 2012949504

TRADEMARKS: Wiley, the Wiley logo, and the Sybex logo are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, in the United States and other countries, and may not be used without written permission. All other trade-marks are the property of their respective owners. John Wiley & Sons, Inc. is not associated with any product or vendor mentioned in this book.

10 9 8 7 6 5 4 3 2 1

Page 7: Mastering - download.e-bookshelf.de€¦ · Acknowledgments As always, my thanks go first and foremost to Ton Roosendaal and all the Blender developers for all their hard work and

Dear Reader,

Thank you for choosing Mastering Blender, Second Edition. This book is part of a family of premium-quality Sybex books, all of which are written by outstanding authors who combine practical experience with a gift for teaching.

Sybex was founded in 1976. More than 30 years later, we’re still committed to producing consis-tently exceptional books. With each of our titles, we’re working hard to set a new standard for the industry. From the paper we print on, to the authors we work with, our goal is to bring you the best books available.

I hope you see all that reflected in these pages. I’d be very interested to hear your comments and get your feedback on how we’re doing. Feel free to let me know what you think about this or any other Sybex book by sending me an email at [email protected]. If you think you’ve found a technical error in this book, please visit http://sybex.custhelp.com. Customer feedback is critical to our efforts at Sybex.

Best regards,

Neil Edde Vice President and Publisher Sybex, an Imprint of Wiley

Page 8: Mastering - download.e-bookshelf.de€¦ · Acknowledgments As always, my thanks go first and foremost to Ton Roosendaal and all the Blender developers for all their hard work and

To my family

Page 9: Mastering - download.e-bookshelf.de€¦ · Acknowledgments As always, my thanks go first and foremost to Ton Roosendaal and all the Blender developers for all their hard work and

AcknowledgmentsAs always, my thanks go first and foremost to Ton Roosendaal and all the Blender developers for all their hard work and dedication. You guys are doing important work and deserve the heartfelt gratitude of the entire community of Blender users.

Many other developers and users have helped me in researching and writing this book, and I’m very grateful for all the support I’ve received from the Blender community. I can’t list all of the individuals at BlenderArtists.org whose artwork, comments, and tutorials have helped me to learn what I know about Blender, but I am particularly grateful for those who helped me as I ventured outside my comfort zone to write about the Blender Game Engine. Special thanks to BlenderArtists.org forum members Social, Mmph!, Blendenzo, and the other BGE gurus who were always eager to help me with my questions and investigations of this sometimes arcane function-ality. I’m also very grateful to Dolf Veenvliet (macouno) and Campbell Barton (ideasman_42), who helped me enormously to deepen my knowledge of Blender’s Python API.

Throughout this book, I have referred to websites, tutorials, support threads, and other resources created by members of the community, and I am very grateful to all of those who have shared their knowledge. Once again, many thanks to Bart Veldhuizen and the contribu-tors to BlenderNation.com and to Roel Spruit and all the moderators and administrators at BlenderArtists.org for their support and for the great service they provide the Blender community.

This book would not have been possible without the efforts of my editors and colleagues at Sybex/Wiley, and I’m very grateful to all of them. Thank you to Mariann Barsolo, Pete Gaughan, Dassi Zeidel, Linda Recktenwald, and everyone else who had a hand in publishing and promot-ing the book. Thanks are also due to Oscar Baechler for his work as technical editor.

As always, I am grateful to my wife, Yuka, and my two daughters for their love and support.

Page 10: Mastering - download.e-bookshelf.de€¦ · Acknowledgments As always, my thanks go first and foremost to Ton Roosendaal and all the Blender developers for all their hard work and
Page 11: Mastering - download.e-bookshelf.de€¦ · Acknowledgments As always, my thanks go first and foremost to Ton Roosendaal and all the Blender developers for all their hard work and

About the AuthorTony Mullen is a college lecturer, animator, independent filmmaker, and writer living in Tokyo. He has worked as a newspaper cartoonist, a graphic designer, a software developer, and a researcher in natural language processing, among other things.

Since discovering Blender, he has been involved in CG animation to the point of obsession, but he also maintains a keen interest in stop-motion techniques, notably as the lead animator and codirector of the award-winning 16mm film Gustav Braüstache and the Auto-Debilitator and other independent shorts. He is currently working on a short film using Blender, which he blogs about at http://electrictownmovie.wordpress.com.

He is an active member of the Blender community and one of the original members of the Blender Foundation’s Trainer Certification Review Board. He is the author of Introducing Character Animation with Blender (Sybex, 2007) and Bounce, Tumble, and Splash!: Simulating the Physical World with Blender 3D (Sybex, 2008), as well as numerous magazine articles and tutorials on Blender. You can follow him on twitter at @tonymullen.

Page 12: Mastering - download.e-bookshelf.de€¦ · Acknowledgments As always, my thanks go first and foremost to Ton Roosendaal and all the Blender developers for all their hard work and
Page 13: Mastering - download.e-bookshelf.de€¦ · Acknowledgments As always, my thanks go first and foremost to Ton Roosendaal and all the Blender developers for all their hard work and

Contents at a Glance

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xxi

Part I • Fundamentals of Blender 3D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

Chapter 1  •  Working in Blender. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

Chapter 2  •  Working with Textures and Materials. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

Chapter 3  •  Sculpting and Retopo Workflow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87

Chapter 4  •  Rendering and Render Engines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133

Part II • Physics and Simulations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .161

Chapter 5  •  Getting Flexible with Soft Bodies and Cloth . . . . . . . . . . . . . . . . . . . . . . 163

Chapter 6  •  Working with Particles. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201

Chapter 7  •  Volumetric Fluid, Smoke, and Fire. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253

Chapter 8  •  Bullet Physics and the Blender Game Engine . . . . . . . . . . . . . . . . . . . . . 315

Part III • Video Post-production in Blender . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367

Chapter 9  •  Compositing with Nodes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369

Chapter 10  •  Advanced 3D/Video Compositing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 419

Chapter 11  •  Working with the Video Sequence Editor . . . . . . . . . . . . . . . . . . . . . . . . 453

Part IV • Blender-Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 481

Chapter 12  •  The Blender-Python Interpreter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 483

Chapter 13  •  Python Scripting for Blender. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 503

Page 14: Mastering - download.e-bookshelf.de€¦ · Acknowledgments As always, my thanks go first and foremost to Ton Roosendaal and all the Blender developers for all their hard work and

xII | Contents at a GlanCe

Part V • Mastering the Blender Game Engine . . . . . . . . . . . . . . . . . . . . . . . . . . . 531

Chapter 14  •  Creating Assets for the Blender Game Engine . . . . . . . . . . . . . . . . . . . . 533

Chapter 15  •  Making Things Happen in the Game Engine . . . . . . . . . . . . . . . . . . . . 573

Chapter 16  •  Python Power in the Blender Game Engine . . . . . . . . . . . . . . . . . . . . . . 605

Appendix  •  The Bottom Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 631

Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 647

Page 15: Mastering - download.e-bookshelf.de€¦ · Acknowledgments As always, my thanks go first and foremost to Ton Roosendaal and all the Blender developers for all their hard work and

Contents

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xxi

Part I  •  Fundamentals of Blender 3D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

Chapter 1  •  Working in Blender . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3Data and Data Access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

Using the Outliner . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4Exploring the User Preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11Other Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

Improving Your Workflow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22Viewport Hot Keys and Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22Grouping and Selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25Object Manipulation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

The Bottom Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

Chapter 2  •  Working with Textures and Materials . . . . . . . . . . . . . . . . . . . . . . .33Creating UV Textures with Blender and GIMP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

Textures and Texture Mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33UV Mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35Texturing a Locomotive Smokestack. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36Smoothing the Seams with Texture Baking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50

Advanced Materials with Material Nodes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60Adding Soot to the Smokestack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60Hot Lava with Nodes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67

Transparency and Subsurface Scattering. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76Transparent Shadows. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78Subsurface Scattering. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79

Creating Convincing Real-Time Viewport Materials with Material Capture Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81

The Bottom Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84

Chapter 3  •  Sculpting and Retopo Workflow . . . . . . . . . . . . . . . . . . . . . . . . . . .87Sculpting with Blender . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87

Multiresolution Modeling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88Sculpting Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89Sculpting a Baby’s Head . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94The Sculpting Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101

Retopologizing the Mesh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118Normal Map Baking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126The Bottom Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131

Page 16: Mastering - download.e-bookshelf.de€¦ · Acknowledgments As always, my thanks go first and foremost to Ton Roosendaal and all the Blender developers for all their hard work and

xIV | Contents

Chapter 4  •  Rendering and Render Engines . . . . . . . . . . . . . . . . . . . . . . . . . . . 133What Is Rendering? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133

Real-Time and Viewport Rendering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134Rendering with Blender Internal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136

Rendering with Cycles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144Cycles and Sampling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144Nodes Revisited . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145

Rendering with Renderfarm.fi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154Distributed Rendering for the People . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155Contributing Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158

The Bottom Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158

Part II  •  Physics and Simulations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161

Chapter 5  •  Getting Flexible with Soft Bodies and Cloth . . . . . . . . . . . . . . . . . 163The Hard Facts on Soft Bodies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163

Understanding Soft Body Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164Baking. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167Animating a Spring with Soft Bodies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167

Force Fields and Collision. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173Simulating Cloth and Clothing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175Hanging the Drapes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176Clothing for Animation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179

The Bottom Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200

Chapter 6  •  Working with Particles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201Introducing Emitter Particles. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201

Adding a Particle System. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202Emitter Particles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202Baking. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206Physics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206Display and Render Options. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208Using Force Fields and Deflection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212Setting Up an Explode Modifier with Dynamic Particles . . . . . . . . . . . . . . . . . . . . . 220

Working with Boids . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223Setting Up the Boids System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224Working with Goals and Predators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224Creating a Simple Flying Bird. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225

Hair Particles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227A Trip to the Beauty Salon. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228Preparing the Mesh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228Editing Hair Particles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230Releasing Your Inner Hairdresser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236Materials and Textures for Hair . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242Creating Clumping, Roughness, and Kink . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246Lighting and Rendering. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250

The Bottom Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251

Page 17: Mastering - download.e-bookshelf.de€¦ · Acknowledgments As always, my thanks go first and foremost to Ton Roosendaal and all the Blender developers for all their hard work and

Contents | xV

Chapter 7  •  Volumetric Fluid, Smoke, and Fire . . . . . . . . . . . . . . . . . . . . . . . .253Using the Blender Fluid Simulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253

Getting Started with Fluids. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253Inflow and Outflow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264Time, Size, and Resolution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268Particles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271Obstacles and Animation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278Animating Fluid Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287

Getting the Shot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287Bottle of Pop. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288Rushing Creek. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294Going Further with Fluids . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301

Simulating Smoke and Fire. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301Rendering Smoke . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303Simulating Flames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307

The Bottom Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313

Chapter 8  •  Bullet Physics and the Blender Game Engine . . . . . . . . . . . . . . . . 315Physics in the BGE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315

Getting Started with the Blender Game Engine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316Using Actions in BGE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324

Rigid Body Simulation and F-Curves . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 326Baking Game F-Curves . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 326Frame Rate and Simulation Speed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328Recording Physics and Animation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328Actor Parameters, Boundaries, and Hull Types. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334General Tips on Working with Bullet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 344Using Physics Visualization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 344

Joints, Ragdolls, and Robots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345Using Rigid Body Joint Constraints. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348Using Generic 6 DoF Joints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350Setting Up a Ragdoll Armature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350Controlling an Armature. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357A Passive-Walking Robot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 362

Further Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 364The Bottom Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 366

Part III  •  Video Post-production in Blender . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367

Chapter 9  •  Compositing with Nodes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .369Compositing with Render Layers and Passes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369

What Is Compositing? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369What Are Nodes? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 370A Closer Look at Render Layers and Nodes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 370Reconstructing an Image with Render Passes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374Combining Passes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379Node Groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 389

Page 18: Mastering - download.e-bookshelf.de€¦ · Acknowledgments As always, my thanks go first and foremost to Ton Roosendaal and all the Blender developers for all their hard work and

xVI | Contents

Pulling a Green Screen Matte with Nodes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 390Working with Green Screen Video . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 390Working with Composite Nodes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392

Using the AnimAll Add-on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397Animating the Garbage Matte . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 405Using Render Layers and Nodes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 408Using Alpha Overlays and Premultiplication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 410Spill Correction and Cleaning Up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 412Tweaking Color Channels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413Finishing Off the Matte . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415Muting Nodes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 417Learning More about Compositing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 418

The Bottom Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 418

Chapter 10  •  Advanced 3D/Video Compositing . . . . . . . . . . . . . . . . . . . . . . . . 419Camera Tracking and the Movie Clip Editor. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 419

Camera Tracking from Video . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 422Anatomy of a Good Feature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 422Tracking Markers and Track Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423Tracking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425Getting Good Tracks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425Camera Solving . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 431

Setting Up the Scene in 3D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 437Reconstruction Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 437The Node Setup. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 439

Masking in the Clip Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 441Editing the Mask. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 442Compositing with Masks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 446Other Mask Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 446

The Bottom Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 451

Chapter 11  •  Working with the Video Sequence Editor . . . . . . . . . . . . . . . . . .453Introducing the Video Sequence Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 453

Importing Video and Image Sequences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 455Setting Frame Rates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 458Working with Sequence Strips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 460Editing Sound . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 463Using Markers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 465Accessing Other VSE Display Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 465

Adding Transitions and Compositing in the VSE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 466Alpha Overlays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 467Fades and Transitions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 468Fading to Black . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 470Transform. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 470Other Effects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473Meta-Strips. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 474

Page 19: Mastering - download.e-bookshelf.de€¦ · Acknowledgments As always, my thanks go first and foremost to Ton Roosendaal and all the Blender developers for all their hard work and

Contents | xVII

Working with Blender Scenes in the VSE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 474Adding Captions to a Video . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 474Composited Scenes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 478Rendering and Output. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 479

The Bottom Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 480

Part IV  •  Blender-Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 481

Chapter 12  •  The Blender-Python Interpreter . . . . . . . . . . . . . . . . . . . . . . . . . .483Introducing Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 483

What Is Python? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 483Why Python? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 485Further Resources. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 486

Understanding the Python Development Environment . . . . . . . . . . . . . . . . . . . . . . . . . 488Using the Command-Line Shell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 488Accessing the System Console . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 489Using the Text Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 491

Understanding Python Syntax. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 491Data Types and Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 491Control Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 496Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 498Classes and OOP. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 500The dir() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 501Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 501

The Bottom Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 502

Chapter 13  •  Python Scripting for Blender . . . . . . . . . . . . . . . . . . . . . . . . . . . .503Editing and Running Scripts in Blender . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 503

Calling Functions from the Command Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 505Working with Text Editors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 506The Blender Text Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 507Script Format and Templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 508Adding a Simple Mesh Object to the Scene . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 508

Creating an Interactive Add-on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 511The Addon Add Object Template. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 511The bl_info Block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 513

Working with Custom Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 518Composing the Add-on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 518The Complete Add Bouncing Cone Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 527

The Bottom Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 530

Part V  •  Mastering the Blender Game Engine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 531

Chapter 14  •  Creating Assets for the Blender Game Engine . . . . . . . . . . . . . . .533Creating Content for the Game Engine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 533

Modeling a Simple Low-Poly Character . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 534Texture Painting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 541

Page 20: Mastering - download.e-bookshelf.de€¦ · Acknowledgments As always, my thanks go first and foremost to Ton Roosendaal and all the Blender developers for all their hard work and

xVIII | Contents

Rigging and Animating the Character . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 545Creating a Walk Cycle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 549

Setting Up the World . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 553Baking Procedural Textures for a Simple Skybox . . . . . . . . . . . . . . . . . . . . . . . . . . . . 554Creating a Simple Maze. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 561

Getting More Familiar with the BGE Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 567Placing Your Objects in the Game World . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 568Setting Material Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 569Using Lighting in the Game Engine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 571Vertex Painting for Light Effects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 572

The Bottom Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 572

Chapter 15  •  Making Things Happen in the Game Engine . . . . . . . . . . . . . . . .573Working with Logic Bricks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 573

Understanding Logic Brick Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 574Setting Up the Camera. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 583

Using Properties, Messages, and States . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 583Setting Up Bad Guys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 583Collecting Treasure and Racking Up Points. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 590

Creating Special Effects with Textures. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 594Creating Dynamic Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 594Creating Animated Textures. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 596

Working with Sound in the BGE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 602The Bottom Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 603

Chapter 16  •  Python Power in the Blender Game Engine . . . . . . . . . . . . . . . . .605From Logic Bricks to Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 605

Controlling a Character with Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 606Python Power for the BGE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 610

Creating a Teleportation Machine with Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 610Creating a Login Screen. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 615

Sound Effects and Multiple Viewports. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 622Working with Viewports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 622Accessing Sound with Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 626

Further Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 628The Bottom Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 628

Appendix  •  The Bottom Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 631Chapter 1: Working in Blender. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 631Chapter 2: Working with Textures and Materials. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 632Chapter 3: Sculpting and Retopo Workflow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 633Chapter 4: Rendering and Render Engines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 634Chapter 5: Getting Flexible with Soft Bodies and Cloth . . . . . . . . . . . . . . . . . . . . . . . . . 635Chapter 6: Working with Particles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 635Chapter 7: Volumetric Fluid, Smoke, and Fire. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 636Chapter 8: Bullet Physics and the Blender Game Engine . . . . . . . . . . . . . . . . . . . . . . . . 637

Page 21: Mastering - download.e-bookshelf.de€¦ · Acknowledgments As always, my thanks go first and foremost to Ton Roosendaal and all the Blender developers for all their hard work and

Contents | xIx

Chapter 9: Compositing with Nodes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 638Chapter 10: Advanced 3D/Video Compositing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 639Chapter 11: Working with the Video Sequence Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . 640Chapter 12: The Blender-Python Interpreter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 641Chapter 13: Python Scripting for Blender . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 642Chapter 14: Creating Assets for the Blender Game Engine. . . . . . . . . . . . . . . . . . . . . . . 643Chapter 15: Making Things Happen in the Game Engine . . . . . . . . . . . . . . . . . . . . . . . 644Chapter 16: Python Power in the Blender Game Engine . . . . . . . . . . . . . . . . . . . . . . . . . 645

Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 647

Page 22: Mastering - download.e-bookshelf.de€¦ · Acknowledgments As always, my thanks go first and foremost to Ton Roosendaal and all the Blender developers for all their hard work and
Page 23: Mastering - download.e-bookshelf.de€¦ · Acknowledgments As always, my thanks go first and foremost to Ton Roosendaal and all the Blender developers for all their hard work and

Introduction

Since the publication of the first edition of this book, things have continued to change rapidly in the world of Blender. The availability of training material has continued to grow, the Blender code base has grown another 50 percent since 2009, and Blender has seen wider user adop-tion than ever. The new interface and underlying event recode of version 2.5 has helped usher Blender into a whole new era. With the recent camera and object-tracking functionality and the development of the built-in Cycles unbiased render engine, Blender has begun to make serious inroads into visual effects, as evidenced by the latest Blender Foundation Open Movie, the live-action/CG effects bonanza Tears of Steel.

All of this progress is driven by the ongoing explosion of the Blender user base. Blender is widely used by students, hobbyists, artists, scientists, and CG professionals, and its use by these groups and others is growing every day. As the world of 3D software applications has become increasingly consolidated, Blender has emerged as the major alternative for people who want a free, open, and independent 3D solution. The Blender community is active in its support for the software, and as it grows and gains momentum, so does every aspect of Blender—from the avail-ability of professional support and training to the stability and functionality of the software itself.

This book is also a product of that expanding user base. Until a few years ago, there were not enough intermediate or advanced Blender users to warrant a book like this. Those intrepid users who did gain a high degree of expertise did so by studying the code and release notes, partici-pating in extensive forum and chat discussions, and putting in endless hours of experimenting with the software itself. My intention in writing this book is to provide today’s intermediate and advanced users with the book those early pioneers might have wished for. This is not a book for beginners. This is a book for Blender users.

The second edition of this book is completely revised and expanded to match the most recent versions of Blender and the most exciting new features. Furthermore, the book you hold in your hands contains not just revised material from the first edition of Mastering Blender but also fully revised material from my previous book, 2008’s Bounce, Tumble, and Splash!: Simulating the Physical World with Blender 3D . The content of the latter book seemed to be a natural fit with the overall goals of Mastering Blender . It has become the basis for the new section on physical simulation.

Who Should Read This BookTo get the most out of this book, you should already know how to get things done in Blender. You should know your way around a polygon mesh, and you should be able to set a keyframe and tweak an Ipo curve. In some areas, you may be pretty confident of your skills. Perhaps you are an expert modeler or a master at texturing and materials. You might be able to create beau-tiful, photorealistic scenes and render them in eye-popping quality. Maybe you’re a top-notch character animator.

Page 24: Mastering - download.e-bookshelf.de€¦ · Acknowledgments As always, my thanks go first and foremost to Ton Roosendaal and all the Blender developers for all their hard work and

xxII | IntRoDUCtIon

If you’re like the vast majority of Blender users, however, there’s a lot you’ve been quietly ignor-ing about your application of choice. You may have long since stopped wondering about that obscure buttons panel that you never touch. You may have disregarded some new development and now feel left too far behind to bother trying to catch up on it. You may have been under the impression that some areas of functionality, such as scripting, were too dry and difficult to get into, or maybe you’ve simply never been clear on how they might be useful to you and what you want to accomplish. Hopefully, this book will be a step in the direction of changing that.

In short, this book is for Blender users who wish to deepen and expand their knowledge of the software. As the title suggests, this book is for people who want to master Blender. If there are areas of Blender that you’ve wondered about but never looked into deeply, if there is func-tionality you’ve toyed with but never truly mastered, then this book is for you.

What You Will Learn from This BookThis book is an attempt to cover functionality in Blender that has not been sufficiently dealt with in other books and to cover specific workflow topics that will help intermediate Blender users boost their productivity and improve the quality of their work. The functionality of Blender is so extensive that even with the available books and training materials, there remains a great deal that has not received the attention it deserves.

For this reason, the subject matter covered here is broad. The first part of the book is the most varied, with chapters on a wide variety of Blender 3D features. The second part of the book focuses on Python and scripting for Blender, and the third part of the book deals with the Blender Game Engine. The only background that is assumed is an intermediate or advanced level of standard Blender usage. No knowledge of Python or the game engine is required. By the end of the book, you will have an advanced skill set in both of these areas, as well as numerous new insights in other areas of Blender.

How to Use This BookThe chapters in Parts I, II, and III of this book are organized in a loosely logical order but do not depend on each other in any significant way. As an intermediate or advanced Blender user, you should have no trouble reading them in whatever order you choose. Parts IV and V are more strictly ordered. Both of these parts of the book are organized in such a way as to give complete introductions to the topics they cover. Part IV first presents an introduction to Python itself and then works through Blender Python scripting topics, starting with the most generally appli-cable and finishing with the most specialized. The information is presented sequentially, so you should skip only what you feel confident that you already know. Correspondingly, Part V begins by describing how to create assets for use in the game engine and ends with the relatively advanced topic of using Python in the game engine environment.

A Word about Software VersionsThe version release scheduling of open-source software is not constrained by co-marketing con-siderations, and it is inevitable (and wonderful) that development will continue at a brisk pace regardless of the publication schedules of books. Experienced Blender users know this, and they know that mastery of one version sows the seeds for mastery of the next version.

In general, this book was written to be accurate to Blender version 2.63. However, some parts, notably those concerning the Clip Editor in Chapter 10, have been written based on develop-mental versions looking ahead to 2.64. The usual caveats apply: For the most predictable results,

Page 25: Mastering - download.e-bookshelf.de€¦ · Acknowledgments As always, my thanks go first and foremost to Ton Roosendaal and all the Blender developers for all their hard work and

IntRoDUCtIon | xxIII

you should use the appropriate version of Blender to follow the tutorials in the book. I heartily encourage you to forge ahead into newer versions, armed with this book and the online release notes, in order to keep your knowledge as up to date as possible and to cultivate the mindset of regarding Blender as a constantly developing tool. Even as you read this, new and exciting func-tionality is being added to Blender and released in official or unofficial versions that you will be eager to learn about.

My advice on keeping up with all the latest developments: Read fast!

The Mastering SeriesThe Mastering series from Sybex provides outstanding instruction for readers with intermediate and advanced skills, in the form of top-notch training and development for those already work-ing in their field and clear, serious education for those aspiring to become pros. Every Mastering book features the following:

◆◆ The Sybex “by professionals for professionals” commitment. Mastering authors are them-selves practitioners, with plenty of credentials in their areas of specialty.

◆◆ A practical perspective for a reader who already knows the basics—someone who needs solutions, not a primer.

◆◆ Real-World Scenarios, ranging from case studies to interviews, that show how the tool, technique, or knowledge presented is applied in actual practice.

◆◆ Skill-based instruction, with chapters organized around real tasks rather than abstract concepts or subjects.

◆◆ Self-review test “Master It” problems and questions, so you can be certain you’re equipped to do the job right.

How This Book Is OrganizedAs I mentioned previously, the book is organized into five parts. Part I includes Chapters 1 through 4. This part deals with general Blender topics, and each chapter within it covers a spe-cific aspect of Blender functionality. Part II covers physics simulation in its various forms, from soft bodies and cloth, to particles and hair, to volumetric fluids and smoke, and finally to rigid body simulations using the Bullet Physics library and the Blender Game Engine (BGE). Part III covers Blender’s video post-production functionality, including nonlinear video editing node-based compositing and camera tracking. Part IV gives a complete overview of Python scripting in Blender, beginning with a basic introduction to Python itself, suitable for nonprogrammers. Part V gives a thorough introduction to the BGE, including using Python in context of the BGE. In more detail, the chapters’ contents are as follows:

Part I: Fundamentals of Blender 3D

Chapter 1: Working in Blender introduces you to some of the fundamental concepts behind data organization in Blender and shows you a variety of ways you can customize your Blender environment and streamline your workflow.

Page 26: Mastering - download.e-bookshelf.de€¦ · Acknowledgments As always, my thanks go first and foremost to Ton Roosendaal and all the Blender developers for all their hard work and

xxIV | IntRoDUCtIon

Chapter 2: Working with Textures and Materials takes an in-depth look at Blender’s power-ful sculpting tools and shows you how to use them in conjunction with the retopo and nor-mal mapping functionality to obtain highly detailed sculpt effects while maintaining good model geometry and manageable polygon counts.

Chapter 3: Sculpting and Retopo Workflow shows you how to take your texturing skills to the next level, with tutorials on using GIMP in conjunction with Blender’s multiple UV tex-turing functionality to create totally seamless photographic textures and on using the mate-rial node system to combine materials for highly realistic effects.

Chapter 4: Rendering and Render Engines gives you the lowdown on render layers, passes, and their uses in both the Blender Internal render engine and the new built-in unbiased ren-der engine Cycles.

Part II: Physics and Simulations

Chapter 5: Getting Flexible with Soft Bodies and Cloth shows you how to make things bounce, flutter, and jiggle with Blender’s soft body and cloth simulation modifiers and how to use your simulations in animated scenes.

Chapter 6: Working with Particles shows you the wide variety of features and uses of Blender’s particle simulation system, including dynamic particles with standard physics and boids simulation as well as static particles for simulating hair and other strand-like behavior.

Chapter 7: Volumetric Fluid, Smoke, and Fire discusses Blender’s two volumetric physics simulation systems: the fluid simulation system and smoke and flame simulation. You’ll learn how to set up, tweak, and render the simulations with suitable materials.

Chapter 8: Bullet Physics and the Blender Game Engine takes a look at Blender’s built-in Bullet Physics Library for rigid body collision simulation. This chapter focuses on creat-ing rigid body simulations and incorporating them into animated scenes using the existing stable method Blender 2.63 (namely via the Blender Game Engine). You’ll also explore setting up simple ragdoll simulation.

Part III: Video Post-production in Blender

Chapter 9: Compositing with Nodes shows how to break down a render into its basic com-ponents and build it back up in the compositor, teaching you the basics of the composite node system along the way. It also shows you a simple example of pulling a green screen matte.

Chapter 10: Advanced 3D/Video Compositing shows you how to extract camera movement from live-action video using camera tracking in the new Clip Editor and how to add CG con-tent into live-action video shot with a moving camera. You will also learn the right way to do masking using bleeding-edge mask features.

Chapter 11: Working with the Video Sequence Editor brings Part III to its logical conclu-sion, showing you how to put everything together in Blender’s versatile Video Sequence Editor. You’ll learn to edit sound and video, do sophisticated transitions and overlays, and bring the full power of the compositing system to bear in a fully integrated, nonlinear video-editing environment.

Page 27: Mastering - download.e-bookshelf.de€¦ · Acknowledgments As always, my thanks go first and foremost to Ton Roosendaal and all the Blender developers for all their hard work and

IntRoDUCtIon | xxV

Part IV: Blender-Python

Chapter 12: The Blender-Python Interpreter provides a quick and painless introduction to the Python programming language itself. Assuming no programming experience at all, this chapter takes it from the top, giving you all the Python basics you need to know to sink your teeth into the next few chapters.

Chapter 13: Python Scripting for Blender gets down to business with Blender-Python. You’ll learn how to use Python to access 3D information, automate tasks, and build your own user interface for scripts. You’ll gain familiarity with the Blender-Python API and learn how to find the information you need to do what you need to do.

Part V: Mastering the Blender Game Engine

Chapter 14: Creating Assets for the Blender Game Engine walks you through the creation of a simple game world and a fully rigged character for a game. Among other things, you’ll learn about texture baking and 3D texture painting and how to set up armature actions for use in the game engine.

Chapter 15: Making Things Happen in the Game Engine gives an in-depth overview of a plethora of things you can do in the BGE: controlling characters and scenes with logic blocks, using properties and states to create complex interactions, creating dynamic text and in-game animated textures, and creating 3D sound effects.

Chapter 16: Python Power in the Blender Game Engine brings several threads together and takes it all a step further, showing you how to use Python to create more streamlined, orga-nized, and powerful game logic than can be created with logic blocks alone. You’ll learn how Python can enable you to create effects and logic that wouldn’t be possible otherwise, with examples such as a simple teleportation machine and a login screen. You’ll see how to handle multiple cameras and split-screen effects and to gain even more control over in-game sound.

To help ensure maximum clarity for the illustrations, there is a 16-page color insert full of images from the discussions and tutorials throughout the book.

What’s on the WebsiteYou will find a variety of .blend files intended to support the text on the Sybex website for this book: www.sybex.com/go/masteringblender2e.

How to Contact the AuthorIf you run into trouble at any point in reading this book, or if you have any insights or tips you would like to share, the first place I recommend to turn for quick responses and knowledgeable feedback is to the community itself at www.blenderartists.org/forum, where I post under the handle bugman_2000. You can also contact me directly at [email protected]. Follow me on Twitter at @_tonymullen.

Page 28: Mastering - download.e-bookshelf.de€¦ · Acknowledgments As always, my thanks go first and foremost to Ton Roosendaal and all the Blender developers for all their hard work and
Page 29: Mastering - download.e-bookshelf.de€¦ · Acknowledgments As always, my thanks go first and foremost to Ton Roosendaal and all the Blender developers for all their hard work and

Mastering Blender Second Edition

Page 30: Mastering - download.e-bookshelf.de€¦ · Acknowledgments As always, my thanks go first and foremost to Ton Roosendaal and all the Blender developers for all their hard work and