Skip to content
This repository was archived by the owner on Jan 19, 2025. It is now read-only.

Commit 12b6573

Browse files
committed
updated mathjax 🚀
1 parent b665d0c commit 12b6573

6 files changed

+522
-504
lines changed

_includes/dependencies-js-blog.html

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,30 @@
11
{% if page.math %}
2-
<script type="text/x-mathjax-config">
3-
MathJax.Hub.Config({
4-
jax: ["input/TeX","output/SVG"],
5-
messageStyle: "none",
6-
tex2jax: {
7-
inlineMath: [['$','$']],
8-
processEscapes: true
9-
},
10-
"HTML-CSS": {
11-
linebreaks: { automatic: true }
12-
},
13-
SVG: {
14-
linebreaks: { automatic: true }
15-
}
16-
});
2+
<script>
3+
window.MathJax = {
4+
tex: {
5+
inlineMath: [['$','$']],
6+
displayMath: [['£$', '£$']],
7+
processEscapes: true,
8+
autoload: {
9+
color: [],
10+
colorV2: ['color']
11+
},
12+
packages: {'[+]': ['noerrors']}
13+
},
14+
svg: {
15+
fontCache: 'global'
16+
},
17+
options: {
18+
ignoreHtmlClass: 'tex2jax_ignore',
19+
processHtmlClass: 'tex2jax_process'
20+
},
21+
loader: {
22+
load: ['[tex]/noerrors']
23+
}
24+
};
1725
</script>
18-
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS_SVG"></script>
26+
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
27+
<script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js" id="MathJax-script"></script>
1928
{% endif %}
2029
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/cookieconsent@3/build/cookieconsent.min.js" data-cfasync="false"></script>
2130
<script type="text/javascript" src="/assets/js/index.blog.min.js?rev=9a2b035a05763800c451c5b6834f504b"></script>

_posts/2017-07-26-phong-lighting-model.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ This is the light component emitted by the surface material. Is a purely additiv
4545
speaking you can use the scene light RGB color. The emissive constant $k_{\text{e}}$ is a surface property that express its emissive
4646
reflectance.
4747

48-
$$I_{\text{emissive}}=k_{\text{e}}I_{\text{LE}}$$
48+
£$I_{\text{emissive}}=k_{\text{e}}I_{\text{LE}}£$
4949

5050
#### **Ambient component**
5151

@@ -57,7 +57,7 @@ constant related exclusively to the surface material that express empirically it
5757
As for the emissive component, the ambient light intensity could be the intensity of the scene light (or an average if
5858
you have multiple scene lights).
5959

60-
$$I_{\text{ambient}}=k_{\text{a}}I_{\text{LA}}$$
60+
£$I_{\text{ambient}}=k_{\text{a}}I_{\text{LA}}£$
6161

6262
#### **Diffusive component**
6363

@@ -69,19 +69,19 @@ and with the attenuation factor due to incident light given by the cosine of the
6969
normal $\cos\theta$. This last value is the dot product between the surface normal ${\hat {N}}$ and the light direction ${\hat {L}}$.
7070
So the final formula for the diffuse component is:
7171

72-
$$I_{\text{diffuse}}=k_{\text{d}}I_{\text{LD}}({\hat {L}}\cdot{\hat {N}})$$
72+
£$I_{\text{diffuse}}=k_{\text{d}}I_{\text{LD}}({\hat {L}}\cdot{\hat {N}})£$
7373

7474
#### **Specular component**
7575

76-
This light component represents the amount of reflected light in a specific direction (mirror alike reflection). Light is reflected in a different way depending on the incident light direction. Shiny materials are the one with a high specular component. The perceived specular light depends on the position of the observer with respect to the surface. In particular, the specular illumination is influenced by $\cos\alpha$, that is the cosine of the angle between the direction from the surface point towards the view ${\hat {V}}$ and the direction that a perfectly reflected ray of light would take from this point on the surface ${\hat {R}}$. The size of the specular highlights is regulated by a shininess constant $$n$$, based on the surface material properties. Given all this information the specular component formula obtained by multiplying the specular surface constant $k_{\text{s}}$ with the light specular intensity $I_{\text{LS}}$ and with dot product of the reflection direction ${\hat {R}}$ and the the direction from the surface point towards the view ${\hat {V}}$ squared to the shininess constant $$n$$:
76+
This light component represents the amount of reflected light in a specific direction (mirror alike reflection). Light is reflected in a different way depending on the incident light direction. Shiny materials are the one with a high specular component. The perceived specular light depends on the position of the observer with respect to the surface. In particular, the specular illumination is influenced by $\cos\alpha$, that is the cosine of the angle between the direction from the surface point towards the view ${\hat {V}}$ and the direction that a perfectly reflected ray of light would take from this point on the surface ${\hat {R}}$. The size of the specular highlights is regulated by a shininess constant £$n£$, based on the surface material properties. Given all this information the specular component formula obtained by multiplying the specular surface constant $k_{\text{s}}$ with the light specular intensity $I_{\text{LS}}$ and with dot product of the reflection direction ${\hat {R}}$ and the the direction from the surface point towards the view ${\hat {V}}$ squared to the shininess constant £$n£$:
7777

