Skip to content

Commit c22f631

Browse files
committed
Try to fix CI
1 parent 50f4f9b commit c22f631

File tree

5 files changed

+180
-49
lines changed

5 files changed

+180
-49
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Build Mitsuba 3 on Ubuntu
2+
inputs:
3+
github_token:
4+
required: true
5+
description: "GitHub token defined by the workflow"
6+
runs:
7+
using: composite
8+
steps:
9+
- name: Install Mitsuba build dependencies
10+
shell: bash
11+
run: |
12+
sudo apt update
13+
sudo apt install -y cmake ccache ninja-build libpng-dev libjpeg-dev
14+
python -m pip install setuptools typing_extensions numpy
15+
16+
- name: Restore ccache
17+
id: cache-mitsuba
18+
uses: actions/cache/restore@v4
19+
with:
20+
path: |
21+
~/.cache
22+
mitsuba3/build
23+
key: build-ubuntu-${{ github.run_id }}
24+
restore-keys: |
25+
build-ubuntu-
26+
27+
- name: Checkout Mitsuba 3 repo
28+
uses: actions/checkout@v4
29+
with:
30+
repository: wjakob/nanobind
31+
# repository: mitsuba-renderer/mitsuba3
32+
path: mitsuba3
33+
submodules: recursive
34+
fetch-depth: 0
35+
36+
- name: Restore timestamps
37+
uses: chetan/git-restore-mtime-action@v2
38+
with:
39+
working-directory: mitsuba3
40+
41+
42+
- name: Build Mitsuba 3
43+
shell: bash
44+
run: |
45+
cd mitsuba3
46+
mkdir -p build
47+
export CCACHE_BASEDIR="$GITHUB_WORKSPACE"
48+
export CCACHE_NOHASHDIR=1
49+
export CCACHE_DEBUG=1
50+
export CMAKE_CXX_COMPILER_LAUNCHER=ccache
51+
export CCACHE_DEBUGDIR=$GITHUB_WORKSPACE/ccache-debug
52+
ccache -s
53+
cd build
54+
cmake .. -GNinja -DCMAKE_BUILD_TYPE=Release
55+
ninja -d explain
56+
ccache -s
57+
58+
- name: Store ccache
59+
if: always()
60+
uses: actions/cache/save@v4
61+
with:
62+
key: build-ubuntu-${{ github.run_id }}
63+
path: |
64+
~/.cache
65+
mitsuba3/build
66+
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Build Mitsuba 3 on Windows
2+
runs:
3+
using: composite
4+
steps:
5+
- name: Install Mitsuba build dependencies
6+
shell: bash
7+
run: |
8+
choco install ninja cmake
9+
python -m pip install setuptools typing_extensions numpy
10+
11+
- name: Checkout Mitsuba 3 repo
12+
uses: actions/checkout@v4
13+
with:
14+
repository: mitsuba-renderer/mitsuba3
15+
path: mitsuba3
16+
submodules: recursive
17+
18+
- name: Restore Mitsuba 3 build
19+
uses: actions/cache/restore@v4
20+
with:
21+
key: mitsuba-build-windows
22+
path: mitsuba3/build
23+
24+
- name: Build Mitsuba 3
25+
shell: bash
26+
run: |
27+
cd mitsuba3
28+
cmake -B build -DCMAKE_BUILD_TYPE=Release
29+
cmake --build build --config Release --parallel
30+
31+
- name: Cache Mitsuba 3 build
32+
if: always()
33+
uses: actions/cache/save@v4
34+
with:
35+
key: mitsuba-build-windows
36+
path: mitsuba3/build
37+

.github/workflows/test.yml

Lines changed: 51 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ name: Test suite
77
on:
88
push:
99
branches:
10-
- "*"
11-
- "!master"
10+
- master
1211
pull_request:
1312
branches: [ master ]
1413
workflow_call:
@@ -27,29 +26,34 @@ jobs:
2726
os: "ubuntu-latest",
2827
mitsuba-version: "3.5.0"
2928
}
30-
- {
31-
os: "windows-latest",
32-
mitsuba-version: "3.5.0"
33-
}
29+
# - {
30+
# os: "windows-latest",
31+
# mitsuba-version: "3.5.0"
32+
# }
3433
blender:
3534
- {
36-
version: "3.6"
35+
version: "3.6",
36+
python-version: "3.10"
3737
}
3838
- {
39-
version: "4.2"
40-
}
41-
- {
42-
version: "4.4"
39+
version: "4.2",
40+
python-version: "3.11"
4341
}
42+
# - {
43+
# version: "4.4",
44+
# python-version: "3.11"
45+
# }
4446
steps:
4547
- name: Git checkout
46-
uses: actions/checkout@v2
48+
uses: actions/checkout@v4
4749

