Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compare latexmath to image math rendering in asciidoctor branch #1909

Merged
merged 2 commits into from
Dec 2, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions specification/2.0/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ $(GENERATED): $(wildcard schema/*.json)
schema/glTF.schema.json > $(PROPREF).adoc

# Spec targets for offline generation
# Requires an up-to-date asciidoctor and asciidoctor-pdf be installed
# Requires an up-to-date asciidoctor, asciidoctor-pdf, and
# asciidoctor-mathematical be installed
# We recommend using the khronosgroup/vulkan-docs-base image on dockerhub
ASCIIDOCTOR = asciidoctor
SPECDEPS = $(SPEC).adoc $(GENERATED)
Expand All @@ -42,8 +43,13 @@ $(SPEC).html: $(SPECDEPS)
# :allow-url-read: is necessary for the embedded render.githubusers.com
# math images to be processed for the PDF target. See
# https://github.com/asciidoctor/asciidoctor-pdf/issues/369
# asciidoctor-mathematical leaves intermediate images of equations behing.
# These are removed after creating the PDF.
STEMIMAGES = stem-*.png
$(SPEC).pdf: $(SPECDEPS)
$(ASCIIDOCTOR) -b pdf -a allow-uri-read -r asciidoctor-pdf $(SPEC).adoc -o $@
$(ASCIIDOCTOR) -b pdf -a allow-uri-read -r asciidoctor-pdf \
-r asciidoctor-mathematical $(SPEC).adoc -o $@
rm -f $(STEMIMAGES)

clean:
-rm -f $(GENERATED) $(TARGETS)
114 changes: 114 additions & 0 deletions specification/2.0/Specification.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1584,6 +1584,20 @@ Runtimes are expected to use the following projection matrices.
[[infinite-perspective-projection]]
==== Infinite perspective projection

*Latexmath*

[latexmath]
++++
\begin{bmatrix}
1 \over { a \times \tan(0.5 \times y) } & 0 & 0 & 0 \\
0 & 1 \over { \tan(0.5 \times y) } & 0 & 0 \\
0 & 0 & -1 & -2n \\
0 & 0 & -1 & 0
\end{bmatrix}
++++

*Old*

image:figures/infinite-perspective.png[pdfwidth=4in,align=left]

where
Expand All @@ -1596,6 +1610,20 @@ where
[[finite-perspective-projection]]
==== Finite perspective projection

*Latexmath*

[latexmath]
++++
\begin{bmatrix}
1 \over { a \times \tan(0.5 \times y) } & 0 & 0 & 0 \\
0 & 1 \over { \tan(0.5 \times y) } & 0 & 0 \\
0 & 0 & { f + n } \over { n - f } & { 2 f n } \over { n - f } \\
0 & 0 & -1 & 0
\end{bmatrix}
++++

*Old*

image:figures/finite-perspective.png[pdfwidth=4in,align=left]

where
Expand All @@ -1609,6 +1637,20 @@ where
[[orthographic-projection]]
==== Orthographic projection

*Latexmath*

[latexmath]
++++
\begin{bmatrix}
1 \over r & 0 & 0 & 0 \\
0 & 1 \over t & 0 & 0 \\
0 & 0 & 2 \over { n - f } & { f + n } \over { n - f } \\
0 & 0 & 0 & 1
\end{bmatrix}
++++

*Old*

image:figures/ortho.png[pdfwidth=4in,align=left]

where
Expand Down Expand Up @@ -2159,28 +2201,82 @@ We use the following notation:

The specular reflection `specular_brdf(α)` is a microfacet BRDF

*Latexmath*

[latexmath]
++++
\text{MicrofacetBRDF} = \frac{G D}{4 \, \left|N \cdot L \right| \, \left| N \cdot V \right|}
++++

*Old*

image:https://render.githubusercontent.com/render/math?math=\displaystyle \text{MicrofacetBRDF} = \frac{G D}{4 \, \left|N \cdot L \right| \, \left| N \cdot V \right|}[format=svg]

with the Trowbridge-Reitz/GGX microfacet distribution

*Latexmath*

[latexmath]
++++
D = \frac{\alpha^2 \, \chi^{+}(N \cdot H)}{\pi ((N \cdot H)^2 (\alpha^2 - 1) + 1)^2}
++++

*Old*

image:https://render.githubusercontent.com/render/math?math=\displaystyle D = \frac{\alpha^2 \, \chi^%2B(N \cdot H)}{\pi ((N \cdot H)^2 (\alpha^2 - 1) %2B 1)^2}[format=svg]

and the separable form of the Smith joint masking-shadowing function

*Latexmath*

[latexmath]
++++
G = \frac{2 \, \left| N \cdot L \right| \, \chi^{+}(H \cdot L)}{\left| N \cdot L \right| + \sqrt{\alpha^2 + (1 - \alpha^2) (N \cdot L)^2}} \frac{2 \, \left| N \cdot V \right| \, \chi^{+}(H \cdot V)}{\left| N \cdot V \right| + \sqrt{\alpha^2 + (1 - \alpha^2) (N \cdot V)^2}}
++++

*Old*

image:https://render.githubusercontent.com/render/math?math=\displaystyle G = \frac{2 \, \left| N \cdot L \right| \, \chi^%2B(H \cdot L)}{\left| N \cdot L \right| %2B \sqrt{\alpha^2 %2B (1 - \alpha^2) (N \cdot L)^2}} \frac{2 \, \left| N \cdot V \right| \, \chi^%2B(H \cdot V)}{\left| N \cdot V \right| %2B \sqrt{\alpha^2 %2B (1 - \alpha^2) (N \cdot V)^2}}[format=svg]

where χ^+^(*x*) denotes the Heaviside function: 1 if *x* > 0 and 0 if *x* <= 0. See <<Heitz2014,Heitz (2014)>> for a derivation of the formulas.

Introducing the visibility function

*Latexmath*

[latexmath]
++++
V = \frac{G}{4 \, \left| N \cdot L \right| \, \left| N \cdot V \right|}
++++

*Old*

image:https://render.githubusercontent.com/render/math?math=\displaystyle V = \frac{G}{4 \, \left| N \cdot L \right| \, \left| N \cdot V \right|}[format=svg]

simplifies the original microfacet BRDF to

*Latexmath*

[latexmath]
++++
\text{MicrofacetBRDF} = V D
++++

*Old*

image:https://render.githubusercontent.com/render/math?math=\displaystyle \text{MicrofacetBRDF} = V D[format=svg]

with

*Latexmath*

[latexmath]
++++
V = \frac{\, \chi^{+}(H \cdot L)}{\left| N \cdot L\right| + \sqrt{\alpha^2 + (1 - \alpha^2) (N \cdot L)^2}} \frac{\, \chi^{+}(H \cdot V)}{\left| N \cdot V \right| + \sqrt{\alpha^2 + (1 - \alpha^2) (N \cdot V)^2}}
++++

*Old*

image:https://render.githubusercontent.com/render/math?math=\displaystyle V = \frac{\, \chi^%2B(H \cdot L)}{\left| N \cdot L\right| %2B \sqrt{\alpha^2 %2B (1 - \alpha^2) (N \cdot L)^2}} \frac{\, \chi^%2B(H \cdot V)}{\left| N \cdot V \right| %2B \sqrt{\alpha^2 %2B (1 - \alpha^2) (N \cdot V)^2}}[format=svg]

Thus we have the function
Expand All @@ -2198,6 +2294,15 @@ function specular_brdf(α) {

The diffuse reflection `diffuse_brdf(color)` is a Lambertian BRDF

*Latexmath*

[latexmath]
++++
\text{LambertianBRDF} = \frac{1}{\pi}
++++

*Old*

image:https://render.githubusercontent.com/render/math?math=\displaystyle \text{LambertianBRDF} = \frac{1}{\pi}[format=svg]

multiplied with the `color`.
Expand All @@ -2215,6 +2320,15 @@ function diffuse_brdf(color) {

An inexpensive approximation for the Fresnel term that can be used for conductors and dielectrics was developed by <<Schlick1994,Schlick (1994)>>:

*Latexmath*

[latexmath]
++++
F = f_0 + (1 - f_0) (1 - \left| V \cdot H \right| )^5
++++

*Old*

image:https://render.githubusercontent.com/render/math?math=\displaystyle F = f_0 %2B (1 - f_0) (1 - \left| V \cdot H \right| )^5[format=svg]

The conductor Fresnel `conductor_fresnel(f0, bsdf)` applies a view-dependent tint to a BSDF:
Expand Down