Mixing CIKernel with RealityKit Geometry Modifier - Error

Hi,

I have trouble mixing Core Image CIKernel with Surface Shader/Geometry Modifier in the same project. I am getting the following error in my surface shader when I compile with -fcikernel option.

RealityFoundation.CustomMaterialError.geometryModifierFunctionNotFound

To simulate the problem:

Compile Sample from Apple Altering RealityKit Rendering with Shader Functions https://developer.apple.com/documentation/realitykit/altering_realitykit_rendering_with_shader_functions

Set Metal Compiler - Build Options Other Metal Compiler Flags -fcikernel

Metal Linker - Build Options Other Metal Linker Flags -fcikernel

RealityView->SetupRobots

RealityFoundation.CustomMaterialError.geometryModifierFunctionNotFound

Any suggestions will be great. Thank you in advance.

Answered by Graphics and Games Engineer in 752307022

Hey, this is a known issue that we have yet to figure out (rdar://99394535). The workaround that has been used internally is to put the CIKernel shaders into a separate metallib and make sure that the geometry modifier is in a metallib that has not been compiled with the -fcikernel flag.

Hi, on first glimpse that looks to me like either you misspelled the function name of your geometry modifier or your metal file isn't being compiled. If you are using the default metal library make sure that you have your geometry modifier function available like so:

#include <metal_stdlib>
#include <RealityKit/RealityKit.h>
using namespace metal;

[[visible]] void nameOfYourGeometryModifier(realitykit::geometry_parameters params) {
    // … your shader
}
Accepted Answer

Hey, this is a known issue that we have yet to figure out (rdar://99394535). The workaround that has been used internally is to put the CIKernel shaders into a separate metallib and make sure that the geometry modifier is in a metallib that has not been compiled with the -fcikernel flag.

Mixing CIKernel with RealityKit Geometry Modifier - Error
 
 
Q