Apply SceneKit shader modifier on multiple nodes

Viewed 513

The question: Is there a way to apply Shader Modifiers not just to a specific SCNMaterial or SCNGeometry (as these are the only classes adopting SCNShadable protocol) but to a set of SCNNodes, for example to all child nodes of a selected one?

Problem I am trying to resolve: I have shader code, which clips (discards fragments) geometry by calculations over uniform parameters. In fact it can clip model by axis coordinates or random "box" volumes passed as uniform.

I didn't find any information about clipping model in SceneKit so I decided to stick with shaders. Applying Shader Modifier to every node seems incorrect. However it did work on simulator but it doesn't work on a real device, since it exceeds resource limit. I also tried SCNTechnique but what I've found looks like it is suited for post-processing rather than handling fragments rendering.

Applying Shader Modifier to scene's rootNode would be a way to go IMHO, but I am not sure if it is even possible. Did I miss something about using shaders in SceneKit? Or there are better ways to perform parametric geometry clipping?

0 Answers
Related