aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge/materials
diff options
context:
space:
mode:
authorhwc4872012-07-09 16:08:02 -0700
committerhwc4872012-07-09 16:08:02 -0700
commit5085d0f67df89a21715308956004164597a6ba79 (patch)
tree2c896163143a66331205a39b0a3b1b45d51bf12a /js/lib/rdge/materials
parent51f1691f792dbda9b740ded8aa0457c9406db156 (diff)
parent84b3327bd92faafab7954b5eb64c7abe24a3fe13 (diff)
downloadninja-5085d0f67df89a21715308956004164597a6ba79.tar.gz
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal into GridFixes
Conflicts: js/helper-classes/3D/StageLine.js
Diffstat (limited to 'js/lib/rdge/materials')
-rwxr-xr-xjs/lib/rdge/materials/bump-metal-material.js176
-rw-r--r--js/lib/rdge/materials/cloud-material.js708
-rw-r--r--js/lib/rdge/materials/deform-material.js102
-rw-r--r--js/lib/rdge/materials/flag-material.js172
-rwxr-xr-xjs/lib/rdge/materials/flat-material.js64
-rw-r--r--js/lib/rdge/materials/fly-material.js150
-rw-r--r--js/lib/rdge/materials/julia-material.js139
-rw-r--r--js/lib/rdge/materials/keleidoscope-material.js150
-rwxr-xr-xjs/lib/rdge/materials/linear-gradient-material.js290
-rw-r--r--js/lib/rdge/materials/mandel-material.js143
-rwxr-xr-xjs/lib/rdge/materials/material-parser.js4
-rwxr-xr-xjs/lib/rdge/materials/material.js569
-rw-r--r--js/lib/rdge/materials/plasma-material.js176
-rw-r--r--js/lib/rdge/materials/pulse-material.js320
-rw-r--r--js/lib/rdge/materials/radial-blur-material.js94
-rwxr-xr-xjs/lib/rdge/materials/radial-gradient-material.js246
-rw-r--r--js/lib/rdge/materials/relief-tunnel-material.js94
-rw-r--r--js/lib/rdge/materials/square-tunnel-material.js94
-rw-r--r--js/lib/rdge/materials/star-material.js110
-rw-r--r--js/lib/rdge/materials/taper-material.js87
-rw-r--r--js/lib/rdge/materials/tunnel-material.js100
-rw-r--r--js/lib/rdge/materials/twist-material.js94
-rw-r--r--js/lib/rdge/materials/twist-vert-material.js300
-rwxr-xr-xjs/lib/rdge/materials/uber-material.js283
-rw-r--r--js/lib/rdge/materials/water-material.js285
-rw-r--r--js/lib/rdge/materials/z-invert-material.js112
26 files changed, 2735 insertions, 2327 deletions
diff --git a/js/lib/rdge/materials/bump-metal-material.js b/js/lib/rdge/materials/bump-metal-material.js
index 3db3df1d..044dc59b 100755
--- a/js/lib/rdge/materials/bump-metal-material.js
+++ b/js/lib/rdge/materials/bump-metal-material.js
@@ -40,92 +40,104 @@ var BumpMetalMaterial = function BumpMetalMaterial() {
40 /////////////////////////////////////////////////////////////////////// 40 ///////////////////////////////////////////////////////////////////////
41 // Instance variables 41 // Instance variables
42 /////////////////////////////////////////////////////////////////////// 42 ///////////////////////////////////////////////////////////////////////
43 this._name = "Bump Metal"; 43 this._name = "Bump Metal";
44 this._shaderName = "bumpMetal"; 44 this._shaderName = "bumpMetal";
45 45
46 46
47 this._defaultLightDiff = [0.3, 0.3, 0.3, 1.0];
47 this._defaultDiffuseTexture = "assets/images/metal.png"; 48 this._defaultDiffuseTexture = "assets/images/metal.png";
48 this._defaultSpecularTexture = "assets/images/silver.png"; 49 this._defaultSpecularTexture = "assets/images/silver.png";
49 this._defaultNormalTexture = "assets/images/normalMap.png"; 50 this._defaultNormalTexture = "assets/images/normalMap.png";
50 51
51 // array textures indexed by shader uniform name 52 // array textures indexed by shader uniform name
52 this._glTextures = []; 53 this._glTextures = [];
53 54
54 this._speed = 1.0; 55 this._speed = 1.0;
55 56
56 /////////////////////////////////////////////////////////////////////// 57 ///////////////////////////////////////////////////////////////////////
57 // Property Accessors 58 // Property Accessors
58 /////////////////////////////////////////////////////////////////////// 59 ///////////////////////////////////////////////////////////////////////
59 this.isAnimated = function() { return true; }; 60 this.isAnimated = function() { return true; };
60 this.getShaderDef = function() { return bumpMetalMaterialDef; }; 61 this.getShaderDef = function() { return bumpMetalMaterialDef; };
61 62
62 /////////////////////////////////////////////////////////////////////// 63 ///////////////////////////////////////////////////////////////////////
63 // Material Property Accessors 64 // Material Property Accessors
64 /////////////////////////////////////////////////////////////////////// 65 ///////////////////////////////////////////////////////////////////////
65 this._propNames = ["u_light0Diff", "u_colMap", "u_normalMap", "u_glowMap" ]; 66 this._propNames = ["u_light0Diff", "u_colMap", "u_normalMap", "u_glowMap" ];
66 this._propLabels = ["Diffuse Color", "Diffuse Map", "Bump Map", "Specular Map" ]; 67 this._propLabels = ["Diffuse Color", "Diffuse Map", "Bump Map", "Specular Map" ];
67 this._propTypes = ["color", "file", "file", "file" ]; 68 this._propTypes = ["color", "file", "file", "file" ];
68 this._propValues = []; 69 this._propValues = [];
69 70
70 this._propValues[ this._propNames[0] ] = [0.3, 0.3, 0.3, 1.0]; 71 this._propValues[ this._propNames[0] ] = this._defaultLightDiff;
71 this._propValues[ this._propNames[1] ] = this._defaultDiffuseTexture.slice(0); 72 this._propValues[ this._propNames[1] ] = this._defaultDiffuseTexture.slice(0);
72 this._propValues[ this._propNames[2] ] = this._defaultNormalTexture.slice(0); 73 this._propValues[ this._propNames[2] ] = this._defaultNormalTexture.slice(0);
73 this._propValues[ this._propNames[3] ] = this._defaultSpecularTexture.slice(0); 74 this._propValues[ this._propNames[3] ] = this._defaultSpecularTexture.slice(0);
74 75
75 76
76 /////////////////////////////////////////////////////////////////////// 77 ///////////////////////////////////////////////////////////////////////
77 // Methods 78 // Methods
78 /////////////////////////////////////////////////////////////////////// 79 ///////////////////////////////////////////////////////////////////////
79 80
80 this.init = function( world ) 81 this.init = function( world )
81 { 82 {
82 // save the world 83 // save the world
83 if (world) { 84 if (world) {
84 this.setWorld( world ); 85 this.setWorld( world );
85 } 86 }
86 87
87 // set up the shader 88 // set up the shader
88 this._shader = new RDGE.jshader(); 89 this._shader = new RDGE.jshader();
89 this._shader.def = bumpMetalMaterialDef; 90 this._shader.def = bumpMetalMaterialDef;
90 this._shader.init(); 91 this._shader.init();
92
93 // set up the material node
94 this._materialNode = RDGE.createMaterialNode( this.getShaderName() + "_" + world.generateUniqueNodeID() );
95 this._materialNode.setShader(this._shader);
91 96
92 // set up the material node 97 this.setShaderValues();
93 this._materialNode = RDGE.createMaterialNode( this.getShaderName() + "_" + world.generateUniqueNodeID() ); 98 this.update(0);
94 this._materialNode.setShader(this._shader); 99 };
95 100
96 this.setShaderValues(); 101 this.resetToDefault = function()
97 this.update(0); 102 {
98 }; 103 this._propValues[ this._propNames[0] ] = this._defaultLightDiff;
104 this._propValues[ this._propNames[1] ] = this._defaultDiffuseTexture.slice(0);
105 this._propValues[ this._propNames[2] ] = this._defaultNormalTexture.slice(0);
106 this._propValues[ this._propNames[3] ] = this._defaultSpecularTexture.slice(0);
107 for (var i=0; i<4; i++)
108 this.setProperty( this._propNames[i], this._propValues[this._propNames[i]] );
109};
99}; 110};
100 111
112
101/////////////////////////////////////////////////////////////////////////////////////// 113///////////////////////////////////////////////////////////////////////////////////////
102// RDGE shader 114// RDGE shader
103 115
104// shader spec (can also be loaded from a .JSON file, or constructed at runtime) 116// shader spec (can also be loaded from a .JSON file, or constructed at runtime)
105var bumpMetalMaterialDef = bumpMetalShaderDef = 117var bumpMetalMaterialDef = bumpMetalShaderDef =
106{ 118{
107 'shaders': 119 'shaders':
108 { 120 {
109 // this shader is being referenced by file 121 // this shader is being referenced by file
110 'defaultVShader':"assets/shaders/test_vshader.glsl", 122 'defaultVShader':"assets/shaders/test_vshader.glsl",
111 'defaultFShader':"assets/shaders/test_fshader.glsl", 123 'defaultFShader':"assets/shaders/test_fshader.glsl",
112 124
113 // this shader is inline 125 // this shader is inline
114 'dirLightVShader': "\ 126 'dirLightVShader': "\
115 uniform mat4 u_mvMatrix;\ 127 uniform mat4 u_mvMatrix;\
116 uniform mat4 u_normalMatrix;\ 128 uniform mat4 u_normalMatrix;\
117 uniform mat4 u_projMatrix;\ 129 uniform mat4 u_projMatrix;\
118 uniform mat4 u_worldMatrix;\ 130 uniform mat4 u_worldMatrix;\
119 attribute vec3 a_pos;\ 131 attribute vec3 a_pos;\
120 attribute vec3 a_nrm;\ 132 attribute vec3 a_nrm;\
121 varying vec3 vNormal;\ 133 varying vec3 vNormal;\
122 varying vec3 vPos;\ 134 varying vec3 vPos;\
123 void main() {\ 135 void main() {\
124 vNormal.xyz = (u_normalMatrix*vec4(a_nrm, 0.0)).xyz;\ 136 vNormal.xyz = (u_normalMatrix*vec4(a_nrm, 0.0)).xyz;\
125 gl_Position = u_projMatrix * u_mvMatrix * vec4(a_pos,1.0);\ 137 gl_Position = u_projMatrix * u_mvMatrix * vec4(a_pos,1.0);\
126 vPos = (u_worldMatrix * vec4(a_pos,1.0)).xyz;\ 138 vPos = (u_worldMatrix * vec4(a_pos,1.0)).xyz;\
127 }", 139 }",
128 'dirLightFShader': "\ 140 'dirLightFShader': "\
129 precision highp float;\ 141 precision highp float;\
130 uniform vec4 u_light1Diff;\ 142 uniform vec4 u_light1Diff;\
131 uniform vec3 u_light1Pos;\ 143 uniform vec3 u_light1Pos;\
@@ -142,37 +154,37 @@ var bumpMetalMaterialDef = bumpMetalShaderDef =
142 float alpha2 = max(0.0, 1.0 - ( (light2.x*light2.x)/range + (light2.y*light2.y)/range + (light2.z*light2.z)/range));\ 154 float alpha2 = max(0.0, 1.0 - ( (light2.x*light2.x)/range + (light2.y*light2.y)/range + (light2.z*light2.z)/range));\
143 gl_FragColor = vec4((u_light2Diff*alpha2 + u_light1Diff*alpha1).rgb, 1.0);\ 155 gl_FragColor = vec4((u_light2Diff*alpha2 + u_light1Diff*alpha1).rgb, 1.0);\
144 }" 156 }"