Using Uniform Arrays to Handle Multiple Lights

As we've seen, handling light properties with individual uniforms makes the code verbose and difficult to maintain. Fortunately, ESSL provides several mechanisms we can use to solve the problem of handling multiple lights. One of them is uniform arrays.

This technique allows us to handle multiple lights by introducing enumerable arrays of vectors in the shaders. This allows us to calculate light contributions by iterating through the light arrays in the shaders. We still need to define each light in JavaScript, but the mapping to ESSL becomes simpler since we aren’t defining one uniform per light property. Let's see how this technique works. We just need to make two simple changes in our code.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.58.39.23