Learn how you can using instancing to render crowd scenes or a field of grass using minimal resources.
This is a companion discussion topic for the original entry at https://www.raywenderlich.com/3537-beginning-metal/lessons/10
Learn how you can using instancing to render crowd scenes or a field of grass using minimal resources.
Great tutorial series! Watching the last 3 lessons today.
One code issue in InstanceScene.swift in the video and the download materialsā¦
In InstanceScene.swift, the outer āfor _ in 0ā¦<40ā loop is not needed after the āfor human in humans.nodesā loop is added is it?
Hello Caroline. Awesome tutorial! I have a question regarding the uint instanceID. Is it possible to create an āinstanceDescriptorā and utilize the [stage_in] qualifier as opposed to using the [instance_id] qualifier.
@twohyjr - Iām not quite sure where your questionās coming from.
The [[ stage_in ]]
qualifier is per vertex.
When you use instancing, youāre using the same vertex over and over, but just different parameters for each instance.
Hi Caroline. Great series so far ā thanks!
One problem. I tried following the challenge through but noticed that no grass was appearing (this is using Swift 4 and Xcode 9, beta 6). Tapping āCapture GPU Frameā I noticed the following issue appears in the instance debug group:
The Compiler was not able to Preload your Buffer
(Issue) The compiler was not able to preload your buffer. Simplify your memory access pattern by using the constant address space, a struct, or a descriptor.
I double checked against the final project included in the chapter resources, only adding the two necessary lines to compile (pipelineDescriptor.depthAttachmentPixelFormat = .depth32Float
and metalView.depthStencilPixelFormat = .depth32Float
), and Iām seeing the same result ā although the models do display here.
Any ideas?
Missing grass and the issue above were in fact unrelated.
My grass was just underground. Clearly just needed some watering a.k.a. setting grass.position.z
not grass.position.y
!
@cldr - so glad you were able to fix it! It can be very frustrating when the mesh just disappears.