Skip to content

Commit

Permalink
Blender 3.6 fixes and attempt to get Windows CI working
Browse files Browse the repository at this point in the history
  • Loading branch information
rtabbara committed Oct 2, 2023
1 parent 17956f1 commit b87b96c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 22 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ jobs:
BLENDER_PYTHON=$(find blender/ -regextype posix-extended -regex '.*bin\/python(.exe|[0-9].[0-9]{1,2}m?)' -print -quit)
echo "Blender Python is $BLENDER_PYTHON"
SITE_PACKAGES=$(./$BLENDER_PYTHON -c "import site; print(site.getsitepackages()[0])")
echo "Blender Python site-packages location is $SITE_PACKAGES"
./$BLENDER_PYTHON -m ensurepip
./$BLENDER_PYTHON -m pip install -U pip --target=$SITE_PACKAGES
./$BLENDER_PYTHON -m pip install -U pip
./$BLENDER_PYTHON -m pip install --upgrade pytest pytest-cov --target=$SITE_PACKAGES
./$BLENDER_PYTHON -m pip install mitsuba==${{ matrix.environment.mitsuba-version }} --force-reinstall --target=$SITE_PACKAGES
Expand Down
23 changes: 5 additions & 18 deletions mitsuba-blender/io/exporter/materials.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ def convert_float_texture_node(export_ctx, socket):
raise NotImplementedError( "Node type %s is not supported. Only texture nodes are supported for float inputs" % node.type)

else:
params = socket.default_value
#roughness values in blender are remapped with a square root
if 'Roughness' in socket.name:
params = pow(socket.default_value, 2)
else:
params = socket.default_value

return params

Expand Down Expand Up @@ -100,11 +104,6 @@ def convert_glossy_materials_cycles(export_ctx, current_node):

roughness = convert_float_texture_node(export_ctx, current_node.inputs['Roughness'])

# Re-mapping to space in Mitsuba
# TODO: Handle when roughness is texture
if type(roughness) is float:
roughness = pow(roughness, 2)

if roughness and current_node.distribution != 'SHARP':
params.update({
'type': 'roughconductor',
Expand Down Expand Up @@ -136,11 +135,6 @@ def convert_glass_materials_cycles(export_ctx, current_node):

roughness = convert_float_texture_node(export_ctx, current_node.inputs['Roughness'])

# Re-mapping to space in Mitsuba
# TODO: Handle when roughness is texture
if type(roughness) is float:
roughness = pow(roughness, 2)

if roughness and current_node.distribution != 'SHARP':
params.update({
'type': 'roughdielectric',
Expand Down Expand Up @@ -279,13 +273,6 @@ def convert_principled_materials_cycles(export_ctx, current_node):
clearcoat = convert_float_texture_node(export_ctx, current_node.inputs['Clearcoat'])
clearcoat_roughness = convert_float_texture_node(export_ctx, current_node.inputs['Clearcoat Roughness'])

# Re-mapping to space in Mitsuba
# TODO: Handle when roughness is texture
if type(roughness) is float:
roughness = pow(roughness, 2)
if type(clearcoat_roughness) is float:
clearcoat_roughness = pow(clearcoat_roughness, 2)

params.update({
'type': 'principled',
'base_color': base_color,
Expand Down
11 changes: 8 additions & 3 deletions mitsuba-blender/io/importer/renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def apply_mi_independent_properties(mi_context, mi_props):
bl_independent_props.sample_count = mi_props.get('sample_count', 4)
bl_independent_props.seed = mi_props.get('seed', 0)
# Cycles properties
bl_renderer.sampling_pattern = 'SOBOL'
bl_renderer.sampling_pattern = 'SOBOL' if bpy.app.version < (3, 5, 0) else 'SOBOL_BURLEY'
bl_renderer.samples = mi_props.get('sample_count', 4)
bl_renderer.preview_samples = mi_props.get('sample_count', 4)
bl_renderer.seed = mi_props.get('seed', 0)
Expand All @@ -210,7 +210,7 @@ def apply_mi_stratified_properties(mi_context, mi_props):
bl_stratified_props.jitter = mi_props.get('jitter', True)
# Cycles properties
# NOTE: There isn't any equivalent sampler in Blender. We use the default Sobol pattern.
bl_renderer.sampling_pattern = 'SOBOL'
bl_renderer.sampling_pattern = 'SOBOL' if bpy.app.version < (3, 5, 0) else 'SOBOL_BURLEY'
bl_renderer.samples = mi_props.get('sample_count', 4)
bl_renderer.seed = mi_props.get('seed', 0)
return True
Expand All @@ -228,7 +228,12 @@ def apply_mi_multijitter_properties(mi_context, mi_props):
bl_multijitter_props.seed = mi_props.get('seed', 0)
bl_multijitter_props.jitter = mi_props.get('jitter', True)
# Cycles properties
bl_renderer.sampling_pattern = 'CORRELATED_MUTI_JITTER' if bpy.app.version < (3, 0, 0) else 'PROGRESSIVE_MULTI_JITTER'
if bpy.app.version < (3, 0, 0):
bl_renderer.sampling_pattern = 'CORRELATED_MUTI_JITTER'
elif bpy.app.version < (3, 5, 0):
bl_renderer.sampling_pattern = 'PROGRESSIVE_MULTI_JITTER'
else:
bl_renderer.sampling_pattern = 'TABULATED_SOBOL'
bl_renderer.samples = mi_props.get('sample_count', 4)
bl_renderer.seed = mi_props.get('seed', 0)
return True
Expand Down

0 comments on commit b87b96c

Please sign in to comment.