I want to be able to support multiple lights of different types (point, spot & directional). Note that I also want to be able to render transparent/translucent objects, which rules out deferred rendering.
This means that I will need a fixed upper limit on the number of lights. All of the implementations I have seen use a uniform array, for example:
struct PointLight
{
vec3 color;
float intensity;
float radius;
};
uniform PointLight pointLights[8];
How can I best extend this to multiple types of lights? Two possible options are:
- Create multiple uniform arrays, one for each type of light.
- Define a struct that can be used for all three types of light and then have some way of differentiating the types of lights in the array (e.g. using start index and count uniforms or adding some kind of type flag to the struct).
Both have disadvantages. Both waste memory (although the first more so than the second) and the second either requires additional uniforms or flag checking.
What is the usual method for handling multiple lights of various types?