BumpMap
Video Lecture
Your browser does not support the video tag.
Description
An image texture to create a bump map. Values alter the perceived depth in relation to the lights.
The Bump map doesn't actually affect the geometry of the object, only the lighting.
Resources
The image files used in this lesson can be downloaded from the file named material-textures-3.zip
. Extract the material-textures-3.zip
contents into the ./dist/client/img/
folder.
material-textures-3.zip
Lesson Script
./src/client/client.ts
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 import * as THREE from 'three'
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls'
import Stats from 'three/examples/jsm/libs/stats.module'
import { GUI } from 'dat.gui'
const scene = new THREE . Scene ()
scene . add ( new THREE . AxesHelper ( 5 ))
const light = new THREE . PointLight ( 0xffffff , 1000 )
light . position . set ( 0 , 5 , 10 )
scene . add ( light )
const camera = new THREE . PerspectiveCamera (
75 ,
window . innerWidth / window . innerHeight ,
0.1 ,
1000
)
camera . position . z = 1
const renderer = new THREE . WebGLRenderer ()
renderer . setSize ( window . innerWidth , window . innerHeight )
document . body . appendChild ( renderer . domElement )
const controls = new OrbitControls ( camera , renderer . domElement )
controls . enableDamping = true
const planeGeometry = new THREE . PlaneGeometry ( 3.6 , 1.8 )
const material = new THREE . MeshPhongMaterial ()
const texture = new THREE . TextureLoader (). load ( 'img/worldColour.5400x2700.jpg' )
material . map = texture
const bumpTexture = new THREE . TextureLoader (). load ( 'img/earth_bumpmap.jpg' )
material . bumpMap = bumpTexture
material . bumpScale = 0.015
const plane = new THREE . Mesh ( planeGeometry , material )
scene . add ( plane )
window . addEventListener ( 'resize' , onWindowResize , false )
function onWindowResize () {
camera . aspect = window . innerWidth / window . innerHeight
camera . updateProjectionMatrix ()
renderer . setSize ( window . innerWidth , window . innerHeight )
render ()
}
const stats = new Stats ()
document . body . appendChild ( stats . dom )
const gui = new GUI ()
gui . add ( material , 'bumpScale' , 0 , 1 , 0.01 )
function animate () {
requestAnimationFrame ( animate )
controls . update ()
render ()
stats . update ()
}
function render () {
renderer . render ( scene , camera )
}
animate ()