t. driemeyer rendering with mental ray® third, completely

10
T. Driemeyer Rendering with mental ray® Third, completely revised edition «• SpringerWienNewYork

Upload: others

Post on 22-Apr-2022

3 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: T. Driemeyer Rendering with mental ray® Third, completely

T. Driemeyer

Rendering with mental ray®

Third, completely revised edition

«•

SpringerWienNewYork

Page 2: T. Driemeyer Rendering with mental ray® Third, completely

Table of Contents

Introduction 1 Organization of This Book 1

Typesetting Conventions 3

WWW Resources 4

Acknowledgements 4

i Overview 5 1.1 Photorealistic Rendering 5

1.2 Scenes and Animations 5

1.2.1 Geometrie Objects 6

1.2.2 Materials 9

1.2.3 Light Sources 10

1.2.4 Cameras 11

1.3 Shaders 11

1.4 Phenomena 13

1.5 Scanline Rendering and Ray Tracing 14

1.5.1 Transparency, Refractions, and Reflections 15

1.5.2 Shadows 16

1.5.3 Motion Blur 17

1.5.4 Lenses 17

1.6 Caustics, Global Illumination, and Photon Maps 18

1.7 Participating Media 19

1.8 Parallelism 19

1.9 Stages of Image Generation 20

1.10 mental ray Configurations 21

1.11 mental ray Versions 21

1.11.1 Changes between Versions 2.0 and 2.1 22

1.11.2 Changes between Versions 2.1 and 3.0 23

1.11.3 Changes between Versions 3.0 and 3.1 24

1.11.4 Changes between mental ray 3.1 and 3.2 26

1.11.5 Changes between mental ray 3.2 and 3.3 28

1.11.6 Changes between mental ray 3.3 and 3.4 29

2 Scene Construction 31 2.1 A Simple Scene 32

2.2 Anatomy of a Scene 35

Page 3: T. Driemeyer Rendering with mental ray® Third, completely

,->

viii Table of Contents

3 Cameras 39 3.1 Pinhole Cameras 39

3.2 Image Resolution 39

3.3 Aspect Ratio 40

3.4 Keystone Distortion 41

3.5 Rendering Subwindows 42

3.6 Orthographie Camera 42

3.7 Clipping Planes * 43

3.8 Lenses: Depth of Field 44

3.9 Füll Camera Example 46

4 Surface Shading 49 4.1 Color and Illumination 52

4.2 Texture Mapping 57

4.2.1 Texture Protections 58

4.2.1.1 Simple XY Protection 59

4.2.1.2 Repeated XY Protection 61

4.2.1.3 Other Protections 62

4.2.1.4 Texture Vectors 64

4.2.1.5 Texture Generation from Coordinate Spaces 69

4.2.2 Local Textures: Avoiding Network Transfers 69

4.2.3 Memory Mapped Textures: Reducing Memory Usage 70

4.2.4 Aliasing in Unfiltered Textures 72

4.2.5 Simple Filtered Textures: Reducing Texture Aliasing 75

4.2.6 Elliptic Filtered Textures: Even Better Texture Anti-Aliasing 77

4.2.7 Summary: Selecting Optimal Texturing Methods 79

4.2.8 3D Textures 81

4.3 Transparency Mapping 83

4.4 Bump Mapping 85

4.5 Displacement Mapping 90

4.5.1 Simple Displacement Approximation31 93

4.5.2 Advanced Displacement Approximation * 95

4.6 Anisotropie Shading 104

4.7 Environment Mapping 108

4.8 Light Mapping 112

4.9 Reflection 118

4.10 Transparency and Refraction 123

4.11 Glossy Reflection 126

4.12 Glossy Transmission (Translucency) 129

Page 4: T. Driemeyer Rendering with mental ray® Third, completely

Table of Contents ix

4.13 Summary of Illumination Models 129

5 Light and Shadow 133 5.1 Point, Spot, and Infinite Lights 135

5.2 Raytraced Shadows 139

5.2.1 Transparent Shadows with Shadow Shaders 141

5.2.2 Soft Shadows with Area Light Sources 143

5.2.3 Shadow Modes: Regulär, Sorted, Segmented 147

5.3 Fast Shadows with Shadow Maps 148

5.4 Detail Shadowmaps33 155

5.5 Internais: How Shadows are Computed ** 156

5.5.1 Raytraced Shadows 156

5.5.2 Shadow Map Shadows 158

5.6 Shadow Summary and Performance 161

5.7 Color Profiles3 A* 162

