Add dark defaults, modular effect templates and canvas leveling
这个提交包含在:
1 父节点
ffabdca5b1
当前提交
5ca307414c
25 个文件已更改
+1702
-88
没有与搜索条件相匹配的文件
@@ -13,12 +13,27 @@
|
||||
id<MTLComputeCommandEncoder>encoder=[commands computeCommandEncoder];[encoder setComputePipelineState:entry[@"dyToolBlend"]];[encoder setTexture:before atIndex:0];[encoder setTexture:after atIndex:1];[encoder setTexture:output atIndex:2];[encoder setBuffer:masks offset:0 atIndex:0];[encoder setBytes:&h length:sizeof(h) atIndex:1];[encoder dispatchThreads:MTLSizeMake(output.width,output.height,1) threadsPerThreadgroup:MTLSizeMake(16,16,1)];[encoder endEncoding];
|
||||
}
|
||||
- (BOOL)copyTile:(FxImageTile*)source to:(FxImageTile*)dest entry:(NSMutableDictionary*)e error:(NSError**)error {
|
||||
return [self copyTile:source to:dest rotation:0 entry:e error:error];
|
||||
}
|
||||
- (BOOL)copyTile:(FxImageTile*)source to:(FxImageTile*)dest rotation:(double)angle entry:(NSMutableDictionary*)e error:(NSError**)error {
|
||||
id<MTLDevice>device=e[@"device"];id<MTLTexture>a=[source metalTextureForDevice:device],b=[dest metalTextureForDevice:device];
|
||||
NSMutableDictionary *pipelines=e[@"pipelines"];NSString *key=[NSString stringWithFormat:@"copy-%d-%lu",_managedFinishing,(unsigned long)b.pixelFormat];id<MTLRenderPipelineState>pipeline=pipelines[key];
|
||||
if(!pipeline){MTLRenderPipelineDescriptor *desc=[MTLRenderPipelineDescriptor new];desc.vertexFunction=[e[@"library"]newFunctionWithName:@"dyVertex"];desc.fragmentFunction=[e[@"library"]newFunctionWithName:_managedFinishing?@"dyManagedCopyFragment":@"dyToolCopyFragment"];desc.colorAttachments[0].pixelFormat=b.pixelFormat;pipeline=[device newRenderPipelineStateWithDescriptor:desc error:error];[desc.vertexFunction release];[desc.fragmentFunction release];[desc release];if(!pipeline)return NO;pipelines[key]=pipeline;[pipeline release];}
|
||||
if(!a||!b)return fail(error,@"宿主图像纹理不可用");
|
||||
BOOL useFloat=_managedFinishing||angle!=0;
|
||||
NSMutableDictionary *pipelines=e[@"pipelines"];NSString *key=[NSString stringWithFormat:@"copy-%d-%lu",useFloat,(unsigned long)b.pixelFormat];id<MTLRenderPipelineState>pipeline=pipelines[key];
|
||||
if(!pipeline){MTLRenderPipelineDescriptor *desc=[MTLRenderPipelineDescriptor new];desc.vertexFunction=[e[@"library"]newFunctionWithName:@"dyVertex"];desc.fragmentFunction=[e[@"library"]newFunctionWithName:useFloat?@"dyManagedCopyFragment":@"dyToolCopyFragment"];desc.colorAttachments[0].pixelFormat=b.pixelFormat;pipeline=[device newRenderPipelineStateWithDescriptor:desc error:error];[desc.vertexFunction release];[desc.fragmentFunction release];[desc release];if(!pipeline)return NO;pipelines[key]=pipeline;[pipeline release];}
|
||||
FxRect s=source.tilePixelBounds,t=dest.tilePixelBounds;float width=s.right-s.left,height=s.top-s.bottom,l=(t.left-s.left)/width,r=(t.right-s.left)/width,top=(s.top-t.top)/height,bottom=(s.top-t.bottom)/height;
|
||||
if(source.imageOrigin==kFxImageOrigin_BOTTOM_LEFT){top=1-top;bottom=1-bottom;}
|
||||
float w=b.width,h=b.height;DYVertex2D v[]={{{w/2,-h/2},{r,bottom}},{{-w/2,-h/2},{l,bottom}},{{w/2,h/2},{r,top}},{{-w/2,h/2},{l,top}}};if(dest.imageOrigin==kFxImageOrigin_BOTTOM_LEFT)for(auto &vertex:v)vertex.position.y=-vertex.position.y;
|
||||
float w=b.width,h=b.height;DYVertex2D v[]={{{w/2,-h/2},{r,bottom}},{{-w/2,-h/2},{l,bottom}},{{w/2,h/2},{r,top}},{{-w/2,h/2},{l,top}}};
|
||||
double pixelAspect=source.pixelAspect;
|
||||
if(!std::isfinite(pixelAspect)||pixelAspect<=0)pixelAspect=1;
|
||||
DYLevelTransform level(angle,width*pixelAspect/height);
|
||||
for(auto &vertex:v){
|
||||
if(angle){
|
||||
CGPoint uv=level.toSource(CGPointMake(vertex.textureCoordinate.x,vertex.textureCoordinate.y));
|
||||
vertex.textureCoordinate={(float)uv.x,(float)uv.y};
|
||||
}
|
||||
if(source.imageOrigin==kFxImageOrigin_BOTTOM_LEFT)vertex.textureCoordinate.y=1-vertex.textureCoordinate.y;
|
||||
if(dest.imageOrigin==kFxImageOrigin_BOTTOM_LEFT)vertex.position.y=-vertex.position.y;
|
||||
}
|
||||
vector_uint2 size={(unsigned)b.width,(unsigned)b.height};id<MTLCommandBuffer>cb=[e[@"queue"]commandBuffer];MTLRenderPassDescriptor *pass=[MTLRenderPassDescriptor renderPassDescriptor];pass.colorAttachments[0].texture=b;pass.colorAttachments[0].loadAction=MTLLoadActionDontCare;pass.colorAttachments[0].storeAction=MTLStoreActionStore;id<MTLRenderCommandEncoder>encoder=[cb renderCommandEncoderWithDescriptor:pass];[encoder setRenderPipelineState:pipeline];[encoder setVertexBytes:v length:sizeof(v) atIndex:0];[encoder setVertexBytes:&size length:sizeof(size) atIndex:1];[encoder setFragmentTexture:a atIndex:0];[encoder drawPrimitives:MTLPrimitiveTypeTriangleStrip vertexStart:0 vertexCount:4];[encoder endEncoding];[cb commit];[cb waitUntilCompleted];return cb.status==MTLCommandBufferStatusCompleted?YES:fail(error,cb.error.localizedDescription);
|
||||
}
|
||||
// Extra skin keeps the source reference used by the prior release. All other
|
||||
@@ -101,6 +116,7 @@
|
||||
});}}
|
||||
- (BOOL)exportLUT:(NSURL*)url uniforms:(DYUniforms)u paths:(NSDictionary*)paths spider:(NSData*)spider tools:(NSDictionary*)tools error:(NSError**)error {@synchronized(self){
|
||||
if(tools&&!DYValidToolDocument(tools))return fail(error,@"工具或蒙版数据损坏,未更改原工程");DYApplyRemovedBaseTools(&u,tools);paths=DYVisibleBaseToolPaths(paths,tools);if(DYBaseToolRemoved(tools,@"spider"))spider=nil;
|
||||
if([tools[@"levelRotation"]doubleValue]!=0)return fail(error,@"水平校正属于空间处理,请保存完整预设。");
|
||||
for(NSDictionary *mask in DYSharedMasks(tools))if(mask[@"stampSource"]&&[mask[@"enabled"]boolValue])return fail(error,@"仿制图章属于空间处理,请保存完整预设。");
|
||||
if((u.lensSectionEnabled>.5&&(u.lensStrength!=0||u.lensScale!=1))||(u.skinProtection.x>.5&&u.skinVisualize>.5))return fail(error,@"镜头修复与肤色区域显示无法保存到 Cube,请保存完整预设。");for(NSDictionary *node in tools[@"layers"]){DYUniforms layer=DYToolUniforms(node);if([node[@"type"]isEqual:@"lens"]&&!DYToolIsNeutral(node))return fail(error,@"镜头畸变属于空间处理,请保存完整预设。");}
|
||||
DYUniforms effective=u;if(![paths[@"input"]length]&&effective.inputProfile==0)effective.preLUTStrength=0;if(![paths[@"look0"]length])effective.postLUTStrength=0;for(int i=0;i<4;i++)if(![paths[[NSString stringWithFormat:@"look%d",i+1]]length])effective.extraPostLUTStrengths[i]=0;bypassNeutralTools(&effective);bypassIdleSkin(&effective);if(effective.skinFaceOnly>.5&&effective.skinProtection.x>.5&&effective.skinProtection.y>0)return fail(error,@"人脸限定肤色保护属于空间选区,Cube 无法保存。请保存完整预设,或关闭人脸限定后导出。");for(NSDictionary *node in tools[@"layers"]){DYUniforms layer=DYToolUniforms(node);if([node[@"type"]isEqual:@"skin"]&&layer.skinProtection.x>.5&&layer.skinProtection.y>0&&(layer.skinFaceOnly>.5||layer.skinVisualize>.5))return fail(error,@"新增肤色层含人脸空间选区,请保存完整预设。");}
|
||||
|
||||
在新工单中引用
屏蔽一个用户