I am trying to use MetalKit newTextureWithContentsOfURL to create the texture for a cow.
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];
Here is the sample cow (top) and my cow (bottom) look.


I don't know the reason about this, but I think the options may help.
How to set this option using NSDictionary?
Based on this Objective-C Literals
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];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With