我正在尝试使用 MetalKit
newTextureWithContentsOfURL
为牛创建纹理。
MTKTextureLoader *texture_loader = [[MTKTextureLoader alloc] initWithDevice:device];
NSURL *cow_image = [[NSBundle mainBundle] URLForResource:@"spot_texture" withExtension:@"png"];
NSError *error;
diffuse_texture = [texture_loader newTextureWithContentsOfURL:cow_image options:nil error:&error];
这是样本牛(上)和我的牛(下)的样子。
我不知道这是什么原因,但我认为这些选项可能会有所帮助。
How to set this option using
NSDictionary
?
MTKTextureLoader *texture_loader = [[MTKTextureLoader alloc] initWithDevice:device];
NSURL *cow_image = [[NSBundle mainBundle] URLForResource:@"spot_texture"
withExtension:@"png"];
NSError *error;
diffuse_texture = [texture_loader newTextureWithContentsOfURL:cow_image options:@{ MTKTextureLoaderOptionSRGB : @true, MTKTextureLoaderOptionOrigin : @true}
error:&error];