Multiplying the new RGB value with the alpha value should fix this.
#include <metal_stdlib>
using namespace metal;
[[stitchable]] half4 replaceColor(float2 pos, half4 oldColor, half4 newColor) {
return half4(half3(newColor.r, newColor.g, newColor.b) * oldColor.a, oldColor.a);
}
Multiplying the new RGB value with the alpha value should fix this.
#include <metal_stdlib>
using namespace metal;
[[stitchable]] half4 replaceColor(float2 pos, half4 oldColor, half4 newColor) {
return half4(half3(newColor.r, newColor.g, newColor.b) * oldColor.a, oldColor.a);
}