48 int faceid,
float u,
float v,
49 float uw1,
float vw1,
float uw2,
float vw2,
50 float width,
float blur)
53 if (!
_tx || nChannels <= 0)
return;
54 if (faceid < 0 || faceid >=
_tx->
numFaces())
return;
74 float uw = fabsf(uw1) + fabsf(uw2), vw = fabsf(vw1) + fabsf(vw2);
93 uw = uw * width + blur * 2.0f;
94 vw = vw * width + blur * 2.0f;
96 Ptex::Res((int8_t)(f.res.ulog2+1),(int8_t)(f.res.vlog2+1)));
102 uw = uw * width + blur;
103 vw = vw * width + blur;
109 assert(k.
uw > 0 && k.
vw > 0);
123 for (
int i = 0; i <
_nchan; i++) result[i] =
float(
_result[i] * scale);
133 bool splitR = (k.
u+k.
uw > k.
res.
u()), splitL = (k.
u < 0);
134 bool splitT = (k.
v+k.
vw > k.
res.
v()), splitB = (k.
v < 0);
143 if (splitR || splitL || splitT || splitB) {
214 int rot = eid - aeid + 2;
218 if (fIsSubface != afIsSubface) {
225 int neid = (aeid + 3) % 4;
229 rot += neid - aeid + 2;
239 bool primary = (af->
adjface(aeid) == faceid);
247 else apply(k, afid, *af);
255 int afid = faceid, aeid = eid;
259 const int MaxValence = 10;
260 int cfaceId[MaxValence];
261 int cedgeId[MaxValence];
265 for (
int i = 0; i < MaxValence; i++) {
269 aeid = (af->
adjedge(aeid) + 1) % 4;
275 if (afid < 0 || (afid == faceid && aeid == eid)) {
288 if (prevIsSubface && !isSubface && af->
adjface((aeid+3)%4) == prevFace)
292 bool primary = (i==1);
294 k.
rotate(eid - aeid + 3 - primary);
298 prevIsSubface = isSubface;
301 if (numCorners == 1) {
305 else if (numCorners > 1) {
309 float initialWeight = k.
weight();
311 for (
int i = 1; i <= numCorners; i++) {
316 _weight += newWeight * (float)numCorners - initialWeight;
330 if (fIsSubface != cfIsSubface) {
338 else apply(k, cfid, cf);
344 assert(k.
u >= 0 && k.
u + k.
uw <= k.
res.
u());
345 assert(k.
v >= 0 && k.
v + k.
vw <= k.
res.
v());
347 if (k.
uw <= 0 || k.
vw <= 0)
return;
357 if (dh->isConstant()) {
360 else if (dh->isTiled()) {
364 int tileresu = tileres.
u();
365 int tileresv = tileres.
v();
366 int ntilesu = k.
res.
u() / tileresu;
367 for (
int v = k.
v, vw = k.
vw; vw > 0; vw -= kt.
vw, v += kt.
vw) {
368 int tilev = v / tileresv;
371 kt.
kv = k.
kv + v - k.
v;
372 for (
int u = k.
u, uw = k.
uw; uw > 0; uw -= kt.
uw, u += kt.
uw) {
373 int tileu = u / tileresu;
376 kt.
ku = k.
ku + u - k.
u;
379 if (th->isConstant())
Left edge, from UV (0,1) to (0,0)
int adjface(int eid) const
Access an adjacent face id. The eid value must be 0..3.
virtual int numChannels()=0
Number of channels stored in file.
void splitAndApply(PtexSeparableKernel &k, int faceid, const Ptex::FaceInfo &f)
void apply(PtexSeparableKernel &k, int faceid, const Ptex::FaceInfo &f)
void apply(float *dst, void *data, DataType dt, int nChan, int nTxChan)
void applyConst(float *dst, void *data, DataType dt, int nChan)
static int DataSize(DataType dt)
Look up size of given data type (in bytes).
virtual void eval(float *result, int firstchan, int nchannels, int faceid, float u, float v, float uw1, float vw1, float uw2, float vw2, float width, float blur)
Apply filter to a ptex data file.
Top edge, from UV (1,1) to (0,1)
void mergeL(BorderMode mode)
void mergeB(BorderMode mode)
bool isNeighborhoodConstant() const
Determine if neighborhood of face is constant (by checking a flag).
bool adjustMainToSubface(int eid)
float makeSymmetric(float initialWeight)
int v() const
V resolution in texels.
static float OneValue(DataType dt)
Look up value of given data type that corresponds to the normalized value of 1.0. ...
Bottom edge, from UV (0,0) to (1,0)
int u() const
U resolution in texels.
int8_t vlog2
log base 2 of v resolution, in texels
static T clamp(T x, T lo, T hi)
void mergeR(BorderMode mode)
virtual void getData(int faceid, void *buffer, int stride)=0
Access texture data for a face at highest-resolution.
bool isSubface() const
Determine if face is a subface (by checking a flag).
void adjustSubfaceToMain(int eid)
virtual int numFaces()=0
Number of faces stored in file.
void mergeT(BorderMode mode)
EdgeId adjedge(int eid) const
Access an adjacent edge id. The eid value must be 0..3.
virtual void buildKernel(PtexSeparableKernel &k, float u, float v, float uw, float vw, Res faceRes)=0
texel beyond border are assumed to be black
virtual Ptex::DataType dataType()=0
Type of data stored in file.
void splitL(PtexSeparableKernel &k)
Smart-pointer for acquiring and releasing API objects.
void applyToCornerFace(PtexSeparableKernel &k, const Ptex::FaceInfo &f, int eid, int cfaceid, const Ptex::FaceInfo &cf, int ceid)
void splitB(PtexSeparableKernel &k)
int8_t ulog2
log base 2 of u resolution, in texels
Right edge, from UV (1,0) to (1,1)
void splitT(PtexSeparableKernel &k)
Pixel resolution of a given texture.
Res res
Resolution of face.
Information about a face, as stored in the Ptex file header.
texel access wraps to other side of face
void applyAcrossEdge(PtexSeparableKernel &k, int faceid, const Ptex::FaceInfo &f, int eid)
static void ConvertToFloat(float *dst, const void *src, Ptex::DataType dt, int numChannels)
Convert a number of data values from the given data type to float.
virtual const Ptex::FaceInfo & getFaceInfo(int faceid)=0
Access resolution and adjacency information about a face.
void applyToCorner(PtexSeparableKernel &k, int faceid, const Ptex::FaceInfo &f, int eid)
texel access is clamped to border
void splitR(PtexSeparableKernel &k)