Skip to content

Instantly share code, notes, and snippets.

View seflless's full-sized avatar

Francois Laberge seflless

View GitHub Profile
@seflless
seflless / normals2rgb.js
Created November 7, 2010 00:00
Code for converting a Normal to a color for Normal Mapping Purposes
// Encodes a float with range [-1.0,1.0] into a color channel with range [0,255]
function encodeFloat(f){
if(f<0.0){
f = -f;
return Math.min(Math.floor((1.0-f)*127.0),127);
}
else{
return 128+Math.min(Math.floor(f*128.0),128);
}
}
@seflless
seflless / test
Created August 28, 2008 06:18
My first test function
function test()
{
}
function test2()
{
}