aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/lib/rdge/materials/fly-material.js2
-rw-r--r--js/lib/rdge/materials/mandel-material.js48
-rw-r--r--js/lib/rdge/materials/plasma-material.js109
-rw-r--r--js/lib/rdge/materials/pulse-material.js2
-rw-r--r--js/lib/rdge/materials/radial-blur-material.js119
-rwxr-xr-xjs/lib/rdge/materials/radial-gradient-material.js274
-rw-r--r--js/lib/rdge/materials/relief-tunnel-material.js44
-rw-r--r--js/lib/rdge/materials/square-tunnel-material.js44
-rw-r--r--js/lib/rdge/materials/star-material.js44
-rw-r--r--js/lib/rdge/materials/taper-material.js74
-rw-r--r--js/lib/rdge/materials/tunnel-material.js44
-rw-r--r--js/lib/rdge/materials/twist-material.js57
-rw-r--r--js/lib/rdge/materials/twist-vert-material.js197
-rw-r--r--js/lib/rdge/materials/z-invert-material.js49
14 files changed, 211 insertions, 896 deletions
diff --git a/js/lib/rdge/materials/fly-material.js b/js/lib/rdge/materials/fly-material.js
index 12e18f7f..7b880a2e 100644
--- a/js/lib/rdge/materials/fly-material.js
+++ b/js/lib/rdge/materials/fly-material.js
@@ -36,7 +36,7 @@ var FlyMaterial = function FlyMaterial() {
36 // Material Property Accessors 36 // Material Property Accessors
37 /////////////////////////////////////////////////////////////////////// 37 ///////////////////////////////////////////////////////////////////////
38 this.isAnimated = function() { return true; }; 38 this.isAnimated = function() { return true; };
39 this.getShaderDef = function() { return flyMaterialDef; } 39 this.getShaderDef = function() { return flyMaterialDef; };
40 40
41 /////////////////////////////////////////////////////////////////////// 41 ///////////////////////////////////////////////////////////////////////
42 // Methods 42 // Methods
diff --git a/js/lib/rdge/materials/mandel-material.js b/js/lib/rdge/materials/mandel-material.js
index e75d74ba..e1c19145 100644
--- a/js/lib/rdge/materials/mandel-material.js
+++ b/js/lib/rdge/materials/mandel-material.js
@@ -14,7 +14,7 @@ var MandelMaterial = function MandelMaterial() {
14 this._name = "MandelMaterial"; 14 this._name = "MandelMaterial";
15 this._shaderName = "mandel"; 15 this._shaderName = "mandel";
16 16
17 this._texMap = 'assets/images/rocky-normal.jpg'; 17 this._defaultTexMap = 'assets/images/rocky-normal.jpg';
18 18
19 this._time = 0.0; 19 this._time = 0.0;
20 this._dTime = 0.01; 20 this._dTime = 0.01;
@@ -27,32 +27,23 @@ var MandelMaterial = function MandelMaterial() {
27 /////////////////////////////////////////////////////////////////////// 27 ///////////////////////////////////////////////////////////////////////
28 // Material Property Accessors 28 // Material Property Accessors
29 /////////////////////////////////////////////////////////////////////// 29 ///////////////////////////////////////////////////////////////////////
30 var u_tex0_index = 0, u_speed_index = 1;
31 this._propNames = ["u_tex0", "u_speed" ];
32 this._propLabels = ["Texture map", "Speed" ];
33 this._propTypes = ["file", "float" ];
34 this._propValues = [];
35 this._propValues[this._propNames[u_tex0_index]] = this._defaultTexMap.slice(0);
36 this._propValues[this._propNames[u_speed_index]] = 1.0;
30 37
31 /////////////////////////////////////////////////////////////////////// 38 ///////////////////////////////////////////////////////////////////////
32 39
33 this.isAnimated = function() { 40 this.isAnimated = function() { return true; };
34 return true; 41 this.getShaderDef = function() { return MandelMaterialDef; }
35 };
36 42
37 /////////////////////////////////////////////////////////////////////// 43 ///////////////////////////////////////////////////////////////////////
38 // Methods 44 // Methods
39 /////////////////////////////////////////////////////////////////////// 45 ///////////////////////////////////////////////////////////////////////
40 // duplcate method requirde 46 // duplcate method requirde
41 this.dup = function( world ) {
42 // get the current values;
43 var propNames = [], propValues = [], propTypes = [], propLabels = [];
44 this.getAllProperties(propNames, propValues, propTypes, propLabels);
45
46 // allocate a new material
47 var newMat = new MandelMaterial();
48
49 // copy over the current values;
50 var n = propNames.length;
51 for (var i = 0; i < n; i++)
52 newMat.setProperty(propNames[i], propValues[i]);
53
54 return newMat;
55 };
56 47
57 this.init = function( world ) { 48 this.init = function( world ) {
58 // save the world 49 // save the world
@@ -72,27 +63,11 @@ var MandelMaterial = function MandelMaterial() {
72 this._shader['default'].u_time.set( [this._time] ); 63 this._shader['default'].u_time.set( [this._time] );
73 } 64 }
74 65
75 // set up the texture
76 var texMapName = this._propValues[this._propNames[0]];
77 this._glTex = new Texture( world, texMapName );
78
79 // set the shader values in the shader 66 // set the shader values in the shader
67 this.setShaderValues();
80 this.setResolution( [world.getViewportWidth(),world.getViewportHeight()] ); 68 this.setResolution( [world.getViewportWidth(),world.getViewportHeight()] );
81 this.update( 0 ); 69 this.update( 0 );
82 }; 70 };
83
84 this.update = function( time ) {
85 var material = this._materialNode;
86 if (material) {
87 var technique = material.shaderProgram['default'];
88 var renderer = RDGE.globals.engine.getContext().renderer;
89 if (renderer && technique) {
90 if (this._shader && this._shader['default'])
91 this._shader['default'].u_time.set( [this._time] );
92 this._time = time;
93 }
94 }
95 };
96}; 71};
97 72
98/////////////////////////////////////////////////////////////////////////////////////// 73///////////////////////////////////////////////////////////////////////////////////////
@@ -124,6 +99,7 @@ var MandelMaterialDef =
124 { 99 {
125 'u_tex0': { 'type' : 'tex2d' }, 100 'u_tex0': { 'type' : 'tex2d' },
126 'u_time' : { 'type' : 'float' }, 101 'u_time' : { 'type' : 'float' },
102 'u_speed' : { 'type' : 'float' },
127 'u_resolution' : { 'type' : 'vec2' }, 103 'u_resolution' : { 'type' : 'vec2' },
128 }, 104 },
129 105
diff --git a/js/lib/rdge/materials/plasma-material.js b/js/lib/rdge/materials/plasma-material.js
index 1db207d6..c1e5524c 100644
--- a/js/lib/rdge/materials/plasma-material.js
+++ b/js/lib/rdge/materials/plasma-material.js
@@ -24,7 +24,7 @@ var PlasmaMaterial = function PlasmaMaterial() {
24 /////////////////////////////////////////////////////////////////////// 24 ///////////////////////////////////////////////////////////////////////
25 // Properties 25 // Properties
26 /////////////////////////////////////////////////////////////////////// 26 ///////////////////////////////////////////////////////////////////////
27 this._propNames = ["wave", "wave1", "wave2", "speed"]; 27 this._propNames = ["u_wave", "u_wave1", "u_wave2", "u_speed"];
28 this._propLabels = ["Wave", "Wave 1", "Wave 2", "Speed"]; 28 this._propLabels = ["Wave", "Wave 1", "Wave 2", "Speed"];
29 this._propTypes = ["float", "float", "float", "float"]; 29 this._propTypes = ["float", "float", "float", "float"];
30 30
@@ -39,68 +39,17 @@ var PlasmaMaterial = function PlasmaMaterial() {
39 // Property Accessors 39 // Property Accessors
40 /////////////////////////////////////////////////////////////////////// 40 ///////////////////////////////////////////////////////////////////////
41 this.getShaderName = function() { return this._shaderName; }; 41 this.getShaderName = function() { return this._shaderName; };
42
43 this.isAnimated = function() { return true; }; 42 this.isAnimated = function() { return true; };
43 this.getShaderDef = function() { return plasmaShaderDef; };
44 44
45 /////////////////////////////////////////////////////////////////////// 45 ///////////////////////////////////////////////////////////////////////
46 // Material Property Accessors 46 // Material Property Accessors
47 /////////////////////////////////////////////////////////////////////// 47 ///////////////////////////////////////////////////////////////////////
48 // duplcate method requirde
49 this.dup = function (world) {
50 // get the current values;
51 var propNames = [], propValues = [], propTypes = [], propLabels = [];
52 this.getAllProperties(propNames, propValues, propTypes, propLabels);
53
54 // allocate a new material
55 var newMat = new PlasmaMaterial();
56
57 // copy over the current values;
58 var n = propNames.length;
59 for (var i = 0; i < n; i++)
60 newMat.setProperty(propNames[i], propValues[i]);
61
62 return newMat;
63 };
64
65 this.setProperty = function( prop, value )
66 {
67 // make sure we have legitimate imput
68 var ok = this.validateProperty( prop, value );
69 if (!ok) {
70 console.log( "invalid property in Water Material:" + prop + " : " + value );
71 }
72
73 switch (prop)
74 {
75 case "wave":
76 this._wave = value;
77 break;
78
79 case "wave1":
80 this._wave1 = value;
81 break;
82
83 case "wave2":
84 this._wave2 = value;
85 break;
86
87 case "speed":
88 this._speed = value;
89 break;
90 }
91
92 this.updateParameters();
93 };
94
95 ///////////////////////////////////////////////////////////////////////
96 48
97 ////////////////////////