|
2964 | 2964 | inline vec3 reflect(const vec3& v, const vec3& n) {
|
2965 | 2965 | return v - 2*dot(v,n)*n;
|
2966 | 2966 | }
|
2967 |
| - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ |
2968 |
| - |
2969 |
| - ... |
2970 | 2967 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
2971 | 2968 | [Listing [vec3-reflect]: <kbd>[vec3.h]</kbd> vec3 reflection function]
|
2972 | 2969 |
|
|
3180 | 3177 |
|
3181 | 3178 | The amount that a refracted ray bends is determined by the material's _refractive index_. Generally,
|
3182 | 3179 | this is a single value that describes how much light bends when entering a material from a vacuum.
|
3183 |
| -Glass has a refractive index of something like 1.5–1.7, and air has a small refractive index |
3184 |
| -of 1.000293. |
| 3180 | +Glass has a refractive index of something like 1.5–1.7, diamond is around 2.4, and air has a |
| 3181 | +small refractive index of 1.000293. |
3185 | 3182 |
|
3186 | 3183 | When a transparent material is embedded in a different transparent material, you can describe the
|
3187 | 3184 | refraction with a relative refraction index: the refractive index of the object's material divided
|
|
3213 | 3210 | $$ \eta \cdot \sin\theta = \eta' \cdot \sin\theta' $$
|
3214 | 3211 |
|
3215 | 3212 | Where $\theta$ and $\theta'$ are the angles from the normal, and $\eta$ and $\eta'$ (pronounced
|
3216 |
| -"eta" and "eta prime") are the refractive indices (typically air = 1.0, glass = 1.3–1.7, diamond = |
3217 |
| -2.4). The geometry is: |
| 3213 | +"eta" and "eta prime") are the refractive indices. The geometry is: |
3218 | 3214 |
|
3219 | 3215 | ![Figure [refraction]: Ray refraction](../images/fig-1.17-refraction.jpg)
|
3220 | 3216 |
|
|
3971 | 3967 | `random_in_unit_sphere()`, just for two dimensions.
|
3972 | 3968 |
|
3973 | 3969 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
|
| 3970 | + ... |
| 3971 | + |
3974 | 3972 | inline vec3 unit_vector(const vec3& u) {
|
3975 | 3973 | return v / v.length();
|
3976 | 3974 | }
|
|
3984 | 3982 | return p;
|
3985 | 3983 | }
|
3986 | 3984 | }
|
| 3985 | + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ |
| 3986 | + |
| 3987 | + ... |
3987 | 3988 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
3988 | 3989 | [Listing [rand-in-unit-disk]: <kbd>[vec3.h]</kbd> Generate random point inside unit disk]
|
3989 | 3990 |
|
|
0 commit comments