6 Volume Rendering 165 6.1 Global Volumes: Atmospheres and Fog 166

6.2 Local Volumes: Für, Fire, Smoke 167

6.3 Ray Marching 171

6.4 Automatic Volumes3 3 175

7 Caustics and Global Il lumination 177 7.1 Photon Mapping vs. Final Gathering 178

7.2 Local Illumination vs. Caustics vs. Global Illumination 181

7.3 Diffuse, Glossy, and Specular Reflection and Transmission 181

7.4 Classification of Light Paths 184

7.5 Caustic and Global Illumination Lights 187

7.6 Caustics 190

7.7 Global Illumination 198

7.7.1 Diffuse Global Illumination (Radiosity) 198

7.7.2 Glossy Global Illumination 201

7.7.3 General Global Illumination 202

7.7.4 Final Gathering 206

7.8 Participating Media 212

7.8.1 Volume Caustics 212

7.8.2 Multiple Volume Scattering: Global Illumination in Volumes 218

7.8.3 Global Illumination in Volumes and Surfaces 221

7.9 The Importance of Physically Correct Shaders 223

7.9.1 Light and Distance 224

7.9.2 Illumination Models 225

Page 5: T. Driemeyer Rendering with mental ray® Third, completely

Table of Contents

7.10 Frequently Asked Questions 226

7.11 Summary 232

7.12 Performance 235

8 Motion Blur 237 8.1 Motion Transformations 238

8.2 Motion Vectors 240

8.3 Summary and Performance 242

9 Hardware Rendering 245 9.1 Hardware vs. Software Rendering 245

9.2 Layering 248

9.3 Speed vs. Quality Tradeoffs 249

9.4 Shader Interfaces 251

9.5 Shader Declarations 252

9.6 Loading Hardware Shaders 253

9.7 Using Hardware Rendering 254

9.7.1 Enabling Hardware Rendering 256

9.7.2 Choosing Hardware Shader Categories 257

9.7.3 Enabling Hardware Rendering per Object 258

9.7.4 Hardware Shaders in Materials 258

9.7.5 Extracting Cg Shader Code 259

9.8 Hardware Shader Implementation 260

i o Contours 261 10.1 Outline Contours 262

10.2 PostScript Contours 265

10.3 Edge Contours 266

10.4 Contours on Reflections and Refractions 266

10.5 Contours at Color Contrasts 267

10.6 Variable-Width Contours 269

10.7 Glowing Contours 270

10.8 Performance 270

i i Shaders and Phenomena 271 11.1 Declarations 272

11.2 Definitions 275

11.3 Shader Lists 277

11.4 Shader Graphs 278

11.5 Phenomena 281

11.5.1 Phenomenon Interface Assignments 283

Page 6: T. Driemeyer Rendering with mental ray® Third, completely

Table of Contents xi

11.5.2 Shader and Phenomenon Options 284

11.5.3 Phenomenon Roots 286

11.6 User Data Blocks 287

11.7 Summary and Performance 288

12 Postprocessing and Image Output 291 12.1 Image Types 292

12.2 Frame Buffers 294

12.3 Image Formats 296

13 Geometrie Objects ** 303 13.1 Vectors and Vertices 308

13.2 Polygonal Geometry 312

13.3 Free-Form Surface Geometry 314

13.3.1 Bases 315

13.3.1.1 Bezier 316

13.3.1.2 B-Spline 317

13.3.1.3 Cardinal 319

13.3.1.4 Basis Matrix 320

13.3.1.5 Taylor 321

13.3.2 Surfaces 321

13.3.3 Rational Surfaces and NURBS 326

13.3.4 Trimming and Holes 328

13.3.5 Special Points and Curves 331

13.3.6 Texture Surfaces 333

13.3.7 Surface Derivatives 336

13.3.8 Simple Approximations 337

13.3.9 Advanced Approximations * 338

13.3.10 Triangle Count and Performance * 346

13.3.11 Connections 347

13.4 Hierarchical Subdivision Surfaces 348

13.4.1 Adding Detail 352

13.4.2 Smooth Creases 354

13.4.3 Vertex Features 355

13.4.4 Trimming 359

13.5 Hair 361

13.5.1 Optimizing Hair Usage 363

13.5.2 Example 365

13.6 Procedural Geometry 365

13.7 Demand-loaded Placeholder Geometry 369

«e

Page 7: T. Driemeyer Rendering with mental ray® Third, completely

-

xii Table of Contents

14 Instancingand Grouping 371

14.1 Instances 371

