aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/RDGE/Materials/UberMaterial.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/helper-classes/RDGE/Materials/UberMaterial.js')
-rw-r--r--js/helper-classes/RDGE/Materials/UberMaterial.js37
1 files changed, 26 insertions, 11 deletions
diff --git a/js/helper-classes/RDGE/Materials/UberMaterial.js b/js/helper-classes/RDGE/Materials/UberMaterial.js
index f3acdaa6..8385f2d6 100644
--- a/js/helper-classes/RDGE/Materials/UberMaterial.js
+++ b/js/helper-classes/RDGE/Materials/UberMaterial.js
@@ -151,10 +151,10 @@ function UberMaterial()
151 { 151 {
152 // ubershader material properties. 152 // ubershader material properties.
153 'material' : { 153 'material' : {
154 'ambientColor' : this._ambientColor, // material ambient color 154 'ambientColor' : this._ambientColor, // material ambient color
155 'diffuseColor' : this._diffuseColor, // material diffuse color 155 'diffuseColor' : this._diffuseColor, // material diffuse color
156 'specularColor' : this._specularColor, // material specular color 156 'specularColor' : this._specularColor, // material specular color
157 'specularPower' : this._specularPower, // material specular power (shininess) 157 'specularPower' : this._specularPower // material specular power (shininess)
158 }, 158 },
159 159
160 // ubershader supports up to four lights. 160 // ubershader supports up to four lights.
@@ -162,7 +162,7 @@ function UberMaterial()
162 'light0' : this._lights[0], 162 'light0' : this._lights[0],
163 'light1' : this._lights[1], 163 'light1' : this._lights[1],
164 'light2' : this._lights[2], 164 'light2' : this._lights[2],
165 'light3' : this._lights[3], 165 'light3' : this._lights[3]
166 }, 166 },
167 167
168 // uvTransform can be used to scale or offset the texture coordinates. 168 // uvTransform can be used to scale or offset the texture coordinates.
@@ -178,7 +178,7 @@ function UberMaterial()
178 'specularMap' : this._specularMapOb, 178 'specularMap' : this._specularMapOb,
179 179
180 // optional environment map 180 // optional environment map
181 'environmentMap' : this._environmentMapOb, 181 'environmentMap' : this._environmentMapOb
182 }; 182 };
183 183
184 this.updateAmbientColor = function() 184 this.updateAmbientColor = function()
@@ -270,6 +270,7 @@ function UberMaterial()
270 if (renderer && technique) 270 if (renderer && technique)
271 { 271 {
272 var tex = renderer.getTextureByName(value, caps.environmentMap.wrap); 272 var tex = renderer.getTextureByName(value, caps.environmentMap.wrap);
273 this.registerTexture( tex );
273 technique.s_environmentMap.set( tex ); 274 technique.s_environmentMap.set( tex );
274 } 275 }
275 } 276 }
@@ -307,6 +308,7 @@ function UberMaterial()
307 if (renderer && technique) 308 if (renderer && technique)
308 { 309 {
309 var tex = renderer.getTextureByName(value, caps.diffuseMap.wrap); 310 var tex = renderer.getTextureByName(value, caps.diffuseMap.wrap);
311 this.registerTexture( tex );
310 technique.s_diffuseMap.set( tex ); 312 technique.s_diffuseMap.set( tex );
311 } 313 }
312 } 314 }
@@ -344,6 +346,7 @@ function UberMaterial()
344 if (renderer && technique) 346 if (renderer && technique)
345 { 347 {
346 var tex = renderer.getTextureByName(value, caps.specularMap.wrap); 348 var tex = renderer.getTextureByName(value, caps.specularMap.wrap);
349 this.registerTexture( tex );
347 technique.s_specularMap.set( tex ); 350 technique.s_specularMap.set( tex );
348 } 351 }
349 } 352 }
@@ -381,6 +384,7 @@ function UberMaterial()
381 if (renderer && technique) 384 if (renderer && technique)
382 { 385 {
383 var tex = renderer.getTextureByName(value, caps.normalMap.wrap); 386 var tex = renderer.getTextureByName(value, caps.normalMap.wrap);
387 this.registerTexture( tex );
384 technique.s_normalMap.set( tex ); 388 technique.s_normalMap.set( tex );
385 } 389 }
386 } 390 }
@@ -411,8 +415,11 @@ function UberMaterial()
411 return newMat; 415 return newMat;
412 } 416 }
413 417
414 this.init = function() 418 this.init = function( world )
415 { 419 {
420 // save the world
421 if (world) this.setWorld( world );
422
416 // set up the shader 423 // set up the shader
417 this._shader = this.buildUberShader( this._ubershaderCaps ); 424 this._shader = this.buildUberShader( this._ubershaderCaps );
418 425
@@ -579,16 +586,24 @@ function UberMaterial()
579 586
580 renderer = g_Engine.getContext().renderer; 587 renderer = g_Engine.getContext().renderer;
581 if(this._useDiffuseMap) { 588 if(this._useDiffuseMap) {
582 technique.s_diffuseMap.set(renderer.getTextureByName(caps.diffuseMap.texture, caps.diffuseMap.wrap, caps.diffuseMap.mips)); 589 var tex = renderer.getTextureByName(caps.diffuseMap.texture, caps.diffuseMap.wrap, caps.diffuseMap.mips);
590 this.registerTexture( tex );
591 technique.s_diffuseMap.set( tex );
583 } 592 }
584 if(this._useNormalMap) { 593 if(this._useNormalMap) {
585 technique.s_normalMap.set(renderer.getTextureByName(caps.normalMap.texture, caps.normalMap.wrap, caps.normalMap.mips)); 594 var tex = renderer.getTextureByName(caps.normalMap.texture, caps.normalMap.wrap, caps.normalMap.mips);
595 this.registerTexture( tex );
596 technique.s_normalMap.set( tex );
586 } 597 }
587 if(this._useSpecularMap) { 598 if(this._useSpecularMap) {
588 technique.s_specMap.set(renderer.getTextureByName(caps.specularMap.texture, caps.specularMap.wrap)); 599 var tex = renderer.getTextureByName(caps.specularMap.texture, caps.specularMap.wrap);
600 this.registerTexture( tex );
601 technique.s_specMap.set( tex );
589 } 602 }
590 if(this._useEnvironmentMap) { 603 if(this._useEnvironmentMap) {
591 technique.s_envMap.set(renderer.getTextureByName(caps.environmentMap.texture, caps.environmentMap.wrap)); 604 var tex = renderer.getTextureByName(caps.environmentMap.texture, caps.environmentMap.wrap);
605 this.registerTexture( tex );
606 technique.s_envMap.set( tex );
592 technique.u_envReflection.set([ caps.environmentMap.envReflection || 1.0 ] ); 607 technique.u_envReflection.set([ caps.environmentMap.envReflection || 1.0 ] );
593 } 608 }
594 609