Hi,
I loaded the Ch14 starter project (had downloaded met-materials-editions-4.0 on 2024.08.11) into Xcode (Version 16.0 (16A242d)) and I got a different view from that in the tutorial (see Image-1). I hit the “Forward” button, and got the same image as in the tutorial (see Image-2). However, hitting the “Deferred” button, I almost got the “right” image (see Image-3) as the tutorial, except this looked exactly like the “Forward” image (aka Image-2). I’m not sure I did anything wrong (I didn’t modify any of the sources), but was a bit concerned since stuff didn’t look right in 2 out of the 3 images. I’ll continue to toddle along with the chapter, hoping that this won’t really effect the tutorial, but I was just concerned. I did try and do some poking around, but still not sure why the first image is all magenta, nor why the 3rd image looks like the 2nd image.
I found the problem.
In my set of sources, there’s a bug in Game/Renderer.swift in draw(scene:in:).
Current code says:
if options.renderChoice == .deferred {
gBufferRenderPass.shadowTexture = shadowRenderPass.shadowTexture
gBufferRenderPass.draw(
commandBuffer: commandBuffer,
scene: scene,
uniforms: uniforms,
params: params)
} else {
But, in the tutorial, the text says to remove:
gBufferRenderPass.descriptor = descriptor
(see image-4)
But this assignment isn’t there. I put this in the ‘starter’ sources, rebuild and ran the app and things were now in sync.
I thought this might have been the problem, but in my fat-fingered way, I was doing something wrong and it didn’t work out until I looked a lot harder (and started going throught the chapter).
Just more erratta for the 5th edition.
I’m a bit confused. Are these images from the starter project?
I just downloaded the code from: GitHub - kodecocodes/met-materials: The projects and the materials that accompany the Metal by Tutorials book.
I opened chapter 14 starter and switched the destination to My Mac. I changed uint
to uint32_t
in Common.h so that it compiles.
I then ran the project, and the results were as per the book. And in Renderer.swift I found this code:
if options.renderChoice == .deferred {
gBufferRenderPass.shadowTexture = shadowRenderPass.shadowTexture
gBufferRenderPass.descriptor = descriptor
which includes gBufferRenderPass.descriptor = descriptor
.
I am using Xcode 16.1 beta, but that wouldn’t make a difference here.
Caroline,
IYeah, had to do the ‘uint’ re-typedef as well).
Hmph. Ok, if you see it ok, then forget me.
I looked again at my snapshot I got from github and that line isn’t there.
Checked the file as well for any file modification (i.e., date, etc.) info - nope (says Created/Modified Tuesday, December 12, 2023 at 6:52 AM). I dunno. Maybe I hit a key while perusing the sources, but there’s no real evidence of that (surrounding lines out of ident sync, etc.).
Oh well. Just kindly chalk it up to yet another probable fat-fingered episode.
Thanks for your response.
You might want to redownload the sample code.
This is the actual file on Github: met-materials/14-deferred-rendering/projects/starter/Deferred/Deferred/Game/Renderer.swift at editions/4.0 · kodecocodes/met-materials · GitHub