445 |
hardware. |
hardware. |
446 |
XXX: we want to be able to draw connected tear-out shapes. |
XXX: we want to be able to draw connected tear-out shapes. |
447 |
|
|
448 |
|
\if 0 |
449 |
We split the edge of the original shape to multiple pieces, |
We split the edge of the original shape to multiple pieces, |
450 |
each assumed to be a straight line segment, and then consider |
each assumed to be a straight line segment, and then consider |
451 |
the problem of distorting each one separately. |
the problem of distorting each one separately. |
490 |
|
|
491 |
Thus, we have a ``connected case'' in a very similar formulation |
Thus, we have a ``connected case'' in a very similar formulation |
492 |
to the above ``scattered case''. |
to the above ``scattered case''. |
493 |
|
\fi |
494 |
|
|
495 |
--- |
--- |
496 |
|
|
499 |
The envelope is parametrized as a mapping $E(x,y)$ to canvas coordinates |
The envelope is parametrized as a mapping $E(x,y)$ to canvas coordinates |
500 |
so that $E(x,0)$ and $E(x,1)$ are the inner and outer edges of the |
so that $E(x,0)$ and $E(x,1)$ are the inner and outer edges of the |
501 |
envelope, respectively, and the ripples are contained between these two curves. |
envelope, respectively, and the ripples are contained between these two curves. |
|
The envelope should not intersect itself. |
|
|
|
|
502 |
An envelope can be defined with a \emph{spine} $E(x,1/2)$ and a normal vector |
An envelope can be defined with a \emph{spine} $E(x,1/2)$ and a normal vector |
503 |
$N(x)$ so that $E(x,y) = E(x,1/2) + (y-1/2) N(x)$. |
$N(x)$ so that $E(x,y) = E(x,1/2) + (y-1/2) N(x)$. |
504 |
|
The envelope should not intersect itself. |
505 |
|
|
506 |
The edge curve $C(x)$ of a conneccted shape can be obtained by simply |
The edge curve $C(x)$ of a conneccted shape can be obtained by simply |
507 |
shifting in the normal direction of the envelope by a function |
displacing the edge in the normal direction of the envelope by a function |
508 |
$0\le f({\bf p})\le 1$ which only depends on the location ${\bf p}$ of the spine: |
$0\le f({\bf p})\le 1$ which only depends on the location ${\bf p}$ of the spine: |
509 |
$C(x) = E(x, f(E(x,1/2)))$. |
$C(x) = E(x, f(E(x,1/2)))$. |
510 |
|
|
517 |
a function with noise at different frequencies, but with lower frequencies |
a function with noise at different frequencies, but with lower frequencies |
518 |
emphasized more, such as turbulence\cite{perlin-noise-intro}. |
emphasized more, such as turbulence\cite{perlin-noise-intro}. |
519 |
|
|
520 |
|
These two algorithms correspond to one-dimensional displacement |
521 |
|
and offset distortions, where the one dimension is in the normal direction. |
522 |
|
|
523 |
Although these algorithms seem different and produce different results, there is |
Although these algorithms seem different and produce different results, there is |
524 |
actually a general formulation which yields to a visual explanation. |
actually a general formulation which yields to a visual explanation. |
525 |
Both algorithms can be seen as computing the intersection of a |
Both algorithms can be seen as computing the intersection of a |
772 |
|
|
773 |
\subsubsection{Offset texture} |
\subsubsection{Offset texture} |
774 |
|
|
775 |
There is an intereseting way of obtaining |
Because the algorithm for drawing the shape is |
776 |
consistent border width using texture shader. |
equivalent to one-dimensional offsetting of a half-plane, |
777 |
|
the border can be drawn by offsetting |
778 |
XXX: connection to the scattered case |
a texture with an image of a straight line. |
779 |
|
However, a sloped offset reduces the width of the distorted line. |
780 |
The border is drawn by offsetting a texture with an image |
|
781 |
of a straight edge. |
This problem can be overcome by computing the mipmaps of |
782 |
The mipmaps of the edge texture are computed with constant line width |
the edge texture with scale-invariant constant line width (in texels). |
783 |
(in texels). |
The computed level of detail for each fragment is lower for a |
784 |
Because mip-map $\lambda$ values are computed for each fragment, |
sloped offset, and the lower detail texture with thicker line |
785 |
the resulting border width from the corresponding mip-map level |
will exactly compensate the reduced line width. |
786 |
is correct for the local slope of the displacement. |
Note that this no longer holds for two-dimensional offsetting. |
787 |
However, derivative discontinuities are sometimes visible |
Also, derivative discontinuities are sometimes visible |
788 |
as spikes in the border, if the border width is more |
as spikes in the border, if the border is more |
789 |
than a few pixels. |
than a few pixels wide. |
790 |
|
|
791 |
The edge texture can be one texel wide (if the image of the |
The edge texture can be one texel wide (if the image of the |
792 |
edge is drawn horizontally), allowing for large height and |
edge is drawn horizontally), allowing for large height and |