Skip to content

Instantly share code, notes, and snippets.

@alteredq
alteredq / gist:717285
Created November 26, 2010 22:22
Chromatic dispersion refraction hack
function generateFragmentShader( maxDirLights, maxPointLights ) {
var chunks = [
"#ifdef GL_ES",
"precision highp float;",
"#endif",
maxDirLights ? "#define MAX_DIR_LIGHTS " + maxDirLights : "",
maxPointLights ? "#define MAX_POINT_LIGHTS " + maxPointLights : "",
// Approach 1 (links)
// Once the renderer finds a *MeshFaceMaterial*, it'll process the face material array
var head_material = [ new MeshBitmapUVMappingMaterial( head_bitmap ) ];
var torso_material = [ new MeshBitmapUVMappingMaterial( torso_bitmap ) ]
mesh.material = [ new MeshFaceMaterial(), new MeshColorStrokeMaterial( 0xff0000 ) ];
mesh.faces[ 0 ].material = head_material;
mesh.faces[ 1 ].material = head_material;
// Approach 1 (links)
// Once the renderer finds a *MeshFaceMaterial*, it'll process the face material array
var common_material = [ new BitmapUVMaterial( bitmap ) ];
mesh.material = [ new MeshFaceMaterial(), new MeshColorStrokeMaterial( 0xff0000 ) ];
mesh.faces[ 0 ].material = common_material;
mesh.faces[ 1 ].material = common_material;
// Approach 2 (indices)