diff options
author | John Mayhew | 2012-04-02 16:28:39 -0700 |
---|---|---|
committer | John Mayhew | 2012-04-02 16:28:39 -0700 |
commit | b4155fb4c33675a8a7cd37473513718043fdf0ba (patch) | |
tree | 3d8c802473f2395d53d599ec9d8b70b60a4db50c /js/helper-classes/RDGE/src/core/script/fx | |
parent | 5ba9aeac94c86049423fd5d4b37b277263939c13 (diff) | |
parent | c6de22bf42be90b403491b5f87b1818d9020310c (diff) | |
download | ninja-b4155fb4c33675a8a7cd37473513718043fdf0ba.tar.gz |
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal into WorkingBranch
Conflicts:
js/helper-classes/RDGE/rdge-compiled.js
js/helper-classes/RDGE/runtime/GLRuntime.js
js/helper-classes/RDGE/src/core/script/MeshManager.js
js/helper-classes/RDGE/src/core/script/engine.js
js/helper-classes/RDGE/src/core/script/fx/ssao.js
js/helper-classes/RDGE/src/core/script/init_state.js
js/helper-classes/RDGE/src/core/script/run_state.js
js/helper-classes/RDGE/src/core/script/scenegraphNodes.js
js/helper-classes/RDGE/src/core/script/utilities.js
js/helper-classes/RDGE/src/tools/compile-rdge-core.bat
js/helper-classes/RDGE/src/tools/compile-rdge-core.sh
js/helper-classes/RDGE/src/tools/rdge-compiled.js
js/lib/drawing/world.js
js/lib/rdge/materials/bump-metal-material.js
js/lib/rdge/materials/deform-material.js
js/lib/rdge/materials/flat-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/linear-gradient-material.js
js/lib/rdge/materials/mandel-material.js
js/lib/rdge/materials/plasma-material.js
js/lib/rdge/materials/pulse-material.js
js/lib/rdge/materials/radial-blur-material.js
js/lib/rdge/materials/radial-gradient-material.js
js/lib/rdge/materials/relief-tunnel-material.js
js/lib/rdge/materials/square-tunnel-material.js
js/lib/rdge/materials/star-material.js
js/lib/rdge/materials/taper-material.js
js/lib/rdge/materials/tunnel-material.js
js/lib/rdge/materials/twist-material.js
js/lib/rdge/materials/twist-vert-material.js
js/lib/rdge/materials/uber-material.js
js/lib/rdge/materials/water-material.js
js/lib/rdge/materials/z-invert-material.js
js/preloader/Preloader.js
Diffstat (limited to 'js/helper-classes/RDGE/src/core/script/fx')
-rwxr-xr-x | js/helper-classes/RDGE/src/core/script/fx/ssao.js | 90 |
1 files changed, 45 insertions, 45 deletions
diff --git a/js/helper-classes/RDGE/src/core/script/fx/ssao.js b/js/helper-classes/RDGE/src/core/script/fx/ssao.js index 24a3c94b..5af2859d 100755 --- a/js/helper-classes/RDGE/src/core/script/fx/ssao.js +++ b/js/helper-classes/RDGE/src/core/script/fx/ssao.js | |||
@@ -8,91 +8,91 @@ var RDGE = RDGE || {}; | |||
8 | RDGE.fx = RDGE.fx || {}; | 8 | RDGE.fx = RDGE.fx || {}; |
9 | 9 | ||
10 | /** | 10 | /** |
11 | * Implements SSAO. | 11 | * Implements SSAO. |
12 | * See http://www.gamedev.net/page/resources/_/reference/programming/140/lighting-and-shading/a-simple-and-practical-approach-to-ssao-r2753 | 12 | * See http://www.gamedev.net/page/resources/_/reference/programming/140/lighting-and-shading/a-simple-and-practical-approach-to-ssao-r2753 |
13 | * @param v2ScreenSize - size of the viewport in window coordinates | 13 | * @param v2ScreenSize - size of the viewport in window coordinates |
14 | */ | 14 | */ |
15 | RDGE.fx.fxSSAO = function (enHRDepth) { | 15 | RDGE.fx.fxSSAO = function (enHRDepth) { |
16 | function renderInitSSAO(quad) { | 16 | function renderInitSSAO(quad) { |
17 | quad.shader = RDGE.createShader(RDGE.globals.gl, 'ssao_vshader', enHRDepth ? 'ssaohr_fshader' : 'ssao_fshader', ["vert", "texcoord"]); | 17 | quad.shader = RDGE.createShader(RDGE.globals.gl, 'ssao_vshader', enHRDepth ? 'ssaohr_fshader' : 'ssao_fshader', ["vert", "texcoord"]); |
18 | quad.renderObj = new RDGE.RenderObject(quad.shader); | 18 | quad.renderObj = new RDGE.RenderObject(quad.shader); |
19 | 19 | ||
20 | var quadBuf = getScreenAlignedQuad(); | 20 | var quadBuf = getScreenAlignedQuad(); |
21 | quad.vertBuffer = quadBuf.vertexObject; | 21 | quad.vertBuffer = quadBuf.vertexObject; |
22 | quad.uvBuffer = quadBuf.texCoordObject; | 22 | quad.uvBuffer = quadBuf.texCoordObject; |
23 | 23 | ||
24 | quad.renderObj.addTexture("sColMap", 0, RDGE.UNIFORMTYPE.TEXTURE2D); | 24 | quad.renderObj.addTexture("sColMap", 0, RDGE.UNIFORMTYPE.TEXTURE2D); |
25 | quad.renderObj.addTexture("sNormDepthMap", 1, RDGE.UNIFORMTYPE.TEXTURE2D); | 25 | quad.renderObj.addTexture("sNormDepthMap", 1, RDGE.UNIFORMTYPE.TEXTURE2D); |
26 | quad.renderObj.addTexture("sRandMap", 2, RDGE.UNIFORMTYPE.TEXTURE2D); | 26 | quad.renderObj.addTexture("sRandMap", 2, RDGE.UNIFORMTYPE.TEXTURE2D); |
27 | if (enHRDepth) | 27 | if (enHRDepth) |
28 | quad.renderObj.addTexture("sHRDepthMap", 3, RDGE.UNIFORMTYPE.TEXTURE2D); | 28 | quad.renderObj.addTexture("sHRDepthMap", 3, RDGE.UNIFORMTYPE.TEXTURE2D); |
29 | 29 | ||
30 | quad.renderObj.addBuffers(quad.vertBuffer, RDGE.globals.gl.ARRAY_BUFFER, 3, 0, RDGE.globals.gl.FLOAT); | 30 | quad.renderObj.addBuffers(quad.vertBuffer, RDGE.globals.gl.ARRAY_BUFFER, 3, 0, RDGE.globals.gl.FLOAT); |
31 | quad.renderObj.addBuffers(quad.uvBuffer, RDGE.globals.gl.ARRAY_BUFFER, 2, 2, RDGE.globals.gl.FLOAT); | 31 | quad.renderObj.addBuffers(quad.uvBuffer, RDGE.globals.gl.ARRAY_BUFFER, 2, 2, RDGE.globals.gl.FLOAT); |
32 | } | 32 | }; |
33 | 33 | ||
34 | // Load random normal texture | 34 | // Load random normal texture |
35 | this.randTexture = createTexture(RDGE.globals.gl, "assets/images/random_normal.png"); | 35 | this.randTexture = createTexture(RDGE.globals.gl, RDGE.globals.engine._assetPath+"images/random_normal.png"); |
36 | RDGE.globals.gl.bindTexture(RDGE.globals.gl.TEXTURE_2D, this.randTexture); | 36 | RDGE.globals.gl.bindTexture(RDGE.globals.gl.TEXTURE_2D, this.randTexture); |
37 | RDGE.globals.gl.texParameteri(RDGE.globals.gl.TEXTURE_2D, RDGE.globals.gl.TEXTURE_MIN_FILTER, RDGE.globals.gl.LINEAR); | 37 | RDGE.globals.gl.texParameteri(RDGE.globals.gl.TEXTURE_2D, RDGE.globals.gl.TEXTURE_MIN_FILTER, RDGE.globals.gl.LINEAR); |
38 | RDGE.globals.gl.texParameteri(RDGE.globals.gl.TEXTURE_2D, RDGE.globals.gl.TEXTURE_WRAP_S, RDGE.globals.gl.REPEAT); | 38 | RDGE.globals.gl.texParameteri(RDGE.globals.gl.TEXTURE_2D, RDGE.globals.gl.TEXTURE_WRAP_S, RDGE.globals.gl.REPEAT); |
39 | RDGE.globals.gl.texParameteri(RDGE.globals.gl.TEXTURE_2D, RDGE.globals.gl.TEXTURE_WRAP_T, RDGE.globals.gl.REPEAT); | 39 | RDGE.globals.gl.texParameteri(RDGE.globals.gl.TEXTURE_2D, RDGE.globals.gl.TEXTURE_WRAP_T, RDGE.globals.gl.REPEAT); |
40 | 40 | ||
41 | // Whether or not to use a high res depth texture | 41 | // Whether or not to use a high res depth texture |
42 | this.enHRDepth = enHRDepth; | 42 | this.enHRDepth = enHRDepth; |
43 | 43 | ||
44 | // Quad for full screen pass | 44 | // Quad for full screen pass |
45 | this.ssaoQuad = new RDGE.ScreenQuad(null); | 45 | this.ssaoQuad = new RDGE.ScreenQuad(null); |
46 | this.ssaoQuad.initialize(renderInitSSAO); | 46 | this.ssaoQuad.initialize(renderInitSSAO); |
47 | 47 | ||
48 | // Set up uniforms | 48 | // Set up uniforms |
49 | var activeCam = g_cameraManager.getActiveCamera(); | 49 | var activeCam = g_cameraManager.getActiveCamera(); |
50 | this.v3FrustumFLT = activeCam.getFTR(); | 50 | this.v3FrustumFLT = activeCam.getFTR(); |
51 | this.ssaoQuad.renderObj.addUniform("u_frustumFLT", this.v3FrustumFLT, RDGE.UNIFORMTYPE.FLOAT3); | 51 | this.ssaoQuad.renderObj.addUniform("u_frustumFLT", this.v3FrustumFLT, RDGE.UNIFORMTYPE.FLOAT3); |
52 | 52 | ||
53 | this.v4ArtVals = [1.0, 1.0, 1.0, 1.0]; | 53 | this.v4ArtVals = [1.0, 1.0, 1.0, 1.0]; |
54 | this.ssaoQuad.renderObj.addUniform("u_artVals", this.v4ArtVals, RDGE.UNIFORMTYPE.FLOAT4); | 54 | this.ssaoQuad.renderObj.addUniform("u_artVals", this.v4ArtVals, RDGE.UNIFORMTYPE.FLOAT4); |
55 | 55 | ||
56 | this.fRandMapSize = 64.0; | 56 | this.fRandMapSize = 64.0; |
57 | this.ssaoQuad.renderObj.addUniform("u_randMapSize", this.fRandMapSize, RDGE.UNIFORMTYPE.FLOAT); | 57 | this.ssaoQuad.renderObj.addUniform("u_randMapSize", this.fRandMapSize, RDGE.UNIFORMTYPE.FLOAT); |
58 | 58 | ||
59 | this.v2ScreenSize = [1024, 1024]; | 59 | this.v2ScreenSize = [1024, 1024]; |
60 | this.ssaoQuad.renderObj.addUniform("u_screenSize", this.v2ScreenSize, RDGE.UNIFORMTYPE.FLOAT2); | 60 | this.ssaoQuad.renderObj.addUniform("u_screenSize", this.v2ScreenSize, RDGE.UNIFORMTYPE.FLOAT2); |
61 | }; | 61 | }; |
62 | 62 | ||
63 | /** | 63 | /** |
64 | * Contributes SSAO to the passed offscreen surface, rendering to another surface. | 64 | * Contributes SSAO to the passed offscreen surface, rendering to another surface. |
65 | * See http://www.gamedev.net/page/resources/_/reference/programming/140/lighting-and-shading/a-simple-and-practical-approach-to-ssao-r2753 | 65 | * See http://www.gamedev.net/page/resources/_/reference/programming/140/lighting-and-shading/a-simple-and-practical-approach-to-ssao-r2753 |
66 | * @param srcTexColor - color surface of rendered scene | 66 | * @param srcTexColor - color surface of rendered scene |
67 | * @param srcTexNormDepth - screenspace normal+depth surface for scene; {nx, ny, nz, depth} | 67 | * @param srcTexNormDepth - screenspace normal+depth surface for scene; {nx, ny, nz, depth} |
68 | * @param dstRenderTarget - where to put the result of SSAO | 68 | * @param dstRenderTarget - where to put the result of SSAO |
69 | * @param sampleRadius - | 69 | * @param sampleRadius - |
70 | * @param intensity - | 70 | * @param intensity - |
71 | * @param distScale - | 71 | * @param distScale - |
72 | * @param bias - | 72 | * @param bias - |
73 | */ | 73 | */ |
74 | RDGE.fx.fxSSAO.prototype.doSSAO = function (srcTexColor, srcTexNormDepth, srcTexHRDepth, dstRenderTarget, sampleRadius, intensity, distScale, bias) { | 74 | RDGE.fx.fxSSAO.prototype.doSSAO = function (srcTexColor, srcTexNormDepth, srcTexHRDepth, dstRenderTarget, sampleRadius, intensity, distScale, bias) { |
75 | // Set art params and other uniforms | 75 | // Set art params and other uniforms |
76 | this.v4ArtVals[0] = sampleRadius; | 76 | this.v4ArtVals[0] = sampleRadius; |
77 | this.v4ArtVals[1] = intensity; | 77 | this.v4ArtVals[1] = intensity; |
78 | this.v4ArtVals[2] = distScale; | 78 | this.v4ArtVals[2] = distScale; |
79 | this.v4ArtVals[3] = bias; | 79 | this.v4ArtVals[3] = bias; |
80 | 80 | ||
81 | this.v2ScreenSize[0] = dstRenderTarget ? dstRenderTarget.frameBuffer.width : RDGE.globals.width; | 81 | this.v2ScreenSize[0] = dstRenderTarget ? dstRenderTarget.frameBuffer.width : RDGE.globals.width; |
82 | this.v2ScreenSize[1] = dstRenderTarget ? dstRenderTarget.frameBuffer.height : RDGE.globals.height; | 82 | this.v2ScreenSize[1] = dstRenderTarget ? dstRenderTarget.frameBuffer.height : RDGE.globals.height; |
83 | 83 | ||
84 | // Do ssao | 84 | // Do ssao |
85 | RDGE.globals.gl.bindFramebuffer(RDGE.globals.gl.FRAMEBUFFER, dstRenderTarget ? dstRenderTarget.frameBuffer : null); | 85 | RDGE.globals.gl.bindFramebuffer(RDGE.globals.gl.FRAMEBUFFER, dstRenderTarget ? dstRenderTarget.frameBuffer : null); |
86 | // gl.viewport(0, 0, 99999, 99999); | 86 | // gl.viewport(0, 0, 99999, 99999); |
87 | RDGE.globals.gl.clear(RDGE.globals.gl.COLOR_BUFFER_BIT); | 87 | RDGE.globals.gl.clear(RDGE.globals.gl.COLOR_BUFFER_BIT); |
88 | 88 | ||
89 | RDGE.globals.gl.disable(RDGE.globals.gl.DEPTH_TEST); | 89 | RDGE.globals.gl.disable(RDGE.globals.gl.DEPTH_TEST); |
90 | 90 | ||
91 | RDGE.globals.gl.useProgram(this.ssaoQuad.shader); | 91 | RDGE.globals.gl.useProgram(this.ssaoQuad.shader); |
92 | 92 | ||
93 | this.ssaoQuad.renderObj.bindBuffers(); | 93 | this.ssaoQuad.renderObj.bindBuffers(); |
94 | this.ssaoQuad.renderObj.bindTextures(); | 94 | this.ssaoQuad.renderObj.bindTextures(); |
95 | this.ssaoQuad.renderObj.bindUniforms(); | 95 | this.ssaoQuad.renderObj.bindUniforms(); |
96 | 96 | ||
97 | RDGE.globals.gl.activeTexture(RDGE.globals.gl.TEXTURE0); | 97 | RDGE.globals.gl.activeTexture(RDGE.globals.gl.TEXTURE0); |
98 | RDGE.globals.gl.bindTexture(RDGE.globals.gl.TEXTURE_2D, srcTexColor); | 98 | RDGE.globals.gl.bindTexture(RDGE.globals.gl.TEXTURE_2D, srcTexColor); |
@@ -100,10 +100,10 @@ RDGE.fx.fxSSAO.prototype.doSSAO = function (srcTexColor, srcTexNormDepth, srcTex | |||
100 | RDGE.globals.gl.bindTexture(RDGE.globals.gl.TEXTURE_2D, srcTexNormDepth); | 100 | RDGE.globals.gl.bindTexture(RDGE.globals.gl.TEXTURE_2D, srcTexNormDepth); |
101 | RDGE.globals.gl.activeTexture(RDGE.globals.gl.TEXTURE2); | 101 | RDGE.globals.gl.activeTexture(RDGE.globals.gl.TEXTURE2); |
102 | RDGE.globals.gl.bindTexture(RDGE.globals.gl.TEXTURE_2D, this.randTexture); | 102 | RDGE.globals.gl.bindTexture(RDGE.globals.gl.TEXTURE_2D, this.randTexture); |
103 | if (this.enHRDepth) { | 103 | if (this.enHRDepth) { |
104 | RDGE.globals.gl.activeTexture(RDGE.globals.gl.TEXTURE3); | 104 | RDGE.globals.gl.activeTexture(RDGE.globals.gl.TEXTURE3); |
105 | RDGE.globals.gl.bindTexture(RDGE.globals.gl.TEXTURE_2D, srcTexHRDepth); | 105 | RDGE.globals.gl.bindTexture(RDGE.globals.gl.TEXTURE_2D, srcTexHRDepth); |
106 | } | 106 | } |
107 | RDGE.globals.gl.activeTexture(RDGE.globals.gl.TEXTURE0); | 107 | RDGE.globals.gl.activeTexture(RDGE.globals.gl.TEXTURE0); |
108 | 108 | ||
109 | RDGE.globals.gl.drawArrays(RDGE.globals.gl.TRIANGLES, 0, 6); | 109 | RDGE.globals.gl.drawArrays(RDGE.globals.gl.TRIANGLES, 0, 6); |
@@ -111,5 +111,5 @@ RDGE.fx.fxSSAO.prototype.doSSAO = function (srcTexColor, srcTexNormDepth, srcTex | |||
111 | RDGE.globals.gl.enable(RDGE.globals.gl.DEPTH_TEST); | 111 | RDGE.globals.gl.enable(RDGE.globals.gl.DEPTH_TEST); |
112 | RDGE.globals.gl.useProgram(null); | 112 | RDGE.globals.gl.useProgram(null); |
113 | 113 | ||
114 | return dstRenderTarget; | 114 | return dstRenderTarget; |
115 | }; | 115 | }; |