Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and...

100
© 2015 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple. #WWDC15 Managing 3D Assets with Model I/O Nick Porcino Apple Inc. Remi Palandri Apple Inc. Claudia Roberts Apple Inc. Graphics and Games Session 602

Transcript of Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and...

Page 1: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

© 2015 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple.

#WWDC15

Managing 3D Assets with Model I/O

Nick Porcino Apple Inc.Remi Palandri Apple Inc.Claudia Roberts Apple Inc.

Graphics and Games

Session 602

Page 2: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

Model I/O

Page 3: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

Model I/OFramework for handling 3D assets and data

Import and export 3D asset files• Describe lighting, materials, environments• Process and generate asset data• Bake lights, subdivide and voxelize meshes

For Physically Based Rendering• Designed for PBR tools and pipelines

Integrated with Xcode 7 and GameKit APIsAvailable for iOS 9 and OS X 10.11

Page 4: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

IntroductionModel I/O Workflow

OpenGL

SceneKit

MetalImport Model I/OContent Creation Tool

Page 5: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

IntroductionModel I/O Workflow

OpenGL

SceneKit

MetalImport Model I/OContent Creation Tool

Bake

Page 6: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

IntroductionModel I/O Workflow

OpenGL

SceneKit

MetalImport

Export

Model I/OContent Creation Tool

Bake

Page 7: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

AgendaThe Model I/O Framework

Features overviewData types and physical motivationGeometry and voxelsAdvanced lightingBaking

Page 8: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

Model I/O Overview

Page 9: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

File Formats

Import formats• Alembic .abc• Polygon .ply• Triangles .stl• Wavefront .obj

Export formats• Triangles .stl• Wavefront .obj

Page 10: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

Import and Export

ImportMDLAsset *asset = [[MDLAsset alloc] initWithURL:myURL];

Export[asset exportAssetToURL:myURL];

Page 11: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

Realistic lights• IES profile, temperature, image based

Realistic materials• Lambert / Blinn-Phong, physical BRDF

Realistic cameras• From lens to sensor

Realistic environments• Panoramic photographs• Procedural skies

Physical Realism

Page 12: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

Modify and Bake Assets

Ambient occlusion[mesh generateAmbientOcclusionTextureWithQuality: ... ];

Light and shadow baking[mesh generateLightMapTextureWithQuality: ... ];

Normals calculation[mesh addNormalsWithAttributeNamed: ... ];

Tangent basis[mesh addTangentBasisForTextureCoordinateAttributeNamed: ... ];

Page 13: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

Voxels

Page 14: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

Voxels

Create voxels from an asset[[MDLVoxelArray alloc] initWithAsset: ... ];

Find voxels in a regionNSData *indices = [voxels voxelsWithinExtent:extent];

Constructive solid geometry[voxels unionWithVoxels:sphereVoxels];

Create a meshMDLMesh *mesh = [voxels meshUsingAllocator:allocator];

Page 15: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

System Integration

SceneKit, Metal, and OpenGLPreview in Finder and QuickLookEdit in XcodePlaygrounds and Swift support

Page 16: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

Data Types

Page 17: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

MDLAssetOverview

Indexed container for 3D objects and materialsTransform hierarchiesMeshesCameras, lightsCreated procedurally or from a URL

Page 18: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

MDLAsset

Painted metal

Cab window glass

Wheels

Suspension

Excavator Body

Home CameraChase Camera Sun Light Root Transform

MDLAsset

Engine Block

Arm

Shovel

Page 19: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

allocators

MDLAsset

descriptors

import and export

MDLObjectMDLObject

MDLObject

MDLAsset

children

URL

Page 20: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

MDLObjectMDLObject

MDLObjectMDLObject

MDLObject

MDLObject

MDLObjectMDLObject

MDLObject

MDLAsset

...

MDLObject

MDLObject

MDLAsset

allocators

descriptors

import and export

children

URL

Page 21: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

User definedUser defined

MDLObject

MDLObject

MDLObjectMDLObject

MDLObjectMDLObject

MDLObject

MDLObject

MDLObjectMDLObject

MDLObject ...

MDLTransformComponent

User defined

MDLObject

MDLObject

transform

name

parent

bounding box

children

components

Page 22: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

User definedUser defined

MDLObject

MDLObject

MDLObjectMDLObject

MDLObjectMDLObject

MDLObject

MDLObject

MDLObjectMDLObject

MDLObject ...

MDLTransformComponent

User defined

TriggerComponent

MDLObject

MDLObject

name

actiontransform

name

parent

bounding box

children

components

Page 23: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

MDLMesh

Contains one or more vertex buffersVertex buffers contain information such as positions, and normalsContains one or more submeshesSubmeshes contain triangle or polygon indicesSubmeshes share data in vertex buffers

