Skip to content

Commit 522203a

Browse files
committed
Merge pull request mrdoob#5809 from bhouston/remove_material_ambient
Remove material.ambient, no need for a secondary surface color just for ambient light
2 parents 48591ba + c5f777f commit 522203a

File tree

69 files changed

+99
-186
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+99
-186
lines changed

editor/js/Sidebar.Material.js

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -408,12 +408,6 @@ Sidebar.Material = function ( editor ) {
408408

409409
}
410410

411-
if ( material.ambient !== undefined ) {
412-
413-
material.ambient.setHex( materialAmbient.getHexValue() );
414-
415-
}
416-
417411
if ( material.emissive !== undefined ) {
418412

419413
material.emissive.setHex( materialEmissive.getHexValue() );
@@ -639,7 +633,6 @@ Sidebar.Material = function ( editor ) {
639633
var properties = {
640634
'name': materialNameRow,
641635
'color': materialColorRow,
642-
'ambient': materialAmbientRow,
643636
'emissive': materialEmissiveRow,
644637
'specular': materialSpecularRow,
645638
'shininess': materialShininessRow,
@@ -703,12 +696,6 @@ Sidebar.Material = function ( editor ) {
703696

704697
}
705698

706-
if ( material.ambient !== undefined ) {
707-
708-
materialAmbient.setHexValue( material.ambient.getHexString() );
709-
710-
}
711-
712699
if ( material.emissive !== undefined ) {
713700

714701
materialEmissive.setHexValue( material.emissive.getHexString() );

examples/js/ShaderSkin.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ THREE.ShaderSkin = {
3838

3939
"diffuse": { type: "c", value: new THREE.Color( 0xeeeeee ) },
4040
"specular": { type: "c", value: new THREE.Color( 0x111111 ) },
41-
"ambient": { type: "c", value: new THREE.Color( 0x050505 ) },
4241
"opacity": { type: "f", value: 1 },
4342

4443
"uRoughness": { type: "f", value: 0.15 },
@@ -65,7 +64,6 @@ THREE.ShaderSkin = {
6564
"uniform bool enableBump;",
6665
"uniform bool enableSpecular;",
6766

68-
"uniform vec3 ambient;",
6967
"uniform vec3 diffuse;",
7068
"uniform vec3 specular;",
7169
"uniform float opacity;",
@@ -295,7 +293,7 @@ THREE.ShaderSkin = {
295293
"totalLight += hemiTotal;",
296294
"#endif",
297295

298-
"gl_FragColor.xyz = gl_FragColor.xyz * ( totalLight + ambientLightColor * ambient ) + specularTotal;",
296+
"gl_FragColor.xyz = gl_FragColor.xyz * ( totalLight + ambientLightColor * diffuse ) + specularTotal;",
299297

300298
THREE.ShaderChunk[ "shadowmap_fragment" ],
301299
THREE.ShaderChunk[ "linear_to_gamma_fragment" ],
@@ -377,7 +375,6 @@ THREE.ShaderSkin = {
377375

378376
"diffuse": { type: "c", value: new THREE.Color( 0xeeeeee ) },
379377
"specular": { type: "c", value: new THREE.Color( 0x111111 ) },
380-
"ambient": { type: "c", value: new THREE.Color( 0x050505 ) },
381378
"opacity": { type: "f", value: 1 },
382379

383380
"uRoughness": { type: "f", value: 0.15 },
@@ -389,7 +386,6 @@ THREE.ShaderSkin = {
389386

390387
fragmentShader: [
391388

392-
"uniform vec3 ambient;",
393389
"uniform vec3 diffuse;",
394390
"uniform vec3 specular;",
395391
"uniform float opacity;",
@@ -595,7 +591,7 @@ THREE.ShaderSkin = {
595591

596592
"gl_FragColor.xyz *= pow( colDiffuse.xyz, vec3( 0.5 ) );",
597593

598-
"gl_FragColor.xyz += ambientLightColor * ambient * colDiffuse.xyz + specularTotal;",
594+
"gl_FragColor.xyz += ambientLightColor * diffuse * colDiffuse.xyz + specularTotal;",
599595

600596
"#ifndef VERSION1",
601597

examples/js/ShaderTerrain.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ THREE.ShaderTerrain = {
4242

4343
"diffuse": { type: "c", value: new THREE.Color( 0xeeeeee ) },
4444
"specular": { type: "c", value: new THREE.Color( 0x111111 ) },
45-
"ambient": { type: "c", value: new THREE.Color( 0x050505 ) },
4645
"shininess": { type: "f", value: 30 },
4746
"opacity": { type: "f", value: 1 },
4847

@@ -57,7 +56,6 @@ THREE.ShaderTerrain = {
5756

5857
fragmentShader: [
5958

60-
"uniform vec3 ambient;",
6159
"uniform vec3 diffuse;",
6260
"uniform vec3 specular;",
6361
"uniform float shininess;",
@@ -288,8 +286,8 @@ THREE.ShaderTerrain = {
288286

289287
"#endif",
290288

291-
//"gl_FragColor.xyz = gl_FragColor.xyz * ( totalDiffuse + ambientLightColor * ambient) + totalSpecular;",
292-
"gl_FragColor.xyz = gl_FragColor.xyz * ( totalDiffuse + ambientLightColor * ambient + totalSpecular );",
289+
//"gl_FragColor.xyz = gl_FragColor.xyz * ( totalDiffuse + ambientLightColor * diffuse ) + totalSpecular;",
290+
"gl_FragColor.xyz = gl_FragColor.xyz * ( totalDiffuse + ambientLightColor * diffuse + totalSpecular );",
293291

294292
THREE.ShaderChunk[ "shadowmap_fragment" ],
295293
THREE.ShaderChunk[ "linear_to_gamma_fragment" ],

examples/js/exporters/SceneExporter.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,6 @@ THREE.SceneExporter.prototype = {
472472
' "type" : "MeshLambertMaterial",',
473473
' "parameters" : {',
474474
' "color" : ' + m.color.getHex() + ',',
475-
' "ambient" : ' + m.ambient.getHex() + ',',
476475
' "emissive" : ' + m.emissive.getHex() + ',',
477476

478477
m.map ? ' "map" : ' + LabelString( getTextureName( m.map ) ) + ',' : '',
@@ -498,7 +497,6 @@ THREE.SceneExporter.prototype = {
498497
' "type" : "MeshPhongMaterial",',
499498
' "parameters" : {',
500499
' "color" : ' + m.color.getHex() + ',',
501-
' "ambient" : ' + m.ambient.getHex() + ',',
502500
' "emissive" : ' + m.emissive.getHex() + ',',
503501
' "specular" : ' + m.specular.getHex() + ',',
504502
' "shininess" : ' + m.shininess + ',',

examples/js/loaders/AssimpJSONLoader.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,6 @@ THREE.AssimpJSONLoader.prototype = {
264264
else if(prop.key === '$clr.specular') {
265265
init_props.specular = toColor(prop.value);
266266
}
267-
else if(prop.key === '$clr.ambient') {
268-
init_props.ambient = toColor(prop.value);
269-
}
270267
else if(prop.key === '$clr.emissive') {
271268
init_props.emissive = toColor(prop.value);
272269
}
@@ -281,10 +278,6 @@ THREE.AssimpJSONLoader.prototype = {
281278
}
282279
}
283280

284-
if(!init_props.ambient) {
285-
init_props.ambient = init_props.color;
286-
}
287-
288281
// note: three.js does not like it when a texture is added after the geometry
289282
// has been rendered once, see http://stackoverflow.com/questions/16531759/.
290283
// for this reason we fill all slots upfront with default textures

examples/js/loaders/BabylonLoader.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ THREE.BabylonLoader.prototype = {
5151

5252
var material = new THREE.MeshPhongMaterial();
5353
material.name = data.name;
54-
material.ambient.fromArray( data.ambient );
5554
material.color.fromArray( data.diffuse );
5655
material.emissive.fromArray( data.emissive );
5756
material.specular.fromArray( data.specular );

examples/js/loaders/ColladaLoader.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3584,7 +3584,6 @@ THREE.ColladaLoader = function () {
35843584

35853585
switch ( child.nodeName ) {
35863586

3587-
case 'ambient':
35883587
case 'emission':
35893588
case 'diffuse':
35903589
case 'specular':

examples/js/loaders/MTLLoader.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,6 @@ THREE.MTLLoader.MaterialCreator.prototype = {
297297

298298
// Ambient color (color under shadow) using RGB values
299299

300-
params[ 'ambient' ] = new THREE.Color().fromArray( value );
301-
302300
break;
303301

304302
case 'ks':
@@ -351,7 +349,6 @@ THREE.MTLLoader.MaterialCreator.prototype = {
351349

352350
if ( params[ 'diffuse' ] ) {
353351

354-
if ( !params[ 'ambient' ]) params[ 'ambient' ] = params[ 'diffuse' ];
355352
params[ 'color' ] = params[ 'diffuse' ];
356353

357354
}

examples/js/loaders/gltf/glTFLoader.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -785,11 +785,6 @@ THREE.glTFLoader.prototype.load = function( url, callback ) {
785785
params.shininess = shininess;
786786
}
787787

788-
if (!(values.ambient === undefined) && !(typeof(values.ambient) == 'string'))
789-
{
790-
params.ambient = RgbArraytoHex(values.ambient);
791-
}
792-
793788
if (!(values.emission === undefined))
794789
{
795790
params.emissive = RgbArraytoHex(values.emission);

examples/js/renderers/SoftwareRenderer.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,9 +300,9 @@ THREE.SoftwareRenderer = function ( parameters ) {
300300
}
301301

302302
function getPalette( material, bSimulateSpecular ) {
303-
var diffuseR = material.ambient.r + material.color.r * 255;
304-
var diffuseG = material.ambient.g + material.color.g * 255;
305-
var diffuseB = material.ambient.b + material.color.b * 255;
303+
var diffuseR = material.color.r * 255;
304+
var diffuseG = material.color.g * 255;
305+
var diffuseB = material.color.b * 255;
306306
var palette = new Uint8Array(256*3);
307307

308308
if ( bSimulateSpecular ) {

0 commit comments

Comments
 (0)