diff options
Diffstat (limited to 'js/helper-classes/RDGE')
-rwxr-xr-x | js/helper-classes/RDGE/rdge-compiled.js | 64 | ||||
-rw-r--r-- | js/helper-classes/RDGE/runtime/CanvasDataManager.js | 98 | ||||
-rw-r--r-- | js/helper-classes/RDGE/runtime/GLRuntime.js | 159 | ||||
-rwxr-xr-x | js/helper-classes/RDGE/src/core/script/engine.js | 15 | ||||
-rwxr-xr-x | js/helper-classes/RDGE/src/core/script/fx/ssao.js | 2 | ||||
-rwxr-xr-x | js/helper-classes/RDGE/src/core/script/init_state.js | 12 | ||||
-rwxr-xr-x | js/helper-classes/RDGE/src/core/script/jshader.js | 8 | ||||
-rwxr-xr-x | js/helper-classes/RDGE/src/core/script/renderer.js | 1 | ||||
-rwxr-xr-x | js/helper-classes/RDGE/src/core/script/scenegraphNodes.js | 2 | ||||
-rwxr-xr-x | js/helper-classes/RDGE/src/core/script/utilities.js | 4 | ||||
-rw-r--r-- | js/helper-classes/RDGE/src/tools/rdge-compiled.js | 64 |
11 files changed, 94 insertions, 335 deletions
diff --git a/js/helper-classes/RDGE/rdge-compiled.js b/js/helper-classes/RDGE/rdge-compiled.js index a211d17f..d1040d73 100755 --- a/js/helper-classes/RDGE/rdge-compiled.js +++ b/js/helper-classes/RDGE/rdge-compiled.js | |||
@@ -54,14 +54,14 @@ this.ctx.clearColor(1,0,0,1);this.clearColor=[1,0,0,1];this.clearFlags=this.ctx. | |||
54 | 5123;this.INT=5124;this.UNSIGNED_INT=5125;this.FLOAT=5126;this.VS_ELEMENT_FLOAT4=4;this.VS_ELEMENT_FLOAT3=this.VS_ELEMENT_NORM=this.VS_ELEMENT_POS=3;this.VS_ELEMENT_UV=this.VS_ELEMENT_FLOAT2=2;this.VS_ELEMENT_FLOAT=1;this.MAX_ELEM_TYPES=7;this.BUFFER_STATIC=35040;this.BUFFER_DYNAMIC=35044;this.BUFFER_STREAM=35048;this.MAX_MATERIAL_LIGHTS=4;this.usedTextureUnits=5;this.vpY=this.vpX=0;this.vpWidth=a.width;this.vpHeight=a.height;this.cameraMan=new cameraManager;this.buffers=[];this.cullBackFace=function(){this.ctx.cullFace(this.ctx.Back)}; | 54 | 5123;this.INT=5124;this.UNSIGNED_INT=5125;this.FLOAT=5126;this.VS_ELEMENT_FLOAT4=4;this.VS_ELEMENT_FLOAT3=this.VS_ELEMENT_NORM=this.VS_ELEMENT_POS=3;this.VS_ELEMENT_UV=this.VS_ELEMENT_FLOAT2=2;this.VS_ELEMENT_FLOAT=1;this.MAX_ELEM_TYPES=7;this.BUFFER_STATIC=35040;this.BUFFER_DYNAMIC=35044;this.BUFFER_STREAM=35048;this.MAX_MATERIAL_LIGHTS=4;this.usedTextureUnits=5;this.vpY=this.vpX=0;this.vpWidth=a.width;this.vpHeight=a.height;this.cameraMan=new cameraManager;this.buffers=[];this.cullBackFace=function(){this.ctx.cullFace(this.ctx.Back)}; |
55 | this.cullFrontFace=function(){this.ctx.cullFace(this.ctx.FRONT)};this.disableCulling=function(){this.ctx.disable(this.ctx.CULL_FACE)};this.enableCulling=function(){this.ctx.enable(this.ctx.CULL_FACE)};this.enablePolyOffsetFill=function(){this.ctx.enable(this.ctx.POLYGON_OFFSET_FILL)};this.disablePolyOffsetFill=function(){this.ctx.enable(this.ctx.POLYGON_OFFSET_FILL)};this.enablePointSprites=function(){};this.disablePointSprites=function(){};this.setClearColor=function(a){this.clearColor=a.slice(); | 55 | this.cullFrontFace=function(){this.ctx.cullFace(this.ctx.FRONT)};this.disableCulling=function(){this.ctx.disable(this.ctx.CULL_FACE)};this.enableCulling=function(){this.ctx.enable(this.ctx.CULL_FACE)};this.enablePolyOffsetFill=function(){this.ctx.enable(this.ctx.POLYGON_OFFSET_FILL)};this.disablePolyOffsetFill=function(){this.ctx.enable(this.ctx.POLYGON_OFFSET_FILL)};this.enablePointSprites=function(){};this.disablePointSprites=function(){};this.setClearColor=function(a){this.clearColor=a.slice(); |
56 | this.ctx.clearColor(a[0],a[1],a[2],a[3])};this.setClearFlags=function(a){this.clearFlags=a};this._clear=function(){this.ctx.clear(this.clearFlags)};this.clear=function(a){this.ctx.clear(a)};this.flush=function(){this.ctx.flush()};this.setViewPort=function(a,b,h,l){this.vpX=a;this.vpY=b;this.vpWidth=h;this.vpHeight=l;this.ctx.viewport(this.vpX,this.vpY,this.vpWidth,this.vpHeight)};this.cameraManager=function(){return this.cameraMan};this.textureMap=[];this.rttMap=[];this.getTextureByName=function(a, | 56 | this.ctx.clearColor(a[0],a[1],a[2],a[3])};this.setClearFlags=function(a){this.clearFlags=a};this._clear=function(){this.ctx.clear(this.clearFlags)};this.clear=function(a){this.ctx.clear(a)};this.flush=function(){this.ctx.flush()};this.setViewPort=function(a,b,h,l){this.vpX=a;this.vpY=b;this.vpWidth=h;this.vpHeight=l;this.ctx.viewport(this.vpX,this.vpY,this.vpWidth,this.vpHeight)};this.cameraManager=function(){return this.cameraMan};this.textureMap=[];this.rttMap=[];this.getTextureByName=function(a, |
57 | b,h){var l=a.split(".")[1],n=this.textureMap[a];n===void 0?(n=this.createTexture(a+(l?"":".png"),b,h),this.textureMap[a]=n,n.lookUpName=a,n.previouslyReferenced=!1):n.previouslyReferenced=!0;return n};this.unloadedTextureCount=0;_texparams=function(a,b){this.wrap=a;this.mips=b};this.createTexture=function(a,b,h){var l=this.ctx.createTexture();this.unloadedTextureCount++;b===void 0&&(b="CLAMP");h===void 0&&(h=!0);if(l)l.image=new Image,l.image.src=a,l.image.context=g_Engine.getContext(),l.texparams= | 57 | b,h){var l=a.split(".")[1],l=l?"":".png",n=this.textureMap[a];n===void 0?(a=g_Engine.remapAssetFolder(a),n=this.createTexture(a+l,b,h),this.textureMap[a]=n,n.lookUpName=a,n.previouslyReferenced=!1):n.previouslyReferenced=!0;return n};this.unloadedTextureCount=0;_texparams=function(a,b){this.wrap=a;this.mips=b};this.createTexture=function(a,b,h){var l=this.ctx.createTexture();this.unloadedTextureCount++;b===void 0&&(b="CLAMP");h===void 0&&(h=!0);if(l)l.image=new Image,l.image.src=a,l.image.context= |
58 | new _texparams(b,h),l.image.onload=function(){this.context.ctxStateManager.RDGEInitState.loadTexture(l);this.context.renderer.unloadedTextureCount--;l.callback&&l.callback(l);this.context.renderer.unloadedTextureCount<0&&console.log("more textures loaded then created...")},l.image.onerror=function(){this.context.renderer.unloadedTextureCount--;l.callback&&l.callback(l);this.context.renderer.unloadedTextureCount<0&&console.log("more textures loaded then created...")};return l};this.commitTexture=function(a){this.ctx.bindTexture(this.ctx.TEXTURE_2D, | 58 | g_Engine.getContext(),l.texparams=new _texparams(b,h),l.image.onload=function(){this.context.ctxStateManager.RDGEInitState.loadTexture(l);this.context.renderer.unloadedTextureCount--;l.callback&&l.callback(l);this.context.renderer.unloadedTextureCount<0&&console.log("more textures loaded then created...")},l.image.onerror=function(){this.context.renderer.unloadedTextureCount--;l.callback&&l.callback(l);this.context.renderer.unloadedTextureCount<0&&console.log("more textures loaded then created...")}; |
59 | a);this.ctx.texImage2D(this.ctx.TEXTURE_2D,0,this.ctx.RGBA,this.ctx.RGBA,this.ctx.UNSIGNED_BYTE,a.image);a.texparams.mips&&this.ctx.generateMipmap(this.ctx.TEXTURE_2D);this.ctx.texParameteri(this.ctx.TEXTURE_2D,this.ctx.TEXTURE_MAG_FILTER,this.ctx.LINEAR);this.ctx.texParameteri(this.ctx.TEXTURE_2D,this.ctx.TEXTURE_MIN_FILTER,a.texparams.mips?this.ctx.LINEAR_MIPMAP_LINEAR:this.ctx.LINEAR);this.ctx.texParameteri(this.ctx.TEXTURE_2D,this.ctx.TEXTURE_WRAP_S,a.texparams.wrap==="REPEAT"?this.ctx.REPEAT: | 59 | return l};this.commitTexture=function(a){this.ctx.bindTexture(this.ctx.TEXTURE_2D,a);this.ctx.texImage2D(this.ctx.TEXTURE_2D,0,this.ctx.RGBA,this.ctx.RGBA,this.ctx.UNSIGNED_BYTE,a.image);a.texparams.mips&&this.ctx.generateMipmap(this.ctx.TEXTURE_2D);this.ctx.texParameteri(this.ctx.TEXTURE_2D,this.ctx.TEXTURE_MAG_FILTER,this.ctx.LINEAR);this.ctx.texParameteri(this.ctx.TEXTURE_2D,this.ctx.TEXTURE_MIN_FILTER,a.texparams.mips?this.ctx.LINEAR_MIPMAP_LINEAR:this.ctx.LINEAR);this.ctx.texParameteri(this.ctx.TEXTURE_2D, |
60 | this.ctx.CLAMP_TO_EDGE);this.ctx.texParameteri(this.ctx.TEXTURE_2D,this.ctx.TEXTURE_WRAP_T,a.texparams.wrap==="REPEAT"?this.ctx.REPEAT:this.ctx.CLAMP_TO_EDGE);this.ctx.bindTexture(this.ctx.TEXTURE_2D,null)};this.verify=function(a){var b=this.ctx.getError();b!=0&&window.console.log("GLError ( "+a+") : "+b)};this.createRenderTargetTexture=function(a,b,h,l){var n=this.ctx,o=n.createFramebuffer();n.bindFramebuffer(n.FRAMEBUFFER,o);o.width=b;o.height=h;b=n.createTexture();n.bindTexture(n.TEXTURE_2D,b); | 60 | this.ctx.TEXTURE_WRAP_S,a.texparams.wrap==="REPEAT"?this.ctx.REPEAT:this.ctx.CLAMP_TO_EDGE);this.ctx.texParameteri(this.ctx.TEXTURE_2D,this.ctx.TEXTURE_WRAP_T,a.texparams.wrap==="REPEAT"?this.ctx.REPEAT:this.ctx.CLAMP_TO_EDGE);this.ctx.bindTexture(this.ctx.TEXTURE_2D,null)};this.verify=function(a){var b=this.ctx.getError();b!=0&&window.console.log("GLError ( "+a+") : "+b)};this.createRenderTargetTexture=function(a,b,h,l){var n=this.ctx,o=n.createFramebuffer();n.bindFramebuffer(n.FRAMEBUFFER,o);o.width= |
61 | try{n.texImage2D(n.TEXTURE_2D,0,n.RGBA,o.width,o.height,0,n.RGBA,n.UNSIGNED_BYTE,null)}catch(p){h=new WebctxUnsignedByteArray(o.width*o.height*4),n.texImage2D(n.TEXTURE_2D,0,n.RGBA,o.width,o.height,0,n.RGBA,n.UNSIGNED_BYTE,h)}n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.LINEAR);n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,l?n.LINEAR_MIPMAP_NEAREST:n.LINEAR);n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE);n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE);l&& | 61 | b;o.height=h;b=n.createTexture();n.bindTexture(n.TEXTURE_2D,b);try{n.texImage2D(n.TEXTURE_2D,0,n.RGBA,o.width,o.height,0,n.RGBA,n.UNSIGNED_BYTE,null)}catch(p){h=new WebctxUnsignedByteArray(o.width*o.height*4),n.texImage2D(n.TEXTURE_2D,0,n.RGBA,o.width,o.height,0,n.RGBA,n.UNSIGNED_BYTE,h)}n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.LINEAR);n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,l?n.LINEAR_MIPMAP_NEAREST:n.LINEAR);n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE);n.texParameteri(n.TEXTURE_2D, |
62 | n.generateMipmap(n.TEXTURE_2D);l=n.createRenderbuffer();n.bindRenderbuffer(n.RENDERBUFFER,l);n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_COMPONENT16,o.width,o.height);n.getError(n.bindFramebuffer(n.FRAMEBUFFER,o));n.getError(n.bindRenderbuffer(n.RENDERBUFFER,l));n.getError(n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_COMPONENT16,o.width,o.height));n.bindRenderbuffer(n.RENDERBUFFER,null);n.getError(n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,b,0));n.getError(n.framebufferRenderbuffer(n.FRAMEBUFFER, | 62 | n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE);l&&n.generateMipmap(n.TEXTURE_2D);l=n.createRenderbuffer();n.bindRenderbuffer(n.RENDERBUFFER,l);n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_COMPONENT16,o.width,o.height);n.getError(n.bindFramebuffer(n.FRAMEBUFFER,o));n.getError(n.bindRenderbuffer(n.RENDERBUFFER,l));n.getError(n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_COMPONENT16,o.width,o.height));n.bindRenderbuffer(n.RENDERBUFFER,null);n.getError(n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D, |
63 | n.DEPTH_ATTACHMENT,n.RENDERBUFFER,l));n.bindFramebuffer(n.FRAMEBUFFER,null);n.bindTexture(n.TEXTURE_2D,null);n.bindRenderbuffer(n.RENDERBUFFER,null);n.bindFramebuffer(n.FRAMEBUFFER,null);b.id="RT_"+nodeIdGen.getId();b.frameBuffer=o;this.textureMap[a]&&window.console.log("Notification: render target: "+a+" has overwritten an existing render target");return this.textureMap[a]=b};this.defaultShaderDefintion={shaders:{defaultVShader:"assets/shaders/test_vshader.glsl",defaultFShader:"assets/shaders/test_fshader.glsl"}, | 63 | b,0));n.getError(n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.RENDERBUFFER,l));n.bindFramebuffer(n.FRAMEBUFFER,null);n.bindTexture(n.TEXTURE_2D,null);n.bindRenderbuffer(n.RENDERBUFFER,null);n.bindFramebuffer(n.FRAMEBUFFER,null);b.id="RT_"+nodeIdGen.getId();b.frameBuffer=o;this.textureMap[a]&&window.console.log("Notification: render target: "+a+" has overwritten an existing render target");return this.textureMap[a]=b};this.defaultShaderDefintion={shaders:{defaultVShader:"assets/shaders/test_vshader.glsl", |
64 | techniques:{defaultTechnique:[{vshader:"defaultVShader",fshader:"defaultFShader",attributes:{vert:{type:"vec3"},normal:{type:"vec3"},texcoord:{type:"vec2"}},params:{},states:{depthEnable:!0,blendEnable:!1,culling:!0,cullFace:"BACK"}}]}}}; | 64 | defaultFShader:"assets/shaders/test_fshader.glsl"},techniques:{defaultTechnique:[{vshader:"defaultVShader",fshader:"defaultFShader",attributes:{vert:{type:"vec3"},normal:{type:"vec3"},texcoord:{type:"vec2"}},params:{},states:{depthEnable:!0,blendEnable:!1,culling:!0,cullFace:"BACK"}}]}}}; |
65 | rdgeDefaultShaderDefintion={shaders:{defaultVShader:"assets/shaders/Basic.vert.glsl",defaultFShader:"assets/shaders/Basic.frag.glsl"},techniques:{defaultTechnique:[{vshader:"defaultVShader",fshader:"defaultFShader",attributes:{vert:{type:"vec3"},normal:{type:"vec3"},texcoord:{type:"vec2"}},params:{},states:{depthEnable:!0,blendEnable:!1,culling:!0,cullFace:"BACK"}}]}}; | 65 | rdgeDefaultShaderDefintion={shaders:{defaultVShader:"assets/shaders/Basic.vert.glsl",defaultFShader:"assets/shaders/Basic.frag.glsl"},techniques:{defaultTechnique:[{vshader:"defaultVShader",fshader:"defaultFShader",attributes:{vert:{type:"vec3"},normal:{type:"vec3"},texcoord:{type:"vec2"}},params:{},states:{depthEnable:!0,blendEnable:!1,culling:!0,cullFace:"BACK"}}]}}; |
66 | rdgeDepthMapShaderDef={shaders:{depthMapVShader:"assets/shaders/depthMap_vshader.glsl",depthMapFShader:"assets/shaders/depthMap_fshader.glsl"},techniques:{shadowDepthMap:[{vshader:"depthMapVShader",fshader:"depthMapFShader",attributes:{vert:{type:"vec3"},normal:{type:"vec3"},texcoord:{type:"vec2"}},params:{},states:{depthEnable:!0,blendEnable:!1,culling:!0,cullFace:"BACK"}}],depthMap:[{vshader:"depthMapVShader",fshader:"depthMapFShader",attributes:{vert:{type:"vec3"},normal:{type:"vec3"},texcoord:{type:"vec2"}}, | 66 | rdgeDepthMapShaderDef={shaders:{depthMapVShader:"assets/shaders/depthMap_vshader.glsl",depthMapFShader:"assets/shaders/depthMap_fshader.glsl"},techniques:{shadowDepthMap:[{vshader:"depthMapVShader",fshader:"depthMapFShader",attributes:{vert:{type:"vec3"},normal:{type:"vec3"},texcoord:{type:"vec2"}},params:{},states:{depthEnable:!0,blendEnable:!1,culling:!0,cullFace:"BACK"}}],depthMap:[{vshader:"depthMapVShader",fshader:"depthMapFShader",attributes:{vert:{type:"vec3"},normal:{type:"vec3"},texcoord:{type:"vec2"}}, |
67 | params:{},states:{depthEnable:!0,blendEnable:!1,culling:!0,cullFace:"BACK"}}]}};rdgeViewSpaceNormalsShader={shaders:{normalsVShader:"assets/shaders/norm_depth_vshader.glsl",normalsFShader:"assets/shaders/norm_depth_fshader.glsl"},techniques:{depthMapWNormal:[{vshader:"normalsVShader",fshader:"normalsFShader",attributes:{vert:{type:"vec3"},normal:{type:"vec3"}},params:{},states:{depthEnable:!0,blendEnable:!1,culling:!0,cullFace:"BACK"}}]}}; | 67 | params:{},states:{depthEnable:!0,blendEnable:!1,culling:!0,cullFace:"BACK"}}]}};rdgeViewSpaceNormalsShader={shaders:{normalsVShader:"assets/shaders/norm_depth_vshader.glsl",normalsFShader:"assets/shaders/norm_depth_fshader.glsl"},techniques:{depthMapWNormal:[{vshader:"normalsVShader",fshader:"normalsFShader",attributes:{vert:{type:"vec3"},normal:{type:"vec3"}},params:{},states:{depthEnable:!0,blendEnable:!1,culling:!0,cullFace:"BACK"}}]}}; |
@@ -118,22 +118,22 @@ jshader=function(a){this.name=a;this.def=null;this.technique={};this.params={};t | |||
118 | "mat4",paramTypeNameMapping[a.SAMPLER_2D]="tex2d",paramTypeNameMapping[a.SAMPLER_CUBE]="texCube";this.bindParameters=function(a){for(var f=a.defParamsList,g=a.lightParams,h=a.lightContext,l=f.length,n=0,o=Array(2),p=0,n=0;n<l;++n)if(f[n].type=="tex2d"||f[n].type=="texCube")o[0]=p++,o[1]=f[n].data[0],bindMap[f[n].type](this.ctx,f[n].loc,o);else bindMap[f[n].type](this.ctx,f[n].loc,rdgeGlobalParameters[f[n].name].data);f=rdgeConstants.MAX_MATERIAL_LIGHTS;for(l=0;l<f;++l)if(h[l]!=null&&g[l]){n=g[l].length; | 118 | "mat4",paramTypeNameMapping[a.SAMPLER_2D]="tex2d",paramTypeNameMapping[a.SAMPLER_CUBE]="texCube";this.bindParameters=function(a){for(var f=a.defParamsList,g=a.lightParams,h=a.lightContext,l=f.length,n=0,o=Array(2),p=0,n=0;n<l;++n)if(f[n].type=="tex2d"||f[n].type=="texCube")o[0]=p++,o[1]=f[n].data[0],bindMap[f[n].type](this.ctx,f[n].loc,o);else bindMap[f[n].type](this.ctx,f[n].loc,rdgeGlobalParameters[f[n].name].data);f=rdgeConstants.MAX_MATERIAL_LIGHTS;for(l=0;l<f;++l)if(h[l]!=null&&g[l]){n=g[l].length; |
119 | for(p=0;p<n;++p)lightDataMap[g[l][p].dataIndex](this.ctx,g[l][p].loc,h[l])}p=this.renderer.usedTextureUnits;f=a.paramsList;l=f.length;for(n=0;n<l;++n)if(f[n].type=="tex2d"||f[n].type=="texCube")o[0]=p++,o[1]=f[n].data[0],bindMap[f[n].type](this.ctx,f[n].loc,o);else bindMap[f[n].type](this.ctx,f[n].loc,f[n].data)};createJShaderTexture=function(a,f){var g=null,g=typeof f.data=="string"?a.canvas.renderer.getTextureByName(f.data,f.wrap,f.repeat,f.mips):a.canvas.renderer.getTextureByName(f.data.lookUpName, | 119 | for(p=0;p<n;++p)lightDataMap[g[l][p].dataIndex](this.ctx,g[l][p].loc,h[l])}p=this.renderer.usedTextureUnits;f=a.paramsList;l=f.length;for(n=0;n<l;++n)if(f[n].type=="tex2d"||f[n].type=="texCube")o[0]=p++,o[1]=f[n].data[0],bindMap[f[n].type](this.ctx,f[n].loc,o);else bindMap[f[n].type](this.ctx,f[n].loc,f[n].data)};createJShaderTexture=function(a,f){var g=null,g=typeof f.data=="string"?a.canvas.renderer.getTextureByName(f.data,f.wrap,f.repeat,f.mips):a.canvas.renderer.getTextureByName(f.data.lookUpName, |
120 | f.wrap,f.repeat,f.mips);return[g]};paramType=function(a,f,g,h,l){this.loc=a.getUniformLocation(h,f);this.loc==null&&window.console.log("ctx:"+a.canvas.rdgeid+", technique: "+l+", uniform: "+f+" was not found, jshader param will have no affect");f=g[f];this.type=f.type;if(f.data==void 0)switch(f.type){case "vec4":this.data=vec4.zero();break;case "vec3":this.data=vec3.zero();break;case "vec2":this.data=vec2.zero();break;case "mat4":this.data=mat4.zero();break;case "mat3":this.data=Array(9);break;case "mat2":this.data= | 120 | f.wrap,f.repeat,f.mips);return[g]};paramType=function(a,f,g,h,l){this.loc=a.getUniformLocation(h,f);this.loc==null&&window.console.log("ctx:"+a.canvas.rdgeid+", technique: "+l+", uniform: "+f+" was not found, jshader param will have no affect");f=g[f];this.type=f.type;if(f.data==void 0)switch(f.type){case "vec4":this.data=vec4.zero();break;case "vec3":this.data=vec3.zero();break;case "vec2":this.data=vec2.zero();break;case "mat4":this.data=mat4.zero();break;case "mat3":this.data=Array(9);break;case "mat2":this.data= |
121 | [0,0,0,0];break;case "float":this.data=[0];break;case "int":this.data=[0];break;case "tex2d":this.data=[a.canvas.renderer.getTextureByName("assets/images/white.png")];break;case "texCube":this.data=[a.canvas.renderer.getTextureByName("assets/images/white.png")]}else this.data=f.type=="tex2d"||f.type=="texCube"?createJShaderTexture(a,f):f.data.slice();this.get=function(){return this.data.slice()};this.set=function(f){if(this.type=="tex2d"||this.type=="texCube")typeof f=="string"&&(f=a.canvas.renderer.getTextureByName(f)), | 121 | [0,0,0,0];break;case "float":this.data=[0];break;case "int":this.data=[0];break;case "tex2d":this.data=[a.canvas.renderer.getTextureByName(g_Engine._assetPath+"images/white.png")];break;case "texCube":this.data=[a.canvas.renderer.getTextureByName(g_Engine._assetPath+"images/white.png")]}else this.data=f.type=="tex2d"||f.type=="texCube"?createJShaderTexture(a,f):f.data.slice();this.get=function(){return this.data.slice()};this.set=function(f){if(this.type=="tex2d"||this.type=="texCube")typeof f=="string"&& |
122 | this.data[0]=f;else for(var g=this.data.length,h=0;h<g;++h)this.data[h]=f[h]}};globalParam=function(a,f,g,h){this.type=g.type;this.data=g.data;this.loc=a.getUniformLocation(h,f);if(this.data)this.data=g.type=="tex2d"||g.type=="texCube"?createJShaderTexture(a,g):g.data.slice();else switch(g.type){case "vec4":this.data=vec4.zero();break;case "vec3":this.data=vec3.zero();break;case "vec2":this.data=vec2.zero();break;case "mat4":this.data=mat4.zero();break;case "mat3":this.data=Array(9);break;case "mat2":this.data= | 122 | (f=a.canvas.renderer.getTextureByName(f)),this.data[0]=f;else for(var g=this.data.length,h=0;h<g;++h)this.data[h]=f[h]}};globalParam=function(a,f,g,h){this.type=g.type;this.data=g.data;this.loc=a.getUniformLocation(h,f);if(this.data)this.data=g.type=="tex2d"||g.type=="texCube"?createJShaderTexture(a,g):g.data.slice();else switch(g.type){case "vec4":this.data=vec4.zero();break;case "vec3":this.data=vec3.zero();break;case "vec2":this.data=vec2.zero();break;case "mat4":this.data=mat4.zero();break;case "mat3":this.data= |
123 | [0,0,0,0];break;case "float":this.data=[0];break;case "int":this.data=[0];break;case "tex2d":this.data=[a.canvas.renderer.getTextureByName("assets/images/white.png")];break;case "texCube":this.data=[a.canvas.renderer.getTextureByName("assets/images/white.png")]}this.get=function(){return this.data.slice()};this.set=function(f){if(this.type=="tex2d"||this.type=="texCube")typeof f=="string"&&(f=a.canvas.renderer.getTextureByName(f)),this.data[0]=f;else for(var g=this.data.length,h=0;h<g;++h)this.data[h]= | 123 | Array(9);break;case "mat2":this.data=[0,0,0,0];break;case "float":this.data=[0];break;case "int":this.data=[0];break;case "tex2d":this.data=[a.canvas.renderer.getTextureByName(g_Engine._assetPath+"images/white.png")];break;case "texCube":this.data=[a.canvas.renderer.getTextureByName(g_Engine._assetPath+"images/white.png")]}this.get=function(){return this.data.slice()};this.set=function(f){if(this.type=="tex2d"||this.type=="texCube")typeof f=="string"&&(f=a.canvas.renderer.getTextureByName(f)),this.data[0]= |
124 | f[h]}};this.init=function(){var a=this.def.techniques,f=null;for(t in a){var f=t,g=a[t];this[t]={passes:[]};for(var h=g.length,l=0;l<h;){var n=this.buildProgram(g[l]);this.ctx.useProgram(n);var o=this.ctx.getProgramParameter(n,this.ctx.ACTIVE_ATTRIBUTES);for(j=0;j<o;++j){var p=this.ctx.getActiveAttrib(n,j);g[l].attributes[p.name]={type:paramTypeNameMapping[p.type]}}o=this.ctx.getProgramParameter(n,this.ctx.ACTIVE_UNIFORMS);for(j=0;j<o;++j)p=this.ctx.getActiveUniform(n,j),rdgeGlobalParameters[p.name]|| | 124 | f;else for(var g=this.data.length,h=0;h<g;++h)this.data[h]=f[h]}};this.init=function(){var a=this.def.techniques,f=null;for(t in a){var f=t,g=a[t];this[t]={passes:[]};for(var h=g.length,l=0;l<h;){var n=this.buildProgram(g[l]);this.ctx.useProgram(n);var o=this.ctx.getProgramParameter(n,this.ctx.ACTIVE_ATTRIBUTES);for(j=0;j<o;++j){var p=this.ctx.getActiveAttrib(n,j);g[l].attributes[p.name]={type:paramTypeNameMapping[p.type]}}o=this.ctx.getProgramParameter(n,this.ctx.ACTIVE_UNIFORMS);for(j=0;j<o;++j)p= |
125 | (g[l].params[p.name]={type:paramTypeNameMapping[p.type]});n.ctxId=this.ctx.canvas.rdgeid;if(n)this[t].passes.push({program:n,params:{},defParams:{},states:g[l].states,attributes:g[l].attribPairs});else{this.renderer.console.log("Build errors found in technique: "+t);this.def[t]=null;break}for(var q in rdgeGlobalParameters)if(o=new globalParam(this.ctx,q,rdgeGlobalParameters[q],n),o.loc!=null)o.loc.ctxID=this.ctx.canvas.rdgeid,this[t].passes[l].defParams[q]=o,this.global[q]=o;this[t].passes[l].lightParams= | 125 | this.ctx.getActiveUniform(n,j),rdgeGlobalParameters[p.name]||(g[l].params[p.name]={type:paramTypeNameMapping[p.type]});n.ctxId=this.ctx.canvas.rdgeid;if(n)this[t].passes.push({program:n,params:{},defParams:{},states:g[l].states,attributes:g[l].attribPairs});else{this.renderer.console.log("Build errors found in technique: "+t);this.def[t]=null;break}for(var q in rdgeGlobalParameters)if(o=new globalParam(this.ctx,q,rdgeGlobalParameters[q],n),o.loc!=null)o.loc.ctxID=this.ctx.canvas.rdgeid,this[t].passes[l].defParams[q]= |
126 | [null,null,null,null];this[t].passes[l].lightContext=[null,null,null,null];if(!this[t].passes[l].paramsList)this[t].passes[l].paramsList=[];o=rdgeConstants.MAX_MATERIAL_LIGHTS;for(p=0;p<o;++p){this[t].passes[l].lightParams[p]=null;var r=0,s;for(s in g_Engine.lightManager.lightUniforms[p])loc=this.ctx.getUniformLocation(n,s),loc!=null&&(this[t].passes[l].lightParams[p]||(this[t].passes[l].lightParams[p]=[]),this[t].passes[l].lightParams[p].push({loc:loc,name:s,dataIndex:r})),r++}for(q in g[l].params)typeof g[l].params[q]!= | 126 | o,this.global[q]=o;this[t].passes[l].lightParams=[null,null,null,null];this[t].passes[l].lightContext=[null,null,null,null];if(!this[t].passes[l].paramsList)this[t].passes[l].paramsList=[];o=rdgeConstants.MAX_MATERIAL_LIGHTS;for(p=0;p<o;++p){this[t].passes[l].lightParams[p]=null;var r=0,s;for(s in g_Engine.lightManager.lightUniforms[p])loc=this.ctx.getUniformLocation(n,s),loc!=null&&(this[t].passes[l].lightParams[p]||(this[t].passes[l].lightParams[p]=[]),this[t].passes[l].lightParams[p].push({loc:loc, |
127 | "string"&&(o=new paramType(this.ctx,q,g[l].params,n,t),this[t].passes[l].params[q]=o,this[t][q]=o);for(q in g[l].params)typeof g[l].params[q]=="string"&&(this[t][q]=this[t].passes[l].params[q]);l++}}for(t in a){h=this[t].passes.length;for(l=0;l<h;++l){this[t].passes[l].defParamsList=[];for(q in this[t].passes[l].params)g=this[t].passes[l].params[q],g.name=q,this[t].passes[l].paramsList.push(g);for(q in this[t].passes[l].defParams)g=this[t].passes[l].defParams[q],g.name=q,this[t].passes[l].defParamsList.push(g)}}this.setTechnique(f)}; | 127 | name:s,dataIndex:r})),r++}for(q in g[l].params)typeof g[l].params[q]!="string"&&(o=new paramType(this.ctx,q,g[l].params,n,t),this[t].passes[l].params[q]=o,this[t][q]=o);for(q in g[l].params)typeof g[l].params[q]=="string"&&(this[t][q]=this[t].passes[l].params[q]);l++}}for(t in a){h=this[t].passes.length;for(l=0;l<h;++l){this[t].passes[l].defParamsList=[];for(q in this[t].passes[l].params)g=this[t].passes[l].params[q],g.name=q,this[t].passes[l].paramsList.push(g);for(q in this[t].passes[l].defParams)g= |
128 | this.initLocalParameter=function(a,f){var g=this.def.techniques;for(t in g)for(var h=g[t],l=h.length,n=0;n<l;){var o=new paramType(this.ctx,a,f,h[n].program,t);if(o){h[n][a]=o;if(!h[n].paramsList)h[n].paramsList=[];h[n].paramsList.push(o)}n++}};this.buildShader=function(a,f){var g="#define PC\n";g+=f;f=g;g=this.ctx.createShader(a);if(g==null)return this.renderer.console.log("*** Error: unable to create shader '"+a+"'"),null;this.ctx.shaderSource(g,f);this.ctx.compileShader(g);if(!this.ctx.getShaderParameter(g, | 128 | this[t].passes[l].defParams[q],g.name=q,this[t].passes[l].defParamsList.push(g)}}this.setTechnique(f)};this.initLocalParameter=function(a,f){var g=this.def.techniques;for(t in g)for(var h=g[t],l=h.length,n=0;n<l;){var o=new paramType(this.ctx,a,f,h[n].program,t);if(o){h[n][a]=o;if(!h[n].paramsList)h[n].paramsList=[];h[n].paramsList.push(o)}n++}};this.buildShader=function(a,f){var g="#define PC\n";g+=f;f=g;g=this.ctx.createShader(a);if(g==null)return this.renderer.console.log("*** Error: unable to create shader '"+ |
129 | this.ctx.COMPILE_STATUS)){var h=this.ctx.getShaderInfoLog(g);window.console.error("*** Error compiling shader '"+a+"':"+h);this.ctx.deleteShader(g);return null}return g};this.buildProgram=function(a){window.console.log("building shader pair: <"+a.vshader+", "+a.fshader+">");var f=this.def.shaders[a.vshader],g=this.def.shaders[a.fshader];this.ctx.useProgram(null);var h=null,l=null;f.indexOf("{")!=-1?l=f:(l=new XMLHttpRequest,l.open("GET",f,!1),l.send(null),l=l.responseText);h=this.buildShader(this.ctx.VERTEX_SHADER, | 129 | a+"'"),null;this.ctx.shaderSource(g,f);this.ctx.compileShader(g);if(!this.ctx.getShaderParameter(g,this.ctx.COMPILE_STATUS)){var h=this.ctx.getShaderInfoLog(g);window.console.error("*** Error compiling shader '"+a+"':"+h);this.ctx.deleteShader(g);return null}return g};this.buildProgram=function(a){window.console.log("building shader pair: <"+a.vshader+", "+a.fshader+">");var f=this.def.shaders[a.vshader],g=this.def.shaders[a.fshader];this.ctx.useProgram(null);var h=null,l=null;f.indexOf("{")!=-1? |
130 | l);l=null;f.indexOf("{")!=-1?l=g:(l=new XMLHttpRequest,l.open("GET",g,!1),l.send(null),l=l.responseText);l=this.buildShader(this.ctx.FRAGMENT_SHADER,l);if(!h||!l)return null;this.compiledShaders[a.vshader]=h;this.compiledShaders[a.fshader]=l;f=this.ctx.createProgram();if(!f)return null;this.ctx.attachShader(f,h);this.ctx.attachShader(f,l);g=0;a.attribPairs=[];for(var n in a.attributes)a.attribPairs.push({loc:g,name:n}),this.ctx.bindAttribLocation(f,g++,n);this.ctx.linkProgram(f);return!this.ctx.getProgramParameter(f, | 130 | l=f:(l=new XMLHttpRequest,l.open("GET",f,!1),l.send(null),l=l.responseText);h=this.buildShader(this.ctx.VERTEX_SHADER,l);l=null;f.indexOf("{")!=-1?l=g:(l=new XMLHttpRequest,l.open("GET",g,!1),l.send(null),l=l.responseText);l=this.buildShader(this.ctx.FRAGMENT_SHADER,l);if(!h||!l)return null;this.compiledShaders[a.vshader]=h;this.compiledShaders[a.fshader]=l;f=this.ctx.createProgram();if(!f)return null;this.ctx.attachShader(f,h);this.ctx.attachShader(f,l);g=0;a.attribPairs=[];for(var n in a.attributes)a.attribPairs.push({loc:g, |
131 | this.ctx.LINK_STATUS)?(a=this.ctx.getProgramInfoLog(f),window.console.log("Error in program linking:"+a),this.ctx.deleteProgram(f),this.ctx.deleteProgram(l),this.ctx.deleteProgram(h),null):f};this.setLightContext=function(a){for(t in this.technique)for(var f=this.technique.passes.length,g=0;g<f;++g)this.technique.passes[g].lightContext=a.slice()};this.setTextureContext=function(a){for(var f=this.technique.passes.length,g=null,h=0,l=a.length;h<l;++h)for(var n=0;n<f;++n)g=a[h],this.technique.passes[n].defParams[g.name]&& | 131 | name:n}),this.ctx.bindAttribLocation(f,g++,n);this.ctx.linkProgram(f);return!this.ctx.getProgramParameter(f,this.ctx.LINK_STATUS)?(a=this.ctx.getProgramInfoLog(f),window.console.log("Error in program linking:"+a),this.ctx.deleteProgram(f),this.ctx.deleteProgram(l),this.ctx.deleteProgram(h),null):f};this.setLightContext=function(a){for(t in this.technique)for(var f=this.technique.passes.length,g=0;g<f;++g)this.technique.passes[g].lightContext=a.slice()};this.setTextureContext=function(a){for(var f= |
132 | this.technique.passes[n].defParams[g.name].set(g.handle),this.technique.passes[n].params[g.name]&&this.technique.passes[n].params[g.name].set(g.data[0])};this.setTechnique=function(a){if(this[a]!=void 0)return this.technique=this[a],!0;this.ctx.console.log("Failed to set technique:"+a);return!1};this.beginRenderState=function(a){var f=this.technique.passes[a].states;if(f!=void 0){(f.depthEnable!=void 0?f.depthEnable:1)?(f.depthFunc&&this.ctx.depthFunc(this.ctx[f.depthFunc]),f.offset&&(this.ctx.enable(this.ctx.POLYGON_OFFSET_FILL), | 132 | this.technique.passes.length,g=null,h=0,l=a.length;h<l;++h)for(var n=0;n<f;++n)g=a[h],this.technique.passes[n].defParams[g.name]&&this.technique.passes[n].defParams[g.name].set(g.handle),this.technique.passes[n].params[g.name]&&this.technique.passes[n].params[g.name].set(g.data[0])};this.setTechnique=function(a){if(this[a]!=void 0)return this.technique=this[a],!0;this.ctx.console.log("Failed to set technique:"+a);return!1};this.beginRenderState=function(a){var f=this.technique.passes[a].states;if(f!= |
133 | this.ctx.polygonOffset(f.offset[0],f.offset[1])),f.depthWrite&&this.ctx.depthMask(f.depthWrite),f.depthRangeMin&&this.ctx.depthRange(f.depthRangeMin),f.depthRangeMax&&this.ctx.depthRange(f.depthRangeMax)):(this.ctx.disable(this.ctx.DEPTH_TEST),this.ctx.depthFunc(this.ctx[f.depthFunc]),this.ctx.depthMask(!0));if(f.blendEnable!=void 0&&f.blendEnable){var g=f.srcBlend!=void 0?f.srcBlend:"ONE",h=f.dstBlend!=void 0?f.dstBlend:"ZERO";this.ctx.enable(this.ctx.BLEND);this.ctx.blendFunc(this.ctx[g],this.ctx[h])}f.culling&& | 133 | void 0){(f.depthEnable!=void 0?f.depthEnable:1)?(f.depthFunc&&this.ctx.depthFunc(this.ctx[f.depthFunc]),f.offset&&(this.ctx.enable(this.ctx.POLYGON_OFFSET_FILL),this.ctx.polygonOffset(f.offset[0],f.offset[1])),f.depthWrite&&this.ctx.depthMask(f.depthWrite),f.depthRangeMin&&this.ctx.depthRange(f.depthRangeMin),f.depthRangeMax&&this.ctx.depthRange(f.depthRangeMax)):(this.ctx.disable(this.ctx.DEPTH_TEST),this.ctx.depthFunc(this.ctx[f.depthFunc]),this.ctx.depthMask(!0));if(f.blendEnable!=void 0&&f.blendEnable){var g= |
134 | (f.culling?this.ctx.enable(this.ctx.CULL_FACE):this.ctx.disable(this.ctx.CULL_FACE));f.cullFace&&this.ctx.cullFace(this.ctx[f.cullFace]);f.pointsprite&&(f.pointsprite===!0?this.renderer.enablePointSprites():this.renderer.disablePointSprites());this.resetRS=this.technique.passes[a].states.reset==void 0||this.technique.passes[a].states.reset==!0}};this.endRenderState=function(){var a=this.ctx;this.resetRS&&(a.enable(this.ctx.DEPTH_TEST),a.disable(this.ctx.BLEND),a.depthFunc(this.ctx.LESS),a.disable(this.ctx.POLYGON_OFFSET_FILL), | 134 | f.srcBlend!=void 0?f.srcBlend:"ONE",h=f.dstBlend!=void 0?f.dstBlend:"ZERO";this.ctx.enable(this.ctx.BLEND);this.ctx.blendFunc(this.ctx[g],this.ctx[h])}f.culling&&(f.culling?this.ctx.enable(this.ctx.CULL_FACE):this.ctx.disable(this.ctx.CULL_FACE));f.cullFace&&this.ctx.cullFace(this.ctx[f.cullFace]);f.pointsprite&&(f.pointsprite===!0?this.renderer.enablePointSprites():this.renderer.disablePointSprites());this.resetRS=this.technique.passes[a].states.reset==void 0||this.technique.passes[a].states.reset== |
135 | a.disable(this.ctx.CULL_FACE))};this.begin=function(){this.currentPass=null;return this.def==null||this.technique==null?0:this.technique.passes.length};this.beginPass=function(a){this.currentPass=this.technique.passes[a];this.ctx.useProgram(this.currentPass.program);this.bindParameters(this.currentPass);this.beginRenderState(a);return this.currentPass};this.endPass=function(){this.endRenderState();this.ctx.useProgram(null)};this.end=function(){};this.exportShader=function(){for(t in this.def.techniques)for(var a= | 135 | !0}};this.endRenderState=function(){var a=this.ctx;this.resetRS&&(a.enable(this.ctx.DEPTH_TEST),a.disable(this.ctx.BLEND),a.depthFunc(this.ctx.LESS),a.disable(this.ctx.POLYGON_OFFSET_FILL),a.disable(this.ctx.CULL_FACE))};this.begin=function(){this.currentPass=null;return this.def==null||this.technique==null?0:this.technique.passes.length};this.beginPass=function(a){this.currentPass=this.technique.passes[a];this.ctx.useProgram(this.currentPass.program);this.bindParameters(this.currentPass);this.beginRenderState(a); |
136 | this[t].passes.length,f=0;f<a;++f){this[t].passes[f].paramsList=[];this[t].passes[f].defParamsList=[];for(var g in this[t].passes[f].params){var h=this.def.techniques[t][f];if(h&&this[t].passes[f].params[g].type!="tex2d"&&this[t].passes[f].params[g]!="texCube")h.params[g].data=this[t].passes[f].params[g].data}}return JSON.stringify(this.def)}};jpassGeoSet={BACKGROUND:1,OPAQUE:2,TRANSPARENT:4,ADDITIVE:8,TRANSLUCENT:16,FOREGROUND:32,ALL:127,SCREEN_QUAD:128,SHADOW:256,MAXSETS:9}; | 136 | return this.currentPass};this.endPass=function(){this.endRenderState();this.ctx.useProgram(null)};this.end=function(){};this.exportShader=function(){for(t in this.def.techniques)for(var a=this[t].passes.length,f=0;f<a;++f){this[t].passes[f].paramsList=[];this[t].passes[f].defParamsList=[];for(var g in this[t].passes[f].params){var h=this.def.techniques[t][f];if(h&&this[t].passes[f].params[g].type!="tex2d"&&this[t].passes[f].params[g]!="texCube")h.params[g].data=this[t].passes[f].params[g].data}}return JSON.stringify(this.def)}};jpassGeoSet={BACKGROUND:1,OPAQUE:2,TRANSPARENT:4,ADDITIVE:8,TRANSLUCENT:16,FOREGROUND:32,ALL:127,SCREEN_QUAD:128,SHADOW:256,MAXSETS:9}; |
137 | _jpassBaseClass=function(){this.context=g_Engine.getContext();this.renderer=g_Engine.getContext().renderer;this.sortCats=rdgeConstants.categoryEnumeration;this.bucketCount=rdgeConstants.categoryEnumeration.MAX_CAT;this.renderOrder=[];this.renderOrder[this.sortCats.BACKGROUND]=0;this.renderOrder[this.sortCats.OPAQUE]=1;this.renderOrder[this.sortCats.TRANSPARENT]=2;this.renderOrder[this.sortCats.ADDITIVE]=3;this.renderOrder[this.sortCats.TRANSLUCENT]=4;this.renderOrder[this.sortCats.FOREGROUND]=5;this.name= | 137 | _jpassBaseClass=function(){this.context=g_Engine.getContext();this.renderer=g_Engine.getContext().renderer;this.sortCats=rdgeConstants.categoryEnumeration;this.bucketCount=rdgeConstants.categoryEnumeration.MAX_CAT;this.renderOrder=[];this.renderOrder[this.sortCats.BACKGROUND]=0;this.renderOrder[this.sortCats.OPAQUE]=1;this.renderOrder[this.sortCats.TRANSPARENT]=2;this.renderOrder[this.sortCats.ADDITIVE]=3;this.renderOrder[this.sortCats.TRANSLUCENT]=4;this.renderOrder[this.sortCats.FOREGROUND]=5;this.name= |
138 | "renderPass_"+nodeIdGen.getId();this.visibility=1;this.onHide=function(){};this.hidePass=function(){this.onHide();for(var a=0,b=this.children.length;a<b;++a)this.children[a].hidePass()};this.defaultTargetOut={};this.outputs=[];this.dirty=!1;this.outputIndex=0;this.inputs=[];this.textures=[];this.frustum_culling="enable";this.clearColor=this.clear=null;this.renderList=[];this.children=[];this.technique=this.shader=null;this.geometrySet="SCREEN_QUAD";this.camera=null;this.init=function(){};this.insertChildPass= | 138 | "renderPass_"+nodeIdGen.getId();this.visibility=1;this.onHide=function(){};this.hidePass=function(){this.onHide();for(var a=0,b=this.children.length;a<b;++a)this.children[a].hidePass()};this.defaultTargetOut={};this.outputs=[];this.dirty=!1;this.outputIndex=0;this.inputs=[];this.textures=[];this.frustum_culling="enable";this.clearColor=this.clear=null;this.renderList=[];this.children=[];this.technique=this.shader=null;this.geometrySet="SCREEN_QUAD";this.camera=null;this.init=function(){};this.insertChildPass= |
139 | function(a){this.children[a.name]=a};this.process=function(){var a,b,f,g,h,l,n,o=0,p=0,q=l=0,r=g_Engine.getContext().renderer;this.bindOutput();this.preRender();var s=r.cameraManager().getActiveCamera();this.technique&&this.shader.setTechnique(this.technique);r.projectionMatrix=s.proj;rdgeGlobalParameters.u_inv_viewport_width.set([1/r.vpWidth]);rdgeGlobalParameters.u_inv_viewport_height.set([1/r.vpHeight]);rdgeGlobalParameters.u_farZ.set([s.zFar()]);rdgeGlobalParameters.u_projMatrix.set(r.projectionMatrix); | 139 | function(a){this.children[a.name]=a};this.process=function(){var a,b,f,g,h,l,n,o=0,p=0,q=l=0,r=g_Engine.getContext().renderer;this.bindOutput();this.preRender();var s=r.cameraManager().getActiveCamera();this.technique&&this.shader.setTechnique(this.technique);r.projectionMatrix=s.proj;rdgeGlobalParameters.u_inv_viewport_width.set([1/r.vpWidth]);rdgeGlobalParameters.u_inv_viewport_height.set([1/r.vpHeight]);rdgeGlobalParameters.u_farZ.set([s.zFar()]);rdgeGlobalParameters.u_projMatrix.set(r.projectionMatrix); |
@@ -208,9 +208,9 @@ UNIFORMTYPE.FLOAT3);this.v2Offset=vec2.zero();this.blurQuad.renderObj.addUniform | |||
208 | fxBlur.prototype.doBlur=function(a,b,f,g){this.v4Weights[0]=f==void 0?0.25:f[0];this.v4Weights[1]=f==void 0?0.25:f[1];this.v4Weights[2]=f==void 0?0.25:f[2];this.v4Weights[3]=f==void 0?0.25:f[3];for(var f=0,h,l;(h=a)&&(l=this.fboSet2[f]);f++)gl.bindFramebuffer(gl.FRAMEBUFFER,l.frameBuffer),gl.viewport(0,0,l.frameBuffer.width,l.frameBuffer.height),gl.clear(gl.COLOR_BUFFER_BIT),gl.disable(gl.DEPTH_TEST),this.v2Offset[0]=0,this.v2Offset[1]=1.2/l.frameBuffer.width,this.blurQuad.texture=h,renderProcScreenQuad(this.blurQuad); | 208 | fxBlur.prototype.doBlur=function(a,b,f,g){this.v4Weights[0]=f==void 0?0.25:f[0];this.v4Weights[1]=f==void 0?0.25:f[1];this.v4Weights[2]=f==void 0?0.25:f[2];this.v4Weights[3]=f==void 0?0.25:f[3];for(var f=0,h,l;(h=a)&&(l=this.fboSet2[f]);f++)gl.bindFramebuffer(gl.FRAMEBUFFER,l.frameBuffer),gl.viewport(0,0,l.frameBuffer.width,l.frameBuffer.height),gl.clear(gl.COLOR_BUFFER_BIT),gl.disable(gl.DEPTH_TEST),this.v2Offset[0]=0,this.v2Offset[1]=1.2/l.frameBuffer.width,this.blurQuad.texture=h,renderProcScreenQuad(this.blurQuad); |
209 | for(f=0;(h=this.fboSet2[f])&&(l=this.fboSet1[f]);f++)gl.bindFramebuffer(gl.FRAMEBUFFER,l.frameBuffer),gl.viewport(0,0,l.frameBuffer.width,l.frameBuffer.height),gl.clear(gl.COLOR_BUFFER_BIT),gl.disable(gl.DEPTH_TEST),this.v2Offset[0]=1.2/l.frameBuffer.width,this.v2Offset[1]=0,this.blurQuad.texture=h,renderProcScreenQuad(this.blurQuad);gl.bindFramebuffer(gl.FRAMEBUFFER,b?b.frameBuffer:null);gl.viewport(0,0,g_width,g_height);gl.clear(gl.COLOR_BUFFER_BIT);gl.disable(gl.DEPTH_TEST);gl.useProgram(this.combineQuad.shader); | 209 | for(f=0;(h=this.fboSet2[f])&&(l=this.fboSet1[f]);f++)gl.bindFramebuffer(gl.FRAMEBUFFER,l.frameBuffer),gl.viewport(0,0,l.frameBuffer.width,l.frameBuffer.height),gl.clear(gl.COLOR_BUFFER_BIT),gl.disable(gl.DEPTH_TEST),this.v2Offset[0]=1.2/l.frameBuffer.width,this.v2Offset[1]=0,this.blurQuad.texture=h,renderProcScreenQuad(this.blurQuad);gl.bindFramebuffer(gl.FRAMEBUFFER,b?b.frameBuffer:null);gl.viewport(0,0,g_width,g_height);gl.clear(gl.COLOR_BUFFER_BIT);gl.disable(gl.DEPTH_TEST);gl.useProgram(this.combineQuad.shader); |
210 | this.combineQuad.renderObj.bindBuffers();this.combineQuad.renderObj.bindTextures();this.combineQuad.renderObj.bindUniforms();gl.activeTexture(gl.TEXTURE0);gl.bindTexture(gl.TEXTURE_2D,a);gl.activeTexture(gl.TEXTURE1);gl.bindTexture(gl.TEXTURE_2D,this.fboSet1[0]);gl.activeTexture(gl.TEXTURE2);gl.bindTexture(gl.TEXTURE_2D,this.fboSet1[1]);gl.activeTexture(gl.TEXTURE3);gl.bindTexture(gl.TEXTURE_2D,this.fboSet1[2]);gl.activeTexture(gl.TEXTURE4);gl.bindTexture(gl.TEXTURE_2D,g);gl.activeTexture(gl.TEXTURE0); | 210 | this.combineQuad.renderObj.bindBuffers();this.combineQuad.renderObj.bindTextures();this.combineQuad.renderObj.bindUniforms();gl.activeTexture(gl.TEXTURE0);gl.bindTexture(gl.TEXTURE_2D,a);gl.activeTexture(gl.TEXTURE1);gl.bindTexture(gl.TEXTURE_2D,this.fboSet1[0]);gl.activeTexture(gl.TEXTURE2);gl.bindTexture(gl.TEXTURE_2D,this.fboSet1[1]);gl.activeTexture(gl.TEXTURE3);gl.bindTexture(gl.TEXTURE_2D,this.fboSet1[2]);gl.activeTexture(gl.TEXTURE4);gl.bindTexture(gl.TEXTURE_2D,g);gl.activeTexture(gl.TEXTURE0); |
211 | gl.drawArrays(gl.TRIANGLES,0,6);gl.enable(gl.DEPTH_TEST);gl.useProgram(null);return b};function fxSSAO(a){this.randTexture=createTexture(gl,"assets/images/random_normal.png");gl.bindTexture(gl.TEXTURE_2D,this.randTexture);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MIN_FILTER,gl.LINEAR);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_S,gl.REPEAT);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_T,gl.REPEAT);this.enHRDepth=a;this.ssaoQuad=new ScreenQuad(null);this.ssaoQuad.initialize(function(b){b.shader=createShader(gl,"ssao_vshader",a?"ssaohr_fshader":"ssao_fshader",["vert","texcoord"]); | 211 | gl.drawArrays(gl.TRIANGLES,0,6);gl.enable(gl.DEPTH_TEST);gl.useProgram(null);return b};function fxSSAO(a){this.randTexture=createTexture(gl,g_Engine._assetPath+"images/random_normal.png");gl.bindTexture(gl.TEXTURE_2D,this.randTexture);gl.texParamet |