Mandrill
Mirror, Mirror
Texture mapping, reflecting, refracting
A texture is an image, in this case an image of a mandrill, and it is mapped to point coordinates in WebGL.
Reflection of the texture onto the sphere requires an environment map, which maps texture coordinates to a world coordinate after multiplying scaling, rotation, and translation matrices and then checks if the ray from the sphere hits the texture or not.
Refraction takes advantage of Snell's law to make a diamond where the velocity of light is 2.4 times slower than in air.
- Perspective: perspective mode. Things far away appear smaller.
- RightBack: hang the image on the right to see reflection from the sphere.
- FlatSmooth:
- click once -> flat surface mode of the sphere.
- click twice -> smooth surface mode of the sphere using Phong shading (this is the mode you want to see the diamond or the mirror).
- RefractReflect: toggles between reflection (mirror) and refraction (diamond)
- To see a mirroring sphere, click Perspective once -> RightBack once -> FlatSmooth twice.
- To see a diamond showing the hidden sierpinski tattoo on the mandrill, click FlatSmooth twice -> RefractReflect once.
- In refraction mode, you can also see that when you are really far away from the diamond everything appears upside down. You know this is true when you hold a magnifying glass far away from you. You can see this happening by putting the sphere in perspective mode (far away from you), click vz + 0.1 more than 25 times, then click z + 0.1 more than 15 times, and suddenly everything turned upside down.
- Enjoy!