diff --git a/renderer.cc b/renderer.cc index 1029f18..9258976 100644 --- a/renderer.cc +++ b/renderer.cc @@ -364,7 +364,23 @@ int main() for(auto& [v, normal, weights]: lviews) for(unsigned y=0; y(vec)); // for a 90 degree view, this is -45° to +45° + //float band = 1e-4f; // radians + //float adjust = 1 / std::abs(std::tan(angle) - std::tan(angle + band)); + // Rectilinear projection compensation method 2 — faster way to accomplish the identical results + //float vx = std::get<0>(vec) / std::get<2>(vec); + //float vy = std::get<1>(vec) / std::get<2>(vec); + //float adjust = 1 / (1 + vx*vx + vy*vy); + // Slightly faster way to calculate the same result as above (no divisions) + // created by simplifying the above expression into vz*vz / (vx*vx + vy*vy + vz*vz) + // Because "vec" is normalized, (vx*vx + vy*vy + vz*vz) is simply 1 and can be ignored. + float adjust = std::get<2>(vec) * std::get<2>(vec); + weights[y*dim+x] = power * adjust; + } // Normalize the weights so that their total sum is 1 float wsum = 0; for(auto& [v, normal, weights]: lviews)