Hi, TL;DR: Mobile: I wanted to add some normal map lighting to my scenes but it is slow. Has anyone used object space normal maps on mobile? I have read that it could be feasible on mobile without ruining performance: http://answers.unity3d.com/answers/210984/view.html My problem history: - First i had a Tilebased-2D Scene where every Tile is a SpriteRenderer (~120 Tiles within screen, 16x16px low resolution, point filtered) - Of course, adding lights breaks batching (~+500 drawcalls) - In response i wrote a script that creates a grid mesh to replace 20x20 spriteRenderers with one object, drawcalls are below 5 again -But still, normal maps ruin my performance, i thought there must be some way to use the fact that my tiles and camera never rotate and read about object space normal maps. So before i plunge myself into Shaders again (i still suck at those) i wanted to ask: Is it is even likely that this will improve mobile performance noticeably? Or is normal lighting on mobile a lost cause?
Object space vs. tangent space won't make a difference to your performance. You might be able to put them in a fixed space to remove the TBN matrix transform, but I highly doubt that is your bottleneck. Also, mobile is a very lose term. If your on a high end iPhone/iPad, your basically on a low end console and should be able to do very complex shading. Our Star Trek game actually does full PBR rendering with normal/specular/emissive on low end mobile devices for all the ships and space stations (iPad2, old mali chipsets, etc).
Thanks for the Reply, I guess i skip that experiment then and resort to use vertex lighting since this seems to run even on my Samsung-S4-Mini without problems. And since i use a uniform triangle grid vertex lighting still looks way better than no lighting or alpha-halo-overlays (which would increase the demand on fillrate)
Object space normal maps should be a bit faster than tangent space. There is no need to pass the tangent anymore, reducing required bandwidth. It also removes the need to convert vectors into tangent space, reducing calculations. Compared to no normal maps, object space normal maps only add one texture lookup and one matrix multiplication to go from object to world space. If the objects don't rotate, you can skip this last step and essentially have world space normal maps. I can't guarantee this will increase the performance enough, but it should be faster.
Nice! In my case nothing rendered ever rotates, everything has it's fixed rotation according to the Type of Texture it is (floor has x:0°, walls and characters x:90° a clean little cardbox world) So if i write a shader that takes object-space normal maps and skips the objectToWorldSpace-Calc it does nothing more than one Texture Lookup? Those texture Lookups are the bandwidth-hogs that mostly slow things on Mobile, right? But it is surely worth a try. Now i am normal-horny again, time to read some shader manuals for dummies!
One word of warning, if you're doing world space normals you cannot import the textures as "normal maps". Unity assumes these are tangent space and tangent space normals don't need a Z component (the blue channel) as it can be assumed they're always facing away from the mesh surface. Instead you need to set the texture type to advanced and turn on Bypass sRGB.