Graphics Reference
In-Depth Information
Figure 16.24. The disco light effect.
the lights—the only animated part of the scene—so that they swirl around the
space.
It might look like there are multiple light sources, but there really is just
one. A real disco ball appears to be multiple light sources because of the flat
mirrored facets on the ball itself. The fragment shader below looks at the angle
between the fragment, the disco ball, and the single light source. It then quan-
tizes that angle to see how close one of the simulated mirrored facets comes
to reflecting the light source to that fragment. It then uses that light intensity,
combined with a raise-to-a-power dropoff, to illuminate the fragment.
uniform int uNum; // # of mirrors in each spherical direction
uniform float Timer; // built-in glman timer function
in vec3 vECpos;
in vec4 vColor;
in float vLightIntensity;
out vec4 fFragColor;
const float DMIN = 0.980; // minimum cosine for no light
const vec3 BALLPOS = vec3( 0., 2., 0. );
const vec3 LIGHTPOS = vec3( 2., 0., 0. );
const vec3 LIGHTCOLOR = vec3( 1., 1., 1. );
const float PI = 3.14159265;
void main( )
{
int numTheta = uNum;
int numPhi = uNum;
float dtheta = 2. * PI / float(numTheta);
float dphi = PI / float(numPhi);
Search WWH ::




Custom Search