MetalByTutorials/18-rendering-with-rays
daemyung jang 6e21d3a9e9
Summerize Chapter 18: Rendering with Rays
2022-04-04 00:46:17 +09:00
..
final/Clouds.playground Copy source code from the official website 2021-04-15 11:39:00 +09:00
projects Copy source code from the official website 2021-04-15 11:39:00 +09:00
starter/Clouds.playground Fix runtime errors 2022-04-03 21:56:43 +09:00
README.md Summerize Chapter 18: Rendering with Rays 2022-04-04 00:46:17 +09:00
references.markdown Copy source code from the official website 2021-04-15 11:39:00 +09:00

README.md

Chapter 18: Rendering with Rays

As I read this book, I summarize what I think is wrong. If you think my comments are wrong then please let me know. We can dicuss more and update your opinion.

Signed distance functions

There is a runtime error in because Shaders.metal files isn't included in the bundle. But we have the default library.

In Renderer.swift, in initializeMetal(), replace this:

guard let path = Bundle.main.path(forResource: "Shaders", ofType: "metal") else { fatalError() }
let input = try String(contentsOfFile: path, encoding: String.Encoding.utf8)
let library = try device.makeLibrary(source: input, options: nil)

With:

let library = device.makeDefaultLibrary()!

The raymarching algorithm

There is a runtime error in because Shaders.metal files isn't included in the bundle. But we have the default library.

In Renderer.swift, in initializeMetal(), replace this:

guard let path = Bundle.main.path(forResource: "Shaders", ofType: "metal") else { fatalError() }
let input = try String(contentsOfFile: path, encoding: String.Encoding.utf8)
let library = try device.makeLibrary(source: input, options: nil)

With:

let library = device.makeDefaultLibrary()!

Creating random noise

There is a runtime error in because Shaders.metal files isn't included in the bundle. But we have the default library.

In Renderer.swift, in initializeMetal(), remove this:

let path = Bundle.main.path(forResource: "Shaders", ofType: "metal")

Replace this:

let input = try String(contentsOfFile: path!, encoding: String.Encoding.utf8)
let library = try device!.makeLibrary(source: input, options: nil)

With:

let library = device.makeDefaultLibrary()!

Marching clouds

There is a runtime error in because Shaders.metal files isn't included in the bundle. But we have the default library.

In Renderer.swift, in initializeMetal(), replace this:

guard let path = Bundle.main.path(forResource: "Shaders", ofType: "metal") else { fatalError() }
let input = try String(contentsOfFile: path, encoding: String.Encoding.utf8)
let library = try device.makeLibrary(source: input, options: nil)

With:

let library = device.makeDefaultLibrary()!