Graphics Reference
In-Depth Information
spot direction . The spot cutoff factor is 1.0 in the spotlight direction given by
spot direction and falls off exponentially to 0.0 at spot cutoff angle radians away.
Example 8-3 describes the vertex shader code that computes the lighting
equation for a spot (and point) light. The spotlight properties are
described by a spot_light struct that contains the following elements:
direction —The light direction in eye space.
ambient_color —The ambient color of the light.
diffuse_color —The diffuse color of the light.
specular_color —The specular color of the light.
attenuation_factors —The distance attenuation factors K 0 , K 1 , and K 2 .
compute_distance_attenuation —A boolean term that determines
whether the distance attenuation must be computed.
spot_direction —The normalized spot direction vector.
spot_exponent —The spotlight exponent used to compute the spot
cutoff factor.
spot_cutoff_angle —The spotlight cutoff angle in degrees.
Example 8-3
Spotlight
#version 300 es
struct spot_light
{
vec4 position; // light position in eye space
vec4 ambient_color;
vec4 diffuse_color;
vec4 specular_color;
vec3 spot_direction; // normalized spot direction
vec3 attenuation_factors; // attenuation factors K 0 , K 1 , K 2
bool compute_distance_attenuation;
float spot_exponent; // spotlight exponent term
float spot_cutoff_angle; // spot cutoff angle in degrees
};
struct material_properties
{
vec4 ambient_color;
vec4 diffuse_color;
(continues)
 
Search WWH ::




Custom Search