diff options
author | Eric Guzman | 2012-02-13 10:29:49 -0800 |
---|---|---|
committer | Eric Guzman | 2012-02-13 10:29:49 -0800 |
commit | e4893f7d3c3b9bd7967973197c3ffb5d3a075c91 (patch) | |
tree | f3d4fd9d96ba0dcf846fbf66153fb443bd60f767 /js/helper-classes/RDGE/Materials/UberMaterial.js | |
parent | ef032412216d437ce1c7dfc9050ab41adf0594c0 (diff) | |
parent | e142611e22718b1f1d1696902ad9161ec5f33f98 (diff) | |
download | ninja-e4893f7d3c3b9bd7967973197c3ffb5d3a075c91.tar.gz |
Merge branch 'refs/heads/master' into TreeComponents
Diffstat (limited to 'js/helper-classes/RDGE/Materials/UberMaterial.js')
-rw-r--r-- | js/helper-classes/RDGE/Materials/UberMaterial.js | 87 |
1 files changed, 51 insertions, 36 deletions
diff --git a/js/helper-classes/RDGE/Materials/UberMaterial.js b/js/helper-classes/RDGE/Materials/UberMaterial.js index a8254465..c7855c95 100644 --- a/js/helper-classes/RDGE/Materials/UberMaterial.js +++ b/js/helper-classes/RDGE/Materials/UberMaterial.js | |||
@@ -21,7 +21,7 @@ function UberMaterial() | |||
21 | /////////////////////////////////////////////////////////////////////// | 21 | /////////////////////////////////////////////////////////////////////// |
22 | this._name = "UberMaterial"; | 22 | this._name = "UberMaterial"; |
23 | this._shaderName = "uber"; | 23 | this._shaderName = "uber"; |
24 | this.getShaderName = function() { return this._shaderName; } | 24 | this.getShaderName = function() { return this._shaderName; }; |
25 | 25 | ||
26 | // set some default values | 26 | // set some default values |
27 | this._ambientColor = [ 0.0, 0.0, 0.0, 1.0 ]; | 27 | this._ambientColor = [ 0.0, 0.0, 0.0, 1.0 ]; |
@@ -45,9 +45,9 @@ function UberMaterial() | |||
45 | /////////////////////////////////////////////////////////////////////// | 45 | /////////////////////////////////////////////////////////////////////// |
46 | // Material Property Accessors | 46 | // Material Property Accessors |
47 | /////////////////////////////////////////////////////////////////////// | 47 | /////////////////////////////////////////////////////////////////////// |
48 | this._propNames = ["ambientColor", "diffuseColor", "specularColor", "specularPower" , "diffuseMap", "normalMap", "specularMap", "environmentMap", "environmentAmount", "dummy" ]; | 48 | this._propNames = ["ambientColor", "diffuseColor", "specularColor", "specularPower" , "diffuseMap", "normalMap", "specularMap", "environmentMap", "environmentAmount" ]; |
49 | this._propLabels = ["Ambient Color", "Diffuse Color", "Specular Color", "Specular Power", "Texture Map", "Bump Map", "Specular Map", "Environment Map", "Environment Map Amount", "Dummy" ]; | 49 | this._propLabels = ["Ambient Color", "Diffuse Color", "Specular Color", "Specular Power", "Texture Map", "Bump Map", "Specular Map", "Environment Map", "Environment Map Amount" ]; |
50 | this._propTypes = ["color", "color", "color", "float", "file", "file", "file", "file", "float", "checkbox"]; | 50 | this._propTypes = ["color", "color", "color", "float", "file", "file", "file", "file", "float" ]; |
51 | this._propValues = []; | 51 | this._propValues = []; |
52 | 52 | ||
53 | this._propValues[ this._propNames[0] ] = this._ambientColor.slice(0); | 53 | this._propValues[ this._propNames[0] ] = this._ambientColor.slice(0); |
@@ -99,7 +99,7 @@ function UberMaterial() | |||
99 | break; | 99 | break; |
100 | } | 100 | } |
101 | } | 101 | } |
102 | } | 102 | }; |
103 | /////////////////////////////////////////////////////////////////////// | 103 | /////////////////////////////////////////////////////////////////////// |
104 | 104 | ||
105 | // define the 4 lights | 105 | // define the 4 lights |
@@ -151,10 +151,10 @@ function UberMaterial() | |||
151 | { | 151 | { |
152 | // ubershader material properties. | 152 | // ubershader material properties. |
153 | 'material' : { | 153 | 'material' : { |
154 | 'ambientColor' : this._ambientColor, // material ambient color | 154 | 'ambientColor' : this._ambientColor, // material ambient color |
155 | 'diffuseColor' : this._diffuseColor, // material diffuse color | 155 | 'diffuseColor' : this._diffuseColor, // material diffuse color |
156 | 'specularColor' : this._specularColor, // material specular color | 156 | 'specularColor' : this._specularColor, // material specular color |
157 | 'specularPower' : this._specularPower, // material specular power (shininess) | 157 | 'specularPower' : this._specularPower // material specular power (shininess) |
158 | }, | 158 | }, |
159 | 159 | ||
160 | // ubershader supports up to four lights. | 160 | // ubershader supports up to four lights. |
@@ -162,7 +162,7 @@ function UberMaterial() | |||
162 | 'light0' : this._lights[0], | 162 | 'light0' : this._lights[0], |
163 | 'light1' : this._lights[1], | 163 | 'light1' : this._lights[1], |
164 | 'light2' : this._lights[2], | 164 | 'light2' : this._lights[2], |
165 | 'light3' : this._lights[3], | 165 | 'light3' : this._lights[3] |
166 | }, | 166 | }, |
167 | 167 | ||
168 | // uvTransform can be used to scale or offset the texture coordinates. | 168 | // uvTransform can be used to scale or offset the texture coordinates. |
@@ -178,7 +178,7 @@ function UberMaterial() | |||
178 | 'specularMap' : this._specularMapOb, | 178 | 'specularMap' : this._specularMapOb, |
179 | 179 | ||
180 | // optional environment map | 180 | // optional environment map |
181 | 'environmentMap' : this._environmentMapOb, | 181 | 'environmentMap' : this._environmentMapOb |
182 | }; | 182 | }; |
183 | 183 | ||
184 | this.updateAmbientColor = function() | 184 | this.updateAmbientColor = function() |
@@ -190,7 +190,7 @@ function UberMaterial() | |||
190 | var technique = material.shaderProgram.defaultTechnique; | 190 | var technique = material.shaderProgram.defaultTechnique; |
191 | technique.u_ambientColor.set(this._ambientColor); | 191 | technique.u_ambientColor.set(this._ambientColor); |
192 | } | 192 | } |
193 | } | 193 | }; |
194 | 194 | ||
195 | this.updateDiffuseColor = function() | 195 | this.updateDiffuseColor = function() |
196 | { | 196 | { |
@@ -202,7 +202,7 @@ function UberMaterial() | |||
202 | var technique = material.shaderProgram.defaultTechnique; | 202 | var technique = material.shaderProgram.defaultTechnique; |
203 | technique.u_diffuseColor.set(this._diffuseColor); | 203 | technique.u_diffuseColor.set(this._diffuseColor); |
204 | } | 204 | } |
205 | } | 205 | }; |
206 | 206 | ||
207 | this.updateSpecularColor = function( value ) | 207 | this.updateSpecularColor = function( value ) |
208 | { | 208 | { |
@@ -214,7 +214,7 @@ function UberMaterial() | |||
214 | var technique = material.shaderProgram.defaultTechnique; | 214 | var technique = material.shaderProgram.defaultTechnique; |
215 | technique.u_specularColor.set(this._specularColor); | 215 | technique.u_specularColor.set(this._specularColor); |
216 | } | 216 | } |
217 | } | 217 | }; |
218 | 218 | ||
219 | this.updateSpecularPower = function( value) | 219 | this.updateSpecularPower = function( value) |
220 | { | 220 | { |
@@ -226,7 +226,7 @@ function UberMaterial() | |||
226 | var technique = material.shaderProgram.defaultTechnique; | 226 | var technique = material.shaderProgram.defaultTechnique; |
227 | technique.u_specularPower.set([this._specularPower]); | 227 | technique.u_specularPower.set([this._specularPower]); |
228 | } | 228 | } |
229 | } | 229 | }; |
230 | 230 | ||
231 | this.updateEnvironmentAmount = function(value) | 231 | this.updateEnvironmentAmount = function(value) |
232 | { | 232 | { |
@@ -238,7 +238,7 @@ function UberMaterial() | |||
238 | var technique = material.shaderProgram.defaultTechnique; | 238 | var technique = material.shaderProgram.defaultTechnique; |
239 | technique.u_envReflection.set([this._environmentMapOb.envReflection]); | 239 | technique.u_envReflection.set([this._environmentMapOb.envReflection]); |
240 | } | 240 | } |
241 | } | 241 | }; |
242 | 242 | ||
243 | this.updateEnvironmentMap = function() | 243 | this.updateEnvironmentMap = function() |
244 | { | 244 | { |
@@ -270,12 +270,13 @@ function UberMaterial() | |||
270 | if (renderer && technique) | 270 | if (renderer && technique) |
271 | { | 271 | { |
272 | var tex = renderer.getTextureByName(value, caps.environmentMap.wrap); | 272 | var tex = renderer.getTextureByName(value, caps.environmentMap.wrap); |
273 | this.registerTexture( tex ); | ||
273 | technique.s_environmentMap.set( tex ); | 274 | technique.s_environmentMap.set( tex ); |
274 | } | 275 | } |
275 | } | 276 | } |
276 | } | 277 | } |
277 | } | 278 | } |
278 | } | 279 | }; |
279 | 280 | ||
280 | this.updateDiffuseMap = function(value) | 281 | this.updateDiffuseMap = function(value) |
281 | { | 282 | { |
@@ -307,12 +308,13 @@ function UberMaterial() | |||
307 | if (renderer && technique) | 308 | if (renderer && technique) |
308 | { | 309 | { |
309 | var tex = renderer.getTextureByName(value, caps.diffuseMap.wrap); | 310 | var tex = renderer.getTextureByName(value, caps.diffuseMap.wrap); |
311 | this.registerTexture( tex ); | ||
310 | technique.s_diffuseMap.set( tex ); | 312 | technique.s_diffuseMap.set( tex ); |
311 | } | 313 | } |
312 | } | 314 | } |
313 | } | 315 | } |
314 | } | 316 | } |
315 | } | 317 | }; |
316 | 318 | ||
317 | this.updateSpecularMap = function() | 319 | this.updateSpecularMap = function() |
318 | { | 320 | { |
@@ -344,12 +346,13 @@ function UberMaterial() | |||
344 | if (renderer && technique) | 346 | if (renderer && technique) |
345 | { | 347 | { |
346 | var tex = renderer.getTextureByName(value, caps.specularMap.wrap); | 348 | var tex = renderer.getTextureByName(value, caps.specularMap.wrap); |
349 | this.registerTexture( tex ); | ||
347 | technique.s_specularMap.set( tex ); | 350 | technique.s_specularMap.set( tex ); |
348 | } | 351 | } |
349 | } | 352 | } |
350 | } | 353 | } |
351 | } | 354 | } |
352 | } | 355 | }; |
353 | 356 | ||
354 | this.updateNormalMap = function(value) | 357 | this.updateNormalMap = function(value) |
355 | { | 358 | { |
@@ -381,12 +384,13 @@ function UberMaterial() | |||
381 | if (renderer && technique) | 384 | if (renderer && technique) |
382 | { | 385 | { |
383 | var tex = renderer.getTextureByName(value, caps.normalMap.wrap); | 386 |