Hello I've been struggling to get the sampler function working with custom Color Kernels. Below is what I've tried:
extern "C" { namespace coreimage {float4 myColor3(sampler inputImage3, float firstpass) { float4 color = inputImage3.sample(inputImage3.coord()); if (firstpass == 1){ color.y = 1; } return color; }
I get the following error message, where I load function from fromMetalLibraryData:Fatal error: 'try!' expression unexpectedly raised an error: Foundation._GenericObjCError.nilError: file /Users/... line 163
Writing the kernel using sample_t works fine (no such error)... but I'm writing a filter that needs the coordinates of the current pixel (not yet implemented, just trying to get the kernel to run at all).
So my main question is why isn't sampler behaving like sample_t?
float4 myColor3(sample_t inputImage3, float firstpass) { if (firstpass == 1){ inputImage3.b = 1; } return inputImage3; }
This is how I have the CIFilter set up:
override var outputImage: CIImage? { guard let inputImage3 = inputImage3, let firstpass = firstpass else { return nil } return self.kernel3.apply(extent: inputImage3.extent, roiCallback: { _, rect -> CGRect in return CGRect(x: rect.minX, y: rect.minY, width: rect.width, height: rect.height) }, arguments: [inputImage3, firstpass])