Planar Shadow § In a 3D space, the line passing through the point L and point V is P = L + K *(V - L) L = [Lx, Ly, Lz] V = [Vx, Vy, Vz] P = [Px, Py, Pz] N = [Nx, Ny, Nz] L = [0.0, 10.0, 5.0] P = [20.0, 0.0, -1.0] V = [10.0, 5.0, 2.0] K=1 K=2
Planar Shadow § Having the plain’s normal N and any dot in the plain P, dotProduct (N, P) + d = 0 // they are perpendicular L = [Lx, Ly, Lz] V = [Vx, Vy, Vz] P = [Px, Py, Pz] N = [0.0, 1.0, 0.0] P = [20.0, 0.0, -1.0]
Planar Shadow § Having the plain’s normal N and any dot in the plain P, dotProduct (N, P) + d = 0 // they are perpendicular n • a – 32.5 = 0 n • c – 32.5 = 0 n • b – 32.5 = 0 y = - x + 5 N = [6.5,6.5,z] b = [5,0,z] a=[0,5,z] c = [2.5,2.5,z]
Planar Shadow § Line passing through L and V: P = L + K * (V - L) § Equation for a plane: N • P + d = 0 § K can be solved as: K = - (d + N • L) / (N •(V-L) § Then P = L + ((d + N • L) / (N •(V - L))(V - L) § And, simplifying,
Test Yourselves § Change renderShadow from 1 to 0 § Change lightHeight from 100 to 1000 and 10 § Change light type from directional (0) to positional light § Verify: § glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); § glStencilOp(GL_ZERO, GL_ZERO, GL_ZERO); § Make the light rotate like a Sun (around z or x axis) § Put together shadows and reflection. § Replace a box with an OBJ object.