Jelajahi Sumber

ae-undershift-factor

David Rose 13 tahun lalu
induk
melakukan
1733b1abd9

+ 6 - 0
panda/src/grutil/config_grutil.cxx

@@ -84,6 +84,12 @@ ConfigVariableInt pfm_vis_max_indices
           "a single generated mesh.  If the mesh would require more than that, "
           "the mesh is subdivided into smaller pieces."));
 
+ConfigVariableDouble ae_undershift_factor
+("ae-undershift-factor", 1.004,
+ PRC_DESC("Specifies the factor by which After Effects under-applies the specified "
+          "maximum pixel shift when applying a displacement map.  This is used "
+          "to control PfmVizzer::make_displacement()."));
+
 ////////////////////////////////////////////////////////////////////
 //     Function: init_libgrutil
 //  Description: Initializes the library.  This must be called at

+ 2 - 0
panda/src/grutil/config_grutil.h

@@ -40,6 +40,8 @@ extern ConfigVariableBool movies_sync_pages;
 extern ConfigVariableInt pfm_vis_max_vertices;
 extern ConfigVariableInt pfm_vis_max_indices;
 
+extern ConfigVariableDouble ae_undershift_factor;
+
 extern EXPCL_PANDA_GRUTIL void init_libgrutil();
 
 #endif

+ 6 - 4
panda/src/grutil/pfmVizzer.cxx

@@ -395,11 +395,13 @@ make_displacement(PNMImage &result, double max_u, double max_v) const {
   // not exactly 0.5, because they round up.
   static const int midval = (PNM_MAXMAXVAL + 1) / 2;
 
-  // After Effects seems to always undershift by exactly this amount.
-  static const double scale_factor = 256.0 / 255.0;
+  // Empirically, After Effects seems to undershift by precisely this
+  // amount.  Curiously, this value is very close to, but not exactly,
+  // 256 / 255.
+  const double scale_factor = ae_undershift_factor;
 
-  double u_scale = scale_factor * 0.5 * (PNM_MAXMAXVAL - 1) / max_u;
-  double v_scale = scale_factor * 0.5 * (PNM_MAXMAXVAL - 1) / max_v;
+  double u_scale = scale_factor * 0.5 * PNM_MAXMAXVAL / max_u;
+  double v_scale = scale_factor * 0.5 * PNM_MAXMAXVAL / max_v;
 
   for (int yi = 0; yi < y_size; ++yi) {
     for (int xi = 0; xi < x_size; ++xi) {