Skip to content

Commit

Permalink
Removing THREE.AddOperation and THREE.OverlayOperation for lightmaps.
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Naumann committed Dec 10, 2014
1 parent 595a163 commit ea9d204
Show file tree
Hide file tree
Showing 6 changed files with 882 additions and 35,147 deletions.
51 changes: 44 additions & 7 deletions build/three.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ THREE.SrcAlphaSaturateFactor = 210;
THREE.MultiplyOperation = 0;
THREE.MixOperation = 1;
THREE.AddOperation = 2;
THREE.Modulate2XOperation = 3;

// Mapping modes

Expand Down Expand Up @@ -13493,13 +13494,14 @@ THREE.MeshBasicMaterial = function ( parameters ) {
this.map = null;

this.lightMap = null;
this.lightMapMode = THREE.MultiplyOperation;

this.specularMap = null;

this.alphaMap = null;

this.envMap = null;
this.combine = THREE.MultiplyOperation;
this.combine = this.envMapMode = THREE.MultiplyOperation;
this.reflectivity = 1;
this.refractionRatio = 0.98;

Expand Down Expand Up @@ -13622,13 +13624,14 @@ THREE.MeshLambertMaterial = function ( parameters ) {
this.map = null;

this.lightMap = null;
this.lightMapMode = THREE.MultiplyOperation;

this.specularMap = null;

this.alphaMap = null;

this.envMap = null;
this.combine = THREE.MultiplyOperation;
this.combine = this.envMapMode = THREE.MultiplyOperation;
this.reflectivity = 1;
this.refractionRatio = 0.98;

Expand Down Expand Up @@ -13770,6 +13773,7 @@ THREE.MeshPhongMaterial = function ( parameters ) {
this.map = null;

this.lightMap = null;
this.lightMapMode = THREE.MultiplyOperation;

this.bumpMap = null;
this.bumpScale = 1;
Expand All @@ -13782,7 +13786,7 @@ THREE.MeshPhongMaterial = function ( parameters ) {
this.alphaMap = null;

this.envMap = null;
this.combine = THREE.MultiplyOperation;
this.combine = this.envMapMode = THREE.MultiplyOperation;
this.reflectivity = 1;
this.refractionRatio = 0.98;

Expand Down Expand Up @@ -16293,7 +16297,7 @@ THREE.ShaderChunk[ 'lights_phong_pars_vertex'] = "#if MAX_SPOT_LIGHTS > 0 || def

// File:src/renderers/shaders/ShaderChunk/lightmap_pars_fragment.glsl

THREE.ShaderChunk[ 'lightmap_pars_fragment'] = "#ifdef USE_LIGHTMAP\n\n varying vec2 vUv2;\n uniform sampler2D lightMap;\n\n#endif";
THREE.ShaderChunk[ 'lightmap_pars_fragment'] = "#ifdef USE_LIGHTMAP\n\n varying vec2 vUv2;\n uniform sampler2D lightMap;\n\n #ifdef LIGHTMAP_OVERLAY\n // <0, 2> the degree to which lightmap modifies the original texture color\n uniform float lm_Intensity;\n\n // <0, 1> neutral point in the light map color range where the original texture color is unchanged\n uniform float lm_Center;\n\n // <0, 1> quadratic rate of intensity decrease for extreme lightmap values\n uniform float lm_Falloff;\n\n #endif\n\n#endif\n";

// File:src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl

Expand Down Expand Up @@ -16393,7 +16397,7 @@ THREE.ShaderChunk[ 'map_vertex'] = "#if defined( USE_MAP ) || defined( USE_BUMPM

// File:src/renderers/shaders/ShaderChunk/lightmap_fragment.glsl

THREE.ShaderChunk[ 'lightmap_fragment'] = "#ifdef USE_LIGHTMAP\n\n gl_FragColor = gl_FragColor * texture2D( lightMap, vUv2 );\n\n#endif";
THREE.ShaderChunk[ 'lightmap_fragment'] = "#ifdef USE_LIGHTMAP\n\n #ifdef LIGHTMAP_MULTIPLY\n gl_FragColor = gl_FragColor * texture2D( lightMap, vUv2 );\n\n #endif\n\n #ifdef LIGHTMAP_MODULATE2X\n gl_FragColor = min( gl_FragColor * 2.0 * texture2D( lightMap, vUv2 ), 1.0 );\n #endif\n\n#endif\n";

// File:src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl

Expand Down Expand Up @@ -21635,7 +21639,7 @@ THREE.WebGLRenderer = function ( parameters ) {

if ( geometry instanceof THREE.BufferGeometry ) {

//
_this.info.memory.geometries ++;

} else if ( object instanceof THREE.Mesh ) {

Expand Down Expand Up @@ -22139,6 +22143,8 @@ THREE.WebGLRenderer = function ( parameters ) {

vertexColors: material.vertexColors,

lightMapMode: material.lightMapMode,

fog: fog,
useFog: material.fog,
fogExp: fog instanceof THREE.FogExp2,
Expand Down Expand Up @@ -22391,6 +22397,14 @@ THREE.WebGLRenderer = function ( parameters ) {

}

if(material.lightMapMode === THREE.OverlayOperation) {
// TODO: Allow to set these parameters for the material
_gl.uniform1f(p_uniforms.lm_Intensity, 0.5);
_gl.uniform1f(p_uniforms.lm_Center, 0.5);
_gl.uniform1f(p_uniforms.lm_Falloff, 0);
}


// skinning uniforms must be set even if material didn't change
// auto-setting of texture unit for bone texture must go before other textures
// not sure why, but otherwise weird things happen
Expand Down Expand Up @@ -22631,7 +22645,7 @@ THREE.WebGLRenderer = function ( parameters ) {
}

uniforms.refractionRatio.value = material.refractionRatio;
uniforms.combine.value = material.combine;
uniforms.combine.value = material.envMapMode || material.combine; // TODO: deprecate material.combine
uniforms.useRefract.value = material.envMap && (
material.envMap.mapping === THREE.CubeRefractionMapping ||
material.envMap.mapping === THREE.EquirectangularRefractionMapping );
Expand Down Expand Up @@ -24666,6 +24680,21 @@ THREE.WebGLProgram = ( function () {

}

var lightMapModeDefine = null;

if( parameters.lightMap ) {

switch ( material.lightMapMode ) {
case THREE.MultiplyOperation:
lightMapModeDefine = "LIGHTMAP_MULTIPLY";
break;
case THREE.Modulate2XOperation:
lightMapModeDefine = 'LIGHTMAP_MODULATE2X';
break;
}

}

// console.log( "building new program " );

//
Expand Down Expand Up @@ -24817,6 +24846,7 @@ THREE.WebGLProgram = ( function () {
parameters.envMap ? "#define USE_ENVMAP" : "",
envMapTypeDefine ? "#define " + envMapTypeDefine : "",
parameters.lightMap ? "#define USE_LIGHTMAP" : "",
parameters.lightMap ? "#define " + lightMapModeDefine : "",
parameters.bumpMap ? "#define USE_BUMPMAP" : "",
parameters.normalMap ? "#define USE_NORMALMAP" : "",
parameters.specularMap ? "#define USE_SPECULARMAP" : "",
Expand Down Expand Up @@ -24907,6 +24937,13 @@ THREE.WebGLProgram = ( function () {

}

if( material.lightMapMode == THREE.OverlayOperation ) {

identifiers = identifiers.concat( [ "lm_Intensity", "lm_Center", "lm_Falloff" ] );

}



for ( var u in uniforms ) {

Expand Down
Loading

0 comments on commit ea9d204

Please sign in to comment.