Open trrbivial opened 1 year ago
I am running demo_render.py with input file of obj/spot/spot_triangulated.obj and default configuration.
demo_render.py
obj/spot/spot_triangulated.obj
I find in this code
template <typename scalar_t> __device__ __forceinline__ void barycentric_clip(scalar_t *w) { for (int k = 0; k < 3; k++) w[k] = max(min(w[k], 1.), 0.); const scalar_t w_sum = max(w[0] + w[1] + w[2], 1e-5); for (int k = 0; k < 3; k++) w[k] /= w_sum; }
When the input w is [-0.25856018 , 1.4101562, -0.15160179]
w
[-0.25856018 , 1.4101562, -0.15160179]
It will become [0.0, 1.0, 0.0] after this function
[0.0, 1.0, 0.0]
However, when sampling texture
template <typename scalar_t> __device__ __forceinline__ scalar_t forward_sample_texture(const scalar_t *texture, const scalar_t *w, const int R, const int k, const int texture_sample_type) { scalar_t texture_k = 0; if (texture_sample_type == 0) { // sample surface color with resolution as R const int w_x = w[0] * R; const int w_y = w[1] * R; if ((w[0] + w[1]) * R - w_x - w_y <= 1) { texture_k = texture[(w_y * R + w_x) * 3 + k]; } else { texture_k = texture[((R - 1 - w_y) * R + (R - 1 - w_x)) * 3 + k]; } } else if (texture_sample_type == 1) { // sample vertex color texture_k = w[0] * texture[k] + w[1] * texture[3+k] + w[2] * texture[6+k]; } return texture_k; }
In this branch
if ((w[0] + w[1]) * R - w_x - w_y <= 1) { texture_k = texture[(w_y * R + w_x) * 3 + k];
Where R == 5, w[0] + w[1] == 1.0, w_x == 0, w_y == 5
R == 5
w[0] + w[1] == 1.0
w_x == 0
w_y == 5
It will read the texture by the index of [bn, fn, 25, k]
texture
[bn, fn, 25, k]
As far as I know, the shape of texture is defined as [batch_size, num_faces, texture_size, 3] where texture_size == 25
[batch_size, num_faces, texture_size, 3]
texture_size == 25
Maybe it is a small bug.
I am running
demo_render.py
with input file ofobj/spot/spot_triangulated.obj
and default configuration.I find in this code
When the input
w
is[-0.25856018 , 1.4101562, -0.15160179]
It will become
[0.0, 1.0, 0.0]
after this functionHowever, when sampling texture
In this branch
Where
R == 5
,w[0] + w[1] == 1.0
,w_x == 0
,w_y == 5
It will read the
texture
by the index of[bn, fn, 25, k]
As far as I know, the shape of
texture
is defined as[batch_size, num_faces, texture_size, 3]
wheretexture_size == 25
Maybe it is a small bug.