aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge/materials
diff options
context:
space:
mode:
authorJonathan Duran2012-06-19 08:40:26 -0700
committerJonathan Duran2012-06-19 08:40:26 -0700
commit6f25a2e70079de6bcbb8c3411ddef88c2ed1ea39 (patch)
tree253e5f6dd5923218e3155f78fa67ff3e43de0ebc /js/lib/rdge/materials
parentb51c9448bc187f9bfa3ab39c366657ec2bb9e2fb (diff)
parent483ad57efcd6475776f580c3af5b60e6deeaf781 (diff)
downloadninja-6f25a2e70079de6bcbb8c3411ddef88c2ed1ea39.tar.gz
Merge branch 'refs/heads/NINJAmaster' into TimelineUber
Diffstat (limited to 'js/lib/rdge/materials')
-rwxr-xr-xjs/lib/rdge/materials/bump-metal-material.js170
-rw-r--r--js/lib/rdge/materials/cloud-material.js439
-rw-r--r--js/lib/rdge/materials/deform-material.js36
-rw-r--r--js/lib/rdge/materials/flag-material.js136
-rwxr-xr-xjs/lib/rdge/materials/flat-material.js99
-rw-r--r--js/lib/rdge/materials/fly-material.js38
-rw-r--r--js/lib/rdge/materials/julia-material.js49
-rw-r--r--js/lib/rdge/materials/keleidoscope-material.js52
-rwxr-xr-xjs/lib/rdge/materials/linear-gradient-material.js250
-rw-r--r--js/lib/rdge/materials/mandel-material.js46
-rwxr-xr-xjs/lib/rdge/materials/material.js306
-rw-r--r--js/lib/rdge/materials/plasma-material.js61
-rw-r--r--js/lib/rdge/materials/pulse-material.js185
-rw-r--r--js/lib/rdge/materials/radial-blur-material.js124
-rwxr-xr-xjs/lib/rdge/materials/radial-gradient-material.js277
-rw-r--r--js/lib/rdge/materials/relief-tunnel-material.js49
-rw-r--r--js/lib/rdge/materials/square-tunnel-material.js45
-rw-r--r--js/lib/rdge/materials/star-material.js53
-rw-r--r--js/lib/rdge/materials/taper-material.js131
-rw-r--r--js/lib/rdge/materials/tunnel-material.js45
-rw-r--r--js/lib/rdge/materials/twist-material.js58
-rw-r--r--js/lib/rdge/materials/twist-vert-material.js325
-rwxr-xr-xjs/lib/rdge/materials/uber-material.js129
-rw-r--r--js/lib/rdge/materials/water-material.js313
-rw-r--r--js/lib/rdge/materials/z-invert-material.js50
25 files changed, 1519 insertions, 1947 deletions
diff --git a/js/lib/rdge/materials/bump-metal-material.js b/js/lib/rdge/materials/bump-metal-material.js
index 27d5793c..99a80da2 100755
--- a/js/lib/rdge/materials/bump-metal-material.js
+++ b/js/lib/rdge/materials/bump-metal-material.js
@@ -6,6 +6,8 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
6 6
7var MaterialParser = require("js/lib/rdge/materials/material-parser").MaterialParser; 7var MaterialParser = require("js/lib/rdge/materials/material-parser").MaterialParser;
8var Material = require("js/lib/rdge/materials/material").Material; 8var Material = require("js/lib/rdge/materials/material").Material;
9var Texture = require("js/lib/rdge/texture").Texture;
10
9/////////////////////////////////////////////////////////////////////// 11///////////////////////////////////////////////////////////////////////
10// Class GLMaterial 12// Class GLMaterial
11// RDGE representation of a material. 13// RDGE representation of a material.
@@ -14,184 +16,61 @@ var BumpMetalMaterial = function BumpMetalMaterial() {
14 /////////////////////////////////////////////////////////////////////// 16 ///////////////////////////////////////////////////////////////////////
15 // Instance variables 17 // Instance variables
16 /////////////////////////////////////////////////////////////////////// 18 ///////////////////////////////////////////////////////////////////////
17 this._name = "BumpMetalMaterial"; 19 this._name = "Bump Metal";
18 this._shaderName = "bumpMetal"; 20 this._shaderName = "bumpMetal";
19 21
20 this._lightDiff = [0.3, 0.3, 0.3, 1.0];
21 this._diffuseTexture = "assets/images/metal.png";
22 this._specularTexture = "assets/images/silver.png";
23 this._normalTexture = "assets/images/normalMap.png";
24
25 ///////////////////////////////////////////////////////////////////////
26 // Property Accessors
27 ///////////////////////////////////////////////////////////////////////
28 this.getName = function() {
29 return this._name;
30 };
31 22
32 this.getShaderName = function() { 23 this._defaultDiffuseTexture = "assets/images/metal.png";
33 return this._shaderName; 24 this._defaultSpecularTexture = "assets/images/silver.png";
34 }; 25 this._defaultNormalTexture = "assets/images/normalMap.png";
35
36 this.getLightDiff = function() {
37 return this._lightDiff;
38 };
39
40 this.setLightDiff = function(ld) {
41 this._lightDiff = ld;
42 // Bad property name. Commenting for now
43
44 if (this._shader && this._shader['default']){
45 this._shader['default'].u_light0Diff.set( ld );
46 }
47 26
48 }; 27 // array textures indexed by shader uniform name
28 this._glTextures = [];
49 29
50 this.getDiffuseTexture = function() { return this._propValues[this._propNames[1]] ? this._propValues[this._propNames[1]].slice() : null }; 30 this._speed = 1.0;
51 this.setDiffuseTexture = function(m) { this._propValues[this._propNames[1]] = m ? m.slice(0) : null; this.updateTexture(1); };
52
53 this.getNormalTexture = function() { return this._propValues[this._propNames[2]] ? this._propValues[this._propNames[2]].slice() : null };
54 this.setNormalTexture = function(m) { this._propValues[this._propNames[2]] = m ? m.slice(0) : null; this.updateTexture(2); };
55
56 this.getSpecularTexture = function() { return this._propValues[this._propNames[3]] ? this._propValues[this._propNames[3]].slice() : null };
57 this.setSpecularTexture = function(m) { this._propValues[this._propNames[3]] = m ? m.slice(0) : null; this.updateTexture(3); };
58 31
32 ///////////////////////////////////////////////////////////////////////
33 // Property Accessors
34 ///////////////////////////////////////////////////////////////////////
59 this.isAnimated = function() { return true; }; 35 this.isAnimated = function() { return true; };
36 this.getShaderDef = function() { return bumpMetalMaterialDef; };
60 37
61 /////////////////////////////////////////////////////////////////////// 38 ///////////////////////////////////////////////////////////////////////
62 // Material Property Accessors 39 // Material Property Accessors
63 /////////////////////////////////////////////////////////////////////// 40 ///////////////////////////////////////////////////////////////////////
64 this._propNames = ["lightDiff", "diffuseTexture", "normalMap", "specularTexture"]; 41 this._propNames = ["u_light0Diff", "u_colMap", "u_normalMap", "u_glowMap" ];
65 this._propLabels = ["Diffuse Color", "Diffuse Map", "Bump Map", "Specular Map"]; 42 this._propLabels = ["Diffuse Color", "Diffuse Map", "Bump Map", "Specular Map" ];
66 this._propTypes = ["color", "file", "file", "file"]; 43 this._propTypes = ["color", "file", "file", "file" ];
67 this._propValues = []; 44 this._propValues = [];
68 45
69 this._propValues[ this._propNames[0] ] = this._lightDiff.slice(0); 46 this._propValues[ this._propNames[0] ] = [0.3, 0.3, 0.3, 1.0];
70 this._propValues[ this._propNames[1] ] = this._diffuseTexture.slice(0); 47 this._propValues[ this._propNames[1] ] = this._defaultDiffuseTexture.slice(0);
71 this._propValues[ this._propNames[2] ] = this._normalTexture.slice(0); 48 this._propValues[ this._propNames[2] ] = this._defaultNormalTexture.slice(0);
72 this._propValues[ this._propNames[3] ] = this._specularTexture.slice(0); 49 this._propValues[ this._propNames[3] ] = this._defaultSpecularTexture.slice(0);
73
74 // TODO - shader techniques are not all named the same, i.e., FlatMaterial uses "colorMe" and BrickMaterial uses "default"
75 this.setProperty = function( prop, value )
76 {
77 // every material should do something with the "color" property
78 if (prop === "color") return;
79
80 // make sure we have legitimate imput
81 var ok = this.validateProperty( prop, value );
82 if (!ok)
83 {
84 console.log( "invalid property in Bump Metal Materia;" + prop + " : " + value );
85 return;
86 }
87 50
88 switch (prop)
89 {
90 case "lightDiff": this.setLightDiff( value ); break;
91 case "diffuseTexture": this.setDiffuseTexture( value ); break;
92 case "specularTexture": this.setSpecularTexture( value ); break;
93 case "normalMap": this.setNormalTexture( value ); break;
94
95 default:
96 console.log( "invalid property to Bump Metal Material: " + prop + ", value: " + value );
97 break;
98 }
99 };
100 51
101 /////////////////////////////////////////////////////////////////////// 52 ///////////////////////////////////////////////////////////////////////
102 // Methods 53 // Methods
103 /////////////////////////////////////////////////////////////////////// 54 ///////////////////////////////////////////////////////////////////////
104 // duplcate method requirde
105 this.dup = function() { return new BumpMetalMaterial(); };
106 55
107 this.init = function( world ) 56 this.init = function( world )
108 { 57 {
109 // save the world 58 // save the world
110 if (world) { 59 if (world) {
111 this.setWorld( world ); 60 this.setWorld( world );
112 } 61 }
113 62
114 // set up the shader 63 // set up the shader
115 this._shader = new RDGE.jshader(); 64 this._shader = new RDGE.jshader();
116 this._shader.def = bumpMetalMaterialDef; 65 this._shader.def = bumpMetalMaterialDef;
117 this._shader.init(); 66 this._shader.init();
118 this._shader['default'].u_light0Diff.set( this.getLightDiff() );
119 67
120 // set up the material node 68 // set up the material node
121 this._materialNode = RDGE.createMaterialNode( this.getShaderName() + "_" + world.generateUniqueNodeID() ); 69 this._materialNode = RDGE.createMaterialNode( this.getShaderName() + "_" + world.generateUniqueNodeID() );
122 this._materialNode.setShader(this._shader); 70 this._materialNode.setShader(this._shader);
123 71
124 // set some image maps 72 this.setShaderValues();
125 this.updateTexture(1); 73 this.update(0);
126 this.updateTexture(2);
127 this.updateTexture(3);
128 };
129
130 this.updateTexture = function( index )
131 {
132 var material = this._materialNode;
133