In the simple lighting example (Ch. 5), I created a couple of parametric meshes and added them to the models for display. However, they have the wrong orientation relative to the Blender models – the y direction points sideways. I know that Blender and Metal coordinate systems are different, but is there a place in the code where you are implicity rotating coordinates to transform coordinates from Blender orientation to left-hand orientation? Thanks!
I am using the models provided with the supporting materials for the book (treefir, train). When I render them, they have the y normals pointing up, as I expect. But when I create and display (using the shaders from Ch. 5) a new MDLMesh using boxWithExtent, the resulting box object has its y normals pointing in the z direction.
Thanks again for your help! This is the coolest book I have read in a long time.
Here’s my modification of the final version of the Chapter 5 project. I’m using a fragment shader that colors upward-pointing normals blue and downward-pointing normals red. The y normals for the sphere point sideways! Thanks again!
If you place a breakpoint on line 53 in Model.swift, that’s meshes = [mesh], then do po mdlMesh.vertexDescriptor in the console, you’ll get this:
However, when you read in the Blender models, you’re using an entirely different vertex descriptor layout from MDLVertexDescriptor.defaultVertexDescriptor
You’ll need to match your vertex descriptors or use a different pipeline state.
If you change the way you read in the Blender models, ie change the defaultVertexDescriptor to match the sphere’s vertex descriptor, then it will work.
Thank you so much! This is subtle. MDLMesh must use a default vertex descriptor, but I can’t find anything in Apple’s documentation describing it :-/
I like your idea of using a different a different pipeline state–more elegant.