Skip to content

Commit

Permalink
upd: alpha can be a texture
Browse files Browse the repository at this point in the history
  • Loading branch information
xehoth committed Oct 14, 2024
1 parent e3bafa3 commit af40b64
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions irtk/connectors/psdr_enzyme_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,10 +396,15 @@ def process_rough_conductor_bsdf(name, scene):
bsdf = scene[name]
cache = scene.cached['psdr_enzyme']

def get_alpha(alpha):
if isinstance(alpha, float) or isinstance(alpha, int):
return color_to_bitmap([alpha, alpha, alpha], 3)
return color_to_bitmap(alpha, 3)

# Create the object if it has not been created
if name not in cache['name_map']:
bsdf_id = len(cache['ctx']['bsdfs'])
psdr_bsdf = psdr_cpu.RoughConductorBSDF(bsdf['alpha_u'].item(), to_numpy(bsdf['eta']), to_numpy(bsdf['k']))
psdr_bsdf = psdr_cpu.RoughConductorBSDF(get_alpha(bsdf['alpha_u']), to_numpy(bsdf['eta']), to_numpy(bsdf['k']))
cache['ctx']['bsdfs'].append(psdr_bsdf)
cache['name_map'][name] = ("bsdfs", bsdf_id)
cache['mat_id_map'][name] = bsdf_id
Expand All @@ -411,11 +416,11 @@ def process_rough_conductor_bsdf(name, scene):
if len(updated) > 0:
for param_name in updated:
if param_name == 'alpha_u':
cache['ctx'][group][idx] = psdr_cpu.RoughConductorBSDF(bsdf['alpha_u'].item(), to_numpy(bsdf['eta']), to_numpy(bsdf['k']))
cache['ctx'][group][idx] = psdr_cpu.RoughConductorBSDF(get_alpha(bsdf['alpha_u']), to_numpy(bsdf['eta']), to_numpy(bsdf['k']))
elif param_name == 'eta':
cache['ctx'][group][idx] = psdr_cpu.RoughConductorBSDF(bsdf['alpha_u'].item(), to_numpy(bsdf['eta']), to_numpy(bsdf['k']))
cache['ctx'][group][idx] = psdr_cpu.RoughConductorBSDF(get_alpha(bsdf['alpha_u']), to_numpy(bsdf['eta']), to_numpy(bsdf['k']))
elif param_name == 'k':
cache['ctx'][group][idx] = psdr_cpu.RoughConductorBSDF(bsdf['alpha_u'].item(), to_numpy(bsdf['eta']), to_numpy(bsdf['k']))
cache['ctx'][group][idx] = psdr_cpu.RoughConductorBSDF(get_alpha(bsdf['alpha_u']), to_numpy(bsdf['eta']), to_numpy(bsdf['k']))
bsdf.mark_updated(param_name, False)
cache['update_scene'] = True

Expand Down

0 comments on commit af40b64

Please sign in to comment.