Track both clone stamp regions and render their relative zoom
这个提交包含在:
1 父节点
78b4c5f962
当前提交
52a7422004
14 个文件已更改
+379
-30
没有与搜索条件相匹配的文件
+22
-6
@@ -364,15 +364,31 @@ kernel void dyCloneStamps(texture2d<float,access::read> input [[texture(0)]],
|
||||
float2 local=(uv-center)*float2(stamp.inverseRadiusX,stamp.inverseRadiusY);
|
||||
float radiusSquared=dot(local,local);
|
||||
if(radiusSquared>1)continue;
|
||||
// A single integer-pixel offset preserves scale, orientation and sample values.
|
||||
float2 offset=(float2(stamp.sourceX,stamp.sourceY)-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;
|
||||
float2 sampleCenter(stamp.sourceX,stamp.sourceY);
|
||||
float2 sampleScale(stamp.samplingScaleX,stamp.samplingScaleY);
|
||||
float4 sampled;
|
||||
if(all(abs(sampleScale-1.f)<.0001f)){
|
||||
// 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));
|
||||
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);
|
||||
float4 bottom=mix(input.read(uint2(lo.x,hi.y)),input.read(hi),blend.x);
|
||||
sampled=mix(top,bottom,blend.y);
|
||||
}
|
||||
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,input.read(uint2(source)),coverage*stamp.strength);
|
||||
color=mix(color,sampled,coverage*stamp.strength);
|
||||
}
|
||||
output.write(color,gid);
|
||||
}
|
||||
在新工单中引用
屏蔽一个用户