File: storm_render_tests.py

package info (click to toggle)
blender 5.0.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 329,128 kB
  • sloc: cpp: 2,489,823; python: 349,859; ansic: 261,364; xml: 2,103; sh: 999; javascript: 317; makefile: 193
file content (186 lines) | stat: -rw-r--r-- 5,606 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
#!/usr/bin/env python3
# SPDX-FileCopyrightText: 2015-2023 Blender Authors
#
# SPDX-License-Identifier: Apache-2.0

import argparse
import os
import sys
from pathlib import Path

# Unsupported or broken scenarios for the Storm render engine
BLOCKLIST_HYDRA = [
    # Corrupted output around borders
    "image.*_half.*.blend",
    "image.*_float.*.blend",
    # Differences between devices/drivers causing this to fail
    "image.blend",
    # VDB rendering is incorrect on Metal
    "overlapping_octrees.blend",
    # No number of sample support, so will not converge to gray as expected
    "white_noise_256spp.blend",
]

BLOCKLIST_USD = [
    # Corrupted output around borders
    "image.*_half.*.blend",
    "image.*_float.*.blend",
    # Nondeterministic exporting of lights in the scene
    "light_tree_node_subtended_angle.blend",
    # VDB rendering is incorrect on Metal
    "overlapping_octrees.blend",
    # No number of sample support, so will not converge to gray as expected
    "white_noise_256spp.blend",
]

# Metal support in Storm is no as good as OpenGL, though this needs to be
# retested with newer OpenUSD versions as there are improvements.
BLOCKLIST_METAL = [
    # Thinfilm
    "principled.*thinfilm.*.blend",
    "metallic.*thinfilm.*.blend",
    # Transparency
    "transparent.blend",
    "transparent_shadow.blend",
    "transparent_shadow_hair.blend",
    "transparent_shadow_hair_blur.blend",
    "shadow_all_max_bounces.blend",
    "underwater_caustics.blend",
    "shadow_link_transparency.blend",
    "principled_bsdf_transmission.blend",
    "light_path_is_shadow_ray.blend",
    "light_path_is_transmission_ray.blend",
    "light_path_ray_depth.blend",
    "light_path_ray_length.blend",
    "transparent_spatial_splits.blend",
    # Volume
    "light_link_surface_in_volume.blend",
    "openvdb.*.blend",
    "principled_bsdf_interior",
    # Other
    "autosmooth_custom_normals.blend",
]

# AMD seems to have similar limitations as Metal for transparency.
BLOCKLIST_AMD = BLOCKLIST_METAL + [
    "volume_tricubic_interpolation.blend",
]

# Minor difference in texture coordinate for white noise hash.
BLOCKLIST_INTEL = [
    "hair_reflection.blend",
    "hair_transmission.blend",
    "principled_bsdf_emission.blend",
    "principled_bsdf_sheen.blend",
]


def setup():
    import bpy
    import addon_utils

    addon_utils.enable("hydra_storm")

    for scene in bpy.data.scenes:
        scene.render.engine = 'HYDRA_STORM'
        scene.hydra.export_method = os.environ['BLENDER_HYDRA_EXPORT_METHOD']


# When run from inside Blender, render and exit.
try:
    import bpy
    inside_blender = True
except ImportError:
    inside_blender = False

if inside_blender:
    try:
        setup()
    except Exception as e:
        print(e)
        sys.exit(1)


def get_arguments(filepath, output_filepath):
    return [
        "--background",
        "--factory-startup",
        "--enable-autoexec",
        "--debug-memory",
        "--debug-exit-on-error",
        filepath,
        "-P",
        os.path.realpath(__file__),
        "-o", output_filepath,
        "-F", "PNG",
        "-f", "1"]


def create_argparse():
    parser = argparse.ArgumentParser(
        description="Run test script for each blend file in TESTDIR, comparing the render result with known output."
    )
    parser.add_argument("--blender", required=True)
    parser.add_argument("--testdir", required=True)
    parser.add_argument("--outdir", required=True)
    parser.add_argument("--oiiotool", required=True)
    parser.add_argument("--export_method", required=True)
    parser.add_argument('--batch', default=False, action='store_true')
    return parser


def main():
    parser = create_argparse()
    args = parser.parse_args()

    from modules import render_report

    if sys.platform == "darwin":
        blocklist = BLOCKLIST_METAL
    else:
        gpu_vendor = render_report.get_gpu_device_vendor(args.blender)
        if gpu_vendor == "AMD":
            blocklist = BLOCKLIST_AMD
        elif gpu_vendor == "INTEL":
            blocklist = BLOCKLIST_INTEL
        else:
            blocklist = []

    if args.export_method == 'HYDRA':
        report = render_report.Report("Storm Hydra", args.outdir, args.oiiotool, blocklist=blocklist + BLOCKLIST_HYDRA)
        report.set_reference_dir("storm_hydra_renders")
        report.set_compare_engine('cycles', 'CPU')
    else:
        report = render_report.Report("Storm USD", args.outdir, args.oiiotool, blocklist=blocklist + BLOCKLIST_USD)
        report.set_reference_dir("storm_usd_renders")
        report.set_compare_engine('storm_hydra')

    report.set_pixelated(True)

    # Try to account for image filtering differences from OS/drivers
    test_dir_name = Path(args.testdir).name
    if (test_dir_name in {'image_mapping'}):
        report.set_fail_threshold(0.028)
        report.set_fail_percent(1.3)
    if (test_dir_name in {'image_colorspace'}):
        report.set_fail_threshold(0.032)
        report.set_fail_percent(1.5)
    if (test_dir_name in {'mesh'}):
        report.set_fail_threshold(0.036)
        report.set_fail_percent(1.3)
    if (test_dir_name in {'sss', 'hair'}):
        # Ignore differences in rasterization of hair on Mesa drivers
        report.set_fail_threshold(0.02)
        report.set_fail_percent(1.8)

    test_dir_name = Path(args.testdir).name

    os.environ['BLENDER_HYDRA_EXPORT_METHOD'] = args.export_method

    ok = report.run(args.testdir, args.blender, get_arguments, batch=args.batch)

    sys.exit(not ok)


if not inside_blender and __name__ == "__main__":
    main()