Rotate sprite with normal maps

I tried creating a sprite with a normal map; lighting works; however if I rotate the sprite, the lighting doesn't respond.


After seeing this; I realize 'duh, my pixels saying +x values still say +x values no matter where I am'


So while I understand why it happens, is there anything built into sprite kit to recompute normal maps or the lighting calculation based on sprite rotation, or am I into custom shaders?


Thanks,

-Michael

Hi michaelk,


Thanks for bringing this to our attention. I'm able to reproduce this issue and have filed a bug report that we are actively working to fix. Your assessment of the issue is correct, but unfortunately we do not have a workaround for you at this time. We will notify you (via this thread) as soon as a fix is in place.


Thank you.

The normals should be considered to be in local space, not world space. (Or tangent space if you're going to mirror the sprite.)


Unity, for example, handles this kind of thing, with batched meshes, by transforming vertexes from local space into world space, on the CPU, and then having local space be the exact same thing as world space.


I have no idea yet if Sprike Kit even does batching.

Is there a reference implementation for the default lighting shader that I can adapt a rotation matrix mult to the normal vector until this is resolved?

Hi Jessy,


SpriteKit is a batching renderer. The crieria for batching is that the textures (or owning atlas) and blend modes are equivalent, or in the case of using shaders that the uniforms and program are equivalent.


SKView provides a number of debugging booleans that you can set to see the number of draw calls, quads and nodes to see how well your scene is batching.

See https://developer.apple.com/library/prerelease/ios/documentation/SpriteKit/Reference/SKView/index.html for more info.


Cheers

Rotate sprite with normal maps
 
 
Q