-
Notifications
You must be signed in to change notification settings - Fork 1
Blender bake normal maps for tiny renderer
Wavefront .obj file was exported using coordinate system: -Z forward Y Up
- Deselect application of all modifiers in render view (ensures high quality output)
- Add image in image editor(blank, 32bit float can be unchecked)
- Add alpha, specify size
Select correct UV map in Object data properties -> UV Maps
- Add image texture node in Shader editor (not connected to anything)
- Select created image where the normal map is baked to
Render properties -> Bake
- Blender does not support baking world space normal maps out of the box. But you can change axis in baking runs to get all the X,Y,Z axis info you need.
Bake Type normal, Space object, margin 3px, clear image yes. Bake 3 times and after each run save the output image (should be grayscale as all color channels have the same axis selected: Save image as Targa RGBA (loss less RLE compression), use descriptive name like +X.tga Swizzle R, G, B = +X, +X, +X Swizzle R, G, B = -Y, -Y, -Y Swizzle R, G, B = +Z, +Z, +Z
Open each image in Gimp. Duplicate one of the opened images. Use Colors-> Decompose to split channels into layers. Remove the red, green, blue layer (but keep alpha) and add the contents of the 3 images to the new image. Rename the layers:
Layer of +X image: red Layer of -Y image: blue Layer of +Z image: green
This is necessary because of the different coordinate systems in OpenGL and blender
Use Colors -> Compose to generate a new image. You should see the correct normal map now. Export as targa (origin = bottom left) BLE compression.
Swizzle R, G, B = -X, -Y, Z
No special thing here. Use image without alpha channel and set image mode to grayscale (with gimp)