Go to the documentation of this file.
   45     inline float squared(
float x) { 
return x*x; }
 
   51                               int faceid, 
float u, 
float v,
 
   52                               float uw1, 
float vw1, 
float uw2, 
float vw2,
 
   53                               float width, 
float blur)
 
   56     if (!
_tx || nChannels <= 0) 
return;
 
   57     if (faceid < 0 || faceid >= 
_tx->
numFaces()) 
return;
 
   67     if (f.isNeighborhoodConstant()) {
 
   97     for (
int i = 0; i < 
_nchan; i++) result[i] = 
float(
_result[i] * scale);
 
  106                                      float uw1, 
float vw1, 
float uw2, 
float vw2,
 
  107                                      float width, 
float blur, Res faceRes)
 
  109     const float sqrt3 = 1.7320508075688772f;
 
  112     float scaleAC = 0.25f * width*width;
 
  113     float scaleB = -2.0f * scaleAC;
 
  114     float A = (vw1*vw1 + vw2*vw2) * scaleAC;
 
  115     float B = (uw1*vw1 + uw2*vw2) * scaleB;
 
  116     float C = (uw1*uw1 + uw2*uw2) * scaleAC;
 
  119     float Ac = 0.75f * A;
 
  120     float Bc = float(sqrt3/2) * (B-A);
 
  121     float Cc = 0.25f * A - 0.5f * B + 
C;
 
  124     const float maxEcc = 15.0f; 
 
  125     const float eccRatio = (maxEcc*maxEcc + 1.0f) / (maxEcc*maxEcc - 1.0f);
 
  126     float X = sqrtf(squared(Ac - Cc) + squared(Bc));
 
  127     float b_e = 0.5f * (eccRatio * X - (Ac + Cc));
 
  131     float b_t = squared(0.5f / (
float)faceRes.u());
 
  134     float b_b = 0.25f * blur * blur;
 
  140     float m = sqrtf(2.0f*(Ac*Cc - 0.25f*Bc*Bc) / (Ac + Cc + X));
 
  146     A = float(4/3.0) * Ac;
 
  147     B = float(2/sqrt3) * Bc + A;
 
  148     C = -0.25f * A + 0.5f * B + Cc;
 
  162     float w = 1.0f - u - v;
 
  163     k.
set(Res((int8_t)reslog2, (int8_t)reslog2), u, v, u-uw, v-vw, w-ww, u+uw, v+vw, w+ww, A, B, 
C);
 
  229         int tileresu = tileres.
u();
 
  230         int tileresv = tileres.
v();
 
  233         int wOffsetBase = k.
rowlen - tileresu;
 
  234         for (
int tilev = k.
v1 / tileresv, tilevEnd = (k.
v2-1) / tileresv; tilev <= tilevEnd; tilev++) {
 
  235             int vOffset = tilev * tileresv;
 
  236             kt.
v = k.
v - (float)vOffset;
 
  239             for (
int tileu = k.
u1 / tileresu, tileuEnd = (k.
u2-1) / tileresu; tileu <= tileuEnd; tileu++) {
 
  240                 int uOffset = tileu * tileresu;
 
  241                 int wOffset = wOffsetBase - uOffset - vOffset;
 
  242                 kt.
u = k.
u - (float)uOffset;
 
  245                 kt.
w1 = k.
w1 - wOffset;
 
  246                 kt.
w2 = k.
w2 - wOffset;
 
  
virtual PtexFaceData * getTile(int tile)=0
Access a tile from the data block.
Pixel resolution of a given texture.
virtual bool isTiled()=0
True if this data block is tiled.
void apply(float *dst, void *data, DataType dt, int nChan, int nTxChan)
void splitU(PtexTriangleKernel &ka)
virtual int numChannels()=0
Number of channels stored in file.
#define PTEX_NAMESPACE_END
virtual bool isConstant()=0
True if this data block is constant.
virtual Ptex::Res tileRes()=0
Resolution of each tile in this data block.
int DataSize(DataType dt)
Look up size of given data type (in bytes).
void applyAcrossEdge(PtexTriangleKernel &k, const Ptex::FaceInfo &f, int eid)
int adjface(int eid) const
Access an adjacent face id. The eid value must be 0..3.
void applyConst(float *dst, void *data, DataType dt, int nChan)
Information about a face, as stored in the Ptex file header.
void applyIter(PtexTriangleKernelIter &k, PtexFaceData *dh)
Triangle filter kernel (in normalized triangle coords)
virtual int numFaces()=0
Number of faces stored in file.
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.
virtual void getData(int faceid, void *buffer, int stride)=0
Access texture data for a face at highest-resolution.
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.
void apply(PtexTriangleKernel &k, int faceid, const Ptex::FaceInfo &f)
float OneValue(DataType dt)
Look up value of given data type that corresponds to the normalized value of 1.0.
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)
Per-face texture data accessor.
Smart-pointer for acquiring and releasing API objects.
void splitW(PtexTriangleKernel &ka)
Triangle filter kernel iterator (in texel coords)
int calcResFromWidth(float w)
int u() const
U resolution in texels.
void buildKernel(PtexTriangleKernel &k, float u, float v, float uw1, float vw1, float uw2, float vw2, float width, float blur, Res faceRes)
virtual const Ptex::FaceInfo & getFaceInfo(int faceid)=0
Access resolution and adjacency information about a face.
virtual void * getData()=0
Access the data from this data block.
void splitAndApply(PtexTriangleKernel &k, int faceid, const Ptex::FaceInfo &f)
int v() const
V resolution in texels.
EdgeId adjedge(int eid) const
Access an adjacent edge id. The eid value must be 0..3.
void getIterators(PtexTriangleKernelIter &ke, PtexTriangleKernelIter &ko)
virtual Ptex::DataType dataType()=0
Type of data stored in file.
Res res
Resolution of face.
void splitV(PtexTriangleKernel &ka)
void reorient(int eid, int aeid)
const PTEX_NAMESPACE_BEGIN float PtexTriangleKernelWidth