78-
$$I_{\text{specular}}=k_{\text{s}}I_{\text{LS}}({\hat {R}}\cdot {\hat {V}})^{n}$$
78+
£$I_{\text{specular}}=k_{\text{s}}I_{\text{LS}}({\hat {R}}\cdot {\hat {V}})^{n}£$
7979

8080
The above observation are valid also in case we have multiple lights. The only difference is that the diffuse and specular
8181
component are calculated for each light and their sum is the final diffuse and specular component.
8282
Now we are ready to write the complete Phong reflection lighting equation:
8383

84-
$$I_{\text{tot}}=k_{\text{e}}I_{\text{LE}}+k_{\text{a}}I_{\text{LA}}+\sum _{p\;\in \;{\text{lights}}}(k_{\text{d}}I_{p,{\text{LD}}} ({\hat {L}}_{p}\cdot {\hat {N}})+k_{\text{s}}I_{p,{\text{LS}}}({\hat {R}}_{p}\cdot {\hat {V}})^{n})$$
84+
£$I_{\text{tot}}=k_{\text{e}}I_{\text{LE}}+k_{\text{a}}I_{\text{LA}}+\sum _{p\;\in \;{\text{lights}}}(k_{\text{d}}I_{p,{\text{LD}}} ({\hat {L}}_{p}\cdot {\hat {N}})+k_{\text{s}}I_{p,{\text{LS}}}({\hat {R}}_{p}\cdot {\hat {V}})^{n})£$
8585

8686
Just a final note: we distinguished different type of light intensity based on the component. In fact most of the time this model is implemented using a single general light intensity triplet for all the component for each light.
8787
How can you implement it in a OpenGL ES shader? The following code sample is a simple implementation of this model using RGB colors.

_posts/2017-08-25-how-to-calculate-reflection-vector.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ vec3 reflectionDirection = reflect(-lightDirection, normalInterp);
2525
Easy, isn't it? But the most curios of you may asking: "How the f*$k this method calculate this reflection direction?" :stuck_out_tongue_closed_eyes:
2626
We will suppose as in the previous post about the phong model that all vectors are normalized. Let's start from the beginning. The formula to calculate the reflection direction is:
2727

28-
$$R = 2({\hat{N}}\cdot{\hat{L}}){\hat{N}} - {\hat{L}}$$
28+
£$R = 2({\hat{N}}\cdot{\hat{L}}){\hat{N}} - {\hat{L}}£$
2929

3030
How is this formula obtained? Let's start from a picture that represents our reflection vector and the other vectors
3131
used in the calculation.
@@ -42,40 +42,40 @@ normal.
4242
Now we are ready for our demonstration :sunglasses:.
4343
From the law of refraction reported above we know that:
4444

45-
$$\Theta_R=\Theta_L$$
45+
£$\Theta_R=\Theta_L£$
4646

