diff options
Diffstat (limited to 'js/helper-classes/RDGE/Materials/UberMaterial.js')
-rw-r--r-- | js/helper-classes/RDGE/Materials/UberMaterial.js | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/js/helper-classes/RDGE/Materials/UberMaterial.js b/js/helper-classes/RDGE/Materials/UberMaterial.js index a8254465..afb745d1 100644 --- a/js/helper-classes/RDGE/Materials/UberMaterial.js +++ b/js/helper-classes/RDGE/Materials/UberMaterial.js | |||
@@ -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 | ||