aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge/materials/twist-vert-material.js
diff options
context:
space:
mode:
authorhwc4872012-05-03 16:42:56 -0700
committerhwc4872012-05-03 16:42:56 -0700
commitd21aaca3d7093b6af968b7f9f764ab54e004f02b (patch)
treeaae070c04d18bc30fda6b133ce3d7de7b621f8b2 /js/lib/rdge/materials/twist-vert-material.js
parente791a7a821221d206c40427fd2695b42a5bacf5f (diff)
downloadninja-d21aaca3d7093b6af968b7f9f764ab54e004f02b.tar.gz
Cleanup of indirect textures.
Diffstat (limited to 'js/lib/rdge/materials/twist-vert-material.js')
-rw-r--r--js/lib/rdge/materials/twist-vert-material.js43
1 files changed, 37 insertions, 6 deletions
diff --git a/js/lib/rdge/materials/twist-vert-material.js b/js/lib/rdge/materials/twist-vert-material.js
index b27c0b11..7d9dd6d6 100644
--- a/js/lib/rdge/materials/twist-vert-material.js
+++ b/js/lib/rdge/materials/twist-vert-material.js
@@ -28,6 +28,9 @@ var TwistVertMaterial = function TwistVertMaterial()
28 this._tex0 = 'assets/images/rocky-normal.jpg'; 28 this._tex0 = 'assets/images/rocky-normal.jpg';
29 this._tex1 = 'assets/images/metal.png'; 29 this._tex1 = 'assets/images/metal.png';
30 30
31 this._glTex0;
32 this._glTex1;
33
31 this._angle = 0.0; 34 this._angle = 0.0;
32 this._deltaTime = 0.01; 35 this._deltaTime = 0.01;
33 36
@@ -79,6 +82,9 @@ var TwistVertMaterial = function TwistVertMaterial()
79 this._materialNode = RDGE.createMaterialNode("twistVertMaterial" + "_" + world.generateUniqueNodeID()); 82 this._materialNode = RDGE.createMaterialNode("twistVertMaterial" + "_" + world.generateUniqueNodeID());
80 this._materialNode.setShader(this._shader); 83 this._materialNode.setShader(this._shader);
81 84
85 // set up the texture maps
86 this.updateTextures();
87
82 // initialize the twist vert properties 88 // initialize the twist vert properties
83 this.updateShaderValues(); 89 this.updateShaderValues();
84 }; 90 };
@@ -146,7 +152,9 @@ var TwistVertMaterial = function TwistVertMaterial()
146 { 152 {
147 if (this._shader && this._shader.twistMe) 153 if (this._shader && this._shader.twistMe)
148 { 154 {
149 var angle = this._angle; 155 var technique = this._shader.twistMe;
156
157 var angle = this._angle;
150 angle += this._deltaTime; 158 angle += this._deltaTime;
151 if (angle > this._propValues["u_twistAmount"]) 159 if (angle > this._propValues["u_twistAmount"])
152 { 160 {
@@ -160,6 +168,25 @@ var TwistVertMaterial = function TwistVertMaterial()
160 } 168 }
161 this._angle = angle; 169 this._angle = angle;
162 this._shader.twistMe["u_twistAmount"].set([angle]); 170 this._shader.twistMe["u_twistAmount"].set([angle]);
171
172 var tex;
173 if (this._glTex0)
174 {
175 if (this._glTex0.isAnimated())
176 this._glTex0.render();
177 tex = this._glTex0.getTexture();
178 if (tex)
179 technique.u_tex0.set( tex );
180 }
181 if (this._glTex1)
182 {
183 if (this._glTex1.isAnimated())
184 this._glTex1.render();
185 tex = this._glTex1.getTexture();
186 if (tex)
187 technique.u_tex1.set( tex );
188 }
189
163 } 190 }
164 }; 191 };
165 192
@@ -195,17 +222,22 @@ var TwistVertMaterial = function TwistVertMaterial()
195 var material = this._materialNode; 222 var material = this._materialNode;
196 if (material) 223 if (material)
197 { 224 {
198 var technique = material.shaderProgram['default']; 225 var technique = material.shaderProgram['twistMe'];
199 var renderer = RDGE.globals.engine.getContext().renderer; 226 var renderer = RDGE.globals.engine.getContext().renderer;
200 if (renderer && technique) 227 if (renderer && technique)
201 { 228 {
202 var texMapName = this._propValues[this._propNames[5]]; 229 var texMapName;
230 texMapName = this._propValues[this._propNames[5]];
203 var wrap = 'REPEAT', mips = true; 231 var wrap = 'REPEAT', mips = true;
204 var tex = this.loadTexture(texMapName, wrap, mips); 232 //var tex = this.loadTexture(texMapName, wrap, mips);
233 this._glTex0 = new Texture( this.getWorld(), texMapName, wrap, mips );
234 tex = this._glTex0.getTexture();
205 if (tex) technique.u_tex0.set(tex); 235 if (tex) technique.u_tex0.set(tex);
206 236
207 texMapName = this._propValues[this._propNames[6]]; 237 texMapName = this._propValues[this._propNames[6]];
208 tex = this.loadTexture(texMapName, wrap, mips); 238 //tex = this.loadTexture(texMapName, wrap, mips);
239 this._glTex1 = new Texture( this.getWorld(), texMapName, wrap, mips );
240 tex = this._glTex1.getTexture();
209 if (tex) technique.u_tex1.set(tex); 241 if (tex) technique.u_tex1.set(tex);
210 } 242 }
211 } 243 }
@@ -242,7 +274,6 @@ twistVertShaderDef =
242 274
243 'u_limit1': { 'type': 'float' }, 275 'u_limit1': { 'type': 'float' },
244 'u_limit2': { 'type': 'float' }, 276 'u_limit2': { 'type': 'float' },
245 'u_limit3': { 'type': 'float' },
246 'u_minVal': { 'type': 'float' }, 277 'u_minVal': { 'type': 'float' },
247 'u_maxVal': { 'type': 'float' }, 278 'u_maxVal': { 'type': 'float' },
248 'u_center': { 'type': 'float' }, 279 'u_center': { 'type': 'float' },