Skip to content

Commit

Permalink
GodRays: add pixel supersampling
Browse files Browse the repository at this point in the history
  • Loading branch information
devernay committed Mar 4, 2015
1 parent 9ece16a commit 71688b3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
25 changes: 20 additions & 5 deletions GodRays/GodRays.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,15 @@ class GodRaysProcessor
} else {
double fx = transformed.z != 0 ? transformed.x / transformed.z : transformed.x;
double fy = transformed.z != 0 ? transformed.y / transformed.z : transformed.y;

ofxsFilterInterpolate2D<PIX,nComponents,filter,clamp>(fx, fy, _srcImg, _blackOutside, tmpPix);
if (filter == eFilterImpulse) {
ofxsFilterInterpolate2D<PIX,nComponents,filter,clamp>(fx, fy, _srcImg, _blackOutside, tmpPix);
} else {
double Jxx = (H.a*transformed.z - transformed.x*H.g)/(transformed.z*transformed.z);
double Jxy = (H.b*transformed.z - transformed.x*H.h)/(transformed.z*transformed.z);
double Jyx = (H.d*transformed.z - transformed.y*H.g)/(transformed.z*transformed.z);
double Jyy = (H.e*transformed.z - transformed.y*H.h)/(transformed.z*transformed.z);
ofxsFilterInterpolate2DSuper<PIX,nComponents,filter,clamp>(fx, fy, Jxx, Jxy, Jyx, Jyy, _srcImg, _blackOutside, tmpPix);
}
}

ofxsMaskMix<PIX, nComponents, maxValue, true>(tmpPix, x, y, _srcImg, _domask, _maskImg, (float)_mix, _maskInvert, dstPix);
Expand Down Expand Up @@ -376,7 +383,8 @@ class GodRaysProcessor
// the coordinates of the center of the pixel in canonical coordinates
// see http://openfx.sourceforge.net/Documentation/1.3/ofxProgrammingReference.html#CanonicalCoordinates
canonicalCoords.x = (double)x + 0.5;
OFX::Point3D transformed = _invtransform[t] * canonicalCoords;
const OFX::Matrix3x3& H = _invtransform[t];
OFX::Point3D transformed = H * canonicalCoords;
if ( !_srcImg || (transformed.z == 0.) ) {
// the back-transformed point is at infinity
for (int c = 0; c < nComponents; ++c) {
Expand All @@ -385,8 +393,15 @@ class GodRaysProcessor
} else {
double fx = transformed.z != 0 ? transformed.x / transformed.z : transformed.x;
double fy = transformed.z != 0 ? transformed.y / transformed.z : transformed.y;

ofxsFilterInterpolate2D<PIX,nComponents,filter,clamp>(fx, fy, _srcImg, _blackOutside, tmpPix);
if (filter == eFilterImpulse) {
ofxsFilterInterpolate2D<PIX,nComponents,filter,clamp>(fx, fy, _srcImg, _blackOutside, tmpPix);
} else {
double Jxx = (H.a*transformed.z - transformed.x*H.g)/(transformed.z*transformed.z);
double Jxy = (H.b*transformed.z - transformed.x*H.h)/(transformed.z*transformed.z);
double Jyx = (H.d*transformed.z - transformed.y*H.g)/(transformed.z*transformed.z);
double Jyy = (H.e*transformed.z - transformed.y*H.h)/(transformed.z*transformed.z);
ofxsFilterInterpolate2DSuper<PIX,nComponents,filter,clamp>(fx, fy, Jxx, Jxy, Jyx, Jyy, _srcImg, _blackOutside, tmpPix);
}
}
for (int c = 0; c < nComponents; ++c) {
// multiply by color
Expand Down
2 changes: 1 addition & 1 deletion SupportExt

0 comments on commit 71688b3

Please sign in to comment.