-
Notifications
You must be signed in to change notification settings - Fork 140
/
filterfootprint.txt
99 lines (72 loc) · 2.33 KB
/
filterfootprint.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/**
\page filterfootprint Filter footprint calculation
\image html uvellipse.png
The Ptex filter footprint is specified as two vectors in uv space:
\f[
W_1 = [uw1, vw1] \\
W_2 = [uw2, vw2]
\f]
The vectors form a parallelogram around the sample point, \f$ [u, v] \f$.
When the vectors are orthogonal, they form the major and minor axis of
the enclosed ellipse.
\par Determining the filter footprint
In general, the vectors represent the uv sampling interval along two
axes, a and b:
\f[
[uw1, vw1] = \left[ \frac{du}{da}, \frac{dv}{da} \right] \\
[uw2, vw2] = \left[ \frac{du}{db}, \frac{dv}{db} \right]
\f]
Two special cases are of interest:
A) Texture aligned grid (the classic Ptex case) - the vectors form two
sides of a rectangle, uw by vw:
\f[
[uw1, vw1] = [uw, 0] \\
[uw2, vw2] = [0, vw]
\f]
B) Projection from screen space (where a and b are screen coordinates in pixels):
<div style="margin-left: 40px;">
Given derivatives of the screen coordinates:
\f[ \frac{da}{du} = Du(a) \f]
\f[ \frac{db}{du} = Du(b) \f]
\f[ \frac{da}{dv} = Dv(a) \f]
\f[ \frac{db}{dv} = Dv(b) \f]
the vectors can be found by inverting the Jacobian matrix \f$
\begin{bmatrix}
\frac{da}{du} & \frac{db}{du} \\
\frac{da}{dv} & \frac{db}{dv}
\end{bmatrix}
\f$:
\f[
det = \left(
\frac{da}{du} * \frac{db}{dv} - \frac{db}{du} * \frac{da}{dv}
\right)
\f]
\f[ \frac{du}{da} = \frac{1}{det} * \frac{db}{dv} \f]
\f[ \frac{dv}{da} = -\frac{1}{det} * \frac{db}{du} \f]
\f[ \frac{du}{db} = -\frac{1}{det} * \frac{da}{dv} \f]
\f[ \frac{dv}{db} = \frac{1}{det} * \frac{da}{du} \f]
\f[
[uw1, vw1] = \left[ \frac{du}{da}, \frac{dv}{da} \right] \\
[uw2, vw2] = \left[ \frac{du}{db}, \frac{dv}{db} \right]
\f]
Note: if the ptex u, v coordinates aren't aligned with the renderer's
uv coordinates, the chain rule can be used.
Given texture coordinates s and t:
\f[ \frac{ds}{du} = Du(s) \f]
\f[ \frac{dt}{du} = Du(t) \f]
\f[ \frac{ds}{dv} = Dv(s) \f]
\f[ \frac{dt}{dv} = Dv(t) \f]
\f[
[uw1, vw1] = \left[
\frac{ds}{du} * \frac{du}{da} + \frac{ds}{dv} * \frac{dv}{da},
\frac{dt}{du} * \frac{du}{da} + \frac{dt}{dv} * \frac{dv}{da}
\right]
\f]
\f[
[uw2, vw2] = \left[
\frac{ds}{du} * \frac{du}{db} + \frac{ds}{dv} * \frac{dv}{db},
\frac{dt}{du} * \frac{du}{db} + \frac{dt}{dv} * \frac{dv}{db}
\right]
\f]
</div>
*/