Baking Cycles Procedural Normals to Texture


(Secrop) #1

Hi all,

I was exporting an object to another program, and I needed to bake all my textures which were heavily procedural.
For most of them, no problem; but my Normals continue to bake flat!

It looks that baking normals in cycles is just for transfer the surface curvature of an highres object, which I don’t have.

So I came out with this helper node, that transforms Normals in WorldCoords to Tangent, so I can bake them and use them in whatever software I want.


To use it just plug your Normal in, and connect the output to the color input of a diffuse shader, and bake the diffuse color.


Now I can use my Bump map made in Cycles, in other programs!
Hope its usefull for you all

Happy bl

Edited

I’ve updated the first image with the corrected node setup (a small error pointed out by hyyou). Now the normals are not inverted. :slight_smile:
And to avoid color space transformations in the result texture, I recommend you to save file in EXR or TIFF format.

Edited #2

I’ve finally turned this nodegroup into a python node, for anyone lazy enough to build this. :stuck_out_tongue:
One can find it in my PythonNodes utility addon, and here’s a screenshot of it:


Combine normal and bump in cycles?
(vitorbalbio) #2

That’s just amazing! I will test it soon :smiley:


(aivanis) #3

Thanks a lot, I had the same problem.


(blendtuts) #4

This node looks cool! :smiley:


(norvman) #5

@Secrop
Thank you! been needing something like this for some time…


(Secrop) #6

I’m really glad it can be usefull for you!
My best wishes for all your works with it. :wink:


(see360) #7

Haven’t tried it yet, but it sounds like this should be the default cycles bake behavior. Thanks Secrop!


(MickeyG) #8

Actually tried this helper node set up, and it works great. Thanks!


(triggerfish) #9

Could you please explain how to build the helper node? I cannot find the Group Input (WorldNormal), and the Group Output (TangentNormal) nodes. Once I build that helper node, how do I group it so that I can use it in the next section where I bake the Diffuse?

Thank you!


(Secrop) #10

just create all the other nodes. When done, select the nodes and group them (CTRL+G). This will enter into that group and give you that greenish backgroung, and the GroupInput/GroupOutput nodes. They will only have an unassigned socket, that you can use to drop input and output connections. If you press N while inside the group, the Properties Toolbar will show, and in the Interface section you can name the inputs and outputs (in my case i named them ‘WorldNormal’ and ‘TangentNormal’ but its a matter of taste ;)).

When ready, press TAB to exit the group, and you’ll end with a simple node just like the yellowish node on the second image. (the color will not be yellow, I’ve changed it just to make the node more visible)

Node Groups are a very powerfull feature in Cycles, check here for more information :wink:


(triggerfish) #11

Secrop, thanks so much for your help and patience! I was able to make a normal map for the rock texture I created in Cycles nodes. I will play around for ways to use the normal map in the BGE. I’m learning ever day. Thnaks again.


(Ducth__Mofo) #12

I recreated this node http://imgur.com/79fpBpy But when i use it color that should be flat (r: .5, g: .5, b: 1) they turn out lighter (r: .73725, g: .73725, b: 1). Edit: Found the anwser, changing the texture from sRGB to Non-Color helped.


(hyyou) #13

I can’t manage to get the node to work. It must be my fault, but I don’t know how to fix it.

I copy Secrop’s nodes and add a wave texture as input.


But the result has some strange glitch.


The green stitch is ok because it is UV seam, but how did red stitch happen?
I attached a small file just in case. test20_secropTest.blend (670 KB)

PS. Thank Secrop, your node is cool and look like it was created with love.

Edit: Cycle’s wave texture is the cause, so I will post in material thread instead.


(Secrop) #14

Hey all, just to say that the inputs from the crossProduct node should be switched!!
Normal on top and Tangent on the bottom.
(@hyyou, thanks for pointing it out)

About the glitch in hyyou’s file, I checked it and the problem is actually from the bump node… lowering the strength/distance on the bump node reduces the glitch, but it still remains there…
And apart from the UV seams, there are also some ‘terminator problems’ and a solution could be to subdivide the mesh a bit more.

Don’t know really how one could solve this, or even if there’s any solution… :frowning:


(PaulStormblader) #15

Can this be done using the normal map node in cycles? I can’t seem to find cross product anymore.


(Secrop) #16

The normal map node transforms vectors in tangent space into vectors in world space. This setup does exactly the opposite, transforming world vectors into tangent space.

And the cross product is a function inside the vector math node. :wink:


(TiagoTiago) #17

I was looking for something like this for quite a while, thanx!


(grinsegold) #18

Did i get you right? You have your object with procedural bumps and you want to bake that? And the following didn’t work?:
-create a new image in the U/V image editor in order to bake onto.
-in the node editor add an image texture node. You don’t need to connect it to anything, but it has to be active. As image you choose the one you just created.
-bake the normals (not having checked “from selected to active”!)

That’s strange.


(grinsegold) #19

oh, and if you insist on sticking to your node setup, try this:
In the “scene”-tab (between “Render layers” and “World”), under “color management"→"Render"→"View”, change the setting from “Default” to “Raw”. That makes the normal map crisper.


(hyyou) #20

Thank, grinsegold. Now, I am using BI instead, because it is more suitable for texture tiling for game assets.

Secrop’s node OP!