• Runtimes
  • Normal Map Support for XNA / C# / MonoGame

Related Discussions
...

After doing some research, I've only seen Normal Maps mentioned for Unity. Is there any support for MonoGame / XNA? Our game uses 2D Spine Characters in a 3D world, and while I've been able to get basic lighting working I was hoping to implement normal maps to really sell the idea of them being in the 3D world.

I think I already know the answer to this from looking through the render code in SkeletonRenderer.cs and MeshBatcher.cs but figured I would ask in case I was missing something.

And as the follow-up questions, assuming that normal maps are not supported, what are your thoughts on the path of least resistance to adding it? I see two possible options:

1) The "proper" way - adding actual normal map support into the runtime code. This looks like a hefty chunk of work, including updating the MeshItem class to carry a second Texture2D, ensuring it gets set in a similar fashion to the base texture in MeshBatch.Draw, making sure these textures are assigned to and set in the SkeletonRenderer, making sure it's supported in the Atlas page, etc. I also would need to do some work to ensure I can get tangent information.

2) Do a runtime implementation without altering any Spine code - something like what is described in this Gamasutra article when it talks about lighting Monkey Island: https://www.gamasutra.com/blogs/OliverFranzke/20140828/224326/Dynamic_2D_Character_Lighting.php
This definitely seems like the easier path but would require more processing during runtime.

Any thoughts or insight is much appreciated!

You are pretty spot on with your analysis. My personal preference would be 1.5, doing it the somewhat proper way 🙂 Instead of modifying the core API like Atlas, I'd have SkeletonRenderer know about which RGBA atlas regions map to what normal map regions. That way, you can keep updating the core API without having to report your changes.

For us, providing normal map support out of the box, is a bit harder. We aren't in control of the end users 3D setup, and we don't want to impose anything on the end user.

Thanks for the confirmation. I will probably be messing around with this in a couple of months as I have some other unrelated tasks that take priority, but if I get it up and running at any point I'll be sure to post up some examples in case it would be helpful to anyone else.