0
\$\begingroup\$

I am dynamically creating a Normal Map in Unity (for my dynamic mesh) but I am having issues, the problem primarily being my weak understanding of Unity's implementation of the Normal Map as used in the Standard Shader. I'm struggling to find any official documentation specifically on procedurally creating a Unity Normal map and have read lots of misleading/contradicting/complex info on the internet, so I need to ask a few specific questions:

  1. Is the Normal Map in the Standard Shader influenced / affected by the Normals, UV's or Tangents of a mesh? I assume no and that the Normal map is independent of the mesh properties.

  2. The "normals" in the Normal Map as used by the Standard Shader are transformed and stored as a Color, using the r,g,b and alpha components, I think. Although in the examples I've seen, b and alpha are always just 1, but I don't know why. Could someone please clarify?

  3. Because I am creating the Normal Map in real-time, I am trying to copy from examples I've seen of a quick technique that takes the average from the pixels above, below and to the sides of each pixel:

    float xDeltaHeight = ((xLeftHeight - xRightHeight) + 1) * 0.5f;
    float yDeltaHeight = ((yUpHeight - yDownHeight) + 1) * 0.5f;
    colours[i] = new Color(xDeltaHeight, yDeltaHeight, 1f, 1f);
    

This seems to give me almost correct results, but one side of my mesh displays the Normals as expected (a bumpy surface) but nothing on the opposite side where the mesh surface is facing the other way, despite both sides receiving equal light positioned equidistant away.

Even though I am creating the flat surface textures exactly the same using the code above, is this a common problem, or have I missed something?

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.