Compare commits
2 Commits
1bc5abb4b0
...
6e21d3a9e9
| Author | SHA1 | Date |
|---|---|---|
|
|
6e21d3a9e9 | |
|
|
ae0cf5ed91 |
|
|
@ -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()!
|
||||
```
|
||||
|
|
@ -16,9 +16,7 @@ public class Renderer: NSObject, MTKViewDelegate {
|
|||
device = MTLCreateSystemDefaultDevice()
|
||||
queue = device!.makeCommandQueue()
|
||||
do {
|
||||
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)
|
||||
let library = device.makeDefaultLibrary()!
|
||||
guard let kernel = library.makeFunction(name: "compute") else { fatalError() }
|
||||
pipelineState = try device.makeComputePipelineState(function: kernel)
|
||||
} catch {
|
||||
|
|
|
|||
|
|
@ -17,9 +17,7 @@ public class Renderer: NSObject, MTKViewDelegate {
|
|||
device = MTLCreateSystemDefaultDevice()
|
||||
queue = device!.makeCommandQueue()
|
||||
do {
|
||||
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)
|
||||
let library = device.makeDefaultLibrary()!
|
||||
guard let kernel = library.makeFunction(name: "compute") else { fatalError() }
|
||||
pipelineState = try device.makeComputePipelineState(function: kernel)
|
||||
} catch {
|
||||
|
|
|
|||
|
|
@ -17,10 +17,8 @@ public class Renderer: NSObject, MTKViewDelegate {
|
|||
func initializeMetal() {
|
||||
device = MTLCreateSystemDefaultDevice()
|
||||
queue = device!.makeCommandQueue()
|
||||
let path = Bundle.main.path(forResource: "Shaders", ofType: "metal")
|
||||
do {
|
||||
let input = try String(contentsOfFile: path!, encoding: String.Encoding.utf8)
|
||||
let library = try device!.makeLibrary(source: input, options: nil)
|
||||
let library = device.makeDefaultLibrary()!
|
||||
let kernel = library.makeFunction(name: "compute")!
|
||||
pipelineState = try device!.makeComputePipelineState(function: kernel)
|
||||
} catch {
|
||||
|
|
|
|||
|
|
@ -17,9 +17,7 @@ public class Renderer: NSObject, MTKViewDelegate {
|
|||
device = MTLCreateSystemDefaultDevice()
|
||||
queue = device!.makeCommandQueue()
|
||||
do {
|
||||
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)
|
||||
let library = device.makeDefaultLibrary()!
|
||||
guard let kernel = library.makeFunction(name: "compute") else { fatalError() }
|
||||
pipelineState = try device.makeComputePipelineState(function: kernel)
|
||||
} catch {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue