aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge/materials/z-invert-material.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib/rdge/materials/z-invert-material.js')
-rw-r--r--js/lib/rdge/materials/z-invert-material.js48
1 files changed, 25 insertions, 23 deletions
diff --git a/js/lib/rdge/materials/z-invert-material.js b/js/lib/rdge/materials/z-invert-material.js
index fc7632eb..f1526b39 100644
--- a/js/lib/rdge/materials/z-invert-material.js
+++ b/js/lib/rdge/materials/z-invert-material.js
@@ -6,6 +6,7 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
6 6
7 7
8var PulseMaterial = require("js/lib/rdge/materials/pulse-material").PulseMaterial; 8var PulseMaterial = require("js/lib/rdge/materials/pulse-material").PulseMaterial;
9var Texture = require("js/lib/rdge/texture").Texture;
9 10
10var ZInvertMaterial = function ZInvertMaterial() { 11var ZInvertMaterial = function ZInvertMaterial() {
11 /////////////////////////////////////////////////////////////////////// 12 ///////////////////////////////////////////////////////////////////////
@@ -14,36 +15,36 @@ var ZInvertMaterial = function ZInvertMaterial() {
14 this._name = "ZInvertMaterial"; 15 this._name = "ZInvertMaterial";
15 this._shaderName = "zinvert"; 16 this._shaderName = "zinvert";
16 17
17 this._texMap = 'assets/images/rocky-normal.jpg'; 18 this._defaultTexMap = 'assets/images/rocky-normal.jpg';
18 19
19 this._time = 0.0; 20 this._time = 0.0;
20 this._dTime = 0.01; 21 this._dTime = 0.01;
21 22
22 /////////////////////////////////////////////////////////////////////// 23 // array textures indexed by shader uniform name
23 // Properties 24 this._glTextures = [];
24 /////////////////////////////////////////////////////////////////////// 25
25 // all defined in parent PulseMaterial.js 26 this.isAnimated = function() { return true; };
26 // load the local default value 27 this.getShaderDef = function() { return zInvertMaterialDef; };
27 this._propValues[this._propNames[0]] = this._texMap.slice(0); 28
29 ///////////////////////////////////////////////////////////////////////
30 // Properties
31 ///////////////////////////////////////////////////////////////////////
32 // all defined in parent PulseMaterial.js
33 // load the local default value
34 this._propNames = ["u_tex0", "u_speed"];
35 this._propLabels = ["Texture map", "Speed"];
36 this._propTypes = ["file", "float"];
37
38 var u_tex_index = 0,
39 u_speed_index = 1;
40
41 this._propValues = [];
42 this._propValues[ this._propNames[u_tex_index ] ] = this._defaultTexMap.slice(0);
43 this._propValues[ this._propNames[u_speed_index ] ] = 1.0;
28 44
29 /////////////////////////////////////////////////////////////////////// 45 ///////////////////////////////////////////////////////////////////////
30 // Methods 46 // Methods
31 /////////////////////////////////////////////////////////////////////// 47 ///////////////////////////////////////////////////////////////////////
32 // duplicate method required
33 this.dup = function (world) {
34 // allocate a new uber material
35 var newMat = new ZInvertMaterial();
36
37 // copy over the current values;
38 var propNames = [], propValues = [], propTypes = [], propLabels = [];
39 this.getAllProperties(propNames, propValues, propTypes, propLabels);
40 var n = propNames.length;
41 for (var i = 0; i < n; i++) {
42 newMat.setProperty(propNames[i], propValues[i]);
43 }
44
45 return newMat;
46 };
47 48
48 this.init = function (world) { 49 this.init = function (world) {
49 // save the world 50 // save the world
@@ -64,7 +65,7 @@ var ZInvertMaterial = function ZInvertMaterial() {
64 } 65 }
65 66
66 // set the shader values in the shader 67 // set the shader values in the shader
67 this.updateTexture(); 68 this.setShaderValues();
68 this.setResolution([world.getViewportWidth(), world.getViewportHeight()]); 69 this.setResolution([world.getViewportWidth(), world.getViewportHeight()]);
69 this.update(0); 70 this.update(0);
70 }; 71 };
@@ -99,6 +100,7 @@ var zInvertMaterialDef =
99 { 100 {
100 'u_tex0': { 'type': 'tex2d' }, 101 'u_tex0': { 'type': 'tex2d' },
101 'u_time': { 'type': 'float' }, 102 'u_time': { 'type': 'float' },
103 'u_speed': { 'type': 'float' },
102 'u_resolution': { 'type': 'vec2' } 104 'u_resolution': { 'type': 'vec2' }
103 }, 105 },
104 106