Page 24: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

MDLMesh

MDLMesh

Modifiers

Bakers

Boxes, ellipsoids, planes, etc.Subdivided model

Generators

MDLObject

submeshes

buffers

descriptors

transform

name

parent

bounding box

children

components

Page 25: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

MDLMesh

Compute normals, tangents, make vertices unique

MDLMesh

Modifiers

Bakers

Generators

MDLObject

submeshes

buffers

descriptors

transform

name

parent

bounding box

children

components

Page 26: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

MDLMesh

Ambient occlusion, light maps

MDLMesh

Modifiers

Bakers

Generators

MDLObject

submeshes

buffers

descriptors

transform

name

parent

bounding box

children

components

Page 27: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

MDLMeshBufferMDLMeshBuffer

MDLMeshBuffer

MDLObject

MDLMesh

MDLMesh

submeshes

descriptors

Generators

Modifiers

Bakers

MDLMeshBuffer

allocator

data

length

Map

transform

name

parent

bounding box

children

components

buffers

Page 28: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

MDLObject

MDLMesh

MDLVertexDescriptor

layout

name

attributes

MDLMesh

Generators

Modifiers

Bakers

submeshes

descriptors

buffers

transform

name

parent

bounding box

children

components

Page 29: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

MDLMeshBufferMDLMeshBuffer

MDLMeshBuffer

MDLObject

MDLMesh

MDLVertexAttribute

offset

name

format

buffer index

MDLMesh

Generators

Modifiers

Bakers

MDLVertexDescriptor

layout

name

attributes

submeshes

descriptors

buffers

transform

name

parent

bounding box

children

components

Page 30: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

MDLMeshBufferMDLMeshBuffer

MDLMeshBuffer

MDLObject

MDLMesh

MDLVertexBufferLayout

stride

MDLMesh

Generators

Modifiers

Bakers

MDLVertexDescriptor

layout

name

attributes

submeshes

descriptors

buffers

transform

name

parent

bounding box

children

components

Page 31: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

MDLObject

MDLMesh

MDLSubmesh

geometry type

name

index buffer

material

MDLMesh

Generators

Modifiers

Bakers

submeshes

descriptors

buffers

transform

name

parent

bounding box

children

components

Page 32: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

MaterialsIntuitive parameters

A dielectric, like clay

Page 33: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

MaterialsIntuitive parameters

A pure metal

Page 34: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

MaterialsIntuitive parameters

A combinationMetallic with an acrylic clear coat

Page 35: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

MaterialsIntuitive parameters

A satin finish

Page 36: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

MaterialsIntuitive parameters

A variety of finishes

Page 37: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

MDLMaterial

Lambert / Blinn-PhongPhysically Plausible

MDLSubmesh

geometry type

name

index buffer

MDLMaterial

name

base material

properties

material

scattering function

Page 38: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

MDLMaterial

Single inheritance

MDLSubmesh

geometry type

name

index buffer

MDLMaterial

name

base material

properties

material

scattering function

Page 39: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

MDLMaterial

MDLMeshBufferMDLMeshBuffer

MDLMeshBufferMDLMaterialProperty

name

semantic

type

value

MDLSubmesh

geometry type

name

index buffer

MDLMaterial

name

base material

properties

material

scattering function

Page 40: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

LightsPhysical realism

Classic CG lightsLights with physical parameters• Geometry• Lumens, color temperatureBaked light mapsIES standard light files

Page 41: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

MDLLight

MDLObject MDLLight

type

MDLPhysicallyPlausibleLight

color

lumens

angles

attenuation

transform

children

name

parent

bounding box

components

Page 42: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

MDLLight

MDLAreaLight

radius

shape

MDLObject MDLLight

type

MDLPhysicallyPlausibleLight

color

lumens

angles

attenuation

transform

children

name

parent

components

bounding box

Page 43: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

MDLLight

MDLPhotometricLight

light web

MDLObject MDLLight

type

MDLPhysicallyPlausibleLight

color

lumens

angles

attenuation

transform

children

name

parent

components

bounding box

Page 44: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

MDLLight

MDLLightProbe

reflective map

irradiance map

spherical harmonics

MDLObject MDLLight

type

MDLPhysicallyPlausibleLight

color

lumens

angles

attenuation

transform

children

name

parent

components

bounding box

Page 45: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

MDLCamera

A physical description of a cameraLens characteristicsShutter propertiesSensor propertiesWhat the camera can seeHow the image will be exposed

as

Page 46: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

MDLCamera

MDLCamera

lens geometry

visibility

lens glass

exit aperture

sensor

exposure

transform

MDLObject

