-
探索 RealityKit 的新进展
了解 RealityKit 的最新进展,让 App 和游戏的沉浸感和真实感更胜以往。探索一众强大的新功能,包括交互式布料模拟、NavMesh 寻路、混合现实光照,以及让空间音频更出彩的自定混响网格。借助改进的阴影效果、角色渲染增强功能以及对高斯泼溅技术的支持,提升视觉保真度。
章节
- 0:00 - Introduction
- 2:00 - Lighting and shadows
- 7:44 - Navigation mesh
- 11:01 - Cloth simulation
- 13:42 - Performance
- 17:09 - 3D Gaussian splats
- 19:08 - Immersive audio
- 22:42 - Next steps
资源
相关视频
WWDC26
-
搜索此视频…
-
-
4:02 - Soft shadows
// Enable soft shadows for the hearth spotlight guard var shadow = hearthSpotlight.components[SpotLightComponent.Shadow.self] else { // handle error } shadow.lightSize = 0.7 // meters shadow.quality = .medium // or .high // shadow.quality = .low // will result in hard shadows hearthSpotlight.components.set(shadow) -
6:13 - Projective textures
// Create one of the planetarium spotlights let spotLightEntity = Entity() spotLightEntity.components.set(SpotLightComponent( color: .white, intensity: intensity, innerAngleInDegrees: innerAngle, outerAngleInDegrees: outerAngle, attenuationRadius: attenuationRadius, )) let projectiveTexture: TextureResource = generateStarsAndNebulaeTexture() spotLightEntity.components.set(SpotLightComponent.ProjectiveTexture( texture: projectiveTexture )) -
7:13 - Physical space lighting
// Enable physical space lighting spotLightEntity.components.set(SpotLightComponent.SurroundingsLight()) -
9:46 - Querying the navigation mesh
// Querying the navigation mesh in Chaparral Village extension Entity { public func navigate(/* ... */) async { let navigator = try! NavigationController(entity: self) guard let result = await navigator.computePath(from: fromPosition, to: toPosition) else { return } if result.isEmpty { return } for node in result { switch node.category { case .meshPoint: finalPath.append(node.position) case .offMeshConnection: // handle ladders } } } } -
12:51 - Pinning cloth to anchor points
// Pin the curtains to the Alchemist's lab for (pin, pinComponent) in pins { let position = pin.position(relativeTo: event.entity) let selectionSphere = ClothSphereShape(radius: pinComponent.radius) let vertices = clothMesh.vertices(in: .sphere(selectionSphere), center: position) clothBody.motionTypes.set(vertexIndices: vertices, value: .kinematic) } -
14:42 - LOD by camera distance
// Create entity with LODs let lod0 = [ModelEntity(mesh: lodMesh0)] let lod1 = [ModelEntity(mesh: lodMesh1)] let lod2 = [ModelEntity(mesh: lodMesh2)] let entity = Entity() LevelOfDetailComponent.addByCameraDistance(to: entity, levels: [ (entities: lod0, maxDistance: 1.0 /* meters */), // highest detail (entities: lod1, maxDistance: 5.0), // medium detail (entities: lod2, maxDistance: .infinity), // lowest detail ]) -
15:58 - LOD by screen area
// Create entity with LODs let lod0 = [ModelEntity(mesh: lodMesh0)] let lod1 = [ModelEntity(mesh: lodMesh1)] let lod2 = [ModelEntity(mesh: lodMesh2)] let entity = Entity() LevelOfDetailComponent.addByScreenArea(to: entity, levels: [ (entities: lod0, minArea: 0.2 /* fraction of screen area */), // highest detail (entities: lod1, minArea: 0.1), // medium detail (entities: lod2, minArea: 0.01), // lowest detail ]) -
16:26 - Responding to thermal state changes
// Respond to changes in device thermal state NotificationCenter.default.addObserver(of: ProcessInfo.self, for: .thermalStateDidChange) {_ in switch ProcessInfo.processInfo.thermalState { case .nominal, .fair: // Stay the course case .serious, .critical: // Improve performance by: // More aggressive LOD switching // Lower shadow quality } } -
18:44 - Creating a Gaussian splat
// Create Gaussian splat resource and component let resource = try GaussianSplatResource.BufferResource(count: splatCount, position: positionBuffer, scale: scaleBuffer, rotation: rotationBuffer, opacity: opacityBuffer, sphericalHarmonics: (sphericalHarmonicsBuffer, degree)) let splatResource = GaussianSplatResource(resource) let splatComponent = GaussianSplatComponent(splatResource) splatEntity.components.set(splatComponent) -
20:49 - Creating a custom reverb mesh
// Create and use custom reverb mesh let mesh: ReverbMeshResource = .shoebox(size: [5, 4, 6]) let reverb: Reverb = .simulated(mesh: mesh, materials: [.dryWall]) entity.components.set(ReverbComponent(reverb: reverb)) -
21:33 - Creating custom reverb materials
// Create custom materials for custom reverb mesh let thickCarpet: Audio.Material = .carpet.scalingAbsorption {freq in 0.1 } let bookshelf: Audio.Material // Absorption coefficients by center frequency: // 31.5Hz, 63Hz, 125Hz, 250Hz, 500Hz, 1kHz, 2kHz, 4kHz, 8kHz, 16kHz let bookshelfAbsorption = Audio.Absorption( [0.10, 0.15, 0.28, 0.20, 0.15, 0.10, 0.10, 0.07, 0.07, 0.05]) // Scattering coefficients for: 500Hz, 1000Hz, 4000Hz let bookshelfScattering = Audio.Scattering([500: 0.5, 1000: 0.6, 4000: 0.7]) bookshelf = .init(absorption: bookshelfAbsorption, scattering: bookshelfScattering)
-
-
- 0:00 - Introduction
Overview of the new RealityKit features introduced this year, including lighting and shadows, navigation mesh, cloth simulation, performance tools, 3D Gaussian splats, and immersive audio.
- 2:00 - Lighting and shadows
Explore RealityKit's updated lighting and shadow capabilities, including lightmap support for indirect lighting and ambient occlusion, soft shadows for dynamic lights, projective textures, and physical space lighting that lets virtual lights interact with real-world environments.
- 7:44 - Navigation mesh
Learn how to use RealityKit's navigation mesh to define traversable paths for characters and NPCs. Covers NavigationMeshResource, NavigationComponent, NavigationController, and how to query and iterate path nodes asynchronously.
- 11:01 - Cloth simulation
Discover how to add realistic cloth simulation to your scenes using ClothBodyComponent, ClothColliderComponent, and cloth mesh resources. Includes how to pin cloth vertices to anchor points using kinematic motion types.
- 13:42 - Performance
Cover performance optimization techniques, including mesh level of detail (LOD) using LevelOfDetailComponent with camera-distance and screen-area algorithms, and how to monitor and respond to device thermal state changes.
- 17:09 - 3D Gaussian splats
Learn how to render high-fidelity real-world captures using RealityKit's 3D Gaussian splat support. Covers how to construct a GaussianSplatResource from position, scale, rotation, opacity, and spherical harmonics buffers, and attach it via GaussianSplatComponent.
- 19:08 - Immersive audio
Explore RealityKit's immersive audio features for Apple Vision Pro, including custom reverb meshes that model the acoustic properties of virtual and real environments. Covers ReverbMeshResource, built-in preset materials, and creating custom materials with absorption and scattering coefficients.
- 22:42 - Next steps
Recap of session topics and pointers to related sessions, sample code, and documentation to explore more of what RealityKit has to offer this year.