Stabilize clone stamp tracks and sample fractional motion continuously

这个提交包含在:
mac 于 2026-11-06 01:30:28 +08:00 提交
1 父节点 89eeaa9ba1
当前提交 7b6a3106ca
7 个文件已更改
+100 -15

没有与搜索条件相匹配的文件

+12 -8
查看文件
@@ -367,18 +367,22 @@ kernel void dyCloneStamps(texture2d<float,access::read> input [[texture(0)]],
float2 sampleCenter(stamp.sourceX,stamp.sourceY);
float2 sampleScale(stamp.samplingScaleX,stamp.samplingScaleY);
float4 sampled;
if(all(abs(sampleScale-1.f)<.0001f)){
float sourceCoverage=1;
float2 offset=(sampleCenter-center+(uv-center)*(sampleScale-1))*float2(size);
if(flip)offset.y=-offset.y;
if(!stamp.subpixel){
// Preserve pixel values for stamps with translation alone.
float2 offset=(sampleCenter-center)*float2(size);
if(flip)offset.y=-offset.y;
int2 source=int2(gid)+int2(round(offset));
if(any(source<0)||any(source>=int2(size)))continue;
sampled=input.read(uint2(source));
}else{
float2 source=sampleCenter+(uv-center)*sampleScale;
if(flip)source.y=1-source.y;
if(any(source<0)||any(source>=1))continue;
float2 pixel=clamp(source*float2(size)-.5f,0.f,float2(size-1));
// Follow fractional motion through unit zoom and fade the sample
// across the last pixel instead of dropping it at the image edge.
float2 source=float2(gid)+offset;
float2 edge=min(source+1,float2(size)-source);
sourceCoverage=saturate(min(edge.x,edge.y));
if(sourceCoverage<=0)continue;
float2 pixel=clamp(source,0.f,float2(size-1));
uint2 lo=uint2(floor(pixel)),hi=min(lo+1,size-1);
float2 blend=fract(pixel);
float4 top=mix(input.read(lo),input.read(uint2(hi.x,lo.y)),blend.x);
@@ -388,7 +392,7 @@ kernel void dyCloneStamps(texture2d<float,access::read> input [[texture(0)]],
float coverage=stamp.feather>0?1-smoothstep(1-stamp.feather,1.f,sqrt(radiusSquared)):1;
coverage=saturate((coverage-stamp.inputBlack)/(stamp.inputWhite-stamp.inputBlack));
if(stamp.inputGamma!=1)coverage=pow(coverage,1/stamp.inputGamma);
color=mix(color,sampled,coverage*stamp.strength);
color=mix(color,sampled,coverage*stamp.strength*sourceCoverage);
}
output.write(color,gid);
}