1 #ifndef PtexTriangleKernel_h
2 #define PtexTriangleKernel_h
67 fn(*
this, dst, data, nChan, nTxChan);
88 void set(
Res resVal,
float uVal,
float vVal,
89 float u1Val,
float v1Val,
float w1Val,
90 float u2Val,
float v2Val,
float w2Val,
91 float AVal,
float BVal,
float CVal)
95 u1 = u1Val; v1 = v1Val; w1 = w1Val;
96 u2 = u2Val; v2 = v2Val; w2 = w2Val;
97 A = AVal; B = BVal; C = CVal;
100 void set(
float uVal,
float vVal,
101 float u1Val,
float v1Val,
float w1Val,
102 float u2Val,
float v2Val,
float w2Val)
105 u1 = u1Val; v1 = v1Val; w1 = w1Val;
106 u2 = u2Val; v2 = v2Val; w2 = w2Val;
109 void setABC(
float AVal,
float BVal,
float CVal)
111 A = AVal; B = BVal; C = CVal;
139 setABC(C, 2.0f*C-B, A+C-B);
146 setABC(A+C-B, 2.0f*A-B, A);
153 #define C(eid, aeid) (eid*3 + aeid)
154 switch (
C(eid, aeid)) {
155 case C(0, 0):
set(1.0f-u, -v, 1.0f-u2, -v2, 1.0f-w2, 1.0f-u1, -v1, 1.0f-w1);
break;
156 case C(0, 1):
set(1.0f-w, 1.0f-u, 1.0f-w2, 1.0f-u2, -v2, 1.0f-w1, 1.0f-u1, -v1);
rotate1();
break;
157 case C(0, 2):
set( -v, 1.0f-w, -v2, 1.0f-w2, 1.0f-u2, -v1, 1.0f-w1, 1.0f-u1);
rotate2();
break;
159 case C(1, 0):
set(1.0f-v, -w, 1.0f-v2, -w2, 1.0f-u2, 1.0f-v1, -w1, 1.0f-u1);
rotate2();
break;
160 case C(1, 1):
set(1.0f-u, 1.0f-v, 1.0f-u2, 1.0f-v2, -w2, 1.0f-u1, 1.0f-v1, -w1);
break;
161 case C(1, 2):
set( -w, 1.0f-u, -w2, 1.0f-u2, 1.0f-v2, -w1, 1.0f-u1, 1.0f-v1);
rotate1();
break;
163 case C(2, 0):
set(1.0f-w, -u, 1.0f-w2, -u2, 1.0f-v2, 1.0f-w1, -u1, 1.0f-v1);
rotate1();
break;
164 case C(2, 1):
set(1.0f-v, 1.0f-w, 1.0f-v2, 1.0f-w2, -u2, 1.0f-v1, 1.0f-w1, -u1);
rotate2();
break;
165 case C(2, 2):
set( -u, 1.0f-v, -u2, 1.0f-v2, 1.0f-w2, -u1, 1.0f-v1, 1.0f-w1);
break;
191 float Finv = 1.0f/((float)resu*(
float)resu*(A*C - 0.25f * B *
B));
192 float Ak = A*Finv, Bk = B*Finv, Ck = C*Finv;
196 ke.
wscale = 1.0f/((float)resu*(
float)resu);
197 float scale = (float)ke.
rowlen;
198 ke.
u = u * scale -
float(1/3.0);
199 ke.
v = v * scale - float(1/3.0);
200 ke.
u1 = int(ceilf(u1 * scale -
float(1/3.0)));
201 ke.
v1 = int(ceilf(v1 * scale -
float(1/3.0)));
202 ke.
w1 = int(ceilf(w1 * scale -
float(1/3.0)));
203 ke.
u2 = int(ceilf(u2 * scale -
float(1/3.0)));
204 ke.
v2 = int(ceilf(v2 * scale -
float(1/3.0)));
205 ke.
w2 = int(ceilf(w2 * scale -
float(1/3.0)));
206 ke.
A = Ak; ke.
B = Bk; ke.
C = Ck;
213 ko.
u = (1.0f-
v) * scale -
float(1/3.0);
214 ko.
v = (1.0f-
u) * scale -
float(1/3.0);
215 ko.
u1 = int(ceilf((1.0f-v2) * scale -
float(1/3.0)));
216 ko.
v1 = int(ceilf((1.0f-u2) * scale -
float(1/3.0)));
217 ko.
w1 = int(ceilf((-w2) * scale -
float(1/3.0)));
218 ko.
u2 = int(ceilf((1.0f-v1) * scale -
float(1/3.0)));
219 ko.
v2 = int(ceilf((1.0f-u1) * scale -
float(1/3.0)));
220 ko.
w2 = int(ceilf((-w1) * scale -
float(1/3.0)));
221 ko.
A = Ck; ko.
B = Bk; ko.
C = Ak;
void setABC(float AVal, float BVal, float CVal)
void set(float uVal, float vVal, float u1Val, float v1Val, float w1Val, float u2Val, float v2Val, float w2Val)
void applyConst(float *dst, void *data, DataType dt, int nChan)
Common data structures and enums used throughout the API.
void splitU(PtexTriangleKernel &ka)
void apply(float *dst, void *data, DataType dt, int nChan, int nTxChan)
void splitV(PtexTriangleKernel &ka)
DataType
Type of data stored in texture file.
void reorient(int eid, int aeid)
Triangle filter kernel iterator (in texel coords)
int u() const
U resolution in texels.
int8_t vlog2
log base 2 of v resolution, in texels
static ApplyFn applyFunctions[40]
DataType
Type of data stored in texture file.
Triangle filter kernel (in normalized triangle coords)
void set(Res resVal, float uVal, float vVal, float u1Val, float v1Val, float w1Val, float u2Val, float v2Val, float w2Val, float AVal, float BVal, float CVal)
void(* ApplyFn)(PtexTriangleKernelIter &k, float *dst, void *data, int nChan, int nTxChan)
void getIterators(PtexTriangleKernelIter &ke, PtexTriangleKernelIter &ko)
int8_t ulog2
log base 2 of u resolution, in texels
Pixel resolution of a given texture.
static const float PtexTriangleKernelWidth
Public API classes for reading, writing, caching, and filtering Ptex files.
void splitW(PtexTriangleKernel &ka)