In Chapter 20, after the “Blending” section you mention using GPU Frame Capture to “examine the textures”. I did the capture and navigated to a list of textures (one of the “All Resources” buttons) and got the list of textures (attached screen shot). My question : is there a “better” way to identify the texture (by name? by index?) other than just the little image icon and its size (or other “general” attributes)? Is there a way to “lookup” the “address” of the texture? Or, is there a “better” way to look at/identify the textures in the pipeline? I know these are part of the Model, so is there a way, upon Model load, to set a label or identifier (or am I just way off base, yet again).
Again, I’m very glad you brought up the subject. All Metal buffers have a label
property, which is what shows up in the frame capture.
So when creating the texture, you can assign the texture’s name to the label.
In TextureController.swift, add this to loadTexture(texture:name:)
and loadTexture(name:)
, before return
.
texture?.label = URL(string: name)?.lastPathComponent
The USDZ texture name is created when you the .usdz file is created, and is one long path. Unfortunately that leaves a ]
on the texture name. If that bothers you, you can do something like:
texture?.label = String((URL(string: name)?.lastPathComponent.dropLast())!)
Thanks! That did the trick. Now the textures are all identified.
I knew textures had a label (makeTextures() has such an argument), but I’m just not super familiar with all the ins and outs of all the structures (yet). And, I just wasn’t sure I was missing some special Xcode button that would do the identification for me.
Small correction - if the last character of the “name” is NOT ‘]’, your alternative actually cuts off the last letter of the texture (i.e., “grass” is “gras”). Oh well.
Yes. I guess it’s a matter of deciding what format your models and textures are coming in as and doing string manipulation as needed.