diff options
author | hwc487 | 2012-05-03 16:42:56 -0700 |
---|---|---|
committer | hwc487 | 2012-05-03 16:42:56 -0700 |
commit | d21aaca3d7093b6af968b7f9f764ab54e004f02b (patch) | |
tree | aae070c04d18bc30fda6b133ce3d7de7b621f8b2 /js/lib/rdge | |
parent | e791a7a821221d206c40427fd2695b42a5bacf5f (diff) | |
download | ninja-d21aaca3d7093b6af968b7f9f764ab54e004f02b.tar.gz |
Cleanup of indirect textures.
Diffstat (limited to 'js/lib/rdge')
-rw-r--r-- | js/lib/rdge/materials/cloud-material.js | 12 | ||||
-rwxr-xr-x | js/lib/rdge/materials/material.js | 7 | ||||
-rw-r--r-- | js/lib/rdge/materials/pulse-material.js | 14 | ||||
-rw-r--r-- | js/lib/rdge/materials/twist-vert-material.js | 43 | ||||
-rwxr-xr-x | js/lib/rdge/materials/uber-material.js | 24 | ||||
-rw-r--r-- | js/lib/rdge/texture.js | 2 |
6 files changed, 37 insertions, 65 deletions
diff --git a/js/lib/rdge/materials/cloud-material.js b/js/lib/rdge/materials/cloud-material.js index b7670178..2c7fced2 100644 --- a/js/lib/rdge/materials/cloud-material.js +++ b/js/lib/rdge/materials/cloud-material.js | |||
@@ -203,18 +203,6 @@ var CloudMaterial = function CloudMaterial() | |||
203 | RDGE.globals.engine.setContext( saveContext.id ); | 203 | RDGE.globals.engine.setContext( saveContext.id ); |
204 | } | 204 | } |
205 | }; | 205 | }; |
206 | |||
207 | this.updateTextures = function() | ||
208 | { | ||
209 | if (this._glTex) | ||
210 | { | ||
211 | if (!this._glTex.isAnimated()) | ||
212 | { | ||
213 | this._glTex.render(); | ||
214 | this.updateTexture(); | ||
215 | } | ||
216 | } | ||
217 | } | ||
218 | 206 | ||
219 | this.updateColor = function() | 207 | this.updateColor = function() |
220 | { | 208 | { |
diff --git a/js/lib/rdge/materials/material.js b/js/lib/rdge/materials/material.js index 4b8a5d6b..77220bf7 100755 --- a/js/lib/rdge/materials/material.js +++ b/js/lib/rdge/materials/material.js | |||
@@ -257,13 +257,6 @@ var Material = function GLMaterial( world ) { | |||
257 | return tex; | 257 | return tex; |
258 | }; | 258 | }; |
259 | 259 | ||
260 | this.updateTextures = function() | ||
261 | { | ||
262 | // this function is called whenever a world that generates textuers for | ||
263 | // the current world changes in some way. Sub-classes with textures | ||
264 | // should override this function. | ||
265 | } | ||
266 | |||
267 | }; | 260 | }; |
268 | 261 | ||
269 | if (typeof exports === "object") { | 262 | if (typeof exports === "object") { |
diff --git a/js/lib/rdge/materials/pulse-material.js b/js/lib/rdge/materials/pulse-material.js index bb8833b4..c2969501 100644 --- a/js/lib/rdge/materials/pulse-material.js +++ b/js/lib/rdge/materials/pulse-material.js | |||
@@ -150,20 +150,6 @@ var PulseMaterial = function PulseMaterial() | |||
150 | } | 150 | } |
151 | }; | 151 | }; |
152 | 152 | ||
153 | |||
154 | this.updateTextures = function() | ||
155 | { | ||
156 | if (this._glTex) | ||
157 | { | ||
158 | if (!this._glTex.isAnimated()) | ||
159 | { | ||
160 | this._glTex.render(); | ||
161 | this.updateTexture(); | ||
162 | } | ||
163 | } | ||
164 | } | ||
165 | |||
166 | |||
167 | this.update = function( time ) | 153 | this.update = function( time ) |
168 | { | 154 | { |
169 | var material = this._materialNode; | 155 | var material = this._materialNode; |
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' }, |
diff --git a/js/lib/rdge/materials/uber-material.js b/js/lib/rdge/materials/uber-material.js index bc2ba340..9d0cc564 100755 --- a/js/lib/rdge/materials/uber-material.js +++ b/js/lib/rdge/materials/uber-material.js | |||
@@ -284,30 +284,6 @@ var UberMaterial = function UberMaterial() { | |||
284 | } | 284 | } |
285 | }; | 285 | }; |
286 | 286 | ||
287 | |||
288 | this.updateTextures = function() | ||
289 | { | ||
290 | var material = this._materialNode; | ||
291 | if (material) | ||
292 | { | ||
293 | var technique = material.shaderProgram.defaultTechnique; | ||
294 | var renderer = RDGE_globals.engine.getContext().renderer; | ||
295 | if (renderer && technique) | ||
296 | { | ||
297 | if (this._diffuseTexture) | ||
298 | { | ||
299 | if (!this._diffuseTexture.isAnimated()) | ||
300 | { | ||
301 | this._diffuseTexture.render(); | ||
302 | var tex = this._diffuseTexture.getTexture(); | ||
303 | technique.s_diffuseMap.set( tex ); | ||
304 | } | ||
305 | } | ||
306 | } | ||
307 | } | ||
308 | } | ||
309 | |||
310 | |||
311 | this.updateSpecularMap = function () { | 287 | this.updateSpecularMap = function () { |
312 | var value = this._propValues["specularMap"]; | 288 | var value = this._propValues["specularMap"]; |