gzz-commits
[Top][All Lists]

## [Gzz-commits] gzz/Documentation/Manuscripts/Irregu irregu.tex

 From: Janne V. Kujala Subject: [Gzz-commits] gzz/Documentation/Manuscripts/Irregu irregu.tex Date: Fri, 29 Nov 2002 06:20:42 -0500

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Janne V. Kujala <address@hidden>        02/11/29 06:20:40

Modified files:
Documentation/Manuscripts/Irregu: irregu.tex

Log message:
symbols, tear-out shapes

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/Documentation/Manuscripts/Irregu/irregu.tex.diff?tr1=1.86&tr2=1.87&r1=text&r2=text

Patches:
Index: gzz/Documentation/Manuscripts/Irregu/irregu.tex
diff -u gzz/Documentation/Manuscripts/Irregu/irregu.tex:1.86
gzz/Documentation/Manuscripts/Irregu/irregu.tex:1.87
--- gzz/Documentation/Manuscripts/Irregu/irregu.tex:1.86        Fri Nov 29
05:38:13 2002
+++ gzz/Documentation/Manuscripts/Irregu/irregu.tex     Fri Nov 29 06:20:40 2002
@@ -371,16 +371,18 @@
and discuss
a simple algorithm for a shape with the desired properties.

+\newcommand{\p}{\mathbf{p}}
+\newcommand{\q}{\mathbf{q}}
Suppose $A \subset \mathbf{R}^2$ is the part of the canvas we want to tear off,
for example, a rectangle or an ellipse.
We want to define the corresponding irregular piece $B \subset \mathbf{R}^2$
so as to make the movement of $A$ look natural.

There should be some maximum radius $r$ of distortion such that
-whether a point $y$ is in $B$ depends only on the set $A \cap B(q, r)$,
-where $B(q, r)$ is a ball of radius $r$ centered at $q \in \mathbf{R}^2$.
-$A \cap B(q, r) = \emptyset$ should imply $q \notin B$ and
-$A \cap B(q, r) = B(y,r)$ should imply $q \in B$.
+whether a point $y$ is in $B$ depends only on the set $A \cap B(\q, r)$,
+where $B(\q, r)$ is a ball of radius $r$ centered at $\q \in \mathbf{R}^2$.
+$A \cap B(\q, r) = \emptyset$ should imply $\q \notin B$ and
+$A \cap B(\q, r) = B(y,r)$ should imply $\q \in B$.
Additionally, the mapping from $A$'s to $B$'s should be continuous
so that slow movement of $A$ results into smooth rippling'' in $B$.
Furthermore, the rippling should not be too fast.
@@ -399,12 +401,12 @@
$R \subset (\mathbf{R}^2)^2$ that identifies the points of $A$
with points in $B$:
$- B = \{\, q \mid \exists p \in A: p R q \,\}. + B = \{\, \q \mid \exists \p \in A: \p R \q \,\}.$
-If $\Vert p - q\Vert \le r$ for all $p R q$, the maximum distortion requirement
-is satisfied.
+If $\Vert \p - \q\Vert \le r$ for all $\p R \q$,
+the maximum distortion requirement is satisfied.

-If $R$ is a continuous function, i.e., $p R q \Leftrightarrow p = G(q)$,
+If $R$ is a continuous function, i.e., $\p R \q \Leftrightarrow \p = G(\q)$,
the irregular shapes will be connected (if the original shape is connected),
but some parts of original
shape may map to overlapping parts in the irregular shape.
@@ -412,7 +414,7 @@
image of its border.

If $R$ is a continuous function in the inverse direction, i.e.,
-$p R q \Leftrightarrow F(q) = p$,
+$\p R \q \Leftrightarrow F(\q) = \p$,
there will be no overlapping.
Specifically, the edge of $A$ will map to the edge of $B$.
However, the irregular shape may be scattered, if many points
@@ -424,11 +426,11 @@
the image of the undistorted shape can be stored in a texture and accessed
with texture coordinates read from (or offset by) another texture storing the
-inverse function (or the offset $F(q) - q$).
+inverse function (or the offset $F(\q) - \q$).
This is called a dependent (or offset) texture access.

-The forward function cannot be efficiently implemented on fragment level,
-because each fragment may depend on multiple values of the function.
+The forward function cannot be efficiently implemented on pixel level,
+because each pixel may depend on multiple values of the function.
The edge of the shape could be displaced on vertex level,
but that is likely to not yield good performance if the shape has fine detail.
Furthermore, intersections in the edge may cause additional problems.
@@ -505,11 +507,11 @@

