diff --git a/18-rendering-with-rays/README.md b/18-rendering-with-rays/README.md new file mode 100644 index 0000000..8f5ff56 --- /dev/null +++ b/18-rendering-with-rays/README.md @@ -0,0 +1,80 @@ +# 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()! +``` diff --git a/README.md b/README.md index 309012b..39abb7c 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,7 @@ You can see color images in this book at [here](https://www.raywenderlich.com/bo * [Chapter 14: Multipass & Deferred Rendering](https://github.com/daemyung/metal-by-tutorials/tree/main/14-multipass-rendering) * [Chapter 15: GPU-Driven Rendering](https://github.com/daemyung/metal-by-tutorials/tree/main/15-gpu-driven-rendering) * [Chapter 16: Particle Systems](https://github.com/daemyung/metal-by-tutorials/tree/main/16-particle-systems) + * [Chapter 18: Rendering with Rays](https://github.com/daemyung/metal-by-tutorials/tree/main/18-rendering-with-rays) ## Copyright