Use two shaders in Metal

Difficult to use Bullet(C++) from Swift / iPhone App Development Memo
↑ I gave up to make a new app with Swift, so I have been using Objective-C and Metal.

For example, this is drawn by Phong shader in Objective-C and Metal :

And ‘particle’ is used in this :

I tried to show the robot and snow at the same time, and I need much time to implement it. Because two shaders (for robot’s Phong shader and shader for particle) are needed.

Two shaders are off course different, so you have to make MTLRenderPipelineDescriptor objects for each shader.

Therefore you need two MTLRenderPipelineState objects which are made from each MTLRenderPipelineDescriptor object. But code don’t need two MTLRenderPassDescriptor objects. You only need only one. At first I made two objects and the view was not appeared as I expected.

Finally, this is a robot and snow:

The best APPLE sample code for multiple shaders is ‘MetalDeferredLighting’
Develop | Comments(0) | Trackback(0)