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.js112
1 files changed, 61 insertions, 51 deletions
diff --git a/js/lib/rdge/materials/z-invert-material.js b/js/lib/rdge/materials/z-invert-material.js
index ef93584d..ead3bed2 100644
--- a/js/lib/rdge/materials/z-invert-material.js
+++ b/js/lib/rdge/materials/z-invert-material.js
@@ -47,24 +47,24 @@ var ZInvertMaterial = function ZInvertMaterial() {
47 // array textures indexed by shader uniform name 47 // array textures indexed by shader uniform name
48 this._glTextures = []; 48 this._glTextures = [];
49 49
50 this.isAnimated = function() { return true; }; 50 this.isAnimated = function() { return true; };
51 this.getShaderDef = function() { return zInvertMaterialDef; }; 51 this.getShaderDef = function() { return zInvertMaterialDef; };
52 52
53 /////////////////////////////////////////////////////////////////////// 53 ///////////////////////////////////////////////////////////////////////
54 // Properties 54 // Properties
55 /////////////////////////////////////////////////////////////////////// 55 ///////////////////////////////////////////////////////////////////////
56 // all defined in parent PulseMaterial.js 56 // all defined in parent PulseMaterial.js
57 // load the local default value 57 // load the local default value
58 this._propNames = ["u_tex0", "u_speed"]; 58 this._propNames = ["u_tex0", "u_speed"];
59 this._propLabels = ["Texture map", "Speed"]; 59 this._propLabels = ["Texture map", "Speed"];
60 this._propTypes = ["file", "float"]; 60 this._propTypes = ["file", "float"];
61 61
62 var u_tex_index = 0, 62 var u_tex_index = 0,
63 u_speed_index = 1; 63 u_speed_index = 1;
64 64
65 this._propValues = []; 65 this._propValues = [];
66 this._propValues[ this._propNames[u_tex_index ] ] = this._defaultTexMap.slice(0); 66 this._propValues[ this._propNames[u_tex_index ] ] = this._defaultTexMap.slice(0);
67 this._propValues[ this._propNames[u_speed_index ] ] = 1.0; 67 this._propValues[ this._propNames[u_speed_index ] ] = 1.0;
68 68
69 /////////////////////////////////////////////////////////////////////// 69 ///////////////////////////////////////////////////////////////////////
70 // Methods 70 // Methods
@@ -89,10 +89,20 @@ var ZInvertMaterial = function ZInvertMaterial() {
89 } 89 }
90 90
91 // set the shader values in the shader 91 // set the shader values in the shader
92 this.setShaderValues(); 92 this.setShaderValues();
93 this.setResolution([world.getViewportWidth(), world.getViewportHeight()]); 93 this.setResolution([world.getViewportWidth(), world.getViewportHeight()]);
94 this.update(0); 94 this.update(0);
95 }; 95 };
96
97 this.resetToDefault = function()
98 {
99 this._propValues[ this._propNames[u_tex_index ] ] = this._defaultTexMap.slice(0);
100 this._propValues[ this._propNames[u_speed_index ] ] = 1.0;
101
102 var nProps = this._propNames.length;
103 for (var i=0; i<nProps; i++)
104 this.setProperty( this._propNames[i], this._propValues[this._propNames[i]] );
105 };
96}; 106};
97 107
98/////////////////////////////////////////////////////////////////////////////////////// 108///////////////////////////////////////////////////////////////////////////////////////
@@ -101,42 +111,42 @@ var ZInvertMaterial = function ZInvertMaterial() {
101// shader spec (can also be loaded from a .JSON file, or constructed at runtime) 111// shader spec (can also be loaded from a .JSON file, or constructed at runtime)
102var zInvertMaterialDef = 112var zInvertMaterialDef =
103{ 'shaders': 113{ 'shaders':
104 { 114 {
105 'defaultVShader': "assets/shaders/Basic.vert.glsl", 115 'defaultVShader': "assets/shaders/Basic.vert.glsl",
106 'defaultFShader': "assets/shaders/ZInvert.frag.glsl" 116 'defaultFShader': "assets/shaders/ZInvert.frag.glsl"
107 }, 117 },
108 'techniques': 118 'techniques':
109 { 119 {
110 'default': 120 'default':
111 [ 121 [
112 { 122 {
113 'vshader': 'defaultVShader', 123 'vshader': 'defaultVShader',
114 'fshader': 'defaultFShader', 124 'fshader': 'defaultFShader',
115 // attributes 125 // attributes
116 'attributes': 126 'attributes':
117 { 127 {
118 'vert': { 'type': 'vec3' }, 128 'vert': { 'type': 'vec3' },
119 'normal': { 'type': 'vec3' }, 129 'normal': { 'type': 'vec3' },
120 'texcoord': { 'type': 'vec2' } 130 'texcoord': { 'type': 'vec2' }
121 }, 131 },
122 // parameters 132 // parameters
123 'params': 133 'params':
124 { 134 {
125 'u_tex0': { 'type': 'tex2d' }, 135 'u_tex0': { 'type': 'tex2d' },
126 'u_time': { 'type': 'float' }, 136 'u_time': { 'type': 'float' },
127 'u_speed': { 'type': 'float' }, 137 'u_speed': { 'type': 'float' },
128 'u_resolution': { 'type': 'vec2' } 138 'u_resolution': { 'type': 'vec2' }
129 }, 139 },
130 140
131 // render states 141 // render states
132 'states': 142 'states':
133 { 143 {
134 'depthEnable': true, 144 'depthEnable': true,
135 'offset': [1.0, 0.1] 145 'offset': [1.0, 0.1]
136 } 146 }
137 } 147 }
138 ] 148 ]
139 } 149 }
140}; 150};
141 151
142ZInvertMaterial.prototype = new PulseMaterial(); 152ZInvertMaterial.prototype = new PulseMaterial();