Lightmaps in Three.js

血红的双手。 提交于 2019-12-20 07:06:24

问题


Lightmaps live independently of other textures, right?

So I have to set up a second set of UVs.

I have exported my JSON object with a second set of UVs and added the following.

geometry.faceVertexUvs[0] = geometry.faceVertexUvs[1];

I got no working results. What I'm missing? Maybe someone can wise me a direction. Three.js r.73

loader.load("model.js", function(geometry){
geometry.faceVertexUvs[0] = geometry.faceVertexUvs[1];

var mesh = new THREE.Mesh( geometry, new THREE.MeshPhongMaterial( {
  color: 0x777777,
  lightMap: THREE.ImageUtils.loadTexture( "lightmap.png" ),
  normalMap: THREE.ImageUtils.loadTexture( "normalmap.png" ),
  specularMap: THREE.ImageUtils.loadTexture( "specularmap.png" )
}));
scene.add(mesh );
});

回答1:


Lightmaps in three.js require a second set of UVs. One solution is to add a second set of UVs by duplicating the first set.

For THREE.Geometry you can do this:

geometry.faceVertexUvs[ 1 ] = geometry.faceVertexUvs[ 0 ];

For THREE.BufferGeometry, use this pattern;

var uvs = geometry.attributes.uv.array;
geometry.addAttribute( 'uv2', new THREE.BufferAttribute( uvs, 2 ) );

three.js r.73



来源:https://stackoverflow.com/questions/34054388/lightmaps-in-three-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!