diff options
Diffstat (limited to 'js/helper-classes/RDGE/src/core/script/jshader.js')
-rwxr-xr-x | js/helper-classes/RDGE/src/core/script/jshader.js | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/js/helper-classes/RDGE/src/core/script/jshader.js b/js/helper-classes/RDGE/src/core/script/jshader.js index b9170857..f8d79580 100755 --- a/js/helper-classes/RDGE/src/core/script/jshader.js +++ b/js/helper-classes/RDGE/src/core/script/jshader.js | |||
@@ -31,46 +31,46 @@ POSSIBILITY OF SUCH DAMAGE. | |||
31 | // RDGE namespaces | 31 | // RDGE namespaces |
32 | var RDGE = RDGE || {}; | 32 | var RDGE = RDGE || {}; |
33 | 33 | ||
34 | /* | 34 | /* |
35 | this API should be familiar to anyone who has worked with HLSL effect files. | 35 | this API should be familiar to anyone who has worked with HLSL effect files. |
36 | */ | 36 | */ |
37 | 37 | ||
38 | /* | 38 | /* |
39 | * A map of types to uniform 'binding' functions | 39 | * A map of types to uniform 'binding' functions |
40 | */ | 40 | */ |
41 | RDGE.bindMap={}; | 41 | RDGE.bindMap={}; |
42 | RDGE.bindMap['int'] = function(ctx, a,b) { ctx.uniform1iv(a,b); }; | 42 | RDGE.bindMap['int'] = function(ctx, a,b) { ctx.uniform1iv(a,b); }; |
43 | RDGE.bindMap['float'] = function(ctx, a,b) { ctx.uniform1fv(a,b); }; | 43 | RDGE.bindMap['float'] = function(ctx, a,b) { ctx.uniform1fv(a,b); }; |
44 | RDGE.bindMap['vec2'] = function(ctx, a,b) { ctx.uniform2fv(a,b); }; | 44 | RDGE.bindMap['vec2'] = function(ctx, a,b) { ctx.uniform2fv(a,b); }; |
45 | RDGE.bindMap['vec3'] = function(ctx, a,b) { ctx.uniform3fv(a,b); }; | 45 | RDGE.bindMap['vec3'] = function(ctx, a,b) { ctx.uniform3fv(a,b); }; |
46 | RDGE.bindMap['vec4'] = function(ctx, a,b) { ctx.uniform4fv(a,b); }; | 46 | RDGE.bindMap['vec4'] = function(ctx, a,b) { ctx.uniform4fv(a,b); }; |
47 | RDGE.bindMap['mat3'] = function(ctx, a,b) { ctx.uniformMatrix3fv(a,false,b); }; | 47 | RDGE.bindMap['mat3'] = function(ctx, a,b) { ctx.uniformMatrix3fv(a,false,b); }; |
48 | RDGE.bindMap['mat4'] = function(ctx, a,b) | 48 | RDGE.bindMap['mat4'] = function(ctx, a,b) |
49 | { | 49 | { |
50 | ctx.uniformMatrix4fv(a,false,b); | 50 | ctx.uniformMatrix4fv(a,false,b); |
51 | RDGE.globals.engine.getContext().debug.mat4CallCount++; | 51 | RDGE.globals.engine.getContext().debug.mat4CallCount++; |
52 | }; | 52 | }; |
53 | 53 | ||
54 | RDGE.bindMap['tex2d'] = function(ctx, a,b) | 54 | RDGE.bindMap['tex2d'] = function(ctx, a,b) |
55 | { | 55 | { |
56 | ctx.activeTexture(ctx.TEXTURE0+b[0]); | 56 | ctx.activeTexture(ctx.TEXTURE0+b[0]); |
57 | ctx.bindTexture(ctx.TEXTURE_2D, b[1]); | 57 | ctx.bindTexture(ctx.TEXTURE_2D, b[1]); |
58 | ctx.uniform1iv(a,[b[0]]); | 58 | ctx.uniform1iv(a,[b[0]]); |
59 | }; | 59 | }; |
60 | 60 | ||
61 | RDGE.bindMap['texCube']=function(ctx, a,b) | 61 | RDGE.bindMap['texCube']=function(ctx, a,b) |
62 | { | 62 | { |
63 | ctx.activeTexture(ctx.TEXTURE0+b[0]); | 63 | ctx.activeTexture(ctx.TEXTURE0+b[0]); |
64 | ctx.bindTexture(ctx.TEXTURE_CUBE_MAP, b[1]); | 64 | ctx.bindTexture(ctx.TEXTURE_CUBE_MAP, b[1]); |
65 | ctx.uniform1iv(a,[b[0]]); | 65 | ctx.uniform1iv(a,[b[0]]); |
66 | }; | 66 | }; |
67 | 67 | ||
68 | RDGE.lightDataMap = | 68 | RDGE.lightDataMap = |
69 | [ | 69 | [ |
70 | function(ctx, loc, lightNode) { ctx.uniform3fv(loc, lightNode.position); }, | 70 | function(ctx, loc, lightNode) { ctx.uniform3fv(loc, lightNode.position); }, |
71 | function(ctx, loc, lightNode) { ctx.uniform4fv(loc, lightNode.lightDiffuse); }, | 71 | function(ctx, loc, lightNode) { ctx.uniform4fv(loc, lightNode.lightDiffuse); }, |
72 | function(ctx, loc, lightNode) { ctx.uniform4fv(loc, lightNode.lightAmbient); }, | 72 | function(ctx, loc, lightNode) { ctx.uniform4fv(loc, lightNode.lightAmbient); }, |
73 | function(ctx, loc, lightNode) { ctx.uniform4fv(loc, lightNode.lightSpecular); } | 73 | function(ctx, loc, lightNode) { ctx.uniform4fv(loc, lightNode.lightSpecular); } |
74 | ]; | 74 | ]; |
75 | 75 | ||
76 | RDGE.paramTypeNameMapping = null; | 76 | RDGE.paramTypeNameMapping = null; |
@@ -120,7 +120,7 @@ RDGE.jshader = function (addr) { | |||
120 | } | 120 | } |
121 | 121 | ||
122 | /* | 122 | /* |
123 | * private helper functions | 123 | * private helper functions |
124 | */ | 124 | */ |
125 | this.bindParameters = function (pass) { | 125 | this.bindParameters = function (pass) { |
126 | var params = pass.defParamsList; // global parameters to start with | 126 | var params = pass.defParamsList; // global parameters to start with |
@@ -177,7 +177,7 @@ RDGE.jshader = function (addr) { | |||
177 | }; | 177 | }; |
178 | 178 | ||
179 | /* | 179 | /* |
180 | * helper function for setting up a texture | 180 | * helper function for setting up a texture |
181 | */ | 181 | */ |
182 | createJShaderTexture = function (ctx, param) { | 182 | createJShaderTexture = function (ctx, param) { |
183 | var texHandle = null; | 183 | var texHandle = null; |
@@ -310,9 +310,9 @@ RDGE.jshader = function (addr) { | |||
310 | defaultTech = t; | 310 | defaultTech = t; |
311 | var curTechnique = techniques[t]; | 311 | var curTechnique = techniques[t]; |
312 | this[t] = | 312 | this[t] = |
313 | { | 313 | { |
314 | 'passes': [] | 314 | 'passes': [] |
315 | }; | 315 | }; |
316 | var numPasses = curTechnique.length; | 316 | var numPasses = curTechnique.length; |
317 | var i = 0; | 317 | var i = 0; |
318 | while (i < numPasses) { | 318 | while (i < numPasses) { |
@@ -445,7 +445,7 @@ RDGE.jshader = function (addr) { | |||
445 | }; | 445 | }; |
446 | 446 | ||
447 | /* | 447 | /* |
448 | * Init a local parameter at any time during the life of the jshader. | 448 | * Init a local parameter at any time during the life of the jshader. |
449 | * This will add the parameter to the list of parameters to be bound | 449 | * This will add the parameter to the list of parameters to be bound |
450 | * before rendering | 450 | * before rendering |
451 | */ | 451 | */ |
@@ -587,7 +587,7 @@ RDGE.jshader = function (addr) { | |||
587 | }; | 587 | }; |
588 | 588 | ||
589 | /* | 589 | /* |
590 | * Set the light nodes used by this jshader | 590 | * Set the light nodes used by this jshader |
591 | * array item 0 corresponds to light 0, item 1 tp light 1 and so on | 591 | * array item 0 corresponds to light 0, item 1 tp light 1 and so on |
592 | * place null for lights that are not there | 592 | * place null for lights that are not there |
593 | */ | 593 | */ |
@@ -601,7 +601,7 @@ RDGE.jshader = function (addr) { | |||
601 | }; | 601 | }; |
602 | 602 | ||
603 | /* | 603 | /* |
604 | * Called by the system to add material textures settings to the jshader | 604 | * Called by the system to add material textures settings to the jshader |
605 | */ | 605 | */ |
606 | this.setTextureContext = function (textureList) { | 606 | this.setTextureContext = function (textureList) { |
607 | var passCount = this.technique.passes.length; | 607 | var passCount = this.technique.passes.length; |