From fb0a659c9ca3479fd6799325498b11f074689936 Mon Sep 17 00:00:00 2001 From: John Mayhew Date: Mon, 2 Apr 2012 14:57:31 -0700 Subject: -Namespaced all RDGE javascript. -Removed the following unused files from the build script /core/script/fx/blur.js /core/script/fx/ssao.js /core/script/animation.js - Fully removed the following from the build and from source control as they are unused or no longer needed /core/script/util/dbgpanel.js /core/script/util/fpsTracker.js /core/script/util/statTracker.js /core/script/input.js /core/script/TextureManager.js /core/script/ubershader.js --- .../RDGE/src/core/script/RenderInitProcs.js | 476 ++++++++++----------- 1 file changed, 224 insertions(+), 252 deletions(-) (limited to 'js/helper-classes/RDGE/src/core/script/RenderInitProcs.js') diff --git a/js/helper-classes/RDGE/src/core/script/RenderInitProcs.js b/js/helper-classes/RDGE/src/core/script/RenderInitProcs.js index 9d4e0d63..4e80183e 100755 --- a/js/helper-classes/RDGE/src/core/script/RenderInitProcs.js +++ b/js/helper-classes/RDGE/src/core/script/RenderInitProcs.js @@ -4,260 +4,232 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. */ -renderInitProcDefault = __renderInitProcDefault; -renderInitScreenQuad = __renderInitScreenQuad; -renderInitProcDepthMap = __renderInitProcDepthMap; -renderInitShadowReceiver= __renderInitShadowReceiver; -renderInitShadowProjection = __renderInitShadowProjection; - -function __renderInitProcDefault(primSet, vertexData) -{ - var material = primSet.material; - - //push envMap tex - material.tex.env.push(arrayPeek(material.shader).envMap); - material.tex.envDiff.push(arrayPeek(material.shader).envDiff); - - gl.useProgram(arrayPeek(material.shader).shaderHandle); - - arrayPeek(material.renderObj).addTexture("layerMap1", 0, UNIFORMTYPE.TEXTURE2D); - arrayPeek(material.renderObj).addTexture("layerMap2", 1, UNIFORMTYPE.TEXTURE2D); - arrayPeek(material.renderObj).addTexture("colorMeMap1", 2, UNIFORMTYPE.TEXTURE2D); - arrayPeek(material.renderObj).addTexture("colorMeMap2", 3, UNIFORMTYPE.TEXTURE2D); - arrayPeek(material.renderObj).addTexture("envMap", 4, UNIFORMTYPE.TEXTURE2D); - arrayPeek(material.renderObj).addTexture("envDiff", 5, UNIFORMTYPE.TEXTURE2D); - - arrayPeek(material.renderObj).addTexture("normalMap1", 15, UNIFORMTYPE.TEXTURE2D); - arrayPeek(material.renderObj).addTexture("normalMap2", 6, UNIFORMTYPE.TEXTURE2D); - - arrayPeek(material.renderObj).addTexture("stickerMap0", 7, UNIFORMTYPE.TEXTURE2D); - arrayPeek(material.renderObj).addTexture("stickerMap1", 8, UNIFORMTYPE.TEXTURE2D); - arrayPeek(material.renderObj).addTexture("stickerMap2", 9, UNIFORMTYPE.TEXTURE2D); - arrayPeek(material.renderObj).addTexture("stickerMap3", 10, UNIFORMTYPE.TEXTURE2D); - arrayPeek(material.renderObj).addTexture("stickerMap4", 11, UNIFORMTYPE.TEXTURE2D); - arrayPeek(material.renderObj).addTexture("stickerMap5", 12, UNIFORMTYPE.TEXTURE2D); - arrayPeek(material.renderObj).addTexture("stickerMap6", 13, UNIFORMTYPE.TEXTURE2D); - arrayPeek(material.renderObj).addTexture("stickerMap7", 14, UNIFORMTYPE.TEXTURE2D); - - arrayPeek(material.renderObj).addUniform("u_normalMatrix", gl.normalMatrix, UNIFORMTYPE.MATRIX4); - arrayPeek(material.renderObj).addUniform("u_mvMatrix", gl.mvMatrix, UNIFORMTYPE.MATRIX4); - arrayPeek(material.renderObj).addUniform("u_invMvMatrix", gl.invMvMatrix, UNIFORMTYPE.MATRIX4); - - arrayPeek(material.renderObj).addUniform("u_stickerMatrix0", primSet.parentMesh.stickers[0], UNIFORMTYPE.MATRIX4); - arrayPeek(material.renderObj).addUniform("u_stickerMatrix1", primSet.parentMesh.stickers[1], UNIFORMTYPE.MATRIX4); - arrayPeek(material.renderObj).addUniform("u_stickerMatrix2", primSet.parentMesh.stickers[2], UNIFORMTYPE.MATRIX4); - arrayPeek(material.renderObj).addUniform("u_stickerMatrix3", primSet.parentMesh.stickers[3], UNIFORMTYPE.MATRIX4); - arrayPeek(material.renderObj).addUniform("u_stickerMatrix4", primSet.parentMesh.stickers[4], UNIFORMTYPE.MATRIX4); - arrayPeek(material.renderObj).addUniform("u_stickerMatrix5", primSet.parentMesh.stickers[5], UNIFORMTYPE.MATRIX4); - arrayPeek(material.renderObj).addUniform("u_stickerMatrix6", primSet.parentMesh.stickers[6], UNIFORMTYPE.MATRIX4); - arrayPeek(material.renderObj).addUniform("u_stickerMatrix7", primSet.parentMesh.stickers[7], UNIFORMTYPE.MATRIX4); - - arrayPeek(material.renderObj).addUniform("u_stickerPos0", primSet.parentMesh.stickersPos[0], UNIFORMTYPE.FLOAT3); - arrayPeek(material.renderObj).addUniform("u_stickerPos1", primSet.parentMesh.stickersPos[1], UNIFORMTYPE.FLOAT3); - arrayPeek(material.renderObj).addUniform("u_stickerPos2", primSet.parentMesh.stickersPos[2], UNIFORMTYPE.FLOAT3); - arrayPeek(material.renderObj).addUniform("u_stickerPos3", primSet.parentMesh.stickersPos[3], UNIFORMTYPE.FLOAT3); - arrayPeek(material.renderObj).addUniform("u_stickerPos4", primSet.parentMesh.stickersPos[4], UNIFORMTYPE.FLOAT3); - arrayPeek(material.renderObj).addUniform("u_stickerPos5", primSet.parentMesh.stickersPos[5], UNIFORMTYPE.FLOAT3); - arrayPeek(material.renderObj).addUniform("u_stickerPos6", primSet.parentMesh.stickersPos[6], UNIFORMTYPE.FLOAT3); - arrayPeek(material.renderObj).addUniform("u_stickerPos7", primSet.parentMesh.stickersPos[7], UNIFORMTYPE.FLOAT3); - - - arrayPeek(material.renderObj).addUniform("u_projMatrix", gl.perspectiveMatrix, UNIFORMTYPE.MATRIX4); - - arrayPeek(material.renderObj).addUniform("u_fillColor1", material.fillColor[0], UNIFORMTYPE.FLOAT4); - arrayPeek(material.renderObj).addUniform("u_fillColor2", material.fillColor[1], UNIFORMTYPE.FLOAT4); - arrayPeek(material.renderObj).addUniform("u_skinColor", material.fillColor[2], UNIFORMTYPE.FLOAT4); - - - // debug--- - vertexData.vertexObject.name = "vertexObject"; - vertexData.normalObject.name = "normalObject"; - vertexData.texCoordObject.name = "texCoordObject"; - vertexData.indexObject.name = "indexObject"; - //---------- - - arrayPeek(material.renderObj).addBuffers(vertexData.vertexObject, gl.ARRAY_BUFFER, 3, 0, gl.FLOAT); - arrayPeek(material.renderObj).addBuffers(vertexData.normalObject, gl.ARRAY_BUFFER, 3, 1, gl.FLOAT); - arrayPeek(material.renderObj).addBuffers(vertexData.texCoordObject, gl.ARRAY_BUFFER, 2, 2, gl.FLOAT); - arrayPeek(material.renderObj).addBuffers(vertexData.indexObject, gl.ELEMENT_ARRAY_BUFFER); - - - //} - - gl.useProgram(null); -// gl.console.log("Mesh Init done!"); - -} - -function __renderInitScreenQuad(quad, shader) -{ - if(shader == undefined) - { - quad.shader = createShader(gl, 'screenQuad_vShader', 'screenQuad_fShader', [ "vert", "texcoord"]); - } - else - { - quad.shader = shader; - } - - quad.renderObj = new RenderObject(quad.shader); - - quadBuf = getScreenAlignedQuad(); - - quad.vertBuffer = quadBuf.vertexObject; - quad.uvBuffer = quadBuf.texCoordObject; - - - quad.renderObj.addTexture("basemap", 0, UNIFORMTYPE.TEXTURE2D); - - var invWidth = (g_width == 0.0) ? 0.0 : 1.0/g_width, invHeight = (g_height == 0.0) ? 0.0 : 1.0/g_height; - quad.renderObj.addUniform("u_inv_viewport_width", invWidth, UNIFORMTYPE.FLOAT); - quad.renderObj.addUniform("u_inv_viewport_height", invHeight, UNIFORMTYPE.FLOAT); - - quad.renderObj.addBuffers(quad.vertBuffer, gl.ARRAY_BUFFER, 3, 0, gl.FLOAT); - quad.renderObj.addBuffers(quad.uvBuffer, gl.ARRAY_BUFFER, 2, 2, gl.FLOAT); -} - -function __renderInitProcDepthMap(renderObj) -{ - renderObj.shader = g_depthShader.shaderHandle;//createShader(gl, depthMapVShader, depthMapFShader, [ "vert", "normal", "texcoord"]); - +// RDGE namespaces +var RDGE = RDGE || {}; + +RDGE.renderInitProcDefault = function (primSet, vertexData) { + var material = primSet.material; + + //push envMap tex + material.tex.env.push(arrayPeek(material.shader).envMap); + material.tex.envDiff.push(arrayPeek(material.shader).envDiff); + + gl.useProgram(arrayPeek(material.shader).shaderHandle); + + arrayPeek(material.renderObj).addTexture("layerMap1", 0, RDGE.UNIFORMTYPE.TEXTURE2D); + arrayPeek(material.renderObj).addTexture("layerMap2", 1, RDGE.UNIFORMTYPE.TEXTURE2D); + arrayPeek(material.renderObj).addTexture("colorMeMap1", 2, RDGE.UNIFORMTYPE.TEXTURE2D); + arrayPeek(material.renderObj).addTexture("colorMeMap2", 3, RDGE.UNIFORMTYPE.TEXTURE2D); + arrayPeek(material.renderObj).addTexture("envMap", 4, RDGE.UNIFORMTYPE.TEXTURE2D); + arrayPeek(material.renderObj).addTexture("envDiff", 5, RDGE.UNIFORMTYPE.TEXTURE2D); + + arrayPeek(material.renderObj).addTexture("normalMap1", 15, RDGE.UNIFORMTYPE.TEXTURE2D); + arrayPeek(material.renderObj).addTexture("normalMap2", 6, RDGE.UNIFORMTYPE.TEXTURE2D); + + arrayPeek(material.renderObj).addTexture("stickerMap0", 7, RDGE.UNIFORMTYPE.TEXTURE2D); + arrayPeek(material.renderObj).addTexture("stickerMap1", 8, RDGE.UNIFORMTYPE.TEXTURE2D); + arrayPeek(material.renderObj).addTexture("stickerMap2", 9, RDGE.UNIFORMTYPE.TEXTURE2D); + arrayPeek(material.renderObj).addTexture("stickerMap3", 10, RDGE.UNIFORMTYPE.TEXTURE2D); + arrayPeek(material.renderObj).addTexture("stickerMap4", 11, RDGE.UNIFORMTYPE.TEXTURE2D); + arrayPeek(material.renderObj).addTexture("stickerMap5", 12, RDGE.UNIFORMTYPE.TEXTURE2D); + arrayPeek(material.renderObj).addTexture("stickerMap6", 13, RDGE.UNIFORMTYPE.TEXTURE2D); + arrayPeek(material.renderObj).addTexture("stickerMap7", 14, RDGE.UNIFORMTYPE.TEXTURE2D); + + arrayPeek(material.renderObj).addUniform("u_normalMatrix", gl.normalMatrix, RDGE.UNIFORMTYPE.MATRIX4); + arrayPeek(material.renderObj).addUniform("u_mvMatrix", gl.mvMatrix, RDGE.UNIFORMTYPE.MATRIX4); + arrayPeek(material.renderObj).addUniform("u_invMvMatrix", gl.invMvMatrix, RDGE.UNIFORMTYPE.MATRIX4); + + arrayPeek(material.renderObj).addUniform("u_stickerMatrix0", primSet.parentMesh.stickers[0], RDGE.UNIFORMTYPE.MATRIX4); + arrayPeek(material.renderObj).addUniform("u_stickerMatrix1", primSet.parentMesh.stickers[1], RDGE.UNIFORMTYPE.MATRIX4); + arrayPeek(material.renderObj).addUniform("u_stickerMatrix2", primSet.parentMesh.stickers[2], RDGE.UNIFORMTYPE.MATRIX4); + arrayPeek(material.renderObj).addUniform("u_stickerMatrix3", primSet.parentMesh.stickers[3], RDGE.UNIFORMTYPE.MATRIX4); + arrayPeek(material.renderObj).addUniform("u_stickerMatrix4", primSet.parentMesh.stickers[4], RDGE.UNIFORMTYPE.MATRIX4); + arrayPeek(material.renderObj).addUniform("u_stickerMatrix5", primSet.parentMesh.stickers[5], RDGE.UNIFORMTYPE.MATRIX4); + arrayPeek(material.renderObj).addUniform("u_stickerMatrix6", primSet.parentMesh.stickers[6], RDGE.UNIFORMTYPE.MATRIX4); + arrayPeek(material.renderObj).addUniform("u_stickerMatrix7", primSet.parentMesh.stickers[7], RDGE.UNIFORMTYPE.MATRIX4); + + arrayPeek(material.renderObj).addUniform("u_stickerPos0", primSet.parentMesh.stickersPos[0], RDGE.UNIFORMTYPE.FLOAT3); + arrayPeek(material.renderObj).addUniform("u_stickerPos1", primSet.parentMesh.stickersPos[1], RDGE.UNIFORMTYPE.FLOAT3); + arrayPeek(material.renderObj).addUniform("u_stickerPos2", primSet.parentMesh.stickersPos[2], RDGE.UNIFORMTYPE.FLOAT3); + arrayPeek(material.renderObj).addUniform("u_stickerPos3", primSet.parentMesh.stickersPos[3], RDGE.UNIFORMTYPE.FLOAT3); + arrayPeek(material.renderObj).addUniform("u_stickerPos4", primSet.parentMesh.stickersPos[4], RDGE.UNIFORMTYPE.FLOAT3); + arrayPeek(material.renderObj).addUniform("u_stickerPos5", primSet.parentMesh.stickersPos[5], RDGE.UNIFORMTYPE.FLOAT3); + arrayPeek(material.renderObj).addUniform("u_stickerPos6", primSet.parentMesh.stickersPos[6], RDGE.UNIFORMTYPE.FLOAT3); + arrayPeek(material.renderObj).addUniform("u_stickerPos7", primSet.parentMesh.stickersPos[7], RDGE.UNIFORMTYPE.FLOAT3); + + arrayPeek(material.renderObj).addUniform("u_projMatrix", gl.perspectiveMatrix, RDGE.UNIFORMTYPE.MATRIX4); + + arrayPeek(material.renderObj).addUniform("u_fillColor1", material.fillColor[0], RDGE.UNIFORMTYPE.FLOAT4); + arrayPeek(material.renderObj).addUniform("u_fillColor2", material.fillColor[1], RDGE.UNIFORMTYPE.FLOAT4); + arrayPeek(material.renderObj).addUniform("u_skinColor", material.fillColor[2], RDGE.UNIFORMTYPE.FLOAT4); + + // debug--- + vertexData.vertexObject.name = "vertexObject"; + vertexData.normalObject.name = "normalObject"; + vertexData.texCoordObject.name = "texCoordObject"; + vertexData.indexObject.name = "indexObject"; + //---------- + + arrayPeek(material.renderObj).addBuffers(vertexData.vertexObject, gl.ARRAY_BUFFER, 3, 0, gl.FLOAT); + arrayPeek(material.renderObj).addBuffers(vertexData.normalObject, gl.ARRAY_BUFFER, 3, 1, gl.FLOAT); + arrayPeek(material.renderObj).addBuffers(vertexData.texCoordObject, gl.ARRAY_BUFFER, 2, 2, gl.FLOAT); + arrayPeek(material.renderObj).addBuffers(vertexData.indexObject, gl.ELEMENT_ARRAY_BUFFER); + + gl.useProgram(null); + // gl.console.log("Mesh Init done!"); +}; + +RDGE.renderInitScreenQuad = function (quad, shader) { + if (shader == undefined) { + quad.shader = RDGE.createShader(gl, 'screenQuad_vShader', 'screenQuad_fShader', ["vert", "texcoord"]); + } + else { + quad.shader = shader; + } + + quad.renderObj = new RDGE.RenderObject(quad.shader); + + quadBuf = getScreenAlignedQuad(); + + quad.vertBuffer = quadBuf.vertexObject; + quad.uvBuffer = quadBuf.texCoordObject; + + + quad.renderObj.addTexture("basemap", 0, RDGE.UNIFORMTYPE.TEXTURE2D); + + var invWidth = (RDGE.globals.width == 0.0) ? 0.0 : 1.0 / RDGE.globals.width, invHeight = (RDGE.globals.height == 0.0) ? 0.0 : 1.0 / RDGE.globals.height; + quad.renderObj.addUniform("u_inv_viewport_width", invWidth, RDGE.UNIFORMTYPE.FLOAT); + quad.renderObj.addUniform("u_inv_viewport_height", invHeight, RDGE.UNIFORMTYPE.FLOAT); + + quad.renderObj.addBuffers(quad.vertBuffer, gl.ARRAY_BUFFER, 3, 0, gl.FLOAT); + quad.renderObj.addBuffers(quad.uvBuffer, gl.ARRAY_BUFFER, 2, 2, gl.FLOAT); +}; + +RDGE.renderInitProcDepthMap = function (renderObj) { + renderObj.shader = g_depthShader.shaderHandle; //RDGE.createShader(gl, depthMapVShader, depthMapFShader, [ "vert", "normal", "texcoord"]); + gl.useProgram(renderObj.shader); - renderObj.addUniform("u_mvpLightMatrix", g_mainLight.mvpMatrix, UNIFORMTYPE.MATRIX4); - //renderObj.addUniform("u_mvpLightMatrixWTF", g_mainLight.mvpMatrix, UNIFORMTYPE.MATRIX4); - // var uni = gl.getUniformLocation(renderObj.shader, "u_mvpLightMatrixWTF"); -// renderObj.addUniform("u_WTF1", g_lightMat[0], UNIFORMTYPE.FLOAT4); -// renderObj.addUniform("u_WTF2", g_lightMat[1], UNIFORMTYPE.FLOAT4); -// renderObj.addUniform("u_WTF3", g_lightMat[2], UNIFORMTYPE.FLOAT4); -// renderObj.addUniform("u_WTF4", g_lightMat[3], UNIFORMTYPE.FLOAT4); -// + renderObj.addUniform("u_mvpLightMatrix", g_mainLight.mvpMatrix, RDGE.UNIFORMTYPE.MATRIX4); + //renderObj.addUniform("u_mvpLightMatrixWTF", g_mainLight.mvpMatrix, RDGE.UNIFORMTYPE.MATRIX4); + // var uni = gl.getUniformLocation(renderObj.shader, "u_mvpLightMatrixWTF"); + // renderObj.addUniform("u_WTF1", g_lightMat[0], RDGE.UNIFORMTYPE.FLOAT4); + // renderObj.addUniform("u_WTF2", g_lightMat[1], RDGE.UNIFORMTYPE.FLOAT4); + // renderObj.addUniform("u_WTF3", g_lightMat[2], RDGE.UNIFORMTYPE.FLOAT4); + // renderObj.addUniform("u_WTF4", g_lightMat[3], RDGE.UNIFORMTYPE.FLOAT4); + // // since the uniform data references should not change we can just bind one time renderObj.bindUniforms(); - + + gl.useProgram(null); +}; + +RDGE.renderInitShadowReceiver = function (primSet, vertexData) { + // setup passes + primSet.shadowTarget = g_texMan.loadRenderTarget("shadowTarget", 256, 256); + primSet.shadowTargetFinal = g_texMan.loadRenderTarget("shadowTargetFinal", 256, 256); + primSet.screenQuad = new RDGE.ScreenQuad(primSet.shadowTargetFinal); + primSet.screenQuad.initialize(RDGE.renderInitRadialBlur); + + // set the target as the shadow to get projcetd + primSet.parentMesh.shadowToProject = primSet.shadowTarget; + + //mainSceneQuad = new RDGE.ScreenQuad(primSet.shadowTarget); + //mainSceneQuad.initialize(renderInitScreenQuad); + + var material = primSet.material; + + //push envMap tex + material.tex.env.push(arrayPeek(material.shader).envMap); + material.tex.envDiff.push(arrayPeek(material.shader).envDiff); + + gl.useProgram(arrayPeek(material.shader).shaderHandle); + + arrayPeek(material.renderObj).addTexture("shadowMap", 0, RDGE.UNIFORMTYPE.TEXTURE2D); + arrayPeek(material.renderObj).addUniform("u_mvMatrix", gl.mvMatrix, RDGE.UNIFORMTYPE.MATRIX4); + + arrayPeek(material.renderObj).addUniform("u_projMatrix", gl.perspectiveMatrix, RDGE.UNIFORMTYPE.MATRIX4); + + arrayPeek(material.renderObj).addUniform("u_shadowBiasMatrix", g_mainLight.shadowMatrix, RDGE.UNIFORMTYPE.MATRIX4); + arrayPeek(material.renderObj).addUniform("u_vShadowLight", g_mainLight.view, RDGE.UNIFORMTYPE.MATRIX4); + + + // debug--- + vertexData.vertexObject.name = "vertexObject"; + vertexData.normalObject.name = "normalObject"; + vertexData.texCoordObject.name = "texCoordObject"; + vertexData.indexObject.name = "indexObject"; + //---------- + + arrayPeek(material.renderObj).addBuffers(vertexData.vertexObject, gl.ARRAY_BUFFER, 3, 0, gl.FLOAT); + arrayPeek(material.renderObj).addBuffers(vertexData.normalObject, gl.ARRAY_BUFFER, 3, 1, gl.FLOAT); + arrayPeek(material.renderObj).addBuffers(vertexData.texCoordObject, gl.ARRAY_BUFFER, 2, 2, gl.FLOAT); + arrayPeek(material.renderObj).addBuffers(vertexData.indexObject, gl.ELEMENT_ARRAY_BUFFER); + gl.useProgram(null); -} - -function __renderInitShadowReceiver(primSet, vertexData) -{ - // setup passes - primSet.shadowTarget = g_texMan.loadRenderTarget("shadowTarget", 256, 256); - primSet.shadowTargetFinal = g_texMan.loadRenderTarget("shadowTargetFinal", 256, 256); - primSet.screenQuad = new ScreenQuad(primSet.shadowTargetFinal); - primSet.screenQuad.initialize(__renderInitRadialBlur); - - // set the target as the shadow to get projcetd - primSet.parentMesh.shadowToProject = primSet.shadowTarget; - - //mainSceneQuad = new ScreenQuad(primSet.shadowTarget); - //mainSceneQuad.initialize(renderInitScreenQuad); - - var material = primSet.material; - - //push envMap tex - material.tex.env.push(arrayPeek(material.shader).envMap); - material.tex.envDiff.push(arrayPeek(material.shader).envDiff); - - gl.useProgram(arrayPeek(material.shader).shaderHandle); - - arrayPeek(material.renderObj).addTexture("shadowMap", 0, UNIFORMTYPE.TEXTURE2D); - arrayPeek(material.renderObj).addUniform("u_mvMatrix", gl.mvMatrix, UNIFORMTYPE.MATRIX4); - - arrayPeek(material.renderObj).addUniform("u_projMatrix", gl.perspectiveMatrix, UNIFORMTYPE.MATRIX4); - - arrayPeek(material.renderObj).addUniform("u_shadowBiasMatrix", g_mainLight.shadowMatrix, UNIFORMTYPE.MATRIX4); - arrayPeek(material.renderObj).addUniform("u_vShadowLight", g_mainLight.view, UNIFORMTYPE.MATRIX4); - - - // debug--- - vertexData.vertexObject.name = "vertexObject"; - vertexData.normalObject.name = "normalObject"; - vertexData.texCoordObject.name = "texCoordObject"; - vertexData.indexObject.name = "indexObject"; - //---------- - - arrayPeek(material.renderObj).addBuffers(vertexData.vertexObject, gl.ARRAY_BUFFER, 3, 0, gl.FLOAT); - arrayPeek(material.renderObj).addBuffers(vertexData.normalObject, gl.ARRAY_BUFFER, 3, 1, gl.FLOAT); - arrayPeek(material.renderObj).addBuffers(vertexData.texCoordObject, gl.ARRAY_BUFFER, 2, 2, gl.FLOAT); - arrayPeek(material.renderObj).addBuffers(vertexData.indexObject, gl.ELEMENT_ARRAY_BUFFER); - - - //} - - gl.useProgram(null); -// gl.console.log("Mesh Init done!"); - - //__renderInitShadowProjection(primSet, vertexData); - -} - - -function __renderInitShadowProjection(primSet, vertexData) -{ - var material = primSet.material; - - //push envMap tex - //material.tex.env.push(arrayPeek(material.shader).envMap); - //material.tex.envDiff.push(arrayPeek(material.shader).envDiff); - - gl.useProgram(arrayPeek(material.shader).shaderHandle); - - arrayPeek(material.renderObj).addTexture("shadowMap", 0, UNIFORMTYPE.TEXTURE2D); - arrayPeek(material.renderObj).addUniform("u_mvMatrix", gl.mvMatrix, UNIFORMTYPE.MATRIX4); - - arrayPeek(material.renderObj).addUniform("u_projMatrix", gl.perspectiveMatrix, UNIFORMTYPE.MATRIX4); - - arrayPeek(material.renderObj).addUniform("u_shadowBiasMatrix", g_mainLight.shadowMatrix, UNIFORMTYPE.MATRIX4); - arrayPeek(material.renderObj).addUniform("u_vShadowLight", g_mainLight.view, UNIFORMTYPE.MATRIX4); - - - // debug--- - vertexData.vertexObject.name = "vertexObject"; - vertexData.normalObject.name = "normalObject"; - vertexData.texCoordObject.name = "texCoordObject"; - vertexData.indexObject.name = "indexObject"; - //---------- - - arrayPeek(material.renderObj).addBuffers(vertexData.vertexObject, gl.ARRAY_BUFFER, 3, 0, gl.FLOAT); - arrayPeek(material.renderObj).addBuffers(vertexData.normalObject, gl.ARRAY_BUFFER, 3, 1, gl.FLOAT); - arrayPeek(material.renderObj).addBuffers(vertexData.texCoordObject, gl.ARRAY_BUFFER, 2, 2, gl.FLOAT); - arrayPeek(material.renderObj).addBuffers(vertexData.indexObject, gl.ELEMENT_ARRAY_BUFFER); - - - //} - - gl.useProgram(null); -// gl.console.log("Mesh Init done!"); - -} - -function __renderInitRadialBlur(quad, shader) -{ - if(shader == undefined) - { - quad.shader = createShader(gl, 'radialBlur_vshader', 'radialBlur_fshader', [ "vert", "texcoord"]); - } - else - { - quad.shader = shader; - } - - quad.renderObj = new RenderObject(quad.shader); - - quadBuf = getScreenAlignedQuad(); - - quad.vertBuffer = quadBuf.vertexObject; - quad.uvBuffer = quadBuf.texCoordObject; - - - quad.renderObj.addTexture("basemap", 0, UNIFORMTYPE.TEXTURE2D); - - quad.renderObj.addUniform("u_inv_viewport_width", 1.0/g_width, UNIFORMTYPE.FLOAT); - quad.renderObj.addUniform("u_inv_viewport_height", 1.0/g_height, UNIFORMTYPE.FLOAT); - quad.renderObj.addUniform("u_sampRadius", 5.0, UNIFORMTYPE.FLOAT); - quad.renderObj.addUniform("u_numSamples", 16, UNIFORMTYPE.INT); - quad.renderObj.addUniform("u_mapSize", 256.0, UNIFORMTYPE.FLOAT); - - quad.renderObj.addBuffers(quad.vertBuffer, gl.ARRAY_BUFFER, 3, 0, gl.FLOAT); - quad.renderObj.addBuffers(quad.uvBuffer, gl.ARRAY_BUFFER, 2, 2, gl.FLOAT); -} + + //RDGE.renderInitShadowProjection(primSet, vertexData); +}; + + +RDGE.renderInitShadowProjection = function (primSet, vertexData) { + var material = primSet.material; + + //push envMap tex + //material.tex.env.push(arrayPeek(material.shader).envMap); + //material.tex.envDiff.push(arrayPeek(material.shader).envDiff); + + gl.useProgram(arrayPeek(material.shader).shaderHandle); + + arrayPeek(material.renderObj).addTexture("shadowMap", 0, RDGE.UNIFORMTYPE.TEXTURE2D); + arrayPeek(material.renderObj).addUniform("u_mvMatrix", gl.mvMatrix, RDGE.UNIFORMTYPE.MATRIX4); + + arrayPeek(material.renderObj).addUniform("u_projMatrix", gl.perspectiveMatrix, RDGE.UNIFORMTYPE.MATRIX4); + + arrayPeek(material.renderObj).addUniform("u_shadowBiasMatrix", g_mainLight.shadowMatrix, RDGE.UNIFORMTYPE.MATRIX4); + arrayPeek(material.renderObj).addUniform("u_vShadowLight", g_mainLight.view, RDGE.UNIFORMTYPE.MATRIX4); + + + // debug--- + vertexData.vertexObject.name = "vertexObject"; + vertexData.normalObject.name = "normalObject"; + vertexData.texCoordObject.name = "texCoordObject"; + vertexData.indexObject.name = "indexObject"; + //---------- + + arrayPeek(material.renderObj).addBuffers(vertexData.vertexObject, gl.ARRAY_BUFFER, 3, 0, gl.FLOAT); + arrayPeek(material.renderObj).addBuffers(vertexData.normalObject, gl.ARRAY_BUFFER, 3, 1, gl.FLOAT); + arrayPeek(material.renderObj).addBuffers(vertexData.texCoordObject, gl.ARRAY_BUFFER, 2, 2, gl.FLOAT); + arrayPeek(material.renderObj).addBuffers(vertexData.indexObject, gl.ELEMENT_ARRAY_BUFFER); + + + gl.useProgram(null); +}; + +RDGE.renderInitRadialBlur = function(quad, shader) { + if (shader == undefined) { + quad.shader = RDGE.createShader(gl, 'radialBlur_vshader', 'radialBlur_fshader', ["vert", "texcoord"]); + } + else { + quad.shader = shader; + } + + quad.renderObj = new RDGE.RenderObject(quad.shader); + + quadBuf = getScreenAlignedQuad(); + + quad.vertBuffer = quadBuf.vertexObject; + quad.uvBuffer = quadBuf.texCoordObject; + + + quad.renderObj.addTexture("basemap", 0, RDGE.UNIFORMTYPE.TEXTURE2D); + + quad.renderObj.addUniform("u_inv_viewport_width", 1.0 / RDGE.globals.width, RDGE.UNIFORMTYPE.FLOAT); + quad.renderObj.addUniform("u_inv_viewport_height", 1.0 / RDGE.globals.height, RDGE.UNIFORMTYPE.FLOAT); + quad.renderObj.addUniform("u_sampRadius", 5.0, RDGE.UNIFORMTYPE.FLOAT); + quad.renderObj.addUniform("u_numSamples", 16, RDGE.UNIFORMTYPE.INT); + quad.renderObj.addUniform("u_mapSize", 256.0, RDGE.UNIFORMTYPE.FLOAT); + + quad.renderObj.addBuffers(quad.vertBuffer, gl.ARRAY_BUFFER, 3, 0, gl.FLOAT); + quad.renderObj.addBuffers(quad.uvBuffer, gl.ARRAY_BUFFER, 2, 2, gl.FLOAT); +}; -- cgit v1.2.3