In my current WebGL project optimization, I am working with a frag shader attached to a quad that covers the canvas. The shader involves a costly loop that casts rays through each pixel until they hit some terrain. To improve efficiency, instead of calculating ray direction individually for each pixel, I attempted to calculate the direction for each corner of the screen and pass them as uniforms. However, testing this concept in the shader code without using uniforms actually slowed down the process rather than speeding it up.
Upon attempting to load the web page with the uniform implementation, Firefox flagged a type error citing an undefined variable 'b' in line 12914 of three.js.
Investigating further, I found the following snippet at line 12914:
h = function(a, b) {
void 0 !== b.x ? a.uniform3f(this.addr, b.x, b.y, b.z) : void 0 !== b.r ? a.uniform3f(this.addr, b.r, b.g, b.b) : a.uniform3fv(this.addr, b)
},
within the context of Three.WebGLUniforms
.
Therefore, my query is aimed towards understanding the purpose of this function and its second argument.
UPDATE:
An important detail omitted earlier is that leaving Firefox open for a few seconds results in a crash.