Pro OpenGL ES for iOS

(singke) #1

CHAPTER 7: Well-Rendered Miscellany (^237)
Figure 7-12. Z-fighting between the platform and the shadow
Now we get to the real fun stuff, actually calculating and drawing the shadow. Listing
7-15 shows how the matrix is generated, while Listing 7-16 draws the squashed
shadow.
Listing 7-15. Calculating the shadow matrix
-(void)calculateShadowMatrix
{
GLfloat shadowMat_local[16] =
{
iLightPosY, 0.0, 0.0, 0.0,
-iLightPosX, 0.0, -iLightPosZ, -1.0,
0.0, 0.0, iLightPosY, 0.0,
0.0, 0.0, 0.0, iLightPosY
};

Free download pdf