add optional undist_lut parameter to PfmVizzer::project()

This commit is contained in:
David Rose 2014-12-04 17:17:57 -08:00
parent 68306f0c8f
commit 255027b18d
2 changed files with 15 additions and 3 deletions

View File

@ -54,7 +54,7 @@ PfmVizzer(PfmFile &pfm) : _pfm(pfm) {
// texture image. // texture image.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
void PfmVizzer:: void PfmVizzer::
project(const Lens *lens) { project(const Lens *lens, const PfmFile *undist_lut) {
nassertv(_pfm.is_valid()); nassertv(_pfm.is_valid());
static LMatrix4f to_uv(0.5f, 0.0f, 0.0f, 0.0f, static LMatrix4f to_uv(0.5f, 0.0f, 0.0f, 0.0f,
@ -77,7 +77,19 @@ project(const Lens *lens) {
_pfm.set_point4(xi, yi, LVecBase4f(0, 0, 0, 0)); _pfm.set_point4(xi, yi, LVecBase4f(0, 0, 0, 0));
} }
} else { } else {
p = to_uv.xform_point(LCAST(PN_float32, film)); // Now the lens gives us coordinates in the range [-1, 1].
// Rescale these to [0, 1].
LPoint3f uvw = film * to_uv;
if (undist_lut != NULL) {
// Apply the undistortion map, if given.
LPoint3f p2;
undist_lut->calc_bilinear_point(p2, uvw[0], 1.0 - uvw[1]);
uvw = p2;
uvw[1] = 1.0 - uvw[1];
}
p = uvw;
} }
} }
} }

View File

@ -36,7 +36,7 @@ PUBLISHED:
INLINE PfmFile &get_pfm(); INLINE PfmFile &get_pfm();
INLINE const PfmFile &get_pfm() const; INLINE const PfmFile &get_pfm() const;
BLOCKING void project(const Lens *lens); BLOCKING void project(const Lens *lens, const PfmFile *undist_lut = NULL);
BLOCKING void extrude(const Lens *lens); BLOCKING void extrude(const Lens *lens);
INLINE void set_vis_inverse(bool vis_inverse); INLINE void set_vis_inverse(bool vis_inverse);