I have the following function in Core Image Kernel Language and I need something equivalent in Metal Shading Language, but I have problem with destCoord , unpremultiply and premultiply functions.
kernel vec4 MyFunc(sampler src, __color color, float distance, float slope) {
vec4 t;
float d;
d = destCoord().y * slope + distance;
t = unpremultiply(sample(src, samplerCoord(src)));
t = (t - d*color) / (1.0-d);
return premultiply(t);
}
My function in MSL so far is:
float4 MyFunc(sample_t image, float3 color, float dist, float slope) {
float4 t;
float d;
d = color[1] * slope + dist
...
return t;
}
Any help would be appreciated!