aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge/materials/mandel-material.js
diff options
context:
space:
mode:
authorKris Kowal2012-07-06 11:52:06 -0700
committerKris Kowal2012-07-06 15:01:48 -0700
commit648ee61ae84216d0236e0dbc211addc13b2cfa3a (patch)
tree8f0f55557bd0c47a84e49c1977c950645d284607 /js/lib/rdge/materials/mandel-material.js
parentaedd14b18695d031f695d27dfbd94df5614495bb (diff)
downloadninja-648ee61ae84216d0236e0dbc211addc13b2cfa3a.tar.gz
Expand tabs
Diffstat (limited to 'js/lib/rdge/materials/mandel-material.js')
-rw-r--r--js/lib/rdge/materials/mandel-material.js130
1 files changed, 65 insertions, 65 deletions
diff --git a/js/lib/rdge/materials/mandel-material.js b/js/lib/rdge/materials/mandel-material.js
index 48377fe4..41b7793e 100644
--- a/js/lib/rdge/materials/mandel-material.js
+++ b/js/lib/rdge/materials/mandel-material.js
@@ -35,60 +35,60 @@ var MandelMaterial = function MandelMaterial() {
35 /////////////////////////////////////////////////////////////////////// 35 ///////////////////////////////////////////////////////////////////////
36 // Instance variables 36 // Instance variables
37 /////////////////////////////////////////////////////////////////////// 37 ///////////////////////////////////////////////////////////////////////
38 this._name = "Mandel"; 38 this._name = "Mandel";
39 this._shaderName = "mandel"; 39 this._shaderName = "mandel";
40 40
41 this._time = 0.0; 41 this._time = 0.0;
42 this._dTime = 0.01; 42 this._dTime = 0.01;
43 43
44 /////////////////////////////////////////////////////////////////////// 44 ///////////////////////////////////////////////////////////////////////
45 // Properties 45 // Properties
46 /////////////////////////////////////////////////////////////////////// 46 ///////////////////////////////////////////////////////////////////////
47 // properties inherited from PulseMaterial 47 // properties inherited from PulseMaterial
48 48
49 /////////////////////////////////////////////////////////////////////// 49 ///////////////////////////////////////////////////////////////////////
50 // Material Property Accessors 50 // Material Property Accessors
51 /////////////////////////////////////////////////////////////////////// 51 ///////////////////////////////////////////////////////////////////////
52 var u_speed_index = 0; 52 var u_speed_index = 0;
53 this._propNames = [ "u_speed" ]; 53 this._propNames = [ "u_speed" ];
54 this._propLabels = [ "Speed" ]; 54 this._propLabels = [ "Speed" ];
55 this._propTypes = [ "float" ]; 55 this._propTypes = [ "float" ];
56 this._propValues = []; 56 this._propValues = [];
57 this._propValues[this._propNames[u_speed_index]] = 1.0; 57 this._propValues[this._propNames[u_speed_index]] = 1.0;
58 58
59 /////////////////////////////////////////////////////////////////////// 59 ///////////////////////////////////////////////////////////////////////
60 60
61 this.isAnimated = function() { return true; }; 61 this.isAnimated = function() { return true; };
62 this.getShaderDef = function() { return MandelMaterialDef; } 62 this.getShaderDef = function() { return MandelMaterialDef; }
63 63
64 /////////////////////////////////////////////////////////////////////// 64 ///////////////////////////////////////////////////////////////////////
65 // Methods 65 // Methods
66 /////////////////////////////////////////////////////////////////////// 66 ///////////////////////////////////////////////////////////////////////
67 // duplcate method requirde 67 // duplcate method requirde
68 68
69 this.init = function( world ) { 69 this.init = function( world ) {
70 // save the world 70 // save the world
71 if (world) this.setWorld( world ); 71 if (world) this.setWorld( world );
72 72
73 // set up the shader 73 // set up the shader
74 this._shader = new RDGE.jshader(); 74 this._shader = new RDGE.jshader();
75 this._shader.def = MandelMaterialDef; 75 this._shader.def = MandelMaterialDef;
76 this._shader.init(); 76 this._shader.init();
77 77
78 // set up the material node 78 // set up the material node
79 this._materialNode = RDGE.createMaterialNode("mandelMaterial" + "_" + world.generateUniqueNodeID()); 79 this._materialNode = RDGE.createMaterialNode("mandelMaterial" + "_" + world.generateUniqueNodeID());
80 this._materialNode.setShader(this._shader); 80 this._materialNode.setShader(this._shader);
81 81
82 this._time = 0; 82 this._time = 0;
83 if (this._shader && this._shader['default']) { 83 if (this._shader && this._shader['default']) {
84 this._shader['default'].u_time.set( [this._time] ); 84 this._shader['default'].u_time.set( [this._time] );
85 } 85 }
86 86
87 // set the shader values in the shader 87 // set the shader values in the shader
88 this.setShaderValues(); 88 this.setShaderValues();
89 this.setResolution( [world.getViewportWidth(),world.getViewportHeight()] ); 89 this.setResolution( [world.getViewportWidth(),world.getViewportHeight()] );
90 this.update( 0 ); 90 this.update( 0 );
91 }; 91 };
92}; 92};
93 93
94/////////////////////////////////////////////////////////////////////////////////////// 94///////////////////////////////////////////////////////////////////////////////////////
@@ -97,41 +97,41 @@ var MandelMaterial = function MandelMaterial() {
97// shader spec (can also be loaded from a .JSON file, or constructed at runtime) 97// shader spec (can also be loaded from a .JSON file, or constructed at runtime)
98var MandelMaterialDef = 98var MandelMaterialDef =
99{'shaders': 99{'shaders':
100 { 100 {
101 'defaultVShader':"assets/shaders/Basic.vert.glsl", 101 'defaultVShader':"assets/shaders/Basic.vert.glsl",
102 'defaultFShader':"assets/shaders/Mandel.frag.glsl" 102 'defaultFShader':"assets/shaders/Mandel.frag.glsl"
103 }, 103 },
104 'techniques': 104 'techniques':
105 { 105 {
106 'default': 106 'default':
107 [ 107 [
108 { 108 {
109 'vshader' : 'defaultVShader', 109 'vshader' : 'defaultVShader',
110 'fshader' : 'defaultFShader', 110 'fshader' : 'defaultFShader',
111 // attributes 111 // attributes
112 'attributes' : 112 'attributes' :
113 { 113 {
114 'vert' : { 'type' : 'vec3' }, 114 'vert' : { 'type' : 'vec3' },
115 'normal' : { 'type' : 'vec3' }, 115 'normal' : { 'type' : 'vec3' },
116 'texcoord' : { 'type' : 'vec2' } 116 'texcoord' : { 'type' : 'vec2' }
117 }, 117 },
118 // parameters 118 // parameters
119 'params' : 119 'params' :
120 { 120 {
121 'u_time' : { 'type' : 'float' }, 121 'u_time' : { 'type' : 'float' },
122 'u_speed' : { 'type' : 'float' }, 122 'u_speed' : { 'type' : 'float' },
123 'u_resolution' : { 'type' : 'vec2' }, 123 'u_resolution' : { 'type' : 'vec2' },
124 }, 124 },
125 125
126 // render states 126 // render states
127 'states' : 127 'states' :
128 { 128 {
129 'depthEnable' : true, 129 'depthEnable' : true,
130 'offset':[1.0, 0.1] 130 'offset':[1.0, 0.1]
131 } 131 }
132 } 132 }
133 ] 133 ]
134 } 134 }
135}; 135};
136 136
137MandelMaterial.prototype = new PulseMaterial(); 137MandelMaterial.prototype = new PulseMaterial();