How to create a Metal shader with layerEffect in SwiftUI

I'm trying to use the new layerEffect(_:maxSampleOffset:isEnabled:). https://developer.apple.com/documentation/swiftui/view/layereffect(_:maxsampleoffset:isenabled:)

Tho I'm not sure how to define the metal shader function signature. The docs indicate that we should use SwiftUI::Layer, tho I'm not sure what to import to get access to this layer structure.

[[ stitchable ]] half4 name(float2 position, SwiftUI::Layer layer, args...)

My goal is to create a custom blur effect.

Does anyone have any pointer on how to get started with layer effects?

Answered by KhaosT in 755475022

You need to include #include <SwiftUI/SwiftUI.h> for the layer definition.

Accepted Answer

You need to include #include <SwiftUI/SwiftUI.h> for the layer definition.

How to create a Metal shader with layerEffect in SwiftUI
 
 
Q