/usr/share/javascript/three/examples/js/shaders/NormalMapShader.js is in libjs-three 80+dfsg2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | /**
* @author alteredq / http://alteredqualia.com/
*
* Normal map shader
* - compute normals from heightmap
*/
THREE.NormalMapShader = {
uniforms: {
"heightMap": { value: null },
"resolution": { value: new THREE.Vector2( 512, 512 ) },
"scale": { value: new THREE.Vector2( 1, 1 ) },
"height": { value: 0.05 }
},
vertexShader: [
"varying vec2 vUv;",
"void main() {",
"vUv = uv;",
"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
"}"
].join( "\n" ),
fragmentShader: [
"uniform float height;",
"uniform vec2 resolution;",
"uniform sampler2D heightMap;",
"varying vec2 vUv;",
"void main() {",
"float val = texture2D( heightMap, vUv ).x;",
"float valU = texture2D( heightMap, vUv + vec2( 1.0 / resolution.x, 0.0 ) ).x;",
"float valV = texture2D( heightMap, vUv + vec2( 0.0, 1.0 / resolution.y ) ).x;",
"gl_FragColor = vec4( ( 0.5 * normalize( vec3( val - valU, val - valV, height ) ) + 0.5 ), 1.0 );",
"}"
].join( "\n" )
};
|