Cycles: Baking normal maps from material.

I’m trying to bake some normal maps with cycles and i’m not sure if i’m doing it wrong or if what i want just can’t be done. but I’ve broken my problem down to the simplest use case.

Input Textures:


Final Result:

Sofar so good!

Problem description: Export the model for use in an 3D Engine with a diffuse color map and a normal map.

Exporting the model: Easy!

Exporting the color diffuse map: Easy!

Exporting the normal map: Not so easy… it bakes the normals of the underlying geometry to the image (which is good), but not anything the shader put on top of that (which makes me sad).

What i got:

What i wanted:

(I faked the ‘what i wanted image’ by stuffing the normal map texture into the color port of the diffuse shader block,
doubt it’ll work well as a normal map, and definitely not an option for a more complex shader network )

What i really want is a baking option that works like diffuse color but gets me the per pixel applied normal map.

Is this possible?!

It’s rather trivial to work around the problem with this simplified example, but I bumped into this problem while trying to export rocks created with this tutorial where I don’t see an easy way out…

had the same problem this week…
check here my solution