12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- console.warn( "THREE.NormalMapShader: As part of the transition to ES6 Modules, the files in 'examples/js' were deprecated in May 2020 (r117) and will be deleted in December 2020 (r124). You can find more information about developing using ES6 Modules in https://threejs.org/docs/#manual/en/introduction/Installation." );
- /**
- * 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" )
- };
|