Posts

Post marked as solved
4 Replies
2k Views
Hi everyone, Running Xcode 12, I'm developing a standalone WatchOS App using Spritekit. I'm using a simple Palette-swap shader using a SKShader with several SKAttributes. The shader seems to work fine, however I get the following message in the console: [Metal Compiler Warning] Warning: Compilation succeeded with:  program_source:3:19: warning: unused variable 's' constexpr sampler s(coord::normalized, I have no idea what this means, there is no variable 's' in my code so I guess this is an issue because GLGS shader code gets compiled to Metal in the background and it goes wrong there? How do I verify this? It seems there is a memory leak associated with this error so I'm prone to solve it. Any help would be appreciated, even if it's just pointing me in a direction. (Like, should I write a new palette shader in Metal?) Thanks in advance! The function that adds the SKShader (an extension to SKSpriteNode): func addMultiColorShader(strokeColor: UIColor, colors:[UIColor]) {         let useColors:[UIColor] = shaderColors(colors)         var attributes:[SKAttribute] = [SKAttribute(name: "a_size", type: .vectorFloat2),                                         SKAttribute(name: "a_scale", type: .vectorFloat2),                                         SKAttribute(name: "a_alpha", type: .float)]                  let colorNames:[String] = ["a_color0","a_color1","a_color2","a_color3"]         for i in 0..<colorNames.count {             attributes += [SKAttribute(name: colorNames[i], type: .vectorFloat4)]         }         let shader = SKShader(fromFile: "SKHMultiColorize", attributes: attributes)         setShaderAttributes(size: self.size, scale: CGSize(width: self.xScale, height: self.yScale), alpha: self.alpha)         setShaderColors(strokeColor: strokeColor, color1: useColors[0], color2: useColors[1], color3: useColors[2])         self.shader = shader     } The actual shader code (OpenGL GS): vec2 nearestNeighbor(vec2 loc, vec2 size) {     vec2 onePixel = vec2(1.0, 1.0) / size;     vec2 coordinate = floor(loc * size) / size; // round     return coordinate + (onePixel * 0.5); } void main() {     vec4 colors[4];     colors[0] = a_color0;     colors[1] = a_color1;     colors[2] = a_color2;     colors[3] = a_color3;              vec4 currentColor = texture2D(u_texture, nearestNeighbor(v_tex_coord, a_size));     int colorIndex = int((currentColor.r * 5.1));      vec4 refColor = colors[colorIndex];     gl_FragColor = refColor * currentColor.a; }
Posted
by Prrrpl.
Last updated
.
Post not yet marked as solved
1 Replies
2.4k Views
I'm working on a standalone AppleWatch App and was able to build and run in Simulator and on a 40mm AppleWatch 3 Device in Xcode 11.0 Beta 6. After the update from Xcode 11.0 Beta 6 to Beta 7 I got the following build errors:Build target AppNAME of project AppNAME with configuration Debugerror: unable to resolve product type 'com.apple.product-type.application.watchapp2-container' for platform 'watchos' (in target 'AppNAME' from project 'AppNAME')error: unable to resolve product type 'com.apple.product-type.application.watchapp2-container' for platform 'watchsimulator' (in target 'AppNAME' from project 'AppNAME')error: unable to resolve product type 'com.apple.product-type.application.watchapp2-container' for platform 'watchsimulator' (in target 'AppNAME' from project 'AppNAME')I've tried changing the Project &gt; Target &gt; BuildSettings and set the Base SDK to watchOS (and iOS) like some older reports on similar issues suggested. Both optionsdid not work. I've done the same for the Supported platforms: both iOS and WatchOS yield the same errors. I've also deleted my Library/developer folder before updating to Xcode. This prompts a suggestion to download some files on startup (I assume simulator-related). Again, this does not resolve my issue.I've also tried deleting and re-Adding Simulators. What I found worrying is that I still need to add an iPhone Simulator; then select a Paired Watch in order to add a AppleWatch as a device. Re-adding the simulators did not fix my issue.Can someone tell me based on the information I provided how I could fix my issues? If you need any more information I'd be happy to report back.Thanks in advance,Emiel
Posted
by Prrrpl.
Last updated
.