From db2bb0ab5d2747f0d07878e3b8a7d2d10c755110 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Thu, 7 Jun 2012 17:07:21 -0700 Subject: Material cleanup --- js/lib/rdge/materials/deform-material.js | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'js/lib/rdge/materials/deform-material.js') diff --git a/js/lib/rdge/materials/deform-material.js b/js/lib/rdge/materials/deform-material.js index 70742c77..91202b24 100644 --- a/js/lib/rdge/materials/deform-material.js +++ b/js/lib/rdge/materials/deform-material.js @@ -14,7 +14,7 @@ var DeformMaterial = function DeformMaterial() { this._name = "DeformMaterial"; this._shaderName = "deform"; - this._texMap = 'assets/images/rocky-normal.jpg'; + this._defaultTexMap = 'assets/images/rocky-normal.jpg'; this._time = 0.0; this._dTime = 0.01; @@ -24,11 +24,21 @@ var DeformMaterial = function DeformMaterial() { /////////////////////////////////////////////////////////////////////// // all defined in parent PulseMaterial.js // load the local default value - this._propValues[this._propNames[0]] = this._texMap.slice(0); + var u_tex0_index = 0; + this._propNames = ["u_tex0", "u_speed" ]; + this._propLabels = ["Texture map", "Speed" ]; + this._propTypes = ["file", "float" ]; + this._propValues = []; + this._propValues[this._propNames[0]] = this._defaultTexMap.slice(0); + this._propValues[this._propNames[1]] = 1.0; + + this._propValues[ this._propNames[ u_tex0_index] ] = this._defaultTexMap.slice(0); /////////////////////////////////////////////////////////////////////// // Material Property Accessors /////////////////////////////////////////////////////////////////////// + this.isAnimated = function() { return true; }; + this.getShaderDef = function() { return pulseMaterialDef; } /////////////////////////////////////////////////////////////////////// @@ -56,12 +66,8 @@ var DeformMaterial = function DeformMaterial() { this._shader['default'].u_time.set([this._time]); } - // set up the texture - var texMapName = this._propValues[this._propNames[0]]; - this._glTex = new Texture( world, texMapName ); - // set the shader values in the shader - this.updateTexture(); + this.setShaderValues(); this.setResolution([world.getViewportWidth(), world.getViewportHeight()]); this.update(0); }; @@ -96,6 +102,7 @@ var deformMaterialDef = { 'u_tex0': { 'type' : 'tex2d' }, 'u_time' : { 'type' : 'float' }, + 'u_speed' : { 'type' : 'float' }, 'u_resolution' : { 'type' : 'vec2' } }, -- cgit v1.2.3