我在 Core Image Kernel Language 中有以下函数,我需要在 Metal Shading Language 中等效的东西,但是我对 destCoord 、 unpremultiply 和 premultiply 函数有问题。
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);
}
Run Code Online (Sandbox Code Playgroud)
到目前为止,我在 MSL 中的功能是:
float4 MyFunc(sample_t image, float3 color, float dist, float slope) {
float4 t;
float d;
d = color[1] * slope + dist
...
return t;
} …
Run Code Online (Sandbox Code Playgroud)