Wednesday, February 20, 2013

Screens of the day 31 - Them normals be hard yo (part 2)

Today, in part two, we'll try and fix the nasty exaggerated normal mapping effect.

To not overly spam the hell out of you, I will be including just the non-normal mapped result and the normal mapped result, skipping the middle one:



This was the number one problem area and the result is better. Let's see it from behind:



Good, good. Now for some grass:



And dirt:









Now I really don't know what to say. Which to prefer? For now, I'll stick to the three terrain rendering qualities: low, medium and high, but in parallel you will be able to choose the softness of the normal mapping. This theoretically would give 6 types of rendering, but low soft and hard soft are identical. A little bit too many options for the standard user. In the future I hope to have even better shaders that blow both soft and hard options right out of the water, thus having fewer options available.

The above option is hard medium. Hard high option is almost identical to what you see in the pictures. But this method has some problems: a nasty repeating pattern can become quite obvious. Hard high tries to hide this pattern, but is slightly slower. Both hard options are faster than the soft ones.

Actually, after dozens of shader permutations I tried, I am very confused. What is normal mapping? Why doesn't it work on facing away polygons? Why does spherical harmonics work? Why was the detail so soft before? What did I do to make it harder? Why is my cat orange? These are all questions that blend together right now. I need to clear my head and take a few days break from normal mapping terrain shaders.

But don't worry, I have material gathered for 3 more posts already!

3 comments:

  1. You said that you are using spherical harmonics? Mind if I take a look at where you got the sample from? I have some normal mapping on my terrain but it looks weaker compared to the normal maps on my models. The models are prepared in the content pipeline so I am guessing I did something wrong for the terrain.

    ReplyDelete
    Replies
    1. Are you Chris?

      The very basic computation is as in the XNA final engine:

      http://xnafinalengine.codeplex.com/

      Check out the SphericalHarmonics.fxh or similar file.

      But I am also doing some funky stuff with it deep in the terrain shader and the code is ridiculously obtuse right now. Need to clean it up a lot. Especially after these two days of tweaking shaders.

      As for terrain, are you computing normals and tangents for the generated mesh? I am computing these myself. Looking to adapt the code for meshes too, another step in removing the pipeline once and for all.

      Delete
    2. Yep, it's the same Chris. I gotta retype my name and sometimes forget to use that in my post.

      I've heard of that engine before, but never gotten too deep into the code. I compute the normals the way Riemers does in his terrrain tutorials, but thing is, I had to change the vertex type to accomodate tangents and binormals, and computing those on the GPU.

      Delete