0
$\begingroup$

I try to understand how blender processes normal maps. As an exercise I try to create a bump map of a half sphere, where each pixel's rgb values describe the normal of the surface of the sphere. That a point $(x,y,z)$ lies on the unit sphere means $x^2 + y^2+z^2 = 1$. Also the normal vector is equal to the point itself, because the vector sticks out of the sphere perpendicularly. Then, by solving for $z$, I can map each $(x,y)$ onto its corresponding normal vector via $$n(x,y) = (x,y,\sqrt{1-x^2-y^2}).$$ From the code below I get this image: enter image description here which in blender produces this result: enter image description here Code

import numpy as np
import matplotlib.pyplot as plt
n= 640
x = np.linspace(-1,1,n)
y = np.linspace(-1,1,n)
X,Y = np.meshgrid(x,y)
Z = (1 - X*X - Y*Y)**0.5

mask = X**2 + Y**2 <= 1

Z[~mask] = 0

N = np.dstack((X,Y,Z))*mask[:,:,np.newaxis]
N = (N + 1 ) / 2

plt.imshow(N)
cv2.imwrite("sphere_normals.png", N)
$\endgroup$

1 Answer 1

1
$\begingroup$

There are 2 types of normal maps, usualy called "Direct-x" and "OpenGL". I suppose you create "Direct-x" type, while Blender uses "OpenGL":

enter image description here

The only difference between them is green channel, invert it.

$\endgroup$

You must log in to answer this question.

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