diff options
author | Ananya Sen | 2012-07-09 16:52:49 -0700 |
---|---|---|
committer | Ananya Sen | 2012-07-09 16:52:49 -0700 |
commit | 2eb84584f44b8c774479d1af2ee1d810597474cf (patch) | |
tree | 64cb3e09a8daeb340261dd7f3869c73f7b90b643 /js/helper-classes/RDGE/src/core/script/ShaderManager.js | |
parent | bf9dba001ec84243e2f12cd13b0c0ae020fba4a2 (diff) | |
parent | cee0deca695359ab468bd06d0e05ed3b2010b338 (diff) | |
download | ninja-2eb84584f44b8c774479d1af2ee1d810597474cf.tar.gz |
Merge branch 'refs/heads/ninja-internal-master' into codemirror-custom-theme-removal
Conflicts:
js/code-editor/codemirror-ninja/theme/lesser-dark-ninja.css
js/code-editor/codemirror-ninja/theme/xq-dark-ninja.css
Signed-off-by: Ananya Sen <Ananya.Sen@motorola.com>
Diffstat (limited to 'js/helper-classes/RDGE/src/core/script/ShaderManager.js')
-rwxr-xr-x | js/helper-classes/RDGE/src/core/script/ShaderManager.js | 221 |
1 files changed, 111 insertions, 110 deletions
diff --git a/js/helper-classes/RDGE/src/core/script/ShaderManager.js b/js/helper-classes/RDGE/src/core/script/ShaderManager.js index 06d44da5..061e9071 100755 --- a/js/helper-classes/RDGE/src/core/script/ShaderManager.js +++ b/js/helper-classes/RDGE/src/core/script/ShaderManager.js | |||
@@ -1,110 +1,111 @@ | |||
1 | /* <copyright> | 1 | /* <copyright> |
2 | Copyright (c) 2012, Motorola Mobility, Inc | 2 | Copyright (c) 2012, Motorola Mobility LLC. |
3 | All Rights Reserved. | 3 | All Rights Reserved. |
4 | BSD License. | 4 | |
5 | 5 | Redistribution and use in source and binary forms, with or without | |
6 | Redistribution and use in source and binary forms, with or without | 6 | modification, are permitted provided that the following conditions are met: |
7 | modification, are permitted provided that the following conditions are met: | 7 | |
8 | 8 | * Redistributions of source code must retain the above copyright notice, | |
9 | - Redistributions of source code must retain the above copyright notice, | 9 | this list of conditions and the following disclaimer. |
10 | this list of conditions and the following disclaimer. | 10 | |
11 | - Redistributions in binary form must reproduce the above copyright | 11 | * Redistributions in binary form must reproduce the above copyright notice, |
12 | notice, this list of conditions and the following disclaimer in the | 12 | this list of conditions and the following disclaimer in the documentation |
13 | documentation and/or other materials provided with the distribution. | 13 | and/or other materials provided with the distribution. |
14 | - Neither the name of Motorola Mobility nor the names of its contributors | 14 | |
15 | may be used to endorse or promote products derived from this software | 15 | * Neither the name of Motorola Mobility LLC nor the names of its |
16 | without specific prior written permission. | 16 | contributors may be used to endorse or promote products derived from this |
17 | 17 | software without specific prior written permission. | |
18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | 18 | |
19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 20 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
21 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | 21 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
22 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 22 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
23 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 23 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
24 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 24 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
25 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 25 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
26 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 26 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
27 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 27 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
28 | POSSIBILITY OF SUCH DAMAGE. | 28 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
29 | </copyright> */ | 29 | POSSIBILITY OF SUCH DAMAGE. |
30 | 30 | </copyright> */ | |
31 | // RDGE namespaces | 31 | |
32 | var RDGE = RDGE || {}; | 32 | // RDGE namespaces |
33 | 33 | var RDGE = RDGE || {}; | |
34 | RDGE.Shader = function (name, shaderHandle, renderProc, initRenderProc, envMap) { | 34 | |
35 | this.name = name; | 35 | RDGE.Shader = function (name, shaderHandle, renderProc, initRenderProc, envMap) { |
36 | this.shaderHandle = shaderHandle; | 36 | this.name = name; |
37 | this.initRenderProc = initRenderProc; | 37 | this.shaderHandle = shaderHandle; |
38 | this.renderProc = renderProc; | 38 | this.initRenderProc = initRenderProc; |
39 | this.postRenderProc = RDGE.postRenderProcDefault; | 39 | this.renderProc = renderProc; |
40 | this.envMap = envMap; | 40 | this.postRenderProc = RDGE.postRenderProcDefault; |
41 | this.envDiff = envMap; | 41 | this.envMap = envMap; |
42 | }; | 42 | this.envDiff = envMap; |
43 | 43 | }; | |
44 | RDGE.ShaderManager = function () { | 44 | |
45 | this.shaderMap = []; | 45 | RDGE.ShaderManager = function () { |
46 | }; | 46 | this.shaderMap = []; |
47 | 47 | }; | |
48 | RDGE.ShaderManager.prototype.addShader = function (name, vShader, fShader, attribs, renderProc, initRenderProc, envMapName, envDiffMapName) { | 48 | |
49 | var shader = this.shaderMap[name]; | 49 | RDGE.ShaderManager.prototype.addShader = function (name, vShader, fShader, attribs, renderProc, initRenderProc, envMapName, envDiffMapName) { |
50 | if (shader == undefined) { | 50 | var shader = this.shaderMap[name]; |
51 | 51 | if (shader == undefined) { | |
52 | var handle = RDGE.createShader(RDGE.globals.engine.getContext().renderer.ctx, vShader, fShader, attribs); | 52 | |
53 | if (envMapName != undefined || envDiffMapName != undefined) { | 53 | var handle = RDGE.createShader(RDGE.globals.engine.getContext().renderer.ctx, vShader, fShader, attribs); |
54 | var envMap = g_texMan.loadMaterial(envMapName); | 54 | if (envMapName != undefined || envDiffMapName != undefined) { |
55 | var envDiff = g_texMan.loadMaterial(envDiffMapName); | 55 | var envMap = g_texMan.loadMaterial(envMapName); |
56 | this.shaderMap[name] = new RDGE.Shader(name, handle, renderProc, initRenderProc, envMap); | 56 | var envDiff = g_texMan.loadMaterial(envDiffMapName); |
57 | this.shaderMap[name].envDiff = envDiff; | 57 | this.shaderMap[name] = new RDGE.Shader(name, handle, renderProc, initRenderProc, envMap); |
58 | } | 58 | this.shaderMap[name].envDiff = envDiff; |
59 | else { | 59 | } |
60 | this.shaderMap[name] = new RDGE.Shader(name, handle, renderProc, initRenderProc, null); | 60 | else { |
61 | this.shaderMap[name].envDiff = null; | 61 | this.shaderMap[name] = new RDGE.Shader(name, handle, renderProc, initRenderProc, null); |
62 | } | 62 | this.shaderMap[name].envDiff = null; |
63 | 63 | } | |
64 | this.shaderMap[name].name = name; | 64 | |
65 | 65 | this.shaderMap[name].name = name; | |
66 | return this.shaderMap[name]; | 66 | |
67 | } | 67 | return this.shaderMap[name]; |
68 | 68 | } | |
69 | return shader; | 69 | |
70 | }; | 70 | return shader; |
71 | 71 | }; | |
72 | RDGE.ShaderManager.prototype.getShaderNames = function () { | 72 | |
73 | var names = []; | 73 | RDGE.ShaderManager.prototype.getShaderNames = function () { |
74 | for (var index in this.shaderMap) { | 74 | var names = []; |
75 | names.push(this.shaderMap[index].name); | 75 | for (var index in this.shaderMap) { |
76 | } | 76 | names.push(this.shaderMap[index].name); |
77 | 77 | } | |
78 | return names; | 78 | |
79 | }; | 79 | return names; |
80 | 80 | }; | |
81 | RDGE.ShaderManager.prototype.getShaderByName = function (name) { | 81 | |
82 | var shader = this.shaderMap[name]; | 82 | RDGE.ShaderManager.prototype.getShaderByName = function (name) { |
83 | 83 | var shader = this.shaderMap[name]; | |
84 | if (shader != undefined && shader != null) | 84 | |
85 | return shader; | 85 | if (shader != undefined && shader != null) |
86 | 86 | return shader; | |
87 | return null; | 87 | |
88 | }; | 88 | return null; |
89 | 89 | }; | |
90 | 90 | ||
91 | /** | 91 | |
92 | * Setup shader names | 92 | /** |
93 | **/ | 93 | * Setup shader names |
94 | RDGE.ShaderManager.prototype.init = function () { | 94 | **/ |
95 | // create shaders for each look | 95 | RDGE.ShaderManager.prototype.init = function () { |
96 | this.addShader("default", vortexVShader, vortexFShader, ["vert", "normal", "texcoord"], RDGE.renderProcDefault, RDGE.renderInitProcDefault, "material_DullPlastic.png", "material_DullPlastic.png"); | 96 | // create shaders for each look |
97 | this.addShader("barlights", vortexVShader, vortexFShader, ["vert", "normal", "texcoord"], RDGE.renderProcDefault, RDGE.renderInitProcDefault, "material_barlights.png", "material_barlightsDull.png"); | 97 | this.addShader("default", vortexVShader, vortexFShader, ["vert", "normal", "texcoord"], RDGE.renderProcDefault, RDGE.renderInitProcDefault, "material_DullPlastic.png", "material_DullPlastic.png"); |
98 | this.addShader("gloss", vortexVShader, vortexFShader, ["vert", "normal", "texcoord"], RDGE.renderProcDefault, RDGE.renderInitProcDefault, "material_gloss.png", "material_glossDull.png"); | 98 | this.addShader("barlights", vortexVShader, vortexFShader, ["vert", "normal", "texcoord"], RDGE.renderProcDefault, RDGE.renderInitProcDefault, "material_barlights.png", "material_barlightsDull.png"); |
99 | this.addShader("inGlass", vortexVShader, vortexFShader, ["vert", "normal", "texcoord"], RDGE.renderProcDefault, RDGE.renderInitProcDefault, "material_inGlass.png", "material_inGlassDull.png"); | 99 | this.addShader("gloss", vortexVShader, vortexFShader, ["vert", "normal", "texcoord"], RDGE.renderProcDefault, RDGE.renderInitProcDefault, "material_gloss.png", "material_glossDull.png"); |
100 | this.addShader("normals", vortexVShader, vortexFShader, ["vert", "normal", "texcoord"], RDGE.renderProcDefault, RDGE.renderInitProcDefault, "material_normal.png", "material_normalDull.png"); | 100 | this.addShader("inGlass", vortexVShader, vortexFShader, ["vert", "normal", "texcoord"], RDGE.renderProcDefault, RDGE.renderInitProcDefault, "material_inGlass.png", "material_inGlassDull.png"); |
101 | this.addShader("paint", vortexVShader, vortexFShader, ["vert", "normal", "texcoord"], RDGE.renderProcDefault, RDGE.renderInitProcDefault, "material_paint.png", "material_paintDull.png"); | 101 | this.addShader("normals", vortexVShader, vortexFShader, ["vert", "normal", "texcoord"], RDGE.renderProcDefault, RDGE.renderInitProcDefault, "material_normal.png", "material_normalDull.png"); |
102 | this.addShader("plastic", vortexVShader, vortexFShader, ["vert", "normal", "texcoord"], RDGE.renderProcDefault, RDGE.renderInitProcDefault, "material_plastic.png", "material_plasticDull.png"); | 102 | this.addShader("paint", vortexVShader, vortexFShader, ["vert", "normal", "texcoord"], RDGE.renderProcDefault, RDGE.renderInitProcDefault, "material_paint.png", "material_paintDull.png"); |
103 | this.addShader("shadows", vortexVShader, vortexFShader, ["vert", "normal", "texcoord"], RDGE.renderProcDefault, RDGE.renderInitProcDefault, "material_shadows.png", "material_shadowsDull.png"); | 103 | this.addShader("plastic", vortexVShader, vortexFShader, ["vert", "normal", "texcoord"], RDGE.renderProcDefault, RDGE.renderInitProcDefault, "material_plastic.png", "material_plasticDull.png"); |
104 | this.addShader("skin", vortexVShader, vortexFShader, ["vert", "normal", "texcoord"], RDGE.renderProcDefault, RDGE.renderInitProcDefault, "material_skin.png", "material_skinDull.png"); | 104 | this.addShader("shadows", vortexVShader, vortexFShader, ["vert", "normal", "texcoord"], RDGE.renderProcDefault, RDGE.renderInitProcDefault, "material_shadows.png", "material_shadowsDull.png"); |
105 | this.addShader("wax", vortexVShader, vortexFShader, ["vert", "normal", "texcoord"], RDGE.renderProcDefault, RDGE.renderInitProcDefault, "material_wax.png", "material_waxDull.png"); | 105 | this.addShader("skin", vortexVShader, vortexFShader, ["vert", "normal", "texcoord"], RDGE.renderProcDefault, RDGE.renderInitProcDefault, "material_skin.png", "material_skinDull.png"); |
106 | 106 | this.addShader("wax", vortexVShader, vortexFShader, ["vert", "normal", "texcoord"], RDGE.renderProcDefault, RDGE.renderInitProcDefault, "material_wax.png", "material_waxDull.png"); | |
107 | // used by backdrop | 107 | |
108 | this.addShader("shadowReceiver", shadow_vshader, shadow_fshader, ["vert", "normal", "texcoord"], RDGE.renderProcShadowReceiver, RDGE.renderInitShadowReceiver); | 108 | // used by backdrop |
109 | this.addShader("shadowProj", shadowProj_vshader, shadowProj_fshader, ["vert", "normal", "texcoord"], RDGE.renderProcShadowProjection, RDGE.renderInitShadowProjection); | 109 | this.addShader("shadowReceiver", shadow_vshader, shadow_fshader, ["vert", "normal", "texcoord"], RDGE.renderProcShadowReceiver, RDGE.renderInitShadowReceiver); |
110 | }; | 110 | this.addShader("shadowProj", shadowProj_vshader, shadowProj_fshader, ["vert", "normal", "texcoord"], RDGE.renderProcShadowProjection, RDGE.renderInitShadowProjection); |
111 | }; | ||