aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge/materials/julia-material.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib/rdge/materials/julia-material.js')
-rw-r--r--js/lib/rdge/materials/julia-material.js128
1 files changed, 64 insertions, 64 deletions
diff --git a/js/lib/rdge/materials/julia-material.js b/js/lib/rdge/materials/julia-material.js
index eed9e79a..718f5b44 100644
--- a/js/lib/rdge/materials/julia-material.js
+++ b/js/lib/rdge/materials/julia-material.js
@@ -35,57 +35,57 @@ var JuliaMaterial = function JuliaMaterial() {
35 /////////////////////////////////////////////////////////////////////// 35 ///////////////////////////////////////////////////////////////////////
36 // Instance variables 36 // Instance variables
37 /////////////////////////////////////////////////////////////////////// 37 ///////////////////////////////////////////////////////////////////////
38 this._name = "Julia"; 38 this._name = "Julia";
39 this._shaderName = "julia"; 39 this._shaderName = "julia";
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 /////////////////////////////////////////////////////////////////////// 46 ///////////////////////////////////////////////////////////////////////
47 // Properties 47 // Properties
48 /////////////////////////////////////////////////////////////////////// 48 ///////////////////////////////////////////////////////////////////////
49 var u_speed_index = 0; 49 var u_speed_index = 0;
50 this._propNames = [ "u_speed" ]; 50 this._propNames = [ "u_speed" ];
51 this._propLabels = [ "Speed" ]; 51 this._propLabels = [ "Speed" ];
52 this._propTypes = [ "float" ]; 52 this._propTypes = [ "float" ];
53 this._propValues = []; 53 this._propValues = [];
54 this._propValues[this._propNames[u_speed_index]] = 1.0; 54 this._propValues[this._propNames[u_speed_index]] = 1.0;
55 55
56 /////////////////////////////////////////////////////////////////////// 56 ///////////////////////////////////////////////////////////////////////
57 // Material Property Accessors 57 // Material Property Accessors
58 /////////////////////////////////////////////////////////////////////// 58 ///////////////////////////////////////////////////////////////////////
59 this.isAnimated = function() { return true; }; 59 this.isAnimated = function() { return true; };
60 this.getShaderDef = function() { return JuliaMaterialDef; } 60 this.getShaderDef = function() { return JuliaMaterialDef; }
61 61
62 /////////////////////////////////////////////////////////////////////// 62 ///////////////////////////////////////////////////////////////////////
63 // Methods 63 // Methods
64 /////////////////////////////////////////////////////////////////////// 64 ///////////////////////////////////////////////////////////////////////
65 65
66 this.init = function( world ) { 66 this.init = function( world ) {
67 // save the world 67 // save the world
68 if (world) this.setWorld( world ); 68 if (world) this.setWorld( world );
69 69
70 // set up the shader 70 // set up the shader
71 this._shader = new RDGE.jshader(); 71 this._shader = new RDGE.jshader();
72 this._shader.def = JuliaMaterialDef; 72 this._shader.def = JuliaMaterialDef;
73 this._shader.init(); 73 this._shader.init();
74 74
75 // set up the material node 75 // set up the material node
76 this._materialNode = RDGE.createMaterialNode("juliaMaterial" + "_" + world.generateUniqueNodeID()); 76 this._materialNode = RDGE.createMaterialNode("juliaMaterial" + "_" + world.generateUniqueNodeID());
77 this._materialNode.setShader(this._shader); 77 this._materialNode.setShader(this._shader);
78 78
79 this._time = 0; 79 this._time = 0;
80 if (this._shader && this._shader['default']) { 80 if (this._shader && this._shader['default']) {
81 this._shader['default'].u_time.set( [this._time] ); 81 this._shader['default'].u_time.set( [this._time] );
82 } 82 }
83 83
84 // set the shader values in the shader 84 // set the shader values in the shader
85 this.setShaderValues(); 85 this.setShaderValues();
86 this.setResolution( [world.getViewportWidth(),world.getViewportHeight()] ); 86 this.setResolution( [world.getViewportWidth(),world.getViewportHeight()] );
87 this.update( 0 ); 87 this.update( 0 );
88 }; 88 };
89} 89}
90 90
91/////////////////////////////////////////////////////////////////////////////////////// 91///////////////////////////////////////////////////////////////////////////////////////
@@ -94,41 +94,41 @@ var JuliaMaterial = function JuliaMaterial() {
94// shader spec (can also be loaded from a .JSON file, or constructed at runtime) 94// shader spec (can also be loaded from a .JSON file, or constructed at runtime)
95var JuliaMaterialDef = 95var JuliaMaterialDef =
96{'shaders': 96{'shaders':
97 { 97 {
98 'defaultVShader':"assets/shaders/Basic.vert.glsl", 98 'defaultVShader':"assets/shaders/Basic.vert.glsl",
99 'defaultFShader':"assets/shaders/Julia.frag.glsl" 99 'defaultFShader':"assets/shaders/Julia.frag.glsl"
100 }, 100 },
101 'techniques': 101 'techniques':
102 { 102 {
103 'default': 103 'default':
104 [ 104 [
105 { 105 {
106 'vshader' : 'defaultVShader', 106 'vshader' : 'defaultVShader',
107 'fshader' : 'defaultFShader', 107 'fshader' : 'defaultFShader',
108 // attributes 108 // attributes
109 'attributes' : 109 'attributes' :
110 { 110 {
111 'vert' : { 'type' : 'vec3' }, 111 'vert' : { 'type' : 'vec3' },
112 'normal' : { 'type' : 'vec3' }, 112 'normal' : { 'type' : 'vec3' },
113 'texcoord' : { 'type' : 'vec2' } 113 'texcoord' : { 'type' : 'vec2' }
114 }, 114 },
115 // parameters 115 // parameters
116 'params' : 116 'params' :
117 { 117 {
118 'u_time' : { 'type' : 'float' }, 118 'u_time' : { 'type' : 'float' },
119 'u_speed' : { 'type' : 'float' }, 119 'u_speed' : { 'type' : 'float' },
120 'u_resolution' : { 'type' : 'vec2' }, 120 'u_resolution' : { 'type' : 'vec2' },
121 }, 121 },
122 122
123 // render states 123 // render states
124 'states' : 124 'states' :
125 { 125 {
126 'depthEnable' : true, 126 'depthEnable' : true,
127 'offset':[1.0, 0.1] 127 'offset':[1.0, 0.1]
128 } 128 }
129 } 129 }
130 ] 130 ]
131 } 131 }
132}; 132};
133 133
134JuliaMaterial.prototype = new PulseMaterial(); 134JuliaMaterial.prototype = new PulseMaterial();