aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge/materials/deform-material.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib/rdge/materials/deform-material.js')
-rw-r--r--js/lib/rdge/materials/deform-material.js102
1 files changed, 56 insertions, 46 deletions
diff --git a/js/lib/rdge/materials/deform-material.js b/js/lib/rdge/materials/deform-material.js
index 234f22e4..274369d6 100644
--- a/js/lib/rdge/materials/deform-material.js
+++ b/js/lib/rdge/materials/deform-material.js
@@ -51,21 +51,21 @@ var DeformMaterial = function DeformMaterial() {
51 /////////////////////////////////////////////////////////////////////// 51 ///////////////////////////////////////////////////////////////////////
52 // all defined in parent PulseMaterial.js 52 // all defined in parent PulseMaterial.js
53 // load the local default value 53 // load the local default value
54 var u_tex0_index = 0; 54 var u_tex0_index = 0;
55 this._propNames = ["u_tex0", "u_speed" ]; 55 this._propNames = ["u_tex0", "u_speed" ];
56 this._propLabels = ["Texture map", "Speed" ]; 56 this._propLabels = ["Texture map", "Speed" ];
57 this._propTypes = ["file", "float" ]; 57 this._propTypes = ["file", "float" ];
58 this._propValues = []; 58 this._propValues = [];
59 this._propValues[this._propNames[0]] = this._defaultTexMap.slice(0); 59 this._propValues[this._propNames[0]] = this._defaultTexMap.slice(0);
60 this._propValues[this._propNames[1]] = 1.0; 60 this._propValues[this._propNames[1]] = 1.0;
61 61
62 this._propValues[ this._propNames[ u_tex0_index] ] = this._defaultTexMap.slice(0); 62 this._propValues[ this._propNames[ u_tex0_index] ] = this._defaultTexMap.slice(0);
63 63
64 /////////////////////////////////////////////////////////////////////// 64 ///////////////////////////////////////////////////////////////////////
65 // Material Property Accessors 65 // Material Property Accessors
66 /////////////////////////////////////////////////////////////////////// 66 ///////////////////////////////////////////////////////////////////////
67 this.isAnimated = function() { return true; }; 67 this.isAnimated = function() { return true; };
68 this.getShaderDef = function() { return pulseMaterialDef; } 68 this.getShaderDef = function() { return pulseMaterialDef; }
69 69
70 /////////////////////////////////////////////////////////////////////// 70 ///////////////////////////////////////////////////////////////////////
71 71
@@ -98,50 +98,60 @@ var DeformMaterial = function DeformMaterial() {
98 this.setResolution([world.getViewportWidth(), world.getViewportHeight()]); 98 this.setResolution([world.getViewportWidth(), world.getViewportHeight()]);
99 this.update(0); 99 this.update(0);
100 }; 100 };
101
102 this.resetToDefault = function()
103 {
104 this._propValues[this._propNames[0]] = this._defaultTexMap.slice(0);
105 this._propValues[this._propNames[1]] = 1.0;
106
107 var nProps = this._propNames.length;
108 for (var i=0; i<nProps; i++)
109 this.setProperty( this._propNames[i], this._propValues[this._propNames[i]] );
110 };
101}; 111};
102 112
103/////////////////////////////////////////////////////////////////////////////////////// 113///////////////////////////////////////////////////////////////////////////////////////
104// RDGE shader 114// RDGE shader
105 115
106// shader spec (can also be loaded from a .JSON file, or constructed at runtime) 116// shader spec (can also be loaded from a .JSON file, or constructed at runtime)
107var deformMaterialDef = 117var deformMaterialDef =
108{'shaders': 118{'shaders':
109 { 119 {
110 'defaultVShader':"assets/shaders/Basic.vert.glsl", 120 'defaultVShader':"assets/shaders/Basic.vert.glsl",
111 'defaultFShader':"assets/shaders/Deform.frag.glsl" 121 'defaultFShader':"assets/shaders/Deform.frag.glsl"
112 }, 122 },
113 'techniques': 123 'techniques':
114 { 124 {
115 'default': 125 'default':
116 [ 126 [
117 { 127 {
118 'vshader' : 'defaultVShader', 128 'vshader' : 'defaultVShader',
119 'fshader' : 'defaultFShader', 129 'fshader' : 'defaultFShader',
120 // attributes 130 // attributes
121 'attributes' : 131 'attributes' :
122 { 132 {
123 'vert' : { 'type' : 'vec3' }, 133 'vert' : { 'type' : 'vec3' },
124 'normal' : { 'type' : 'vec3' }, 134 'normal' : { 'type' : 'vec3' },
125 'texcoord' : { 'type' : 'vec2' } 135 'texcoord' : { 'type' : 'vec2' }
126 }, 136 },
127 // parameters 137 // parameters
128 'params' : 138 'params' :
129 { 139 {
130 'u_tex0': { 'type' : 'tex2d' }, 140 'u_tex0': { 'type' : 'tex2d' },
131 'u_time' : { 'type' : 'float' }, 141 'u_time' : { 'type' : 'float' },
132 'u_speed' : { 'type' : 'float' }, 142 'u_speed' : { 'type' : 'float' },
133 'u_resolution' : { 'type' : 'vec2' } 143 'u_resolution' : { 'type' : 'vec2' }
134 }, 144 },
135 145
136 // render states 146 // render states
137 'states' : 147 'states' :
138 { 148 {
139 'depthEnable' : true, 149 'depthEnable' : true,
140 'offset':[1.0, 0.1] 150 'offset':[1.0, 0.1]
141 } 151 }
142 } 152 }
143 ] 153 ]
144 } 154 }
145}; 155};
146 156
147DeformMaterial.prototype = new PulseMaterial(); 157DeformMaterial.prototype = new PulseMaterial();