Repository navigation
OSL render tests: match MaterialXTest's OSL settings - #86
Merged
Merged
Conversation
Add Python bindings for OslRenderer.setEnvShaderParameterOverrides, setDataLibraryOSOPath, useOslCommandString, setAaLit, setAaUnlit and setOSLCmdStr, and for GenOptions.oslConnectCiWrapper. These are the settings MaterialXTest's OSL render tests use, so Python drivers of OslRenderer can reproduce its renders.
Test documents reference images relative to the repo root, e.g. "resources/Images/grid.png", which MaterialXTest resolves against its data root. The pytest search path didn't include the repo root, so these only loaded when pytest ran from the repo root: ImageHandler falls back to the working directory, but OSL's testrender received the bare relative path and rendered without the texture.
Use the new OslRenderer and GenOptions bindings so OSL renders match MaterialXTest's [renderosl] output: - -aa 2 for lit and 1 for unlit outputs, as MaterialXTest's non-reference-quality renders. - The radiance map as an environment shader override, replacing the patched copies of the utility shaders, which are now compiled straight from the repo. - oslConnectCiWrapper, so color4 and vector4 alpha renders as transparency. - No fileTextureVerticalFlip, which MaterialXTest doesn't set for OSL; with it, textures rendered upside down relative to MaterialXTest. The tangent and bitangent overrides MaterialXTest registers for testrender are C++ ShaderNodeImpl subclasses and remain a known difference.
Regenerated with oslConnectCiWrapper, which adds the mx_set_ci terminal node, and without fileTextureVerticalFlip, which drops the V flip from mx_transform_uv.
Substitute MaterialXTest's TangentOsl and BitangentOsl expressions for the inline source of the stdlib genosl tangent and bitangent implementations, since Python can't register ShaderNodeImpls. With this, all 143 OSL renders are pixel-identical to MaterialXTest's.
There was a problem hiding this comment.
🟢 Approval recommended
The focused bindings and backend changes align with the existing C++ render-test behavior, with consistent regenerated baselines and no unresolved blocking findings.
No open issues 🎉
What changed in this PR
Aligns the pytest OSL backend with MaterialXTest’s render settings, completing the follow-up to #85 and replacing earlier rendering workarounds.
Changes:
- Exposes additional OSL renderer settings and
oslConnectCiWrapperthrough Python bindings. - Matches sampling, environment-map, texture-orientation, and tangent-frame settings; adds repository-root image lookup.
- Regenerates OSL shader baselines and documents the updated behavior.
| File | Description |
|---|---|
| source/PyMaterialX/PyMaterialXRenderOsl/PyOslRenderer.cpp | Exposes additional renderer controls to Python. |
| source/PyMaterialX/PyMaterialXGenShader/PyGenOptions.cpp | Exposes the Ci-wrapper generation option. |
| contrib/tests/rendertest/backends.py | Aligns OSL generation and rendering settings. |
| contrib/tests/README.md | Documents matching settings and tangent overrides. |
| contrib/tests/conftest.py | Adds repository-root image lookup. |
| contrib/renders/aswf/vertical_layering/vertical_layering_ex5_out.osl | Updates Ci wrapper and tangent frame. |
| contrib/renders/aswf/vertical_layering/vertical_layering_ex2_out.osl | Updates Ci wrapper and tangent frame. |
| contrib/renders/aswf/translucent_bsdf/translucent_bsdf_out.osl | Adds Ci-wrapper baseline. |
| contrib/renders/aswf/toon_shade/surfacematerial.osl | Adds Ci-wrapper baseline. |
| contrib/renders/aswf/subsurface_bsdf/subsurface_4_forward_out.osl | Adds Ci-wrapper baseline. |
| contrib/renders/aswf/subsurface_bsdf/subsurface_4_backward_out.osl | Adds Ci-wrapper baseline. |
| contrib/renders/aswf/subsurface_bsdf/subsurface_3_weighted_out.osl | Adds Ci-wrapper baseline. |
| contrib/renders/aswf/subsurface_bsdf/subsurface_2_radius_5_0_out.osl | Adds Ci-wrapper baseline. |
| contrib/renders/aswf/subsurface_bsdf/subsurface_2_radius_0_025_out.osl | Adds Ci-wrapper baseline. |
| contrib/renders/aswf/subsurface_bsdf/subsurface_2_radius_0_01_out.osl | Adds Ci-wrapper baseline. |
| contrib/renders/aswf/subsurface_bsdf/subsurface_1_common_out.osl | Adds Ci-wrapper baseline. |
| contrib/renders/aswf/starfield/starfield_out.osl | Wraps color output as a closure. |
| contrib/renders/aswf/sheen_bsdf/zeltner_sheen_out.osl | Adds Ci-wrapper baseline. |
| contrib/renders/aswf/sheen_bsdf/conty_kulla_sheen_out.osl | Adds Ci-wrapper baseline. |
| contrib/renders/aswf/oren_nayar_diffuse/oren_nayar_diffuse_out5.osl | Adds Ci-wrapper baseline. |
| contrib/renders/aswf/oren_nayar_diffuse/oren_nayar_diffuse_out4.osl | Adds Ci-wrapper baseline. |
| contrib/renders/aswf/oren_nayar_diffuse/oren_nayar_diffuse_out3.osl | Adds Ci-wrapper baseline. |
| contrib/renders/aswf/oren_nayar_diffuse/oren_nayar_diffuse_out2.osl | Adds Ci-wrapper baseline. |
| contrib/renders/aswf/oren_nayar_diffuse/oren_nayar_diffuse_out1.osl | Adds Ci-wrapper baseline. |
| contrib/renders/aswf/multiply_bsdf/multiply_bsdf_test_out.osl | Adds Ci-wrapper baseline. |
| contrib/renders/aswf/mix_bsdf/mix_bsdf_test3_out.osl | Adds Ci-wrapper baseline. |
| contrib/renders/aswf/mix_bsdf/mix_bsdf_test1_out.osl | Adds Ci-wrapper baseline. |
| contrib/renders/aswf/mix_bsdf/IMP_substrateshader_out.osl | Adds Ci-wrapper baseline. |
| contrib/renders/aswf/layer_bsdf/layer_bsdf_test2_out.osl | Updates Ci wrapper and tangent frame. |
| contrib/renders/aswf/heighttonormal/NG_heighttonormal_vec_out.osl | Updates texture orientation and wraps vector output. |
| contrib/renders/aswf/gooch_shade/redblue_gooch_material.osl | Adds Ci-wrapper baseline. |
| contrib/renders/aswf/gooch_shade/default_gooch_material.osl | Adds Ci-wrapper baseline. |
| contrib/renders/aswf/generalized_schlick/schlick_bsdf_T_out.osl | Updates Ci wrapper and tangent frame. |
| contrib/renders/aswf/generalized_schlick/schlick_bsdf_RT_out.osl | Updates Ci wrapper and tangent frame. |
| contrib/renders/aswf/generalized_schlick/schlick_bsdf_R_out.osl | Updates Ci wrapper and tangent frame. |
| contrib/renders/aswf/edge_brighten/edge_brighten_out.osl | Wraps color output as a closure. |
| contrib/renders/aswf/dielectric/dielectric_bsdf_T_out.osl | Updates Ci wrapper and tangent frame. |
| contrib/renders/aswf/dielectric/dielectric_bsdf_RT_out.osl | Updates Ci wrapper and tangent frame. |
| contrib/renders/aswf/dielectric/dielectric_bsdf_R_out.osl | Updates Ci wrapper and tangent frame. |
| contrib/renders/aswf/dielectric/dielectric_bsdf_layer_RT_out.osl | Updates Ci wrapper and tangent frame. |
| contrib/renders/aswf/conductor/test_conductor_out.osl | Updates Ci wrapper and tangent frame. |
| contrib/renders/aswf/color3_vec3_cm_test/height_to_normal_cm_out.osl | Updates texture orientation and wraps vector output. |
| contrib/renders/aswf/burley_diffuse/test_burley_diffuse_out.osl | Adds Ci-wrapper baseline. |
| contrib/renders/aswf/bsdf_graph/test_mybsdf_out.osl | Updates Ci wrapper and tangent frame. |
| contrib/renders/aswf/blur/blur_vector3_out.osl | Updates texture orientation and wraps vector output. |
| contrib/renders/aswf/blur/blur_vector2_out.osl | Updates texture orientation and wraps vector output. |
| contrib/renders/aswf/blur/blur_float_out.osl | Updates texture orientation and wraps scalar output. |
| contrib/renders/aswf/blur/blur_color4_out.osl | Updates texture orientation and wraps color output. |
| contrib/renders/aswf/blur/blur_color3_out.osl | Updates texture orientation and wraps color output. |
| contrib/renders/aswf/blur/blur_cellnoise_out.osl | Wraps scalar output as a closure. |
| contrib/renders/aswf/blackbody/Blackbody.osl | Adds Ci-wrapper baseline. |
| contrib/renders/aswf/add_bsdf/add_bsdf_test_out.osl | Updates Ci wrapper and tangent frame. |
| contrib/renders/adsk/Examples/Revit/other/turbulence3d_object_out.osl | Wraps scalar output as a closure. |
| contrib/renders/adsk/Examples/Revit/other/turbulence2d_object_out.osl | Wraps scalar output as a closure. |
| contrib/renders/adsk/Examples/Revit/mirror/M_legacy_mirror.osl | Updates Ci wrapper and tangent frame. |
| contrib/renders/adsk/Examples/Revit/glazing/M_legacy_glazing.osl | Updates Ci wrapper and tangent frame. |
| contrib/renders/adsk/Examples/Fusion/transparent/Gemstone_Ruby.osl | Updates Ci wrapper and tangent frame. |
| contrib/renders/adsk/Examples/Fusion/transparent/Gemstone_Diamond.osl | Updates Ci wrapper and tangent frame. |
| contrib/renders/adsk/Examples/Fusion/metal/Copper_Polished.osl | Updates Ci wrapper and tangent frame. |
| contrib/renders/adsk/Examples/Fusion/metal/Anodized_Red_Rough.osl | Updates Ci wrapper and tangent frame. |
| contrib/renders/adsk/Examples/Fusion/metal/Anodized_Blue_Glossy.osl | Updates Ci wrapper and tangent frame. |
| contrib/renders/adsk/Examples/Fusion/glazing/Glazing_test.osl | Updates Ci wrapper and tangent frame. |
| contrib/renders/adsk/Examples/Fusion/bitmap/bitmapoutput.osl | Updates texture orientation and wraps color output. |
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Makes the pytest OSL backend render exactly like MaterialXTest's
[renderosl]tests. All 143 OSL renders undercontrib/renders/aswfare now pixel-identical to MaterialXTest's.Follows up on #85.
Commits
Split so each can be cherry-picked upstream on its own:
OslRendererand OSLGenOptionssettings in Python. AddssetEnvShaderParameterOverrides,setDataLibraryOSOPath,useOslCommandString,setAaLit,setAaUnlit,setOSLCmdStrandGenOptions.oslConnectCiWrapper. This is the only C++ change and a candidate for upstreaming.resources/Images/grid.pngrelative to the repo root, so thesearch_pathfixture now includes the repo root. Before this, testrender rendered those textures as missing.-aa2 for lit and 1 for unlit rendersenvmap_filenameas an environment shader overrideoslConnectCiWrapperfileTextureVerticalFlipmx_set_ciand removes themx_transform_uvV-flip.TangentOsl/BitangentOslnode implementations. Python can't register those, so the OSL backend puts the same expressions into the inline source of the stdlibgenosltangent and bitangent implementations. Only those two OSL implementations are affected.Verification
python -m pytest contrib/tests -m osl -n 8: 100 passed.[renderosl](Debug) withoutputDirectoryset in the build copy of_options.mtlx. It writes the same flat<stem>/layout ascontrib/renders/aswf, sotests_to_html.py -i1 contrib/renders/aswf -i2 <MaterialXTest output> -l1 osl -l2 osl -dpairs all 143 images directly, with no adapter.Known limitation
OslRendererdoesn't quote paths in its oslc and testrender command lines, so the backend still rejects paths containing spaces (AcademySoftwareFoundation#3120).