three.js - Normal map in *.obj file -
in blender create normal map, export blender obj (wawefront) , there stored in *.mtl file "map_bump".
map_bump have same bumpsacale. parramter in mtl file defines bumpscale in three.js?
my mtl file:
newmtl ship_white ns 0.000000 ka 0.000000 0.000000 0.000000 kd 0.656604 0.656604 0.656604 ks 0.433962 0.433962 0.433962 ni 1.000000 d 1.000000 illum 2 map_kd 2t3l.png map_bump 2t3l_normal.jpg
currently not supported. can remove bump map file , map manually in three.js.
loading texture.
var bmap = three.imageutils.loadtexture('bumpmap.jpg');
you need traverse model , find it's material. e.g.
object.traverse( function( node ) { if ( node instanceof three.mesh ) { // smoothing node.geometry.computevertexnormals(); console.log(node); } if (node instanceof three.mesh && node.material instanceof three.meshphongmaterial ) { // console.log(node); geometry = node.geometry; material = node.material; } });
then either assign directly on material need. or create new 3 js mesh , assign there. warned though if obj contains multiple meshes need find 'right' one.
mesh = new three.mesh( geometry, material); material.bumpmap = bmap; material.bumpscale = 1;
Comments
Post a Comment