diff --git a/docs/api/materials/MeshBasicMaterial.html b/docs/api/materials/MeshBasicMaterial.html
index 553e1056b0f8684ccceeb9e65f7507d5937e1939..3ca017f59b8780b5c76856c05bb4f8278a31def7 100644
--- a/docs/api/materials/MeshBasicMaterial.html
+++ b/docs/api/materials/MeshBasicMaterial.html
@@ -1,7 +1,7 @@
-
+
@@ -41,6 +41,8 @@
color — geometry color in hexadecimal. Default is 0xffffff.
map — Set texture map. Default is null
+ lightMap — Set light map. Default is null.
+ lightMapIntensity — Set light map intensity. Default is 1.
aoMap — Set ao map. Default is null.
aoMapIntensity — Set ao map intensity. Default is 1.
specularMap — Set specular map. Default is null.
@@ -71,11 +73,17 @@
Set texture map. Default is null.
+ [property:Texture lightMap]
+ Set light map. Default is null. The lightMap requires a second set of UVs.
+
+ [property:Float lightMapIntensity]
+ Intensity of the baked light. Default is 1.
+
[property:Texture aoMap]
Set ambient occlusion map. Default is null.
[property:Float aoMapIntensity]
- TODO
+ Intensity of the ambient occlusion effect. Default is 1. Zero is no occlusion effect.
[property:Texture specularMap]
Set specular map. Default is null.
diff --git a/src/materials/MeshBasicMaterial.js b/src/materials/MeshBasicMaterial.js
index efcf35b31e85727a1fc58f9c1039671e3e3f5ec2..5217cac597f37aa86f5ae6d1f2e31e412d84a9d8 100644
--- a/src/materials/MeshBasicMaterial.js
+++ b/src/materials/MeshBasicMaterial.js
@@ -11,6 +11,9 @@ import { Color } from '../math/Color';
* opacity: ,
* map: new THREE.Texture( ),
*
+ * lightMap: new THREE.Texture( ),
+ * lightMapIntensity:
+ *
* aoMap: new THREE.Texture( ),
* aoMapIntensity:
*
@@ -45,6 +48,9 @@ function MeshBasicMaterial( parameters ) {
this.map = null;
+ this.lightMap = null;
+ this.lightMapIntensity = 1.0;
+
this.aoMap = null;
this.aoMapIntensity = 1.0;
@@ -84,6 +90,9 @@ MeshBasicMaterial.prototype.copy = function ( source ) {
this.map = source.map;
+ this.lightMap = source.lightMap;
+ this.lightMapIntensity = source.lightMapIntensity;
+
this.aoMap = source.aoMap;
this.aoMapIntensity = source.aoMapIntensity;
diff --git a/src/renderers/WebGLRenderer.js b/src/renderers/WebGLRenderer.js
index 1cb03d92009832306b363e009d371c2f7878e688..f332099497f76a369f8669e4169fb45a0976e4b5 100644
--- a/src/renderers/WebGLRenderer.js
+++ b/src/renderers/WebGLRenderer.js
@@ -1945,6 +1945,13 @@ function WebGLRenderer( parameters ) {
uniforms.specularMap.value = material.specularMap;
uniforms.alphaMap.value = material.alphaMap;
+ if ( material.lightMap ) {
+
+ uniforms.lightMap.value = material.lightMap;
+ uniforms.lightMapIntensity.value = material.lightMapIntensity;
+
+ }
+
if ( material.aoMap ) {
uniforms.aoMap.value = material.aoMap;
@@ -2083,13 +2090,6 @@ function WebGLRenderer( parameters ) {
function refreshUniformsLambert( uniforms, material ) {
- if ( material.lightMap ) {
-
- uniforms.lightMap.value = material.lightMap;
- uniforms.lightMapIntensity.value = material.lightMapIntensity;
-
- }
-
if ( material.emissiveMap ) {
uniforms.emissiveMap.value = material.emissiveMap;
@@ -2103,13 +2103,6 @@ function WebGLRenderer( parameters ) {
uniforms.specular.value = material.specular;
uniforms.shininess.value = Math.max( material.shininess, 1e-4 ); // to prevent pow( 0.0, 0.0 )
- if ( material.lightMap ) {
-
- uniforms.lightMap.value = material.lightMap;
- uniforms.lightMapIntensity.value = material.lightMapIntensity;
-
- }
-
if ( material.emissiveMap ) {
uniforms.emissiveMap.value = material.emissiveMap;
@@ -2157,13 +2150,6 @@ function WebGLRenderer( parameters ) {
}
- if ( material.lightMap ) {
-
- uniforms.lightMap.value = material.lightMap;
- uniforms.lightMapIntensity.value = material.lightMapIntensity;
-
- }
-
if ( material.emissiveMap ) {
uniforms.emissiveMap.value = material.emissiveMap;
diff --git a/src/renderers/shaders/ShaderLib.js b/src/renderers/shaders/ShaderLib.js
index bc59929a570e3e13a374357be8aff730bd17b350..9e072532b05e0ab754828e37e627b07c53ffbc39 100644
--- a/src/renderers/shaders/ShaderLib.js
+++ b/src/renderers/shaders/ShaderLib.js
@@ -16,6 +16,7 @@ var ShaderLib = {
uniforms: Object.assign( {},
UniformsLib.common,
UniformsLib.aomap,
+ UniformsLib.lightmap,
UniformsLib.fog
),
diff --git a/src/renderers/shaders/ShaderLib/meshbasic_frag.glsl b/src/renderers/shaders/ShaderLib/meshbasic_frag.glsl
index 81d8119ee3170004bdca0bd3fa86d291aad9732e..5858ea7ce91204f1c0e0446e86c29df2009ab07c 100644
--- a/src/renderers/shaders/ShaderLib/meshbasic_frag.glsl
+++ b/src/renderers/shaders/ShaderLib/meshbasic_frag.glsl
@@ -14,6 +14,7 @@ uniform float opacity;
#include
#include
#include
+#include
#include
#include
#include
@@ -33,14 +34,24 @@ void main() {
#include
#include
- ReflectedLight reflectedLight;
- reflectedLight.directDiffuse = vec3( 0.0 );
- reflectedLight.directSpecular = vec3( 0.0 );
- reflectedLight.indirectDiffuse = diffuseColor.rgb;
- reflectedLight.indirectSpecular = vec3( 0.0 );
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
+ // accumulation (baked indirect lighting only)
+ #ifdef USE_LIGHTMAP
+
+ reflectedLight.indirectDiffuse += texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;
+
+ #else
+
+ reflectedLight.indirectDiffuse += vec3( 1.0 );
+
+ #endif
+
+ // modulation
#include
+ reflectedLight.indirectDiffuse *= diffuseColor.rgb;
+
vec3 outgoingLight = reflectedLight.indirectDiffuse;
#include