aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge/materials/z-invert-material.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib/rdge/materials/z-invert-material.js')
-rw-r--r--js/lib/rdge/materials/z-invert-material.js132
1 files changed, 66 insertions, 66 deletions
diff --git a/js/lib/rdge/materials/z-invert-material.js b/js/lib/rdge/materials/z-invert-material.js
index 0d62d1b0..c35b7d7f 100644
--- a/js/lib/rdge/materials/z-invert-material.js
+++ b/js/lib/rdge/materials/z-invert-material.js
@@ -1,8 +1,8 @@
1/* <copyright> 1/* <copyright>
2 This file contains proprietary software owned by Motorola Mobility, Inc.<br/> 2This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3 No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> 3No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
4 (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. 4(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5 </copyright> */ 5</copyright> */
6 6
7 7
8var PulseMaterial = require("js/lib/rdge/materials/pulse-material").PulseMaterial; 8var PulseMaterial = require("js/lib/rdge/materials/pulse-material").PulseMaterial;
@@ -12,106 +12,106 @@ var ZInvertMaterial = function ZInvertMaterial() {
12 /////////////////////////////////////////////////////////////////////// 12 ///////////////////////////////////////////////////////////////////////
13 // Instance variables 13 // Instance variables
14 /////////////////////////////////////////////////////////////////////// 14 ///////////////////////////////////////////////////////////////////////
15 this._name = "ZInvertMaterial"; 15 this._name = "ZInvertMaterial";
16 this._shaderName = "zinvert"; 16 this._shaderName = "zinvert";
17 17
18 this._texMap = 'assets/images/rocky-normal.jpg'; 18 this._texMap = 'assets/images/rocky-normal.jpg';
19 19
20 this._time = 0.0; 20 this._time = 0.0;
21 this._dTime = 0.01; 21 this._dTime = 0.01;
22 22
23 /////////////////////////////////////////////////////////////////////// 23 ///////////////////////////////////////////////////////////////////////
24 // Properties 24 // Properties
25 /////////////////////////////////////////////////////////////////////// 25 ///////////////////////////////////////////////////////////////////////
26 // all defined in parent PulseMaterial.js 26 // all defined in parent PulseMaterial.js
27 // load the local default value 27 // load the local default value
28 this._propValues[ this._propNames[0] ] = this._texMap.slice(0); 28 this._propValues[this._propNames[0]] = this._texMap.slice(0);
29 29
30 /////////////////////////////////////////////////////////////////////// 30 ///////////////////////////////////////////////////////////////////////
31 // Methods 31 // Methods
32 /////////////////////////////////////////////////////////////////////// 32 ///////////////////////////////////////////////////////////////////////
33 // duplcate method requirde 33 // duplicate method required
34 this.dup = function( world ) { 34 this.dup = function (world) {
35 // allocate a new uber material 35 // allocate a new uber material
36 var newMat = new ZInvertMaterial(); 36 var newMat = new ZInvertMaterial();
37 37
38 // copy over the current values; 38 // copy over the current values;
39 var propNames = [], propValues = [], propTypes = [], propLabels = []; 39 var propNames = [], propValues = [], propTypes = [], propLabels = [];
40 this.getAllProperties( propNames, propValues, propTypes, propLabels); 40 this.getAllProperties(propNames, propValues, propTypes, propLabels);
41 var n = propNames.length; 41 var n = propNames.length;
42 for (var i=0; i<n; i++) { 42 for (var i = 0; i < n; i++) {
43 newMat.setProperty( propNames[i], propValues[i] ); 43 newMat.setProperty(propNames[i], propValues[i]);
44 } 44 }
45 45
46 return newMat; 46 return newMat;
47 }; 47 };
48 48
49 this.init = function( world ) { 49 this.init = function (world) {
50 // save the world 50 // save the world
51 if (world) this.setWorld( world ); 51 if (world) this.setWorld(world);
52 52
53 // set up the shader 53 // set up the shader
54 this._shader = new jshader(); 54 this._shader = new RDGE.jshader();
55 this._shader.def = zInvertMaterialDef; 55 this._shader.def = zInvertMaterialDef;
56 this._shader.init(); 56 this._shader.init();
57 57
58 // set up the material node 58 // set up the material node
59 this._materialNode = createMaterialNode("zInvertMaterial" + "_" + world.generateUniqueNodeID()); 59 this._materialNode = RDGE.createMaterialNode("zInvertMaterial" + "_" + world.generateUniqueNodeID());
60 this._materialNode.setShader(this._shader); 60 this._materialNode.setShader(this._shader);
61 61
62 this._time = 0; 62 this._time = 0;
63 if (this._shader && this._shader['default']) { 63 if (this._shader && this._shader['default']) {
64 this._shader['default'].u_time.set( [this._time] ); 64 this._shader['default'].u_time.set([this._time]);
65 } 65 }
66 66
67 // set up the texture 67 // set up the texture
68 var texMapName = this._propValues[this._propNames[0]]; 68 var texMapName = this._propValues[this._propNames[0]];
69 this._glTex = new Texture( world, texMapName ); 69 this._glTex = new Texture( world, texMapName );
70 70
71 // set the shader values in the shader 71 // set the shader values in the shader
72 this.updateTexture(); 72 this.updateTexture();
73 this.setResolution( [world.getViewportWidth(),world.getViewportHeight()] ); 73 this.setResolution([world.getViewportWidth(), world.getViewportHeight()]);
74 this.update( 0 ); 74 this.update(0);
75 } 75 };
76}; 76};
77 77
78/////////////////////////////////////////////////////////////////////////////////////// 78///////////////////////////////////////////////////////////////////////////////////////
79// RDGE shader 79// RDGE shader
80 80
81// shader spec (can also be loaded from a .JSON file, or constructed at runtime) 81// shader spec (can also be loaded from a .JSON file, or constructed at runtime)
82var zInvertMaterialDef = 82var zInvertMaterialDef =
83{'shaders': 83{ 'shaders':
84 { 84 {
85 'defaultVShader':"assets/shaders/Basic.vert.glsl", 85 'defaultVShader': "assets/shaders/Basic.vert.glsl",
86 'defaultFShader':"assets/shaders/ZInvert.frag.glsl" 86 'defaultFShader': "assets/shaders/ZInvert.frag.glsl"
87 }, 87 },
88 'techniques': 88 'techniques':
89 { 89 {
90 'default': 90 'default':
91 [ 91 [
92 { 92 {
93 'vshader' : 'defaultVShader', 93 'vshader': 'defaultVShader',
94 'fshader' : 'defaultFShader', 94 'fshader': 'defaultFShader',
95 // attributes 95 // attributes
96 'attributes' : 96 'attributes':
97 { 97 {
98 'vert' : { 'type' : 'vec3' }, 98 'vert': { 'type': 'vec3' },
99 'normal' : { 'type' : 'vec3' }, 99 'normal': { 'type': 'vec3' },
100 'texcoord' : { 'type' : 'vec2' } 100 'texcoord': { 'type': 'vec2' }
101 }, 101 },
102 // parameters 102 // parameters
103 'params' : 103 'params':
104 { 104 {
105 'u_tex0': { 'type' : 'tex2d' }, 105 'u_tex0': { 'type': 'tex2d' },
106 'u_time' : { 'type' : 'float' }, 106 'u_time': { 'type': 'float' },
107 'u_resolution' : { 'type' : 'vec2' } 107 'u_resolution': { 'type': 'vec2' }
108 }, 108 },
109 109
110 // render states 110 // render states
111 'states' : 111 'states':
112 { 112 {
113 'depthEnable' : true, 113 'depthEnable': true,
114 'offset':[1.0, 0.1] 114 'offset': [1.0, 0.1]
115 } 115 }
116 } 116 }
117 ] 117 ]