diff options
author | Kris Kowal | 2012-07-06 12:34:53 -0700 |
---|---|---|
committer | Kris Kowal | 2012-07-06 15:01:48 -0700 |
commit | 3644cb6def4f681c99959e5729e78ea353441fad (patch) | |
tree | f8a886f4829e507cc4956db37cff2580cae6003d /js/helper-classes/RDGE/src/core/script/fx | |
parent | 04343eda8c2f870b0da55cfdc8003c99fe1cc4de (diff) | |
download | ninja-3644cb6def4f681c99959e5729e78ea353441fad.tar.gz |
Normalize to unix line terminators
Diffstat (limited to 'js/helper-classes/RDGE/src/core/script/fx')
-rwxr-xr-x | js/helper-classes/RDGE/src/core/script/fx/blur.js | 434 | ||||
-rwxr-xr-x | js/helper-classes/RDGE/src/core/script/fx/ssao.js | 278 |
2 files changed, 356 insertions, 356 deletions
diff --git a/js/helper-classes/RDGE/src/core/script/fx/blur.js b/js/helper-classes/RDGE/src/core/script/fx/blur.js index a8788968..aa76b9ad 100755 --- a/js/helper-classes/RDGE/src/core/script/fx/blur.js +++ b/js/helper-classes/RDGE/src/core/script/fx/blur.js | |||
@@ -1,217 +1,217 @@ | |||
1 | /* <copyright> | 1 | /* <copyright> |
2 | Copyright (c) 2012, Motorola Mobility, Inc | 2 | Copyright (c) 2012, Motorola Mobility, Inc |
3 | All Rights Reserved. | 3 | All Rights Reserved. |
4 | BSD License. | 4 | BSD License. |
5 | 5 | ||
6 | Redistribution and use in source and binary forms, with or without | 6 | Redistribution and use in source and binary forms, with or without |
7 | modification, are permitted provided that the following conditions are met: | 7 | modification, are permitted provided that the following conditions are met: |
8 | 8 | ||
9 | - Redistributions of source code must retain the above copyright notice, | 9 | - Redistributions of source code must retain the above copyright notice, |
10 | this list of conditions and the following disclaimer. | 10 | this list of conditions and the following disclaimer. |
11 | - Redistributions in binary form must reproduce the above copyright | 11 | - Redistributions in binary form must reproduce the above copyright |
12 | notice, this list of conditions and the following disclaimer in the | 12 | notice, this list of conditions and the following disclaimer in the |
13 | documentation and/or other materials provided with the distribution. | 13 | documentation and/or other materials provided with the distribution. |
14 | - Neither the name of Motorola Mobility nor the names of its contributors | 14 | - Neither the name of Motorola Mobility nor the names of its contributors |
15 | may be used to endorse or promote products derived from this software | 15 | may be used to endorse or promote products derived from this software |
16 | without specific prior written permission. | 16 | without specific prior written permission. |
17 | 17 | ||
18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
21 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | 21 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
22 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 22 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
23 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 23 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
24 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 24 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
25 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 25 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
26 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 26 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
27 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 27 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
28 | POSSIBILITY OF SUCH DAMAGE. | 28 | POSSIBILITY OF SUCH DAMAGE. |
29 | </copyright> */ | 29 | </copyright> */ |
30 | 30 | ||
31 | 31 | ||
32 | // RDGE namespaces | 32 | // RDGE namespaces |
33 | var RDGE = RDGE || {}; | 33 | var RDGE = RDGE || {}; |
34 | RDGE.fx = RDGE.fx || {}; | 34 | RDGE.fx = RDGE.fx || {}; |
35 | 35 | ||
36 | /** | 36 | /** |
37 | * Implements a 5x5 blur. | 37 | * Implements a 5x5 blur. |
38 | * See http://prideout.net/archive/bloom/ | 38 | * See http://prideout.net/archive/bloom/ |
39 | * @param mipSizes - up to three pow2 mip sizes to be separately blurred | 39 | * @param mipSizes - up to three pow2 mip sizes to be separately blurred |
40 | * and combined with the src image, e.g. [256,128,64] | 40 | * and combined with the src image, e.g. [256,128,64] |
41 | * @param enAuxTexture - true to enable an extra texture to be added to | 41 | * @param enAuxTexture - true to enable an extra texture to be added to |
42 | * the weighted blur mips (see doBlur) | 42 | * the weighted blur mips (see doBlur) |
43 | */ | 43 | */ |
44 | RDGE.fx.fxBlur = function (mipSizes, enAuxTexture) { | 44 | RDGE.fx.fxBlur = function (mipSizes, enAuxTexture) { |
45 | var separableBlurCombine_fshader = [ | 45 | var separableBlurCombine_fshader = [ |
46 | "#ifdef GL_ES", | 46 | "#ifdef GL_ES", |
47 | "precision highp float;", | 47 | "precision highp float;", |
48 | "#endif", | 48 | "#endif", |
49 | 49 | ||
50 | "varying vec2 vTexcoord;", // base tex coord | 50 | "varying vec2 vTexcoord;", // base tex coord |
51 | "uniform vec4 vWeights;", // blend weights | 51 | "uniform vec4 vWeights;", // blend weights |
52 | 52 | ||
53 | enAuxTexture ? "uniform sampler2D sTextureAux;" : "", // aux image (unweighted) | 53 | enAuxTexture ? "uniform sampler2D sTextureAux;" : "", // aux image (unweighted) |
54 | "uniform sampler2D sTexture1;", // source texture #1 | 54 | "uniform sampler2D sTexture1;", // source texture #1 |
55 | mipSizes[0] ? "uniform sampler2D sTexture2;" : "", // source texture #2 | 55 | mipSizes[0] ? "uniform sampler2D sTexture2;" : "", // source texture #2 |
56 | mipSizes[1] ? "uniform sampler2D sTexture3;" : "", // source texture #3 | 56 | mipSizes[1] ? "uniform sampler2D sTexture3;" : "", // source texture #3 |
57 | mipSizes[2] ? "uniform sampler2D sTexture4;" : "", // source texture #4 | 57 | mipSizes[2] ? "uniform sampler2D sTexture4;" : "", // source texture #4 |
58 | 58 | ||
59 | "void main()", | 59 | "void main()", |
60 | "{", | 60 | "{", |
61 | "vec4 blurCol = vWeights.x * texture2D(sTexture1, vTexcoord, -32.0);", | 61 | "vec4 blurCol = vWeights.x * texture2D(sTexture1, vTexcoord, -32.0);", |
62 | mipSizes[0] ? "blurCol += vWeights.y * texture2D(sTexture2, vTexcoord, -32.0);" : "", | 62 | mipSizes[0] ? "blurCol += vWeights.y * texture2D(sTexture2, vTexcoord, -32.0);" : "", |
63 | mipSizes[1] ? "blurCol += vWeights.z * texture2D(sTexture3, vTexcoord, -32.0);" : "", | 63 | mipSizes[1] ? "blurCol += vWeights.z * texture2D(sTexture3, vTexcoord, -32.0);" : "", |
64 | mipSizes[2] ? "blurCol += vWeights.w * texture2D(sTexture4, vTexcoord, -32.0);" : "", | 64 | mipSizes[2] ? "blurCol += vWeights.w * texture2D(sTexture4, vTexcoord, -32.0);" : "", |
65 | 65 | ||
66 | enAuxTexture ? "gl_FragColor = texture2D(sTextureAux, vTexcoord, -32.0) + blurCol;" : "gl_FragColor = blurCol;", | 66 | enAuxTexture ? "gl_FragColor = texture2D(sTextureAux, vTexcoord, -32.0) + blurCol;" : "gl_FragColor = blurCol;", |
67 | "}" | 67 | "}" |
68 | 68 | ||
69 | ].join("\n"); | 69 | ].join("\n"); |
70 | 70 | ||
71 | 71 | ||
72 | function renderInitBlur(quad) { | 72 | function renderInitBlur(quad) { |
73 | quad.shader = RDGE.createShader(gl, 'separableBlur_vshader', 'separableBlur_fshader', ["vert", "texcoord"]); | 73 | quad.shader = RDGE.createShader(gl, 'separableBlur_vshader', 'separableBlur_fshader', ["vert", "texcoord"]); |
74 | quad.renderObj = new RDGE.RenderObject(quad.shader); | 74 | quad.renderObj = new RDGE.RenderObject(quad.shader); |
75 | 75 | ||
76 | quad.vertBuffer = quadBuf.vertexObject; | 76 | quad.vertBuffer = quadBuf.vertexObject; |
77 | quad.uvBuffer = quadBuf.texCoordObject; | 77 | quad.uvBuffer = quadBuf.texCoordObject; |
78 | 78 | ||
79 | quad.renderObj.addTexture("sTexture", 0, RDGE.UNIFORMTYPE.TEXTURE2D); | 79 | quad.renderObj.addTexture("sTexture", 0, RDGE.UNIFORMTYPE.TEXTURE2D); |
80 | 80 | ||
81 | quad.renderObj.addBuffers(quad.vertBuffer, gl.ARRAY_BUFFER, 3, 0, gl.FLOAT); | 81 | quad.renderObj.addBuffers(quad.vertBuffer, gl.ARRAY_BUFFER, 3, 0, gl.FLOAT); |
82 | quad.renderObj.addBuffers(quad.uvBuffer, gl.ARRAY_BUFFER, 2, 2, gl.FLOAT); | 82 | quad.renderObj.addBuffers(quad.uvBuffer, gl.ARRAY_BUFFER, 2, 2, gl.FLOAT); |
83 | }; | 83 | }; |
84 | 84 | ||
85 | function renderInitCombine(quad) { | 85 | function renderInitCombine(quad) { |
86 | quad.shader = RDGE.createShader(gl, 'separableBlur_vshader', separableBlurCombine_fshader, ["vert", "texcoord"]); | 86 | quad.shader = RDGE.createShader(gl, 'separableBlur_vshader', separableBlurCombine_fshader, ["vert", "texcoord"]); |
87 | quad.renderObj = new RDGE.RenderObject(quad.shader); | 87 | quad.renderObj = new RDGE.RenderObject(quad.shader); |
88 | 88 | ||
89 | quad.vertBuffer = quadBuf.vertexObject; | 89 | quad.vertBuffer = quadBuf.vertexObject; |
90 | quad.uvBuffer = quadBuf.texCoordObject; | 90 | quad.uvBuffer = quadBuf.texCoordObject; |
91 | 91 | ||
92 | quad.renderObj.addTexture("sTexture1", 0, RDGE.UNIFORMTYPE.TEXTURE2D); | 92 | quad.renderObj.addTexture("sTexture1", 0, RDGE.UNIFORMTYPE.TEXTURE2D); |
93 | quad.renderObj.addTexture("sTexture2", 1, RDGE.UNIFORMTYPE.TEXTURE2D); | 93 | quad.renderObj.addTexture("sTexture2", 1, RDGE.UNIFORMTYPE.TEXTURE2D); |
94 | quad.renderObj.addTexture("sTexture3", 2, RDGE.UNIFORMTYPE.TEXTURE2D); | 94 | quad.renderObj.addTexture("sTexture3", 2, RDGE.UNIFORMTYPE.TEXTURE2D); |
95 | quad.renderObj.addTexture("sTexture4", 3, RDGE.UNIFORMTYPE.TEXTURE2D); | 95 | quad.renderObj.addTexture("sTexture4", 3, RDGE.UNIFORMTYPE.TEXTURE2D); |
96 | quad.renderObj.addTexture("sTextureAux", 4, RDGE.UNIFORMTYPE.TEXTURE2D); | 96 | quad.renderObj.addTexture("sTextureAux", 4, RDGE.UNIFORMTYPE.TEXTURE2D); |
97 | 97 | ||
98 | quad.renderObj.addBuffers(quad.vertBuffer, gl.ARRAY_BUFFER, 3, 0, gl.FLOAT); | 98 | quad.renderObj.addBuffers(quad.vertBuffer, gl.ARRAY_BUFFER, 3, 0, gl.FLOAT); |
99 | quad.renderObj.addBuffers(quad.uvBuffer, gl.ARRAY_BUFFER, 2, 2, gl.FLOAT); | 99 | quad.renderObj.addBuffers(quad.uvBuffer, gl.ARRAY_BUFFER, 2, 2, gl.FLOAT); |
100 | }; | 100 | }; |
101 | 101 | ||
102 | // Screen aligned quad geometry | 102 | // Screen aligned quad geometry |
103 | var quadBuf = getScreenAlignedQuad(); | 103 | var quadBuf = getScreenAlignedQuad(); |
104 | 104 | ||
105 | // Fbos for each mip level; two sets are used to pingpong horizontal and vertical blur | 105 | // Fbos for each mip level; two sets are used to pingpong horizontal and vertical blur |
106 | mipSizes = mipSizes || [128, 64, 32]; | 106 | mipSizes = mipSizes || [128, 64, 32]; |
107 | 107 | ||
108 | this.fboSet1 = []; | 108 | this.fboSet1 = []; |
109 | this.fboSet2 = []; | 109 | this.fboSet2 = []; |
110 | 110 | ||
111 | for (var i in mipSizes) { | 111 | for (var i in mipSizes) { |
112 | this.fboSet1.push(createRenderTargetTexture(mipSizes[i], mipSizes[i])); | 112 | this.fboSet1.push(createRenderTargetTexture(mipSizes[i], mipSizes[i])); |
113 | this.fboSet2.push(createRenderTargetTexture(mipSizes[i], mipSizes[i])); | 113 | this.fboSet2.push(createRenderTargetTexture(mipSizes[i], mipSizes[i])); |
114 | }; | 114 | }; |
115 | 115 | ||
116 | // Blitter for downsampling | 116 | // Blitter for downsampling |
117 | this.blitQuad = new RDGE.ScreenQuad(null); | 117 | this.blitQuad = new RDGE.ScreenQuad(null); |
118 | this.blitQuad.initialize(RDGE.renderInitScreenQuad); | 118 | this.blitQuad.initialize(RDGE.renderInitScreenQuad); |
119 | 119 | ||
120 | // Blur shader | 120 | // Blur shader |