Implement Emily's algorithm for computing vertex normals

This commit is contained in:
Eryn Wells 2018-11-22 10:53:02 -07:00
parent 3cd9aca62b
commit 6c0792fc9c
2 changed files with 62 additions and 1 deletions

View file

@ -200,6 +200,7 @@ class Terrain: NSObject {
computeEncoder.setBuffer(faceNormalsBuffer, offset: 0, index: GeneratorBufferIndex.faceNormals.rawValue)
let normalsBuffer = mesh.vertexBuffers[BufferIndex.normals.rawValue]
computeEncoder.setBuffer(normalsBuffer.buffer, offset: normalsBuffer.offset, index: GeneratorBufferIndex.normals.rawValue)
computeEncoder.setBuffer(uniforms.buffer, offset: uniforms.offset, index: GeneratorBufferIndex.uniforms.rawValue)
computeEncoder.dispatchThreads(MTLSize(width: 2 * Int(segments.x * segments.y), height: 1, depth: 1), threadsPerThreadgroup: MTLSize(width: 8, height: 8, depth: 1))
computeEncoder.popDebugGroup()
computeEncoder.endEncoding()