Skip to content

Commit

Permalink
Transparency fixes: opaque first, transparent later
Browse files Browse the repository at this point in the history
  • Loading branch information
kenohori committed Dec 15, 2016
1 parent 7cea702 commit 1dc4021
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions src/MetalView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -926,10 +926,33 @@ class MetalView: MTKView {
continue
}
if faceBuffers[bufferType.key]![bufferSubtype.key]!.length > 0 {
renderEncoder.setVertexBuffer(faceBuffers[bufferType.key]![bufferSubtype.key]!, offset:0, at:0)
constants.colour = renderedTypes[bufferType.key]![bufferSubtype.key]!
renderEncoder.setVertexBytes(&constants, length: MemoryLayout<Constants>.size, at: 1)
renderEncoder.drawPrimitives(type: .triangle, vertexStart: 0, vertexCount: faceBuffers[bufferType.key]![bufferSubtype.key]!.length/MemoryLayout<VertexWithNormal>.size)
if renderedTypes[bufferType.key]![bufferSubtype.key]!.w == 1.0 {
renderEncoder.setVertexBuffer(faceBuffers[bufferType.key]![bufferSubtype.key]!, offset:0, at:0)
constants.colour = renderedTypes[bufferType.key]![bufferSubtype.key]!
renderEncoder.setVertexBytes(&constants, length: MemoryLayout<Constants>.size, at: 1)
renderEncoder.drawPrimitives(type: .triangle, vertexStart: 0, vertexCount: faceBuffers[bufferType.key]![bufferSubtype.key]!.length/MemoryLayout<VertexWithNormal>.size)
}
}
}
}

for bufferType in faceBuffers {
if !renderedTypes.keys.contains(bufferType.key) {
// Swift.print("Render type for \(bufferType.key) not set")
continue
}
for bufferSubtype in bufferType.value {
if !renderedTypes[bufferType.key]!.keys.contains(bufferSubtype.key) {
// Swift.print("Render type for \(bufferType.key) \(bufferSubtype.key) not set")
continue
}
if faceBuffers[bufferType.key]![bufferSubtype.key]!.length > 0 {
if renderedTypes[bufferType.key]![bufferSubtype.key]!.w < 1.0 {
renderEncoder.setVertexBuffer(faceBuffers[bufferType.key]![bufferSubtype.key]!, offset:0, at:0)
constants.colour = renderedTypes[bufferType.key]![bufferSubtype.key]!
renderEncoder.setVertexBytes(&constants, length: MemoryLayout<Constants>.size, at: 1)
renderEncoder.drawPrimitives(type: .triangle, vertexStart: 0, vertexCount: faceBuffers[bufferType.key]![bufferSubtype.key]!.length/MemoryLayout<VertexWithNormal>.size)
}
}
}
}
Expand Down

0 comments on commit 1dc4021

Please sign in to comment.