Rendering an animated Normal Map using Orthographic Camera in cycles I am using the ocean simulation to make an animating water texture.

I want to use cycles to render my simulation surface into a nice normal map to be used for better performance while still having the proper caustics of the simulation. All of the preliminaries are sorted already, I.E. The camera is set up, my ocean modifiers are set up properly, the animation is all ready to render, except for the actual coloring part of it.

When it came down to actually attempting to render the normal map, I got as far as feeding the normal geometry output into an emmission shader before I got stuck. The "Normal" output of the geometry shader doesn't behave like a standard texture normal map does, I'm looking for "Normal-Map Periwinkle" (or however the color is named) to show up on a perfectly flat surface, but it outputs as 100% blue (as I should have expected using this hacky method). I tried vector mapping and a few other things to rotate the input, but I don't want to do this a terrible, lazy way that gives me an improper normal map, What should I do instead to make sure this gives me a normal map that will actually work properly for anything I use it in?

I thought maybe normalizing the vectors would do it, but I have no idea how to work the node so I couldn't figure out how to set that up. If anyone knows the real way to do this, I'm sure this is probably the place to ask. I tried another method that LOOKS correct, but I can't tell if it's 100% right: I subtracted 50% blue from the colors, and then added 50% white. it looks correct, but I have no idea if the colors are in fact correct. If anyone knows a setup that would cause 100% accurate results, I would greatly appreciate it.

Update: Everywhere I look, it's apparent that the flat/default color for a Normal Map should be R=0.5, G=0.5, B=1.0. However, in blender, when I sample a normal map with the color picker, I get R=0.212, G=0.212, B=1.0. Because of this, I realized that blender does not handle the colors properly for this particular purpose.

Incidentally, after using the Color Curves node to remap x=0.5,y=0.5 to x=0.5, y=0.212, my test hemisphere normal map ended up almost indistinguishable from one which I baked properly, unfortunately, as with all other methods so far, subtracting it from the proper one in compositing revealed it's still not a perfect normal map.

Still looking for any input on how to fix this.
I have made a test setup that works, at least as far as I can tell:
First, it's important to set the Colour Management display type to sRGB/RAW (or to None) and the gamma value to 1.0. This makes sure that the render output is stored into the output file in a linear manner. It shouldn't affect how the RGB values are shown inside of Blender though, so this should always be correct.

Then a glance at how Blender expects normal maps to behave and how it stores the normals internally helps with setting up the material. Information on this can be found here: Wiki: Bump and Normal Maps
Quote:

Red maps from (0-255) to X (-1.0 - 1.0)
Green maps from (0-255) to Y (-1.0 - 1.0)
Blue maps from (0-255) to Z (0.0 - 1.0)

In other places, the blue channel is also mapped from -1.0 to 1.0. Either way, this means that the red and green values have to be remapped accordingly. Optionally, this applies to the blue channel, too. This is easy to achieve using math nodes (here for blue from -1.0 to 1.0):

Then, using an orthographic camera from the top, the follwing result is achieved:

Here, camera-facing surfaces have RGB values of (0.5|0.5|1.0), as expected. Also, the colours stay between 0 and 1 in all areas, but use the full range. So this looks good to me.