Skip to content

Instantly share code, notes, and snippets.

View abaczkowski's full-sized avatar

abaczkowski

  • Buffalo, NY
View GitHub Profile
@Huud
Huud / Generate Normal Map From Height Map.py
Last active May 7, 2024 17:55
Generate Normal Map From Height Map
# A fast - numpy based - CPU functions that take a height map and generate a normal map from it
import numpy as np
import matplotlib.image as mpimg
# a function that takes a vector - three numbers - and normalize it, i.e make it's length = 1
def normalizeRGB(vec):
length = np.sqrt(vec[:,:,0]**2 + vec[:,:,1]**2 + vec[:,:,2]**2)
vec[:,:,0] = vec[:,:,0] / length
vec[:,:,1] = vec[:,:,1] / length