Skip to content

Instantly share code, notes, and snippets.

@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
@subudeepak
subudeepak / angular-loadscript-with-documentwrite.js
Last active September 9, 2024 04:25 — forked from endorama/angular-loadscript.js
Loading scripts on ngInclude (ng route) - Script loading directive
/**
* This module is a variant which supports document.write. If you need document.write use this instead
* Author: Deepak Subramanian @subudeepak(https://github.com/subudeepak)
* Distributed under MIT License
*/
/*global angular */
(function (ng) {
'use strict';
app.directive('script', function() {
return {