dimanche 15 février 2015

Why won't a normalMap render correctly when using THREE.SubdivisionModifier?


I need to render a 'soft' cube with a normal map. I'm not getting any errors or warnings when running the code, but when I specify the normal map parameter in the function call and refresh the browser, I see a black object. If I remove the normal map, I can successfully render a cube with a Phong material. Interestingly, if I change the material to a Normal material, and attempt to texture the cube, the actual RGB normal map that I'm tring to use otherwise is applied. Also, I can get the normal map to work properly if I don't use THREE.SubdivisionModifier() on the cube, and simply render a sharp-edged cube. Any ideas? Thanks in advance. Here's my code:



var cube_geo = new THREE.BoxGeometry(.1, .1, .1, 5, 5, 5);
var smooth = cube_geo.clone();
var modifier = new THREE.SubdivisionModifier(5);
modifier.modify(smooth);
var cube_mat = new THREE.MeshPhongMaterial(
{
color: 0x000000,
specular: 0x222222,
normalMap: cube_normal_map,
}
);
cube = new THREE.Mesh(smooth, cube_mat);
scene.add(cube);




Aucun commentaire:

Enregistrer un commentaire