# Metal by Tutorials

**URL:** https://forums.kodeco.com/c/books/metal-by-tutorials/44.md?page=10

[Latest](https://forums.kodeco.com/latest.md) · [Categories](https://forums.kodeco.com/categories.md) · [Tags](https://forums.kodeco.com/tags.md)

**Page:** 11

---

## [Rebuilding a Triangle Acceleration Structure](https://forums.kodeco.com/t/rebuilding-a-triangle-acceleration-structure/92296)

<div class="topic-metadata">

**Author:** [@johnlobe](https://forums.kodeco.com/u/johnlobe)\
**Replies:** 3\
**Last updated:** [December 23, 2019, 10:05pm UTC](https://forums.kodeco.com/t/rebuilding-a-triangle-acceleration-structure/92296 "2019-12-23T22:05:28Z")

</div>

Hi - I continue to enjoy learning from Metal by Tutorials with the 2nd Edition! I have begun to adapt the Ray Tracing Project ( Chapter 21 ) to handle vertex connecting & merging which has opened up a bunch of new ideas…

---

## [Chap 2: Import to Blender](https://forums.kodeco.com/t/chap-2-import-to-blender/92003)

<div class="topic-metadata">

**Author:** [@tchelyzt](https://forums.kodeco.com/u/tchelyzt)\
**Replies:** 3\
**Last updated:** [December 19, 2019, 9:20pm UTC](https://forums.kodeco.com/t/chap-2-import-to-blender/92003 "2019-12-19T21:20:44Z")

</div>

I tried to confirm my understanding by importing your plane into Blender. Set up plane.obj as follows: # Apple ModelIO OBJ File: plane mtllib plane.mtl g submesh v 0 0.5 -0.5 v 0 -0.5 -0.5 v 0 -0.5 0.5 v 0 0.5 0.5 vn -…

---

## [Ch11: Normals for the surface](https://forums.kodeco.com/t/ch11-normals-for-the-surface/70125)

<div class="topic-metadata">

**Author:** [@mjeragh](https://forums.kodeco.com/u/mjeragh)\
**Replies:** 3\
**Last updated:** [November 20, 2019, 7:49am UTC](https://forums.kodeco.com/t/ch11-normals-for-the-surface/70125 "2019-11-20T07:49:47Z")

</div>

Im trying to integrate the tessellation code into the game engine of Ch9. For the lights I need to compute the normal vectors, I found an article (Smooth normals and Tessellation - Graphics and GPU Programming - GameDev.…

---

## [Index problems in some projects](https://forums.kodeco.com/t/index-problems-in-some-projects/86350)

<div class="topic-metadata">

**Author:** [@knight556](https://forums.kodeco.com/u/knight556)\
**Replies:** 9\
**Last updated:** [November 13, 2019, 5:09am UTC](https://forums.kodeco.com/t/index-problems-in-some-projects/86350 "2019-11-13T05:09:55Z")

</div>

Hi guys, any idea why some of the projects are having these issues? (see images). I did a frame capture and it seems that one of the triangle indices is a crazy huge number. Possibly a problem loading the obj file? T…

---

## [Textbox, label, selectbox on metal 3d](https://forums.kodeco.com/t/textbox-label-selectbox-on-metal-3d/86435)

<div class="topic-metadata">

**Author:** [@levanlong](https://forums.kodeco.com/u/levanlong)\
**Replies:** 1\
**Last updated:** [October 29, 2019, 2:28am UTC](https://forums.kodeco.com/t/textbox-label-selectbox-on-metal-3d/86435 "2019-10-29T02:28:41Z")

</div>

Hi, I don’t find anywhere even on metal by tutorial how to manage textbox or label to add them on 3d metal ? is there any existing lib or we must create them ? or maybe we can used 2d from swift to incoporated them on s…

---

## [Question about setScissorRect](https://forums.kodeco.com/t/question-about-setscissorrect/82965)

<div class="topic-metadata">

**Author:** [@markusm](https://forums.kodeco.com/u/markusm)\
**Replies:** 2\
**Last updated:** [September 26, 2019, 4:44am UTC](https://forums.kodeco.com/t/question-about-setscissorrect/82965 "2019-09-26T04:44:56Z")

</div>

Hi, I have a question about setScissorRect. When it is applied will it prevent computation of pixels outside of this rectangle or does it just clip the output when everything is computed ? In other words, can it be use…

---

## [Generated model and lighting (Chapter 5)](https://forums.kodeco.com/t/generated-model-and-lighting-chapter-5/81627)

<div class="topic-metadata">

**Author:** [@asalian](https://forums.kodeco.com/u/asalian)\
**Replies:** 5\
**Last updated:** [September 13, 2019, 5:10am UTC](https://forums.kodeco.com/t/generated-model-and-lighting-chapter-5/81627 "2019-09-13T05:10:23Z")

</div>

Hi everyone, I have been generating a simple model using my own vertex data (4 vertices and 2 triangles, 6 indices to describe a sheet) and then I have introduced a light source based on material from chapter 5. However…

---

## [Texture2d\_array or array of texture2d](https://forums.kodeco.com/t/texture2d-array-or-array-of-texture2d/81426)

<div class="topic-metadata">

**Author:** [@octavo](https://forums.kodeco.com/u/octavo)\
**Replies:** 2\
**Last updated:** [September 11, 2019, 2:50am UTC](https://forums.kodeco.com/t/texture2d-array-or-array-of-texture2d/81426 "2019-09-11T02:50:49Z")

</div>

Anyone know the difference between those two? I try to use array\<texture2d, 10\> in shader, but I don’t know how to pass an array of textures to shader in swift. texture2d\_array can be passed as single MTLTexture, but I…

---

## [The upperbound of the textures in Metal](https://forums.kodeco.com/t/the-upperbound-of-the-textures-in-metal/61105)

<div class="topic-metadata">

**Author:** [@monkyu](https://forums.kodeco.com/u/monkyu)\
**Replies:** 13\
**Last updated:** [September 3, 2019, 10:00am UTC](https://forums.kodeco.com/t/the-upperbound-of-the-textures-in-metal/61105 "2019-09-03T10:00:48Z")

</div>

Anyone know the upperbound of the textures in Metal Refer to : setFragmentTextures:withRange: Recently, I want to render lots of subtitles use the kernel function, steps as below: turn the each subtitle to texture? s…

---

## [Chapter 16 and 9 - Particles with scene-graph](https://forums.kodeco.com/t/chapter-16-and-9-particles-with-scene-graph/80004)

<div class="topic-metadata">

**Author:** [@jplozach](https://forums.kodeco.com/u/jplozach)\
**Replies:** 4\
**Last updated:** [August 30, 2019, 11:47pm UTC](https://forums.kodeco.com/t/chapter-16-and-9-particles-with-scene-graph/80004 "2019-08-30T23:47:17Z")

</div>

Hello, I have mixed chapter 16 and 9 to have a 3D scene with particles. The app runs with no error message, but on the screen l see only the particles (very nice :wink:). The renderParticlesEncoder is the last in the …

---

## [Best data layout in threadgroup memory](https://forums.kodeco.com/t/best-data-layout-in-threadgroup-memory/79663)

<div class="topic-metadata">

**Author:** [@octavo](https://forums.kodeco.com/u/octavo)\
**Replies:** 6\
**Last updated:** [August 26, 2019, 12:10am UTC](https://forums.kodeco.com/t/best-data-layout-in-threadgroup-memory/79663 "2019-08-26T00:10:54Z")

</div>

Is threadgroup memory in Metal similar to shared memory in CUDA? Is there a similar bank conflicts issue in Metal? I try to optimize the memory access in threadgroup memory. Thanks

---

## [Chapter 16 - particles pipelineState pixelFormat](https://forums.kodeco.com/t/chapter-16-particles-pipelinestate-pixelformat/79958)

<div class="topic-metadata">

**Author:** [@jplozach](https://forums.kodeco.com/u/jplozach)\
**Replies:** 2\
**Last updated:** [August 25, 2019, 1:17am UTC](https://forums.kodeco.com/t/chapter-16-particles-pipelinestate-pixelformat/79958 "2019-08-25T01:17:30Z")

</div>

Hello, I try to have particles as fire of chapter 16 in a 3D scene as the one of the chapter 9. So I have 3 pipelineState : rendererPipelineState for the 3D scene, particulePipelineState to compute the particles, pa…

---

## [Ch 4 - DebugLights](https://forums.kodeco.com/t/ch-4-debuglights/52907)

<div class="topic-metadata">

**Author:** [@12o1v](https://forums.kodeco.com/u/12o1v)\
**Replies:** 13\
**Last updated:** [August 24, 2019, 7:50am UTC](https://forums.kodeco.com/t/ch-4-debuglights/52907 "2019-08-24T07:50:18Z")

</div>

PDF Page 133 suggests using DebugLights.swift : “debugLights(renderEncoder: renderEncoder, lightType: Sunlight)” This didn’t work for me, and not knowing why, I spent time making sure I had followed the instructions. Wh…

---

## [Integrating with SceneKit](https://forums.kodeco.com/t/integrating-with-scenekit/52691)

<div class="topic-metadata">

**Author:** [@wolfmanfx](https://forums.kodeco.com/u/wolfmanfx)\
**Replies:** 5\
**Last updated:** [July 5, 2019, 4:33am UTC](https://forums.kodeco.com/t/integrating-with-scenekit/52691 "2019-07-05T04:33:36Z")

</div>

Hi, I am integrating SceneKit with Metalkit. My main motivation is to use some low level features from Metal like viewports and using the Scenegraph from Scenekit. I needed a 4port Cad view and created a sample but its…

---

## [Chapter 2: Importing primitive.obj into Blender fails](https://forums.kodeco.com/t/chapter-2-importing-primitive-obj-into-blender-fails/74914)

<div class="topic-metadata">

**Author:** [@jbrewer](https://forums.kodeco.com/u/jbrewer)\
**Replies:** 5\
**Last updated:** [June 28, 2019, 12:48am UTC](https://forums.kodeco.com/t/chapter-2-importing-primitive-obj-into-blender-fails/74914 "2019-06-28T00:48:37Z")

</div>

When I try to import the cone into Blender (freshly downloaded 2.79b). I get an “IndexError: list index out of range” message, and the import fails. Any idea what’s wrong?

---

## [Bvec3 in Metal?](https://forums.kodeco.com/t/bvec3-in-metal/74431)

<div class="topic-metadata">

**Author:** [@markusm](https://forums.kodeco.com/u/markusm)\
**Replies:** 1\
**Last updated:** [June 21, 2019, 12:44am UTC](https://forums.kodeco.com/t/bvec3-in-metal/74431 "2019-06-21T00:44:45Z")

</div>

Hi, I am trying to port this shader to Metal: Shader - Shadertoy BETA I am having problems with this part: // winding number from http://geomalgorithms.com/a03-\_inclusion.html bvec3 cond = bvec3( p.y\>=v\[i\].y, …

---

## [Chapter 1 playground not rendering](https://forums.kodeco.com/t/chapter-1-playground-not-rendering/73924)

<div class="topic-metadata">

**Author:** [@supercatilac](https://forums.kodeco.com/u/supercatilac)\
**Replies:** 1\
**Last updated:** [June 15, 2019, 3:52am UTC](https://forums.kodeco.com/t/chapter-1-playground-not-rendering/73924 "2019-06-15T03:52:10Z")

</div>

Hi, I am running my code in Version 10.2.1 (10E1001). I believe I’ve copied it all down correctly, but nothing is showing up when the playground runs. I’ve restarted xcode and it still doesn’t work. Moreover, when I ru…

---

## [Ch 14 Deferred Rendering code very slow on iOS](https://forums.kodeco.com/t/ch-14-deferred-rendering-code-very-slow-on-ios/71154)

<div class="topic-metadata">

**Author:** [@orle](https://forums.kodeco.com/u/orle)\
**Replies:** 5\
**Last updated:** [May 17, 2019, 1:47pm UTC](https://forums.kodeco.com/t/ch-14-deferred-rendering-code-very-slow-on-ios/71154 "2019-05-17T13:47:49Z")

</div>

Hi, first of all: excellent book, I’m enjoying every bit of it. I’ve made it to the Multipass & Deferred Rendering chapter, followed the tutorial and managed to get the final code up and running without issues on a Mac.…

---

## [Cooperative Compute Shader](https://forums.kodeco.com/t/cooperative-compute-shader/69189)

<div class="topic-metadata">

**Author:** [@markusm](https://forums.kodeco.com/u/markusm)\
**Replies:** 14\
**Last updated:** [May 3, 2019, 3:41am UTC](https://forums.kodeco.com/t/cooperative-compute-shader/69189 "2019-05-03T03:41:48Z")

</div>

Hi I am searching for an example how to create a compute shaders so that the results of each thread group can be analyzed and compared after execution. I am unsure how to set this up. In my use case I need to iterate o…

---

## [Minor bug in PBR Workflow example code](https://forums.kodeco.com/t/minor-bug-in-pbr-workflow-example-code/53622)

<div class="topic-metadata">

**Author:** [@cocheret](https://forums.kodeco.com/u/cocheret)\
**Replies:** 2\
**Last updated:** [April 23, 2019, 1:40pm UTC](https://forums.kodeco.com/t/minor-bug-in-pbr-workflow-example-code/53622 "2019-04-23T13:40:45Z")

</div>

You have… if let roughness = material?.property(with: .roughness), roughness.type == .float3 { self.roughness = roughness.floatValue } I believe that should be roughness.type == .float which wouldn’t be an issu…

---

## [Chapter 5, color calculations](https://forums.kodeco.com/t/chapter-5-color-calculations/68274)

<div class="topic-metadata">

**Author:** [@carlos](https://forums.kodeco.com/u/carlos)\
**Replies:** 2\
**Last updated:** [April 22, 2019, 2:26pm UTC](https://forums.kodeco.com/t/chapter-5-color-calculations/68274 "2019-04-22T14:26:16Z")

</div>

I noticed that on the calculation for the point light, the color of the light was red (0,0,1) and the base color is blue (1, 0, 0) and thus when we were having the calculation of color we have color = lightColor\*baseColo…

---

## [Wish list for book additions ;-)](https://forums.kodeco.com/t/wish-list-for-book-additions/57129)

<div class="topic-metadata">

**Author:** [@cocheret](https://forums.kodeco.com/u/cocheret)\
**Replies:** 4\
**Last updated:** [March 26, 2019, 3:42pm UTC](https://forums.kodeco.com/t/wish-list-for-book-additions/57129 "2019-03-26T15:42:05Z")

</div>

Finished the book a few days ago. Thanks for the great start with Metal. I was wondering if you plan new content for later versions. If so, here’s my wishlist. :wink: Argument Buffers Indirect Command Buffers (CPU and…

---

## [Metal color blend and renderCommandEncoder](https://forums.kodeco.com/t/metal-color-blend-and-rendercommandencoder/66852)

<div class="topic-metadata">

**Author:** [@monkyu](https://forums.kodeco.com/u/monkyu)\
**Replies:** 3\
**Last updated:** [April 14, 2019, 10:36am UTC](https://forums.kodeco.com/t/metal-color-blend-and-rendercommandencoder/66852 "2019-04-14T10:36:59Z")

</div>

Hi, I was confused by the blend function and renderCommandEncoder I have a MTKView and passDescriptor.colorAttachments\[0\].clearColor = MTLClearColorMake(1, 1, 1, 0.0); I have render a texture on it and texture colo…

---

## [Chapter 21: hit test with MPSRayIntersector](https://forums.kodeco.com/t/chapter-21-hit-test-with-mpsrayintersector/66083)

<div class="topic-metadata">

**Author:** [@mjeragh](https://forums.kodeco.com/u/mjeragh)\
**Replies:** 1\
**Last updated:** [March 31, 2019, 4:37pm UTC](https://forums.kodeco.com/t/chapter-21-hit-test-with-mpsrayintersector/66083 "2019-03-31T16:37:44Z")

</div>

Is it possible to use the MPSRayIntersector with touchesBegan and get the first interact object to pan? I have been trying to do it myself but with no luck for sometime https://stackoverflow.com/questions/55435228/how-…

---

## [Chapter 14: Spotlight Shadow Map](https://forums.kodeco.com/t/chapter-14-spotlight-shadow-map/60775)

<div class="topic-metadata">

**Author:** [@smehsu](https://forums.kodeco.com/u/smehsu)\
**Replies:** 5\
**Last updated:** [March 16, 2019, 3:57pm UTC](https://forums.kodeco.com/t/chapter-14-spotlight-shadow-map/60775 "2019-03-16T15:57:20Z")

</div>

Hi, I’m really enjoying the book! In chapter 14 (pg. 392/ 393) we create a shadow map using an ortho projection matrix. In the description, the book mentions " If instead you used a spotlight, for example, you would use…

---

## [Chapter 9 - parent relation with camera](https://forums.kodeco.com/t/chapter-9-parent-relation-with-camera/63921)

<div class="topic-metadata">

**Author:** [@jplozach](https://forums.kodeco.com/u/jplozach)\
**Replies:** 5\
**Last updated:** [March 8, 2019, 4:03am UTC](https://forums.kodeco.com/t/chapter-9-parent-relation-with-camera/63921 "2019-03-08T04:03:54Z")

</div>

Hello ! sorry for my English, but I am French… Thank you for your wonderful book ! I have a little problem with the parent relation with the camera : I develop a space navigation simulation with metal and I use the fi…

---

## [Made it to the end of the book](https://forums.kodeco.com/t/made-it-to-the-end-of-the-book/63838)

<div class="topic-metadata">

**Author:** [@mjeragh](https://forums.kodeco.com/u/mjeragh)\
**Replies:** 1\
**Last updated:** [March 6, 2019, 7:25pm UTC](https://forums.kodeco.com/t/made-it-to-the-end-of-the-book/63838 "2019-03-06T19:25:44Z")

</div>

Thank you very much for this book. It is one of the most enjoyable tutorial book I have worked through until the end. Hopefully there will be a second edition :slight\_smile: which includes a small game, some Neural Netw…

---

## [Chapter 14 deferred rendering with skybox](https://forums.kodeco.com/t/chapter-14-deferred-rendering-with-skybox/62668)

<div class="topic-metadata">

**Author:** [@henrygorner](https://forums.kodeco.com/u/henrygorner)\
**Replies:** 4\
**Last updated:** [February 22, 2019, 12:03am UTC](https://forums.kodeco.com/t/chapter-14-deferred-rendering-with-skybox/62668 "2019-02-22T00:03:31Z")

</div>

hi, I went through all the chapters in section 1. With the section 2 I am skipping as I feel. So far I did the Instancing and just finished the multipass and deferred rendering. Instead of using the starting projects I …

---

## [Chapter 7 parallax mapping texture](https://forums.kodeco.com/t/chapter-7-parallax-mapping-texture/62540)

<div class="topic-metadata">

**Author:** [@henrygorner](https://forums.kodeco.com/u/henrygorner)\
**Replies:** 2\
**Last updated:** [February 20, 2019, 12:19pm UTC](https://forums.kodeco.com/t/chapter-7-parallax-mapping-texture/62540 "2019-02-20T12:19:58Z")

</div>

Hi, After finishing the chapter 7 normal mapping, I would like to do on my own a parallax mapping with the cube object provided. For that I understand I need a displacement texture. Looking into that project there is on…

---

## [Chapter 17: improving performance of Flocking](https://forums.kodeco.com/t/chapter-17-improving-performance-of-flocking/61567)

<div class="topic-metadata">

**Author:** [@mjeragh](https://forums.kodeco.com/u/mjeragh)\
**Replies:** 1\
**Last updated:** [February 6, 2019, 6:34pm UTC](https://forums.kodeco.com/t/chapter-17-improving-performance-of-flocking/61567 "2019-02-06T18:34:04Z")

</div>

To improve the performance I wanted to combine the three loops cohesion\_separation\_alignment into a single loop, I have written this function: device float2 \* cohesion\_separation\_alignment(uint index, device Boid\* b…

[Previous page](https://forums.kodeco.com/c/books/metal-by-tutorials/44.md?page=9)

[Next page](https://forums.kodeco.com/c/books/metal-by-tutorials/44.md?page=11)