14.2 Instance Groups 373

14.3 Multiple Instancing 374

14.4 Coordinate Spaces 375

15 Inheritance 379

15.1 Material Inheritance 379

15.2 Tagged Material Inheritance 384

15.3 Parameter Inheritance 387

15.4 Object Flag Inheritance 389

16 Incremental Changes and Animations 393

17 Using and Creating Shader Libraries** 399

18 Parallelism 405

18.1 Thread Parallelism 405

18.2 Network Parallelism 406

18.3 Parallelism Efficiency 407

18.4 Balancing Network Rendering 409

18.5 Rendering Animations 410

18.6 Filename Rewriting 411

19 The Options Block 417

19.1 Feature Flags 417

19.2 Rendering Quality and Performance 420

19.3 Shadows 422

19.4 Ray Tracing Control 423

19.5 Final Gathering, Global Illumination, and Caustics 424

19.6 Scene Modeling 427

19.7 Diagnostic Modes 428

20 The Architectureof mental ray 3.x** 431

20.1 Scene Database Caching 432

20.2 Multithreading and Networking 432

20.3 Cache Behavior 433

20.4 Controlling Cache Performance 435

21 Quality and Performance Tuning 437

21.1 Reading the Message Log * 437

Page 8: T. Driemeyer Rendering with mental ray® Third, completely

Table of Contents xiii

21.2 Image Sampling Quality 440

21.3 Ray Tracing vs. Scanline Rendering * 444

21.4 OpenGL Hardware Acceleration * 446

21.5 Tuning BSP Ray Tracing Parameters * 447

21.5.1 Using Diagnostics for BSP Optimization * 449

21.6 Optimizing Memory Usage * 450

21.7 Optimizing the Cache Size * 455

21.8 Address Space Limitations * 456

21.9 Summary: Quality and Performance Checklist 457

21.9.1 Sampling 457

21.9.2 Texture Mapping 458

21.9.3 Light and Shadow 458

21.9.4 Final Gathering, Caustics, and Global Illumination 459

21.9.5 Geometry Modeling 459

21.9.6 Shaders and Phenomena 460

21.9.7 Networking and Multithreading 460

21.9.8 Memory Management 461

22 Troubleshooting* 463 22.1 Sampling 463

22.2 Shading 464

22.3 Caustics and Global Illumination 464

22.4 Geometry 465

22.5 System 466

Color Plates 469

A Command LineOptions 487 A.l mental ray 487

A.2 Inventor mental ray 506

A.3 Environment Variables * 507

A.4 Image Display: imLdisp 509

A.5 Image Copy: imLcopy 511

A.6 Image Information: imLinfo 512

A.7 Image Comparison: imLdiff 513

A.8 Create Shader Skeletons: mkmishader ** 514

A.9 Convert Scenes to C: mitoapi ** 514

A.10 Finalgather Map Copy: fg.copy ** 515

B The Sphere and Utah Teapot Models 517 B.l NURBS Sphere 517

Page 9: T. Driemeyer Rendering with mental ray® Third, completely

xiv Table of Contents

B.2 Utah Teapot 517

C Base Shaders * 525 C. 1 Overview 525

C.2 Texture Space Mapping 527

C.3 Environments 532

C.4 Textures 535

C.5 Sample Compositing 539

C.6 Illumination 543

C.7 Data Conversion 551

C.8 Geometry 555

C.9 Photon 558

CIO Light 559

C.l 1 Light Utilities 561

C.12 Shadow 562

C.13 Light Mapping 563

C.14 Lens 564

D Physics Shaders * 567 D.l Lens Shader: physicaLlens_dof 567

D.2 Light Shader: physicalJight 568

D.3 Materials 568

D.4 Photon Tracing 571

D.5 Participating Media 571

D.6 Photon Tracing in Participating Media 573

D.7 Physically Correct Subsurface Scattering 575

D.7.1 Scene Requirements 576

D.7.2 Shaders 578

D.7.2.1 misss-physical 578

D.7.2.2 misss.physicaLphen 579

D.7.3 Optical properties 579

D.7.4 Tuning 580

D.7.5 Attributes Correlations 581

D.7.6 Known Issues and Limitations 585

E Contour Shaders * 587 E.l Contour Store Shaders 588

E.2 Contour Contrast Shaders 588

E.3 Material Contour Shaders 589

E.4 Contour Output Shaders 598

Page 10: T. Driemeyer Rendering with mental ray® Third, completely

Table of Contents

Glossary 601

Bibliography 615

Index 617