Hello All
I'd like to get following effect in my application (iOS/macOS):
- First I'd like to have Metal-rendered background image
- Second, (preferably) standard UI blur effect on top of that
- And finally, at the very top, again something drawn with Metal.
I guess I could achieve that effect mimicking UI blur effect and just drawing everything in Metal. On iOS, I could use Metal Performance Shaders (Gaussian blur) to achieve effect similar to UI blur. I am hovewer concerned about future OS versions (what if blur style changes?), about performance (doubt that my implementation, especially on macOS without performance shaders, will be as fast as iOS's), and so on.
I can think of another idea: stacking NSViews/UIViews as follows:
- First one would be my standad View using Metal to display itself (View A)
- Second would be UIVisualEffectView or whatever one uses to achieve "system" blur effect in OS (View B)
- And third one (View C) would be yet another VIew using Metal for rendering, using apropriate alpha blending to make underlying View A blurred through View B visible. Rendering in this view will be pretty lightweight. A bit of overlapping symbols, mostly just "see through".
Will it work? If so, do I understand correctly that Views A and C should perform separate rendering, each one getting drawable for himself and presenting it? Will it hit my performance hard? How can I prevent it?
Thanks in advance
Michal
Yes, if you stop drawing to an MTKView or CAMetalLayer, it will continue displaying the contents of the most recently-presented drawable.
You don't want to hold onto a drawable after the end of a frame for the sake of reusing its texture. Instead, you should render the scene into a separate offscreen texture (or blit from the drawable's texture to another texture) and use that texture for your accumulation buffer-style effects.