alexnasa commited on
Commit
eeac89b
·
verified ·
1 Parent(s): 66cac5e

Update src/pixel3dmm/tracking/renderer_nvdiffrast.py

Browse files
src/pixel3dmm/tracking/renderer_nvdiffrast.py CHANGED
@@ -75,6 +75,7 @@ class NVDRenderer(nn.Module):
75
  def __init__(self, image_size, obj_filename, uv_size=512, flip=False,
76
  no_sh : bool = False,
77
  white_bg : bool = False,
 
78
  ):
79
  super(NVDRenderer, self).__init__()
80
  #TODO path management
@@ -156,6 +157,7 @@ class NVDRenderer(nn.Module):
156
  self.no_sh = no_sh
157
  self.rast_out = None
158
  self.rast_out_db = None
 
159
 
160
 
161
  def add_SHlight(self, normal_images, sh_coeff):
@@ -199,7 +201,7 @@ class NVDRenderer(nn.Module):
199
  pos_clips = transform_pos(r_mvps, vertices_world).float()
200
 
201
  if self.rast_out is None:
202
- rast_out, rast_out_db = dr.rasterize(glctx, pos_clips, self.pos_idx,
203
  resolution=[self.image_size, self.image_size])
204
  else:
205
  rast_out = self.rast_out
 
75
  def __init__(self, image_size, obj_filename, uv_size=512, flip=False,
76
  no_sh : bool = False,
77
  white_bg : bool = False,
78
+ glctx=None,
79
  ):
80
  super(NVDRenderer, self).__init__()
81
  #TODO path management
 
157
  self.no_sh = no_sh
158
  self.rast_out = None
159
  self.rast_out_db = None
160
+ self.glctx = glctx or dr.RasterizeCudaContext()
161
 
162
 
163
  def add_SHlight(self, normal_images, sh_coeff):
 
201
  pos_clips = transform_pos(r_mvps, vertices_world).float()
202
 
203
  if self.rast_out is None:
204
+ rast_out, rast_out_db = dr.rasterize(self.glctx, pos_clips, self.pos_idx,
205
  resolution=[self.image_size, self.image_size])
206
  else:
207
  rast_out = self.rast_out