children

name

parent

bounding box

components

Page 47: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

Default exposure settings

Page 48: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

Underexposed and flashed for shadow detail

Page 49: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

SkiesPhysical realism

Create a sky through physics• Time of day• Atmospheric condition

Page 50: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

SkiesPhysical realism

Create a sky through photography• Take a spherical panorama with your phone or DSLR

Page 51: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

SkiesPhysical realism

Create a sky through photography• Take a spherical panorama with your phone or DSLR

Page 52: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

SkiesPhysical realism

Prepare it for renderingMDLTexture *sky = [[MDLURLTexture alloc] initWithURL:picURL name:"skypano"];

Create a cube map for reflection and irradianceMDLTexture *cube = [MDLTexture irradianceTextureCubeWithTexture:sky ...];

Page 53: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

Incoming light from all directionsEfficient low-frequency representation Important for physically based rendering

Advanced LightingIrradiance

Page 54: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

SkiesPhysical realism

And perfectly match the lighting

Page 55: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

Integration with SceneKit

MDLAsset SceneKit root node

MDLMesh SCNNode with SCNGeometry

MDLLight SCNLight

MDLCamera SCNCamera

MDLMaterial SCNMaterial

Page 56: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

Integration with MetalKit

MetalKit will prepare buffers for rendering• Traverse asset to find lights, cameras• Use to drive custom Metal renderer

See “What’s New in Metal, Part 2”Integration with OpenGL and GLKit is similar

MDLAsset

MDLMesh Array of MTKMeshes

MDLLight

MDLCamera

Page 57: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

Models and VoxelsClaudia Roberts

Page 58: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

AgendaGeometry and modeling in Model I/O

Normal smoothingSubdivision surfacesVoxelsDemo

Page 59: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

Normal SmoothingShared vertex normals

Approximates curvature of more complicated geometryFlat vs smooth shading

Add smoothed out normals to the spaceship[spaceship addNormalsWithAttributeNamed:@“normals” creaseThreshold:0.5];

Page 60: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

Subdivision SurfacesVary surface detail

Generate subdivided mesh from source meshIncrease level of detail only when and where necessary

MDLMesh *mesh = [MDLMesh newSubdividedMesh:spaceship submeshIndex:0 subdivisionLevels:2];

Page 61: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

VoxelsPhysical realism

Volumetric representation consistent with the real worldProcedural modeling/generation Easily explore dataset via neighborhood, child traversal Facilitates real-world operations like slicing and cuttingConstructive Solid Geometry operations

Page 62: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

VoxelsPhysical realism

Volumetric representation consistent with the real worldProcedural modeling/generation Easily explore dataset via neighborhood, child traversal Facilitates real-world operations like slicing and cuttingConstructive Solid Geometry operations

Page 63: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

VoxelsPhysical realism

Volumetric representation consistent with the real worldProcedural modeling/generation Easily explore dataset via neighborhood, child traversal Facilitates real-world operations like slicing and cuttingConstructive Solid Geometry operations

Page 64: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

VoxelsPhysical realism

Volumetric representation consistent with the real worldProcedural modeling/generation Easily explore dataset via neighborhood, child traversal Facilitates real-world operations like slicing and cuttingConstructive Solid Geometry operations

Page 65: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

VoxelsMDLVoxelArray

Sparse volume grid accessed by a spatial index

(2,0,0)

(1,0,1)

(0,0,2)

(0,1,1)

(0,2,0)

(1,1,0)

z

Page 66: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

VoxelsMDLVoxelArray

Sparse volume grid accessed by a spatial indexQuick neighbor finding

(i, j, k)

(i, j+1, k-1)

(i+1, j, k-1))

z

Page 67: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

VoxelsMDLVoxelArray

Sparse volume grid accessed by a spatial indexQuick neighbor finding Interior, exterior, surface shell levels

Page 68: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

VoxelsMDLVoxelArray

Sparse volume grid accessed by a spatial indexQuick neighbor finding Interior, exterior, surface shell levelsModel healing and clean-up Create polygonal mesh from voxels

Page 69: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

VoxelsMDLVoxelArray operations

// Set voxels corresponding to mesh [grid setVoxelsForMesh:m divisions:25 interiorShells:0.f exteriorShells:0.f];

Page 70: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

VoxelsMDLVoxelArray operations

// Set voxels corresponding to mesh [grid setVoxelsForMesh:m divisions:25 interiorShells:0.f exteriorShells:0.f];

// Given a second MDLVoxelArray, perform boolean operations [grid intersectWithVoxels:voxels]; [grid unionWithVoxels:voxels]; [grid differenceWithVoxels:voxels];

Page 71: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

VoxelsMDLVoxelArray operations

