aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xjs/helper-classes/RDGE/src/core/script/engine.js3
-rwxr-xr-xjs/helper-classes/RDGE/src/core/script/fx/blur.js6
-rwxr-xr-xjs/helper-classes/RDGE/src/core/script/fx/ssao.js90
-rwxr-xr-xjs/helper-classes/RDGE/src/core/script/jshader.js8
-rwxr-xr-xjs/helper-classes/RDGE/src/core/script/math/mat4.js44
-rwxr-xr-xjs/helper-classes/RDGE/src/core/script/renderer.js2
-rwxr-xr-xjs/helper-classes/RDGE/src/core/script/utilities.js4
-rwxr-xr-xjs/lib/drawing/world.js8
8 files changed, 82 insertions, 83 deletions
diff --git a/js/helper-classes/RDGE/src/core/script/engine.js b/js/helper-classes/RDGE/src/core/script/engine.js
index 1777fc22..cf576702 100755
--- a/js/helper-classes/RDGE/src/core/script/engine.js
+++ b/js/helper-classes/RDGE/src/core/script/engine.js
@@ -426,13 +426,12 @@ RDGE.Engine.prototype.registerCanvas = function (canvas, runState) {
426}; 426};
427 427
428RDGE.Engine.prototype.unregisterCanvas = function (canvas) { 428RDGE.Engine.prototype.unregisterCanvas = function (canvas) {
429 stat.closePage(canvas.rdgeid + "_fps");
430 contextManager.removeObject(canvas.rdgeCtxHandle); 429 contextManager.removeObject(canvas.rdgeCtxHandle);
431 this.clearContext( canvas.rdgeid ); 430 this.clearContext( canvas.rdgeid );
432}; 431};
433 432
434 433
435Engine.prototype.getCanvas = function( id ) 434RDGE.Engine.prototype.getCanvas = function (id)
436{ 435{
437 return this.canvasToRendererMap[id]; 436 return this.canvasToRendererMap[id];
438}; 437};
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 110ea8e3..2a8c2ff1 100755
--- a/js/helper-classes/RDGE/src/core/script/fx/blur.js
+++ b/js/helper-classes/RDGE/src/core/script/fx/blur.js
@@ -56,7 +56,7 @@ RDGE.fx.fxBlur = function (mipSizes, enAuxTexture) {
56 56
57 quad.renderObj.addBuffers(quad.vertBuffer, gl.ARRAY_BUFFER, 3, 0, gl.FLOAT); 57 quad.renderObj.addBuffers(quad.vertBuffer, gl.ARRAY_BUFFER, 3, 0, gl.FLOAT);
58 quad.renderObj.addBuffers(quad.uvBuffer, gl.ARRAY_BUFFER, 2, 2, gl.FLOAT); 58 quad.renderObj.addBuffers(quad.uvBuffer, gl.ARRAY_BUFFER, 2, 2, gl.FLOAT);
59 } 59 };
60 60
61 function renderInitCombine(quad) { 61 function renderInitCombine(quad) {
62 quad.shader = RDGE.createShader(gl, 'separableBlur_vshader', separableBlurCombine_fshader, ["vert", "texcoord"]); 62 quad.shader = RDGE.createShader(gl, 'separableBlur_vshader', separableBlurCombine_fshader, ["vert", "texcoord"]);
@@ -73,7 +73,7 @@ RDGE.fx.fxBlur = function (mipSizes, enAuxTexture) {
73 73
74 quad.renderObj.addBuffers(quad.vertBuffer, gl.ARRAY_BUFFER, 3, 0, gl.FLOAT); 74 quad.renderObj.addBuffers(quad.vertBuffer, gl.ARRAY_BUFFER, 3, 0, gl.FLOAT);
75 quad.renderObj.addBuffers(quad.uvBuffer, gl.ARRAY_BUFFER, 2, 2, gl.FLOAT); 75 quad.renderObj.addBuffers(quad.uvBuffer, gl.ARRAY_BUFFER, 2, 2, gl.FLOAT);
76 } 76 };
77 77
78 // Screen aligned quad geometry 78 // Screen aligned quad geometry
79 var quadBuf = getScreenAlignedQuad(); 79 var quadBuf = getScreenAlignedQuad();
@@ -87,7 +87,7 @@ RDGE.fx.fxBlur = function (mipSizes, enAuxTexture) {
87 for (var i in mipSizes) { 87 for (var i in mipSizes) {
88 this.fboSet1.push(createRenderTargetTexture(mipSizes[i], mipSizes[i])); 88 this.fboSet1.push(createRenderTargetTexture(mipSizes[i], mipSizes[i]));
89 this.fboSet2.push(createRenderTargetTexture(mipSizes[i], mipSizes[i])); 89 this.fboSet2.push(createRenderTargetTexture(mipSizes[i], mipSizes[i]));
90 } 90 };
91 91
92 // Blitter for downsampling 92 // Blitter for downsampling
93 this.blitQuad = new RDGE.ScreenQuad(null); 93 this.blitQuad = new RDGE.ScreenQuad(null);
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 5af2859d..2f96aa5b 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 || {};
8RDGE.fx = RDGE.fx || {}; 8RDGE.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*/
15RDGE.fx.fxSSAO = function (enHRDepth) { 15RDGE.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, RDGE.globals.engine._assetPath+"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*/
74RDGE.fx.fxSSAO.prototype.doSSAO = function (srcTexColor, srcTexNormDepth, srcTexHRDepth, dstRenderTarget, sampleRadius, intensity, distScale, bias) { 74RDGE.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 th