Game Development Reference
In-Depth Information
else{
for(var i=0;i<this.lights.length;++i){
if(this.lights[i][lightType].length>0){
sum= sum.concat(this.lights[i][type])
}
}
}
return sum;
}
}
Understanding the main code
We have added code in the initShaders function to get reference to the six uniform
arrays. We have used this function in our shaders as follows:
function initShaders(){
shaderProgram.uAmbientColor = gl.getUniformLocation
(shaderProgram, "uAmbientColor");
shaderProgram.uLightDirection = gl.getUniformLocation
(shaderProgram, "uLightDirection");
shaderProgram.uPositionalDiffuseColor = gl.getUniformLocation
(shaderProgram, "uPositionalDiffuseColor");
shaderProgram.uPositionalSpecularColor = gl.getUniformLocation
(shaderProgram, "uPositionalSpecularColor");
shaderProgram.uDirectionalDiffuseColor = gl.getUniformLocation
(shaderProgram, "uDirectionalDiffuseColor");
shaderProgram.uDirectionalSpecularColor = gl.getUniformLocation
(shaderProgram, "uDirectionalSpecularColor");
shaderProgram.uLightPosition = gl.getUniformLocation
(shaderProgram, "uLightPosition");
............
}
 
Search WWH ::




Custom Search