Spot light
Spot light volume is represented by a cone with a rounded base. We can use same technique used for generating the capsule light half capsule volume and shape the result as the spot lights cone. As this requires only half of the capsule, we will only need to draw a single vertex.
Getting ready
As with the point and capsule lights, we will need all the GBuffer related values along with the pixel shader constants we used for the light properties in the forward spot light recipe.
Unlike the capsule light volume, the spot light volume can be scaled by a matrix, so we won't need to pass any scaling parameters to the Domain shader. The following illustration shows how the pretransform cone will look like:
We can use the following formula to calculate the matrix X and Y scale value:
Where α is the cone's outer angle LightRange is the spot light's range. For the Z component we just use the light range value.
The light cone tip will be at coordinate origin, so the rotation and translation parts...