Note 1: First is the experience of the mirror example.
The overall process is:
1. Draw a normal object; Clear the stencil of each pixel 2. Set the stencil value of the specular area as the reference value 1 3. Determines whether the stencil value of each pixel is 1 after render, and the teapot entity is drawn if the condition is met
It is important to note that:
1. Draw the stencil area is 1 o'clock, our aim is only to change the pixel stencil, the other values do not change, so: first prohibit the ZBuffer write, followed by the drawing set is not visible, that is, the use of mixing, set the source Alpha zero.
2. When drawing the mirror teapot, because the z-value of the mirror under Carmen observation is less than mirror, the occlusion of depth z is avoided and the zbuffer is emptied. Second, let the Mirror look and mirror together.
3. Modification of the reverse blanking mode. The default CWW mode, which is drawn clockwise, but the teapot within the mirror is exactly the part of the back blanking, so change the cull mode to CW.
Mathematical aspect: Find point V for planar np+d=0 symmetrical Mirror point coordinates.
The use of Dragon Book 9 Chapter8 Stencil