aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge/materials
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib/rdge/materials')
-rwxr-xr-xjs/lib/rdge/materials/bump-metal-material.js199
-rw-r--r--js/lib/rdge/materials/cloud-material.js731
-rw-r--r--js/lib/rdge/materials/deform-material.js125
-rw-r--r--js/lib/rdge/materials/flag-material.js195
-rwxr-xr-xjs/lib/rdge/materials/flat-material.js87
-rw-r--r--js/lib/rdge/materials/fly-material.js173
-rw-r--r--js/lib/rdge/materials/julia-material.js162
-rw-r--r--js/lib/rdge/materials/keleidoscope-material.js173
-rwxr-xr-xjs/lib/rdge/materials/linear-gradient-material.js311
-rw-r--r--js/lib/rdge/materials/mandel-material.js166
-rwxr-xr-xjs/lib/rdge/materials/material-parser.js27
-rwxr-xr-xjs/lib/rdge/materials/material.js592
-rw-r--r--js/lib/rdge/materials/plasma-material.js199
-rw-r--r--js/lib/rdge/materials/pulse-material.js343
-rw-r--r--js/lib/rdge/materials/radial-blur-material.js117
-rwxr-xr-xjs/lib/rdge/materials/radial-gradient-material.js269
-rw-r--r--js/lib/rdge/materials/relief-tunnel-material.js117
-rw-r--r--js/lib/rdge/materials/square-tunnel-material.js117
-rw-r--r--js/lib/rdge/materials/star-material.js133
-rw-r--r--js/lib/rdge/materials/taper-material.js110
-rw-r--r--js/lib/rdge/materials/tunnel-material.js123
-rw-r--r--js/lib/rdge/materials/twist-material.js117
-rw-r--r--js/lib/rdge/materials/twist-vert-material.js323
-rwxr-xr-xjs/lib/rdge/materials/uber-material.js306
-rw-r--r--js/lib/rdge/materials/water-material.js308
-rw-r--r--js/lib/rdge/materials/z-invert-material.js135
26 files changed, 3046 insertions, 2612 deletions
diff --git a/js/lib/rdge/materials/bump-metal-material.js b/js/lib/rdge/materials/bump-metal-material.js
index 3db3df1d..02540033 100755
--- a/js/lib/rdge/materials/bump-metal-material.js
+++ b/js/lib/rdge/materials/bump-metal-material.js
@@ -1,24 +1,25 @@
1/* <copyright> 1/* <copyright>
2Copyright (c) 2012, Motorola Mobility, Inc 2Copyright (c) 2012, Motorola Mobility LLC.
3All Rights Reserved. 3All Rights Reserved.
4BSD License.
5 4
6Redistribution and use in source and binary forms, with or without 5Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions are met: 6modification, are permitted provided that the following conditions are met:
8 7
9 - Redistributions of source code must retain the above copyright notice, 8* Redistributions of source code must retain the above copyright notice,
10 this list of conditions and the following disclaimer. 9 this list of conditions and the following disclaimer.
11 - Redistributions in binary form must reproduce the above copyright 10
12 notice, this list of conditions and the following disclaimer in the 11* Redistributions in binary form must reproduce the above copyright notice,
13 documentation and/or other materials provided with the distribution. 12 this list of conditions and the following disclaimer in the documentation
14 - Neither the name of Motorola Mobility nor the names of its contributors 13 and/or other materials provided with the distribution.
15 may be used to endorse or promote products derived from this software 14
16 without specific prior written permission. 15* Neither the name of Motorola Mobility LLC nor the names of its
16 contributors may be used to endorse or promote products derived from this
17 software without specific prior written permission.
17 18
18THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 22ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
@@ -40,92 +41,104 @@ var BumpMetalMaterial = function BumpMetalMaterial() {
40 /////////////////////////////////////////////////////////////////////// 41 ///////////////////////////////////////////////////////////////////////
41 // Instance variables 42 // Instance variables
42 /////////////////////////////////////////////////////////////////////// 43 ///////////////////////////////////////////////////////////////////////
43 this._name = "Bump Metal"; 44 this._name = "Bump Metal";
44 this._shaderName = "bumpMetal"; 45 this._shaderName = "bumpMetal";
45 46
46 47
48 this._defaultLightDiff = [0.3, 0.3, 0.3, 1.0];
47 this._defaultDiffuseTexture = "assets/images/metal.png"; 49 this._defaultDiffuseTexture = "assets/images/metal.png";
48 this._defaultSpecularTexture = "assets/images/silver.png"; 50 this._defaultSpecularTexture = "assets/images/silver.png";
49 this._defaultNormalTexture = "assets/images/normalMap.png"; 51 this._defaultNormalTexture = "assets/images/normalMap.png";
50 52
51 // array textures indexed by shader uniform name 53 // array textures indexed by shader uniform name
52 this._glTextures = []; 54 this._glTextures = [];
53 55
54 this._speed = 1.0; 56 this._speed = 1.0;
55 57
56 /////////////////////////////////////////////////////////////////////// 58 ///////////////////////////////////////////////////////////////////////
57 // Property Accessors 59 // Property Accessors
58 /////////////////////////////////////////////////////////////////////// 60 ///////////////////////////////////////////////////////////////////////
59 this.isAnimated = function() { return true; }; 61 this.isAnimated = function() { return true; };
60 this.getShaderDef = function() { return bumpMetalMaterialDef; }; 62 this.getShaderDef = function() { return bumpMetalMaterialDef; };
61 63
62 /////////////////////////////////////////////////////////////////////// 64 ///////////////////////////////////////////////////////////////////////
63 // Material Property Accessors 65 // Material Property Accessors
64 /////////////////////////////////////////////////////////////////////// 66 ///////////////////////////////////////////////////////////////////////
65 this._propNames = ["u_light0Diff", "u_colMap", "u_normalMap", "u_glowMap" ]; 67 this._propNames = ["u_light0Diff", "u_colMap", "u_normalMap", "u_glowMap" ];
66 this._propLabels = ["Diffuse Color", "Diffuse Map", "Bump Map", "Specular Map" ]; 68 this._propLabels = ["Diffuse Color", "Diffuse Map", "Bump Map", "Specular Map" ];
67 this._propTypes = ["color", "file", "file", "file" ]; 69 this._propTypes = ["color", "file", "file", "file" ];
68 this._propValues = []; 70 this._propValues = [];
69 71
70 this._propValues[ this._propNames[0] ] = [0.3, 0.3, 0.3, 1.0]; 72 this._propValues[ this._propNames[0] ] = this._defaultLightDiff;
71 this._propValues[ this._propNames[1] ] = this._defaultDiffuseTexture.slice(0); 73 this._propValues[ this._propNames[1] ] = this._defaultDiffuseTexture.slice(0);
72 this._propValues[ this._propNames[2] ] = this._defaultNormalTexture.slice(0); 74 this._propValues[ this._propNames[2] ] = this._defaultNormalTexture.slice(0);
73 this._propValues[ this._propNames[3] ] = this._defaultSpecularTexture.slice(0); 75 this._propValues[ this._propNames[3] ] = this._defaultSpecularTexture.slice(0);
74 76
75 77
76 /////////////////////////////////////////////////////////////////////// 78 ///////////////////////////////////////////////////////////////////////
77 // Methods 79 // Methods
78 /////////////////////////////////////////////////////////////////////// 80 ///////////////////////////////////////////////////////////////////////
79 81
80 this.init = function( world ) 82 this.init = function( world )
81 { 83 {
82 // save the world 84 // save the world
83 if (world) { 85 if (world) {
84 this.setWorld( world ); 86 this.setWorld( world );
85 } 87 }
86 88
87 // set up the shader 89 // set up the shader
88 this._shader = new RDGE.jshader(); 90 this._shader = new RDGE.jshader();
89 this._shader.def = bumpMetalMaterialDef; 91 this._shader.def = bumpMetalMaterialDef;
90 this._shader.init(); 92 this._shader.init();
93
94 // set up the material node
95 this._materialNode = RDGE.createMaterialNode( this.getShaderName() + "_" + world.generateUniqueNodeID() );
96 this._materialNode.setShader(this._shader);
91 97
92 // set up the material node 98 this.setShaderValues();
93 this._materialNode = RDGE.createMaterialNode( this.getShaderName() + "_" + world.generateUniqueNodeID() ); 99 this.update(0);
94 this._materialNode.setShader(this._shader); 100 };
95 101
96 this.setShaderValues(); 102 this.resetToDefault = function()
97 this.update(0); 103 {
98 }; 104 this._propValues[ this._propNames[0] ] = this._defaultLightDiff;
105 this._propValues[ this._propNames[1] ] = this._defaultDiffuseTexture.slice(0);
106 this._propValues[ this._propNames[2] ] = this._defaultNormalTexture.slice(0);
107 this._propValues[ this._propNames[3] ] = this._defaultSpecularTexture.slice(0);
108 for (var i=0; i<4; i++)
109 this.setProperty( this._propNames[i], this._propValues[this._propNames[i]] );
110};
99}; 111};
100 112
113
101/////////////////////////////////////////////////////////////////////////////////////// 114///////////////////////////////////////////////////////////////////////////////////////
102// RDGE shader 115// RDGE shader
103 116
104// shader spec (can also be loaded from a .JSON file, or constructed at runtime) 117// shader spec (can also be loaded from a .JSON file, or constructed at runtime)
105var bumpMetalMaterialDef = bumpMetalShaderDef = 118var bumpMetalMaterialDef = bumpMetalShaderDef =
106{ 119{
107 'shaders': 120 'shaders':
108 { 121 {
109 // this shader is being referenced by file 122 // this shader is being referenced by file
110 'defaultVShader':"assets/shaders/test_vshader.glsl", 123 'defaultVShader':"assets/shaders/test_vshader.glsl",
111 'defaultFShader':"assets/shaders/test_fshader.glsl", 124 'defaultFShader':"assets/shaders/test_fshader.glsl",
112 125
113 // this shader is inline 126