The edge curve $C(x)$ of a conneccted shape can be obtained by simply
displacing the edge in the normal direction of the envelope by a function
-$0\le f({\bf p})\le 1$ which only depends on the location ${\bf p}$ of the
spine:
+$0\le f(\p)\le 1$ which only depends on the location $\p$ of the spine:
$C(x) = E(x, f(E(x,1/2)))$.

The scattered case, on the other hand, can be obtained through a decision
process:
-again using a function $f({\bf p})$ of location ${\bf p}$,
+again using a function $f(\p)$ of location $\p$,
a given point $E(x,y)$ is {\em inside} the tear-out,
iff $f(E(x,y)) > y$.

@@ -519,17 +521,17 @@

These two algorithms correspond to one-dimensional displacement
and offset distortions, where the one dimension is in the normal direction.
-That corresponding function and inverse function are
+The corresponding function and inverse function are
\begin{eqnarray}
-  G_n(p) &=& p + r n (2f(p) - 1), \\
-  F_n(q) &=& q - r n (2f(q) - 1),
+  G_n(\p) &=& \p + (r N) (2f(\p) - 1), \\
+  F_n(\q) &=& \q - (r N) (2f(\q) - 1),
\end{eqnarray}
-where $n$ is the unit normal and $r$ the distortion radius.
+where $N$ is the unit normal and $r$ is the distortion radius.

-Although these algorithms seem different and produce different results, there
is
-actually a general formulation which yields to a visual explanation.
+Although these algorithms seem different and produce different results,
+there is actually a general formulation in the one-dimensional case.
Both algorithms can be seen as computing the intersection of a
-\emph{ripple volume}, the volume below the surface $({\bf p}, f({\bf p}))$,
+\emph{ripple volume}, the volume below the surface $(\p, f(\p))$,
and a \emph{cutting surface} $(E(x,g(y)), y)$,
and then mapping the intersection on the envelope $E(x,y)$
using the parameters of the cutting surface.
@@ -596,7 +598,7 @@
with texture coordinates interpolated as $(x,g(y))$
and the alpha component of the primary color as $(1-y)$.
The left side of the inequality can be computed using
-texture environment mode ADD and an INTENSITY texture storing $f({\bf p})$.
+texture environment mode ADD and an INTENSITY texture storing $f(\p)$.
The alpha output of the texture environment can then be tested
against $1$ using ALPHA\_TEST to discard fragments outside
the tear-out.
@@ -845,29 +847,41 @@
The border of the intersection shape is obtained
as a similar intersection using the half-planes corresponding to
the outer edges of the borders.
+The intersection can be implemented using stencil operations.

-The intersection can be implemented by drawing the outside
-to the stencil buffer for each side of the shape.
-The inside is then drawn
-with stencil test set to discard those fragments that were
-drawn to the stencil buffer as the outside of the shape.
-This method works even if the tear-out shape has no corners,
-and requires no extra passes over the inside of the shape
-(the stencil can be cleared as the contents are drawn).
+%by drawing the outside
+%to the stencil buffer for each side of the shape.
+%The inside is then drawn
+%with stencil test set to discard those fragments that were
+%drawn to the stencil buffer as the outside of the shape.
+%This method works even if the tear-out shape has no corners,
+%and requires no extra passes over the inside of the shape
+%(the stencil can be cleared as the contents are drawn).
+
+When the tear-out reaches the edge of canvas, the smooth
+canvas border should be drawn instead of the parts of the tear-out
+shape extending outside the canvas.
+This can be implemented with stencil operations:
+First the full tear-out shape including the border is drawn
+to the stencil buffer.
+Then the canvas with its borders is drawn on screen using stencil test,
+and another bit is written to the stencil buffer for each canvas pixel
+ending up on screen.
+That stencil bit is then used to draw borders for the torn edges.

If a canvas is torn into multiple pieces, the above methods
produce edges that do not fit together: the edges of adjacent
pieces have opposing ripples.
-The problem is partly solved by inverting (i.e., $1-f({\bf p})$)
+The problem is partly solved by inverting (i.e., $1-f(\p)$)
the ripple function for either one of each pair of facing sides.
But then a 180 degree rotation of a pair of fitting pieces
inverts the torn shape between them, breaking the principle of
tying ripple shape to canvas location.

The problem can be fully solved with a vector valued ripple function
-${\bf F}({\bf p})$, $\Vert{\bf F}({\bf p})\Vert \le 1$,
-using $f({\bf p}) = (1 + {\bf d}\cdot {\bf F}({\bf p}))/2$,
-where ${\bf d}$ is the unit normal
+$F({\p})$, $\Vert F({\p})\Vert \le 1$,
+using $f({\p}) = (1 + N \cdot F({\p}))/2$,
+where $N$ is the unit normal
of the envelope. The dot product automatically inverts the
function for a 180 degree rotation.
XXX: equivalent to drawing each envelope section by real 2D-offsetting