@@ -156,7 +156,8 @@ __global__ void computeCov2DCUDA(int P,
156
156
float * dL_dopacity,
157
157
const float * dL_dinvdepth,
158
158
float3 * dL_dmeans,
159
- float * dL_dcov)
159
+ float * dL_dcov,
160
+ bool antialiasing)
160
161
{
161
162
auto idx = cg::this_grid ().thread_rank ();
162
163
if (idx >= P || !(radii[idx] > 0 ))
@@ -205,41 +206,44 @@ __global__ void computeCov2DCUDA(int P,
205
206
float c_yy = cov2D[1 ][1 ];
206
207
207
208
constexpr float h_var = 0 .3f ;
208
- #ifdef DGR_FIX_AA
209
- const float det_cov = c_xx * c_yy - c_xy * c_xy;
210
- c_xx += h_var;
211
- c_yy += h_var;
212
- const float det_cov_plus_h_cov = c_xx * c_yy - c_xy * c_xy;
213
- const float h_convolution_scaling = sqrt (max (0 .000025f , det_cov / det_cov_plus_h_cov)); // max for numerical stability
214
- const float dL_dopacity_v = dL_dopacity[idx];
215
- const float d_h_convolution_scaling = dL_dopacity_v * opacities[idx];
216
- dL_dopacity[idx] = dL_dopacity_v * h_convolution_scaling;
217
- const float d_inside_root = (det_cov / det_cov_plus_h_cov) <= 0 .000025f ? 0 .f : d_h_convolution_scaling / (2 * h_convolution_scaling);
218
- #else
219
- c_xx += h_var;
220
- c_yy += h_var;
221
- #endif
209
+ float d_inside_root = 0 .f ;
210
+ if (antialiasing)
211
+ {
212
+ const float det_cov = c_xx * c_yy - c_xy * c_xy;
213
+ c_xx += h_var;
214
+ c_yy += h_var;
215
+ const float det_cov_plus_h_cov = c_xx * c_yy - c_xy * c_xy;
216
+ const float h_convolution_scaling = sqrt (max (0 .000025f , det_cov / det_cov_plus_h_cov)); // max for numerical stability
217
+ const float dL_dopacity_v = dL_dopacity[idx];
218
+ const float d_h_convolution_scaling = dL_dopacity_v * opacities[idx];
219
+ dL_dopacity[idx] = dL_dopacity_v * h_convolution_scaling;
220
+ d_inside_root = (det_cov / det_cov_plus_h_cov) <= 0 .000025f ? 0 .f : d_h_convolution_scaling / (2 * h_convolution_scaling);
221
+ }
222
+ else
223
+ {
224
+ c_xx += h_var;
225
+ c_yy += h_var;
226
+ }
222
227
223
228
float dL_dc_xx = 0 ;
224
229
float dL_dc_xy = 0 ;
225
230
float dL_dc_yy = 0 ;
226
- # ifdef DGR_FIX_AA
231
+ if (antialiasing)
227
232
{
228
- // https://www.wolframalpha.com/input?i=d+%28%28x*y+-+z%5E2%29%2F%28%28x%2Bw%29*%28y%2Bw%29+-+z%5E2%29%29+%2Fdx
229
- // https://www.wolframalpha.com/input?i=d+%28%28x*y+-+z%5E2%29%2F%28%28x%2Bw%29*%28y%2Bw%29+-+z%5E2%29%29+%2Fdz
230
- const float x = c_xx;
231
- const float y = c_yy;
232
- const float z = c_xy;
233
- const float w = h_var;
234
- const float denom_f = d_inside_root / sq (w * w + w * (x + y) + x * y - z * z);
235
- const float dL_dx = w * (w * y + y * y + z * z) * denom_f;
236
- const float dL_dy = w * (w * x + x * x + z * z) * denom_f;
237
- const float dL_dz = -2 .f * w * z * (w + x + y) * denom_f;
238
- dL_dc_xx = dL_dx;
239
- dL_dc_yy = dL_dy;
240
- dL_dc_xy = dL_dz;
233
+ // https://www.wolframalpha.com/input?i=d+%28%28x*y+-+z%5E2%29%2F%28%28x%2Bw%29*%28y%2Bw%29+-+z%5E2%29%29+%2Fdx
234
+ // https://www.wolframalpha.com/input?i=d+%28%28x*y+-+z%5E2%29%2F%28%28x%2Bw%29*%28y%2Bw%29+-+z%5E2%29%29+%2Fdz
235
+ const float x = c_xx;
236
+ const float y = c_yy;
237
+ const float z = c_xy;
238
+ const float w = h_var;
239
+ const float denom_f = d_inside_root / sq (w * w + w * (x + y) + x * y - z * z);
240
+ const float dL_dx = w * (w * y + y * y + z * z) * denom_f;
241
+ const float dL_dy = w * (w * x + x * x + z * z) * denom_f;
242
+ const float dL_dz = -2 .f * w * z * (w + x + y) * denom_f;
243
+ dL_dc_xx = dL_dx;
244
+ dL_dc_yy = dL_dy;
245
+ dL_dc_xy = dL_dz;
241
246
}
242
- #endif
243
247
244
248
float denom = c_xx * c_yy - c_xy * c_xy;
245
249
@@ -658,7 +662,8 @@ void BACKWARD::preprocess(
658
662
float * dL_dcov3D,
659
663
float * dL_dsh,
660
664
glm::vec3* dL_dscale,
661
- glm::vec4* dL_drot)
665
+ glm::vec4* dL_drot,
666
+ bool antialiasing)
662
667
{
663
668
// Propagate gradients for the path of 2D conic matrix computation.
664
669
// Somewhat long, thus it is its own kernel rather than being part of
@@ -679,7 +684,8 @@ void BACKWARD::preprocess(
679
684
dL_dopacity,
680
685
dL_dinvdepth,
681
686
(float3 *)dL_dmean3D,
682
- dL_dcov3D);
687
+ dL_dcov3D,
688
+ antialiasing);
683
689
684
690
// Propagate gradients for remaining steps: finish 3D mean gradients,
685
691
// propagate color gradients to SH (if desireD), propagate 3D covariance
0 commit comments