aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge/materials/keleidoscope-material.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib/rdge/materials/keleidoscope-material.js')
-rw-r--r--js/lib/rdge/materials/keleidoscope-material.js136
1 files changed, 68 insertions, 68 deletions
diff --git a/js/lib/rdge/materials/keleidoscope-material.js b/js/lib/rdge/materials/keleidoscope-material.js
index 648bf401..90340e00 100644
--- a/js/lib/rdge/materials/keleidoscope-material.js
+++ b/js/lib/rdge/materials/keleidoscope-material.js
@@ -35,13 +35,13 @@ var KeleidoscopeMaterial = function KeleidoscopeMaterial() {
35 /////////////////////////////////////////////////////////////////////// 35 ///////////////////////////////////////////////////////////////////////
36 // Instance variables 36 // Instance variables
37 /////////////////////////////////////////////////////////////////////// 37 ///////////////////////////////////////////////////////////////////////
38 this._name = "Keleidoscope"; 38 this._name = "Keleidoscope";
39 this._shaderName = "keleidoscope"; 39 this._shaderName = "keleidoscope";
40 40
41 this._defaultTexMap = 'assets/images/rocky-normal.jpg'; 41 this._defaultTexMap = 'assets/images/rocky-normal.jpg';
42 42
43 this._time = 0.0; 43 this._time = 0.0;
44 this._dTime = 0.01; 44 this._dTime = 0.01;
45 45
46 // array textures indexed by shader uniform name 46 // array textures indexed by shader uniform name
47 this._glTextures = []; 47 this._glTextures = [];
@@ -49,21 +49,21 @@ var KeleidoscopeMaterial = function KeleidoscopeMaterial() {
49 /////////////////////////////////////////////////////////////////////// 49 ///////////////////////////////////////////////////////////////////////
50 // Properties 50 // Properties
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, u_speed_index = 1; 54 var u_tex0_index = 0, u_speed_index = 1;
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[u_tex0_index]] = this._defaultTexMap.slice(0); 59 this._propValues[this._propNames[u_tex0_index]] = this._defaultTexMap.slice(0);
60 this._propValues[this._propNames[u_speed_index]] = 1.0; 60 this._propValues[this._propNames[u_speed_index]] = 1.0;
61 61
62 /////////////////////////////////////////////////////////////////////// 62 ///////////////////////////////////////////////////////////////////////
63 // Material Property Accessors 63 // Material Property Accessors
64 /////////////////////////////////////////////////////////////////////// 64 ///////////////////////////////////////////////////////////////////////
65 this.isAnimated = function() { return true; }; 65 this.isAnimated = function() { return true; };
66 this.getShaderDef = function() { return keleidoscopeMaterialDef; } 66 this.getShaderDef = function() { return keleidoscopeMaterialDef; }
67 67
68 /////////////////////////////////////////////////////////////////////// 68 ///////////////////////////////////////////////////////////////////////
69 69
@@ -71,31 +71,31 @@ var KeleidoscopeMaterial = function KeleidoscopeMaterial() {
71 /////////////////////////////////////////////////////////////////////// 71 ///////////////////////////////////////////////////////////////////////
72 // Methods 72 // Methods
73 /////////////////////////////////////////////////////////////////////// 73 ///////////////////////////////////////////////////////////////////////
74 // duplcate method requirde 74 // duplcate method requirde
75 75
76 this.init = function( world ) { 76 this.init = function( world ) {
77 // save the world 77 // save the world
78 if (world) this.setWorld( world ); 78 if (world) this.setWorld( world );
79 79
80 // set up the shader 80 // set up the shader
81 this._shader = new RDGE.jshader(); 81 this._shader = new RDGE.jshader();
82 this._shader.def = keleidoscopeMaterialDef; 82 this._shader.def = keleidoscopeMaterialDef;
83 this._shader.init(); 83 this._shader.init();
84 84
85 // set up the material node 85 // set up the material node
86 this._materialNode = RDGE.createMaterialNode("keleidoscopeMaterial" + "_" + world.generateUniqueNodeID()); 86 this._materialNode = RDGE.createMaterialNode("keleidoscopeMaterial" + "_" + world.generateUniqueNodeID());
87 this._materialNode.setShader(this._shader); 87 this._materialNode.setShader(this._shader);
88 88
89 this._time = 0; 89 this._time = 0;
90 if (this._shader && this._shader['default']) { 90 if (this._shader && this._shader['default']) {
91 this._shader['default'].u_time.set( [this._time] ); 91 this._shader['default'].u_time.set( [this._time] );
92 } 92 }
93 93
94 // set the shader values in the shader 94 // set the shader values in the shader
95 this.setShaderValues(); 95 this.setShaderValues();
96 this.setResolution( [world.getViewportWidth(),world.getViewportHeight()] ); 96 this.setResolution( [world.getViewportWidth(),world.getViewportHeight()] );
97 this.update( 0 ); 97 this.update( 0 );
98 }; 98 };
99}; 99};
100 100
101/////////////////////////////////////////////////////////////////////////////////////// 101///////////////////////////////////////////////////////////////////////////////////////
@@ -104,42 +104,42 @@ var KeleidoscopeMaterial = function KeleidoscopeMaterial() {
104// shader spec (can also be loaded from a .JSON file, or constructed at runtime) 104// shader spec (can also be loaded from a .JSON file, or constructed at runtime)
105var keleidoscopeMaterialDef = 105var keleidoscopeMaterialDef =
106{'shaders': 106{'shaders':
107 { 107 {
108 'defaultVShader':"assets/shaders/Basic.vert.glsl", 108 'defaultVShader':"assets/shaders/Basic.vert.glsl",
109 'defaultFShader':"assets/shaders/Keleidoscope.frag.glsl" 109 'defaultFShader':"assets/shaders/Keleidoscope.frag.glsl"
110 }, 110 },
111 'techniques': 111 'techniques':
112 { 112 {
113 'default': 113 'default':
114 [ 114 [
115 { 115 {
116 'vshader' : 'defaultVShader', 116 'vshader' : 'defaultVShader',
117 'fshader' : 'defaultFShader', 117 'fshader' : 'defaultFShader',
118 // attributes 118 // attributes
119 'attributes' : 119 'attributes' :
120 { 120 {
121 'vert' : { 'type' : 'vec3' }, 121 'vert' : { 'type' : 'vec3' },
122 'normal' : { 'type' : 'vec3' }, 122 'normal' : { 'type' : 'vec3' },
123 'texcoord' : { 'type' : 'vec2' } 123 'texcoord' : { 'type' : 'vec2' }
124 }, 124 },
125 // parameters 125 // parameters
126 'params' : 126 'params' :
127 { 127 {
128 'u_tex0': { 'type' : 'tex2d' }, 128 'u_tex0': { 'type' : 'tex2d' },
129 'u_speed' : { 'type' : 'float' }, 129 'u_speed' : { 'type' : 'float' },
130 'u_time' : { 'type' : 'float' }, 130 'u_time' : { 'type' : 'float' },
131 'u_resolution' : { 'type' : 'vec2' }, 131 'u_resolution' : { 'type' : 'vec2' },
132 }, 132 },
133 133
134 // render states 134 // render states
135 'states' : 135 'states' :
136 { 136 {
137 'depthEnable' : true, 137 'depthEnable' : true,
138 'offset':[1.0, 0.1] 138 'offset':[1.0, 0.1]
139 } 139 }
140 } 140 }
141 ] 141 ]
142 } 142 }
143}; 143};
144 144
145KeleidoscopeMaterial.prototype = new PulseMaterial(); 145KeleidoscopeMaterial.prototype = new PulseMaterial();