bumpMap
process colormap to its bumpMap
by Wai Ting Chen
HTML
<div id="info">bump map</div>
<script src="http://cdnjs.cloudflare.com/ajax/libs/three.js/r70/three.min.js"></script>
<script src="https://dl.dropboxusercontent.com/u/3587259/Code/Threejs/OrbitControls.js">
</script>
CSS
#info {
position: absolute;
top: 0px;
width: 100%;
padding: 10px;
text-align: center;
color: #ff12ee;
}
JavaScript
var renderer, geometry, material, mesh, light;
var scene, camera;
var controls;
init();
animate();
function init() {
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera(50, window.innerWidth / window.innerHeight, 0.1, 10000);
camera.position.z = 500;
camera.lookAt(new THREE.Vector3(0, 0, 0));
THREE.ImageUtils.crossOrigin = '';
var texture = THREE.ImageUtils.loadTexture('http://jyunming-chen.github.io/tutsplus/images/stone.jpg');
var bumptex = THREE.ImageUtils.loadTexture('http://jyunming-chen.github.io/tutsplus/images/stone_bump2.jpg');
// var bumptex = THREE.ImageUtils.loadTexture('http://jyunming-//chen.github.io/tutsplus/images/stone_bump.jpg');
var back = new THREE.Mesh(new THREE.PlaneGeometry(200, 200),
new THREE.MeshPhongMaterial({
// map: texture,
color: 0xf6c4df,
bumpMap: bumptex,
bumpScale: 0.8,
side: THREE.DoubleSide
}));
back.doubleSided=true;
scene.add(back);
var pointLight = new THREE.PointLight(0xffffff);
pointLight.position.set(0, 300, 200);
scene.add(pointLight);
renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setClearColor(0x666666);
controls = new THREE.OrbitControls(camera, renderer.domElement);
document.body.appendChild(renderer.domElement);
}
function animate() {
controls.update();
requestAnimationFrame(animate);
render();
}
function render() {
renderer.render(scene, camera);
}