diff options
author | Valerio Virgillito | 2012-07-09 14:35:44 -0700 |
---|---|---|
committer | Valerio Virgillito | 2012-07-09 14:35:44 -0700 |
commit | 84b3327bd92faafab7954b5eb64c7abe24a3fe13 (patch) | |
tree | 3f56cbed2f08c5a81ea79eaf0bcb9bd031d8a627 /js/lib/rdge/materials/mandel-material.js | |
parent | c0a42c56f768a873ba637f5b86d5f6a84d4a3312 (diff) | |
parent | 40c6eb2c06b34f65a74d59ef9687251952858bab (diff) | |
download | ninja-84b3327bd92faafab7954b5eb64c7abe24a3fe13.tar.gz |
Merge branch 'normalize' of https://github.com/kriskowal/ninja-internal
Conflicts:
js/components/gradientpicker.reel/gradientpicker.js
js/components/tools-properties/text-properties.reel/text-properties.js
js/document/views/base.js
js/document/views/design.js
js/helper-classes/3D/StageLine.js
js/helper-classes/3D/draw-utils.js
js/lib/drawing/world.js
js/lib/geom/circle.js
js/lib/geom/line.js
js/lib/geom/rectangle.js
js/lib/geom/shape-primitive.js
js/lib/rdge/materials/bump-metal-material.js
js/lib/rdge/materials/flag-material.js
js/lib/rdge/materials/fly-material.js
js/lib/rdge/materials/julia-material.js
js/lib/rdge/materials/keleidoscope-material.js
js/lib/rdge/materials/mandel-material.js
js/lib/rdge/materials/material.js
js/lib/rdge/materials/plasma-material.js
js/lib/rdge/materials/pulse-material.js
js/lib/rdge/materials/radial-gradient-material.js
js/lib/rdge/materials/taper-material.js
js/lib/rdge/materials/twist-vert-material.js
js/lib/rdge/materials/water-material.js
js/panels/Materials/materials-library-panel.reel/materials-library-panel.html
js/panels/Materials/materials-library-panel.reel/materials-library-panel.js
js/panels/Materials/materials-popup.reel/materials-popup.html
js/panels/Materials/materials-popup.reel/materials-popup.js
js/tools/LineTool.js
Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Diffstat (limited to 'js/lib/rdge/materials/mandel-material.js')
-rw-r--r-- | js/lib/rdge/materials/mandel-material.js | 136 |
1 files changed, 68 insertions, 68 deletions
diff --git a/js/lib/rdge/materials/mandel-material.js b/js/lib/rdge/materials/mandel-material.js index 1661c63a..cc628afb 100644 --- a/js/lib/rdge/materials/mandel-material.js +++ b/js/lib/rdge/materials/mandel-material.js | |||
@@ -35,60 +35,60 @@ var MandelMaterial = function MandelMaterial() { | |||
35 | /////////////////////////////////////////////////////////////////////// | 35 | /////////////////////////////////////////////////////////////////////// |
36 | // Instance variables | 36 | // Instance variables |
37 | /////////////////////////////////////////////////////////////////////// | 37 | /////////////////////////////////////////////////////////////////////// |
38 | this._name = "Mandel"; | 38 | this._name = "Mandel"; |
39 | this._shaderName = "mandel"; | 39 | this._shaderName = "mandel"; |
40 | 40 | ||
41 | this._time = 0.0; | 41 | this._time = 0.0; |
42 | this._dTime = 0.01; | 42 | this._dTime = 0.01; |
43 | 43 | ||
44 | /////////////////////////////////////////////////////////////////////// | 44 | /////////////////////////////////////////////////////////////////////// |
45 | // Properties | 45 | // Properties |
46 | /////////////////////////////////////////////////////////////////////// | 46 | /////////////////////////////////////////////////////////////////////// |
47 | // properties inherited from PulseMaterial | 47 | // properties inherited from PulseMaterial |
48 | 48 | ||
49 | /////////////////////////////////////////////////////////////////////// | 49 | /////////////////////////////////////////////////////////////////////// |
50 | // Material Property Accessors | 50 | // Material Property Accessors |
51 | /////////////////////////////////////////////////////////////////////// | 51 | /////////////////////////////////////////////////////////////////////// |
52 | var u_speed_index = 0; | 52 | var u_speed_index = 0; |
53 | this._propNames = [ "u_speed" ]; | 53 | this._propNames = [ "u_speed" ]; |
54 | this._propLabels = [ "Speed" ]; | 54 | this._propLabels = [ "Speed" ]; |
55 | this._propTypes = [ "float" ]; | 55 | this._propTypes = [ "float" ]; |
56 | this._propValues = []; | 56 | this._propValues = []; |
57 | this._propValues[this._propNames[u_speed_index]] = 1.0; | 57 | this._propValues[this._propNames[u_speed_index]] = 1.0; |
58 | 58 | ||
59 | /////////////////////////////////////////////////////////////////////// | 59 | /////////////////////////////////////////////////////////////////////// |
60 | 60 | ||
61 | this.isAnimated = function() { return true; }; | 61 | this.isAnimated = function() { return true; }; |
62 | this.getShaderDef = function() { return MandelMaterialDef; } | 62 | this.getShaderDef = function() { return MandelMaterialDef; } |
63 | 63 | ||
64 | /////////////////////////////////////////////////////////////////////// | 64 | /////////////////////////////////////////////////////////////////////// |
65 | // Methods | 65 | // Methods |
66 | /////////////////////////////////////////////////////////////////////// | 66 | /////////////////////////////////////////////////////////////////////// |
67 | // duplcate method requirde | 67 | // duplcate method requirde |
68 | 68 | ||
69 | this.init = function( world ) { | 69 | this.init = function( world ) { |
70 | // save the world | 70 | // save the world |
71 | if (world) this.setWorld( world ); | 71 | if (world) this.setWorld( world ); |
72 | 72 | ||
73 | // set up the shader | 73 | // set up the shader |
74 | this._shader = new RDGE.jshader(); | 74 | this._shader = new RDGE.jshader(); |
75 | this._shader.def = MandelMaterialDef; | 75 | this._shader.def = MandelMaterialDef; |
76 | this._shader.init(); | 76 | this._shader.init(); |
77 | 77 | ||
78 | // set up the material node | 78 | // set up the material node |
79 | this._materialNode = RDGE.createMaterialNode("mandelMaterial" + "_" + world.generateUniqueNodeID()); | 79 | this._materialNode = RDGE.createMaterialNode("mandelMaterial" + "_" + world.generateUniqueNodeID()); |
80 | this._materialNode.setShader(this._shader); | 80 | this._materialNode.setShader(this._shader); |
81 | 81 | ||
82 | this._time = 0; | 82 | this._time = 0; |
83 | if (this._shader && this._shader['default']) { | 83 | if (this._shader && this._shader['default']) { |
84 | this._shader['default'].u_time.set( [this._time] ); | 84 | this._shader['default'].u_time.set( [this._time] ); |
85 | } | 85 | } |
86 | 86 | ||
87 | // set the shader values in the shader | 87 | // set the shader values in the shader |
88 | this.setShaderValues(); | 88 | this.setShaderValues(); |
89 | this.setResolution( [world.getViewportWidth(),world.getViewportHeight()] ); | 89 | this.setResolution( [world.getViewportWidth(),world.getViewportHeight()] ); |
90 | this.update( 0 ); | 90 | this.update( 0 ); |
91 | }; | 91 | }; |
92 | 92 | ||
93 | this.resetToDefault = function() | 93 | this.resetToDefault = function() |
94 | { | 94 | { |
@@ -97,50 +97,50 @@ var MandelMaterial = function MandelMaterial() { | |||
97 | var nProps = this._propNames.length; | 97 | var nProps = this._propNames.length; |
98 | for (var i=0; i<nProps; i++) | 98 | for (var i=0; i<nProps; i++) |
99 | this.setProperty( this._propNames[i], this._propValues[this._propNames[i]] ); | 99 | this.setProperty( this._propNames[i], this._propValues[this._propNames[i]] ); |
100 | }; | 100 | }; |
101 | }; | 101 | }; |
102 | 102 | ||
103 | /////////////////////////////////////////////////////////////////////////////////////// | 103 | /////////////////////////////////////////////////////////////////////////////////////// |
104 | // RDGE shader | 104 | // RDGE shader |
105 | 105 | ||
106 | // shader spec (can also be loaded from a .JSON file, or constructed at runtime) | 106 | // shader spec (can also be loaded from a .JSON file, or constructed at runtime) |
107 | var MandelMaterialDef = | 107 | var MandelMaterialDef = |
108 | {'shaders': | 108 | {'shaders': |
109 | { | 109 | { |
110 | 'defaultVShader':"assets/shaders/Basic.vert.glsl", | 110 | 'defaultVShader':"assets/shaders/Basic.vert.glsl", |
111 | 'defaultFShader':"assets/shaders/Mandel.frag.glsl" | 111 | 'defaultFShader':"assets/shaders/Mandel.frag.glsl" |
112 | }, | 112 | }, |
113 | 'techniques': | 113 | 'techniques': |
114 | { | 114 | { |
115 | 'default': | 115 | 'default': |
116 | [ | 116 | [ |
117 | { | 117 | { |
118 | 'vshader' : 'defaultVShader', | 118 | 'vshader' : 'defaultVShader', |
119 | 'fshader' : 'defaultFShader', | 119 | 'fshader' : 'defaultFShader', |
120 | // attributes | 120 | // attributes |
121 | 'attributes' : | 121 | 'attributes' : |
122 | { | 122 | { |
123 | 'vert' : { 'type' : 'vec3' }, | 123 | 'vert' : { 'type' : 'vec3' }, |
124 | 'normal' : { 'type' : 'vec3' }, | 124 | 'normal' : { 'type' : 'vec3' }, |
125 | 'texcoord' : { 'type' : 'vec2' } | 125 | 'texcoord' : { 'type' : 'vec2' } |
126 | }, | 126 | }, |
127 | // parameters | 127 | // parameters |
128 | 'params' : | 128 | 'params' : |
129 | { | 129 | { |
130 | 'u_time' : { 'type' : 'float' }, | 130 | 'u_time' : { 'type' : 'float' }, |
131 | 'u_speed' : { 'type' : 'float' }, | 131 | 'u_speed' : { 'type' : 'float' }, |
132 | 'u_resolution' : { 'type' : 'vec2' }, | 132 | 'u_resolution' : { 'type' : 'vec2' }, |
133 | }, | 133 | }, |
134 | 134 | ||
135 | // render states | 135 | // render states |
136 | 'states' : | 136 | 'states' : |
137 | { | 137 | { |
138 | 'depthEnable' : true, | 138 | 'depthEnable' : true, |
139 | 'offset':[1.0, 0.1] | 139 | 'offset':[1.0, 0.1] |
140 | } | 140 | } |
141 | } | 141 | } |
142 | ] | 142 | ] |
143 | } | 143 | } |
144 | }; | 144 | }; |
145 | 145 | ||
146 | MandelMaterial.prototype = new PulseMaterial(); | 146 | MandelMaterial.prototype = new PulseMaterial(); |