4747
This equation could be rewritten as the dot product of the reflection direction with the normal equals the dot product of the incident light direction and the normal (remember that the [dot product of two vector is equal to the cosine of the angle between them](https://en.wikipedia.org/wiki/Dot_product "dot product of two vector is equal to the cosine of the angle between them")). So we have:
4848

49-
$${\hat {R}} \cdot {\hat {N}} = {\hat {L}} \cdot {\hat {N}}$$
49+
£${\hat {R}} \cdot {\hat {N}} = {\hat {L}} \cdot {\hat {N}}£$
5050

5151
From the image above it's also evident for symmetry that:
5252

53-
$${\hat {U}^{\prime}} = -{\hat {U}^{\prime \prime}}$$
53+
£${\hat {U}^{\prime}} = -{\hat {U}^{\prime \prime}}£$
5454

5555
As you can see again from the image above, this two vectors could be easily calculated. In fact the first one is the difference between the reflection vector and the [projection](https://en.wikipedia.org/wiki/Vector_projection "vector projection") of it on the normal. The second one is the difference between the light incident vector and the projection of it on the normal. So for the reflection side we could write:
5656

57-
$${\hat {U}^{\prime}} = {\hat {R}} - {\hat {N}^{\prime}} = {\hat {R}} - ({\hat {R}} \cdot {\hat {N}}){\hat {N}}$$
57+
£${\hat {U}^{\prime}} = {\hat {R}} - {\hat {N}^{\prime}} = {\hat {R}} - ({\hat {R}} \cdot {\hat {N}}){\hat {N}}£$
5858

5959
For the light side we could write:
6060

61-
$${\hat {U}^{\prime \prime}} = {\hat {L}} - {\hat {N}^{\prime \prime}} = {\hat {L}} - ({\hat {L}} \cdot {\hat {N}}){\hat {N}}$$
61+
£${\hat {U}^{\prime \prime}} = {\hat {L}} - {\hat {N}^{\prime \prime}} = {\hat {L}} - ({\hat {L}} \cdot {\hat {N}}){\hat {N}}£$
6262

6363
As a consequence we obtain the following equation:
6464

65-
$${\hat {R}} - ({\hat {R}} \cdot {\hat {N}}){\hat {N}} = -({\hat {L}} - ({\hat {L}} \cdot {\hat {N}}){\hat {N}})$$
65+
£${\hat {R}} - ({\hat {R}} \cdot {\hat {N}}){\hat {N}} = -({\hat {L}} - ({\hat {L}} \cdot {\hat {N}}){\hat {N}})£$
6666

6767
Now we can see again from the image above that the vector projections ${\hat {N}^{\prime}}$ and ${\hat {N}^{\prime \prime}}$ are equals, that means we could change the previous equation by substituting the first one with the second one. So we obtain the following equation:
6868

69-
$${\hat {R}} - ({\hat {L}} \cdot {\hat {N}}){\hat {N}} = -({\hat {L}} - ({\hat {L}} \cdot {\hat {N}}){\hat {N}})$$
69+
£${\hat {R}} - ({\hat {L}} \cdot {\hat {N}}){\hat {N}} = -({\hat {L}} - ({\hat {L}} \cdot {\hat {N}}){\hat {N}})£$
7070

7171
Now we have all we need to calculate our R vector:
7272

73-
$${\hat {R}} - ({\hat {L}} \cdot {\hat {N}}){\hat {N}} = -({\hat {L}} - ({\hat {L}} \cdot {\hat {N}}){\hat {N}})$$
73+
£${\hat {R}} - ({\hat {L}} \cdot {\hat {N}}){\hat {N}} = -({\hat {L}} - ({\hat {L}} \cdot {\hat {N}}){\hat {N}})£$
7474

75-
$${\hat {R}} = ({\hat {L}} \cdot {\hat {N}}){\hat {N}} - ({\hat {L}} - ({\hat {L}} \cdot {\hat {N}}){\hat {N}})$$
75+
£${\hat {R}} = ({\hat {L}} \cdot {\hat {N}}){\hat {N}} - ({\hat {L}} - ({\hat {L}} \cdot {\hat {N}}){\hat {N}})£$
7676

77-
$${\hat {R}} = ({\hat {L}} \cdot {\hat {N}}){\hat {N}} - {\hat {L}} + ({\hat {L}} \cdot {\hat {N}}){\hat {N}}$$
77+
£${\hat {R}} = ({\hat {L}} \cdot {\hat {N}}){\hat {N}} - {\hat {L}} + ({\hat {L}} \cdot {\hat {N}}){\hat {N}}£$
7878

79-
$$R = 2({\hat{N}}\cdot{\hat{L}}){\hat{N}} - {\hat{L}}$$
79+
£$R = 2({\hat{N}}\cdot{\hat{L}}){\hat{N}} - {\hat{L}}£$
8080

8181
That's it!! We get our formula. Now you're ready to understand in detail [the "magic" of the Phong lighting model](/2017/07/26/phong-lighting-model.html) :relaxed:.

_posts/2017-12-07-physically-base-rendering-introduction.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Other two important quantities of radiometry are **irradiance** and **radiant ex
2828
arriving at a surface per unit area. The second one describe flux leaving a surface per unit area (Pharr et al., 2010 [1]).
2929
Formally irradiance is described with the following equation:
3030

31-
$$E = \frac{d\phi}{dA}$$
31+
£$E = \frac{d\phi}{dA}£$
3232

3333
where the differential flux $d\phi$ is computed over the differential area $dA$. It is measured as units of watt
3434
per square meter.
@@ -40,7 +40,7 @@ it with $\omega$, that is the set of all direction vectors anchored at $p$ that
4040
sphere and the object (Pharr et al., 2010 [1]).
4141
Now it is possible to give the definition of **radiance**, that is flux density per unit solid angle per unit area:
4242

43-
$$L=\frac{d\phi}{d\omega \ dA^{\perp}}$$
43+
£$L=\frac{d\phi}{d\omega \ dA^{\perp}}£$
4444

4545
In this case $dA^{\perp}$ is the projected area $dA$ on a surface perpendicular to $\omega$. So radiance describe
4646
the limit of measurement of incident light at the surface as a cone of incident directions of interest ${d\omega}$ becomes
@@ -50,7 +50,7 @@ and radiance leaving a point called exitant radiance and indicated with $L_{o}(p
5050
in the equations described below. It is important also to note another useful property, that connect
5151
the two types of radiance:
5252

53-
$$L_{i}(p,\omega) \neq L_{o}(p,\omega)$$
53+
£$L_{i}(p,\omega) \neq L_{o}(p,\omega)£$
5454

5555
#### **The rendering equation**
5656

@@ -59,7 +59,7 @@ Equation. It is the equation that describes the equilibrium distribution of radi
5959
gives the total reflected radiance at a point as a sum of emitted and reflected light from a surface. This is the
6060
formula of the rendering equation:
6161

62-
$$L_{o}(p,\omega) = L_{e}(p,\omega) + \int_{\Omega}f_{r}(p,\omega_{i},\omega_{0})L_{i}(p,\omega)\cos\theta_{i}d\omega_{i}$$
62+
£$L_{o}(p,\omega) = L_{e}(p,\omega) + \int_{\Omega}f_{r}(p,\omega_{i},\omega_{0})L_{i}(p,\omega)\cos\theta_{i}d\omega_{i}£$
6363

6464
In this formula the meaning of each symbols are:
6565

@@ -83,11 +83,11 @@ between the differential exitant radiance and the differential irradiance at a p
8383
parameter of this function are: the incident light direction, the outgoing light direction and a point on the surface.
8484
The formula for this function in terms of radiometric quantities is the following:
8585

86-
$$f_{r}(p,\omega_{i},\omega_{o}) = \frac{dL_{o}(p,\omega_{o})}{dE(p,\omega_{I})}$$
86+
£$f_{r}(p,\omega_{i},\omega_{o}) = \frac{dL_{o}(p,\omega_{o})}{dE(p,\omega_{I})}£$
8787

8888
The BRDF has two important properties:
8989

90-
* it is a symmetric function, so for all pair of directions $$f_{r}(p,\omega_{i},\omega_{o}) = f_{r}(p,\omega_{o},\omega_{i})$$
90+
* it is a symmetric function, so for all pair of directions £$f_{r}(p,\omega_{i},\omega_{o}) = f_{r}(p,\omega_{o},\omega_{i})£$
9191
* it satisfies the **energy conservation principle**: *the light reflected is less than or equal to the incident light*.
9292

9393
A lot of models has been developed to describe the BRDF of different surfaces. In particular, in the last years

dependencies-js-blog.html

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,30 @@
11
{% if page.math %}
2-
<script type="text/x-mathjax-config">
3-
MathJax.Hub.Config({
4-
jax: ["input/TeX","output/SVG"],
5-
messageStyle: "none",
6-
tex2jax: {
7-
inlineMath: [['$','$']],
8-
processEscapes: true
9-
},
10-
"HTML-CSS": {
11-
linebreaks: { automatic: true }
12-
},
13-
SVG: {
14-
linebreaks: { automatic: true }
15-
}
16-
});
2+
<script>
3+
window.MathJax = {
4+
tex: {
5+
inlineMath: [['$','$']],
6+
displayMath: [['£$', '£$']],
7+
processEscapes: true,
8+
autoload: {
9+
color: [],
10+
colorV2: ['color']
11+
},
12+
packages: {'[+]': ['noerrors']}
13+
},
14+
svg: {
15+
fontCache: 'global'
16+
},
17+
options: {
18+
ignoreHtmlClass: 'tex2jax_ignore',
19+
processHtmlClass: 'tex2jax_process'
20+
},
21+
loader: {
22+
load: ['[tex]/noerrors']
23+
}
24+
};
1725
</script>
18-
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS_SVG"></script>
26+
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
27+
<script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js" id="MathJax-script"></script>
1928
{% endif %}
2029
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/cookieconsent@3/build/cookieconsent.min.js" data-cfasync="false"></script>
2130
<script type="text/javascript" src="/assets/js/index.blog.min.js?rev=@@hash"></script>

0 commit comments

Comments
 (0)