Skip to content

Instantly share code, notes, and snippets.

View kchapelier's full-sized avatar
💬

Kevin Chapelier kchapelier

💬
View GitHub Profile
@kchapelier
kchapelier / notes.md
Last active August 6, 2026 10:19
Lighting technique notes
@kchapelier
kchapelier / sources.txt
Created August 6, 2017 19:16
3D models sources
http://graphics.stanford.edu/data/3Dscanrep/
https://www.cc.gatech.edu/projects/large_models/
https://gumroad.com/l/xAQxj
https://www.myminifactory.com/scantheworld/
https://sketchfab.com/britishmuseum
http://lincoln3dscans.co.uk/
@kchapelier
kchapelier / randomThetaPhi.js
Last active June 25, 2017 18:19
Uniform distribution on a sphere
//Return random directions, spherical angle pairs theta [0,PI) and phi [0,TWO_PI), distributed uniformly over a sphere
//Pairs generated with theta=random(PI) and phi=random(TWO_PI) have a higher density around the poles.
//See spherical coordinates: https://en.wikipedia.org/wiki/Spherical_coordinate_system
//Optimalization by Dan Gries
//https://pastebin.com/7uPYaA8G
function randomThetaPhi () {
"use strict";
@kchapelier
kchapelier / gaussianKernel1d.js
Created June 18, 2017 09:07
1D gaussian kernel
// based on https://warpycode.wordpress.com/2009/04/13/computing-a-1d-gaussian-kernel/
// see http://www.stat.wisc.edu/~mchung/teaching/MIA/reading/diffusion.gaussian.kernel.pdf.pdf for more info
var gaussianKernel1d = (function () {
var sqr2pi = Math.sqrt(2 * Math.PI);
return function gaussianKernel1d (size, sigma) {
"use strict";
// ensure size is even and prepare variables
@kchapelier
kchapelier / merge-three-buffer-geometries.js
Last active September 11, 2018 22:04
Merge indexed and non-indexed THREE.BufferGeometry into a new indexed THREE.BufferGeometry. All missing uniforms are set to 0.
/**
* Combine indexed and non-indexed BufferGeometry into a new indexed BufferGeometry. All missing uniforms are set to 0.
* @param {array} geometries Array of THREE.BufferGeometry instances
* @returns {BufferGeometry}
*/
function mergeBufferGeometries (geometries) {
var indexLength = 0,
verticesLength = 0,
attributesInfos = {},
geometriesInfos = [],
@kchapelier
kchapelier / things-to-read.md
Last active November 2, 2021 19:53
Things to read / public bookmarks
@kchapelier
kchapelier / unexif.js
Last active April 28, 2017 12:15
UnEXIF: UnProtect Your Work!
/***
Undoing the hacks of https://www.exif.co/ with unsophisticated javascript.
As an artist, the best way to protect your work is to approach sharing technologies and third party services with a healthy dose of scepticism and to always clearly specify the license under which your work is made available on the Internet.
***/
// click on an image served by exif.co to replace it with a canvas containing the full image
document.body.addEventListener('click', function (e) {
if(e.target.parentNode && e.target.parentNode.classList.contains('js-exif-image')) {
var element = e.target.parentNode,
@kchapelier
kchapelier / scraper.js
Created April 28, 2017 10:06
Unicode blocks scraped from Wikipedia as a JSON
// executed directly on https://en.wikipedia.org/wiki/Unicode_block
var planes = [],
blocks = [],
plane,
pos;
var planesFirstLine = document.querySelectorAll('#collapsibleTable3 tr:nth-of-type(3) th');
var planesSecondLine = document.querySelectorAll('#collapsibleTable3 tr:nth-of-type(5) th');
@kchapelier
kchapelier / nefertiti-smooth.json
Last active March 24, 2017 11:36
Smooth low-poly version of The Other Nefertiti. Original version : http://nefertitihack.alloversky.com/
{
"indices":[0,1,2,3,4,5,3,5,6,4,7,8,9,10,11,12,13,14,14,15,16,15,17,18,19,20,21,22,23,24,25,26,27,28,29,30,29,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,56,59,60,61,62,63,50,64,63,65,66,67,68,67,69,68,70,71,72,65,73,68,74,75,76,73,77,78,78,77,79,80,81,82,83,84,85,86,87,88,85,84,89,90,91,92,93,82,86,93,86,94,95,96,97,98,99,100,96,101,102,97,102,103,104,105,106,107,108,109,108,107,110,88,87,111,112,106,113,114,115,116,117,87,118,119,120,118,110,109,111,111,121,110,122,113,110,123,116,124,122,125,126,127,128,129,121,111,130,131,132,133,127,134,128,135,122,136,13,137,15,108,88,109,122,126,136,124,131,133,124,133,138,139,140,125,141,135,136,134,138,142,128,134,142,130,117,143,144,145,125,133,146,147,148,130,143,147,146,149,125,150,151,121,152,140,151,144,125,151,145,144,153,146,132,146,154,149,150,155,156,157,145,151,158,159,160,161,162,163,163,162,164,157,151,150,153,165,166,167,168,16,163,169,170,171,172,173,163,164,169,174,175,152,155,176,177,178,175,176,171,179,169,1
@kchapelier
kchapelier / nefertiti.json
Last active March 24, 2017 11:40
Low-poly version of The Other Nefertiti. Original version : http://nefertitihack.alloversky.com/
This file has been truncated, but you can view the full file.
{
"indices":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262,263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279