0

I am having a very annoying issue...

I have a game with pixel-based art, so the textures used are 8x8 and then scaled up to 128x128 or whatever is needed.

To do this, all I need to do is say texture.filteringMode = SKTextureFilteringNearest

Now that works for almost everything- except for texture atlases. Pulling a texture from a texture atlas causes the texture to refuse to switch filtering modes. One thing to note is that it seems to work from the standard process of setting up a texture atlas, but it doesn't work when my texture atlas is a singleton.

Now usually, I would just figure that I'm setting it up wrong, but I think this issue is on SpriteKit. Here's why:

1) The bug didn't happen until recently, and I hadn't changed anything

2) The bug only happens in iOS 7- not in 7.1 or 8+

3) The issue is not that the filtering mode is wrong- the filtering mode is set to 0, which is nearest (I tested it, logged every frame, and the mode was right- but it was visually incorrect)

So its a rendering bug. But that doesn't make sense, especially when it seemed to work for a bit. Anyone else have any input? I appreciate anything, I'll be trying a couple more things too. Thanks!

Note- I want to emphasize that the code as-is works just fine in ios7.1+, so the code works in some form... but it also isn't a 7.1 unique feature as it worked for me at one point.

IAmTheAg
  • 351
  • 3
  • 11

1 Answers1

0

Oh god guys I've solved it, sorry if I wasted anyone's time with this.

But this is truly the stupidest thing I've ever seen. I fixed it. BUT HOW DOES THIS FIX IT.

I replaced the code:

self.texture.filteringMode = SKTextureFilteringNearest;

with

self.texture.filteringMode = SKTextureFilteringLinear;
self.texture.filteringMode = SKTextureFilteringNearest;

NEW QUESTION GUYS. Why in the world would that EVER fix something? It hurts that I even would try that, seriously. I don't think I can be a programmer if this is the kind of shenanigans I'm going to deal with.

Apologies in advance for any, um... colloquial language. The dialogue on here is supposed to be monotonous and dry from what I gather.

edit: Ok, I've calmed down a bit- the solution is that, somewhere after the initialization, scream at the texture to set the texture mode to first linear and then nearest. I'm trying to figure out exactly where this needs to be done (Right now, I crammed the code into my update statement, so it runs constantly, but I will update this when I know exactly when in the code you need to specify the correct filter.

IAmTheAg
  • 351
  • 3
  • 11