3
$\begingroup$

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.

$\endgroup$
6
  • $\begingroup$ You could try baking and some Python... I still need to test how, but it should work $\endgroup$ Commented Dec 28, 2014 at 14:40
  • $\begingroup$ Oh I'm not baking, I'm attempting to use a manual render for it since there's no animated bake feature. there's an addon for it, but it doesn't do what I want, and I also want to see if I can figure out how to do this method $\endgroup$
    – Kavukamari
    Commented Dec 28, 2014 at 15:24
  • $\begingroup$ Right, that should have been obvious to me from the title. Anyways. One of the problems with analyzing and comparing the colors is that some image types are gamma corrected and some are not. Cycles renders are in linear space, when you save it as a .png it becomes sRGB and if you use it as a normal map then it has to be set to non-color data to function properly. Confusing yes! $\endgroup$ Commented Dec 29, 2014 at 0:49
  • $\begingroup$ Here's a link. I have not tried this method yet and I think the reason the normals he has generated looked faded is because they may still be in linear color space. Once saved as a .png they may end up looking correct since gamma correction will be applied to the color. I'm just guessing really, as I said, I have not tried it yet. blenderartists.org/forum/… $\endgroup$ Commented Dec 29, 2014 at 0:53
  • $\begingroup$ BTW. I'm fairly certain that to use the Normalize node, you are just supposed to use the top socket. The bottom isn't supposed to be used. Rumor has it that the developer did this so a new type of node didn't have to be added in just to handle a few corner cases. $\endgroup$ Commented Dec 29, 2014 at 0:55

1 Answer 1

2
$\begingroup$

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.

Scene settings for linear output.

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):

Material setup for a normal map material in Cycles.

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

Rendered result in my test scene.

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.

$\endgroup$
2
  • $\begingroup$ yup, this is exactly what I did as well, I think, marked as correct answer. I think I also marked all items as invisible to every type of ray except camera just in case, so the lights don't intermingle $\endgroup$
    – Kavukamari
    Commented Jan 8, 2015 at 4:31
  • 1
    $\begingroup$ yeah what a pain! Thank you. I also found that I needed to use this emission shader to camera hack to eliminate lighting from shading my bump/normal maps, thanks blender.stackexchange.com/a/21535/3038 $\endgroup$ Commented May 11, 2020 at 21:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .