diff options
author | Ananya Sen | 2012-04-17 18:11:55 -0700 |
---|---|---|
committer | Ananya Sen | 2012-04-17 18:11:55 -0700 |
commit | 35abad196cc9feb76ef50c1b63032a38233a6d51 (patch) | |
tree | 914689c66d4ab6c6e088b571eade0a0e35082916 /js/helper-classes/RDGE/src/core/script/RenderInitProcs.js | |
parent | 1f891c58bad0b7746659aa4138001b5ee76d9a0e (diff) | |
parent | 616a8532099fec2a15855eac97cd85cb60c4451c (diff) | |
download | ninja-35abad196cc9feb76ef50c1b63032a38233a6d51.tar.gz |
Merge branch 'refs/heads/ninja-internal-master' into Codeview-improvements
Diffstat (limited to 'js/helper-classes/RDGE/src/core/script/RenderInitProcs.js')
-rwxr-xr-x | js/helper-classes/RDGE/src/core/script/RenderInitProcs.js | 476 |
1 files changed, 224 insertions, 252 deletions
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 | |||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | 4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. |
5 | </copyright> */ | 5 | </copyright> */ |
6 | 6 | ||
7 | renderInitProcDefault = __renderInitProcDefault; | 7 | // RDGE namespaces |
8 | renderInitScreenQuad = __renderInitScreenQuad; | 8 | var RDGE = RDGE || {}; |
9 | renderInitProcDepthMap = __renderInitProcDepthMap; | 9 | |
10 | renderInitShadowReceiver= __renderInitShadowReceiver; | 10 | RDGE.renderInitProcDefault = function (primSet, vertexData) { |
11 | renderInitShadowProjection = __renderInitShadowProjection; | 11 | var material = primSet.material; |
12 | 12 | ||
13 | function __renderInitProcDefault(primSet, vertexData) | 13 | //push envMap tex |
14 | { | 14 | material.tex.env.push(arrayPeek(material.shader).envMap); |
15 | var material = primSet.material; | 15 | material.tex.envDiff.push(arrayPeek(material.shader).envDiff); |
16 | 16 | ||
17 | //push envMap tex | 17 | gl.useProgram(arrayPeek(material.shader).shaderHandle); |
18 | material.tex.env.push(arrayPeek(material.shader).envMap); | 18 | |
19 | material.tex.envDiff.push(arrayPeek(material.shader).envDiff); | 19 | arrayPeek(material.renderObj).addTexture("layerMap1", 0, RDGE.UNIFORMTYPE.TEXTURE2D); |
20 | 20 | arrayPeek(material.renderObj).addTexture("layerMap2", 1, RDGE.UNIFORMTYPE.TEXTURE2D); | |
21 | gl.useProgram(arrayPeek(material.shader).shaderHandle); | 21 | arrayPeek(material.renderObj).addTexture("colorMeMap1", 2, RDGE.UNIFORMTYPE.TEXTURE2D); |
22 | 22 | arrayPeek(material.renderObj).addTexture("colorMeMap2", 3, RDGE.UNIFORMTYPE.TEXTURE2D); | |
23 | arrayPeek(material.renderObj).addTexture("layerMap1", 0, UNIFORMTYPE.TEXTURE2D); | 23 | arrayPeek(material.renderObj).addTexture("envMap", 4, RDGE.UNIFORMTYPE.TEXTURE2D); |
24 | arrayPeek(material.renderObj).addTexture("layerMap2", 1, UNIFORMTYPE.TEXTURE2D); | 24 | arrayPeek(material.renderObj).addTexture("envDiff", 5, RDGE.UNIFORMTYPE.TEXTURE2D); |
25 | arrayPeek(material.renderObj).addTexture("colorMeMap1", 2, UNIFORMTYPE.TEXTURE2D); | 25 | |
26 | arrayPeek(material.renderObj).addTexture("colorMeMap2", 3, UNIFORMTYPE.TEXTURE2D); | 26 | arrayPeek(material.renderObj).addTexture("normalMap1", 15, RDGE.UNIFORMTYPE.TEXTURE2D); |
27 | arrayPeek(material.renderObj).addTexture("envMap", 4, UNIFORMTYPE.TEXTURE2D); | 27 | arrayPeek(material.renderObj).addTexture("normalMap2", 6, RDGE.UNIFORMTYPE.TEXTURE2D); |
28 | arrayPeek(material.renderObj).addTexture("envDiff", 5, UNIFORMTYPE.TEXTURE2D); | 28 | |
29 | 29 | arrayPeek(material.renderObj).addTexture("stickerMap0", 7, RDGE.UNIFORMTYPE.TEXTURE2D); | |
30 | arrayPeek(material.renderObj).addTexture("normalMap1", 15, UNIFORMTYPE.TEXTURE2D); | 30 | arrayPeek(material.renderObj).addTexture("stickerMap1", 8, RDGE.UNIFORMTYPE.TEXTURE2D); |
31 | arrayPeek(material.renderObj).addTexture("normalMap2", 6, UNIFORMTYPE.TEXTURE2D); | 31 | arrayPeek(material.renderObj).addTexture("stickerMap2", 9, RDGE.UNIFORMTYPE.TEXTURE2D); |
32 | 32 | arrayPeek(material.renderObj).addTexture("stickerMap3", 10, RDGE.UNIFORMTYPE.TEXTURE2D); | |
33 | arrayPeek(material.renderObj).addTexture("stickerMap0", 7, UNIFORMTYPE.TEXTURE2D); | 33 | arrayPeek(material.renderObj).addTexture("stickerMap4", 11, RDGE.UNIFORMTYPE.TEXTURE2D); |
34 | arrayPeek(material.renderObj).addTexture("stickerMap1", 8, UNIFORMTYPE.TEXTURE2D); | 34 | arrayPeek(material.renderObj).addTexture("stickerMap5", 12, RDGE.UNIFORMTYPE.TEXTURE2D); |
35 | arrayPeek(material.renderObj).addTexture("stickerMap2", 9, UNIFORMTYPE.TEXTURE2D); | 35 | arrayPeek(material.renderObj).addTexture("stickerMap6", 13, RDGE.UNIFORMTYPE.TEXTURE2D); |
36 | arrayPeek(material.renderObj).addTexture("stickerMap3", 10, UNIFORMTYPE.TEXTURE2D); | 36 | arrayPeek(material.renderObj).addTexture("stickerMap7", 14, RDGE.UNIFORMTYPE.TEXTURE2D); |
37 | arrayPeek(material.renderObj).addTexture("stickerMap4", 11, UNIFORMTYPE.TEXTURE2D); | 37 | |
38 | arrayPeek(material.renderObj).addTexture("stickerMap5", 12, UNIFORMTYPE.TEXTURE2D); | 38 | arrayPeek(material.renderObj).addUniform("u_normalMatrix", gl.normalMatrix, RDGE.UNIFORMTYPE.MATRIX4); |
39 | arrayPeek(material.renderObj).addTexture("stickerMap6", 13, UNIFORMTYPE.TEXTURE2D); | 39 | arrayPeek(material.renderObj).addUniform("u_mvMatrix", gl.mvMatrix, RDGE.UNIFORMTYPE.MATRIX4); |
40 | arrayPeek(material.renderObj).addTexture("stickerMap7", 14, UNIFORMTYPE.TEXTURE2D); | 40 | arrayPeek(material.renderObj).addUniform("u_invMvMatrix", gl.invMvMatrix, RDGE.UNIFORMTYPE.MATRIX4); |
41 | 41 | ||
42 | arrayPeek(material.renderObj).addUniform("u_normalMatrix", gl.normalMatrix, UNIFORMTYPE.MATRIX4); | 42 | arrayPeek(material.renderObj).addUniform("u_stickerMatrix0", primSet.parentMesh.stickers[0], RDGE.UNIFORMTYPE.MATRIX4); |
43 | arrayPeek(material.renderObj).addUniform("u_mvMatrix", gl.mvMatrix, UNIFORMTYPE.MATRIX4); | 43 | arrayPeek(material.renderObj).addUniform("u_stickerMatrix1", primSet.parentMesh.stickers[1], RDGE.UNIFORMTYPE.MATRIX4); |
44 | arrayPeek(material.renderObj).addUniform("u_invMvMatrix", gl.invMvMatrix, UNIFORMTYPE.MATRIX4); | 44 | arrayPeek(material.renderObj).addUniform("u_stickerMatrix2", primSet.parentMesh.stickers[2], RDGE.UNIFORMTYPE.MATRIX4); |
45 | 45 | arrayPeek(material.renderObj).addUniform("u_stickerMatrix3", primSet.parentMesh.stickers[3], RDGE.UNIFORMTYPE.MATRIX4); | |
46 | arrayPeek(material.renderObj).addUniform("u_stickerMatrix0", primSet.parentMesh.stickers[0], UNIFORMTYPE.MATRIX4); | 46 | arrayPeek(material.renderObj).addUniform("u_stickerMatrix4", primSet.parentMesh.stickers[4], RDGE.UNIFORMTYPE.MATRIX4); |
47 | arrayPeek(material.renderObj).addUniform("u_stickerMatrix1", primSet.parentMesh.stickers[1], UNIFORMTYPE.MATRIX4); | 47 | arrayPeek(material.renderObj).addUniform("u_stickerMatrix5", primSet.parentMesh.stickers[5], RDGE.UNIFORMTYPE.MATRIX4); |
48 | arrayPeek(material.renderObj).addUniform("u_stickerMatrix2", primSet.parentMesh.stickers[2], UNIFORMTYPE.MATRIX4); | 48 | arrayPeek(material.renderObj).addUniform("u_stickerMatrix6", primSet.parentMesh.stickers[6], RDGE.UNIFORMTYPE.MATRIX4); |
49 | arrayPeek(material.renderObj).addUniform("u_stickerMatrix3", primSet.parentMesh.stickers[3], UNIFORMTYPE.MATRIX4); | 49 | arrayPeek(material.renderObj).addUniform("u_stickerMatrix7", primSet.parentMesh.stickers[7], RDGE.UNIFORMTYPE.MATRIX4); |
50 | arrayPeek(material.renderObj).addUniform("u_stickerMatrix4", primSet.parentMesh.stickers[4], UNIFORMTYPE.MATRIX4); | 50 | |
51 | arrayPeek(material.renderObj).addUniform("u_stickerMatrix5", primSet.parentMesh.stickers[5], UNIFORMTYPE.MATRIX4); | 51 | arrayPeek(material.renderObj).addUniform("u_stickerPos0", primSet.parentMesh.stickersPos[0], RDGE.UNIFORMTYPE.FLOAT3); |
52 | arrayPeek(material.renderObj).addUniform("u_stickerMatrix6", primSet.parentMesh.stickers[6], UNIFORMTYPE.MATRIX4); | 52 | arrayPeek(material.renderObj).addUniform("u_stickerPos1", primSet.parentMesh.stickersPos[1], RDGE.UNIFORMTYPE.FLOAT3); |
53 | arrayPeek(material.renderObj).addUniform("u_stickerMatrix7", primSet.parentMesh.stickers[7], UNIFORMTYPE.MATRIX4); | 53 | arrayPeek(material.renderObj).addUniform("u_stickerPos2", primSet.parentMesh.stickersPos[2], RDGE.UNIFORMTYPE.FLOAT3); |
54 | 54 | arrayPeek(material.renderObj).addUniform("u_stickerPos3", primSet.parentMesh.stickersPos[3], RDGE.UNIFORMTYPE.FLOAT3); | |
55 | arrayPeek(material.renderObj).addUniform("u_stickerPos0", primSet.parentMesh.stickersPos[0], UNIFORMTYPE.FLOAT3); | 55 | arrayPeek(material.renderObj).addUniform("u_stickerPos4", primSet.parentMesh.stickersPos[4], RDGE.UNIFORMTYPE.FLOAT3); |
56 | arrayPeek(material.renderObj).addUniform("u_stickerPos1", primSet.parentMesh.stickersPos[1], UNIFORMTYPE.FLOAT3); | 56 | arrayPeek(material.renderObj).addUniform("u_stickerPos5", primSet.parentMesh.stickersPos[5], RDGE.UNIFORMTYPE.FLOAT3); |
57 | arrayPeek(material.renderObj).addUniform("u_stickerPos2", primSet.parentMesh.stickersPos[2], UNIFORMTYPE.FLOAT3); | 57 | arrayPeek(material.renderObj).addUniform("u_stickerPos6", primSet.parentMesh.stickersPos[6], RDGE.UNIFORMTYPE.FLOAT3); |
58 | arrayPeek(material.renderObj).addUniform("u_stickerPos3", primSet.parentMesh.stickersPos[3], UNIFORMTYPE.FLOAT3); | 58 | arrayPeek(material.renderObj).addUniform("u_stickerPos7", primSet.parentMesh.stickersPos[7], RDGE.UNIFORMTYPE.FLOAT3); |
59 | arrayPeek(material.renderObj).addUniform("u_stickerPos4", primSet.parentMesh.stickersPos[4], UNIFORMTYPE.FLOAT3); | 59 | |
60 | arrayPeek(material.renderObj).addUniform("u_stickerPos5", primSet.parentMesh.stickersPos[5], UNIFORMTYPE.FLOAT3); | 60 | arrayPeek(material.renderObj).addUniform("u_projMatrix", gl.perspectiveMatrix, RDGE.UNIFORMTYPE.MATRIX4); |
61 | arrayPeek(material.renderObj).addUniform("u_stickerPos6", primSet.parentMesh.stickersPos[6], UNIFORMTYPE.FLOAT3); | 61 | |
62 | arrayPeek(material.renderObj).addUniform("u_stickerPos7", primSet.parentMesh.stickersPos[7], UNIFORMTYPE.FLOAT3); | 62 | arrayPeek(material.renderObj).addUniform("u_fillColor1", material.fillColor[0], RDGE.UNIFORMTYPE.FLOAT4); |
63 | 63 | arrayPeek(material.renderObj).addUniform("u_fillColor2", material.fillColor[1], RDGE.UNIFORMTYPE.FLOAT4); | |
64 | 64 | arrayPeek(material.renderObj).addUniform("u_skinColor", material.fillColor[2], RDGE.UNIFORMTYPE.FLOAT4); | |
65 | arrayPeek(material.renderObj).addUniform("u_projMatrix", gl.perspectiveMatrix, UNIFORMTYPE.MATRIX4); | 65 | |
66 | 66 | // debug--- | |
67 | arrayPeek(material.renderObj).addUniform("u_fillColor1", material.fillColor[0], UNIFORMTYPE.FLOAT4); | 67 | vertexData.vertexObject.name = "vertexObject"; |
68 | arrayPeek(material.renderObj).addUniform("u_fillColor2", material.fillColor[1], UNIFORMTYPE.FLOAT4); | 68 | vertexData.normalObject.name = "normalObject"; |
69 | arrayPeek(material.renderObj).addUniform("u_skinColor", material.fillColor[2], UNIFORMTYPE.FLOAT4); | 69 | vertexData.texCoordObject.name = "texCoordObject"; |
70 | 70 | vertexData.indexObject.name = "indexObject"; | |
71 | 71 | //---------- | |
72 | // debug--- | 72 | |
73 | vertexData.vertexObject.name = "vertexObject"; | 73 | arrayPeek(material.renderObj).addBuffers(vertexData.vertexObject, gl.ARRAY_BUFFER, 3, 0, gl.FLOAT); |
74 | vertexData.normalObject.name = "normalObject"; | 74 | arrayPeek(material.renderObj).addBuffers(vertexData.normalObject, gl.ARRAY_BUFFER, 3, 1, gl.FLOAT); |
75 | vertexData.texCoordObject.name = "texCoordObject"; | 75 | arrayPeek(material.renderObj).addBuffers(vertexData.texCoordObject, gl.ARRAY_BUFFER, 2, 2, gl.FLOAT); |
76 | vertexData.indexObject.name = "indexObject"; | 76 | arrayPeek(material.renderObj).addBuffers(vertexData.indexObject, gl.ELEMENT_ARRAY_BUFFER); |
77 | //---------- | 77 | |
78 | 78 | gl.useProgram(null); | |
79 | arrayPeek(material.renderObj).addBuffers(vertexData.vertexObject, gl.ARRAY_BUFFER, 3, 0, gl.FLOAT); | 79 | // gl.console.log("Mesh Init done!"); |
80 | arrayPeek(material.renderObj).addBuffers(vertexData.normalObject, gl.ARRAY_BUFFER, 3, 1, gl.FLOAT); | 80 | }; |
81 | arrayPeek(material.renderObj).addBuffers(vertexData.texCoordObject, gl.ARRAY_BUFFER, 2, 2, gl.FLOAT); | 81 | |
82 | arrayPeek(material.renderObj).addBuffers(vertexData.indexObject, gl.ELEMENT_ARRAY_BUFFER); | 82 | RDGE.renderInitScreenQuad = function (quad, shader) { |
83 | 83 | if (shader == undefined) { | |
84 | 84 | quad.shader = RDGE.createShader(gl, 'screenQuad_vShader', 'screenQuad_fShader', ["vert", "texcoord"]); | |
85 | //} | 85 | } |
86 | 86 | else { | |
87 | gl.useProgram(null); | 87 | quad.shader = shader; |
88 | // gl.console.log("Mesh Init done!"); | 88 | } |
89 | 89 | ||
90 | } | 90 | quad.renderObj = new RDGE.RenderObject(quad.shader); |
91 | 91 | ||
92 | function __renderInitScreenQuad(quad, shader) | 92 | quadBuf = getScreenAlignedQuad(); |
93 | { | 93 | |
94 | if(shader == undefined) | 94 | quad.vertBuffer = quadBuf.vertexObject; |
95 | { | 95 | quad.uvBuffer = quadBuf.texCoordObject; |
96 | quad.shader = createShader(gl, 'screenQuad_vShader', 'screenQuad_fShader', [ "vert", "texcoord"]); | 96 | |
97 | } | 97 | |
98 | else | 98 | quad.renderObj.addTexture("basemap", 0, RDGE.UNIFORMTYPE.TEXTURE2D); |
99 | { | 99 | |
100 | quad.shader = shader; | 100 | 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; |
101 | } | 101 | quad.renderObj.addUniform("u_inv_viewport_width", invWidth, RDGE.UNIFORMTYPE.FLOAT); |
102 | 102 | quad.renderObj.addUniform("u_inv_viewport_height", invHeight, RDGE.UNIFORMTYPE.FLOAT); | |
103 | quad.renderObj = new RenderObject(quad.shader); | 103 | |
104 | 104 | quad.renderObj.addBuffers(quad.vertBuffer, gl.ARRAY_BUFFER, 3, 0, gl.FLOAT); | |
105 | quadBuf = getScreenAlignedQuad(); | 105 | quad.renderObj.addBuffers(quad.uvBuffer, gl.ARRAY_BUFFER, 2, 2, gl.FLOAT); |
106 | 106 | }; | |
107 | quad.vertBuffer = quadBuf.vertexObject; | 107 | |
108 | quad.uvBuffer = quadBuf.texCoordObject; | 108 | RDGE.renderInitProcDepthMap = function (renderObj) { |
109 | 109 | renderObj.shader = g_depthShader.shaderHandle; //RDGE.createShader(gl, depthMapVShader, depthMapFShader, [ "vert", "normal", "texcoord"]); | |
110 | 110 | ||
111 | quad.renderObj.addTexture("basemap", 0, UNIFORMTYPE.TEXTURE2D); | ||
112 | |||
113 | var invWidth = (g_width == 0.0) ? 0.0 : 1.0/g_width, invHeight = (g_height == 0.0) ? 0.0 : 1.0/g_height; | ||
114 | quad.renderObj.addUniform("u_inv_viewport_width", invWidth, UNIFORMTYPE.FLOAT); | ||
115 | quad.renderObj.addUniform("u_inv_viewport_height", invHeight, UNIFORMTYPE.FLOAT); | ||
116 | |||
117 | quad.renderObj.addBuffers(quad.vertBuffer, gl.ARRAY_BUFFER, 3, 0, gl.FLOAT); | ||
118 | quad.renderObj.addBuffers(quad.uvBuffer, gl.ARRAY_BUFFER, 2, 2, gl.FLOAT); | ||
119 | } | ||
120 | |||
121 | function __renderInitProcDepthMap(renderObj) | ||