4850
- name: Setup Python
4951
uses: "actions/setup-python@v2"
52+
with:
53+
python-version: ${{ matrix.blender.python-version }}
5054

5155
- name: Install Python dependencies
52-
run: python -m pip install --upgrade requests
56+
run: python -m pip install --upgrade requests
5357

5458
- name: Retrieve Blender full version
5559
id: blender-version
@@ -68,6 +72,26 @@ jobs:
6872
if: steps.cache-blender.outputs.cache-hit != 'true'
6973
run: python scripts/blender_downloader.py ${{ matrix.blender.version }} -o blender
7074

75+
- name: Check if mitsuba_version branch
76+
id: check-branch
77+
shell: bash
78+
run: |
79+
if [[ "${{ github.head_ref || github.ref_name }}" == mitsuba_version* ]]; then
80+
echo "::set-output name=is_mitsuba_version::true"
81+
else
82+
echo "::set-output name=is_mitsuba_version::false"
83+
fi
84+
85+
- name: Build Mitsuba if needed (Ubuntu)
86+
if: steps.check-branch.outputs.is_mitsuba_version == 'true' && matrix.environment.os == 'ubuntu-latest'
87+
uses: ./.github/workflows/build_mitsuba_ubuntu
88+
with:
89+
github_token: ${{ secrets.GITHUB_TOKEN }}
90+
91+
- name: Build Mitsuba if needed (Windows)
92+
if: steps.check-branch.outputs.is_mitsuba_version == 'true' && matrix.environment.os == 'windows-latest'
93+
uses: ./.github/workflows/build_mitsuba_windows
94+
7195
- name: Install Blender dependencies
7296
shell: bash
7397
run: |
@@ -76,11 +100,23 @@ jobs:
76100
./$BLENDER_PYTHON -m ensurepip
77101
./$BLENDER_PYTHON -m pip install -U pip
78102
./$BLENDER_PYTHON -m pip install --upgrade pytest pytest-cov
79-
./$BLENDER_PYTHON -m pip install mitsuba==${{ matrix.environment.mitsuba-version }} --force-reinstall
103+
if [[ "${{ steps.check-branch.outputs.is_mitsuba_version }}" == "true" ]]; then
104+
echo "Using local Mitsuba build"
105+
export PYTHONPATH="$PWD/mitsuba3/build/python:$PYTHONPATH"
106+
else
107+
echo "Using PyPI Mitsuba"
108+
./$BLENDER_PYTHON -m pip install mitsuba==${{ matrix.environment.mitsuba-version }} --force-reinstall
109+
fi
80110
81111
- name: Run Addon test suite
82112
shell: bash
83113
run: |
84114
BLENDER_EXECUTABLE=$(find blender/ -maxdepth 1 -regextype posix-extended -regex '.*blender(.exe)?' -print -quit)
85115
echo "Blender Executable is $BLENDER_EXECUTABLE"
86-
./$BLENDER_EXECUTABLE -b -noaudio --factory-startup --python scripts/run_tests.py -- -v --cov=mitsuba-blender
116+
if [[ "${{ steps.check-branch.outputs.is_mitsuba_version }}" == "true" ]]; then
117+
echo "Running tests with local Mitsuba build"
118+
./$BLENDER_EXECUTABLE -b -noaudio --factory-startup --python scripts/run_tests.py --mitsuba "$PWD/mitsuba3/build" -- -v --cov=mitsuba-blender
119+
else
120+
echo "Running tests with PyPI Mitsuba"
121+
./$BLENDER_EXECUTABLE -b -noaudio --factory-startup --python scripts/run_tests.py -- -v --cov=mitsuba-blender
122+
fi

mitsuba-blender/io/exporter/materials.py

