3D Graphics with Metal · Conclusion | raywenderlich.com

This is a companion discussion topic for the original entry at https://www.raywenderlich.com/1258241-3d-graphics-with-metal/lessons/24
1 Like

One I have rendered a model, and I can move the camera around to view it from all angles. How can I set the opacity of the 3d object in the fragment function?

When I set the 4th element in the float4 that is color to 0.75, it is still completely non-transparent :confused:

That’s a more advanced feature. You have to tell the GPU that it will have to do blending, and you do this via the pipeline state.

Take a look at this answer that uses blending:


With respect to rendering, can we expect Metal to be faster than Scenekit? Or is that part of SceneKit already written in Metal and therefore have the same performance?

If the rendering performance is different, could you give your best guess at a % difference? I know that may be hard, but your best guess would be great to give me an idea.

I haven’t done any comparison. I would expect that SceneKit is highly efficient at what it does. I would also expect that if the programmer is a novice in both Metal and SceneKit, then SceneKit would give better results much more quickly.
However Metal gives you more control. SceneKit has a fair amount of complexity in various areas. If you don’t need that particular complexity, then you don’t have to include it in a Metal app. With SceneKit, you’re running on SceneKit’s schedule. If you need to schedule events in a different way, then Metal would allow you to do that.
SceneKit doesn’t do compute, so if you need to do any GPU non-rendering work, you’d have to use Metal with it.
You can use Metal shaders with SceneKit if you need custom rendering.

1 Like

Ok, then would I be correct to approach making AR apps by using SceneKit to handle the heavy lifting and tedious work related to importing animated models (eg .dae), and then to integrate custom Metal shaders to handle the custom rendering?


  1. Would the above approach to making AR apps be the best way to go in your opinion?
  2. How might I go about learning how to render 3d models with animations? Perhaps you have some yet-to-release tutorial videos you’d like me to try out? :stuck_out_tongue_winking_eye:

If you don’t have a lot of experience at putting together 3d scenes/games, then SceneKit would be a good place to start. Especially as Apple have done a great job at integrating it with ARKit. PBR rendering is mostly built in, rather than having to do complex shading calculations. Then drop down to Metal if you find that certain procedures need better performance.
'Fraid I don’t have any 3d animation videos in the pipeline :slight_smile: - Metal by Tutorials has a chapter on animation, where you start with a bouncing ball and move on to a skeleton character with a skeleton rig. The current version uses glTF, but the upcoming new version replaces that with usdz instead.
usdz appears to be Apple’s preferred format now. SceneKit can import animated daes, and Model I/O can import usdz.
For understanding 3d animation, there is a great video series by Thinmatrix: https://www.youtube.com/playlist?list=PLRIWtICgwaX2tKWCxdeB7Wv_rTET9JtWW - it’s OpenGL, but the concepts are the same. All his other videos are great for understanding concepts too.


OK! I’ll take a look at learning to overlay custom shader extensions to SceneKit’s ready made shaders through SCNShadable, and try hacking in some custom rendering modifications! I will check out that OpenGL video too, I am looking to enter that space after iOS so it sounds like a good intro for me into OpenGl as well. Thx!

ps: To anyone who also didn’t know what PBR was check out this video: https://www.youtube.com/watch?v=GVNnfZG4riw

1 Like

Lol. Sorry - we get so used to using these acronyms.