def __init__(self, image_size=256, background_color=[0,0,0], near=1, far=100, anti_aliasing=False, fill_back=True, eps=1e-3, sigma_val=1e-5, dist_func='euclidean', dist_eps=1e-4, gamma_val=1e-4, aggr_func_rgb='softmax', aggr_func_alpha='prod', texture_type='surface', camera_mode='projection', P=None, dist_coeffs=None, orig_size=512, perspective=True, viewing_angle=30, viewing_scale=1.0, eye=None, camera_direction=[0,0,1], light_mode='surface', light_intensity_ambient=0.5, light_color_ambient=[1,1,1], light_intensity_directionals=0.5, light_color_directionals=[1,1,1], light_directions=[0,1,0]): super(SoftRenderer, self).__init__() # light self.lighting = sr.Lighting(light_mode, light_intensity_ambient, light_color_ambient, light_intensity_directionals, light_color_directionals, light_directions) # camera self.transform = sr.Transform(camera_mode, P, dist_coeffs, orig_size, perspective, viewing_angle, viewing_scale, eye, camera_direction) # rasterization self.rasterizer = sr.SoftRasterizer(image_size, background_color, near, far, anti_aliasing, fill_back, eps, sigma_val, dist_func, dist_eps, gamma_val, aggr_func_rgb, aggr_func_alpha, texture_type)
def __init__(self, batch_size=1, image_size=256, is_tranform=True, camera_mode='projection', K=None, R=None, t=None, dist_coeffs=None, orig_size=512, perspective=True, viewing_angle=30, viewing_scale=1.0, eye=None, camera_direction=[0, 0, 1]): super(ColorRenderer, self).__init__() # camera if is_tranform: self.transform = sr.Transform(camera_mode, K, R, t, dist_coeffs, orig_size, perspective, viewing_angle, viewing_scale, eye, camera_direction) # rasterization self.rasterizer = sr.StandardRasterizer(batch_size, image_size) self.is_transform = is_tranform self.image_size = image_size
def __init__(self, image_size=256, background_color=[0,0,0], near=1, far=100, anti_aliasing=True, fill_back=True, eps=1e-6, camera_mode='projection', P=None, dist_coeffs=None, orig_size=512, perspective=True, viewing_angle=30, viewing_scale=1.0, eye=None, camera_direction=[0,0,1], light_mode='surface', light_intensity_ambient=0.5, light_color_ambient=[1,1,1], light_intensity_directionals=0.5, light_color_directionals=[1,1,1], light_directions=[0,1,0]): super(Renderer, self).__init__() # light self.lighting = sr.Lighting(light_mode, light_intensity_ambient, light_color_ambient, light_intensity_directionals, light_color_directionals, light_directions) # camera self.transform = sr.Transform(camera_mode, P, dist_coeffs, orig_size, perspective, viewing_angle, viewing_scale, eye, camera_direction) # rasterization self.rasterizer = sr.Rasterizer(image_size, background_color, near, far, anti_aliasing, fill_back, eps)
def __init__(self, image_size=256, background_color=[0, 0, 0], near=1, far=100, anti_aliasing=False, fill_back=True, eps=1e-3, sigma_val=1e-5, dist_func='euclidean', dist_eps=1e-4, gamma_val=1e-4, aggr_func_rgb='softmax', aggr_func_alpha='prod', texture_type='surface', camera_mode='projection', P=None, dist_coeffs=None, orig_size=512, perspective=True, viewing_angle=30, viewing_scale=1.0, eye=None, camera_direction=[0, 0, 1], light_mode='surface', light_intensity_ambient=0.5, light_color_ambient=[1, 1, 1], light_intensity_directionals=0.5, light_color_directionals=[1, 1, 1], light_directions=[0, 1, 0], shadow=True, light_width=2, softmin_scale=10): super(SoftRenderer, self).__init__() # light self.lighting = sr.Lighting(light_mode, light_intensity_ambient, light_color_ambient, light_intensity_directionals, light_color_directionals, light_directions) # camera self.transform = sr.Transform(camera_mode, P, dist_coeffs, orig_size, perspective, viewing_angle, viewing_scale, eye, camera_direction) if not isinstance(light_directions, (torch.Tensor, np.ndarray)): light_directions = torch.FloatTensor(light_directions) self.light_space_tform = None if shadow: # TODO: Allow specifying the light distance # TODO: the light should really get its own viewing_scale instead of # sharing with the main camera self.light_space_tform = sr.Transform('look_at', perspective=False, eye=30 * light_directions, viewing_scale=viewing_scale) self.viewing_scale = viewing_scale # rasterization self.depth_rasterizer = sr.SoftRasterizer(image_size, background_color, near, far, False, fill_back, eps, sigma_val, dist_func, dist_eps, gamma_val, 'depth', aggr_func_alpha, texture_type) self.rasterizer = sr.SoftRasterizer(image_size, background_color, near, far, anti_aliasing, fill_back, eps, sigma_val, dist_func, dist_eps, gamma_val, aggr_func_rgb, aggr_func_alpha, texture_type, light_width, softmin_scale)
def __init__( self, image_size=256, background_color=[0, 0, 0], near=1, far=100, is_tranform=True, anti_aliasing=False, fill_back=True, eps=1e-3, sigma_val=1e-5, dist_func='euclidean', dist_eps=1e-4, gamma_val=1e-4, aggr_func_rgb='softmax', aggr_func_alpha='prod', texture_type='vertex', camera_mode='projection', K=None, R=None, t=None, dist_coeffs=None, orig_size=512, perspective=True, viewing_angle=30, viewing_scale=1.0, eye=None, camera_direction=[0, 0, 1], light_mode='direcntional', # directional, spherical shading_mode='Gouraud', #flat, Gouraud, Phong light_intensity_ambient=0.5, light_color_ambient=[1, 1, 1], light_intensity_directionals=0.5, light_color_directionals=[1, 1, 1], light_directions=[0, 1, 0]): super(TexSoftRenderer, self).__init__() # light self.light_mode = light_mode if light_mode == 'directional': self.lighting = sr.Lighting(light_mode, light_intensity_ambient, light_color_ambient, light_intensity_directionals, light_color_directionals, light_directions) elif light_mode == 'spherical': self.lighting = sr.SHLighting() else: print('no lighting') # camera if is_tranform: self.transform = sr.Transform(camera_mode, K, R, t, dist_coeffs, orig_size, perspective, viewing_angle, viewing_scale, eye, camera_direction) # rasterization self.texture_type = texture_type anti_aliasing = False self.rasterizer = sr.SoftRasterizer(image_size, background_color, near, far, anti_aliasing, fill_back, eps, sigma_val, dist_func, dist_eps, gamma_val, aggr_func_rgb, aggr_func_alpha, texture_type) self.is_transform = is_tranform