aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--js/helper-classes/RDGE/Materials/BumpMetalMaterial.js48
-rw-r--r--js/helper-classes/RDGE/Materials/FlatMaterial.js45
-rw-r--r--js/helper-classes/RDGE/Materials/LinearGradientMaterial.js144
-rw-r--r--js/helper-classes/RDGE/Materials/RadialGradientMaterial.js86
-rw-r--r--js/helper-classes/RDGE/Materials/UberMaterial.js44
5 files changed, 206 insertions, 161 deletions
diff --git a/js/helper-classes/RDGE/Materials/BumpMetalMaterial.js b/js/helper-classes/RDGE/Materials/BumpMetalMaterial.js
index 999d4676..a7a3724e 100644
--- a/js/helper-classes/RDGE/Materials/BumpMetalMaterial.js
+++ b/js/helper-classes/RDGE/Materials/BumpMetalMaterial.js
@@ -29,24 +29,24 @@ function BumpMetalMaterial()
29 /////////////////////////////////////////////////////////////////////// 29 ///////////////////////////////////////////////////////////////////////
30 // Property Accessors 30 // Property Accessors
31 /////////////////////////////////////////////////////////////////////// 31 ///////////////////////////////////////////////////////////////////////
32 this.getName = function() { return this._name; } 32 this.getName = function() { return this._name; };
33 this.getShaderName = function() { return this._shaderName; } 33 this.getShaderName = function() { return this._shaderName; };
34 34
35 this.getLightDiff = function() { return this._lightDiff; } 35 this.getLightDiff = function() { return this._lightDiff; };
36 this.setLightDiff = function(ld) { this._lightDiff = ld; 36 this.setLightDiff = function(ld) { this._lightDiff = ld;
37 if (this._shader && this._shader.default) 37 if (this._shader && this._shader.default)
38 this._shader.default.u_light0Diff.set( ld ); } 38 this._shader.default.u_light0Diff.set( ld ); };
39 39
40 this.getDiffuseTexture = function() { return this._propValues[this._propNames[1]] ? this._propValues[this._propNames[1]].slice() : null } 40 this.getDiffuseTexture = function() { return this._propValues[this._propNames[1]] ? this._propValues[this._propNames[1]].slice() : null };
41 this.setDiffuseTexture = function(m) { this._propValues[this._propNames[1]] = m ? m.slice(0) : null; this.updateTexture(1); } 41 this.setDiffuseTexture = function(m) { this._propValues[this._propNames[1]] = m ? m.slice(0) : null; this.updateTexture(1); };
42 42
43 this.getNormalTexture = function() { return this._propValues[this._propNames[2]] ? this._propValues[this._propNames[2]].slice() : null } 43 this.getNormalTexture = function() { return this._propValues[this._propNames[2]] ? this._propValues[this._propNames[2]].slice() : null };
44 this.setNormalTexture = function(m) { this._propValues[this._propNames[2]] = m ? m.slice(0) : null; this.updateTexture(2); } 44 this.setNormalTexture = function(m) { this._propValues[this._propNames[2]] = m ? m.slice(0) : null; this.updateTexture(2); };
45 45
46 this.getSpecularTexture = function() { return this._propValues[this._propNames[3]] ? this._propValues[this._propNames[3]].slice() : null } 46 this.getSpecularTexture = function() { return this._propValues[this._propNames[3]] ? this._propValues[this._propNames[3]].slice() : null };
47 this.setSpecularTexture = function(m) { this._propValues[this._propNames[3]] = m ? m.slice(0) : null; this.updateTexture(3); } 47 this.setSpecularTexture = function(m) { this._propValues[this._propNames[3]] = m ? m.slice(0) : null; this.updateTexture(3); };
48 48
49 this.isAnimated = function() { return true; } 49 this.isAnimated = function() { return true; };
50 50
51 /////////////////////////////////////////////////////////////////////// 51 ///////////////////////////////////////////////////////////////////////
52 // Material Property Accessors 52 // Material Property Accessors
@@ -86,13 +86,13 @@ function BumpMetalMaterial()
86 console.log( "invalid property to Bump Metal Material: " + prop + ", value: " + value ); 86 console.log( "invalid property to Bump Metal Material: " + prop + ", value: " + value );
87 break; 87 break;
88 } 88 }
89 } 89 };
90 90
91 /////////////////////////////////////////////////////////////////////// 91 ///////////////////////////////////////////////////////////////////////
92 // Methods 92 // Methods
93 /////////////////////////////////////////////////////////////////////// 93 ///////////////////////////////////////////////////////////////////////
94 // duplcate method requirde 94 // duplcate method requirde
95 this.dup = function() { return new BumpMetalMaterial(); } 95 this.dup = function() { return new BumpMetalMaterial(); };
96 96
97 this.init = function( world ) 97 this.init = function( world )
98 { 98 {
@@ -113,7 +113,7 @@ function BumpMetalMaterial()
113 this.updateTexture(1); 113 this.updateTexture(1);
114 this.updateTexture(2); 114 this.updateTexture(2);
115 this.updateTexture(3); 115 this.updateTexture(3);
116 } 116 };
117 117
118 this.updateTexture = function( index ) 118 this.updateTexture = function( index )
119 { 119 {
@@ -140,7 +140,7 @@ function BumpMetalMaterial()
140 } 140 }
141 } 141 }
142 } 142 }
143 } 143 };
144 144
145 this.export = function() 145 this.export = function()
146 { 146 {
@@ -157,7 +157,7 @@ function BumpMetalMaterial()
157 exportStr += "endMaterial\n"; 157 exportStr += "endMaterial\n";
158 158
159 return exportStr; 159 return exportStr;
160 } 160 };
161 161
162 this.import = function( importStr ) 162 this.import = function( importStr )
163 { 163 {
@@ -190,7 +190,7 @@ function BumpMetalMaterial()
190 } 190 }
191 191
192 return rtnStr; 192 return rtnStr;
193 } 193 };
194} 194}
195 195
196/////////////////////////////////////////////////////////////////////////////////////// 196///////////////////////////////////////////////////////////////////////////////////////
@@ -237,7 +237,7 @@ bumpMetalShaderDef =
237 float alpha1 = max(0.0, 1.0 - ( (light1.x*light1.x)/range + (light1.y*light1.y)/range + (light1.z*light1.z)/range));\ 237 float alpha1 = max(0.0, 1.0 - ( (light1.x*light1.x)/range + (light1.y*light1.y)/range + (light1.z*light1.z)/range));\
238 float alpha2 = max(0.0, 1.0 - ( (light2.x*light2.x)/range + (light2.y*light2.y)/range + (light2.z*light2.z)/range));\ 238 float alpha2 = max(0.0, 1.0 - ( (light2.x*light2.x)/range + (light2.y*light2.y)/range + (light2.z*light2.z)/range));\
239 gl_FragColor = vec4((u_light2Diff*alpha2 + u_light1Diff*alpha1).rgb, 1.0);\ 239 gl_FragColor = vec4((u_light2Diff*alpha2 + u_light1Diff*alpha1).rgb, 1.0);\
240 }", 240 }"
241 }, 241 },
242 'techniques': 242 'techniques':
243 { 243 {
@@ -251,7 +251,7 @@ bumpMetalShaderDef =
251 { 251 {
252 'vert' : { 'type' : 'vec3' }, 252 'vert' : { 'type' : 'vec3' },
253 'normal' : { 'type' : 'vec3' }, 253 'normal' : { 'type' : 'vec3' },
254 'texcoord' : { 'type' : 'vec2' }, 254 'texcoord' : { 'type' : 'vec2' }
255 }, 255 },
256 // parameters 256 // parameters
257 'params' : 257 'params' :
@@ -260,7 +260,7 @@ bumpMetalShaderDef =
260 //'u_matDiffuse' : { 'type' : 'vec4' } 260 //'u_matDiffuse' : { 'type' : 'vec4' }
261 'u_colMap': { 'type' : 'tex2d' }, 261 'u_colMap': { 'type' : 'tex2d' },
262 'u_normalMap': { 'type' : 'tex2d' }, 262 'u_normalMap': { 'type' : 'tex2d' },
263 'u_glowMap': { 'type' : 'tex2d' }, 263 'u_glowMap': { 'type' : 'tex2d' }
264 }, 264 },
265 265
266 // render states 266 // render states
@@ -268,7 +268,7 @@ bumpMetalShaderDef =
268 { 268 {
269 'depthEnable' : true, 269 'depthEnable' : true,
270 'offset':[1.0, 0.1] 270 'offset':[1.0, 0.1]
271 }, 271 }
272 }, 272 },
273 { // light pass 273 { // light pass
274 'vshader' : 'dirLightVShader', 274 'vshader' : 'dirLightVShader',
@@ -277,7 +277,7 @@ bumpMetalShaderDef =
277 'attributes' : 277 'attributes' :
278 { 278 {
279 'a_pos' : { 'type' : 'vec3' }, 279 'a_pos' : { 'type' : 'vec3' },
280 'a_nrm' : { 'type' : 'vec3' }, 280 'a_nrm' : { 'type' : 'vec3' }
281 }, 281 },
282 // parameters 282 // parameters
283 'params' : 283 'params' :
@@ -290,8 +290,8 @@ bumpMetalShaderDef =
290 'depthEnable' : true, 290 'depthEnable' : true,
291 "blendEnable" : true, 291 "blendEnable" : true,
292 "srcBlend" : "SRC_ALPHA", 292 "srcBlend" : "SRC_ALPHA",
293 "dstBlend" : "DST_ALPHA", 293 "dstBlend" : "DST_ALPHA"
294 }, 294 }
295 } // light pass 295 } // light pass
296 ] 296 ]
297 } // techniques 297 } // techniques
diff --git a/js/helper-classes/RDGE/Materials/FlatMaterial.js b/js/helper-classes/RDGE/Materials/FlatMaterial.js
index a250dc0a..570e7f9e 100644
--- a/js/helper-classes/RDGE/Materials/FlatMaterial.js
+++ b/js/helper-classes/RDGE/Materials/FlatMaterial.js
@@ -26,11 +26,11 @@ function FlatMaterial()
26 /////////////////////////////////////////////////////////////////////// 26 ///////////////////////////////////////////////////////////////////////
27 // Property Accessors 27 // Property Accessors
28 /////////////////////////////////////////////////////////////////////// 28 ///////////////////////////////////////////////////////////////////////
29 this.getColor = function() { return this._color; } 29 this.getColor = function() { return this._color; };
30 this.getShaderName = function() { return this._shaderName; } 30 this.getShaderName = function() { return this._shaderName; };
31 31
32 this.isAnimated = function() { return false; } 32 this.isAnimated = function() { return false; };
33 this.hasVertexDeformation = function() { return true; } 33 this.hasVertexDeformation = function() { return true; };
34 this._hasVertexDeformation = true; 34 this._hasVertexDeformation = true;
35 this._vertexDeformationTolerance = 0.2; 35 this._vertexDeformationTolerance = 0.2;
36 36
@@ -38,7 +38,7 @@ function FlatMaterial()
38 // Methods