Skip to content

Commit 6475b29

Browse files
committed
Restored aoMap to MeshBasicMaterial
1 parent 86333f9 commit 6475b29

5 files changed

Lines changed: 41 additions & 9 deletions

File tree

docs/api/materials/MeshBasicMaterial.html

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ <h3>[name]( [page:Object parameters] )</h3>
2424
<div>parameters is an object with one or more properties defining the material's appearance.</div>
2525
<div>
2626
color — geometry color in hexadecimal. Default is 0xffffff.<br />
27-
map — Sets the texture map. Default is null <br />
27+
map — Set texture map. Default is null <br />
28+
aoMap — Set ambient occlusion map. Default is null <br />
2829
specularMap — Set specular map. Default is null.<br />
2930
alphaMap — Set alpha map. Default is null.<br />
3031
envMap — Set env map. Default is null.<br />
@@ -44,6 +45,14 @@ <h2>Properties</h2>
4445
<h3>[property:Integer color]</h3>
4546
<div>Sets the color of the geometry. Default is 0xffffff.</div>
4647

48+
<h3>[property:Texture map]</h3>
49+
<div>
50+
Set texture map. Default is null.
51+
</div>
52+
53+
<h3>[property:Texture aoMap]</h3>
54+
<div>Set ambient occlusion map. Default is null.</div>
55+
4756
<h3>[property:Texture specularMap]</h3>
4857
<div>Set specular map. Default is null.</div>
4958

@@ -86,11 +95,6 @@ <h3>[property:Boolean skinning]</h3>
8695
<h3>[property:Boolean morphTargets]</h3>
8796
<div>Define whether the material uses morphTargets. Default is false.</div>
8897

89-
<h3>[property:Texture map]</h3>
90-
<div>
91-
Sets the texture map. Default is null.
92-
</div>
93-
9498
<h3>[property:number combine]</h3>
9599
<div>
96100
How to combine the result of the surface's color with the environment map, if any.

docs/api/materials/MeshPhongMaterial.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ <h3>[name]([page:Object parameters])</h3>
2424
</div>
2525
<div>
2626
color — geometry color in hexadecimal. Default is 0xffffff.<br />
27-
map — Sets the texture map. Default is null <br />
27+
map — Set texture map. Default is null <br />
2828
lightMap — Set light map. Default is null.<br />
29+
aoMap — Set ao map. Default is null.<br />
2930
specularMap — Set specular map. Default is null.<br />
3031
alphaMap — Set alpha map. Default is null.<br />
3132
envMap — Set env map. Default is null.<br />
@@ -80,6 +81,9 @@ <h3>[property:Texture map]</h3>
8081
<h3>[property:Texture lightMap]</h3>
8182
<div>Set light map. Default is null.</div>
8283

84+
<h3>[property:Texture aoMap]</h3>
85+
<div>Set ambient occlusion map. Default is null.</div>
86+
8387
<h3>[property:Texture bumpMap]</h3>
8488
<div>
8589
The texture to create a bump map. The black and white values map to the perceived depth in relation to the lights.

src/materials/MeshBasicMaterial.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
* opacity: <float>,
88
* map: new THREE.Texture( <Image> ),
99
*
10+
* aoMap: new THREE.Texture( <Image> ),
11+
* aoMapIntensity: <float>
12+
*
1013
* specularMap: new THREE.Texture( <Image> ),
1114
*
1215
* alphaMap: new THREE.Texture( <Image> ),
@@ -43,6 +46,9 @@ THREE.MeshBasicMaterial = function ( parameters ) {
4346

4447
this.map = null;
4548

49+
this.aoMap = null;
50+
this.aoMapIntensity = 1.0;
51+
4652
this.specularMap = null;
4753

4854
this.alphaMap = null;
@@ -83,6 +89,9 @@ THREE.MeshBasicMaterial.prototype.clone = function () {
8389

8490
material.map = this.map;
8591

92+
material.aoMap = this.aoMap;
93+
material.aoMapIntensity = this.aoMapIntensity;
94+
8695
material.specularMap = this.specularMap;
8796

8897
material.alphaMap = this.alphaMap;

src/renderers/WebGLRenderer.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2255,6 +2255,10 @@ THREE.WebGLRenderer = function ( parameters ) {
22552255

22562256
refreshUniformsLambert( m_uniforms, material );
22572257

2258+
} else if ( material instanceof THREE.MeshBasicMaterial ) {
2259+
2260+
refreshUniformsBasic( m_uniforms, material );
2261+
22582262
} else if ( material instanceof THREE.MeshDepthMaterial ) {
22592263

22602264
m_uniforms.mNear.value = camera.near;
@@ -2438,6 +2442,13 @@ THREE.WebGLRenderer = function ( parameters ) {
24382442

24392443
}
24402444

2445+
function refreshUniformsBasic ( uniforms, material ) {
2446+
2447+
uniforms.aoMap.value = material.aoMap;
2448+
uniforms.aoMapIntensity.value = material.aoMapIntensity;
2449+
2450+
}
2451+
24412452
function refreshUniformsLights ( uniforms, lights ) {
24422453

24432454
uniforms.ambientLightColor.value = lights.ambient;

src/renderers/shaders/ShaderLib.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ THREE.ShaderLib = {
1414
uniforms: THREE.UniformsUtils.merge( [
1515

1616
THREE.UniformsLib[ "common" ],
17+
THREE.UniformsLib[ "aomap" ],
1718
THREE.UniformsLib[ "fog" ],
1819
THREE.UniformsLib[ "shadowmap" ]
1920

@@ -70,6 +71,7 @@ THREE.ShaderLib = {
7071
THREE.ShaderChunk[ "uv2_pars_fragment" ],
7172
THREE.ShaderChunk[ "map_pars_fragment" ],
7273
THREE.ShaderChunk[ "alphamap_pars_fragment" ],
74+
THREE.ShaderChunk[ "aomap_pars_fragment" ],
7375
THREE.ShaderChunk[ "envmap_pars_fragment" ],
7476
THREE.ShaderChunk[ "fog_pars_fragment" ],
7577
THREE.ShaderChunk[ "shadowmap_pars_fragment" ],
@@ -78,17 +80,19 @@ THREE.ShaderLib = {
7880

7981
"void main() {",
8082

81-
" vec3 outgoingLight = vec3( 0.0 );", // outgoing light does not have an alpha, the surface does
83+
" vec3 outgoingLight = vec3( 0.0 );",
8284
" vec4 diffuseColor = vec4( diffuse, opacity );",
85+
" vec3 totalAmbientLight = vec3( 1.0 );", // hardwired
8386

8487
THREE.ShaderChunk[ "logdepthbuf_fragment" ],
8588
THREE.ShaderChunk[ "map_fragment" ],
8689
THREE.ShaderChunk[ "color_fragment" ],
8790
THREE.ShaderChunk[ "alphamap_fragment" ],
8891
THREE.ShaderChunk[ "alphatest_fragment" ],
8992
THREE.ShaderChunk[ "specularmap_fragment" ],
93+
THREE.ShaderChunk[ "aomap_fragment" ],
9094

91-
" outgoingLight = diffuseColor.rgb;", // simple shader
95+
" outgoingLight = diffuseColor.rgb * totalAmbientLight;", // simple shader
9296

9397
THREE.ShaderChunk[ "envmap_fragment" ],
9498
THREE.ShaderChunk[ "shadowmap_fragment" ], // TODO: Shadows on an otherwise unlit surface doesn't make sense.

0 commit comments

Comments
 (0)