diff options
author | hwc487 | 2012-03-22 15:32:19 -0700 |
---|---|---|
committer | hwc487 | 2012-03-22 15:32:19 -0700 |
commit | 31e924e1b8b8da8342b3ff2341c8284915486c0b (patch) | |
tree | 560ec8c2ffbd91d7f06d7ae9ad51b78ad7b07e76 /js/lib/rdge/materials | |
parent | 4cd4d29ae10b87f7b280d537b8980d207a22dd43 (diff) | |
download | ninja-31e924e1b8b8da8342b3ff2341c8284915486c0b.tar.gz |
Added Paris and Raiders materials
Diffstat (limited to 'js/lib/rdge/materials')
-rw-r--r-- | js/lib/rdge/materials/radial-blur-material.js | 2 | ||||
-rw-r--r-- | js/lib/rdge/materials/water-material.js | 84 |
2 files changed, 81 insertions, 5 deletions
diff --git a/js/lib/rdge/materials/radial-blur-material.js b/js/lib/rdge/materials/radial-blur-material.js index 91eebcff..f4a4baa2 100644 --- a/js/lib/rdge/materials/radial-blur-material.js +++ b/js/lib/rdge/materials/radial-blur-material.js | |||
@@ -275,7 +275,6 @@ var radialBlurMaterialDef = | |||
275 | }; | 275 | }; |
276 | 276 | ||
277 | 277 | ||
278 | /* | ||
279 | var RaidersMaterial = function RaidersMaterial() | 278 | var RaidersMaterial = function RaidersMaterial() |
280 | { | 279 | { |
281 | // initialize the inherited members | 280 | // initialize the inherited members |
@@ -295,7 +294,6 @@ if (typeof exports === "object") | |||
295 | { | 294 | { |
296 | exports.RaidersMaterial = RaidersMaterial; | 295 | exports.RaidersMaterial = RaidersMaterial; |
297 | } | 296 | } |
298 | */ | ||
299 | 297 | ||
300 | 298 | ||
301 | RadialBlurMaterial.prototype = new Material(); | 299 | RadialBlurMaterial.prototype = new Material(); |
diff --git a/js/lib/rdge/materials/water-material.js b/js/lib/rdge/materials/water-material.js index 565055a1..b7413f55 100644 --- a/js/lib/rdge/materials/water-material.js +++ b/js/lib/rdge/materials/water-material.js | |||
@@ -117,7 +117,6 @@ var waterMaterialDef = | |||
117 | } | 117 | } |
118 | }; | 118 | }; |
119 | 119 | ||
120 | /* | ||
121 | var ParisMaterial = function ParisMaterial() | 120 | var ParisMaterial = function ParisMaterial() |
122 | { | 121 | { |
123 | // initialize the inherited members | 122 | // initialize the inherited members |
@@ -125,19 +124,98 @@ var ParisMaterial = function ParisMaterial() | |||
125 | this.inheritedFrom(); | 124 | this.inheritedFrom(); |
126 | 125 | ||
127 | this._name = "ParisMaterial"; | 126 | this._name = "ParisMaterial"; |
128 | this._shaderName = "water"; | 127 | this._shaderName = "paris"; |
129 | 128 | ||
130 | this._texMap = 'assets/images/paris.png'; | 129 | this._texMap = 'assets/images/paris.png'; |
131 | this._propValues[ this._propNames[0] ] = this._texMap.slice(0); | 130 | this._propValues[ this._propNames[0] ] = this._texMap.slice(0); |
132 | 131 | ||
133 | this._diffuseColor = [0.5, 0.5, 0.5, 0.5]; | 132 | this._diffuseColor = [0.5, 0.5, 0.5, 0.5]; |
134 | this._propValues[ this._propNames[1] ] = this._diffuseColor.slice(); | 133 | this._propValues[ this._propNames[1] ] = this._diffuseColor.slice(); |
134 | |||
135 | // duplcate method requirde | ||
136 | this.dup = function( world ) { | ||
137 | // allocate a new uber material | ||
138 | var newMat = new ParisMaterial(); | ||
139 | |||
140 | // copy over the current values; | ||
141 | var propNames = [], propValues = [], propTypes = [], propLabels = []; | ||
142 | this.getAllProperties( propNames, propValues, propTypes, propLabels); | ||
143 | var n = propNames.length; | ||
144 | for (var i=0; i<n; i++) | ||
145 | newMat.setProperty( propNames[i], propValues[i] ); | ||
146 | |||
147 | return newMat; | ||
148 | }; | ||
149 | |||
150 | this.init = function( world ) { | ||
151 | // save the world | ||
152 | if (world) this.setWorld( world ); | ||
153 | |||
154 | // set up the shader | ||
155 | this._shader = new jshader(); | ||
156 | this._shader.def = parisMaterialDef; | ||
157 | this._shader.init(); | ||
158 | |||
159 | // set up the material node | ||
160 | this._materialNode = createMaterialNode("parisMaterial" + "_" + world.generateUniqueNodeID()); | ||
161 | this._materialNode.setShader(this._shader); | ||
162 | |||
163 | this._time = 0; | ||
164 | if (this._shader && this._shader['default']) { | ||
165 | this._shader['default'].u_time.set( [this._time] ); | ||
166 | } | ||
167 | |||
168 | // set the shader values in the shader | ||
169 | this.updateTexture(); | ||
170 | this.setResolution( [world.getViewportWidth(),world.getViewportHeight()] ); | ||
171 | this.update( 0 ); | ||
172 | } | ||
135 | } | 173 | } |
174 | |||
136 | ParisMaterial.prototype = new PulseMaterial(); | 175 | ParisMaterial.prototype = new PulseMaterial(); |
137 | if (typeof exports === "object") { | 176 | if (typeof exports === "object") { |
138 | exports.ParisMaterial = ParisMaterial; | 177 | exports.ParisMaterial = ParisMaterial; |
139 | } | 178 | } |
140 | */ | 179 | |
180 | // shader spec (can also be loaded from a .JSON file, or constructed at runtime) | ||
181 | var parisMaterialDef = | ||
182 | {'shaders': | ||
183 | { | ||
184 | 'defaultVShader':"assets/shaders/Basic.vert.glsl", | ||
185 | 'defaultFShader':"assets/shaders/Paris.frag.glsl" | ||
186 | }, | ||
187 | 'techniques': | ||
188 | { | ||
189 | 'default': | ||
190 | [ | ||
191 | { | ||
192 | 'vshader' : 'defaultVShader', | ||
193 | 'fshader' : 'defaultFShader', | ||
194 | // attributes | ||
195 | 'attributes' : | ||
196 | { | ||
197 | 'vert' : { 'type' : 'vec3' }, | ||
198 | 'normal' : { 'type' : 'vec3' }, | ||
199 | 'texcoord' : { 'type' : 'vec2' } | ||
200 | }, | ||
201 | // parameters | ||
202 | 'params' : | ||
203 | { | ||
204 | 'u_tex0': { 'type' : 'tex2d' }, | ||
205 | 'u_time' : { 'type' : 'float' }, | ||
206 | 'u_resolution' : { 'type' : 'vec2' } | ||
207 | }, | ||
208 | |||
209 | // render states | ||
210 | 'states' : | ||
211 | { | ||
212 | 'depthEnable' : true, | ||
213 | 'offset':[1.0, 0.1] | ||
214 | } | ||
215 | } | ||
216 | ] | ||
217 | } | ||
218 | }; | ||
141 | 219 | ||
142 | 220 | ||
143 | WaterMaterial.prototype = new PulseMaterial(); | 221 | WaterMaterial.prototype = new PulseMaterial(); |