// Set voxels corresponding to mesh [grid setVoxelsForMesh:m divisions:25 interiorShells:0.f exteriorShells:0.f];

// Given a second MDLVoxelArray, perform boolean operations [grid intersectWithVoxels:voxels]; [grid unionWithVoxels:voxels]; [grid differenceWithVoxels:voxels];

// Retrieve voxel data NSData *voxelData = [grid getVoxelIndices];

Page 72: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

VoxelsMDLVoxelArray operations

// Set voxels corresponding to mesh [grid setVoxelsForMesh:m divisions:25 interiorShells:0.f exteriorShells:0.f];

// Given a second MDLVoxelArray, perform boolean operations [grid intersectWithVoxels:voxels]; [grid unionWithVoxels:voxels]; [grid differenceWithVoxels:voxels];

// Retrieve voxel data NSData *voxelData = [grid getVoxelIndices];

// Create mesh from voxel grid MDLMesh *mesh = [grid meshUsingAllocator:allocator];

Page 73: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

DemoVoxels

Page 74: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

Advanced Lighting and BakingRemi Palandri

Page 75: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

Advanced LightingGlobal illumination

Global illumination looks great But very expensive We want to approximate GI Balance performance/quality

Page 76: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process
Page 77: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process
Page 78: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process
Page 79: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

Advanced LightingAmbient occlusion

Page 80: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

Advanced Lighting

Measure of geometry occlusion

Ambient occlusion

Page 81: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

Advanced Lighting

Measure of geometry occlusion

Ambient occlusion

Page 82: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

Advanced Lighting

Measure of geometry occlusionUses offline raytracing

Ambient occlusion

Page 83: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

Advanced Lighting

Measure of geometry occlusionUses offline raytracingInput—a mesh and a set of occlusion meshes

Ambient occlusion

Page 84: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

Advanced Lighting

Measure of geometry occlusionUses offline raytracingInput—a mesh and a set of occlusion meshesOutput—a set of occlusion values

Ambient occlusion

Page 85: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

Advanced Lighting

Measure of geometry occlusionUses offline raytracingInput—a mesh and a set of occlusion meshesOutput—a set of occlusion valuesStored in vertices or a texture

Ambient occlusion

Page 86: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

Advanced Lighting

Measure of geometry occlusionUses offline raytracingInput—a mesh and a set of occlusion meshesOutput—a set of occlusion valuesStored in vertices or a texture

Ambient occlusion

Page 87: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

Advanced LightingMDLMesh operations

// Bake the spaceship with itself [shipMesh generateAmbientOcclusionVertexColorsWithQuality:0.6 attenuationFactor:0.8 objectsToConsider:@[shipMesh] vertexAttributeNamed:@“aoTextureCoord” ];

// Bake the ground floor with its surrounding objects [groundMesh generateAmbientOcclusionTextureWithQuality:0.6 attenuationFactor:0.8 objectsToConsider:@[boxMesh, groundMesh] vertexAttributeNamed:@“aoTextureCoord” materialPropertyNamed:@“aoTextureProperty” ];

Page 88: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

DemoXcode Integration

Page 89: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

Advanced LightingLight maps

Page 90: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

Computes the effect of lights

Advanced LightingLight maps

Page 91: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

Computes the effect of lights

Advanced LightingLight maps

Page 92: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

Computes the effect of lights

Advanced LightingLight maps

Page 93: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

Computes the effect of lightsSupports lots of lights

Advanced LightingLight maps

Page 94: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

Computes the effect of lightsSupports lots of lightsCalculated offline

Advanced LightingLight maps

Page 95: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

Computes the effect of lightsSupports lots of lightsCalculated offlineComplex lights supported

Advanced LightingLight maps

Page 96: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

Summary

Import and export 3D asset filesPhysical basis for renderingModels, lights, cameras, materials, skiesIntegration with the system and frameworksTools in Xcode

Page 97: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

More Information

Documentation and Videoshttp://developer.apple.comApple Developer Forumshttp://developer.apple.com/forumsDeveloper Technical Supporthttp://developer.apple.com/support/technical

General InquiriesAllan Schaffer, Game Technologies [email protected]

Page 98: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

Related Sessions

Enhancements to SceneKit Mission Wednesday 2:30PM

What's New in Metal, Part 2 Mission Thursday 9:00AM

Page 99: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process

Labs

Model I/O Lab Graphics, Games, and Media Lab D Tuesday 3:30PM

Model I/O Lab Graphics, Games, and Media Lab D Wednesday 9:00AM

Page 100: Managing 3D Assets with Model I/O...Model I/O Framework for handling 3D assets and data Import and export 3D asset files • Describe lighting, materials, environments • Process