aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/RDGE/Materials/UberMaterial.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/helper-classes/RDGE/Materials/UberMaterial.js')
-rw-r--r--js/helper-classes/RDGE/Materials/UberMaterial.js87
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 var tex = renderer.getTextureByName(value, caps.normalMap.wrap);
387 this.registerTexture( tex );
384 technique.s_normalMap.set( tex ); 388 technique.s_normalMap.set( tex );
385 } 389 }
386 } 390 }
387 } 391 }
388 }