Lines changed: 23 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -234,35 +234,23 @@ def convert_mix_materials_cycles(export_ctx, current_node):#TODO: test and fix t
234234
}
235235
return params
236236
elif mat_I.type != 'EMISSION' and mat_II.type != 'EMISSION':
237-
237+
# TODO: When we can process textures in-memory, support exporting mask BSDFs
238238
weight = convert_color_texture_node(export_ctx, current_node.inputs['Fac'])
239-
240-
if mat_I.type == 'BSDF_TRANSPARENT' or mat_II.type == 'BSDF_TRANSPARENT':
241-
#FIXME: What if the transparent opacity is not 1?
242-
params = {
243-
'type': 'mask',
244-
'opacity': weight
245-
}
246-
other_mat = mat_II if mat_I.type == 'BSDF_TRANSPARENT' else mat_I
247-
mat_params = cycles_material_to_dict(export_ctx, other_mat)
248-
params.update([('bsdf', mat_params)])
249-
250-
else:
251-
params = {
252-
'type': 'blendbsdf',
253-
'weight': weight
254-
}
255-
# add first material
256-
mat_A = cycles_material_to_dict(export_ctx, mat_I)
257-
params.update([
258-
('bsdf1', mat_A)
259-
])
260-
261-
# add second material
262-
mat_B = cycles_material_to_dict(export_ctx, mat_II)
263-
params.update([
264-
('bsdf2', mat_B)
265-
])
239+
params = {
240+
'type': 'blendbsdf',
241+
'weight': weight
242+
}
243+
# add first material
244+
mat_A = cycles_material_to_dict(export_ctx, mat_I)
245+
params.update([
246+
('bsdf1', mat_A)
247+
])
248+
249+
# add second material
250+
mat_B = cycles_material_to_dict(export_ctx, mat_II)
251+
params.update([
252+
('bsdf2', mat_B)
253+
])
266254

267255
return params
268256
else:#one bsdf, one emitter
@@ -341,12 +329,16 @@ def convert_transparent_materials_cycles(export_ctx, current_node):
341329
# a texture. This will be doable once we convert textures in-memory instead
342330
# of on-disk (cf PR #121).
343331
export_ctx.log("Transparent BSDF: opacity textures are currently not supported. Consider using a Mix Shader instead.", 'WARN')
344-
opacity_bl = list(current_node.inputs['Color'].default_value)
332+
bl_opacity = current_node.inputs['Color'].default_value
333+
if min(bl_opacity) == 1.0:
334+
# Completely transparent, export a null material
335+
return {'type': 'null'}
336+
345337
# Invert the opacity value to match Mitsuba's convention
346-
opacity_mi = [*[1.0 - x for x in opacity_bl[:3]], opacity_bl[3]]
338+
mi_opacity = [*[1.0 - x for x in bl_opacity[:3]], bl_opacity[3]]
347339
params = {
348340
'type': 'mask',
349-
'opacity': export_ctx.spectrum(opacity_mi),
341+
'opacity': export_ctx.spectrum(mi_opacity),
350342
'bsdf': {
351343
'type': 'diffuse',
352344
'reflectance': export_ctx.spectrum(0.0)

mitsuba-blender/io/importer/materials.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -500,8 +500,8 @@ def write_mi_mask_bsdf(mi_context, mi_mat, bl_mat_wrap, out_socket_id, mi_bump=N
500500
mi_context.log(f'Unexpected number of child BSDFs in mask BSDF. Expected 1 but got {mi_child_mats_count}.', 'ERROR')
501501
return False
502502

503-
mi_child_mats = [mi_context.mi_state.nodes[i].props for i in mi_child_ids]
504-
if mi_child_mats[0].plugin_name() == 'diffuse' and mi_child_mats[0].get_texture('reflectance').max() == 0:
503+
mi_child_mat = mi_context.mi_state.nodes[mi_child_ids[0]].props
504+
if mi_child_mat.plugin_name() == 'diffuse' and mi_child_mat.get_texture('reflectance').max() == 0:
505505
# This can simply be a transparent material.
506506
bl_transparent = bl_mat_wrap.ensure_node_type([out_socket_id], 'ShaderNodeBsdfTransparent', 'BSDF')
507507
bl_transparent_wrap = bl_shader_utils.NodeMaterialWrapper(bl_mat_wrap.bl_mat, out_node=bl_transparent)
@@ -528,7 +528,7 @@ def write_mi_mask_bsdf(mi_context, mi_mat, bl_mat_wrap, out_socket_id, mi_bump=N
528528
write_mi_float_property(mi_context, mi_mat, 'opacity', bl_mix_wrap, 'Fac', 0.5)
529529
# Add a transparent node to the top socket of the mix shader
530530
bl_mix_wrap.ensure_node_type(['Shader'], 'ShaderNodeBsdfTransparent', 'BSDF')
531-
write_mi_material_to_node_graph(mi_context, mi_child_mats[0], bl_mix_wrap, 'Shader_001', mi_bump=mi_bump, mi_normal=mi_normal)
531+
write_mi_material_to_node_graph(mi_context, mi_child_mat, bl_mix_wrap, 'Shader_001', mi_bump=mi_bump, mi_normal=mi_normal)
532532

533533
return True
534534

0 commit comments

Comments
 (0)