- Home /
How can I merge 2 Normal Maps into a single Normal Map at runtime?
Preface:
I am a solo developer, and I am working on a project that requires building meshes piecemeal at runtime so that they can fit together the way RuleTiles work on TileMaps. The individual parts are mapped and will have both a texture map and normal map shared among all parts used to build each mesh. I am using CombineMeshes() to build each mesh from these parts, then again to merge a map of these meshes to reduce load on the game engine.
These meshes represent structure objects in the game that can take damage. I want to visually show this damage via scratches, cracks, and other deformations on the normal map. I could go through the effort of creating 4-5 high-poly sets of models for each kind of structure, and require any modders that want to add their own variants to do the same. However, this would require 4-5 times as much modeling work to achieve. So I would rather create 1 detail normal map for each variant of the structure, and 3-4 damage normal maps that could work for all variants. Then combine each detail normal map with each of the damage normal maps at application load.
I know that the default Shader has two normal map inputs. However I am trying to use the Universal Render Pipeline, and the URP Shaders I have tried only have 1 normal map. I do not want to create a custom shader at this time. I would prefer to combine the normal maps when the assets are loaded, then use them with the built-in URP Shaders.
Question:
How do I take 2 Normal Maps, overlay 1 (possibly with some tiling) over the other, and then store a soft copy of the result for later use with a built-in URP Shader? I know there are functions for working with Normal Maps within the Shader system, but I need to perform this operation prior to the Shader. Are there functions in Unity I can leverage for this? Do I need to write a function to perform the merge? An example would be helpful.
Thank you.
I know it has been a $$anonymous$$ute, but I have the same question. My application is different with 2D characters in 3D space, but I also am in need of a way to overlay normal maps to get a single composite to use before the shader is applied. Have you had any luck finding a way of doing this in Unity?