From c78738087b9d83df9518abf984c46c53c883ef9b Mon Sep 17 00:00:00 2001 From: Bogdan Nagirniak Date: Wed, 7 Sep 2022 16:15:24 +0300 Subject: [PATCH 01/28] Create basic MaterialX addon: - Created basic structure of MaterialX addon - Added MxNode related classes, generate_node_classes.py, categories.py. - Added preferences.py, node_tree.py - Added basic UI for MX node tree - Added materialx libraries --- materialx/__init__.py | 45 + materialx/libraries/README.md | 70 + materialx/libraries/alglib/alglib_defs.mtlx | 93 + materialx/libraries/alglib/alglib_ng.mtlx | 518 ++ .../libraries/bxdf/disney_brdf_2012.mtlx | 18 + .../libraries/bxdf/disney_brdf_2015.mtlx | 25 + .../libraries/bxdf/standard_surface.mtlx | 327 ++ .../libraries/bxdf/usd_preview_surface.mtlx | 335 ++ .../lights/genglsl/lights_genglsl_impl.mtlx | 13 + .../lights/genglsl/mx_directional_light.glsl | 5 + .../lights/genglsl/mx_point_light.glsl | 8 + .../lights/genglsl/mx_spot_light.glsl | 13 + materialx/libraries/lights/lights_defs.mtlx | 57 + .../pbrlib/genglsl/lib/mx_defines.glsl | 4 + .../genglsl/lib/mx_environment_fis.glsl | 72 + .../genglsl/lib/mx_environment_none.glsl | 11 + .../genglsl/lib/mx_environment_prefilter.glsl | 29 + .../libraries/pbrlib/genglsl/lib/mx_math.glsl | 83 + .../pbrlib/genglsl/lib/mx_microfacet.glsl | 57 + .../genglsl/lib/mx_microfacet_diffuse.glsl | 84 + .../genglsl/lib/mx_microfacet_sheen.glsl | 52 + .../genglsl/lib/mx_microfacet_specular.glsl | 386 ++ .../genglsl/lib/mx_refraction_index.glsl | 31 + .../pbrlib/genglsl/lib/mx_shadow.glsl | 23 + .../pbrlib/genglsl/lib/mx_table.glsl | 7 + .../libraries/pbrlib/genglsl/mx_add_bsdf.glsl | 14 + .../libraries/pbrlib/genglsl/mx_add_edf.glsl | 4 + .../pbrlib/genglsl/mx_artistic_ior.glsl | 6 + .../genglsl/mx_burley_diffuse_bsdf.glsl | 35 + .../pbrlib/genglsl/mx_conductor_bsdf.glsl | 55 + .../pbrlib/genglsl/mx_dielectric_bsdf.glsl | 96 + .../genglsl/mx_generalized_schlick_bsdf.glsl | 86 + .../libraries/pbrlib/genglsl/mx_mix_bsdf.glsl | 14 + .../libraries/pbrlib/genglsl/mx_mix_edf.glsl | 4 + .../genglsl/mx_multiply_bsdf_color.glsl | 14 + .../genglsl/mx_multiply_bsdf_float.glsl | 14 + .../pbrlib/genglsl/mx_multiply_edf_color.glsl | 4 + .../pbrlib/genglsl/mx_multiply_edf_float.glsl | 4 + .../genglsl/mx_oren_nayar_diffuse_bsdf.glsl | 34 + .../genglsl/mx_roughness_anisotropy.glsl | 15 + .../pbrlib/genglsl/mx_roughness_dual.glsl | 9 + .../pbrlib/genglsl/mx_sheen_bsdf.glsl | 50 + .../pbrlib/genglsl/mx_subsurface_bsdf.glsl | 32 + .../pbrlib/genglsl/mx_translucent_bsdf.glsl | 27 + .../pbrlib/genglsl/mx_uniform_edf.glsl | 4 + .../pbrlib/genglsl/pbrlib_genglsl_impl.mtlx | 66 + .../pbrlib/genmdl/pbrlib_genmdl_impl.mtlx | 92 + .../pbrlib/genosl/lib/mx_microfacet.osl | 125 + .../genosl/lib/mx_microfacet_specular.osl | 116 + .../pbrlib/genosl/lib/mx_refraction_index.osl | 31 + .../libraries/pbrlib/genosl/mx_add.inline | 1 + .../pbrlib/genosl/mx_artistic_ior.osl | 6 + .../pbrlib/genosl/mx_burley_diffuse_bsdf.osl | 5 + .../pbrlib/genosl/mx_conductor_bsdf.osl | 29 + .../pbrlib/genosl/mx_dielectric_bsdf.osl | 35 + .../pbrlib/genosl/mx_displacement_float.osl | 4 + .../pbrlib/genosl/mx_displacement_vector3.osl | 4 + .../genosl/mx_generalized_schlick_bsdf.osl | 32 + .../libraries/pbrlib/genosl/mx_mix.inline | 1 + .../pbrlib/genosl/mx_multiply_bsdf.inline | 1 + .../pbrlib/genosl/mx_multiply_edf.inline | 1 + .../genosl/mx_oren_nayar_diffuse_bsdf.inline | 1 + .../pbrlib/genosl/mx_roughness_anisotropy.osl | 15 + .../pbrlib/genosl/mx_roughness_dual.osl | 12 + .../libraries/pbrlib/genosl/mx_sheen_bsdf.osl | 61 + .../pbrlib/genosl/mx_subsurface_bsdf.osl | 5 + .../libraries/pbrlib/genosl/mx_surface.osl | 5 + .../pbrlib/genosl/mx_translucent_bsdf.inline | 1 + .../pbrlib/genosl/mx_uniform_edf.inline | 1 + .../pbrlib/genosl/pbrlib_genosl_impl.mtlx | 67 + materialx/libraries/pbrlib/pbrlib_defs.mtlx | 397 ++ materialx/libraries/pbrlib/pbrlib_ng.mtlx | 22 + .../libraries/stdlib/genglsl/lib/mx_hsv.glsl | 91 + .../stdlib/genglsl/lib/mx_noise.glsl | 321 ++ .../stdlib/genglsl/lib/mx_sampling.glsl | 91 + .../stdlib/genglsl/lib/mx_transform_uv.glsl | 5 + .../genglsl/lib/mx_transform_uv_vflip.glsl | 5 + .../libraries/stdlib/genglsl/mx_aastep.glsl | 5 + .../libraries/stdlib/genglsl/mx_absval.inline | 1 + .../genglsl/mx_acescg_to_linear_color3.glsl | 5 + .../genglsl/mx_acescg_to_linear_color4.glsl | 5 + .../libraries/stdlib/genglsl/mx_acos.inline | 1 + .../libraries/stdlib/genglsl/mx_add.inline | 1 + .../stdlib/genglsl/mx_add_surfaceshader.glsl | 5 + .../libraries/stdlib/genglsl/mx_asin.inline | 1 + .../libraries/stdlib/genglsl/mx_atan2.inline | 1 + .../stdlib/genglsl/mx_burn_color3.glsl | 8 + .../stdlib/genglsl/mx_burn_color4.glsl | 9 + .../stdlib/genglsl/mx_burn_float.glsl | 9 + .../libraries/stdlib/genglsl/mx_ceil.inline | 1 + .../stdlib/genglsl/mx_cellnoise2d_float.glsl | 6 + .../stdlib/genglsl/mx_cellnoise3d_float.glsl | 6 + .../libraries/stdlib/genglsl/mx_clamp.inline | 1 + .../stdlib/genglsl/mx_constant.inline | 1 + .../libraries/stdlib/genglsl/mx_cos.inline | 1 + .../stdlib/genglsl/mx_crossproduct.inline | 1 + .../stdlib/genglsl/mx_determinant.inline | 1 + .../stdlib/genglsl/mx_difference.inline | 1 + .../genglsl/mx_disjointover_color4.glsl | 25 + .../libraries/stdlib/genglsl/mx_divide.inline | 1 + .../libraries/stdlib/genglsl/mx_dodge.inline | 1 + .../stdlib/genglsl/mx_dodge_color3.glsl | 8 + .../stdlib/genglsl/mx_dodge_color4.glsl | 9 + .../stdlib/genglsl/mx_dodge_float.glsl | 9 + .../libraries/stdlib/genglsl/mx_dot.inline | 1 + .../stdlib/genglsl/mx_dotproduct.inline | 1 + .../libraries/stdlib/genglsl/mx_exp.inline | 1 + .../libraries/stdlib/genglsl/mx_floor.inline | 1 + .../genglsl/mx_fractal3d_fa_vector2.glsl | 7 + .../genglsl/mx_fractal3d_fa_vector3.glsl | 7 + .../genglsl/mx_fractal3d_fa_vector4.glsl | 8 + .../stdlib/genglsl/mx_fractal3d_float.glsl | 7 + .../stdlib/genglsl/mx_fractal3d_vector2.glsl | 7 + .../stdlib/genglsl/mx_fractal3d_vector3.glsl | 7 + .../stdlib/genglsl/mx_fractal3d_vector4.glsl | 8 + .../mx_g22_ap1_to_lin_rec709_color3.glsl | 6 + .../mx_g22_ap1_to_lin_rec709_color4.glsl | 6 + .../genglsl/mx_gamma18_to_linear_color3.glsl | 5 + .../genglsl/mx_gamma18_to_linear_color4.glsl | 5 + .../genglsl/mx_gamma22_to_linear_color3.glsl | 5 + .../genglsl/mx_gamma22_to_linear_color4.glsl | 5 + .../genglsl/mx_gamma24_to_linear_color3.glsl | 5 + .../genglsl/mx_gamma24_to_linear_color4.glsl | 5 + .../stdlib/genglsl/mx_hsvtorgb_color3.glsl | 6 + .../stdlib/genglsl/mx_hsvtorgb_color4.glsl | 6 + .../stdlib/genglsl/mx_image_color3.glsl | 14 + .../stdlib/genglsl/mx_image_color4.glsl | 14 + .../stdlib/genglsl/mx_image_float.glsl | 14 + .../stdlib/genglsl/mx_image_vector2.glsl | 14 + .../stdlib/genglsl/mx_image_vector3.glsl | 14 + .../stdlib/genglsl/mx_image_vector4.glsl | 14 + .../stdlib/genglsl/mx_in_color4.inline | 1 + .../libraries/stdlib/genglsl/mx_inside.inline | 1 + .../libraries/stdlib/genglsl/mx_invert.inline | 1 + .../stdlib/genglsl/mx_invertM.inline | 1 + .../libraries/stdlib/genglsl/mx_ln.inline | 1 + .../stdlib/genglsl/mx_luminance_color3.glsl | 4 + .../stdlib/genglsl/mx_luminance_color4.glsl | 4 + .../stdlib/genglsl/mx_magnitude.inline | 1 + .../stdlib/genglsl/mx_mask_color4.inline | 1 + .../stdlib/genglsl/mx_matte_color4.inline | 1 + .../libraries/stdlib/genglsl/mx_max.inline | 1 + .../libraries/stdlib/genglsl/mx_min.inline | 1 + .../libraries/stdlib/genglsl/mx_minus.inline | 1 + .../libraries/stdlib/genglsl/mx_mix.inline | 1 + .../stdlib/genglsl/mx_mix_surfaceshader.glsl | 5 + .../libraries/stdlib/genglsl/mx_modulo.inline | 1 + .../stdlib/genglsl/mx_multiply.inline | 1 + .../mx_multiply_surfaceshader_color3.glsl | 5 + .../mx_multiply_surfaceshader_float.glsl | 5 + .../stdlib/genglsl/mx_noise2d_fa_vector2.glsl | 7 + .../stdlib/genglsl/mx_noise2d_fa_vector3.glsl | 7 + .../stdlib/genglsl/mx_noise2d_fa_vector4.glsl | 8 + .../stdlib/genglsl/mx_noise2d_float.glsl | 7 + .../stdlib/genglsl/mx_noise2d_vector2.glsl | 7 + .../stdlib/genglsl/mx_noise2d_vector3.glsl | 7 + .../stdlib/genglsl/mx_noise2d_vector4.glsl | 8 + .../stdlib/genglsl/mx_noise3d_fa_vector2.glsl | 7 + .../stdlib/genglsl/mx_noise3d_fa_vector3.glsl | 7 + .../stdlib/genglsl/mx_noise3d_fa_vector4.glsl | 8 + .../stdlib/genglsl/mx_noise3d_float.glsl | 7 + .../stdlib/genglsl/mx_noise3d_vector2.glsl | 7 + .../stdlib/genglsl/mx_noise3d_vector3.glsl | 7 + .../stdlib/genglsl/mx_noise3d_vector4.glsl | 8 + .../stdlib/genglsl/mx_normalize.inline | 1 + .../stdlib/genglsl/mx_normalmap.glsl | 16 + .../stdlib/genglsl/mx_out_color2.inline | 1 + .../stdlib/genglsl/mx_out_color4.inline | 1 + .../stdlib/genglsl/mx_outside.inline | 1 + .../stdlib/genglsl/mx_over_color2.inline | 1 + .../stdlib/genglsl/mx_over_color4.inline | 1 + .../libraries/stdlib/genglsl/mx_overlay.glsl | 25 + .../stdlib/genglsl/mx_overlay_color3.glsl | 6 + .../stdlib/genglsl/mx_overlay_color4.glsl | 6 + .../stdlib/genglsl/mx_overlay_float.inline | 1 + .../libraries/stdlib/genglsl/mx_plus.inline | 1 + .../libraries/stdlib/genglsl/mx_power.inline | 1 + .../genglsl/mx_power_color3_float.inline | 1 + .../genglsl/mx_power_color4_float.inline | 1 + .../genglsl/mx_power_vector2_float.inline | 1 + .../genglsl/mx_power_vector3_float.inline | 1 + .../genglsl/mx_power_vector4_float.inline | 1 + .../stdlib/genglsl/mx_premult_color4.glsl | 4 + .../stdlib/genglsl/mx_ramplr_float.glsl | 4 + .../stdlib/genglsl/mx_ramplr_vector2.glsl | 4 + .../stdlib/genglsl/mx_ramplr_vector3.glsl | 4 + .../stdlib/genglsl/mx_ramplr_vector4.glsl | 4 + .../stdlib/genglsl/mx_ramptb_float.glsl | 4 + .../stdlib/genglsl/mx_ramptb_vector2.glsl | 4 + .../stdlib/genglsl/mx_ramptb_vector3.glsl | 4 + .../stdlib/genglsl/mx_ramptb_vector4.glsl | 4 + .../libraries/stdlib/genglsl/mx_remap.inline | 1 + .../stdlib/genglsl/mx_rgbtohsv_color3.glsl | 6 + .../stdlib/genglsl/mx_rgbtohsv_color4.glsl | 6 + .../stdlib/genglsl/mx_rotate_vector2.glsl | 7 + .../stdlib/genglsl/mx_rotate_vector3.glsl | 19 + .../libraries/stdlib/genglsl/mx_screen.inline | 1 + .../libraries/stdlib/genglsl/mx_sign.inline | 1 + .../libraries/stdlib/genglsl/mx_sin.inline | 1 + .../stdlib/genglsl/mx_smoothstep_float.glsl | 9 + .../stdlib/genglsl/mx_smoothstep_vec2.glsl | 7 + .../stdlib/genglsl/mx_smoothstep_vec2FA.glsl | 7 + .../stdlib/genglsl/mx_smoothstep_vec3.glsl | 8 + .../stdlib/genglsl/mx_smoothstep_vec3FA.glsl | 8 + .../stdlib/genglsl/mx_smoothstep_vec4.glsl | 9 + .../stdlib/genglsl/mx_smoothstep_vec4FA.glsl | 9 + .../stdlib/genglsl/mx_splitlr_float.glsl | 6 + .../stdlib/genglsl/mx_splitlr_vector2.glsl | 6 + .../stdlib/genglsl/mx_splitlr_vector3.glsl | 6 + .../stdlib/genglsl/mx_splitlr_vector4.glsl | 6 + .../stdlib/genglsl/mx_splittb_float.glsl | 6 + .../stdlib/genglsl/mx_splittb_vector2.glsl | 6 + .../stdlib/genglsl/mx_splittb_vector3.glsl | 6 + .../stdlib/genglsl/mx_splittb_vector4.glsl | 6 + .../libraries/stdlib/genglsl/mx_sqrt.inline | 1 + .../mx_srgb_texture_to_linear_color3.glsl | 13 + .../mx_srgb_texture_to_linear_color4.glsl | 13 + .../stdlib/genglsl/mx_subtract.inline | 1 + .../libraries/stdlib/genglsl/mx_tan.inline | 1 + .../stdlib/genglsl/mx_transformmatrix.inline | 1 + .../genglsl/mx_transformmatrix_vector2M3.glsl | 5 + .../genglsl/mx_transformmatrix_vector3M4.glsl | 5 + .../stdlib/genglsl/mx_transpose.inline | 1 + .../stdlib/genglsl/mx_unpremult_color4.glsl | 4 + .../genglsl/stdlib_genglsl_cm_impl.mtlx | 24 + .../stdlib/genglsl/stdlib_genglsl_impl.mtlx | 769 +++ .../genglsl/stdlib_genglsl_unit_impl.mtlx | 18 + .../stdlib/genmdl/stdlib_genmdl_cm_impl.mtlx | 24 + .../stdlib/genmdl/stdlib_genmdl_impl.mtlx | 773 +++ .../genmdl/stdlib_genmdl_unit_impl.mtlx | 18 + .../stdlib/genosl/lib/mx_sampling.osl | 150 + .../stdlib/genosl/lib/mx_transform_uv.osl | 4 + .../genosl/lib/mx_transform_uv_vflip.osl | 4 + .../libraries/stdlib/genosl/mx_absval.inline | 1 + .../genosl/mx_acescg_to_linear_color3.osl | 7 + .../genosl/mx_acescg_to_linear_color4.osl | 7 + .../libraries/stdlib/genosl/mx_acos.inline | 1 + .../libraries/stdlib/genosl/mx_add.inline | 1 + .../genosl/mx_ambientocclusion_float.osl | 5 + .../libraries/stdlib/genosl/mx_asin.inline | 1 + .../libraries/stdlib/genosl/mx_atan2.inline | 1 + .../stdlib/genosl/mx_bitangent_vector3.inline | 1 + .../stdlib/genosl/mx_burn_color3.osl | 8 + .../stdlib/genosl/mx_burn_color4.osl | 9 + .../libraries/stdlib/genosl/mx_burn_float.osl | 9 + .../libraries/stdlib/genosl/mx_ceil.inline | 1 + .../stdlib/genosl/mx_cellnoise2d_float.osl | 4 + .../stdlib/genosl/mx_cellnoise3d_float.osl | 4 + .../libraries/stdlib/genosl/mx_clamp.inline | 1 + .../stdlib/genosl/mx_constant.inline | 1 + .../stdlib/genosl/mx_contrast.inline | 1 + .../libraries/stdlib/genosl/mx_cos.inline | 1 + .../stdlib/genosl/mx_crossproduct.inline | 1 + .../stdlib/genosl/mx_determinant.inline | 1 + .../stdlib/genosl/mx_difference.inline | 1 + .../stdlib/genosl/mx_disjointover_color4.osl | 25 + .../libraries/stdlib/genosl/mx_divide.inline | 1 + .../stdlib/genosl/mx_dodge_color3.osl | 8 + .../stdlib/genosl/mx_dodge_color4.osl | 9 + .../stdlib/genosl/mx_dodge_float.osl | 9 + .../libraries/stdlib/genosl/mx_dot.inline | 1 + .../stdlib/genosl/mx_dotproduct.inline | 1 + .../libraries/stdlib/genosl/mx_exp.inline | 1 + .../libraries/stdlib/genosl/mx_floor.inline | 1 + .../stdlib/genosl/mx_fractal3d_color3.osl | 5 + .../stdlib/genosl/mx_fractal3d_color4.osl | 5 + .../stdlib/genosl/mx_fractal3d_fa_color3.osl | 5 + .../stdlib/genosl/mx_fractal3d_fa_color4.osl | 5 + .../stdlib/genosl/mx_fractal3d_fa_vector2.osl | 5 + .../stdlib/genosl/mx_fractal3d_fa_vector3.osl | 5 + .../stdlib/genosl/mx_fractal3d_fa_vector4.osl | 5 + .../stdlib/genosl/mx_fractal3d_float.osl | 5 + .../stdlib/genosl/mx_fractal3d_vector2.osl | 5 + .../stdlib/genosl/mx_fractal3d_vector3.osl | 5 + .../stdlib/genosl/mx_fractal3d_vector4.osl | 5 + .../stdlib/genosl/mx_frame_float.osl | 4 + .../mx_g22_ap1_to_lin_rec709_color3.osl | 11 + .../mx_g22_ap1_to_lin_rec709_color4.osl | 11 + .../genosl/mx_gamma18_to_linear_color3.osl | 5 + .../genosl/mx_gamma18_to_linear_color4.osl | 5 + .../genosl/mx_gamma22_to_linear_color3.osl | 5 + .../genosl/mx_gamma22_to_linear_color4.osl | 5 + .../genosl/mx_gamma24_to_linear_color3.osl | 5 + .../genosl/mx_gamma24_to_linear_color4.osl | 5 + .../stdlib/genosl/mx_geomcolor_color3.osl | 4 + .../stdlib/genosl/mx_geomcolor_color4.osl | 9 + .../stdlib/genosl/mx_geomcolor_float.osl | 4 + .../genosl/mx_geompropvalue_boolean.osl | 5 + .../stdlib/genosl/mx_geompropvalue_color3.osl | 5 + .../stdlib/genosl/mx_geompropvalue_color4.osl | 16 + .../stdlib/genosl/mx_geompropvalue_float.osl | 7 + .../genosl/mx_geompropvalue_integer.osl | 5 + .../stdlib/genosl/mx_geompropvalue_string.osl | 5 + .../genosl/mx_geompropvalue_vector2.osl | 13 + .../genosl/mx_geompropvalue_vector3.osl | 5 + .../genosl/mx_geompropvalue_vector4.osl | 15 + .../genosl/mx_heighttonormal_vector3.osl | 5 + .../stdlib/genosl/mx_hsvtorgb_color3.osl | 4 + .../stdlib/genosl/mx_hsvtorgb_color4.osl | 4 + .../stdlib/genosl/mx_image_color3.osl | 16 + .../stdlib/genosl/mx_image_color4.osl | 21 + .../stdlib/genosl/mx_image_float.osl | 17 + .../stdlib/genosl/mx_image_vector2.osl | 18 + .../stdlib/genosl/mx_image_vector3.osl | 16 + .../stdlib/genosl/mx_image_vector4.osl | 21 + .../libraries/stdlib/genosl/mx_in.inline | 1 + .../libraries/stdlib/genosl/mx_inside.inline | 1 + .../libraries/stdlib/genosl/mx_invert.inline | 1 + .../libraries/stdlib/genosl/mx_invertM.inline | 1 + .../libraries/stdlib/genosl/mx_ln.inline | 1 + .../stdlib/genosl/mx_luminance_color3.osl | 4 + .../stdlib/genosl/mx_luminance_color4.osl | 4 + .../stdlib/genosl/mx_magnitude.inline | 1 + .../libraries/stdlib/genosl/mx_mask.inline | 1 + .../stdlib/genosl/mx_matte_color4.inline | 1 + .../libraries/stdlib/genosl/mx_max.inline | 1 + .../libraries/stdlib/genosl/mx_min.inline | 1 + .../libraries/stdlib/genosl/mx_minus.inline | 1 + .../libraries/stdlib/genosl/mx_mix.inline | 1 + .../libraries/stdlib/genosl/mx_modulo.inline | 1 + .../stdlib/genosl/mx_modulo_color3FA.inline | 1 + .../stdlib/genosl/mx_modulo_vector3FA.inline | 1 + .../stdlib/genosl/mx_multiply.inline | 1 + .../stdlib/genosl/mx_noise2d_color3.osl | 5 + .../stdlib/genosl/mx_noise2d_color4.osl | 5 + .../stdlib/genosl/mx_noise2d_fa_color3.osl | 5 + .../stdlib/genosl/mx_noise2d_fa_color4.osl | 5 + .../stdlib/genosl/mx_noise2d_fa_vector2.osl | 5 + .../stdlib/genosl/mx_noise2d_fa_vector3.osl | 5 + .../stdlib/genosl/mx_noise2d_fa_vector4.osl | 5 + .../stdlib/genosl/mx_noise2d_float.osl | 5 + .../stdlib/genosl/mx_noise2d_vector2.osl | 5 + .../stdlib/genosl/mx_noise2d_vector3.osl | 5 + .../stdlib/genosl/mx_noise2d_vector4.osl | 5 + .../stdlib/genosl/mx_noise3d_color3.osl | 5 + .../stdlib/genosl/mx_noise3d_color4.osl | 5 + .../stdlib/genosl/mx_noise3d_fa_color3.osl | 5 + .../stdlib/genosl/mx_noise3d_fa_color4.osl | 5 + .../stdlib/genosl/mx_noise3d_fa_vector2.osl | 5 + .../stdlib/genosl/mx_noise3d_fa_vector3.osl | 5 + .../stdlib/genosl/mx_noise3d_fa_vector4.osl | 5 + .../stdlib/genosl/mx_noise3d_float.osl | 5 + .../stdlib/genosl/mx_noise3d_vector2.osl | 5 + .../stdlib/genosl/mx_noise3d_vector3.osl | 5 + .../stdlib/genosl/mx_noise3d_vector4.osl | 5 + .../stdlib/genosl/mx_normal_vector3.inline | 1 + .../stdlib/genosl/mx_normalize.inline | 1 + .../libraries/stdlib/genosl/mx_normalmap.osl | 17 + .../libraries/stdlib/genosl/mx_out.inline | 1 + .../libraries/stdlib/genosl/mx_outside.inline | 1 + .../libraries/stdlib/genosl/mx_over.inline | 1 + .../libraries/stdlib/genosl/mx_overlay.inline | 1 + .../stdlib/genosl/mx_overlay_color3.osl | 16 + .../stdlib/genosl/mx_overlay_color4.osl | 22 + .../libraries/stdlib/genosl/mx_plus.inline | 1 + .../stdlib/genosl/mx_position_vector3.inline | 1 + .../libraries/stdlib/genosl/mx_power.inline | 1 + .../stdlib/genosl/mx_premult_color4.osl | 4 + .../libraries/stdlib/genosl/mx_ramplr.inline | 1 + .../libraries/stdlib/genosl/mx_ramptb.inline | 1 + .../libraries/stdlib/genosl/mx_remap.inline | 1 + .../stdlib/genosl/mx_rgbtohsv_color3.osl | 4 + .../stdlib/genosl/mx_rgbtohsv_color4.osl | 4 + .../stdlib/genosl/mx_rotate_vector2.osl | 7 + .../stdlib/genosl/mx_rotate_vector3.osl | 20 + .../libraries/stdlib/genosl/mx_screen.inline | 1 + .../libraries/stdlib/genosl/mx_sign.inline | 1 + .../libraries/stdlib/genosl/mx_sin.inline | 1 + .../stdlib/genosl/mx_smoothstep.inline | 1 + .../libraries/stdlib/genosl/mx_splitlr.inline | 1 + .../libraries/stdlib/genosl/mx_splittb.inline | 1 + .../libraries/stdlib/genosl/mx_sqrt.inline | 1 + .../mx_srgb_texture_to_linear_color3.osl | 17 + .../mx_srgb_texture_to_linear_color4.osl | 19 + .../stdlib/genosl/mx_subtract.inline | 1 + .../libraries/stdlib/genosl/mx_tan.inline | 1 + .../stdlib/genosl/mx_tangent_vector3.inline | 1 + .../stdlib/genosl/mx_texcoord_vector2.inline | 1 + .../stdlib/genosl/mx_texcoord_vector3.inline | 1 + .../libraries/stdlib/genosl/mx_time_float.osl | 6 + .../stdlib/genosl/mx_transformmatrix.inline | 1 + .../genosl/mx_transformmatrix_vector2M3.osl | 6 + .../stdlib/genosl/mx_transformnormal.inline | 1 + .../stdlib/genosl/mx_transformpoint.inline | 1 + .../stdlib/genosl/mx_transformvector.inline | 1 + .../stdlib/genosl/mx_transpose.inline | 1 + .../stdlib/genosl/mx_unpremult_color4.osl | 4 + .../stdlib/genosl/stdlib_genosl_cm_impl.mtlx | 24 + .../stdlib/genosl/stdlib_genosl_impl.mtlx | 775 +++ .../genosl/stdlib_genosl_unit_impl.mtlx | 18 + materialx/libraries/stdlib/osl/README.md | 5 + materialx/libraries/stdlib/osl/color4.h | 332 ++ materialx/libraries/stdlib/osl/matrix33.h | 165 + .../libraries/stdlib/osl/mx_absval_color.osl | 17 + .../libraries/stdlib/osl/mx_absval_color4.osl | 17 + .../libraries/stdlib/osl/mx_absval_float.osl | 17 + .../libraries/stdlib/osl/mx_absval_vector.osl | 17 + .../stdlib/osl/mx_absval_vector2.osl | 17 + .../stdlib/osl/mx_absval_vector4.osl | 17 + .../libraries/stdlib/osl/mx_acos_color.osl | 17 + .../libraries/stdlib/osl/mx_acos_color4.osl | 17 + .../libraries/stdlib/osl/mx_acos_float.osl | 17 + .../libraries/stdlib/osl/mx_acos_vector.osl | 17 + .../libraries/stdlib/osl/mx_acos_vector2.osl | 17 + .../libraries/stdlib/osl/mx_acos_vector4.osl | 17 + .../libraries/stdlib/osl/mx_add_color.osl | 19 + .../libraries/stdlib/osl/mx_add_color4.osl | 19 + .../libraries/stdlib/osl/mx_add_float.osl | 19 + .../stdlib/osl/mx_add_float_color.osl | 18 + .../stdlib/osl/mx_add_float_color4.osl | 18 + .../stdlib/osl/mx_add_float_matrix33.osl | 18 + .../stdlib/osl/mx_add_float_matrix44.osl | 18 + .../stdlib/osl/mx_add_float_vector.osl | 18 + .../stdlib/osl/mx_add_float_vector2.osl | 18 + .../stdlib/osl/mx_add_float_vector4.osl | 18 + .../libraries/stdlib/osl/mx_add_matrix33.osl | 19 + .../libraries/stdlib/osl/mx_add_matrix44.osl | 19 + .../stdlib/osl/mx_add_surfaceshader.osl | 19 + .../libraries/stdlib/osl/mx_add_vector.osl | 19 + .../libraries/stdlib/osl/mx_add_vector2.osl | 19 + .../libraries/stdlib/osl/mx_add_vector4.osl | 19 + .../stdlib/osl/mx_ambientocclusion_float.osl | 19 + .../libraries/stdlib/osl/mx_asin_color.osl | 17 + .../libraries/stdlib/osl/mx_asin_color4.osl | 17 + .../libraries/stdlib/osl/mx_asin_float.osl | 17 + .../libraries/stdlib/osl/mx_asin_vector.osl | 17 + .../libraries/stdlib/osl/mx_asin_vector2.osl | 17 + .../libraries/stdlib/osl/mx_asin_vector4.osl | 17 + .../libraries/stdlib/osl/mx_atan2_color.osl | 19 + .../libraries/stdlib/osl/mx_atan2_color4.osl | 19 + .../libraries/stdlib/osl/mx_atan2_float.osl | 19 + .../stdlib/osl/mx_atan2_float_color.osl | 19 + .../stdlib/osl/mx_atan2_float_color4.osl | 19 + .../stdlib/osl/mx_atan2_float_vector.osl | 19 + .../stdlib/osl/mx_atan2_float_vector2.osl | 19 + .../stdlib/osl/mx_atan2_float_vector4.osl | 19 + .../libraries/stdlib/osl/mx_atan2_vector.osl | 19 + .../libraries/stdlib/osl/mx_atan2_vector2.osl | 19 + .../libraries/stdlib/osl/mx_atan2_vector4.osl | 19 + .../stdlib/osl/mx_bitangent_vector.osl | 17 + .../libraries/stdlib/osl/mx_blur_color.osl | 19 + .../libraries/stdlib/osl/mx_blur_color4.osl | 19 + .../libraries/stdlib/osl/mx_blur_float.osl | 19 + .../libraries/stdlib/osl/mx_blur_vector.osl | 19 + .../libraries/stdlib/osl/mx_blur_vector2.osl | 19 + .../libraries/stdlib/osl/mx_blur_vector4.osl | 19 + .../libraries/stdlib/osl/mx_burn_color.osl | 18 + .../libraries/stdlib/osl/mx_burn_color4.osl | 18 + .../libraries/stdlib/osl/mx_burn_float.osl | 18 + .../libraries/stdlib/osl/mx_ceil_color.osl | 17 + .../libraries/stdlib/osl/mx_ceil_color4.osl | 17 + .../libraries/stdlib/osl/mx_ceil_float.osl | 17 + .../libraries/stdlib/osl/mx_ceil_vector.osl | 17 + .../libraries/stdlib/osl/mx_ceil_vector2.osl | 17 + .../libraries/stdlib/osl/mx_ceil_vector4.osl | 17 + .../stdlib/osl/mx_cellnoise2d_float.osl | 20 + .../stdlib/osl/mx_cellnoise3d_float.osl | 20 + .../libraries/stdlib/osl/mx_clamp_color.osl | 19 + .../libraries/stdlib/osl/mx_clamp_color4.osl | 19 + .../libraries/stdlib/osl/mx_clamp_float.osl | 19 + .../stdlib/osl/mx_clamp_float_color.osl | 19 + .../stdlib/osl/mx_clamp_float_color4.osl | 19 + .../stdlib/osl/mx_clamp_float_vector.osl | 19 + .../stdlib/osl/mx_clamp_float_vector2.osl | 19 + .../stdlib/osl/mx_clamp_float_vector4.osl | 19 + .../libraries/stdlib/osl/mx_clamp_vector.osl | 19 + .../libraries/stdlib/osl/mx_clamp_vector2.osl | 19 + .../libraries/stdlib/osl/mx_clamp_vector4.osl | 19 + .../stdlib/osl/mx_combine2_vector2.osl | 22 + .../stdlib/osl/mx_combine3_color.osl | 22 + .../stdlib/osl/mx_combine3_vector.osl | 22 + .../stdlib/osl/mx_combine4_color4.osl | 22 + .../stdlib/osl/mx_combine4_vector4.osl | 22 + .../stdlib/osl/mx_combine_cf_color4.osl | 20 + .../stdlib/osl/mx_combine_vf_vector4.osl | 22 + .../stdlib/osl/mx_combine_vv_vector4.osl | 22 + .../libraries/stdlib/osl/mx_compare_color.osl | 26 + .../stdlib/osl/mx_compare_color4.osl | 26 + .../libraries/stdlib/osl/mx_compare_float.osl | 26 + .../stdlib/osl/mx_compare_vector.osl | 26 + .../stdlib/osl/mx_compare_vector2.osl | 26 + .../stdlib/osl/mx_compare_vector4.osl | 26 + .../libraries/stdlib/osl/mx_constant_bool.osl | 17 + .../stdlib/osl/mx_constant_color.osl | 17 + .../stdlib/osl/mx_constant_color4.osl | 17 + .../stdlib/osl/mx_constant_filename.osl | 17 + .../stdlib/osl/mx_constant_float.osl | 17 + .../libraries/stdlib/osl/mx_constant_int.osl | 17 + .../stdlib/osl/mx_constant_matrix33.osl | 17 + .../stdlib/osl/mx_constant_matrix44.osl | 17 + .../stdlib/osl/mx_constant_string.osl | 17 + .../stdlib/osl/mx_constant_vector.osl | 17 + .../stdlib/osl/mx_constant_vector2.osl | 17 + .../stdlib/osl/mx_constant_vector4.osl | 17 + .../libraries/stdlib/osl/mx_cos_color.osl | 17 + .../libraries/stdlib/osl/mx_cos_color4.osl | 17 + .../libraries/stdlib/osl/mx_cos_float.osl | 17 + .../libraries/stdlib/osl/mx_cos_vector.osl | 17 + .../libraries/stdlib/osl/mx_cos_vector2.osl | 17 + .../libraries/stdlib/osl/mx_cos_vector4.osl | 17 + .../stdlib/osl/mx_crossproduct_vector.osl | 18 + .../stdlib/osl/mx_determinant_matrix33.osl | 17 + .../stdlib/osl/mx_determinant_matrix44.osl | 17 + .../stdlib/osl/mx_disjointover_color4.osl | 38 + .../libraries/stdlib/osl/mx_divide_color.osl | 18 + .../libraries/stdlib/osl/mx_divide_color4.osl | 18 + .../libraries/stdlib/osl/mx_divide_float.osl | 18 + .../stdlib/osl/mx_divide_float_color.osl | 18 + .../stdlib/osl/mx_divide_float_color4.osl | 18 + .../stdlib/osl/mx_divide_float_matrix33.osl | 18 + .../stdlib/osl/mx_divide_float_matrix44.osl | 18 + .../stdlib/osl/mx_divide_float_vector.osl | 18 + .../stdlib/osl/mx_divide_float_vector2.osl | 18 + .../stdlib/osl/mx_divide_float_vector4.osl | 18 + .../stdlib/osl/mx_divide_matrix33.osl | 18 + .../stdlib/osl/mx_divide_matrix44.osl | 18 + .../libraries/stdlib/osl/mx_divide_vector.osl | 18 + .../stdlib/osl/mx_divide_vector2.osl | 18 + .../stdlib/osl/mx_divide_vector4.osl | 18 + .../libraries/stdlib/osl/mx_dodge_color.osl | 18 + .../libraries/stdlib/osl/mx_dodge_color4.osl | 18 + .../libraries/stdlib/osl/mx_dodge_float.osl | 18 + .../libraries/stdlib/osl/mx_dot_bool.osl | 17 + .../libraries/stdlib/osl/mx_dot_color.osl | 17 + .../libraries/stdlib/osl/mx_dot_color4.osl | 17 + .../stdlib/osl/mx_dot_displacementshader.osl | 17 + .../libraries/stdlib/osl/mx_dot_filename.osl | 17 + .../libraries/stdlib/osl/mx_dot_float.osl | 17 + materialx/libraries/stdlib/osl/mx_dot_int.osl | 17 + .../stdlib/osl/mx_dot_lightshader.osl | 17 + .../libraries/stdlib/osl/mx_dot_matrix33.osl | 17 + .../libraries/stdlib/osl/mx_dot_matrix44.osl | 17 + .../libraries/stdlib/osl/mx_dot_string.osl | 17 + .../stdlib/osl/mx_dot_surfaceshader.osl | 17 + .../libraries/stdlib/osl/mx_dot_vector.osl | 17 + .../libraries/stdlib/osl/mx_dot_vector2.osl | 17 + .../libraries/stdlib/osl/mx_dot_vector4.osl | 17 + .../stdlib/osl/mx_dot_volumeshader.osl | 17 + .../stdlib/osl/mx_dotproduct_vector.osl | 18 + .../stdlib/osl/mx_dotproduct_vector2.osl | 18 + .../stdlib/osl/mx_dotproduct_vector4.osl | 18 + .../libraries/stdlib/osl/mx_exp_color.osl | 17 + .../libraries/stdlib/osl/mx_exp_color4.osl | 17 + .../libraries/stdlib/osl/mx_exp_float.osl | 17 + .../libraries/stdlib/osl/mx_exp_vector.osl | 17 + .../libraries/stdlib/osl/mx_exp_vector2.osl | 17 + .../libraries/stdlib/osl/mx_exp_vector4.osl | 17 + .../stdlib/osl/mx_exponent_float.osl | 18 + .../stdlib/osl/mx_exponent_vector.osl | 18 + .../stdlib/osl/mx_exponent_vector2.osl | 18 + .../stdlib/osl/mx_exponent_vector4.osl | 18 + .../libraries/stdlib/osl/mx_extract_color.osl | 19 + .../stdlib/osl/mx_extract_color4.osl | 19 + .../stdlib/osl/mx_extract_vector.osl | 19 + .../stdlib/osl/mx_extract_vector2.osl | 19 + .../stdlib/osl/mx_extract_vector4.osl | 19 + .../libraries/stdlib/osl/mx_floor_color.osl | 17 + .../libraries/stdlib/osl/mx_floor_color4.osl | 17 + .../libraries/stdlib/osl/mx_floor_float.osl | 17 + .../libraries/stdlib/osl/mx_floor_vector.osl | 17 + .../libraries/stdlib/osl/mx_floor_vector2.osl | 17 + .../libraries/stdlib/osl/mx_floor_vector4.osl | 17 + .../stdlib/osl/mx_fractal3d_color.osl | 36 + .../stdlib/osl/mx_fractal3d_color4.osl | 36 + .../stdlib/osl/mx_fractal3d_fa_color.osl | 36 + .../stdlib/osl/mx_fractal3d_fa_color4.osl | 36 + .../stdlib/osl/mx_fractal3d_fa_vector.osl | 36 + .../stdlib/osl/mx_fractal3d_fa_vector2.osl | 36 + .../stdlib/osl/mx_fractal3d_fa_vector4.osl | 36 + .../stdlib/osl/mx_fractal3d_float.osl | 36 + .../stdlib/osl/mx_fractal3d_vector.osl | 36 + .../stdlib/osl/mx_fractal3d_vector2.osl | 36 + .../stdlib/osl/mx_fractal3d_vector4.osl | 36 + .../libraries/stdlib/osl/mx_frame_float.osl | 16 + materialx/libraries/stdlib/osl/mx_funcs.h | 817 ++++ .../stdlib/osl/mx_geomcolor_color.osl | 16 + .../stdlib/osl/mx_geomcolor_color4.osl | 16 + .../stdlib/osl/mx_geomcolor_float.osl | 16 + .../stdlib/osl/mx_geompropvalue_bool.osl | 18 + .../stdlib/osl/mx_geompropvalue_color.osl | 18 + .../stdlib/osl/mx_geompropvalue_color4.osl | 18 + .../stdlib/osl/mx_geompropvalue_float.osl | 18 + .../stdlib/osl/mx_geompropvalue_int.osl | 18 + .../stdlib/osl/mx_geompropvalue_string.osl | 18 + .../stdlib/osl/mx_geompropvalue_vector.osl | 18 + .../stdlib/osl/mx_geompropvalue_vector2.osl | 18 + .../stdlib/osl/mx_geompropvalue_vector4.osl | 18 + .../stdlib/osl/mx_heighttonormal_vector.osl | 19 + .../stdlib/osl/mx_hsvadjust_color.osl | 41 + .../stdlib/osl/mx_hsvadjust_color4.osl | 41 + .../stdlib/osl/mx_hsvtorgb_color.osl | 18 + .../stdlib/osl/mx_hsvtorgb_color4.osl | 18 + .../stdlib/osl/mx_hueshift_color.osl | 43 + .../stdlib/osl/mx_hueshift_color4.osl | 43 + .../libraries/stdlib/osl/mx_image_color.osl | 50 + .../libraries/stdlib/osl/mx_image_color4.osl | 50 + .../libraries/stdlib/osl/mx_image_float.osl | 50 + .../libraries/stdlib/osl/mx_image_vector.osl | 50 + .../libraries/stdlib/osl/mx_image_vector2.osl | 50 + .../libraries/stdlib/osl/mx_image_vector4.osl | 50 + .../libraries/stdlib/osl/mx_in_color4.osl | 19 + .../libraries/stdlib/osl/mx_inside_color.osl | 19 + .../libraries/stdlib/osl/mx_inside_color4.osl | 19 + .../libraries/stdlib/osl/mx_inside_float.osl | 19 + .../libraries/stdlib/osl/mx_invert_color.osl | 18 + .../libraries/stdlib/osl/mx_invert_color4.osl | 18 + .../libraries/stdlib/osl/mx_invert_float.osl | 18 + .../stdlib/osl/mx_invert_float_color.osl | 18 + .../stdlib/osl/mx_invert_float_color4.osl | 18 + .../stdlib/osl/mx_invert_float_vector.osl | 18 + .../stdlib/osl/mx_invert_float_vector2.osl | 18 + .../stdlib/osl/mx_invert_float_vector4.osl | 18 + .../libraries/stdlib/osl/mx_invert_vector.osl | 18 + .../stdlib/osl/mx_invert_vector2.osl | 18 + .../stdlib/osl/mx_invert_vector4.osl | 18 + .../libraries/stdlib/osl/mx_ln_color.osl | 17 + .../libraries/stdlib/osl/mx_ln_color4.osl | 17 + .../libraries/stdlib/osl/mx_ln_float.osl | 17 + .../libraries/stdlib/osl/mx_ln_vector.osl | 17 + .../libraries/stdlib/osl/mx_ln_vector2.osl | 17 + .../libraries/stdlib/osl/mx_ln_vector4.osl | 17 + .../stdlib/osl/mx_luminance_color.osl | 35 + .../stdlib/osl/mx_luminance_color4.osl | 35 + .../stdlib/osl/mx_magnitude_vector.osl | 17 + .../stdlib/osl/mx_magnitude_vector2.osl | 17 + .../stdlib/osl/mx_magnitude_vector4.osl | 17 + .../libraries/stdlib/osl/mx_mask_color4.osl | 19 + .../stdlib/osl/mx_matrix_invert_matrix33.osl | 17 + .../stdlib/osl/mx_matrix_invert_matrix44.osl | 17 + .../libraries/stdlib/osl/mx_matte_color4.osl | 27 + .../libraries/stdlib/osl/mx_max_color.osl | 18 + .../libraries/stdlib/osl/mx_max_color4.osl | 18 + .../libraries/stdlib/osl/mx_max_float.osl | 18 + .../stdlib/osl/mx_max_float_color.osl | 18 + .../stdlib/osl/mx_max_float_color4.osl | 18 + .../stdlib/osl/mx_max_float_vector.osl | 18 + .../stdlib/osl/mx_max_float_vector2.osl | 18 + .../stdlib/osl/mx_max_float_vector4.osl | 18 + .../libraries/stdlib/osl/mx_max_vector.osl | 18 + .../libraries/stdlib/osl/mx_max_vector2.osl | 18 + .../libraries/stdlib/osl/mx_max_vector4.osl | 18 + .../libraries/stdlib/osl/mx_min_color.osl | 18 + .../libraries/stdlib/osl/mx_min_color4.osl | 18 + .../libraries/stdlib/osl/mx_min_float.osl | 18 + .../stdlib/osl/mx_min_float_color.osl | 18 + .../stdlib/osl/mx_min_float_color4.osl | 18 + .../stdlib/osl/mx_min_float_vector.osl | 18 + .../stdlib/osl/mx_min_float_vector2.osl | 18 + .../stdlib/osl/mx_min_float_vector4.osl | 18 + .../libraries/stdlib/osl/mx_min_vector.osl | 18 + .../libraries/stdlib/osl/mx_min_vector2.osl | 18 + .../libraries/stdlib/osl/mx_min_vector4.osl | 18 + .../libraries/stdlib/osl/mx_mix_color.osl | 19 + .../libraries/stdlib/osl/mx_mix_color4.osl | 19 + .../libraries/stdlib/osl/mx_mix_float.osl | 19 + .../stdlib/osl/mx_mix_surfaceshader.osl | 19 + .../libraries/stdlib/osl/mx_mix_vector.osl | 19 + .../libraries/stdlib/osl/mx_mix_vector2.osl | 19 + .../libraries/stdlib/osl/mx_mix_vector4.osl | 19 + .../libraries/stdlib/osl/mx_modulo_color.osl | 20 + .../libraries/stdlib/osl/mx_modulo_color4.osl | 20 + .../libraries/stdlib/osl/mx_modulo_float.osl | 20 + .../stdlib/osl/mx_modulo_float_color.osl | 20 + .../stdlib/osl/mx_modulo_float_color4.osl | 20 + .../stdlib/osl/mx_modulo_float_vector.osl | 20 + .../stdlib/osl/mx_modulo_float_vector2.osl | 20 + .../stdlib/osl/mx_modulo_float_vector4.osl | 20 + .../libraries/stdlib/osl/mx_modulo_vector.osl | 20 + .../stdlib/osl/mx_modulo_vector2.osl | 20 + .../stdlib/osl/mx_modulo_vector4.osl | 20 + .../osl/mx_mult_surfaceshader_color.osl | 18 + .../osl/mx_mult_surfaceshader_float.osl | 18 + .../stdlib/osl/mx_multiply_color.osl | 18 + .../stdlib/osl/mx_multiply_color4.osl | 18 + .../stdlib/osl/mx_multiply_float.osl | 18 + .../stdlib/osl/mx_multiply_float_color.osl | 18 + .../stdlib/osl/mx_multiply_float_color4.osl | 18 + .../stdlib/osl/mx_multiply_float_matrix33.osl | 18 + .../stdlib/osl/mx_multiply_float_matrix44.osl | 18 + .../stdlib/osl/mx_multiply_float_vector.osl | 18 + .../stdlib/osl/mx_multiply_float_vector2.osl | 18 + .../stdlib/osl/mx_multiply_float_vector4.osl | 18 + .../stdlib/osl/mx_multiply_matrix33.osl | 18 + .../stdlib/osl/mx_multiply_matrix44.osl | 18 + .../stdlib/osl/mx_multiply_vector.osl | 18 + .../stdlib/osl/mx_multiply_vector2.osl | 18 + .../stdlib/osl/mx_multiply_vector4.osl | 18 + .../libraries/stdlib/osl/mx_noise2d_color.osl | 29 + .../stdlib/osl/mx_noise2d_color4.osl | 29 + .../stdlib/osl/mx_noise2d_fa_color.osl | 30 + .../stdlib/osl/mx_noise2d_fa_color4.osl | 30 + .../stdlib/osl/mx_noise2d_fa_vector.osl | 30 + .../stdlib/osl/mx_noise2d_fa_vector2.osl | 30 + .../stdlib/osl/mx_noise2d_fa_vector4.osl | 30 + .../libraries/stdlib/osl/mx_noise2d_float.osl | 29 + .../stdlib/osl/mx_noise2d_vector.osl | 29 + .../stdlib/osl/mx_noise2d_vector2.osl | 29 + .../stdlib/osl/mx_noise2d_vector4.osl | 29 + .../libraries/stdlib/osl/mx_noise3d_color.osl | 29 + .../stdlib/osl/mx_noise3d_color4.osl | 29 + .../stdlib/osl/mx_noise3d_fa_color.osl | 30 + .../stdlib/osl/mx_noise3d_fa_color4.osl | 30 + .../stdlib/osl/mx_noise3d_fa_vector.osl | 30 + .../stdlib/osl/mx_noise3d_fa_vector2.osl | 30 + .../stdlib/osl/mx_noise3d_fa_vector4.osl | 30 + .../libraries/stdlib/osl/mx_noise3d_float.osl | 29 + .../stdlib/osl/mx_noise3d_vector.osl | 29 + .../stdlib/osl/mx_noise3d_vector2.osl | 29 + .../stdlib/osl/mx_noise3d_vector4.osl | 29 + .../libraries/stdlib/osl/mx_normal_vector.osl | 17 + .../stdlib/osl/mx_normalize_vector.osl | 17 + .../stdlib/osl/mx_normalize_vector2.osl | 17 + .../stdlib/osl/mx_normalize_vector4.osl | 17 + .../libraries/stdlib/osl/mx_out_color4.osl | 19 + .../libraries/stdlib/osl/mx_outside_color.osl | 19 + .../stdlib/osl/mx_outside_color4.osl | 19 + .../libraries/stdlib/osl/mx_outside_float.osl | 19 + .../libraries/stdlib/osl/mx_over_color4.osl | 19 + .../libraries/stdlib/osl/mx_overlay_color.osl | 39 + .../stdlib/osl/mx_overlay_color4.osl | 39 + .../libraries/stdlib/osl/mx_overlay_float.osl | 39 + .../stdlib/osl/mx_position_vector.osl | 17 + .../libraries/stdlib/osl/mx_power_color.osl | 18 + .../libraries/stdlib/osl/mx_power_color4.osl | 18 + .../libraries/stdlib/osl/mx_power_float.osl | 18 + .../stdlib/osl/mx_power_float_color.osl | 18 + .../stdlib/osl/mx_power_float_color4.osl | 18 + .../stdlib/osl/mx_power_float_vector.osl | 18 + .../stdlib/osl/mx_power_float_vector2.osl | 18 + .../stdlib/osl/mx_power_float_vector4.osl | 18 + .../libraries/stdlib/osl/mx_power_vector.osl | 18 + .../libraries/stdlib/osl/mx_power_vector2.osl | 18 + .../libraries/stdlib/osl/mx_power_vector4.osl | 18 + .../libraries/stdlib/osl/mx_premult_color.osl | 34 + .../stdlib/osl/mx_premult_color4.osl | 34 + .../libraries/stdlib/osl/mx_ramp4_color.osl | 31 + .../libraries/stdlib/osl/mx_ramp4_color4.osl | 31 + .../libraries/stdlib/osl/mx_ramp4_float.osl | 31 + .../libraries/stdlib/osl/mx_ramp4_vector.osl | 31 + .../libraries/stdlib/osl/mx_ramp4_vector2.osl | 31 + .../libraries/stdlib/osl/mx_ramp4_vector4.osl | 31 + .../libraries/stdlib/osl/mx_ramplr_color.osl | 26 + .../libraries/stdlib/osl/mx_ramplr_color4.osl | 26 + .../libraries/stdlib/osl/mx_ramplr_float.osl | 26 + .../libraries/stdlib/osl/mx_ramplr_vector.osl | 26 + .../stdlib/osl/mx_ramplr_vector2.osl | 26 + .../stdlib/osl/mx_ramplr_vector4.osl | 26 + .../libraries/stdlib/osl/mx_ramptb_color.osl | 23 + .../libraries/stdlib/osl/mx_ramptb_color4.osl | 23 + .../libraries/stdlib/osl/mx_ramptb_float.osl | 23 + .../libraries/stdlib/osl/mx_ramptb_vector.osl | 23 + .../stdlib/osl/mx_ramptb_vector2.osl | 23 + .../stdlib/osl/mx_ramptb_vector4.osl | 23 + .../libraries/stdlib/osl/mx_remap_color.osl | 33 + .../libraries/stdlib/osl/mx_remap_color4.osl | 33 + .../libraries/stdlib/osl/mx_remap_float.osl | 33 + .../stdlib/osl/mx_remap_float_color.osl | 31 + .../stdlib/osl/mx_remap_float_color4.osl | 31 + .../stdlib/osl/mx_remap_float_vector.osl | 31 + .../stdlib/osl/mx_remap_float_vector2.osl | 31 + .../stdlib/osl/mx_remap_float_vector4.osl | 31 + .../libraries/stdlib/osl/mx_remap_vector.osl | 33 + .../libraries/stdlib/osl/mx_remap_vector2.osl | 33 + .../libraries/stdlib/osl/mx_remap_vector4.osl | 33 + .../stdlib/osl/mx_rgbtohsv_color.osl | 18 + .../stdlib/osl/mx_rgbtohsv_color4.osl | 18 + .../stdlib/osl/mx_rotate2d_vector2.osl | 23 + .../libraries/stdlib/osl/mx_rotate_vector.osl | 21 + .../stdlib/osl/mx_rotate_vector2.osl | 21 + .../libraries/stdlib/osl/mx_scale_vector.osl | 19 + .../libraries/stdlib/osl/mx_scale_vector2.osl | 19 + .../libraries/stdlib/osl/mx_screen_color.osl | 18 + .../libraries/stdlib/osl/mx_screen_color4.osl | 18 + .../libraries/stdlib/osl/mx_screen_float.osl | 18 + .../stdlib/osl/mx_separate_color.osl | 75 + .../stdlib/osl/mx_separate_color4.osl | 75 + .../stdlib/osl/mx_separate_vector.osl | 75 + .../stdlib/osl/mx_separate_vector2.osl | 75 + .../stdlib/osl/mx_separate_vector4.osl | 75 + .../libraries/stdlib/osl/mx_sign_color.osl | 17 + .../libraries/stdlib/osl/mx_sign_color4.osl | 17 + .../libraries/stdlib/osl/mx_sign_float.osl | 17 + .../libraries/stdlib/osl/mx_sign_vector.osl | 17 + .../libraries/stdlib/osl/mx_sign_vector2.osl | 17 + .../libraries/stdlib/osl/mx_sign_vector4.osl | 17 + .../libraries/stdlib/osl/mx_sin_color.osl | 17 + .../libraries/stdlib/osl/mx_sin_color4.osl | 17 + .../libraries/stdlib/osl/mx_sin_float.osl | 17 + .../libraries/stdlib/osl/mx_sin_vector.osl | 17 + .../libraries/stdlib/osl/mx_sin_vector2.osl | 17 + .../libraries/stdlib/osl/mx_sin_vector4.osl | 17 + .../stdlib/osl/mx_smoothstep_color.osl | 22 + .../stdlib/osl/mx_smoothstep_color4.osl | 22 + .../stdlib/osl/mx_smoothstep_float.osl | 22 + .../stdlib/osl/mx_smoothstep_float_color.osl | 22 + .../stdlib/osl/mx_smoothstep_float_color4.osl | 22 + .../stdlib/osl/mx_smoothstep_float_vector.osl | 22 + .../osl/mx_smoothstep_float_vector2.osl | 22 + .../osl/mx_smoothstep_float_vector4.osl | 22 + .../stdlib/osl/mx_smoothstep_vector.osl | 22 + .../stdlib/osl/mx_smoothstep_vector2.osl | 22 + .../stdlib/osl/mx_smoothstep_vector4.osl | 22 + .../libraries/stdlib/osl/mx_splitlr_color.osl | 29 + .../stdlib/osl/mx_splitlr_color4.osl | 29 + .../libraries/stdlib/osl/mx_splitlr_float.osl | 29 + .../stdlib/osl/mx_splitlr_vector.osl | 29 + .../stdlib/osl/mx_splitlr_vector2.osl | 29 + .../stdlib/osl/mx_splitlr_vector4.osl | 29 + .../libraries/stdlib/osl/mx_splittb_color.osl | 29 + .../stdlib/osl/mx_splittb_color4.osl | 29 + .../libraries/stdlib/osl/mx_splittb_float.osl | 29 + .../stdlib/osl/mx_splittb_vector.osl | 29 + .../stdlib/osl/mx_splittb_vector2.osl | 29 + .../stdlib/osl/mx_splittb_vector4.osl | 29 + .../libraries/stdlib/osl/mx_sqrt_color.osl | 17 + .../libraries/stdlib/osl/mx_sqrt_color4.osl | 17 + .../libraries/stdlib/osl/mx_sqrt_float.osl | 17 + .../libraries/stdlib/osl/mx_sqrt_vector.osl | 17 + .../libraries/stdlib/osl/mx_sqrt_vector2.osl | 17 + .../libraries/stdlib/osl/mx_sqrt_vector4.osl | 17 + .../stdlib/osl/mx_subtract_color.osl | 19 + .../stdlib/osl/mx_subtract_color4.osl | 19 + .../stdlib/osl/mx_subtract_float.osl | 19 + .../stdlib/osl/mx_subtract_float_color.osl | 18 + .../stdlib/osl/mx_subtract_float_color4.osl | 18 + .../stdlib/osl/mx_subtract_float_matrix33.osl | 18 + .../stdlib/osl/mx_subtract_float_matrix44.osl | 18 + .../stdlib/osl/mx_subtract_float_vector.osl | 18 + .../stdlib/osl/mx_subtract_float_vector2.osl | 18 + .../stdlib/osl/mx_subtract_float_vector4.osl | 18 + .../stdlib/osl/mx_subtract_matrix33.osl | 19 + .../stdlib/osl/mx_subtract_matrix44.osl | 19 + .../stdlib/osl/mx_subtract_vector.osl | 19 + .../stdlib/osl/mx_subtract_vector2.osl | 19 + .../stdlib/osl/mx_subtract_vector4.osl | 19 + .../libraries/stdlib/osl/mx_switch_color.osl | 34 + .../libraries/stdlib/osl/mx_switch_color4.osl | 34 + .../libraries/stdlib/osl/mx_switch_float.osl | 34 + .../libraries/stdlib/osl/mx_switch_vector.osl | 34 + .../stdlib/osl/mx_switch_vector2.osl | 34 + .../stdlib/osl/mx_switch_vector4.osl | 34 + .../stdlib/osl/mx_swizzle_color4_color.osl | 27 + .../stdlib/osl/mx_swizzle_color4_color4.osl | 27 + .../stdlib/osl/mx_swizzle_color4_float.osl | 27 + .../stdlib/osl/mx_swizzle_color4_vector.osl | 27 + .../stdlib/osl/mx_swizzle_color4_vector2.osl | 27 + .../stdlib/osl/mx_swizzle_color4_vector4.osl | 27 + .../stdlib/osl/mx_swizzle_color_color.osl | 26 + .../stdlib/osl/mx_swizzle_color_color4.osl | 26 + .../stdlib/osl/mx_swizzle_color_float.osl | 26 + .../stdlib/osl/mx_swizzle_color_vector.osl | 26 + .../stdlib/osl/mx_swizzle_color_vector2.osl | 26 + .../stdlib/osl/mx_swizzle_color_vector4.osl | 26 + .../stdlib/osl/mx_swizzle_float_color.osl | 27 + .../stdlib/osl/mx_swizzle_float_color4.osl | 27 + .../stdlib/osl/mx_swizzle_float_vector.osl | 27 + .../stdlib/osl/mx_swizzle_float_vector2.osl | 27 + .../stdlib/osl/mx_swizzle_float_vector4.osl | 27 + .../stdlib/osl/mx_swizzle_vector2_color.osl | 25 + .../stdlib/osl/mx_swizzle_vector2_color4.osl | 25 + .../stdlib/osl/mx_swizzle_vector2_float.osl | 25 + .../stdlib/osl/mx_swizzle_vector2_vector.osl | 25 + .../stdlib/osl/mx_swizzle_vector2_vector2.osl | 25 + .../stdlib/osl/mx_swizzle_vector2_vector4.osl | 25 + .../stdlib/osl/mx_swizzle_vector4_color.osl | 27 + .../stdlib/osl/mx_swizzle_vector4_color4.osl | 27 + .../stdlib/osl/mx_swizzle_vector4_float.osl | 27 + .../stdlib/osl/mx_swizzle_vector4_vector.osl | 27 + .../stdlib/osl/mx_swizzle_vector4_vector2.osl | 27 + .../stdlib/osl/mx_swizzle_vector4_vector4.osl | 27 + .../stdlib/osl/mx_swizzle_vector_color.osl | 26 + .../stdlib/osl/mx_swizzle_vector_color4.osl | 26 + .../stdlib/osl/mx_swizzle_vector_float.osl | 26 + .../stdlib/osl/mx_swizzle_vector_vector.osl | 26 + .../stdlib/osl/mx_swizzle_vector_vector2.osl | 26 + .../stdlib/osl/mx_swizzle_vector_vector4.osl | 26 + .../libraries/stdlib/osl/mx_tan_color.osl | 17 + .../libraries/stdlib/osl/mx_tan_color4.osl | 17 + .../libraries/stdlib/osl/mx_tan_float.osl | 17 + .../libraries/stdlib/osl/mx_tan_vector.osl | 17 + .../libraries/stdlib/osl/mx_tan_vector2.osl | 17 + .../libraries/stdlib/osl/mx_tan_vector4.osl | 17 + .../stdlib/osl/mx_tangent_vector.osl | 17 + .../stdlib/osl/mx_texcoord_vector.osl | 30 + .../stdlib/osl/mx_texcoord_vector2.osl | 30 + .../stdlib/osl/mx_tiledimage_color.osl | 48 + .../stdlib/osl/mx_tiledimage_color4.osl | 48 + .../stdlib/osl/mx_tiledimage_float.osl | 48 + .../stdlib/osl/mx_tiledimage_vector.osl | 48 + .../stdlib/osl/mx_tiledimage_vector2.osl | 48 + .../stdlib/osl/mx_tiledimage_vector4.osl | 48 + .../libraries/stdlib/osl/mx_time_float.osl | 16 + .../stdlib/osl/mx_transformnormal_vector.osl | 27 + .../stdlib/osl/mx_transformnormal_vector4.osl | 27 + .../stdlib/osl/mx_transformpoint_vector.osl | 27 + .../stdlib/osl/mx_transformpoint_vector4.osl | 27 + .../stdlib/osl/mx_transformvector_vector.osl | 27 + .../stdlib/osl/mx_transformvector_vector4.osl | 27 + .../stdlib/osl/mx_transpose_matrix33.osl | 17 + .../stdlib/osl/mx_transpose_matrix44.osl | 17 + .../osl/mx_triplanarprojection_color.osl | 73 + .../osl/mx_triplanarprojection_color4.osl | 73 + .../osl/mx_triplanarprojection_float.osl | 73 + .../osl/mx_triplanarprojection_vector.osl | 73 + .../osl/mx_triplanarprojection_vector2.osl | 73 + .../osl/mx_triplanarprojection_vector4.osl | 73 + .../stdlib/osl/mx_unpremult_color.osl | 34 + .../stdlib/osl/mx_unpremult_color4.osl | 34 + .../stdlib/osl/mx_viewdirection_vector.osl | 14 + materialx/libraries/stdlib/osl/oslutil.h | 135 + .../libraries/stdlib/osl/stdlib_osl_impl.mtlx | 780 +++ materialx/libraries/stdlib/osl/stdosl.h | 601 +++ materialx/libraries/stdlib/osl/vector2.h | 326 ++ materialx/libraries/stdlib/osl/vector4.h | 407 ++ materialx/libraries/stdlib/stdlib_defs.mtlx | 4210 +++++++++++++++++ materialx/libraries/stdlib/stdlib_ng.mtlx | 2070 ++++++++ materialx/libraries/targets/genglsl.mtlx | 14 + materialx/libraries/targets/genmdl.mtlx | 14 + materialx/libraries/targets/genosl.mtlx | 14 + materialx/logging.py | 67 + materialx/node_tree.py | 277 ++ materialx/nodes/.gitignore | 1 + materialx/nodes/__init__.py | 80 + materialx/nodes/categories.py | 47 + materialx/nodes/generate_node_classes.py | 334 ++ materialx/nodes/node.py | 449 ++ materialx/nodes/ui.py | 204 + materialx/preferences.py | 14 + materialx/utils.py | 374 ++ 929 files changed, 32383 insertions(+) create mode 100644 materialx/__init__.py create mode 100644 materialx/libraries/README.md create mode 100644 materialx/libraries/alglib/alglib_defs.mtlx create mode 100644 materialx/libraries/alglib/alglib_ng.mtlx create mode 100644 materialx/libraries/bxdf/disney_brdf_2012.mtlx create mode 100644 materialx/libraries/bxdf/disney_brdf_2015.mtlx create mode 100644 materialx/libraries/bxdf/standard_surface.mtlx create mode 100644 materialx/libraries/bxdf/usd_preview_surface.mtlx create mode 100644 materialx/libraries/lights/genglsl/lights_genglsl_impl.mtlx create mode 100644 materialx/libraries/lights/genglsl/mx_directional_light.glsl create mode 100644 materialx/libraries/lights/genglsl/mx_point_light.glsl create mode 100644 materialx/libraries/lights/genglsl/mx_spot_light.glsl create mode 100644 materialx/libraries/lights/lights_defs.mtlx create mode 100644 materialx/libraries/pbrlib/genglsl/lib/mx_defines.glsl create mode 100644 materialx/libraries/pbrlib/genglsl/lib/mx_environment_fis.glsl create mode 100644 materialx/libraries/pbrlib/genglsl/lib/mx_environment_none.glsl create mode 100644 materialx/libraries/pbrlib/genglsl/lib/mx_environment_prefilter.glsl create mode 100644 materialx/libraries/pbrlib/genglsl/lib/mx_math.glsl create mode 100644 materialx/libraries/pbrlib/genglsl/lib/mx_microfacet.glsl create mode 100644 materialx/libraries/pbrlib/genglsl/lib/mx_microfacet_diffuse.glsl create mode 100644 materialx/libraries/pbrlib/genglsl/lib/mx_microfacet_sheen.glsl create mode 100644 materialx/libraries/pbrlib/genglsl/lib/mx_microfacet_specular.glsl create mode 100644 materialx/libraries/pbrlib/genglsl/lib/mx_refraction_index.glsl create mode 100644 materialx/libraries/pbrlib/genglsl/lib/mx_shadow.glsl create mode 100644 materialx/libraries/pbrlib/genglsl/lib/mx_table.glsl create mode 100644 materialx/libraries/pbrlib/genglsl/mx_add_bsdf.glsl create mode 100644 materialx/libraries/pbrlib/genglsl/mx_add_edf.glsl create mode 100644 materialx/libraries/pbrlib/genglsl/mx_artistic_ior.glsl create mode 100644 materialx/libraries/pbrlib/genglsl/mx_burley_diffuse_bsdf.glsl create mode 100644 materialx/libraries/pbrlib/genglsl/mx_conductor_bsdf.glsl create mode 100644 materialx/libraries/pbrlib/genglsl/mx_dielectric_bsdf.glsl create mode 100644 materialx/libraries/pbrlib/genglsl/mx_generalized_schlick_bsdf.glsl create mode 100644 materialx/libraries/pbrlib/genglsl/mx_mix_bsdf.glsl create mode 100644 materialx/libraries/pbrlib/genglsl/mx_mix_edf.glsl create mode 100644 materialx/libraries/pbrlib/genglsl/mx_multiply_bsdf_color.glsl create mode 100644 materialx/libraries/pbrlib/genglsl/mx_multiply_bsdf_float.glsl create mode 100644 materialx/libraries/pbrlib/genglsl/mx_multiply_edf_color.glsl create mode 100644 materialx/libraries/pbrlib/genglsl/mx_multiply_edf_float.glsl create mode 100644 materialx/libraries/pbrlib/genglsl/mx_oren_nayar_diffuse_bsdf.glsl create mode 100644 materialx/libraries/pbrlib/genglsl/mx_roughness_anisotropy.glsl create mode 100644 materialx/libraries/pbrlib/genglsl/mx_roughness_dual.glsl create mode 100644 materialx/libraries/pbrlib/genglsl/mx_sheen_bsdf.glsl create mode 100644 materialx/libraries/pbrlib/genglsl/mx_subsurface_bsdf.glsl create mode 100644 materialx/libraries/pbrlib/genglsl/mx_translucent_bsdf.glsl create mode 100644 materialx/libraries/pbrlib/genglsl/mx_uniform_edf.glsl create mode 100644 materialx/libraries/pbrlib/genglsl/pbrlib_genglsl_impl.mtlx create mode 100644 materialx/libraries/pbrlib/genmdl/pbrlib_genmdl_impl.mtlx create mode 100644 materialx/libraries/pbrlib/genosl/lib/mx_microfacet.osl create mode 100644 materialx/libraries/pbrlib/genosl/lib/mx_microfacet_specular.osl create mode 100644 materialx/libraries/pbrlib/genosl/lib/mx_refraction_index.osl create mode 100644 materialx/libraries/pbrlib/genosl/mx_add.inline create mode 100644 materialx/libraries/pbrlib/genosl/mx_artistic_ior.osl create mode 100644 materialx/libraries/pbrlib/genosl/mx_burley_diffuse_bsdf.osl create mode 100644 materialx/libraries/pbrlib/genosl/mx_conductor_bsdf.osl create mode 100644 materialx/libraries/pbrlib/genosl/mx_dielectric_bsdf.osl create mode 100644 materialx/libraries/pbrlib/genosl/mx_displacement_float.osl create mode 100644 materialx/libraries/pbrlib/genosl/mx_displacement_vector3.osl create mode 100644 materialx/libraries/pbrlib/genosl/mx_generalized_schlick_bsdf.osl create mode 100644 materialx/libraries/pbrlib/genosl/mx_mix.inline create mode 100644 materialx/libraries/pbrlib/genosl/mx_multiply_bsdf.inline create mode 100644 materialx/libraries/pbrlib/genosl/mx_multiply_edf.inline create mode 100644 materialx/libraries/pbrlib/genosl/mx_oren_nayar_diffuse_bsdf.inline create mode 100644 materialx/libraries/pbrlib/genosl/mx_roughness_anisotropy.osl create mode 100644 materialx/libraries/pbrlib/genosl/mx_roughness_dual.osl create mode 100644 materialx/libraries/pbrlib/genosl/mx_sheen_bsdf.osl create mode 100644 materialx/libraries/pbrlib/genosl/mx_subsurface_bsdf.osl create mode 100644 materialx/libraries/pbrlib/genosl/mx_surface.osl create mode 100644 materialx/libraries/pbrlib/genosl/mx_translucent_bsdf.inline create mode 100644 materialx/libraries/pbrlib/genosl/mx_uniform_edf.inline create mode 100644 materialx/libraries/pbrlib/genosl/pbrlib_genosl_impl.mtlx create mode 100644 materialx/libraries/pbrlib/pbrlib_defs.mtlx create mode 100644 materialx/libraries/pbrlib/pbrlib_ng.mtlx create mode 100644 materialx/libraries/stdlib/genglsl/lib/mx_hsv.glsl create mode 100644 materialx/libraries/stdlib/genglsl/lib/mx_noise.glsl create mode 100644 materialx/libraries/stdlib/genglsl/lib/mx_sampling.glsl create mode 100644 materialx/libraries/stdlib/genglsl/lib/mx_transform_uv.glsl create mode 100644 materialx/libraries/stdlib/genglsl/lib/mx_transform_uv_vflip.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_aastep.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_absval.inline create mode 100644 materialx/libraries/stdlib/genglsl/mx_acescg_to_linear_color3.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_acescg_to_linear_color4.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_acos.inline create mode 100644 materialx/libraries/stdlib/genglsl/mx_add.inline create mode 100644 materialx/libraries/stdlib/genglsl/mx_add_surfaceshader.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_asin.inline create mode 100644 materialx/libraries/stdlib/genglsl/mx_atan2.inline create mode 100644 materialx/libraries/stdlib/genglsl/mx_burn_color3.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_burn_color4.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_burn_float.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_ceil.inline create mode 100644 materialx/libraries/stdlib/genglsl/mx_cellnoise2d_float.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_cellnoise3d_float.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_clamp.inline create mode 100644 materialx/libraries/stdlib/genglsl/mx_constant.inline create mode 100644 materialx/libraries/stdlib/genglsl/mx_cos.inline create mode 100644 materialx/libraries/stdlib/genglsl/mx_crossproduct.inline create mode 100644 materialx/libraries/stdlib/genglsl/mx_determinant.inline create mode 100644 materialx/libraries/stdlib/genglsl/mx_difference.inline create mode 100644 materialx/libraries/stdlib/genglsl/mx_disjointover_color4.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_divide.inline create mode 100644 materialx/libraries/stdlib/genglsl/mx_dodge.inline create mode 100644 materialx/libraries/stdlib/genglsl/mx_dodge_color3.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_dodge_color4.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_dodge_float.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_dot.inline create mode 100644 materialx/libraries/stdlib/genglsl/mx_dotproduct.inline create mode 100644 materialx/libraries/stdlib/genglsl/mx_exp.inline create mode 100644 materialx/libraries/stdlib/genglsl/mx_floor.inline create mode 100644 materialx/libraries/stdlib/genglsl/mx_fractal3d_fa_vector2.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_fractal3d_fa_vector3.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_fractal3d_fa_vector4.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_fractal3d_float.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_fractal3d_vector2.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_fractal3d_vector3.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_fractal3d_vector4.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_g22_ap1_to_lin_rec709_color3.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_g22_ap1_to_lin_rec709_color4.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_gamma18_to_linear_color3.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_gamma18_to_linear_color4.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_gamma22_to_linear_color3.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_gamma22_to_linear_color4.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_gamma24_to_linear_color3.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_gamma24_to_linear_color4.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_hsvtorgb_color3.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_hsvtorgb_color4.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_image_color3.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_image_color4.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_image_float.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_image_vector2.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_image_vector3.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_image_vector4.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_in_color4.inline create mode 100644 materialx/libraries/stdlib/genglsl/mx_inside.inline create mode 100644 materialx/libraries/stdlib/genglsl/mx_invert.inline create mode 100644 materialx/libraries/stdlib/genglsl/mx_invertM.inline create mode 100644 materialx/libraries/stdlib/genglsl/mx_ln.inline create mode 100644 materialx/libraries/stdlib/genglsl/mx_luminance_color3.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_luminance_color4.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_magnitude.inline create mode 100644 materialx/libraries/stdlib/genglsl/mx_mask_color4.inline create mode 100644 materialx/libraries/stdlib/genglsl/mx_matte_color4.inline create mode 100644 materialx/libraries/stdlib/genglsl/mx_max.inline create mode 100644 materialx/libraries/stdlib/genglsl/mx_min.inline create mode 100644 materialx/libraries/stdlib/genglsl/mx_minus.inline create mode 100644 materialx/libraries/stdlib/genglsl/mx_mix.inline create mode 100644 materialx/libraries/stdlib/genglsl/mx_mix_surfaceshader.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_modulo.inline create mode 100644 materialx/libraries/stdlib/genglsl/mx_multiply.inline create mode 100644 materialx/libraries/stdlib/genglsl/mx_multiply_surfaceshader_color3.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_multiply_surfaceshader_float.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_noise2d_fa_vector2.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_noise2d_fa_vector3.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_noise2d_fa_vector4.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_noise2d_float.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_noise2d_vector2.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_noise2d_vector3.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_noise2d_vector4.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_noise3d_fa_vector2.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_noise3d_fa_vector3.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_noise3d_fa_vector4.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_noise3d_float.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_noise3d_vector2.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_noise3d_vector3.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_noise3d_vector4.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_normalize.inline create mode 100644 materialx/libraries/stdlib/genglsl/mx_normalmap.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_out_color2.inline create mode 100644 materialx/libraries/stdlib/genglsl/mx_out_color4.inline create mode 100644 materialx/libraries/stdlib/genglsl/mx_outside.inline create mode 100644 materialx/libraries/stdlib/genglsl/mx_over_color2.inline create mode 100644 materialx/libraries/stdlib/genglsl/mx_over_color4.inline create mode 100644 materialx/libraries/stdlib/genglsl/mx_overlay.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_overlay_color3.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_overlay_color4.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_overlay_float.inline create mode 100644 materialx/libraries/stdlib/genglsl/mx_plus.inline create mode 100644 materialx/libraries/stdlib/genglsl/mx_power.inline create mode 100644 materialx/libraries/stdlib/genglsl/mx_power_color3_float.inline create mode 100644 materialx/libraries/stdlib/genglsl/mx_power_color4_float.inline create mode 100644 materialx/libraries/stdlib/genglsl/mx_power_vector2_float.inline create mode 100644 materialx/libraries/stdlib/genglsl/mx_power_vector3_float.inline create mode 100644 materialx/libraries/stdlib/genglsl/mx_power_vector4_float.inline create mode 100644 materialx/libraries/stdlib/genglsl/mx_premult_color4.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_ramplr_float.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_ramplr_vector2.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_ramplr_vector3.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_ramplr_vector4.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_ramptb_float.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_ramptb_vector2.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_ramptb_vector3.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_ramptb_vector4.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_remap.inline create mode 100644 materialx/libraries/stdlib/genglsl/mx_rgbtohsv_color3.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_rgbtohsv_color4.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_rotate_vector2.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_rotate_vector3.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_screen.inline create mode 100644 materialx/libraries/stdlib/genglsl/mx_sign.inline create mode 100644 materialx/libraries/stdlib/genglsl/mx_sin.inline create mode 100644 materialx/libraries/stdlib/genglsl/mx_smoothstep_float.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_smoothstep_vec2.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_smoothstep_vec2FA.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_smoothstep_vec3.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_smoothstep_vec3FA.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_smoothstep_vec4.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_smoothstep_vec4FA.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_splitlr_float.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_splitlr_vector2.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_splitlr_vector3.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_splitlr_vector4.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_splittb_float.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_splittb_vector2.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_splittb_vector3.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_splittb_vector4.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_sqrt.inline create mode 100644 materialx/libraries/stdlib/genglsl/mx_srgb_texture_to_linear_color3.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_srgb_texture_to_linear_color4.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_subtract.inline create mode 100644 materialx/libraries/stdlib/genglsl/mx_tan.inline create mode 100644 materialx/libraries/stdlib/genglsl/mx_transformmatrix.inline create mode 100644 materialx/libraries/stdlib/genglsl/mx_transformmatrix_vector2M3.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_transformmatrix_vector3M4.glsl create mode 100644 materialx/libraries/stdlib/genglsl/mx_transpose.inline create mode 100644 materialx/libraries/stdlib/genglsl/mx_unpremult_color4.glsl create mode 100644 materialx/libraries/stdlib/genglsl/stdlib_genglsl_cm_impl.mtlx create mode 100644 materialx/libraries/stdlib/genglsl/stdlib_genglsl_impl.mtlx create mode 100644 materialx/libraries/stdlib/genglsl/stdlib_genglsl_unit_impl.mtlx create mode 100644 materialx/libraries/stdlib/genmdl/stdlib_genmdl_cm_impl.mtlx create mode 100644 materialx/libraries/stdlib/genmdl/stdlib_genmdl_impl.mtlx create mode 100644 materialx/libraries/stdlib/genmdl/stdlib_genmdl_unit_impl.mtlx create mode 100644 materialx/libraries/stdlib/genosl/lib/mx_sampling.osl create mode 100644 materialx/libraries/stdlib/genosl/lib/mx_transform_uv.osl create mode 100644 materialx/libraries/stdlib/genosl/lib/mx_transform_uv_vflip.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_absval.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_acescg_to_linear_color3.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_acescg_to_linear_color4.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_acos.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_add.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_ambientocclusion_float.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_asin.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_atan2.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_bitangent_vector3.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_burn_color3.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_burn_color4.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_burn_float.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_ceil.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_cellnoise2d_float.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_cellnoise3d_float.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_clamp.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_constant.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_contrast.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_cos.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_crossproduct.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_determinant.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_difference.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_disjointover_color4.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_divide.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_dodge_color3.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_dodge_color4.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_dodge_float.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_dot.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_dotproduct.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_exp.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_floor.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_fractal3d_color3.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_fractal3d_color4.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_fractal3d_fa_color3.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_fractal3d_fa_color4.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_fractal3d_fa_vector2.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_fractal3d_fa_vector3.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_fractal3d_fa_vector4.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_fractal3d_float.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_fractal3d_vector2.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_fractal3d_vector3.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_fractal3d_vector4.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_frame_float.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_g22_ap1_to_lin_rec709_color3.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_g22_ap1_to_lin_rec709_color4.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_gamma18_to_linear_color3.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_gamma18_to_linear_color4.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_gamma22_to_linear_color3.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_gamma22_to_linear_color4.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_gamma24_to_linear_color3.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_gamma24_to_linear_color4.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_geomcolor_color3.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_geomcolor_color4.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_geomcolor_float.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_geompropvalue_boolean.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_geompropvalue_color3.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_geompropvalue_color4.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_geompropvalue_float.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_geompropvalue_integer.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_geompropvalue_string.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_geompropvalue_vector2.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_geompropvalue_vector3.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_geompropvalue_vector4.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_heighttonormal_vector3.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_hsvtorgb_color3.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_hsvtorgb_color4.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_image_color3.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_image_color4.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_image_float.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_image_vector2.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_image_vector3.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_image_vector4.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_in.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_inside.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_invert.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_invertM.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_ln.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_luminance_color3.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_luminance_color4.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_magnitude.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_mask.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_matte_color4.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_max.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_min.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_minus.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_mix.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_modulo.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_modulo_color3FA.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_modulo_vector3FA.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_multiply.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_noise2d_color3.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_noise2d_color4.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_noise2d_fa_color3.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_noise2d_fa_color4.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_noise2d_fa_vector2.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_noise2d_fa_vector3.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_noise2d_fa_vector4.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_noise2d_float.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_noise2d_vector2.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_noise2d_vector3.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_noise2d_vector4.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_noise3d_color3.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_noise3d_color4.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_noise3d_fa_color3.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_noise3d_fa_color4.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_noise3d_fa_vector2.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_noise3d_fa_vector3.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_noise3d_fa_vector4.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_noise3d_float.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_noise3d_vector2.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_noise3d_vector3.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_noise3d_vector4.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_normal_vector3.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_normalize.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_normalmap.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_out.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_outside.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_over.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_overlay.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_overlay_color3.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_overlay_color4.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_plus.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_position_vector3.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_power.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_premult_color4.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_ramplr.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_ramptb.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_remap.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_rgbtohsv_color3.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_rgbtohsv_color4.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_rotate_vector2.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_rotate_vector3.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_screen.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_sign.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_sin.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_smoothstep.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_splitlr.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_splittb.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_sqrt.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_srgb_texture_to_linear_color3.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_srgb_texture_to_linear_color4.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_subtract.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_tan.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_tangent_vector3.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_texcoord_vector2.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_texcoord_vector3.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_time_float.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_transformmatrix.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_transformmatrix_vector2M3.osl create mode 100644 materialx/libraries/stdlib/genosl/mx_transformnormal.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_transformpoint.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_transformvector.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_transpose.inline create mode 100644 materialx/libraries/stdlib/genosl/mx_unpremult_color4.osl create mode 100644 materialx/libraries/stdlib/genosl/stdlib_genosl_cm_impl.mtlx create mode 100644 materialx/libraries/stdlib/genosl/stdlib_genosl_impl.mtlx create mode 100644 materialx/libraries/stdlib/genosl/stdlib_genosl_unit_impl.mtlx create mode 100644 materialx/libraries/stdlib/osl/README.md create mode 100644 materialx/libraries/stdlib/osl/color4.h create mode 100644 materialx/libraries/stdlib/osl/matrix33.h create mode 100644 materialx/libraries/stdlib/osl/mx_absval_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_absval_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_absval_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_absval_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_absval_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_absval_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_acos_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_acos_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_acos_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_acos_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_acos_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_acos_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_add_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_add_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_add_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_add_float_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_add_float_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_add_float_matrix33.osl create mode 100644 materialx/libraries/stdlib/osl/mx_add_float_matrix44.osl create mode 100644 materialx/libraries/stdlib/osl/mx_add_float_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_add_float_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_add_float_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_add_matrix33.osl create mode 100644 materialx/libraries/stdlib/osl/mx_add_matrix44.osl create mode 100644 materialx/libraries/stdlib/osl/mx_add_surfaceshader.osl create mode 100644 materialx/libraries/stdlib/osl/mx_add_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_add_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_add_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_ambientocclusion_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_asin_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_asin_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_asin_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_asin_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_asin_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_asin_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_atan2_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_atan2_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_atan2_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_atan2_float_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_atan2_float_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_atan2_float_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_atan2_float_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_atan2_float_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_atan2_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_atan2_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_atan2_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_bitangent_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_blur_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_blur_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_blur_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_blur_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_blur_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_blur_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_burn_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_burn_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_burn_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_ceil_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_ceil_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_ceil_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_ceil_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_ceil_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_ceil_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_cellnoise2d_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_cellnoise3d_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_clamp_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_clamp_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_clamp_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_clamp_float_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_clamp_float_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_clamp_float_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_clamp_float_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_clamp_float_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_clamp_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_clamp_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_clamp_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_combine2_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_combine3_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_combine3_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_combine4_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_combine4_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_combine_cf_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_combine_vf_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_combine_vv_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_compare_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_compare_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_compare_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_compare_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_compare_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_compare_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_constant_bool.osl create mode 100644 materialx/libraries/stdlib/osl/mx_constant_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_constant_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_constant_filename.osl create mode 100644 materialx/libraries/stdlib/osl/mx_constant_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_constant_int.osl create mode 100644 materialx/libraries/stdlib/osl/mx_constant_matrix33.osl create mode 100644 materialx/libraries/stdlib/osl/mx_constant_matrix44.osl create mode 100644 materialx/libraries/stdlib/osl/mx_constant_string.osl create mode 100644 materialx/libraries/stdlib/osl/mx_constant_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_constant_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_constant_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_cos_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_cos_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_cos_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_cos_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_cos_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_cos_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_crossproduct_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_determinant_matrix33.osl create mode 100644 materialx/libraries/stdlib/osl/mx_determinant_matrix44.osl create mode 100644 materialx/libraries/stdlib/osl/mx_disjointover_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_divide_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_divide_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_divide_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_divide_float_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_divide_float_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_divide_float_matrix33.osl create mode 100644 materialx/libraries/stdlib/osl/mx_divide_float_matrix44.osl create mode 100644 materialx/libraries/stdlib/osl/mx_divide_float_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_divide_float_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_divide_float_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_divide_matrix33.osl create mode 100644 materialx/libraries/stdlib/osl/mx_divide_matrix44.osl create mode 100644 materialx/libraries/stdlib/osl/mx_divide_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_divide_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_divide_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_dodge_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_dodge_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_dodge_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_dot_bool.osl create mode 100644 materialx/libraries/stdlib/osl/mx_dot_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_dot_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_dot_displacementshader.osl create mode 100644 materialx/libraries/stdlib/osl/mx_dot_filename.osl create mode 100644 materialx/libraries/stdlib/osl/mx_dot_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_dot_int.osl create mode 100644 materialx/libraries/stdlib/osl/mx_dot_lightshader.osl create mode 100644 materialx/libraries/stdlib/osl/mx_dot_matrix33.osl create mode 100644 materialx/libraries/stdlib/osl/mx_dot_matrix44.osl create mode 100644 materialx/libraries/stdlib/osl/mx_dot_string.osl create mode 100644 materialx/libraries/stdlib/osl/mx_dot_surfaceshader.osl create mode 100644 materialx/libraries/stdlib/osl/mx_dot_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_dot_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_dot_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_dot_volumeshader.osl create mode 100644 materialx/libraries/stdlib/osl/mx_dotproduct_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_dotproduct_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_dotproduct_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_exp_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_exp_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_exp_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_exp_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_exp_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_exp_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_exponent_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_exponent_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_exponent_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_exponent_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_extract_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_extract_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_extract_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_extract_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_extract_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_floor_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_floor_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_floor_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_floor_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_floor_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_floor_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_fractal3d_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_fractal3d_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_fractal3d_fa_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_fractal3d_fa_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_fractal3d_fa_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_fractal3d_fa_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_fractal3d_fa_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_fractal3d_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_fractal3d_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_fractal3d_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_fractal3d_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_frame_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_funcs.h create mode 100644 materialx/libraries/stdlib/osl/mx_geomcolor_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_geomcolor_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_geomcolor_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_geompropvalue_bool.osl create mode 100644 materialx/libraries/stdlib/osl/mx_geompropvalue_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_geompropvalue_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_geompropvalue_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_geompropvalue_int.osl create mode 100644 materialx/libraries/stdlib/osl/mx_geompropvalue_string.osl create mode 100644 materialx/libraries/stdlib/osl/mx_geompropvalue_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_geompropvalue_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_geompropvalue_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_heighttonormal_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_hsvadjust_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_hsvadjust_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_hsvtorgb_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_hsvtorgb_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_hueshift_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_hueshift_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_image_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_image_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_image_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_image_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_image_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_image_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_in_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_inside_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_inside_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_inside_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_invert_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_invert_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_invert_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_invert_float_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_invert_float_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_invert_float_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_invert_float_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_invert_float_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_invert_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_invert_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_invert_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_ln_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_ln_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_ln_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_ln_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_ln_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_ln_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_luminance_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_luminance_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_magnitude_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_magnitude_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_magnitude_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_mask_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_matrix_invert_matrix33.osl create mode 100644 materialx/libraries/stdlib/osl/mx_matrix_invert_matrix44.osl create mode 100644 materialx/libraries/stdlib/osl/mx_matte_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_max_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_max_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_max_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_max_float_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_max_float_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_max_float_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_max_float_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_max_float_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_max_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_max_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_max_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_min_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_min_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_min_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_min_float_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_min_float_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_min_float_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_min_float_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_min_float_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_min_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_min_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_min_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_mix_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_mix_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_mix_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_mix_surfaceshader.osl create mode 100644 materialx/libraries/stdlib/osl/mx_mix_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_mix_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_mix_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_modulo_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_modulo_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_modulo_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_modulo_float_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_modulo_float_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_modulo_float_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_modulo_float_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_modulo_float_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_modulo_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_modulo_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_modulo_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_mult_surfaceshader_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_mult_surfaceshader_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_multiply_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_multiply_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_multiply_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_multiply_float_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_multiply_float_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_multiply_float_matrix33.osl create mode 100644 materialx/libraries/stdlib/osl/mx_multiply_float_matrix44.osl create mode 100644 materialx/libraries/stdlib/osl/mx_multiply_float_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_multiply_float_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_multiply_float_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_multiply_matrix33.osl create mode 100644 materialx/libraries/stdlib/osl/mx_multiply_matrix44.osl create mode 100644 materialx/libraries/stdlib/osl/mx_multiply_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_multiply_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_multiply_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_noise2d_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_noise2d_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_noise2d_fa_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_noise2d_fa_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_noise2d_fa_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_noise2d_fa_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_noise2d_fa_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_noise2d_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_noise2d_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_noise2d_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_noise2d_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_noise3d_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_noise3d_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_noise3d_fa_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_noise3d_fa_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_noise3d_fa_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_noise3d_fa_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_noise3d_fa_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_noise3d_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_noise3d_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_noise3d_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_noise3d_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_normal_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_normalize_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_normalize_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_normalize_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_out_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_outside_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_outside_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_outside_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_over_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_overlay_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_overlay_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_overlay_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_position_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_power_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_power_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_power_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_power_float_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_power_float_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_power_float_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_power_float_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_power_float_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_power_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_power_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_power_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_premult_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_premult_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_ramp4_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_ramp4_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_ramp4_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_ramp4_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_ramp4_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_ramp4_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_ramplr_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_ramplr_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_ramplr_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_ramplr_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_ramplr_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_ramplr_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_ramptb_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_ramptb_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_ramptb_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_ramptb_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_ramptb_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_ramptb_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_remap_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_remap_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_remap_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_remap_float_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_remap_float_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_remap_float_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_remap_float_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_remap_float_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_remap_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_remap_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_remap_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_rgbtohsv_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_rgbtohsv_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_rotate2d_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_rotate_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_rotate_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_scale_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_scale_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_screen_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_screen_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_screen_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_separate_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_separate_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_separate_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_separate_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_separate_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_sign_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_sign_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_sign_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_sign_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_sign_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_sign_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_sin_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_sin_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_sin_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_sin_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_sin_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_sin_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_smoothstep_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_smoothstep_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_smoothstep_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_smoothstep_float_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_smoothstep_float_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_smoothstep_float_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_smoothstep_float_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_smoothstep_float_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_smoothstep_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_smoothstep_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_smoothstep_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_splitlr_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_splitlr_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_splitlr_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_splitlr_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_splitlr_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_splitlr_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_splittb_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_splittb_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_splittb_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_splittb_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_splittb_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_splittb_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_sqrt_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_sqrt_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_sqrt_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_sqrt_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_sqrt_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_sqrt_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_subtract_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_subtract_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_subtract_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_subtract_float_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_subtract_float_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_subtract_float_matrix33.osl create mode 100644 materialx/libraries/stdlib/osl/mx_subtract_float_matrix44.osl create mode 100644 materialx/libraries/stdlib/osl/mx_subtract_float_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_subtract_float_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_subtract_float_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_subtract_matrix33.osl create mode 100644 materialx/libraries/stdlib/osl/mx_subtract_matrix44.osl create mode 100644 materialx/libraries/stdlib/osl/mx_subtract_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_subtract_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_subtract_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_switch_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_switch_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_switch_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_switch_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_switch_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_switch_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_color4_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_color4_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_color4_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_color4_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_color4_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_color4_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_color_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_color_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_color_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_color_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_color_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_color_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_float_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_float_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_float_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_float_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_float_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_vector2_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_vector2_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_vector2_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_vector2_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_vector2_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_vector2_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_vector4_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_vector4_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_vector4_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_vector4_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_vector4_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_vector4_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_vector_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_vector_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_vector_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_vector_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_vector_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_vector_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_tan_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_tan_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_tan_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_tan_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_tan_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_tan_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_tangent_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_texcoord_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_texcoord_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_tiledimage_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_tiledimage_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_tiledimage_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_tiledimage_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_tiledimage_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_tiledimage_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_time_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_transformnormal_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_transformnormal_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_transformpoint_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_transformpoint_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_transformvector_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_transformvector_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_transpose_matrix33.osl create mode 100644 materialx/libraries/stdlib/osl/mx_transpose_matrix44.osl create mode 100644 materialx/libraries/stdlib/osl/mx_triplanarprojection_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_triplanarprojection_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_triplanarprojection_float.osl create mode 100644 materialx/libraries/stdlib/osl/mx_triplanarprojection_vector.osl create mode 100644 materialx/libraries/stdlib/osl/mx_triplanarprojection_vector2.osl create mode 100644 materialx/libraries/stdlib/osl/mx_triplanarprojection_vector4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_unpremult_color.osl create mode 100644 materialx/libraries/stdlib/osl/mx_unpremult_color4.osl create mode 100644 materialx/libraries/stdlib/osl/mx_viewdirection_vector.osl create mode 100644 materialx/libraries/stdlib/osl/oslutil.h create mode 100644 materialx/libraries/stdlib/osl/stdlib_osl_impl.mtlx create mode 100644 materialx/libraries/stdlib/osl/stdosl.h create mode 100644 materialx/libraries/stdlib/osl/vector2.h create mode 100644 materialx/libraries/stdlib/osl/vector4.h create mode 100644 materialx/libraries/stdlib/stdlib_defs.mtlx create mode 100644 materialx/libraries/stdlib/stdlib_ng.mtlx create mode 100644 materialx/libraries/targets/genglsl.mtlx create mode 100644 materialx/libraries/targets/genmdl.mtlx create mode 100644 materialx/libraries/targets/genosl.mtlx create mode 100644 materialx/logging.py create mode 100644 materialx/node_tree.py create mode 100644 materialx/nodes/.gitignore create mode 100644 materialx/nodes/__init__.py create mode 100644 materialx/nodes/categories.py create mode 100644 materialx/nodes/generate_node_classes.py create mode 100644 materialx/nodes/node.py create mode 100644 materialx/nodes/ui.py create mode 100644 materialx/preferences.py create mode 100644 materialx/utils.py diff --git a/materialx/__init__.py b/materialx/__init__.py new file mode 100644 index 000000000..894d32ccd --- /dev/null +++ b/materialx/__init__.py @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright 2022, AMD + +""" +MaterialX NodeTree addon + MaterialX online library +""" + +bl_info = { + "name": "MaterialX NodeTree", + "description": "MaterialX NodeTree addon + MaterialX online library", + "author": "AMD", + "version": (1, 0, 0), + "blender": (3, 4, 0), + "location": "Editor Type -> MaterialX", + "doc_url": "{BLENDER_MANUAL_URL}/addons/materials/materialx.html", + "warning": "Alpha", + "support": "TESTING", + "category": "Material", +} + +ADDON_PREFIX = "materialx" + + +import bpy + +from . import preferences +from . import node_tree +from . import nodes + +from . import logging +log = logging.Log("") + + +def register(): + log("register") + bpy.utils.register_class(preferences.AddonPreferences) + bpy.utils.register_class(node_tree.MxNodeTree) + nodes.register() + + +def unregister(): + log("unregister") + nodes.unregister() + bpy.utils.unregister_class(node_tree.MxNodeTree) + bpy.utils.unregister_class(preferences.AddonPreferences) diff --git a/materialx/libraries/README.md b/materialx/libraries/README.md new file mode 100644 index 000000000..d2e2b9369 --- /dev/null +++ b/materialx/libraries/README.md @@ -0,0 +1,70 @@ +# MaterialX Data Libraries + +The following is the layout of the definitions and implementations provided as part of the core libraries. + +These libraries can be used to build shading networks which can be accepted by code generators to produce shader code. + +The following core "targets": GLSL, MDL and OSL. + +## Standard Library +- [stdlib](stdlib) + - [stdlib_defs.mtlx](stdlib/stdlib_defs.mtlx) : Single node nodedef definitions file. + - [stdlib_ng.mtlx](stdlib/stdlib_ng.mtlx) : Node graph definitions file. + - [genglsl](stdlib/genglsl): GLSL language support. + - lib : Shader utility files. + - [stdlib_genglsl_impl.mtlx](stdlib/genglsl/stdlib_genglsl_impl.mtlx) : Mapping from definitions to implementations + - [stdlib_genglsl_cm_impl.mtlx](stdlib/genglsl/stdlib_genglsl_cm_impl.mtlx) : Minimal set of "default" color management implementations. + - [stdlib_genglsl_unit_impl.mtlx](stdlib/genosl/stdlib_genglsl_unit_impl.mtlx) : Real world unit support implementations. + - GLSL implementation files. + - [genosl](stdlib/genosl): OSL language support. + - lib: Shader utility files. + - [stdlib_genosl_impl.mtlx](stdlib/genosl/stdlib_genosl_impl.mtlx) : Mapping from definitions to implementations + - [stdlib_genosl_cm_impl.mtlx](stdlib/genosl/stdlib_genosl_cm_impl.mtlx) : Minimal set of "default" color management implementations. + - [stdlib_genosl_unit_impl.mtlx](stdlib/genosl/stdlib_genosl_unit_impl.mtlx) : Real world unit support implementations. + - OSL implementation files. + - [osl](stdlib/osl): OSL reference implementation + - OSL implementation files. + - [genmdl](stdlib/genmdl): MDL language support. + - [stdlib_genmdl_impl.mtlx](stdlib/genosl/stdlib_genmdl_impl.mtlx) : Mapping from definitions to implementations + - [stdlib_genmdl_cm_impl.mtlx](stdlib/genosl/stdlib_genmdl_cm_impl.mtlx) : Minimal set of "default" color management implementations. + - [stdlib_genmdl_unit_impl.mtlx](stdlib/genosl/stdlib_genmdl_unit_impl.mtlx) : Real world unit support implementations. + +## Physically-Based Shading Library +- [pbrlib](pbrlib) + - [pbrlib_defs.mtlx](pbrlib/pbrlib_defs.mtlx) : Single node definitions file. + - [pbrlib_ng.mtlx](pbrlib/pbrlib_ng.mtlx) : Node graph definitions file. + - [genglsl](pbrlib/genglsl) : GLSL language support + - lib : Shader utility files. + - [pbrlib_genglsl_impl.mtlx](pbrlib/genglsl/pbrlib_genglsl_impl.mtlx) : Mapping from definitions to implementations + - GLSL implementation files. + - [genosl](pbrlib/genosl) : OSL language support + - lib : Utilities + - [pbrlib_genosl_impl.mtlx](pbrlib/genosl/pbrlib_genosl_impl.mtlx) : Mapping from definitions to implementations + - OSL implementation files. + - [genmdl](pbrlib/genmdl) : MDL language support + - [pbrlib_genmdl_impl.mtlx](pbrlib/genosl/pbrlib_genmdl_impl.mtlx) : Mapping from definitions to implementations. + - Note: MDL implementation files are in a "package" folder found under + [source/MaterialXGenMdl/mdl/materialx](../source/MaterialXGenMdl/mdl/materialx) + +## Target Definitions +- Each target implementation requires a target definition for definition / implementation correspondence to work. +- [targets](targets) is the folder holding documents which declare these definitions. +- There are definition files for the following core targets: + - OSL : `genosl` + - Desktop GLSL : `genglsl` + - MDL : `genmdl` +- Any additional target files should be added under this folder and loaded in as required. + +### Target Support +- GLSL target support is for version 4.0 or higher. +- OSL target support is for version 1.9.10 or higher. +- MDL target support is for version 1.6. +- "Default" color management support includes OSL, GLSL, and MDL implementations for the following non-LUT transforms: + - lin_rec709, gamma18, gamma22, gamma24, acescg, g22_acescg, srgb_texture +- Basic GLSL `lightshader` node definitions and implementations are provided for the following light types: + - point, directional, spot +- Code generation does not currently support: + - `ambientocclusion` node. + - `arrayappend` node. + - `curveadjust` node. + - `displacementshader` and `volumeshader` nodes and associated operations (`add`, `multiply`, `mix`) for GLSL targets. diff --git a/materialx/libraries/alglib/alglib_defs.mtlx b/materialx/libraries/alglib/alglib_defs.mtlx new file mode 100644 index 000000000..c80c785b6 --- /dev/null +++ b/materialx/libraries/alglib/alglib_defs.mtlx @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/materialx/libraries/alglib/alglib_ng.mtlx b/materialx/libraries/alglib/alglib_ng.mtlx new file mode 100644 index 000000000..6fb3910c1 --- /dev/null +++ b/materialx/libraries/alglib/alglib_ng.mtlx @@ -0,0 +1,518 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/materialx/libraries/bxdf/disney_brdf_2012.mtlx b/materialx/libraries/bxdf/disney_brdf_2012.mtlx new file mode 100644 index 000000000..f6a66bb7a --- /dev/null +++ b/materialx/libraries/bxdf/disney_brdf_2012.mtlx @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/materialx/libraries/bxdf/disney_brdf_2015.mtlx b/materialx/libraries/bxdf/disney_brdf_2015.mtlx new file mode 100644 index 000000000..afc3c4311 --- /dev/null +++ b/materialx/libraries/bxdf/disney_brdf_2015.mtlx @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/materialx/libraries/bxdf/standard_surface.mtlx b/materialx/libraries/bxdf/standard_surface.mtlx new file mode 100644 index 000000000..68b5fe3fd --- /dev/null +++ b/materialx/libraries/bxdf/standard_surface.mtlx @@ -0,0 +1,327 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/materialx/libraries/bxdf/usd_preview_surface.mtlx b/materialx/libraries/bxdf/usd_preview_surface.mtlx new file mode 100644 index 000000000..04ce67ba5 --- /dev/null +++ b/materialx/libraries/bxdf/usd_preview_surface.mtlx @@ -0,0 +1,335 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/materialx/libraries/lights/genglsl/lights_genglsl_impl.mtlx b/materialx/libraries/lights/genglsl/lights_genglsl_impl.mtlx new file mode 100644 index 000000000..cde8de51e --- /dev/null +++ b/materialx/libraries/lights/genglsl/lights_genglsl_impl.mtlx @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/materialx/libraries/lights/genglsl/mx_directional_light.glsl b/materialx/libraries/lights/genglsl/mx_directional_light.glsl new file mode 100644 index 000000000..634c5fe99 --- /dev/null +++ b/materialx/libraries/lights/genglsl/mx_directional_light.glsl @@ -0,0 +1,5 @@ +void mx_directional_light(LightData light, vec3 position, out lightshader result) +{ + result.direction = -light.direction; + result.intensity = light.color * light.intensity; +} diff --git a/materialx/libraries/lights/genglsl/mx_point_light.glsl b/materialx/libraries/lights/genglsl/mx_point_light.glsl new file mode 100644 index 000000000..c94b2225a --- /dev/null +++ b/materialx/libraries/lights/genglsl/mx_point_light.glsl @@ -0,0 +1,8 @@ +void mx_point_light(LightData light, vec3 position, out lightshader result) +{ + result.direction = light.position - position; + float distance = length(result.direction) + M_FLOAT_EPS; + float attenuation = pow(distance + 1.0, light.decay_rate + M_FLOAT_EPS); + result.intensity = light.color * light.intensity / attenuation; + result.direction /= distance; +} diff --git a/materialx/libraries/lights/genglsl/mx_spot_light.glsl b/materialx/libraries/lights/genglsl/mx_spot_light.glsl new file mode 100644 index 000000000..b3607844c --- /dev/null +++ b/materialx/libraries/lights/genglsl/mx_spot_light.glsl @@ -0,0 +1,13 @@ +void mx_spot_light(LightData light, vec3 position, out lightshader result) +{ + result.direction = light.position - position; + float distance = length(result.direction) + M_FLOAT_EPS; + float attenuation = pow(distance + 1.0, light.decay_rate + M_FLOAT_EPS); + result.intensity = light.color * light.intensity / attenuation; + result.direction /= distance; + float low = min(light.inner_angle, light.outer_angle); + float high = light.inner_angle; + float cosDir = dot(result.direction, -light.direction); + float spotAttenuation = smoothstep(low, high, cosDir); + result.intensity *= spotAttenuation; +} diff --git a/materialx/libraries/lights/lights_defs.mtlx b/materialx/libraries/lights/lights_defs.mtlx new file mode 100644 index 000000000..f212a187e --- /dev/null +++ b/materialx/libraries/lights/lights_defs.mtlx @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/materialx/libraries/pbrlib/genglsl/lib/mx_defines.glsl b/materialx/libraries/pbrlib/genglsl/lib/mx_defines.glsl new file mode 100644 index 000000000..7abee973e --- /dev/null +++ b/materialx/libraries/pbrlib/genglsl/lib/mx_defines.glsl @@ -0,0 +1,4 @@ +#define M_PI 3.1415926535897932384626433832795 +#define M_PI_INV 1.0/3.1415926535897932384626433832795 +#define M_GOLDEN_RATIO 1.6180339887498948482045868343656 +#define M_FLOAT_EPS 1e-8 diff --git a/materialx/libraries/pbrlib/genglsl/lib/mx_environment_fis.glsl b/materialx/libraries/pbrlib/genglsl/lib/mx_environment_fis.glsl new file mode 100644 index 000000000..4f2ed7c62 --- /dev/null +++ b/materialx/libraries/pbrlib/genglsl/lib/mx_environment_fis.glsl @@ -0,0 +1,72 @@ +#include "pbrlib/genglsl/lib/mx_microfacet_specular.glsl" + +int numRadianceSamples() +{ + return min($envRadianceSamples, MAX_ENV_RADIANCE_SAMPLES); +} + +// https://developer.nvidia.com/gpugems/GPUGems3/gpugems3_ch20.html +// Section 20.4 Equation 13 +float mx_latlong_compute_lod(vec3 dir, float pdf, float maxMipLevel, int envSamples) +{ + const float MIP_LEVEL_OFFSET = 1.5; + float effectiveMaxMipLevel = maxMipLevel - MIP_LEVEL_OFFSET; + float distortion = sqrt(1.0 - mx_square(dir.y)); + return max(effectiveMaxMipLevel - 0.5 * log2(envSamples * pdf * distortion), 0.0); +} + +vec3 mx_environment_radiance(vec3 N, vec3 V, vec3 X, vec2 roughness, int distribution, FresnelData fd) +{ + vec3 Y = normalize(cross(N, X)); + X = cross(Y, N); + + // Compute shared dot products. + float NdotV = clamp(dot(N, V), M_FLOAT_EPS, 1.0); + + // Integrate outgoing radiance using filtered importance sampling. + // http://cgg.mff.cuni.cz/~jaroslav/papers/2008-egsr-fis/2008-egsr-fis-final-embedded.pdf + vec3 radiance = vec3(0.0); + int envRadianceSamples = numRadianceSamples(); + for (int i = 0; i < envRadianceSamples; i++) + { + vec2 Xi = mx_spherical_fibonacci(i, envRadianceSamples); + + // Compute the half vector and incoming light direction. + vec3 H = mx_ggx_importance_sample_NDF(Xi, X, Y, N, roughness.x, roughness.y); + vec3 L = -reflect(V, H); + + // Compute dot products for this sample. + float NdotH = clamp(dot(N, H), M_FLOAT_EPS, 1.0); + float NdotL = clamp(dot(N, L), M_FLOAT_EPS, 1.0); + float VdotH = clamp(dot(V, H), M_FLOAT_EPS, 1.0); + float LdotH = VdotH; + + // Sample the environment light from the given direction. + float pdf = mx_ggx_PDF(X, Y, H, NdotH, LdotH, roughness.x, roughness.y); + float lod = mx_latlong_compute_lod(L, pdf, $envRadianceMips - 1, envRadianceSamples); + vec3 sampleColor = mx_latlong_map_lookup(L, $envMatrix, lod, $envRadiance); + + // Compute the Fresnel term. + vec3 F = mx_compute_fresnel(VdotH, fd); + + // Compute the geometric term. + float G = mx_ggx_smith_G(NdotL, NdotV, mx_average_roughness(roughness)); + + // Add the radiance contribution of this sample. + // From https://cdn2.unrealengine.com/Resources/files/2013SiggraphPresentationsNotes-26915738.pdf + // incidentLight = sampleColor * NdotL + // microfacetSpecular = D * F * G / (4 * NdotL * NdotV) + // pdf = D * NdotH / (4 * VdotH) + // radiance = incidentLight * microfacetSpecular / pdf + radiance += sampleColor * F * G * VdotH / (NdotV * NdotH); + } + + // Normalize and return the final radiance. + radiance /= float(envRadianceSamples); + return radiance; +} + +vec3 mx_environment_irradiance(vec3 N) +{ + return mx_latlong_map_lookup(N, $envMatrix, 0.0, $envIrradiance); +} diff --git a/materialx/libraries/pbrlib/genglsl/lib/mx_environment_none.glsl b/materialx/libraries/pbrlib/genglsl/lib/mx_environment_none.glsl new file mode 100644 index 000000000..9e6ff48fe --- /dev/null +++ b/materialx/libraries/pbrlib/genglsl/lib/mx_environment_none.glsl @@ -0,0 +1,11 @@ +#include "pbrlib/genglsl/lib/mx_microfacet_specular.glsl" + +vec3 mx_environment_radiance(vec3 N, vec3 V, vec3 X, vec2 roughness, int distribution, FresnelData fd) +{ + return vec3(0.0); +} + +vec3 mx_environment_irradiance(vec3 N) +{ + return vec3(0.0); +} diff --git a/materialx/libraries/pbrlib/genglsl/lib/mx_environment_prefilter.glsl b/materialx/libraries/pbrlib/genglsl/lib/mx_environment_prefilter.glsl new file mode 100644 index 000000000..ff226d3f5 --- /dev/null +++ b/materialx/libraries/pbrlib/genglsl/lib/mx_environment_prefilter.glsl @@ -0,0 +1,29 @@ +#include "pbrlib/genglsl/lib/mx_microfacet_specular.glsl" + +float mx_latlong_compute_lod(float roughness) +{ + // Select a mip level based on input roughness. + float lodBias = roughness < 0.25 ? sqrt(roughness) : 0.5*roughness + 0.375; + return lodBias * $envRadianceMips; +} + +vec3 mx_environment_radiance(vec3 N, vec3 V, vec3 X, vec2 roughness, int distribution, FresnelData fd) +{ + N = mx_forward_facing_normal(N, V); + vec3 L = reflect(-V, N); + + float NdotV = clamp(dot(N, V), M_FLOAT_EPS, 1.0); + + float avgRoughness = mx_average_roughness(roughness); + vec3 F = mx_compute_fresnel(NdotV, fd); + float G = mx_ggx_smith_G(NdotV, NdotV, avgRoughness); + vec3 comp = mx_ggx_energy_compensation(NdotV, avgRoughness, F); + vec3 Li = mx_latlong_map_lookup(L, $envMatrix, mx_latlong_compute_lod(avgRoughness), $envRadiance); + + return Li * F * G * comp; +} + +vec3 mx_environment_irradiance(vec3 N) +{ + return mx_latlong_map_lookup(N, $envMatrix, 0.0, $envIrradiance); +} diff --git a/materialx/libraries/pbrlib/genglsl/lib/mx_math.glsl b/materialx/libraries/pbrlib/genglsl/lib/mx_math.glsl new file mode 100644 index 000000000..8460e665a --- /dev/null +++ b/materialx/libraries/pbrlib/genglsl/lib/mx_math.glsl @@ -0,0 +1,83 @@ +float mx_square(float x) +{ + return x*x; +} + +vec2 mx_square(vec2 x) +{ + return x*x; +} + +vec3 mx_square(vec3 x) +{ + return x*x; +} + +vec4 mx_square(vec4 x) +{ + return x*x; +} + +float mx_pow5(float x) +{ + return mx_square(mx_square(x)) * x; +} + +float mx_max_component(vec2 v) +{ + return max(v.x, v.y); +} + +float mx_max_component(vec3 v) +{ + return max(max(v.x, v.y), v.z); +} + +float mx_max_component(vec4 v) +{ + return max(max(max(v.x, v.y), v.z), v.w); +} + +bool mx_is_tiny(float v) +{ + return abs(v) < M_FLOAT_EPS; +} + +bool mx_is_tiny(vec3 v) +{ + return all(lessThan(abs(v), vec3(M_FLOAT_EPS))); +} + +float mx_mix(float v00, float v01, float v10, float v11, + float x, float y) +{ + float v0_ = mix(v00, v01, x); + float v1_ = mix(v10, v11, x); + return mix(v0_, v1_, y); +} + +vec2 mx_latlong_projection(vec3 dir) +{ + float latitude = -asin(dir.y) * M_PI_INV + 0.5; + float longitude = atan(dir.x, -dir.z) * M_PI_INV * 0.5 + 0.5; + return vec2(longitude, latitude); +} + +vec3 mx_latlong_map_lookup(vec3 dir, mat4 transform, float lod, sampler2D sampler) +{ + vec3 envDir = normalize((transform * vec4(dir,0.0)).xyz); + vec2 uv = mx_latlong_projection(envDir); + return textureLod(sampler, uv, lod).rgb; +} + +vec3 mx_forward_facing_normal(vec3 N, vec3 V) +{ + if (dot(N, V) < 0.0) + { + return -N; + } + else + { + return N; + } +} diff --git a/materialx/libraries/pbrlib/genglsl/lib/mx_microfacet.glsl b/materialx/libraries/pbrlib/genglsl/lib/mx_microfacet.glsl new file mode 100644 index 000000000..0d5f3c731 --- /dev/null +++ b/materialx/libraries/pbrlib/genglsl/lib/mx_microfacet.glsl @@ -0,0 +1,57 @@ +// Standard Schlick Fresnel +float mx_fresnel_schlick(float cosTheta, float F0) +{ + float x = clamp(1.0 - cosTheta, 0.0, 1.0); + float x5 = mx_pow5(x); + return F0 + (1.0 - F0) * x5; +} +vec3 mx_fresnel_schlick(float cosTheta, vec3 F0) +{ + float x = clamp(1.0 - cosTheta, 0.0, 1.0); + float x5 = mx_pow5(x); + return F0 + (1.0 - F0) * x5; +} + +// Generalized Schlick Fresnel +float mx_fresnel_schlick(float cosTheta, float F0, float F90) +{ + float x = clamp(1.0 - cosTheta, 0.0, 1.0); + float x5 = mx_pow5(x); + return mix(F0, F90, x5); +} +vec3 mx_fresnel_schlick(float cosTheta, vec3 F0, vec3 F90) +{ + float x = clamp(1.0 - cosTheta, 0.0, 1.0); + float x5 = mx_pow5(x); + return mix(F0, F90, x5); +} + +// Generalized Schlick Fresnel with a variable exponent +float mx_fresnel_schlick(float cosTheta, float F0, float F90, float exponent) +{ + float x = clamp(1.0 - cosTheta, 0.0, 1.0); + return mix(F0, F90, pow(x, exponent)); +} +vec3 mx_fresnel_schlick(float cosTheta, vec3 F0, vec3 F90, float exponent) +{ + float x = clamp(1.0 - cosTheta, 0.0, 1.0); + return mix(F0, F90, pow(x, exponent)); +} + +// Compute the average of an anisotropic roughness pair +float mx_average_roughness(vec2 roughness) +{ + return sqrt(roughness.x * roughness.y); +} + +// https://www.graphics.rwth-aachen.de/publication/2/jgt.pdf +float mx_golden_ratio_sequence(int i) +{ + return fract((float(i) + 1.0) * M_GOLDEN_RATIO); +} + +// https://people.irisa.fr/Ricardo.Marques/articles/2013/SF_CGF.pdf +vec2 mx_spherical_fibonacci(int i, int numSamples) +{ + return vec2((float(i) + 0.5) / float(numSamples), mx_golden_ratio_sequence(i)); +} diff --git a/materialx/libraries/pbrlib/genglsl/lib/mx_microfacet_diffuse.glsl b/materialx/libraries/pbrlib/genglsl/lib/mx_microfacet_diffuse.glsl new file mode 100644 index 000000000..985486cd7 --- /dev/null +++ b/materialx/libraries/pbrlib/genglsl/lib/mx_microfacet_diffuse.glsl @@ -0,0 +1,84 @@ +#include "pbrlib/genglsl/lib/mx_microfacet.glsl" + +// Based on the OSL implementation of Oren-Nayar diffuse, which is in turn +// based on https://mimosa-pudica.net/improved-oren-nayar.html. +float mx_oren_nayar_diffuse(vec3 L, vec3 V, vec3 N, float NdotL, float roughness) +{ + float LdotV = clamp(dot(L, V), M_FLOAT_EPS, 1.0); + float NdotV = clamp(dot(N, V), M_FLOAT_EPS, 1.0); + float s = LdotV - NdotL * NdotV; + float stinv = (s > 0.0f) ? s / max(NdotL, NdotV) : 0.0; + + float sigma2 = mx_square(roughness * M_PI); + float A = 1.0 - 0.5 * (sigma2 / (sigma2 + 0.33)); + float B = 0.45 * sigma2 / (sigma2 + 0.09); + + return A + B * stinv; +} + +// https://disney-animation.s3.amazonaws.com/library/s2012_pbs_disney_brdf_notes_v2.pdf +// Section 5.3 +float mx_burley_diffuse(vec3 L, vec3 V, vec3 N, float NdotL, float roughness) +{ + vec3 H = normalize(L + V); + float LdotH = clamp(dot(L, H), M_FLOAT_EPS, 1.0); + float NdotV = clamp(dot(N, V), M_FLOAT_EPS, 1.0); + + float F90 = 0.5 + (2.0 * roughness * mx_square(LdotH)); + float refL = mx_fresnel_schlick(NdotL, 1.0, F90); + float refV = mx_fresnel_schlick(NdotV, 1.0, F90); + return refL * refV; +} + +// Compute the directional albedo component of Burley diffuse for the given +// view angle and roughness. Curve fit provided by Stephen Hill. +float mx_burley_diffuse_directional_albedo(float NdotV, float roughness) +{ + float x = NdotV; + float fit0 = 0.97619 - 0.488095 * mx_pow5(1 - x); + float fit1 = 1.55754 + (-2.02221 + (2.56283 - 1.06244 * x) * x) * x; + return mix(fit0, fit1, roughness); +} + +// Evaluate the Burley diffusion profile for the given distance and diffusion shape. +// Based on https://graphics.pixar.com/library/ApproxBSSRDF/ +vec3 mx_burley_diffusion_profile(float dist, vec3 shape) +{ + vec3 num1 = exp(-shape * dist); + vec3 num2 = exp(-shape * dist / 3.0); + float denom = max(dist, M_FLOAT_EPS); + return (num1 + num2) / denom; +} + +// Integrate the Burley diffusion profile over a sphere of the given radius. +// Inspired by Eric Penner's presentation in http://advances.realtimerendering.com/s2011/ +vec3 mx_integrate_burley_diffusion(vec3 N, vec3 L, float radius, vec3 mfp) +{ + float theta = acos(dot(N, L)); + + // Estimate the Burley diffusion shape from mean free path. + vec3 shape = vec3(1.0) / max(mfp, 0.1); + + // Integrate the profile over the sphere. + vec3 sumD = vec3(0.0); + vec3 sumR = vec3(0.0); + const int SAMPLE_COUNT = 32; + const float SAMPLE_WIDTH = (2.0 * M_PI) / SAMPLE_COUNT; + for (int i = 0; i < SAMPLE_COUNT; i++) + { + float x = -M_PI + (i + 0.5) * SAMPLE_WIDTH; + float dist = radius * abs(2.0 * sin(x * 0.5)); + vec3 R = mx_burley_diffusion_profile(dist, shape); + sumD += R * max(cos(theta + x), 0.0); + sumR += R; + } + + return sumD / sumR; +} + +vec3 mx_subsurface_scattering_approx(vec3 N, vec3 L, vec3 P, vec3 albedo, vec3 mfp) +{ + float curvature = length(fwidth(N)) / length(fwidth(P)); + float radius = 1.0 / max(curvature, 0.01); + return albedo * mx_integrate_burley_diffusion(N, L, radius, mfp) / vec3(M_PI); +} diff --git a/materialx/libraries/pbrlib/genglsl/lib/mx_microfacet_sheen.glsl b/materialx/libraries/pbrlib/genglsl/lib/mx_microfacet_sheen.glsl new file mode 100644 index 000000000..c88bb16e4 --- /dev/null +++ b/materialx/libraries/pbrlib/genglsl/lib/mx_microfacet_sheen.glsl @@ -0,0 +1,52 @@ +#include "pbrlib/genglsl/lib/mx_microfacet.glsl" + +// http://www.aconty.com/pdf/s2017_pbs_imageworks_sheen.pdf +// Equation 2 +float mx_imageworks_sheen_NDF(float cosTheta, float roughness) +{ + float invRoughness = 1.0 / max(roughness, 0.0001); + float cos2 = cosTheta * cosTheta; + float sin2 = 1.0 - cos2; + return (2.0 + invRoughness) * pow(sin2, invRoughness * 0.5) / (2.0 * M_PI); +} + +// LUT for sheen directional albedo. +// A 2D table parameterized with 'cosTheta' (cosine of angle to normal) on x-axis and 'roughness' on y-axis. +#define SHEEN_ALBEDO_TABLE_SIZE 16 +const float u_sheenAlbedo[SHEEN_ALBEDO_TABLE_SIZE*SHEEN_ALBEDO_TABLE_SIZE] = float[]( + 1.6177, 0.978927, 0.618938, 0.391714, 0.245177, 0.150234, 0.0893475, 0.0511377, 0.0280191, 0.0144204, 0.00687674, 0.00295935, 0.00111049, 0.000336768, 7.07119e-05, 6.22646e-06, + 1.1084, 0.813928, 0.621389, 0.479304, 0.370299, 0.284835, 0.21724, 0.163558, 0.121254, 0.0878921, 0.0619052, 0.0419894, 0.0270556, 0.0161443, 0.00848212, 0.00342323, + 0.930468, 0.725652, 0.586532, 0.479542, 0.393596, 0.322736, 0.26353, 0.213565, 0.171456, 0.135718, 0.105481, 0.0800472, 0.0588117, 0.0412172, 0.0268329, 0.0152799, + 0.833791, 0.671201, 0.558957, 0.471006, 0.398823, 0.337883, 0.285615, 0.240206, 0.200696, 0.16597, 0.135422, 0.10859, 0.0850611, 0.0644477, 0.0464763, 0.0308878, + 0.771692, 0.633819, 0.537877, 0.461939, 0.398865, 0.344892, 0.297895, 0.256371, 0.219562, 0.186548, 0.156842, 0.130095, 0.10598, 0.0841919, 0.0645311, 0.04679, + 0.727979, 0.606373, 0.52141, 0.453769, 0.397174, 0.348337, 0.305403, 0.267056, 0.232655, 0.201398, 0.17286, 0.146756, 0.122808, 0.100751, 0.0804254, 0.0616485, + 0.695353, 0.585281, 0.508227, 0.44667, 0.394925, 0.350027, 0.310302, 0.274561, 0.242236, 0.212604, 0.185281, 0.16002, 0.13657, 0.114693, 0.0942543, 0.0750799, + 0.669981, 0.568519, 0.497442, 0.440542, 0.392567, 0.350786, 0.313656, 0.280075, 0.249533, 0.221359, 0.195196, 0.170824, 0.148012, 0.126537, 0.106279, 0.0870713, + 0.649644, 0.554855, 0.488453, 0.435237, 0.390279, 0.351028, 0.316036, 0.284274, 0.255266, 0.228387, 0.203297, 0.179796, 0.157665, 0.136695, 0.116774, 0.0977403, + 0.632951, 0.543489, 0.480849, 0.430619, 0.388132, 0.350974, 0.317777, 0.287562, 0.259885, 0.234153, 0.210041, 0.187365, 0.165914, 0.145488, 0.125983, 0.10724, + 0.61899, 0.533877, 0.47433, 0.426573, 0.386145, 0.35075, 0.319078, 0.290197, 0.263681, 0.238971, 0.215746, 0.193838, 0.173043, 0.153167, 0.134113, 0.115722, + 0.607131, 0.52564, 0.468678, 0.423001, 0.38432, 0.35043, 0.320072, 0.292349, 0.266856, 0.243055, 0.220636, 0.199438, 0.179264, 0.159926, 0.141332, 0.123323, + 0.596927, 0.518497, 0.463731, 0.419829, 0.382647, 0.350056, 0.320842, 0.294137, 0.269549, 0.246564, 0.224875, 0.204331, 0.18474, 0.165919, 0.147778, 0.130162, + 0.588052, 0.512241, 0.459365, 0.416996, 0.381114, 0.349657, 0.321448, 0.295641, 0.271862, 0.24961, 0.228584, 0.208643, 0.189596, 0.171266, 0.153566, 0.136341, + 0.580257, 0.506717, 0.455481, 0.41445, 0.379708, 0.34925, 0.321929, 0.296923, 0.273869, 0.252279, 0.231859, 0.212472, 0.193933, 0.176066, 0.158788, 0.141945, + 0.573355, 0.5018, 0.452005, 0.412151, 0.378416, 0.348844, 0.322316, 0.298028, 0.275627, 0.254638, 0.234772, 0.215896, 0.197828, 0.180398, 0.163522, 0.147049 +); + +float mx_imageworks_sheen_directional_albedo(float cosTheta, float roughness) +{ + float x = cosTheta * (SHEEN_ALBEDO_TABLE_SIZE - 1); + float y = roughness * (SHEEN_ALBEDO_TABLE_SIZE - 1); + int ix = int(x); + int iy = int(y); + int ix2 = clamp(ix + 1, 0, SHEEN_ALBEDO_TABLE_SIZE - 1); + int iy2 = clamp(iy + 1, 0, SHEEN_ALBEDO_TABLE_SIZE - 1); + float fx = x - ix; + float fy = y - iy; + + // Bi-linear interpolation of the LUT values + float v1 = mix(u_sheenAlbedo[iy * SHEEN_ALBEDO_TABLE_SIZE + ix], u_sheenAlbedo[iy * SHEEN_ALBEDO_TABLE_SIZE + ix2], fx); + float v2 = mix(u_sheenAlbedo[iy2 * SHEEN_ALBEDO_TABLE_SIZE + ix], u_sheenAlbedo[iy2 * SHEEN_ALBEDO_TABLE_SIZE + ix2], fx); + float albedo = mix(v1, v2, fy); + + return clamp(albedo, 0.0, 1.0); +} diff --git a/materialx/libraries/pbrlib/genglsl/lib/mx_microfacet_specular.glsl b/materialx/libraries/pbrlib/genglsl/lib/mx_microfacet_specular.glsl new file mode 100644 index 000000000..5aad7d3de --- /dev/null +++ b/materialx/libraries/pbrlib/genglsl/lib/mx_microfacet_specular.glsl @@ -0,0 +1,386 @@ +#include "pbrlib/genglsl/lib/mx_microfacet.glsl" + +// https://disney-animation.s3.amazonaws.com/library/s2012_pbs_disney_brdf_notes_v2.pdf +// Appendix B.2 Equation 13 +float mx_ggx_NDF(vec3 X, vec3 Y, vec3 H, float NdotH, float alphaX, float alphaY) +{ + float XdotH = dot(X, H); + float YdotH = dot(Y, H); + float denom = mx_square(XdotH / alphaX) + mx_square(YdotH / alphaY) + mx_square(NdotH); + return 1.0 / (M_PI * alphaX * alphaY * mx_square(denom)); +} + +// https://disney-animation.s3.amazonaws.com/library/s2012_pbs_disney_brdf_notes_v2.pdf +// Appendix B.1 Equation 3 +float mx_ggx_PDF(vec3 X, vec3 Y, vec3 H, float NdotH, float LdotH, float alphaX, float alphaY) +{ + return mx_ggx_NDF(X, Y, H, NdotH, alphaX, alphaY) * NdotH / (4.0 * LdotH); +} + +// https://disney-animation.s3.amazonaws.com/library/s2012_pbs_disney_brdf_notes_v2.pdf +// Appendix B.2 Equation 15 +vec3 mx_ggx_importance_sample_NDF(vec2 Xi, vec3 X, vec3 Y, vec3 N, float alphaX, float alphaY) +{ + float phi = 2.0 * M_PI * Xi.x; + float tanTheta = sqrt(Xi.y / (1.0 - Xi.y)); + vec3 H = X * (tanTheta * alphaX * cos(phi)) + + Y * (tanTheta * alphaY * sin(phi)) + + N; + return normalize(H); +} + +// http://jcgt.org/published/0003/02/03/paper.pdf +// Equations 72 and 99 +float mx_ggx_smith_G(float NdotL, float NdotV, float alpha) +{ + float alpha2 = mx_square(alpha); + float lambdaL = sqrt(alpha2 + (1.0 - alpha2) * mx_square(NdotL)); + float lambdaV = sqrt(alpha2 + (1.0 - alpha2) * mx_square(NdotV)); + return 2.0 / (lambdaL / NdotL + lambdaV / NdotV); +} + +// https://www.unrealengine.com/blog/physically-based-shading-on-mobile +vec3 mx_ggx_directional_albedo_curve_fit(float NdotV, float roughness, vec3 F0, vec3 F90) +{ + const vec4 c0 = vec4(-1, -0.0275, -0.572, 0.022); + const vec4 c1 = vec4( 1, 0.0425, 1.04, -0.04 ); + vec4 r = roughness * c0 + c1; + float a004 = min(r.x * r.x, exp2(-9.28 * NdotV)) * r.x + r.y; + vec2 AB = vec2(-1.04, 1.04) * a004 + r.zw; + return F0 * AB.x + F90 * AB.y; +} + +vec3 mx_ggx_directional_albedo_table_lookup(float NdotV, float roughness, vec3 F0, vec3 F90) +{ +#if DIRECTIONAL_ALBEDO_METHOD == 1 + vec2 res = textureSize($albedoTable, 0); + if (res.x > 1) + { + vec2 AB = texture($albedoTable, vec2(NdotV, roughness)).rg; + return F0 * AB.x + F90 * AB.y; + } +#endif + return vec3(0.0); +} + +// https://cdn2.unrealengine.com/Resources/files/2013SiggraphPresentationsNotes-26915738.pdf +vec3 mx_ggx_directional_albedo_importance_sample(float NdotV, float roughness, vec3 F0, vec3 F90) +{ + NdotV = clamp(NdotV, M_FLOAT_EPS, 1.0); + vec3 V = vec3(sqrt(1.0f - mx_square(NdotV)), 0, NdotV); + + vec2 AB = vec2(0.0); + const int SAMPLE_COUNT = 64; + for (int i = 0; i < SAMPLE_COUNT; i++) + { + vec2 Xi = mx_spherical_fibonacci(i, SAMPLE_COUNT); + + // Compute the half vector and incoming light direction. + vec3 H = mx_ggx_importance_sample_NDF(Xi, vec3(1, 0, 0), vec3(0, 1, 0), vec3(0, 0, 1), roughness, roughness); + vec3 L = -reflect(V, H); + + // Compute dot products for this sample. + float NdotL = clamp(L.z, M_FLOAT_EPS, 1.0); + float NdotH = clamp(H.z, M_FLOAT_EPS, 1.0); + float VdotH = clamp(dot(V, H), M_FLOAT_EPS, 1.0); + + // Compute the Fresnel term. + float Fc = mx_fresnel_schlick(VdotH, 0.0, 1.0); + + // Compute the geometric visibility term. + float Gvis = mx_ggx_smith_G(NdotL, NdotV, roughness) * VdotH / (NdotH * NdotV); + + // Add the contribution of this sample. + AB += vec2(Gvis * (1 - Fc), Gvis * Fc); + } + + // Normalize integrated terms. + AB /= SAMPLE_COUNT; + + // Return the final directional albedo. + return F0 * AB.x + F90 * AB.y; +} + +vec3 mx_ggx_directional_albedo(float NdotV, float roughness, vec3 F0, vec3 F90) +{ +#if DIRECTIONAL_ALBEDO_METHOD == 0 + return mx_ggx_directional_albedo_curve_fit(NdotV, roughness, F0, F90); +#elif DIRECTIONAL_ALBEDO_METHOD == 1 + return mx_ggx_directional_albedo_table_lookup(NdotV, roughness, F0, F90); +#else + return mx_ggx_directional_albedo_importance_sample(NdotV, roughness, F0, F90); +#endif +} + +float mx_ggx_directional_albedo(float NdotV, float roughness, float F0, float F90) +{ + return mx_ggx_directional_albedo(NdotV, roughness, vec3(F0), vec3(F90)).x; +} + +// https://blog.selfshadow.com/publications/turquin/ms_comp_final.pdf +// Equations 14 and 16 +vec3 mx_ggx_energy_compensation(float NdotV, float roughness, vec3 Fss) +{ + float Ess = mx_ggx_directional_albedo(NdotV, roughness, 1.0, 1.0); + return 1.0 + Fss * (1.0 - Ess) / Ess; +} + +float mx_ggx_energy_compensation(float NdotV, float roughness, float Fss) +{ + return mx_ggx_energy_compensation(NdotV, roughness, vec3(Fss)).x; +} + +// Convert a real-valued index of refraction to normal-incidence reflectivity. +float mx_ior_to_f0(float ior) +{ + return mx_square((ior - 1.0) / (ior + 1.0)); +} + +// https://seblagarde.wordpress.com/2013/04/29/memo-on-fresnel-equations/ +float mx_fresnel_dielectric(float cosTheta, float ior) +{ + if (cosTheta < 0.0) + return 1.0; + + float g = ior*ior + cosTheta*cosTheta - 1.0; + // Check for total internal reflection + if (g < 0.0) + return 1.0; + + g = sqrt(g); + float gmc = g - cosTheta; + float gpc = g + cosTheta; + float x = gmc / gpc; + float y = (gpc * cosTheta - 1.0) / (gmc * cosTheta + 1.0); + return 0.5 * x * x * (1.0 + y * y); +} + +vec3 mx_fresnel_conductor(float cosTheta, vec3 n, vec3 k) +{ + float c2 = cosTheta*cosTheta; + vec3 n2_k2 = n*n + k*k; + vec3 nc2 = 2.0 * n * cosTheta; + + vec3 rs_a = n2_k2 + c2; + vec3 rp_a = n2_k2 * c2 + 1.0; + vec3 rs = (rs_a - nc2) / (rs_a + nc2); + vec3 rp = (rp_a - nc2) / (rp_a + nc2); + + return 0.5 * (rs + rp); +} + +// Fresnel for dielectric/dielectric interface and polarized light. +void mx_fresnel_dielectric_polarized(float cosTheta, float n1, float n2, out vec2 F, out vec2 phi) +{ + float eta2 = mx_square(n1 / n2); + float st2 = 1.0 - cosTheta*cosTheta; + + // Check for total internal reflection + if(eta2*st2 > 1.0) + { + F = vec2(1.0); + float s = sqrt(st2 - 1.0/eta2) / cosTheta; + phi = 2.0 * atan(vec2(-eta2 * s, -s)); + return; + } + + float cosTheta_t = sqrt(1 - eta2 * st2); + vec2 r = vec2((n2*cosTheta - n1*cosTheta_t) / (n2*cosTheta + n1*cosTheta_t), + (n1*cosTheta - n2*cosTheta_t) / (n1*cosTheta + n2*cosTheta_t)); + F = mx_square(r); + phi.x = (r.x < 0.0) ? M_PI : 0.0; + phi.y = (r.y < 0.0) ? M_PI : 0.0; +} + +// Fresnel for dielectric/conductor interface and polarized light. +// TODO: Optimize this functions and support wavelength dependent complex refraction index. +void mx_fresnel_conductor_polarized(float cosTheta, float n1, float n2, float k, out vec2 F, out vec2 phi) +{ + if (k == 0) + { + // Use dielectric formula to avoid numerical issues + mx_fresnel_dielectric_polarized(cosTheta, n1, n2, F, phi); + return; + } + + float A = mx_square(n2) * (1.0 - mx_square(k)) - mx_square(n1) * (1.0 - mx_square(cosTheta)); + float B = sqrt(mx_square(A) + mx_square(2.0 * mx_square(n2) * k)); + float U = sqrt((A+B) / 2.0); + float V = sqrt((B-A) / 2.0); + + F.y = (mx_square(n1*cosTheta - U) + mx_square(V)) / (mx_square(n1*cosTheta + U) + mx_square(V)); + phi.y = atan(2.0*n1 * V*cosTheta, mx_square(U) + mx_square(V) - mx_square(n1*cosTheta)) + M_PI; + + F.x = (mx_square(mx_square(n2) * (1.0 - mx_square(k)) * cosTheta - n1*U) + mx_square(2.0 * mx_square(n2) * k * cosTheta - n1*V)) / + (mx_square(mx_square(n2) * (1.0 - mx_square(k)) * cosTheta + n1*U) + mx_square(2.0 * mx_square(n2) * k * cosTheta + n1*V)); + phi.x = atan(2.0 * n1 * mx_square(n2) * cosTheta * (2*k*U - (1.0 - mx_square(k)) * V), mx_square(mx_square(n2) * (1.0 + mx_square(k)) * cosTheta) - mx_square(n1) * (mx_square(U) + mx_square(V))); +} + +// XYZ to CIE 1931 RGB color space (using neutral E illuminant) +const mat3 XYZ_TO_RGB = mat3(2.3706743, -0.5138850, 0.0052982, -0.9000405, 1.4253036, -0.0146949, -0.4706338, 0.0885814, 1.0093968); + +// Depolarization functions for natural light +float mx_depolarize(vec2 v) +{ + return 0.5 * (v.x + v.y); +} +vec3 mx_depolarize(vec3 s, vec3 p) +{ + return 0.5 * (s + p); +} + +// Evaluation XYZ sensitivity curves in Fourier space +vec3 mx_eval_sensitivity(float opd, float shift) +{ + // Use Gaussian fits, given by 3 parameters: val, pos and var + float phase = 2*M_PI * opd; + vec3 val = vec3(5.4856e-13, 4.4201e-13, 5.2481e-13); + vec3 pos = vec3(1.6810e+06, 1.7953e+06, 2.2084e+06); + vec3 var = vec3(4.3278e+09, 9.3046e+09, 6.6121e+09); + vec3 xyz = val * sqrt(2*M_PI * var) * cos(pos * phase + shift) * exp(- var * phase*phase); + xyz.x += 9.7470e-14 * sqrt(2*M_PI * 4.5282e+09) * cos(2.2399e+06 * phase + shift) * exp(- 4.5282e+09 * phase*phase); + return xyz / 1.0685e-7; +} + +// A Practical Extension to Microfacet Theory for the Modeling of Varying Iridescence +// https://belcour.github.io/blog/research/2017/05/01/brdf-thin-film.html +vec3 mx_fresnel_airy(float cosTheta, vec3 ior, vec3 extinction, float tf_thickness, float tf_ior) +{ + // Convert nm -> m + float d = tf_thickness * 1.0e-9; + + // Assume vacuum on the outside + float eta1 = 1.0; + float eta2 = tf_ior; + + // Optical path difference + float cosTheta2 = sqrt(1.0 - mx_square(eta1/eta2) * (1.0 - mx_square(cosTheta))); + float D = 2.0 * eta2 * d * cosTheta2; + + // First interface + vec2 R12, phi12; + mx_fresnel_dielectric_polarized(cosTheta, eta1, eta2, R12, phi12); + vec2 R21 = R12; + vec2 T121 = vec2(1.0) - R12; + vec2 phi21 = vec2(M_PI) - phi12; + + // Second interface + vec2 R23, phi23; + mx_fresnel_conductor_polarized(cosTheta2, eta2, ior.x, extinction.x, R23, phi23); + + // Phase shift + vec2 phi2 = phi21 + phi23; + + // Compound terms + vec3 R = vec3(0.0); + vec2 R123 = R12*R23; + vec2 r123 = sqrt(R123); + vec2 Rs = mx_square(T121)*R23 / (1-R123); + + // Reflectance term for m=0 (DC term amplitude) + vec2 C0 = R12 + Rs; + vec3 S0 = mx_eval_sensitivity(0.0, 0.0); + R += mx_depolarize(C0) * S0; + + // Reflectance term for m>0 (pairs of diracs) + vec2 Cm = Rs - T121; + for (int m=1; m<=3; ++m) + { + Cm *= r123; + vec3 SmS = 2.0 * mx_eval_sensitivity(m*D, m*phi2.x); + vec3 SmP = 2.0 * mx_eval_sensitivity(m*D, m*phi2.y); + R += mx_depolarize(Cm.x*SmS, Cm.y*SmP); + } + + // Convert back to RGB reflectance + R = clamp(XYZ_TO_RGB * R, vec3(0.0), vec3(1.0)); + + return R; +} + +// Parameters for Fresnel calculations. +struct FresnelData +{ + vec3 ior; // In Schlick Fresnel mode these two + vec3 extinction; // hold F0 and F90 reflectance values + float exponent; + float tf_thickness; + float tf_ior; + int model; +}; + +FresnelData mx_init_fresnel_dielectric(float ior) +{ + FresnelData fd = FresnelData(vec3(0), vec3(0), 0, 0, 0, -1); + fd.model = 0; + fd.ior = vec3(ior); + fd.tf_thickness = 0.0f; + return fd; +} + +FresnelData mx_init_fresnel_conductor(vec3 ior, vec3 extinction) +{ + FresnelData fd = FresnelData(vec3(0), vec3(0), 0, 0, 0, -1); + fd.model = 1; + fd.ior = ior; + fd.extinction = extinction; + fd.tf_thickness = 0.0f; + return fd; +} + +FresnelData mx_init_fresnel_schlick(vec3 F0) +{ + FresnelData fd = FresnelData(vec3(0), vec3(0), 0, 0, 0, -1); + fd.model = 2; + fd.ior = F0; + fd.extinction = vec3(1.0); + fd.exponent = 5.0f; + fd.tf_thickness = 0.0f; + return fd; +} + +FresnelData mx_init_fresnel_schlick(vec3 F0, vec3 F90, float exponent) +{ + FresnelData fd = FresnelData(vec3(0), vec3(0), 0, 0, 0, -1); + fd.model = 2; + fd.ior = F0; + fd.extinction = F90; + fd.exponent = exponent; + fd.tf_thickness = 0.0f; + return fd; +} + +FresnelData mx_init_fresnel_dielectric_airy(float ior, float tf_thickness, float tf_ior) +{ + FresnelData fd = FresnelData(vec3(0), vec3(0), 0, 0, 0, -1); + fd.model = 3; + fd.ior = vec3(ior); + fd.extinction = vec3(0.0); + fd.tf_thickness = tf_thickness; + fd.tf_ior = tf_ior; + return fd; +} + +FresnelData mx_init_fresnel_conductor_airy(vec3 ior, vec3 extinction, float tf_thickness, float tf_ior) +{ + FresnelData fd = FresnelData(vec3(0), vec3(0), 0, 0, 0, -1); + fd.model = 3; + fd.ior = ior; + fd.extinction = extinction; + fd.tf_thickness = tf_thickness; + fd.tf_ior = tf_ior; + return fd; +} + +vec3 mx_compute_fresnel(float cosTheta, FresnelData fd) +{ + if (fd.model == 0) + return vec3(mx_fresnel_dielectric(cosTheta, fd.ior.x)); + else if (fd.model == 1) + return mx_fresnel_conductor(cosTheta, fd.ior, fd.extinction); + else if (fd.model == 2) + // ior & extinction holds F0 & F90 + return mx_fresnel_schlick(cosTheta, fd.ior, fd.extinction, fd.exponent); + else + return mx_fresnel_airy(cosTheta, fd.ior, fd.extinction, fd.tf_thickness, fd.tf_ior); +} diff --git a/materialx/libraries/pbrlib/genglsl/lib/mx_refraction_index.glsl b/materialx/libraries/pbrlib/genglsl/lib/mx_refraction_index.glsl new file mode 100644 index 000000000..00433b0fa --- /dev/null +++ b/materialx/libraries/pbrlib/genglsl/lib/mx_refraction_index.glsl @@ -0,0 +1,31 @@ +// "Artist Friendly Metallic Fresnel", Ole Gulbrandsen, 2014 +// http://jcgt.org/published/0003/04/03/paper.pdf + +void mx_complex_to_artistic_ior(vec3 ior, vec3 extinction, out vec3 reflectivity, out vec3 edge_color) +{ + vec3 nm1 = ior - 1.0; + vec3 np1 = ior + 1.0; + vec3 k2 = extinction * extinction; + vec3 r = (nm1*nm1 + k2) / (np1*np1 + k2); + reflectivity = r; + + vec3 r_sqrt = sqrt(r); + vec3 n_min = (1.0 - r) / (1.0 + r); + vec3 n_max = (1.0 + r_sqrt) / (1.0 - r_sqrt); + edge_color = (n_max - ior) / (n_max - n_min); +} + +void mx_artistic_to_complex_ior(vec3 reflectivity, vec3 edge_color, out vec3 ior, out vec3 extinction) +{ + vec3 r = clamp(reflectivity, 0.0, 0.99); + vec3 r_sqrt = sqrt(r); + vec3 n_min = (1.0 - r) / (1.0 + r); + vec3 n_max = (1.0 + r_sqrt) / (1.0 - r_sqrt); + ior = mix(n_max, n_min, edge_color); + + vec3 np1 = ior + 1.0; + vec3 nm1 = ior - 1.0; + vec3 k2 = (np1*np1 * r - nm1*nm1) / (1.0 - r); + k2 = max(k2, 0.0); + extinction = sqrt(k2); +} diff --git a/materialx/libraries/pbrlib/genglsl/lib/mx_shadow.glsl b/materialx/libraries/pbrlib/genglsl/lib/mx_shadow.glsl new file mode 100644 index 000000000..0a0fdb4f0 --- /dev/null +++ b/materialx/libraries/pbrlib/genglsl/lib/mx_shadow.glsl @@ -0,0 +1,23 @@ +// https://developer.nvidia.com/gpugems/gpugems3/part-ii-light-and-shadows/chapter-8-summed-area-variance-shadow-maps +float mx_variance_shadow_occlusion(vec2 moments, float fragmentDepth) +{ + const float MIN_VARIANCE = 0.00001; + + // One-tailed inequality valid if fragmentDepth > moments.x. + float p = (fragmentDepth <= moments.x) ? 1.0 : 0.0; + + // Compute variance. + float variance = moments.y - mx_square(moments.x); + variance = max(variance, MIN_VARIANCE); + + // Compute probabilistic upper bound. + float d = fragmentDepth - moments.x; + float pMax = variance / (variance + mx_square(d)); + return max(p, pMax); +} + +vec2 mx_compute_depth_moments() +{ + float depth = gl_FragCoord.z; + return vec2(depth, mx_square(depth)); +} diff --git a/materialx/libraries/pbrlib/genglsl/lib/mx_table.glsl b/materialx/libraries/pbrlib/genglsl/lib/mx_table.glsl new file mode 100644 index 000000000..e453758d9 --- /dev/null +++ b/materialx/libraries/pbrlib/genglsl/lib/mx_table.glsl @@ -0,0 +1,7 @@ +#include "pbrlib/genglsl/lib/mx_microfacet_specular.glsl" + +vec2 mx_ggx_directional_albedo_generate_table() +{ + vec2 uv = gl_FragCoord.xy / $albedoTableSize; + return mx_ggx_directional_albedo_importance_sample(uv.x, uv.y, vec3(1, 0, 0), vec3(0, 1, 0)).xy; +} diff --git a/materialx/libraries/pbrlib/genglsl/mx_add_bsdf.glsl b/materialx/libraries/pbrlib/genglsl/mx_add_bsdf.glsl new file mode 100644 index 000000000..d66a42521 --- /dev/null +++ b/materialx/libraries/pbrlib/genglsl/mx_add_bsdf.glsl @@ -0,0 +1,14 @@ +void mx_add_bsdf_reflection(vec3 L, vec3 V, vec3 P, float occlusion, BSDF in1, BSDF in2, out BSDF result) +{ + result = in1 + in2; +} + +void mx_add_bsdf_transmission(vec3 V, BSDF in1, BSDF in2, out BSDF result) +{ + result = in1 + in2; +} + +void mx_add_bsdf_indirect(vec3 V, vec3 in1, vec3 in2, out vec3 result) +{ + result = in1 + in2; +} diff --git a/materialx/libraries/pbrlib/genglsl/mx_add_edf.glsl b/materialx/libraries/pbrlib/genglsl/mx_add_edf.glsl new file mode 100644 index 000000000..0631c107b --- /dev/null +++ b/materialx/libraries/pbrlib/genglsl/mx_add_edf.glsl @@ -0,0 +1,4 @@ +void mx_add_edf(vec3 N, vec3 L, EDF in1, EDF in2, out EDF result) +{ + result = in1 + in2; +} diff --git a/materialx/libraries/pbrlib/genglsl/mx_artistic_ior.glsl b/materialx/libraries/pbrlib/genglsl/mx_artistic_ior.glsl new file mode 100644 index 000000000..98a1021ad --- /dev/null +++ b/materialx/libraries/pbrlib/genglsl/mx_artistic_ior.glsl @@ -0,0 +1,6 @@ +#include "pbrlib/genglsl/lib/mx_refraction_index.glsl" + +void mx_artistic_ior(vec3 reflectivity, vec3 edge_color, out vec3 ior, out vec3 extinction) +{ + mx_artistic_to_complex_ior(reflectivity, edge_color, ior, extinction); +} diff --git a/materialx/libraries/pbrlib/genglsl/mx_burley_diffuse_bsdf.glsl b/materialx/libraries/pbrlib/genglsl/mx_burley_diffuse_bsdf.glsl new file mode 100644 index 000000000..d9f4c9aac --- /dev/null +++ b/materialx/libraries/pbrlib/genglsl/mx_burley_diffuse_bsdf.glsl @@ -0,0 +1,35 @@ +#include "pbrlib/genglsl/lib/mx_microfacet_diffuse.glsl" + +void mx_burley_diffuse_bsdf_reflection(vec3 L, vec3 V, vec3 P, float occlusion, float weight, vec3 color, float roughness, vec3 normal, out BSDF result) +{ + if (weight < M_FLOAT_EPS) + { + result = BSDF(0.0); + return; + } + + normal = mx_forward_facing_normal(normal, V); + + float NdotL = clamp(dot(normal, L), M_FLOAT_EPS, 1.0); + + result = color * occlusion * weight * NdotL * M_PI_INV; + result *= mx_burley_diffuse(L, V, normal, NdotL, roughness); + return; +} + +void mx_burley_diffuse_bsdf_indirect(vec3 V, float weight, vec3 color, float roughness, vec3 normal, out BSDF result) +{ + if (weight < M_FLOAT_EPS) + { + result = BSDF(0.0); + return; + } + + normal = mx_forward_facing_normal(normal, V); + + float NdotV = clamp(dot(normal, V), M_FLOAT_EPS, 1.0); + + vec3 Li = mx_environment_irradiance(normal) * + mx_burley_diffuse_directional_albedo(NdotV, roughness); + result = Li * color * weight; +} diff --git a/materialx/libraries/pbrlib/genglsl/mx_conductor_bsdf.glsl b/materialx/libraries/pbrlib/genglsl/mx_conductor_bsdf.glsl new file mode 100644 index 000000000..18daeaae0 --- /dev/null +++ b/materialx/libraries/pbrlib/genglsl/mx_conductor_bsdf.glsl @@ -0,0 +1,55 @@ +#include "pbrlib/genglsl/lib/mx_microfacet_specular.glsl" + +void mx_conductor_bsdf_reflection(vec3 L, vec3 V, vec3 P, float occlusion, float weight, vec3 ior_n, vec3 ior_k, vec2 roughness, vec3 N, vec3 X, int distribution, thinfilm tf, out BSDF result) +{ + if (weight < M_FLOAT_EPS) + { + result = BSDF(0.0); + return; + } + + N = mx_forward_facing_normal(N, V); + + vec3 Y = normalize(cross(N, X)); + vec3 H = normalize(L + V); + + float NdotL = clamp(dot(N, L), M_FLOAT_EPS, 1.0); + float NdotV = clamp(dot(N, V), M_FLOAT_EPS, 1.0); + float NdotH = clamp(dot(N, H), M_FLOAT_EPS, 1.0); + float VdotH = clamp(dot(V, H), M_FLOAT_EPS, 1.0); + + FresnelData fd = tf.thickness > 0.0 ? mx_init_fresnel_conductor_airy(ior_n, ior_k, tf.thickness, tf.ior) : mx_init_fresnel_conductor(ior_n, ior_k); + vec3 F = mx_compute_fresnel(VdotH, fd); + + float avgRoughness = mx_average_roughness(roughness); + float D = mx_ggx_NDF(X, Y, H, NdotH, roughness.x, roughness.y); + float G = mx_ggx_smith_G(NdotL, NdotV, avgRoughness); + + vec3 comp = mx_ggx_energy_compensation(NdotV, avgRoughness, F); + + // Note: NdotL is cancelled out + result = D * F * G * comp * occlusion * weight / (4 * NdotV); +} + +void mx_conductor_bsdf_indirect(vec3 V, float weight, vec3 ior_n, vec3 ior_k, vec2 roughness, vec3 N, vec3 X, int distribution, thinfilm tf, out BSDF result) +{ + if (weight < M_FLOAT_EPS) + { + result = BSDF(0.0); + return; + } + + N = mx_forward_facing_normal(N, V); + + float NdotV = clamp(dot(N, V), M_FLOAT_EPS, 1.0); + + FresnelData fd = tf.thickness > 0.0 ? mx_init_fresnel_conductor_airy(ior_n, ior_k, tf.thickness, tf.ior) : mx_init_fresnel_conductor(ior_n, ior_k); + vec3 F = mx_compute_fresnel(NdotV, fd); + + vec3 Li = mx_environment_radiance(N, V, X, roughness, distribution, fd); + + float avgRoughness = mx_average_roughness(roughness); + vec3 comp = mx_ggx_energy_compensation(NdotV, avgRoughness, F); + + result = Li * comp * weight; +} diff --git a/materialx/libraries/pbrlib/genglsl/mx_dielectric_bsdf.glsl b/materialx/libraries/pbrlib/genglsl/mx_dielectric_bsdf.glsl new file mode 100644 index 000000000..d0c77a26a --- /dev/null +++ b/materialx/libraries/pbrlib/genglsl/mx_dielectric_bsdf.glsl @@ -0,0 +1,96 @@ +#include "pbrlib/genglsl/lib/mx_microfacet_specular.glsl" + +void mx_dielectric_bsdf_reflection(vec3 L, vec3 V, vec3 P, float occlusion, float weight, vec3 tint, float ior, vec2 roughness, vec3 N, vec3 X, int distribution, int scatter_mode, BSDF base, thinfilm tf, out BSDF result) +{ + if (weight < M_FLOAT_EPS) + { + result = base; + return; + } + + N = mx_forward_facing_normal(N, V); + + vec3 Y = normalize(cross(N, X)); + vec3 H = normalize(L + V); + + float NdotL = clamp(dot(N, L), M_FLOAT_EPS, 1.0); + float NdotV = clamp(dot(N, V), M_FLOAT_EPS, 1.0); + float NdotH = clamp(dot(N, H), M_FLOAT_EPS, 1.0); + float VdotH = clamp(dot(V, H), M_FLOAT_EPS, 1.0); + + float avgRoughness = mx_average_roughness(roughness); + + FresnelData fd = tf.thickness > 0.0 ? mx_init_fresnel_dielectric_airy(ior, tf.thickness, tf.ior) : mx_init_fresnel_dielectric(ior); + vec3 F = mx_compute_fresnel(VdotH, fd); + float D = mx_ggx_NDF(X, Y, H, NdotH, roughness.x, roughness.y); + float G = mx_ggx_smith_G(NdotL, NdotV, avgRoughness); + + float F0 = mx_ior_to_f0(ior); + vec3 comp = mx_ggx_energy_compensation(NdotV, avgRoughness, F); + vec3 dirAlbedo = mx_ggx_directional_albedo(NdotV, avgRoughness, F0, 1.0) * comp; + + // Note: NdotL is cancelled out + result = D * F * G * comp * tint * occlusion * weight / (4 * NdotV) // Top layer reflection + + base * (1.0 - dirAlbedo * weight); // Base layer reflection attenuated by top layer +} + +void mx_dielectric_bsdf_transmission(vec3 V, float weight, vec3 tint, float ior, vec2 roughness, vec3 N, vec3 X, int distribution, int scatter_mode, BSDF base, thinfilm tf, out BSDF result) +{ + if (scatter_mode == 1) + { + result = tint * weight; + return; + } + + if (scatter_mode == 2) + { + // No external layering in RT mode, + // the base is always T in this case. + base = tint * weight; + } + + if (weight < M_FLOAT_EPS) + { + result = base; + return; + } + + N = mx_forward_facing_normal(N, V); + float NdotV = clamp(dot(N, V), M_FLOAT_EPS, 1.0); + + FresnelData fd = tf.thickness > 0.0 ? mx_init_fresnel_dielectric_airy(ior, tf.thickness, tf.ior) : mx_init_fresnel_dielectric(ior); + vec3 F = mx_compute_fresnel(NdotV, fd); + + float avgRoughness = mx_average_roughness(roughness); + float F0 = mx_ior_to_f0(ior); + vec3 comp = mx_ggx_energy_compensation(NdotV, avgRoughness, F); + vec3 dirAlbedo = mx_ggx_directional_albedo(NdotV, avgRoughness, F0, 1.0) * comp; + + result = base * (1.0 - dirAlbedo * weight); // Transmission attenuated by reflection amount +} + +void mx_dielectric_bsdf_indirect(vec3 V, float weight, vec3 tint, float ior, vec2 roughness, vec3 N, vec3 X, int distribution, int scatter_mode, BSDF base, thinfilm tf, out BSDF result) +{ + if (weight < M_FLOAT_EPS) + { + result = base; + return; + } + + N = mx_forward_facing_normal(N, V); + + float NdotV = clamp(dot(N, V), M_FLOAT_EPS, 1.0); + + FresnelData fd = tf.thickness > 0.0 ? mx_init_fresnel_dielectric_airy(ior, tf.thickness, tf.ior) : mx_init_fresnel_dielectric(ior); + vec3 F = mx_compute_fresnel(NdotV, fd); + + float avgRoughness = mx_average_roughness(roughness); + float F0 = mx_ior_to_f0(ior); + vec3 comp = mx_ggx_energy_compensation(NdotV, avgRoughness, F); + vec3 dirAlbedo = mx_ggx_directional_albedo(NdotV, avgRoughness, F0, 1.0) * comp; + + vec3 Li = mx_environment_radiance(N, V, X, roughness, distribution, fd); + + result = Li * tint * comp * weight // Top layer reflection + + base * (1.0 - dirAlbedo * weight); // Base layer reflection attenuated by top layer +} diff --git a/materialx/libraries/pbrlib/genglsl/mx_generalized_schlick_bsdf.glsl b/materialx/libraries/pbrlib/genglsl/mx_generalized_schlick_bsdf.glsl new file mode 100644 index 000000000..cf567db2d --- /dev/null +++ b/materialx/libraries/pbrlib/genglsl/mx_generalized_schlick_bsdf.glsl @@ -0,0 +1,86 @@ +#include "pbrlib/genglsl/lib/mx_microfacet_specular.glsl" + +void mx_generalized_schlick_bsdf_reflection(vec3 L, vec3 V, vec3 P, float occlusion, float weight, vec3 color0, vec3 color90, float exponent, vec2 roughness, vec3 N, vec3 X, int distribution, int scatter_mode, BSDF base, thinfilm tf, out BSDF result) +{ + if (weight < M_FLOAT_EPS) + { + result = base; + return; + } + + N = mx_forward_facing_normal(N, V); + + vec3 Y = normalize(cross(N, X)); + vec3 H = normalize(L + V); + + float NdotL = clamp(dot(N, L), M_FLOAT_EPS, 1.0); + float NdotV = clamp(dot(N, V), M_FLOAT_EPS, 1.0); + float NdotH = clamp(dot(N, H), M_FLOAT_EPS, 1.0); + float VdotH = clamp(dot(V, H), M_FLOAT_EPS, 1.0); + + float avgRoughness = mx_average_roughness(roughness); + + FresnelData fd = mx_init_fresnel_schlick(color0, color90, exponent); + vec3 F = mx_compute_fresnel(VdotH, fd); + float D = mx_ggx_NDF(X, Y, H, NdotH, roughness.x, roughness.y); + float G = mx_ggx_smith_G(NdotL, NdotV, avgRoughness); + + vec3 comp = mx_ggx_energy_compensation(NdotV, avgRoughness, F); + vec3 dirAlbedo = mx_ggx_directional_albedo(NdotV, avgRoughness, color0, color90) * comp; + float avgDirAlbedo = dot(dirAlbedo, vec3(1.0 / 3.0)); + + // Note: NdotL is cancelled out + result = D * F * G * comp * occlusion * weight / (4 * NdotV) // Top layer reflection + + base * (1.0 - avgDirAlbedo * weight); // Base layer reflection attenuated by top layer +} + +void mx_generalized_schlick_bsdf_transmission(vec3 V, float weight, vec3 color0, vec3 color90, float exponent, vec2 roughness, vec3 N, vec3 X, int distribution, int scatter_mode, BSDF base, thinfilm tf, out BSDF result) +{ + // + // TODO: We need handling of transmission for generalized schlick + // + + if (weight < M_FLOAT_EPS) + { + result = base; + return; + } + + N = mx_forward_facing_normal(N, V); + float NdotV = clamp(dot(N, V), M_FLOAT_EPS, 1.0); + + FresnelData fd = mx_init_fresnel_schlick(color0, color90, exponent); + vec3 F = mx_compute_fresnel(NdotV, fd); + + float avgRoughness = mx_average_roughness(roughness); + vec3 comp = mx_ggx_energy_compensation(NdotV, avgRoughness, F); + vec3 dirAlbedo = mx_ggx_directional_albedo(NdotV, avgRoughness, color0, color90) * comp; + float avgDirAlbedo = dot(dirAlbedo, vec3(1.0 / 3.0)); + + result = base * (1.0 - avgDirAlbedo * weight); // Transmission attenuated by top layer +} + +void mx_generalized_schlick_bsdf_indirect(vec3 V, float weight, vec3 color0, vec3 color90, float exponent, vec2 roughness, vec3 N, vec3 X, int distribution, int scatter_mode, BSDF base, thinfilm tf, out BSDF result) +{ + if (weight < M_FLOAT_EPS) + { + result = base; + return; + } + + N = mx_forward_facing_normal(N, V); + float NdotV = clamp(dot(N, V), M_FLOAT_EPS, 1.0); + + FresnelData fd = mx_init_fresnel_schlick(color0, color90, exponent); + vec3 F = mx_compute_fresnel(NdotV, fd); + + float avgRoughness = mx_average_roughness(roughness); + vec3 comp = mx_ggx_energy_compensation(NdotV, avgRoughness, F); + vec3 dirAlbedo = mx_ggx_directional_albedo(NdotV, avgRoughness, color0, color90) * comp; + float avgDirAlbedo = dot(dirAlbedo, vec3(1.0 / 3.0)); + + vec3 Li = mx_environment_radiance(N, V, X, roughness, distribution, fd); + + result = Li * comp * weight // Top layer reflection + + base * (1.0 - avgDirAlbedo * weight); // Base layer reflection attenuated by top layer +} diff --git a/materialx/libraries/pbrlib/genglsl/mx_mix_bsdf.glsl b/materialx/libraries/pbrlib/genglsl/mx_mix_bsdf.glsl new file mode 100644 index 000000000..0c5316308 --- /dev/null +++ b/materialx/libraries/pbrlib/genglsl/mx_mix_bsdf.glsl @@ -0,0 +1,14 @@ +void mx_mix_bsdf_reflection(vec3 L, vec3 V, vec3 P, float occlusion, BSDF fg, BSDF bg, float w, out BSDF result) +{ + result = mix(bg, fg, clamp(w, 0.0, 1.0)); +} + +void mx_mix_bsdf_transmission(vec3 V, BSDF fg, BSDF bg, float w, out BSDF result) +{ + result = mix(bg, fg, clamp(w, 0.0, 1.0)); +} + +void mx_mix_bsdf_indirect(vec3 V, vec3 fg, vec3 bg, float w, out vec3 result) +{ + result = mix(bg, fg, clamp(w, 0.0, 1.0)); +} diff --git a/materialx/libraries/pbrlib/genglsl/mx_mix_edf.glsl b/materialx/libraries/pbrlib/genglsl/mx_mix_edf.glsl new file mode 100644 index 000000000..59c5606bc --- /dev/null +++ b/materialx/libraries/pbrlib/genglsl/mx_mix_edf.glsl @@ -0,0 +1,4 @@ +void mx_mix_edf(vec3 N, vec3 L, EDF fg, EDF bg, float w, out EDF result) +{ + result = mix(bg, fg, clamp(w, 0.0, 1.0)); +} diff --git a/materialx/libraries/pbrlib/genglsl/mx_multiply_bsdf_color.glsl b/materialx/libraries/pbrlib/genglsl/mx_multiply_bsdf_color.glsl new file mode 100644 index 000000000..d83a9ce64 --- /dev/null +++ b/materialx/libraries/pbrlib/genglsl/mx_multiply_bsdf_color.glsl @@ -0,0 +1,14 @@ +void mx_multiply_bsdf_color_reflection(vec3 L, vec3 V, vec3 P, float occlusion, BSDF in1, vec3 in2, out BSDF result) +{ + result = in1 * clamp(in2, 0.0, 1.0); +} + +void mx_multiply_bsdf_color_transmission(vec3 V, BSDF in1, vec3 in2, out BSDF result) +{ + result = in1 * clamp(in2, 0.0, 1.0); +} + +void mx_multiply_bsdf_color_indirect(vec3 V, vec3 in1, vec3 in2, out vec3 result) +{ + result = in1 * clamp(in2, 0.0, 1.0); +} diff --git a/materialx/libraries/pbrlib/genglsl/mx_multiply_bsdf_float.glsl b/materialx/libraries/pbrlib/genglsl/mx_multiply_bsdf_float.glsl new file mode 100644 index 000000000..6dd31da8f --- /dev/null +++ b/materialx/libraries/pbrlib/genglsl/mx_multiply_bsdf_float.glsl @@ -0,0 +1,14 @@ +void mx_multiply_bsdf_float_reflection(vec3 L, vec3 V, vec3 P, float occlusion, BSDF in1, float in2, out BSDF result) +{ + result = in1 * clamp(in2, 0.0, 1.0); +} + +void mx_multiply_bsdf_float_transmission(vec3 V, BSDF in1, float in2, out BSDF result) +{ + result = in1 * clamp(in2, 0.0, 1.0); +} + +void mx_multiply_bsdf_float_indirect(vec3 V, vec3 in1, float in2, out vec3 result) +{ + result = in1 * clamp(in2, 0.0, 1.0); +} diff --git a/materialx/libraries/pbrlib/genglsl/mx_multiply_edf_color.glsl b/materialx/libraries/pbrlib/genglsl/mx_multiply_edf_color.glsl new file mode 100644 index 000000000..f516e39c6 --- /dev/null +++ b/materialx/libraries/pbrlib/genglsl/mx_multiply_edf_color.glsl @@ -0,0 +1,4 @@ +void mx_multiply_edf_color(vec3 N, vec3 L, EDF in1, vec3 in2, out EDF result) +{ + result = in1 * in2; +} diff --git a/materialx/libraries/pbrlib/genglsl/mx_multiply_edf_float.glsl b/materialx/libraries/pbrlib/genglsl/mx_multiply_edf_float.glsl new file mode 100644 index 000000000..fa61bff30 --- /dev/null +++ b/materialx/libraries/pbrlib/genglsl/mx_multiply_edf_float.glsl @@ -0,0 +1,4 @@ +void mx_multiply_edf_float(vec3 N, vec3 L, EDF in1, float in2, out EDF result) +{ + result = in1 * in2; +} diff --git a/materialx/libraries/pbrlib/genglsl/mx_oren_nayar_diffuse_bsdf.glsl b/materialx/libraries/pbrlib/genglsl/mx_oren_nayar_diffuse_bsdf.glsl new file mode 100644 index 000000000..e4163119b --- /dev/null +++ b/materialx/libraries/pbrlib/genglsl/mx_oren_nayar_diffuse_bsdf.glsl @@ -0,0 +1,34 @@ +#include "pbrlib/genglsl/lib/mx_microfacet_diffuse.glsl" + +void mx_oren_nayar_diffuse_bsdf_reflection(vec3 L, vec3 V, vec3 P, float occlusion, float weight, vec3 color, float roughness, vec3 normal, out BSDF result) +{ + if (weight < M_FLOAT_EPS) + { + result = BSDF(0.0); + return; + } + + normal = mx_forward_facing_normal(normal, V); + + float NdotL = clamp(dot(normal, L), M_FLOAT_EPS, 1.0); + + result = color * occlusion * weight * NdotL * M_PI_INV; + if (roughness > 0.0) + { + result *= mx_oren_nayar_diffuse(L, V, normal, NdotL, roughness); + } +} + +void mx_oren_nayar_diffuse_bsdf_indirect(vec3 V, float weight, vec3 color, float roughness, vec3 normal, out vec3 result) +{ + if (weight < M_FLOAT_EPS) + { + result = BSDF(0.0); + return; + } + + normal = mx_forward_facing_normal(normal, V); + + vec3 Li = mx_environment_irradiance(normal); + result = Li * color * weight; +} diff --git a/materialx/libraries/pbrlib/genglsl/mx_roughness_anisotropy.glsl b/materialx/libraries/pbrlib/genglsl/mx_roughness_anisotropy.glsl new file mode 100644 index 000000000..39d266eba --- /dev/null +++ b/materialx/libraries/pbrlib/genglsl/mx_roughness_anisotropy.glsl @@ -0,0 +1,15 @@ +void mx_roughness_anisotropy(float roughness, float anisotropy, out vec2 result) +{ + float roughness_sqr = clamp(roughness*roughness, M_FLOAT_EPS, 1.0); + if (anisotropy > 0.0) + { + float aspect = sqrt(1.0 - clamp(anisotropy, 0.0, 0.98)); + result.x = min(roughness_sqr / aspect, 1.0); + result.y = roughness_sqr * aspect; + } + else + { + result.x = roughness_sqr; + result.y = roughness_sqr; + } +} diff --git a/materialx/libraries/pbrlib/genglsl/mx_roughness_dual.glsl b/materialx/libraries/pbrlib/genglsl/mx_roughness_dual.glsl new file mode 100644 index 000000000..f4b538399 --- /dev/null +++ b/materialx/libraries/pbrlib/genglsl/mx_roughness_dual.glsl @@ -0,0 +1,9 @@ +void mx_roughness_dual(vec2 roughness, out vec2 result) +{ + if (roughness.y < 0.0) + { + roughness.y = roughness.x; + } + result.x = clamp(roughness.x * roughness.x, M_FLOAT_EPS, 1.0); + result.y = clamp(roughness.y * roughness.y, M_FLOAT_EPS, 1.0); +} diff --git a/materialx/libraries/pbrlib/genglsl/mx_sheen_bsdf.glsl b/materialx/libraries/pbrlib/genglsl/mx_sheen_bsdf.glsl new file mode 100644 index 000000000..5a7ac9606 --- /dev/null +++ b/materialx/libraries/pbrlib/genglsl/mx_sheen_bsdf.glsl @@ -0,0 +1,50 @@ +#include "pbrlib/genglsl/lib/mx_microfacet_sheen.glsl" + +void mx_sheen_bsdf_reflection(vec3 L, vec3 V, vec3 P, float occlusion, float weight, vec3 color, float roughness, vec3 N, BSDF base, out BSDF result) +{ + if (weight < M_FLOAT_EPS) + { + result = base; + return; + } + + N = mx_forward_facing_normal(N, V); + + vec3 H = normalize(L + V); + + float NdotL = clamp(dot(N, L), M_FLOAT_EPS, 1.0); + float NdotV = clamp(dot(N, V), M_FLOAT_EPS, 1.0); + float NdotH = clamp(dot(N, H), M_FLOAT_EPS, 1.0); + + float D = mx_imageworks_sheen_NDF(NdotH, roughness); + + // Geometry term is skipped and we use a smoother denominator, as in: + // https://blog.selfshadow.com/publications/s2013-shading-course/rad/s2013_pbs_rad_notes.pdf + vec3 fr = D * color / (4.0 * (NdotL + NdotV - NdotL*NdotV)); + + float dirAlbedo = mx_imageworks_sheen_directional_albedo(NdotV, roughness); + + // We need to include NdotL from the light integral here + // as in this case it's not cancelled out by the BRDF denominator. + result = fr * NdotL * occlusion * weight // Top layer reflection + + base * (1.0 - dirAlbedo * weight); // Base layer reflection attenuated by top layer +} + +void mx_sheen_bsdf_indirect(vec3 V, float weight, vec3 color, float roughness, vec3 N, BSDF base, out vec3 result) +{ + if (weight <= 0.0) + { + result = base; + return; + } + + N = mx_forward_facing_normal(N, V); + + float NdotV = clamp(dot(N, V), M_FLOAT_EPS, 1.0); + + float dirAlbedo = mx_imageworks_sheen_directional_albedo(NdotV, roughness); + + vec3 Li = mx_environment_irradiance(N); + result = Li * color * dirAlbedo * weight // Top layer reflection + + base * (1.0 - dirAlbedo * weight); // Base layer reflection attenuated by top layer +} diff --git a/materialx/libraries/pbrlib/genglsl/mx_subsurface_bsdf.glsl b/materialx/libraries/pbrlib/genglsl/mx_subsurface_bsdf.glsl new file mode 100644 index 000000000..0e255e4c1 --- /dev/null +++ b/materialx/libraries/pbrlib/genglsl/mx_subsurface_bsdf.glsl @@ -0,0 +1,32 @@ +#include "pbrlib/genglsl/lib/mx_microfacet_diffuse.glsl" + +void mx_subsurface_bsdf_reflection(vec3 L, vec3 V, vec3 P, float occlusion, float weight, vec3 color, vec3 radius, float anisotropy, vec3 normal, out BSDF result) +{ + if (weight < M_FLOAT_EPS) + { + result = BSDF(0.0); + return; + } + + normal = mx_forward_facing_normal(normal, V); + + vec3 sss = mx_subsurface_scattering_approx(normal, L, P, color, radius); + float NdotL = clamp(dot(normal, L), M_FLOAT_EPS, 1.0); + float visibleOcclusion = 1.0 - NdotL * (1.0 - occlusion); + result = sss * visibleOcclusion * weight; +} + +void mx_subsurface_bsdf_indirect(vec3 V, float weight, vec3 color, vec3 radius, float anisotropy, vec3 normal, out BSDF result) +{ + if (weight < M_FLOAT_EPS) + { + result = BSDF(0.0); + return; + } + + normal = mx_forward_facing_normal(normal, V); + + // For now, we render indirect subsurface as simple indirect diffuse. + vec3 Li = mx_environment_irradiance(normal); + result = Li * color * weight; +} diff --git a/materialx/libraries/pbrlib/genglsl/mx_translucent_bsdf.glsl b/materialx/libraries/pbrlib/genglsl/mx_translucent_bsdf.glsl new file mode 100644 index 000000000..4854173b5 --- /dev/null +++ b/materialx/libraries/pbrlib/genglsl/mx_translucent_bsdf.glsl @@ -0,0 +1,27 @@ +// We fake diffuse transmission by using diffuse reflection from the opposite side. +// So this BTDF is really a BRDF. +void mx_translucent_bsdf_reflection(vec3 L, vec3 V, vec3 P, float occlusion, float weight, vec3 color, vec3 normal, out BSDF result) +{ + // Invert normal since we're transmitting light from the other side + float NdotL = dot(L, -normal); + if (NdotL <= 0.0 || weight < M_FLOAT_EPS) + { + result = BSDF(0.0); + return; + } + + result = color * weight * NdotL * M_PI_INV; +} + +void mx_translucent_bsdf_indirect(vec3 V, float weight, vec3 color, vec3 normal, out BSDF result) +{ + if (weight < M_FLOAT_EPS) + { + result = BSDF(0.0); + return; + } + + // Invert normal since we're transmitting light from the other side + vec3 Li = mx_environment_irradiance(-normal); + result = Li * color * weight; +} diff --git a/materialx/libraries/pbrlib/genglsl/mx_uniform_edf.glsl b/materialx/libraries/pbrlib/genglsl/mx_uniform_edf.glsl new file mode 100644 index 000000000..31e8a450c --- /dev/null +++ b/materialx/libraries/pbrlib/genglsl/mx_uniform_edf.glsl @@ -0,0 +1,4 @@ +void mx_uniform_edf(vec3 N, vec3 L, vec3 color, out EDF result) +{ + result = color; +} diff --git a/materialx/libraries/pbrlib/genglsl/pbrlib_genglsl_impl.mtlx b/materialx/libraries/pbrlib/genglsl/pbrlib_genglsl_impl.mtlx new file mode 100644 index 000000000..dc799ff97 --- /dev/null +++ b/materialx/libraries/pbrlib/genglsl/pbrlib_genglsl_impl.mtlx @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/materialx/libraries/pbrlib/genmdl/pbrlib_genmdl_impl.mtlx b/materialx/libraries/pbrlib/genmdl/pbrlib_genmdl_impl.mtlx new file mode 100644 index 000000000..450dc0350 --- /dev/null +++ b/materialx/libraries/pbrlib/genmdl/pbrlib_genmdl_impl.mtlx @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/materialx/libraries/pbrlib/genosl/lib/mx_microfacet.osl b/materialx/libraries/pbrlib/genosl/lib/mx_microfacet.osl new file mode 100644 index 000000000..c0b78cf97 --- /dev/null +++ b/materialx/libraries/pbrlib/genosl/lib/mx_microfacet.osl @@ -0,0 +1,125 @@ +float mx_square(float x) +{ + return x*x; +} + +vector2 mx_square(vector2 x) +{ + return x*x; +} + +vector mx_square(vector x) +{ + return x*x; +} + +vector4 mx_square(vector4 x) +{ + return x*x; +} + +float mx_pow5(float x) +{ + return mx_square(mx_square(x)) * x; +} + +float mx_fract(float x) +{ + return x - floor(x); +} + +float mx_average_roughness(vector2 roughness) +{ + return sqrt(roughness.x * roughness.y); +} + +// https://www.graphics.rwth-aachen.de/publication/2/jgt.pdf +float mx_golden_ratio_sequence(int i) +{ + return mx_fract((float(i) + 1.0) * M_GOLDEN_RATIO); +} + +// https://people.irisa.fr/Ricardo.Marques/articles/2013/SF_CGF.pdf +vector2 mx_spherical_fibonacci(int i, int numSamples) +{ + return vector2((float(i) + 0.5) / float(numSamples), mx_golden_ratio_sequence(i)); +} + +// Convert a real-valued index of refraction to normal-incidence reflectivity. +float mx_ior_to_f0(float ior) +{ + return mx_square((ior - 1.0) / (ior + 1.0)); +} + +// https://seblagarde.wordpress.com/2013/04/29/memo-on-fresnel-equations/ +float mx_fresnel_dielectric(float cosTheta, float ior) +{ + if (cosTheta < 0.0 || ior == 0.0) + return 1.0; + + float g = ior*ior + cosTheta*cosTheta - 1.0; + // Check for total internal reflection + if (g < 0.0) + return 1.0; + + g = sqrt(g); + float gmc = g - cosTheta; + float gpc = g + cosTheta; + float x = gmc / gpc; + float y = (gpc * cosTheta - 1.0) / (gmc * cosTheta + 1.0); + return 0.5 * x * x * (1.0 + y * y); +} + +color mx_fresnel_conductor(float cosTheta, vector n, vector k) +{ + float c2 = cosTheta*cosTheta; + vector n2_k2 = n*n + k*k; + vector nc2 = 2.0 * n * cosTheta; + + vector rs_a = n2_k2 + c2; + vector rp_a = n2_k2 * c2 + 1.0; + vector rs = (rs_a - nc2) / (rs_a + nc2); + vector rp = (rp_a - nc2) / (rp_a + nc2); + + return 0.5 * (rs + rp); +} + +// Standard Schlick Fresnel +float mx_fresnel_schlick(float cosTheta, float F0) +{ + float x = clamp(1.0 - cosTheta, 0.0, 1.0); + float x5 = mx_pow5(x); + return F0 + (1.0 - F0) * x5; +} +color mx_fresnel_schlick(float cosTheta, color F0) +{ + float x = clamp(1.0 - cosTheta, 0.0, 1.0); + float x5 = mx_pow5(x); + return F0 + (1.0 - F0) * x5; +} + +// Generalized Schlick Fresnel +float mx_fresnel_schlick(float cosTheta, float F0, float F90) +{ + float x = clamp(1.0 - cosTheta, 0.0, 1.0); + float x5 = mx_pow5(x); + return mix(F0, F90, x5); +} +color mx_fresnel_schlick(float cosTheta, color F0, color F90) +{ + float x = clamp(1.0 - cosTheta, 0.0, 1.0); + float x5 = mx_pow5(x); + return mix(F0, F90, x5); +} + +// Generalized Schlick Fresnel with a variable exponent +color mx_fresnel_schlick(float cosTheta, float f0, float f90, float exponent) +{ + float x = clamp(1.0 - cosTheta, 0.0, 1.0); + return mix(f0, f90, pow(x, exponent)); +} +color mx_fresnel_schlick(float cosTheta, color f0, color f90, float exponent) +{ + float x = clamp(1.0 - cosTheta, 0.0, 1.0); + return mix(f0, f90, pow(x, exponent)); +} diff --git a/materialx/libraries/pbrlib/genosl/lib/mx_microfacet_specular.osl b/materialx/libraries/pbrlib/genosl/lib/mx_microfacet_specular.osl new file mode 100644 index 000000000..aed6b34be --- /dev/null +++ b/materialx/libraries/pbrlib/genosl/lib/mx_microfacet_specular.osl @@ -0,0 +1,116 @@ +#include "pbrlib/genosl/lib/mx_microfacet.osl" + +// https://disney-animation.s3.amazonaws.com/library/s2012_pbs_disney_brdf_notes_v2.pdf +// Appendix B.2 Equation 15 +vector mx_ggx_importance_sample_NDF(vector2 Xi, vector X, vector Y, vector N, float alphaX, float alphaY) +{ + float phi = 2.0 * M_PI * Xi.x; + float tanTheta = sqrt(Xi.y / (1.0 - Xi.y)); + vector H = X * (tanTheta * alphaX * cos(phi)) + + Y * (tanTheta * alphaY * sin(phi)) + + N; + return normalize(H); +} + +// http://jcgt.org/published/0003/02/03/paper.pdf +// Equations 72 and 99 +float mx_ggx_smith_G(float NdotL, float NdotV, float alpha) +{ + float alpha2 = mx_square(alpha); + float lambdaL = sqrt(alpha2 + (1.0 - alpha2) * mx_square(NdotL)); + float lambdaV = sqrt(alpha2 + (1.0 - alpha2) * mx_square(NdotV)); + return 2.0 / (lambdaL / NdotL + lambdaV / NdotV); +} + +// https://www.unrealengine.com/blog/physically-based-shading-on-mobile +color mx_ggx_directional_albedo_curve_fit(float NdotV, float roughness, color F0, color F90) +{ + vector4 c0 = vector4(-1, -0.0275, -0.572, 0.022); + vector4 c1 = vector4( 1, 0.0425, 1.04, -0.04 ); + vector4 r = roughness * c0 + c1; + float a004 = min(r.x * r.x, exp2(-9.28 * NdotV)) * r.x + r.y; + vector2 AB = vector2(-1.04, 1.04) * a004 + vector2(r.z, r.w); + return F0 * AB.x + F90 * AB.y; +} + +color mx_ggx_directional_albedo_table_lookup(float NdotV, float roughness, color F0, color F90) +{ + vector2 st = vector2(NdotV, roughness); + vector AB = texture(GGX_DIRECTIONAL_ALBEDO_TABLE, st.x, st.y); + return F0 * AB[0] + F90 * AB[1]; +} + +// https://cdn2.unrealengine.com/Resources/files/2013SiggraphPresentationsNotes-26915738.pdf +color mx_ggx_directional_albedo_importance_sample(float _NdotV, float roughness, color F0, color F90) +{ + float NdotV = clamp(_NdotV, M_FLOAT_EPS, 1.0); + vector V = vector(sqrt(1.0 - mx_square(NdotV)), 0.0, NdotV); + + vector2 AB = vector2(0.0, 0.0); + int SAMPLE_COUNT = 64; + for (int i = 0; i < SAMPLE_COUNT; i++) + { + vector2 Xi = mx_spherical_fibonacci(i, SAMPLE_COUNT); + + // Compute the half vector and incoming light direction. + vector H = mx_ggx_importance_sample_NDF(Xi, vector(1, 0, 0), vector(0, 1, 0), vector(0, 0, 1), roughness, roughness); + vector L = -reflect(V, H); + + // Compute dot products for this sample. + float NdotL = clamp(L[2], M_FLOAT_EPS, 1.0); + float NdotH = clamp(H[2], M_FLOAT_EPS, 1.0); + float VdotH = clamp(dot(V, H), M_FLOAT_EPS, 1.0); + + // Compute the Fresnel term. + float Fc = mx_fresnel_schlick(VdotH, 0.0, 1.0); + + // Compute the geometric visibility term. + float Gvis = mx_ggx_smith_G(NdotL, NdotV, roughness) * VdotH / (NdotH * NdotV); + + // Add the contribution of this sample. + AB += vector2(Gvis * (1 - Fc), Gvis * Fc); + } + + // Normalize integrated terms. + AB /= SAMPLE_COUNT; + + // Return the final directional albedo. + return F0 * AB.x + F90 * AB.y; +} + +color mx_ggx_directional_albedo(float NdotV, float roughness, color F0, color F90) +{ +#if GGX_DIRECTIONAL_ALBEDO_METHOD == 0 + return mx_ggx_directional_albedo_curve_fit(NdotV, roughness, F0, F90); +#elif GGX_DIRECTIONAL_ALBEDO_METHOD == 1 + return mx_ggx_directional_albedo_table_lookup(NdotV, roughness, F0, F90); +#else + return mx_ggx_directional_albedo_importance_sample(NdotV, roughness, F0, F90); +#endif +} + +float mx_ggx_directional_albedo(float NdotV, float roughness, float F0, float F90) +{ + color result = mx_ggx_directional_albedo(NdotV, roughness, color(F0), color(F90)); + return result[0]; +} + +float mx_ggx_directional_albedo(float NdotV, float roughness, float ior) +{ + color result = mx_ggx_directional_albedo(NdotV, roughness, color(mx_ior_to_f0(ior)), color(1.0)); + return result[0]; +} + +// https://blog.selfshadow.com/publications/turquin/ms_comp_final.pdf +// Equations 14 and 16 +color mx_ggx_energy_compensation(float NdotV, float roughness, color Fss) +{ + float Ess = mx_ggx_directional_albedo(NdotV, roughness, 1.0, 1.0); + return 1.0 + Fss * (1.0 - Ess) / Ess; +} + +float mx_ggx_energy_compensation(float NdotV, float roughness, float Fss) +{ + color result = mx_ggx_energy_compensation(NdotV, roughness, color(Fss)); + return result[0]; +} diff --git a/materialx/libraries/pbrlib/genosl/lib/mx_refraction_index.osl b/materialx/libraries/pbrlib/genosl/lib/mx_refraction_index.osl new file mode 100644 index 000000000..6fb20b093 --- /dev/null +++ b/materialx/libraries/pbrlib/genosl/lib/mx_refraction_index.osl @@ -0,0 +1,31 @@ +// "Artist Friendly Metallic Fresnel", Ole Gulbrandsen, 2014 +// http://jcgt.org/published/0003/04/03/paper.pdf + +void mx_complex_to_artistic_ior(vector ior, vector extinction, output color reflectivity, output color edge_color) +{ + vector nm1 = ior - 1.0; + vector np1 = ior + 1.0; + vector k2 = extinction * extinction; + vector r = (nm1*nm1 + k2) / (np1*np1 + k2); + reflectivity = r; + + vector r_sqrt = sqrt(r); + vector n_min = (1.0 - r) / (1.0 + r); + vector n_max = (1.0 + r_sqrt) / (1.0 - r_sqrt); + edge_color = (n_max - ior) / (n_max - n_min); +} + +void mx_artistic_to_complex_ior(color reflectivity, color edge_color, output vector ior, output vector extinction) +{ + color r = clamp(reflectivity, 0.0, 0.99); + color r_sqrt = sqrt(r); + color n_min = (1.0 - r) / (1.0 + r); + color n_max = (1.0 + r_sqrt) / (1.0 - r_sqrt); + ior = mix(n_max, n_min, edge_color); + + color np1 = ior + 1.0; + color nm1 = ior - 1.0; + color k2 = (np1*np1 * r - nm1*nm1) / (1.0 - r); + k2 = max(k2, 0.0); + extinction = sqrt(k2); +} diff --git a/materialx/libraries/pbrlib/genosl/mx_add.inline b/materialx/libraries/pbrlib/genosl/mx_add.inline new file mode 100644 index 000000000..d16f1ab8c --- /dev/null +++ b/materialx/libraries/pbrlib/genosl/mx_add.inline @@ -0,0 +1 @@ +mx_add({{in1}}, {{in2}}) diff --git a/materialx/libraries/pbrlib/genosl/mx_artistic_ior.osl b/materialx/libraries/pbrlib/genosl/mx_artistic_ior.osl new file mode 100644 index 000000000..32f343b8f --- /dev/null +++ b/materialx/libraries/pbrlib/genosl/mx_artistic_ior.osl @@ -0,0 +1,6 @@ +#include "pbrlib/genosl/lib/mx_refraction_index.osl" + +void mx_artistic_ior(color reflectivity, color edge_color, output vector ior, output vector extinction) +{ + mx_artistic_to_complex_ior(reflectivity, edge_color, ior, extinction); +} diff --git a/materialx/libraries/pbrlib/genosl/mx_burley_diffuse_bsdf.osl b/materialx/libraries/pbrlib/genosl/mx_burley_diffuse_bsdf.osl new file mode 100644 index 000000000..62ead30f1 --- /dev/null +++ b/materialx/libraries/pbrlib/genosl/mx_burley_diffuse_bsdf.osl @@ -0,0 +1,5 @@ +void mx_burley_diffuse_bsdf(float weight, color reflectance, float roughness, normal N, output BSDF result) +{ + // TODO: Implement properly. + result = reflectance * weight * oren_nayar(N, roughness); +} diff --git a/materialx/libraries/pbrlib/genosl/mx_conductor_bsdf.osl b/materialx/libraries/pbrlib/genosl/mx_conductor_bsdf.osl new file mode 100644 index 000000000..67dce6508 --- /dev/null +++ b/materialx/libraries/pbrlib/genosl/mx_conductor_bsdf.osl @@ -0,0 +1,29 @@ +#include "pbrlib/genosl/lib/mx_microfacet_specular.osl" + +void mx_conductor_bsdf(float weight, color ior_n, color ior_k, vector2 roughness, normal N, vector U, string distribution, thinfilm tf, output BSDF result) +{ + if (weight < M_FLOAT_EPS) + { + result = 0; + return; + } + + // Calculate conductor fresnel + // + // Fresnel should be based on microfacet normal + // but we have no access to that from here, so just use + // view direction and surface normal instead + // + float NdotV = fabs(dot(N,-I)); + color F = mx_fresnel_conductor(NdotV, ior_n, ior_k); + + // Calculate compensation for multiple scattering. + // This should normally be done inside the closure + // but since vanilla OSL doesen't support this we + // add it here in shader code instead. + float avgRoughness = mx_average_roughness(roughness); + color comp = mx_ggx_energy_compensation(NdotV, avgRoughness, F); + + // Set ior to 0.0 to disable the internal dielectric fresnel + result = F * comp * weight * microfacet(distribution, N, U, roughness.x, roughness.y, 0.0, false); +} diff --git a/materialx/libraries/pbrlib/genosl/mx_dielectric_bsdf.osl b/materialx/libraries/pbrlib/genosl/mx_dielectric_bsdf.osl new file mode 100644 index 000000000..9c0780a67 --- /dev/null +++ b/materialx/libraries/pbrlib/genosl/mx_dielectric_bsdf.osl @@ -0,0 +1,35 @@ +#include "pbrlib/genosl/lib/mx_microfacet_specular.osl" + +void mx_dielectric_bsdf(float weight, color tint, float ior, vector2 roughness, normal N, vector U, string distribution, string scatter_mode, BSDF base, thinfilm tf, output BSDF result) +{ + if (scatter_mode == "T") + { + result = tint * weight * microfacet(distribution, N, U, roughness.x, roughness.y, ior, 1); + return; + } + + float NdotV = clamp(dot(N,-I), M_FLOAT_EPS, 1.0); + float F0 = mx_ior_to_f0(ior); + float F = mx_fresnel_schlick(NdotV, F0); + + // Calculate compensation for multiple scattering. + // This should normally be done inside the closure + // but since vanilla OSL doesen't support this we + // add it here in shader code instead. + float avgRoughness = mx_average_roughness(roughness); + float comp = mx_ggx_energy_compensation(NdotV, avgRoughness, F); + + if (scatter_mode == "R") + { + // Calculate directional albedo since we need + // to attenuate the base layer according to this. + float dirAlbedo = mx_ggx_directional_albedo(NdotV, avgRoughness, ior) * comp; + + result = tint * weight * comp * microfacet(distribution, N, U, roughness.x, roughness.y, ior, 0) + + base * (1.0 - dirAlbedo * weight); + } + else + { + result = tint * weight * comp * microfacet(distribution, N, U, roughness.x, roughness.y, ior, 2); + } +} diff --git a/materialx/libraries/pbrlib/genosl/mx_displacement_float.osl b/materialx/libraries/pbrlib/genosl/mx_displacement_float.osl new file mode 100644 index 000000000..f28985f43 --- /dev/null +++ b/materialx/libraries/pbrlib/genosl/mx_displacement_float.osl @@ -0,0 +1,4 @@ +void mx_displacement_float(float displacement, float scale, output displacementshader result) +{ + result = vector(displacement * scale); +} diff --git a/materialx/libraries/pbrlib/genosl/mx_displacement_vector3.osl b/materialx/libraries/pbrlib/genosl/mx_displacement_vector3.osl new file mode 100644 index 000000000..2a59cb050 --- /dev/null +++ b/materialx/libraries/pbrlib/genosl/mx_displacement_vector3.osl @@ -0,0 +1,4 @@ +void mx_displacement_vector3(vector displacement, float scale, output displacementshader result) +{ + result = displacement * scale; +} diff --git a/materialx/libraries/pbrlib/genosl/mx_generalized_schlick_bsdf.osl b/materialx/libraries/pbrlib/genosl/mx_generalized_schlick_bsdf.osl new file mode 100644 index 000000000..85d201dbe --- /dev/null +++ b/materialx/libraries/pbrlib/genosl/mx_generalized_schlick_bsdf.osl @@ -0,0 +1,32 @@ +#include "pbrlib/genosl/lib/mx_microfacet_specular.osl" + +void mx_generalized_schlick_bsdf(float weight, color color0, color color90, float exponent, vector2 roughness, normal N, vector U, string distribution, string scatter_mode, BSDF base, thinfilm tf, output BSDF result) +{ + // + // TODO: We need handling of transmission for generalized schlick + // + if (weight < M_FLOAT_EPS || scatter_mode == "T") + { + result = base; + return; + } + + float NdotV = fabs(dot(N,-I)); + color F = mx_fresnel_schlick(NdotV, color0, color90, exponent); + float avgRoughness = mx_average_roughness(roughness); + + // Calculate compensation for multiple scattering. + // This should normally be done inside the closure + // but since vanilla OSL doesen't support this we + // add it here in shader code instead. + color comp = mx_ggx_energy_compensation(NdotV, avgRoughness, F); + + // Calculate directional albedo since we need + // to attenuate the base layer according to this. + color dirAlbedo = mx_ggx_directional_albedo(NdotV, avgRoughness, color0, color90) * comp; + float avgDirAlbedo = dot(dirAlbedo, color(1.0 / 3.0)); + + // Set ior to 0.0 to disable the internal dielectric fresnel + result = F * comp * weight * microfacet(distribution, N, U, roughness.x, roughness.y, 0.0, 0) + + base * (1.0 - avgDirAlbedo * weight); +} diff --git a/materialx/libraries/pbrlib/genosl/mx_mix.inline b/materialx/libraries/pbrlib/genosl/mx_mix.inline new file mode 100644 index 000000000..e06e87be5 --- /dev/null +++ b/materialx/libraries/pbrlib/genosl/mx_mix.inline @@ -0,0 +1 @@ +mix({{bg}}, {{fg}}, {{mix}}) diff --git a/materialx/libraries/pbrlib/genosl/mx_multiply_bsdf.inline b/materialx/libraries/pbrlib/genosl/mx_multiply_bsdf.inline new file mode 100644 index 000000000..50519f9d2 --- /dev/null +++ b/materialx/libraries/pbrlib/genosl/mx_multiply_bsdf.inline @@ -0,0 +1 @@ +{{in1}} * clamp({{in2}}, 0.0, 1.0) diff --git a/materialx/libraries/pbrlib/genosl/mx_multiply_edf.inline b/materialx/libraries/pbrlib/genosl/mx_multiply_edf.inline new file mode 100644 index 000000000..4c4799f44 --- /dev/null +++ b/materialx/libraries/pbrlib/genosl/mx_multiply_edf.inline @@ -0,0 +1 @@ +{{in1}} * {{in2}} diff --git a/materialx/libraries/pbrlib/genosl/mx_oren_nayar_diffuse_bsdf.inline b/materialx/libraries/pbrlib/genosl/mx_oren_nayar_diffuse_bsdf.inline new file mode 100644 index 000000000..afeaccb96 --- /dev/null +++ b/materialx/libraries/pbrlib/genosl/mx_oren_nayar_diffuse_bsdf.inline @@ -0,0 +1 @@ +{{color}} * {{weight}} * oren_nayar({{normal}}, {{roughness}}) diff --git a/materialx/libraries/pbrlib/genosl/mx_roughness_anisotropy.osl b/materialx/libraries/pbrlib/genosl/mx_roughness_anisotropy.osl new file mode 100644 index 000000000..48b256e70 --- /dev/null +++ b/materialx/libraries/pbrlib/genosl/mx_roughness_anisotropy.osl @@ -0,0 +1,15 @@ +void mx_roughness_anisotropy(float roughness, float anisotropy, output vector2 result) +{ + float roughness_sqr = clamp(roughness*roughness, M_FLOAT_EPS, 1.0); + if (anisotropy > 0.0) + { + float aspect = sqrt(1.0 - clamp(anisotropy, 0.0, 0.98)); + result.x = min(roughness_sqr / aspect, 1.0); + result.y = roughness_sqr * aspect; + } + else + { + result.x = roughness_sqr; + result.y = roughness_sqr; + } +} diff --git a/materialx/libraries/pbrlib/genosl/mx_roughness_dual.osl b/materialx/libraries/pbrlib/genosl/mx_roughness_dual.osl new file mode 100644 index 000000000..6de64c73a --- /dev/null +++ b/materialx/libraries/pbrlib/genosl/mx_roughness_dual.osl @@ -0,0 +1,12 @@ +void mx_roughness_dual(vector2 roughness, output vector2 result) +{ + result.x = clamp(roughness.x * roughness.x, M_FLOAT_EPS, 1.0); + if (roughness.y < 0.0) + { + result.y = result.x; + } + else + { + result.y = clamp(roughness.y * roughness.y, M_FLOAT_EPS, 1.0); + } +} diff --git a/materialx/libraries/pbrlib/genosl/mx_sheen_bsdf.osl b/materialx/libraries/pbrlib/genosl/mx_sheen_bsdf.osl new file mode 100644 index 000000000..bef33d389 --- /dev/null +++ b/materialx/libraries/pbrlib/genosl/mx_sheen_bsdf.osl @@ -0,0 +1,61 @@ +float mx_imageworks_sheen_directional_albedo(float cosTheta, float roughness) +{ + // LUT for sheen directional albedo. + // A 2D table parameterized with 'cosTheta' (cosine of angle to normal) on x-axis and 'roughness' on y-axis. + int SHEEN_ALBEDO_TABLE_SIZE = 16; + float _sheenAlbedo[256] = { + 1.6177, 0.978927, 0.618938, 0.391714, 0.245177, 0.150234, 0.0893475, 0.0511377, 0.0280191, 0.0144204, 0.00687674, 0.00295935, 0.00111049, 0.000336768, 7.07119e-05, 6.22646e-06, + 1.1084, 0.813928, 0.621389, 0.479304, 0.370299, 0.284835, 0.21724, 0.163558, 0.121254, 0.0878921, 0.0619052, 0.0419894, 0.0270556, 0.0161443, 0.00848212, 0.00342323, + 0.930468, 0.725652, 0.586532, 0.479542, 0.393596, 0.322736, 0.26353, 0.213565, 0.171456, 0.135718, 0.105481, 0.0800472, 0.0588117, 0.0412172, 0.0268329, 0.0152799, + 0.833791, 0.671201, 0.558957, 0.471006, 0.398823, 0.337883, 0.285615, 0.240206, 0.200696, 0.16597, 0.135422, 0.10859, 0.0850611, 0.0644477, 0.0464763, 0.0308878, + 0.771692, 0.633819, 0.537877, 0.461939, 0.398865, 0.344892, 0.297895, 0.256371, 0.219562, 0.186548, 0.156842, 0.130095, 0.10598, 0.0841919, 0.0645311, 0.04679, + 0.727979, 0.606373, 0.52141, 0.453769, 0.397174, 0.348337, 0.305403, 0.267056, 0.232655, 0.201398, 0.17286, 0.146756, 0.122808, 0.100751, 0.0804254, 0.0616485, + 0.695353, 0.585281, 0.508227, 0.44667, 0.394925, 0.350027, 0.310302, 0.274561, 0.242236, 0.212604, 0.185281, 0.16002, 0.13657, 0.114693, 0.0942543, 0.0750799, + 0.669981, 0.568519, 0.497442, 0.440542, 0.392567, 0.350786, 0.313656, 0.280075, 0.249533, 0.221359, 0.195196, 0.170824, 0.148012, 0.126537, 0.106279, 0.0870713, + 0.649644, 0.554855, 0.488453, 0.435237, 0.390279, 0.351028, 0.316036, 0.284274, 0.255266, 0.228387, 0.203297, 0.179796, 0.157665, 0.136695, 0.116774, 0.0977403, + 0.632951, 0.543489, 0.480849, 0.430619, 0.388132, 0.350974, 0.317777, 0.287562, 0.259885, 0.234153, 0.210041, 0.187365, 0.165914, 0.145488, 0.125983, 0.10724, + 0.61899, 0.533877, 0.47433, 0.426573, 0.386145, 0.35075, 0.319078, 0.290197, 0.263681, 0.238971, 0.215746, 0.193838, 0.173043, 0.153167, 0.134113, 0.115722, + 0.607131, 0.52564, 0.468678, 0.423001, 0.38432, 0.35043, 0.320072, 0.292349, 0.266856, 0.243055, 0.220636, 0.199438, 0.179264, 0.159926, 0.141332, 0.123323, + 0.596927, 0.518497, 0.463731, 0.419829, 0.382647, 0.350056, 0.320842, 0.294137, 0.269549, 0.246564, 0.224875, 0.204331, 0.18474, 0.165919, 0.147778, 0.130162, + 0.588052, 0.512241, 0.459365, 0.416996, 0.381114, 0.349657, 0.321448, 0.295641, 0.271862, 0.24961, 0.228584, 0.208643, 0.189596, 0.171266, 0.153566, 0.136341, + 0.580257, 0.506717, 0.455481, 0.41445, 0.379708, 0.34925, 0.321929, 0.296923, 0.273869, 0.252279, 0.231859, 0.212472, 0.193933, 0.176066, 0.158788, 0.141945, + 0.573355, 0.5018, 0.452005, 0.412151, 0.378416, 0.348844, 0.322316, 0.298028, 0.275627, 0.254638, 0.234772, 0.215896, 0.197828, 0.180398, 0.163522, 0.147049 + }; + + float x = cosTheta * (SHEEN_ALBEDO_TABLE_SIZE - 1); + float y = roughness * (SHEEN_ALBEDO_TABLE_SIZE - 1); + int ix = int(x); + int iy = int(y); + int ix2 = clamp(ix + 1, 0, SHEEN_ALBEDO_TABLE_SIZE - 1); + int iy2 = clamp(iy + 1, 0, SHEEN_ALBEDO_TABLE_SIZE - 1); + float fx = x - ix; + float fy = y - iy; + + float v1 = mix(_sheenAlbedo[iy * SHEEN_ALBEDO_TABLE_SIZE + ix], _sheenAlbedo[iy * SHEEN_ALBEDO_TABLE_SIZE + ix2], fx); + float v2 = mix(_sheenAlbedo[iy2 * SHEEN_ALBEDO_TABLE_SIZE + ix], _sheenAlbedo[iy2 * SHEEN_ALBEDO_TABLE_SIZE + ix2], fx); + float albedo = mix(v1, v2, fy); + + return clamp(albedo, 0.0, 1.0); +} + +// TODO: Vanilla OSL doesn't have a proper sheen closure, +// so use 'diffuse' scaled by sheen directional albedo for now. +void mx_sheen_bsdf(float weight, color Ks, float roughness, vector N, BSDF base, output BSDF result) +{ + if (weight > M_FLOAT_EPS) + { + // TODO: Normalization should not be needed. My suspicion is that + // BSDF sampling of new outgoing direction in 'testrender' needs + // to be fixed. + vector V = normalize(-I); + + float NdotV = fabs(dot(N,V)); + float alpha = clamp(roughness, M_FLOAT_EPS, 1.0); + float albedo = weight * mx_imageworks_sheen_directional_albedo(NdotV, alpha); + result = albedo * Ks * diffuse(N) + (1.0 - albedo) * base; + } + else + { + result = base; + } +} diff --git a/materialx/libraries/pbrlib/genosl/mx_subsurface_bsdf.osl b/materialx/libraries/pbrlib/genosl/mx_subsurface_bsdf.osl new file mode 100644 index 000000000..744e2995b --- /dev/null +++ b/materialx/libraries/pbrlib/genosl/mx_subsurface_bsdf.osl @@ -0,0 +1,5 @@ +void mx_subsurface_bsdf(float weight, color _color, vector radius, float anisotropy, vector _normal, output BSDF result) +{ + // TODO: Subsurface closure is not supported by vanilla OSL. + result = _color * weight * translucent(_normal); +} diff --git a/materialx/libraries/pbrlib/genosl/mx_surface.osl b/materialx/libraries/pbrlib/genosl/mx_surface.osl new file mode 100644 index 000000000..a997b47fe --- /dev/null +++ b/materialx/libraries/pbrlib/genosl/mx_surface.osl @@ -0,0 +1,5 @@ +void mx_surface(BSDF bsdf, EDF edf, float opacity, output surfaceshader result) +{ + float opacity_weight = clamp(opacity, 0.0, 1.0); + result = (bsdf + edf) * opacity_weight + transparent() * (1.0 - opacity_weight); +} diff --git a/materialx/libraries/pbrlib/genosl/mx_translucent_bsdf.inline b/materialx/libraries/pbrlib/genosl/mx_translucent_bsdf.inline new file mode 100644 index 000000000..34775217a --- /dev/null +++ b/materialx/libraries/pbrlib/genosl/mx_translucent_bsdf.inline @@ -0,0 +1 @@ +{{color}} * {{weight}} * translucent({{normal}}) diff --git a/materialx/libraries/pbrlib/genosl/mx_uniform_edf.inline b/materialx/libraries/pbrlib/genosl/mx_uniform_edf.inline new file mode 100644 index 000000000..aabebe91a --- /dev/null +++ b/materialx/libraries/pbrlib/genosl/mx_uniform_edf.inline @@ -0,0 +1 @@ +{{color}} * emission() diff --git a/materialx/libraries/pbrlib/genosl/pbrlib_genosl_impl.mtlx b/materialx/libraries/pbrlib/genosl/pbrlib_genosl_impl.mtlx new file mode 100644 index 000000000..2817aefe3 --- /dev/null +++ b/materialx/libraries/pbrlib/genosl/pbrlib_genosl_impl.mtlx @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/materialx/libraries/pbrlib/pbrlib_defs.mtlx b/materialx/libraries/pbrlib/pbrlib_defs.mtlx new file mode 100644 index 000000000..1ac4df259 --- /dev/null +++ b/materialx/libraries/pbrlib/pbrlib_defs.mtlx @@ -0,0 +1,397 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/materialx/libraries/pbrlib/pbrlib_ng.mtlx b/materialx/libraries/pbrlib/pbrlib_ng.mtlx new file mode 100644 index 000000000..fb5c2ab76 --- /dev/null +++ b/materialx/libraries/pbrlib/pbrlib_ng.mtlx @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + diff --git a/materialx/libraries/stdlib/genglsl/lib/mx_hsv.glsl b/materialx/libraries/stdlib/genglsl/lib/mx_hsv.glsl new file mode 100644 index 000000000..923e9eac4 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/lib/mx_hsv.glsl @@ -0,0 +1,91 @@ +/* +Color transform functions. + +These funcions are modified versions of the color operators found in Open Shading Language: +github.com/imageworks/OpenShadingLanguage/blob/master/src/liboslexec/opcolor.cpp + +It contains the subset of color operators needed to implement the MaterialX +standard library. The modifications are for conversions from C++ to GLSL. + +Original copyright notice: +------------------------------------------------------------------------ +Copyright (c) 2009-2010 Sony Pictures Imageworks Inc., et al. +All Rights Reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +* Neither the name of Sony Pictures Imageworks nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +------------------------------------------------------------------------ +*/ + +vec3 mx_hsvtorgb(vec3 hsv) +{ + // Reference for this technique: Foley & van Dam + float h = hsv.x; float s = hsv.y; float v = hsv.z; + if (s < 0.0001f) { + return vec3 (v, v, v); + } else { + h = 6.0f * (h - floor(h)); // expand to [0..6) + int hi = int(trunc(h)); + float f = h - float(hi); + float p = v * (1.0f-s); + float q = v * (1.0f-s*f); + float t = v * (1.0f-s*(1.0f-f)); + if (hi == 0) + return vec3 (v, t, p); + else if (hi == 1) + return vec3 (q, v, p); + else if (hi == 2) + return vec3 (p, v, t); + else if (hi == 3) + return vec3 (p, q, v); + else if (hi == 4) + return vec3 (t, p, v); + return vec3 (v, p, q); + } +} + + +vec3 mx_rgbtohsv(vec3 c) +{ + // See Foley & van Dam + float r = c.x; float g = c.y; float b = c.z; + float mincomp = min (r, min(g, b)); + float maxcomp = max (r, max(g, b)); + float delta = maxcomp - mincomp; // chroma + float h, s, v; + v = maxcomp; + if (maxcomp > 0.0f) + s = delta / maxcomp; + else s = 0.0f; + if (s <= 0.0f) + h = 0.0f; + else { + if (r >= maxcomp) h = (g-b) / delta; + else if (g >= maxcomp) h = 2.0f + (b-r) / delta; + else h = 4.0f + (r-g) / delta; + h *= (1.0f/6.0f); + if (h < 0.0f) + h += 1.0f; + } + return vec3(h, s, v); +} diff --git a/materialx/libraries/stdlib/genglsl/lib/mx_noise.glsl b/materialx/libraries/stdlib/genglsl/lib/mx_noise.glsl new file mode 100644 index 000000000..d1944cd4b --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/lib/mx_noise.glsl @@ -0,0 +1,321 @@ +/* +Noise Library. + +This library is a modified version of the noise library found in +Open Shading Language: +github.com/imageworks/OpenShadingLanguage/blob/master/src/include/OSL/oslnoise.h + +It contains the subset of noise types needed to implement the MaterialX +standard library. The modifications are mainly conversions from C++ to GLSL. +Produced results should be identical to the OSL noise functions. + +Original copyright notice: +------------------------------------------------------------------------ +Copyright (c) 2009-2010 Sony Pictures Imageworks Inc., et al. +All Rights Reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +* Neither the name of Sony Pictures Imageworks nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +------------------------------------------------------------------------ +*/ + +float mx_select(bool b, float t, float f) +{ + return b ? t : f; +} + +float mx_negate_if(float val, bool b) +{ + return b ? -val : val; +} + +int mx_floor(float x) +{ + // return the greatest integer <= x + return x < 0.0 ? int(x) - 1 : int(x); +} + +// return mx_floor as well as the fractional remainder +float mx_floorfrac(float x, out int i) +{ + i = mx_floor(x); + return x - i; +} + +float mx_bilerp(float v0, float v1, float v2, float v3, float s, float t) +{ + float s1 = 1.0 - s; + return (1.0 - t) * (v0*s1 + v1*s) + t * (v2*s1 + v3*s); +} +vec3 mx_bilerp(vec3 v0, vec3 v1, vec3 v2, vec3 v3, float s, float t) +{ + float s1 = 1.0 - s; + return (1.0 - t) * (v0*s1 + v1*s) + t * (v2*s1 + v3*s); +} +float mx_trilerp(float v0, float v1, float v2, float v3, float v4, float v5, float v6, float v7, float s, float t, float r) +{ + float s1 = 1.0 - s; + float t1 = 1.0 - t; + float r1 = 1.0 - r; + return (r1*(t1*(v0*s1 + v1*s) + t*(v2*s1 + v3*s)) + + r*(t1*(v4*s1 + v5*s) + t*(v6*s1 + v7*s))); +} +vec3 mx_trilerp(vec3 v0, vec3 v1, vec3 v2, vec3 v3, vec3 v4, vec3 v5, vec3 v6, vec3 v7, float s, float t, float r) +{ + float s1 = 1.0 - s; + float t1 = 1.0 - t; + float r1 = 1.0 - r; + return (r1*(t1*(v0*s1 + v1*s) + t*(v2*s1 + v3*s)) + + r*(t1*(v4*s1 + v5*s) + t*(v6*s1 + v7*s))); +} + +// 2 and 3 dimensional gradient functions - perform a dot product against a +// randomly chosen vector. Note that the gradient vector is not normalized, but +// this only affects the overal "scale" of the result, so we simply account for +// the scale by multiplying in the corresponding "perlin" function. +float mx_gradient_float(uint hash, float x, float y) +{ + // 8 possible directions (+-1,+-2) and (+-2,+-1) + uint h = hash & 7u; + float u = mx_select(h<4u, x, y); + float v = 2.0 * mx_select(h<4u, y, x); + // compute the dot product with (x,y). + return mx_negate_if(u, bool(h&1u)) + mx_negate_if(v, bool(h&2u)); +} +float mx_gradient_float(uint hash, float x, float y, float z) +{ + // use vectors pointing to the edges of the cube + uint h = hash & 15u; + float u = mx_select(h<8u, x, y); + float v = mx_select(h<4u, y, mx_select((h==12u)||(h==14u), x, z)); + return mx_negate_if(u, bool(h&1u)) + mx_negate_if(v, bool(h&2u)); +} +vec3 mx_gradient_vec3(uvec3 hash, float x, float y) +{ + return vec3(mx_gradient_float(hash.x, x, y), mx_gradient_float(hash.y, x, y), mx_gradient_float(hash.z, x, y)); +} +vec3 mx_gradient_vec3(uvec3 hash, float x, float y, float z) +{ + return vec3(mx_gradient_float(hash.x, x, y, z), mx_gradient_float(hash.y, x, y, z), mx_gradient_float(hash.z, x, y, z)); +} +// Scaling factors to normalize the result of gradients above. +// These factors were experimentally calculated to be: +// 2D: 0.6616 +// 3D: 0.9820 +float mx_gradient_scale2d(float v) { return 0.6616 * v; } +float mx_gradient_scale3d(float v) { return 0.9820 * v; } +vec3 mx_gradient_scale2d(vec3 v) { return 0.6616 * v; } +vec3 mx_gradient_scale3d(vec3 v) { return 0.9820 * v; } + +/// Bitwise circular rotation left by k bits (for 32 bit unsigned integers) +uint mx_rotl32(uint x, int k) +{ + return (x<>(32-k)); +} + +// Mix up and combine the bits of a, b, and c (doesn't change them, but +// returns a hash of those three original values). +uint mx_bjfinal(uint a, uint b, uint c) +{ + c ^= b; c -= mx_rotl32(b,14); + a ^= c; a -= mx_rotl32(c,11); + b ^= a; b -= mx_rotl32(a,25); + c ^= b; c -= mx_rotl32(b,16); + a ^= c; a -= mx_rotl32(c,4); + b ^= a; b -= mx_rotl32(a,14); + c ^= b; c -= mx_rotl32(b,24); + return c; +} + +// Convert a 32 bit integer into a floating point number in [0,1] +float mx_bits_to_01(uint bits) +{ + return float(bits) / float(uint(0xffffffff)); +} + +float mx_fade(float t) +{ + return t * t * t * (t * (t * 6.0 - 15.0) + 10.0); +} + +uint mx_hash_int(int x, int y) +{ + uint len = 2u; + uint a, b, c; + a = b = c = uint(0xdeadbeef) + (len << 2u) + 13u; + a += uint(x); + b += uint(y); + return mx_bjfinal(a, b, c); +} + +uint mx_hash_int(int x, int y, int z) +{ + uint len = 3u; + uint a, b, c; + a = b = c = uint(0xdeadbeef) + (len << 2u) + 13u; + a += uint(x); + b += uint(y); + c += uint(z); + return mx_bjfinal(a, b, c); +} + +uvec3 mx_hash_vec3(int x, int y) +{ + uint h = mx_hash_int(x, y); + // we only need the low-order bits to be random, so split out + // the 32 bit result into 3 parts for each channel + uvec3 result; + result.x = (h ) & 0xFFu; + result.y = (h >> 8 ) & 0xFFu; + result.z = (h >> 16) & 0xFFu; + return result; +} + +uvec3 mx_hash_vec3(int x, int y, int z) +{ + uint h = mx_hash_int(x, y, z); + // we only need the low-order bits to be random, so split out + // the 32 bit result into 3 parts for each channel + uvec3 result; + result.x = (h ) & 0xFFu; + result.y = (h >> 8 ) & 0xFFu; + result.z = (h >> 16) & 0xFFu; + return result; +} + +float mx_perlin_noise_float(vec2 p) +{ + int X, Y; + float fx = mx_floorfrac(p.x, X); + float fy = mx_floorfrac(p.y, Y); + float u = mx_fade(fx); + float v = mx_fade(fy); + float result = mx_bilerp( + mx_gradient_float(mx_hash_int(X , Y ), fx , fy ), + mx_gradient_float(mx_hash_int(X+1, Y ), fx-1.0, fy ), + mx_gradient_float(mx_hash_int(X , Y+1), fx , fy-1.0), + mx_gradient_float(mx_hash_int(X+1, Y+1), fx-1.0, fy-1.0), + u, v); + return mx_gradient_scale2d(result); +} + +float mx_perlin_noise_float(vec3 p) +{ + int X, Y, Z; + float fx = mx_floorfrac(p.x, X); + float fy = mx_floorfrac(p.y, Y); + float fz = mx_floorfrac(p.z, Z); + float u = mx_fade(fx); + float v = mx_fade(fy); + float w = mx_fade(fz); + float result = mx_trilerp( + mx_gradient_float(mx_hash_int(X , Y , Z ), fx , fy , fz ), + mx_gradient_float(mx_hash_int(X+1, Y , Z ), fx-1.0, fy , fz ), + mx_gradient_float(mx_hash_int(X , Y+1, Z ), fx , fy-1.0, fz ), + mx_gradient_float(mx_hash_int(X+1, Y+1, Z ), fx-1.0, fy-1.0, fz ), + mx_gradient_float(mx_hash_int(X , Y , Z+1), fx , fy , fz-1.0), + mx_gradient_float(mx_hash_int(X+1, Y , Z+1), fx-1.0, fy , fz-1.0), + mx_gradient_float(mx_hash_int(X , Y+1, Z+1), fx , fy-1.0, fz-1.0), + mx_gradient_float(mx_hash_int(X+1, Y+1, Z+1), fx-1.0, fy-1.0, fz-1.0), + u, v, w); + return mx_gradient_scale3d(result); +} + +vec3 mx_perlin_noise_vec3(vec2 p) +{ + int X, Y; + float fx = mx_floorfrac(p.x, X); + float fy = mx_floorfrac(p.y, Y); + float u = mx_fade(fx); + float v = mx_fade(fy); + vec3 result = mx_bilerp( + mx_gradient_vec3(mx_hash_vec3(X , Y ), fx , fy ), + mx_gradient_vec3(mx_hash_vec3(X+1, Y ), fx-1.0, fy ), + mx_gradient_vec3(mx_hash_vec3(X , Y+1), fx , fy-1.0), + mx_gradient_vec3(mx_hash_vec3(X+1, Y+1), fx-1.0, fy-1.0), + u, v); + return mx_gradient_scale2d(result); +} + +vec3 mx_perlin_noise_vec3(vec3 p) +{ + int X, Y, Z; + float fx = mx_floorfrac(p.x, X); + float fy = mx_floorfrac(p.y, Y); + float fz = mx_floorfrac(p.z, Z); + float u = mx_fade(fx); + float v = mx_fade(fy); + float w = mx_fade(fz); + vec3 result = mx_trilerp( + mx_gradient_vec3(mx_hash_vec3(X , Y , Z ), fx , fy , fz ), + mx_gradient_vec3(mx_hash_vec3(X+1, Y , Z ), fx-1.0, fy , fz ), + mx_gradient_vec3(mx_hash_vec3(X , Y+1, Z ), fx , fy-1.0, fz ), + mx_gradient_vec3(mx_hash_vec3(X+1, Y+1, Z ), fx-1.0, fy-1.0, fz ), + mx_gradient_vec3(mx_hash_vec3(X , Y , Z+1), fx , fy , fz-1.0), + mx_gradient_vec3(mx_hash_vec3(X+1, Y , Z+1), fx-1.0, fy , fz-1.0), + mx_gradient_vec3(mx_hash_vec3(X , Y+1, Z+1), fx , fy-1.0, fz-1.0), + mx_gradient_vec3(mx_hash_vec3(X+1, Y+1, Z+1), fx-1.0, fy-1.0, fz-1.0), + u, v, w); + return mx_gradient_scale3d(result); +} + +float mx_cell_noise_float(vec2 p) +{ + int ix = mx_floor(p.x); + int iy = mx_floor(p.y); + return mx_bits_to_01(mx_hash_int(ix, iy)); +} + +float mx_cell_noise_float(vec3 p) +{ + int ix = mx_floor(p.x); + int iy = mx_floor(p.y); + int iz = mx_floor(p.z); + return mx_bits_to_01(mx_hash_int(ix, iy, iz)); +} + +float mx_fractal_noise_float(vec3 p, int octaves, float lacunarity, float diminish) +{ + float result = 0.0; + float amplitude = 1.0; + for (int i = 0; i < octaves; ++i) + { + result += amplitude * mx_perlin_noise_float(p); + amplitude *= diminish; + p *= lacunarity; + } + return result; +} + +vec3 mx_fractal_noise_vec3(vec3 p, int octaves, float lacunarity, float diminish) +{ + vec3 result = vec3(0.0); + float amplitude = 1.0; + for (int i = 0; i < octaves; ++i) + { + result += amplitude * mx_perlin_noise_vec3(p); + amplitude *= diminish; + p *= lacunarity; + } + return result; +} diff --git a/materialx/libraries/stdlib/genglsl/lib/mx_sampling.glsl b/materialx/libraries/stdlib/genglsl/lib/mx_sampling.glsl new file mode 100644 index 000000000..f112d0352 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/lib/mx_sampling.glsl @@ -0,0 +1,91 @@ +// Restrict to 7x7 kernel size for performance reasons +#define MX_MAX_SAMPLE_COUNT 49 +// Size of all weights for all levels (including level 1) +#define MX_WEIGHT_ARRAY_SIZE 84 + +// +// Function to compute the sample size relative to a texture coordinate +// +vec2 mx_compute_sample_size_uv(vec2 uv, float filterSize, float filterOffset) +{ + vec2 derivUVx = dFdx(uv) * 0.5f; + vec2 derivUVy = dFdy(uv) * 0.5f; + float derivX = abs(derivUVx.x) + abs(derivUVy.x); + float derivY = abs(derivUVx.y) + abs(derivUVy.y); + float sampleSizeU = 2.0f * filterSize * derivX + filterOffset; + if (sampleSizeU < 1.0E-05f) + sampleSizeU = 1.0E-05f; + float sampleSizeV = 2.0f * filterSize * derivY + filterOffset; + if (sampleSizeV < 1.0E-05f) + sampleSizeV = 1.0E-05f; + return vec2(sampleSizeU, sampleSizeV); +} + +// +// Compute a normal mapped to 0..1 space based on a set of input +// samples using a Sobel filter. +// +vec3 mx_normal_from_samples_sobel(float S[9], float _scale) +{ + float nx = S[0] - S[2] + (2.0*S[3]) - (2.0*S[5]) + S[6] - S[8]; + float ny = S[0] + (2.0*S[1]) + S[2] - S[6] - (2.0*S[7]) - S[8]; + float nz = max(_scale, M_FLOAT_EPS) * sqrt(max(1.0 - nx * nx - ny * ny, M_FLOAT_EPS)); + vec3 norm = normalize(vec3(nx, ny, nz)); + return (norm + 1.0) * 0.5; +} + +// +// Apply filter for float samples S, using weights W. +// sampleCount should be a square of a odd number in the range { 1, 3, 5, 7 } +// +float mx_convolution_float(float S[MX_MAX_SAMPLE_COUNT], float W[MX_WEIGHT_ARRAY_SIZE], int offset, int sampleCount) +{ + float result = 0.0; + for (int i = 0; i < sampleCount; i++) + { + result += S[i]*W[i+offset]; + } + return result; +} + +// +// Apply filter for vec2 samples S, using weights W. +// sampleCount should be a square of a odd number in the range { 1, 3, 5, 7 } +// +vec2 mx_convolution_vec2(vec2 S[MX_MAX_SAMPLE_COUNT], float W[MX_WEIGHT_ARRAY_SIZE], int offset, int sampleCount) +{ + vec2 result = vec2(0.0); + for (int i=0; i 1) + { + vec2 uv = mx_transform_uv(texcoord, uv_scale, uv_offset); + result = texture(tex_sampler, uv).rgb; + } + else + { + result = defaultval; + } +} diff --git a/materialx/libraries/stdlib/genglsl/mx_image_color4.glsl b/materialx/libraries/stdlib/genglsl/mx_image_color4.glsl new file mode 100644 index 000000000..0f5eb1ee9 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_image_color4.glsl @@ -0,0 +1,14 @@ +#include "$fileTransformUv" + +void mx_image_color4(sampler2D tex_sampler, int layer, vec4 defaultval, vec2 texcoord, int uaddressmode, int vaddressmode, int filtertype, int framerange, int frameoffset, int frameendaction, vec2 uv_scale, vec2 uv_offset, out vec4 result) +{ + if (textureSize(tex_sampler, 0).x > 1) + { + vec2 uv = mx_transform_uv(texcoord, uv_scale, uv_offset); + result = texture(tex_sampler, uv); + } + else + { + result = defaultval; + } +} diff --git a/materialx/libraries/stdlib/genglsl/mx_image_float.glsl b/materialx/libraries/stdlib/genglsl/mx_image_float.glsl new file mode 100644 index 000000000..f1efe5f23 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_image_float.glsl @@ -0,0 +1,14 @@ +#include "$fileTransformUv" + +void mx_image_float(sampler2D tex_sampler, int layer, float defaultval, vec2 texcoord, int uaddressmode, int vaddressmode, int filtertype, int framerange, int frameoffset, int frameendaction, vec2 uv_scale, vec2 uv_offset, out float result) +{ + if (textureSize(tex_sampler, 0).x > 1) + { + vec2 uv = mx_transform_uv(texcoord, uv_scale, uv_offset); + result = texture(tex_sampler, uv).r; + } + else + { + result = defaultval; + } +} diff --git a/materialx/libraries/stdlib/genglsl/mx_image_vector2.glsl b/materialx/libraries/stdlib/genglsl/mx_image_vector2.glsl new file mode 100644 index 000000000..38739fe8d --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_image_vector2.glsl @@ -0,0 +1,14 @@ +#include "$fileTransformUv" + +void mx_image_vector2(sampler2D tex_sampler, int layer, vec2 defaultval, vec2 texcoord, int uaddressmode, int vaddressmode, int filtertype, int framerange, int frameoffset, int frameendaction, vec2 uv_scale, vec2 uv_offset, out vec2 result) +{ + if (textureSize(tex_sampler, 0).x > 1) + { + vec2 uv = mx_transform_uv(texcoord, uv_scale, uv_offset); + result = texture(tex_sampler, uv).rg; + } + else + { + result = defaultval; + } +} diff --git a/materialx/libraries/stdlib/genglsl/mx_image_vector3.glsl b/materialx/libraries/stdlib/genglsl/mx_image_vector3.glsl new file mode 100644 index 000000000..dbb7b26a2 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_image_vector3.glsl @@ -0,0 +1,14 @@ +#include "$fileTransformUv" + +void mx_image_vector3(sampler2D tex_sampler, int layer, vec3 defaultval, vec2 texcoord, int uaddressmode, int vaddressmode, int filtertype, int framerange, int frameoffset, int frameendaction, vec2 uv_scale, vec2 uv_offset, out vec3 result) +{ + if (textureSize(tex_sampler, 0).x > 1) + { + vec2 uv = mx_transform_uv(texcoord, uv_scale, uv_offset); + result = texture(tex_sampler, uv).rgb; + } + else + { + result = defaultval; + } +} diff --git a/materialx/libraries/stdlib/genglsl/mx_image_vector4.glsl b/materialx/libraries/stdlib/genglsl/mx_image_vector4.glsl new file mode 100644 index 000000000..a1fc7ffda --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_image_vector4.glsl @@ -0,0 +1,14 @@ +#include "$fileTransformUv" + +void mx_image_vector4(sampler2D tex_sampler, int layer, vec4 defaultval, vec2 texcoord, int uaddressmode, int vaddressmode, int filtertype, int framerange, int frameoffset, int frameendaction, vec2 uv_scale, vec2 uv_offset, out vec4 result) +{ + if (textureSize(tex_sampler, 0).x > 1) + { + vec2 uv = mx_transform_uv(texcoord, uv_scale, uv_offset); + result = texture(tex_sampler, uv); + } + else + { + result = defaultval; + } +} diff --git a/materialx/libraries/stdlib/genglsl/mx_in_color4.inline b/materialx/libraries/stdlib/genglsl/mx_in_color4.inline new file mode 100644 index 000000000..6c55bfb9a --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_in_color4.inline @@ -0,0 +1 @@ +({{fg}}*{{bg}}.a * {{mix}}) + ({{bg}} * (1.0-{{mix}})); diff --git a/materialx/libraries/stdlib/genglsl/mx_inside.inline b/materialx/libraries/stdlib/genglsl/mx_inside.inline new file mode 100644 index 000000000..9109f03f0 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_inside.inline @@ -0,0 +1 @@ +{{in}} * {{mask}} diff --git a/materialx/libraries/stdlib/genglsl/mx_invert.inline b/materialx/libraries/stdlib/genglsl/mx_invert.inline new file mode 100644 index 000000000..79af688a4 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_invert.inline @@ -0,0 +1 @@ +{{amount}} - {{in}} diff --git a/materialx/libraries/stdlib/genglsl/mx_invertM.inline b/materialx/libraries/stdlib/genglsl/mx_invertM.inline new file mode 100644 index 000000000..55e50dd15 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_invertM.inline @@ -0,0 +1 @@ +inverse({{in}}) diff --git a/materialx/libraries/stdlib/genglsl/mx_ln.inline b/materialx/libraries/stdlib/genglsl/mx_ln.inline new file mode 100644 index 000000000..2edf9002a --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_ln.inline @@ -0,0 +1 @@ +log({{in}}) diff --git a/materialx/libraries/stdlib/genglsl/mx_luminance_color3.glsl b/materialx/libraries/stdlib/genglsl/mx_luminance_color3.glsl new file mode 100644 index 000000000..d60ba93a6 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_luminance_color3.glsl @@ -0,0 +1,4 @@ +void mx_luminance_color3(vec3 _in, vec3 lumacoeffs, out vec3 result) +{ + result = vec3(dot(_in, lumacoeffs)); +} diff --git a/materialx/libraries/stdlib/genglsl/mx_luminance_color4.glsl b/materialx/libraries/stdlib/genglsl/mx_luminance_color4.glsl new file mode 100644 index 000000000..28e794300 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_luminance_color4.glsl @@ -0,0 +1,4 @@ +void mx_luminance_color4(vec4 _in, vec3 lumacoeffs, out vec4 result) +{ + result = vec4(vec3(dot(_in.rgb, lumacoeffs)), _in.a); +} diff --git a/materialx/libraries/stdlib/genglsl/mx_magnitude.inline b/materialx/libraries/stdlib/genglsl/mx_magnitude.inline new file mode 100644 index 000000000..6316e30aa --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_magnitude.inline @@ -0,0 +1 @@ +length({{in}}) diff --git a/materialx/libraries/stdlib/genglsl/mx_mask_color4.inline b/materialx/libraries/stdlib/genglsl/mx_mask_color4.inline new file mode 100644 index 000000000..208c52e46 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_mask_color4.inline @@ -0,0 +1 @@ +({{bg}}*{{fg}}.a * {{mix}}) + ({{bg}} * (1.0-{{mix}})); diff --git a/materialx/libraries/stdlib/genglsl/mx_matte_color4.inline b/materialx/libraries/stdlib/genglsl/mx_matte_color4.inline new file mode 100644 index 000000000..b83873554 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_matte_color4.inline @@ -0,0 +1 @@ +vec4( {{fg}}.xyz*{{fg}}.w + {{bg}}.xyz*(1.0-{{fg}}.w), {{fg}}.w + ({{bg}}.w*(1.0-{{fg}}.w)) ) * {{mix}} + ({{bg}} * (1.0-{{mix}})); diff --git a/materialx/libraries/stdlib/genglsl/mx_max.inline b/materialx/libraries/stdlib/genglsl/mx_max.inline new file mode 100644 index 000000000..21f1cb084 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_max.inline @@ -0,0 +1 @@ +max({{in1}}, {{in2}}) diff --git a/materialx/libraries/stdlib/genglsl/mx_min.inline b/materialx/libraries/stdlib/genglsl/mx_min.inline new file mode 100644 index 000000000..58fb42416 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_min.inline @@ -0,0 +1 @@ +min({{in1}}, {{in2}}) diff --git a/materialx/libraries/stdlib/genglsl/mx_minus.inline b/materialx/libraries/stdlib/genglsl/mx_minus.inline new file mode 100644 index 000000000..82f6094ed --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_minus.inline @@ -0,0 +1 @@ +({{mix}}*({{bg}} - {{fg}})) + ((1.0-{{mix}})*{{bg}}) diff --git a/materialx/libraries/stdlib/genglsl/mx_mix.inline b/materialx/libraries/stdlib/genglsl/mx_mix.inline new file mode 100644 index 000000000..e06e87be5 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_mix.inline @@ -0,0 +1 @@ +mix({{bg}}, {{fg}}, {{mix}}) diff --git a/materialx/libraries/stdlib/genglsl/mx_mix_surfaceshader.glsl b/materialx/libraries/stdlib/genglsl/mx_mix_surfaceshader.glsl new file mode 100644 index 000000000..4ae6a0b44 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_mix_surfaceshader.glsl @@ -0,0 +1,5 @@ +void mx_mix_surfaceshader(surfaceshader fg, surfaceshader bg, float w, out surfaceshader returnshader) +{ + returnshader.color = mix(bg.color, fg.color, w); + returnshader.transparency = mix(bg.transparency, fg.transparency, w); +} diff --git a/materialx/libraries/stdlib/genglsl/mx_modulo.inline b/materialx/libraries/stdlib/genglsl/mx_modulo.inline new file mode 100644 index 000000000..5d652aa4e --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_modulo.inline @@ -0,0 +1 @@ +mod({{in1}}, {{in2}}) diff --git a/materialx/libraries/stdlib/genglsl/mx_multiply.inline b/materialx/libraries/stdlib/genglsl/mx_multiply.inline new file mode 100644 index 000000000..4c4799f44 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_multiply.inline @@ -0,0 +1 @@ +{{in1}} * {{in2}} diff --git a/materialx/libraries/stdlib/genglsl/mx_multiply_surfaceshader_color3.glsl b/materialx/libraries/stdlib/genglsl/mx_multiply_surfaceshader_color3.glsl new file mode 100644 index 000000000..dfdb04132 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_multiply_surfaceshader_color3.glsl @@ -0,0 +1,5 @@ +void mx_multiply_surfaceshader_color3(surfaceshader shader1, vec3 value, out surfaceshader returnshader) +{ + returnshader.color = shader1.color * value; + returnshader.transparency = shader1.transparency; +} diff --git a/materialx/libraries/stdlib/genglsl/mx_multiply_surfaceshader_float.glsl b/materialx/libraries/stdlib/genglsl/mx_multiply_surfaceshader_float.glsl new file mode 100644 index 000000000..198b1a10d --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_multiply_surfaceshader_float.glsl @@ -0,0 +1,5 @@ +void mx_multiply_surfaceshader_float(surfaceshader shader1, float value, out surfaceshader returnshader) +{ + returnshader.color = shader1.color * vec3(value); + returnshader.transparency = shader1.transparency * value; +} diff --git a/materialx/libraries/stdlib/genglsl/mx_noise2d_fa_vector2.glsl b/materialx/libraries/stdlib/genglsl/mx_noise2d_fa_vector2.glsl new file mode 100644 index 000000000..6441cf9d0 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_noise2d_fa_vector2.glsl @@ -0,0 +1,7 @@ +#include "stdlib/genglsl/lib/mx_noise.glsl" + +void mx_noise2d_fa_vector2(float amplitude, float pivot, vec2 texcoord, out vec2 result) +{ + vec3 value = mx_perlin_noise_vec3(texcoord); + result = value.xy * amplitude + pivot; +} diff --git a/materialx/libraries/stdlib/genglsl/mx_noise2d_fa_vector3.glsl b/materialx/libraries/stdlib/genglsl/mx_noise2d_fa_vector3.glsl new file mode 100644 index 000000000..2d1dd3279 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_noise2d_fa_vector3.glsl @@ -0,0 +1,7 @@ +#include "stdlib/genglsl/lib/mx_noise.glsl" + +void mx_noise2d_fa_vector3(float amplitude, float pivot, vec2 texcoord, out vec3 result) +{ + vec3 value = mx_perlin_noise_vec3(texcoord); + result = value * amplitude + pivot; +} diff --git a/materialx/libraries/stdlib/genglsl/mx_noise2d_fa_vector4.glsl b/materialx/libraries/stdlib/genglsl/mx_noise2d_fa_vector4.glsl new file mode 100644 index 000000000..fd8e245d8 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_noise2d_fa_vector4.glsl @@ -0,0 +1,8 @@ +#include "stdlib/genglsl/lib/mx_noise.glsl" + +void mx_noise2d_fa_vector4(float amplitude, float pivot, vec2 texcoord, out vec4 result) +{ + vec3 xyz = mx_perlin_noise_vec3(texcoord); + float w = mx_perlin_noise_float(texcoord + vec2(19, 73)); + result = vec4(xyz, w) * amplitude + pivot; +} diff --git a/materialx/libraries/stdlib/genglsl/mx_noise2d_float.glsl b/materialx/libraries/stdlib/genglsl/mx_noise2d_float.glsl new file mode 100644 index 000000000..be780c40e --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_noise2d_float.glsl @@ -0,0 +1,7 @@ +#include "stdlib/genglsl/lib/mx_noise.glsl" + +void mx_noise2d_float(float amplitude, float pivot, vec2 texcoord, out float result) +{ + float value = mx_perlin_noise_float(texcoord); + result = value * amplitude + pivot; +} diff --git a/materialx/libraries/stdlib/genglsl/mx_noise2d_vector2.glsl b/materialx/libraries/stdlib/genglsl/mx_noise2d_vector2.glsl new file mode 100644 index 000000000..8a3831aa5 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_noise2d_vector2.glsl @@ -0,0 +1,7 @@ +#include "stdlib/genglsl/lib/mx_noise.glsl" + +void mx_noise2d_vector2(vec2 amplitude, float pivot, vec2 texcoord, out vec2 result) +{ + vec3 value = mx_perlin_noise_vec3(texcoord); + result = value.xy * amplitude + pivot; +} diff --git a/materialx/libraries/stdlib/genglsl/mx_noise2d_vector3.glsl b/materialx/libraries/stdlib/genglsl/mx_noise2d_vector3.glsl new file mode 100644 index 000000000..264c271cb --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_noise2d_vector3.glsl @@ -0,0 +1,7 @@ +#include "stdlib/genglsl/lib/mx_noise.glsl" + +void mx_noise2d_vector3(vec3 amplitude, float pivot, vec2 texcoord, out vec3 result) +{ + vec3 value = mx_perlin_noise_vec3(texcoord); + result = value * amplitude + pivot; +} diff --git a/materialx/libraries/stdlib/genglsl/mx_noise2d_vector4.glsl b/materialx/libraries/stdlib/genglsl/mx_noise2d_vector4.glsl new file mode 100644 index 000000000..a7133e3e0 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_noise2d_vector4.glsl @@ -0,0 +1,8 @@ +#include "stdlib/genglsl/lib/mx_noise.glsl" + +void mx_noise2d_vector4(vec4 amplitude, float pivot, vec2 texcoord, out vec4 result) +{ + vec3 xyz = mx_perlin_noise_vec3(texcoord); + float w = mx_perlin_noise_float(texcoord + vec2(19, 73)); + result = vec4(xyz, w) * amplitude + pivot; +} diff --git a/materialx/libraries/stdlib/genglsl/mx_noise3d_fa_vector2.glsl b/materialx/libraries/stdlib/genglsl/mx_noise3d_fa_vector2.glsl new file mode 100644 index 000000000..0a6421723 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_noise3d_fa_vector2.glsl @@ -0,0 +1,7 @@ +#include "stdlib/genglsl/lib/mx_noise.glsl" + +void mx_noise3d_fa_vector2(float amplitude, float pivot, vec3 position, out vec2 result) +{ + vec3 value = mx_perlin_noise_vec3(position); + result = value.xy * amplitude + pivot; +} diff --git a/materialx/libraries/stdlib/genglsl/mx_noise3d_fa_vector3.glsl b/materialx/libraries/stdlib/genglsl/mx_noise3d_fa_vector3.glsl new file mode 100644 index 000000000..4c03ed74a --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_noise3d_fa_vector3.glsl @@ -0,0 +1,7 @@ +#include "stdlib/genglsl/lib/mx_noise.glsl" + +void mx_noise3d_fa_vector3(float amplitude, float pivot, vec3 position, out vec3 result) +{ + vec3 value = mx_perlin_noise_vec3(position); + result = value * amplitude + pivot; +} diff --git a/materialx/libraries/stdlib/genglsl/mx_noise3d_fa_vector4.glsl b/materialx/libraries/stdlib/genglsl/mx_noise3d_fa_vector4.glsl new file mode 100644 index 000000000..d33f7f9a1 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_noise3d_fa_vector4.glsl @@ -0,0 +1,8 @@ +#include "stdlib/genglsl/lib/mx_noise.glsl" + +void mx_noise3d_fa_vector4(float amplitude, float pivot, vec3 position, out vec4 result) +{ + vec3 xyz = mx_perlin_noise_vec3(position); + float w = mx_perlin_noise_float(position + vec3(19, 73, 29)); + result = vec4(xyz, w) * amplitude + pivot; +} diff --git a/materialx/libraries/stdlib/genglsl/mx_noise3d_float.glsl b/materialx/libraries/stdlib/genglsl/mx_noise3d_float.glsl new file mode 100644 index 000000000..980327340 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_noise3d_float.glsl @@ -0,0 +1,7 @@ +#include "stdlib/genglsl/lib/mx_noise.glsl" + +void mx_noise3d_float(float amplitude, float pivot, vec3 position, out float result) +{ + float value = mx_perlin_noise_float(position); + result = value * amplitude + pivot; +} diff --git a/materialx/libraries/stdlib/genglsl/mx_noise3d_vector2.glsl b/materialx/libraries/stdlib/genglsl/mx_noise3d_vector2.glsl new file mode 100644 index 000000000..564eb4b4d --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_noise3d_vector2.glsl @@ -0,0 +1,7 @@ +#include "stdlib/genglsl/lib/mx_noise.glsl" + +void mx_noise3d_vector2(vec2 amplitude, float pivot, vec3 position, out vec2 result) +{ + vec3 value = mx_perlin_noise_vec3(position); + result = value.xy * amplitude + pivot; +} diff --git a/materialx/libraries/stdlib/genglsl/mx_noise3d_vector3.glsl b/materialx/libraries/stdlib/genglsl/mx_noise3d_vector3.glsl new file mode 100644 index 000000000..6c304e6dc --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_noise3d_vector3.glsl @@ -0,0 +1,7 @@ +#include "stdlib/genglsl/lib/mx_noise.glsl" + +void mx_noise3d_vector3(vec3 amplitude, float pivot, vec3 position, out vec3 result) +{ + vec3 value = mx_perlin_noise_vec3(position); + result = value * amplitude + pivot; +} diff --git a/materialx/libraries/stdlib/genglsl/mx_noise3d_vector4.glsl b/materialx/libraries/stdlib/genglsl/mx_noise3d_vector4.glsl new file mode 100644 index 000000000..21bbb405f --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_noise3d_vector4.glsl @@ -0,0 +1,8 @@ +#include "stdlib/genglsl/lib/mx_noise.glsl" + +void mx_noise3d_vector4(vec4 amplitude, float pivot, vec3 position, out vec4 result) +{ + vec3 xyz = mx_perlin_noise_vec3(position); + float w = mx_perlin_noise_float(position + vec3(19, 73, 29)); + result = vec4(xyz, w) * amplitude + pivot; +} diff --git a/materialx/libraries/stdlib/genglsl/mx_normalize.inline b/materialx/libraries/stdlib/genglsl/mx_normalize.inline new file mode 100644 index 000000000..debdc12ab --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_normalize.inline @@ -0,0 +1 @@ +normalize({{in}}) diff --git a/materialx/libraries/stdlib/genglsl/mx_normalmap.glsl b/materialx/libraries/stdlib/genglsl/mx_normalmap.glsl new file mode 100644 index 000000000..a6c5b39ac --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_normalmap.glsl @@ -0,0 +1,16 @@ +void mx_normalmap(vec3 value, int map_space, float normal_scale, vec3 N, vec3 T, out vec3 result) +{ + // Tangent space + if (map_space == 0) + { + vec3 v = value * 2.0 - 1.0; + vec3 B = normalize(cross(N, T)); + result = normalize(T * v.x * normal_scale + B * v.y * normal_scale + N * v.z); + } + // Object space + else + { + vec3 n = value * 2.0 - 1.0; + result = normalize(n); + } +} diff --git a/materialx/libraries/stdlib/genglsl/mx_out_color2.inline b/materialx/libraries/stdlib/genglsl/mx_out_color2.inline new file mode 100644 index 000000000..90e911989 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_out_color2.inline @@ -0,0 +1 @@ +({{fg}}*(1.0-{{bg}}.g) * {{mix}}) + ({{bg}} * (1.0-{{mix}})); diff --git a/materialx/libraries/stdlib/genglsl/mx_out_color4.inline b/materialx/libraries/stdlib/genglsl/mx_out_color4.inline new file mode 100644 index 000000000..5bd0cbde2 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_out_color4.inline @@ -0,0 +1 @@ +({{fg}}*(1.0-{{bg}}.a) * {{mix}}) + ({{bg}} * (1.0-{{mix}})); diff --git a/materialx/libraries/stdlib/genglsl/mx_outside.inline b/materialx/libraries/stdlib/genglsl/mx_outside.inline new file mode 100644 index 000000000..73a388ad7 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_outside.inline @@ -0,0 +1 @@ +{{in}} * (1.0 - {{mask}}) diff --git a/materialx/libraries/stdlib/genglsl/mx_over_color2.inline b/materialx/libraries/stdlib/genglsl/mx_over_color2.inline new file mode 100644 index 000000000..b0a1e49c3 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_over_color2.inline @@ -0,0 +1 @@ +({{fg}} + ({{bg}}*(1.0-{{fg}}[1]))) * {{mix}} + {{bg}} * (1.0-{{mix}}) \ No newline at end of file diff --git a/materialx/libraries/stdlib/genglsl/mx_over_color4.inline b/materialx/libraries/stdlib/genglsl/mx_over_color4.inline new file mode 100644 index 000000000..e6e8f671e --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_over_color4.inline @@ -0,0 +1 @@ +({{fg}} + ({{bg}}*(1.0-{{fg}}[3]))) * {{mix}} + {{bg}} * (1.0-{{mix}}) diff --git a/materialx/libraries/stdlib/genglsl/mx_overlay.glsl b/materialx/libraries/stdlib/genglsl/mx_overlay.glsl new file mode 100644 index 000000000..fb9f42a24 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_overlay.glsl @@ -0,0 +1,25 @@ +float mx_overlay(float fg, float bg) +{ + return (fg < 0.5) ? (2 * fg * bg) : (1 - (1 - fg) * (1 - bg)); +} + +vec2 mx_overlay(vec2 fg, vec2 bg) +{ + return vec2(mx_overlay(fg.r, bg.r), + mx_overlay(fg.g, bg.g)); +} + +vec3 mx_overlay(vec3 fg, vec3 bg) +{ + return vec3(mx_overlay(fg.r, bg.r), + mx_overlay(fg.g, bg.g), + mx_overlay(fg.b, bg.b)); +} + +vec4 mx_overlay(vec4 fg, vec4 bg) +{ + return vec4(mx_overlay(fg.r, bg.r), + mx_overlay(fg.g, bg.g), + mx_overlay(fg.b, bg.b), + mx_overlay(fg.a, bg.a)); +} diff --git a/materialx/libraries/stdlib/genglsl/mx_overlay_color3.glsl b/materialx/libraries/stdlib/genglsl/mx_overlay_color3.glsl new file mode 100644 index 000000000..8fb062519 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_overlay_color3.glsl @@ -0,0 +1,6 @@ +#include "stdlib/genglsl/mx_overlay.glsl" + +void mx_overlay_color3(vec3 fg, vec3 bg, float mix, out vec3 result) +{ + result = mix * mx_overlay(fg, bg) + (1-mix) * bg; +} diff --git a/materialx/libraries/stdlib/genglsl/mx_overlay_color4.glsl b/materialx/libraries/stdlib/genglsl/mx_overlay_color4.glsl new file mode 100644 index 000000000..7b18db17b --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_overlay_color4.glsl @@ -0,0 +1,6 @@ +#include "stdlib/genglsl/mx_overlay.glsl" + +void mx_overlay_color4(vec4 fg, vec4 bg, float mix, out vec4 result) +{ + result = mix * mx_overlay(fg, bg) + (1-mix) * bg; +} diff --git a/materialx/libraries/stdlib/genglsl/mx_overlay_float.inline b/materialx/libraries/stdlib/genglsl/mx_overlay_float.inline new file mode 100644 index 000000000..654aba2d3 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_overlay_float.inline @@ -0,0 +1 @@ +({{fg}} < 0.5) ? ({{mix}}*2.0*{{fg}}*{{bg}}) + ((1.0-{{mix}})*{{bg}}) : ({{mix}}*(1.0-(1.0-{{fg}})*(1.0-{{bg}}))) + ((1.0-{{mix}})*{{bg}}) diff --git a/materialx/libraries/stdlib/genglsl/mx_plus.inline b/materialx/libraries/stdlib/genglsl/mx_plus.inline new file mode 100644 index 000000000..bc5a3f6b1 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_plus.inline @@ -0,0 +1 @@ +({{mix}}*({{bg}} + {{fg}})) + ((1.0-{{mix}})*{{bg}}) diff --git a/materialx/libraries/stdlib/genglsl/mx_power.inline b/materialx/libraries/stdlib/genglsl/mx_power.inline new file mode 100644 index 000000000..b48b1a2e2 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_power.inline @@ -0,0 +1 @@ +pow({{in1}}, {{in2}}) diff --git a/materialx/libraries/stdlib/genglsl/mx_power_color3_float.inline b/materialx/libraries/stdlib/genglsl/mx_power_color3_float.inline new file mode 100644 index 000000000..019e4ef92 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_power_color3_float.inline @@ -0,0 +1 @@ +pow({{in1}}, vec3({{in2}})) diff --git a/materialx/libraries/stdlib/genglsl/mx_power_color4_float.inline b/materialx/libraries/stdlib/genglsl/mx_power_color4_float.inline new file mode 100644 index 000000000..386f2baa9 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_power_color4_float.inline @@ -0,0 +1 @@ +pow({{in1}}, vec4({{in2}})) diff --git a/materialx/libraries/stdlib/genglsl/mx_power_vector2_float.inline b/materialx/libraries/stdlib/genglsl/mx_power_vector2_float.inline new file mode 100644 index 000000000..93f21bc37 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_power_vector2_float.inline @@ -0,0 +1 @@ +pow({{in1}}, vec2({{in2}})) diff --git a/materialx/libraries/stdlib/genglsl/mx_power_vector3_float.inline b/materialx/libraries/stdlib/genglsl/mx_power_vector3_float.inline new file mode 100644 index 000000000..019e4ef92 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_power_vector3_float.inline @@ -0,0 +1 @@ +pow({{in1}}, vec3({{in2}})) diff --git a/materialx/libraries/stdlib/genglsl/mx_power_vector4_float.inline b/materialx/libraries/stdlib/genglsl/mx_power_vector4_float.inline new file mode 100644 index 000000000..386f2baa9 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_power_vector4_float.inline @@ -0,0 +1 @@ +pow({{in1}}, vec4({{in2}})) diff --git a/materialx/libraries/stdlib/genglsl/mx_premult_color4.glsl b/materialx/libraries/stdlib/genglsl/mx_premult_color4.glsl new file mode 100644 index 000000000..0f45c3967 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_premult_color4.glsl @@ -0,0 +1,4 @@ +void mx_premult_color4(vec4 _in, out vec4 result) +{ + result = vec4(_in.rgb * _in.a, _in.a); +} diff --git a/materialx/libraries/stdlib/genglsl/mx_ramplr_float.glsl b/materialx/libraries/stdlib/genglsl/mx_ramplr_float.glsl new file mode 100644 index 000000000..d19df8f75 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_ramplr_float.glsl @@ -0,0 +1,4 @@ +void mx_ramplr_float(float valuel, float valuer, vec2 texcoord, out float result) +{ + result = mix (valuel, valuer, clamp(texcoord.x, 0, 1) ); +} diff --git a/materialx/libraries/stdlib/genglsl/mx_ramplr_vector2.glsl b/materialx/libraries/stdlib/genglsl/mx_ramplr_vector2.glsl new file mode 100644 index 000000000..58b99a92d --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_ramplr_vector2.glsl @@ -0,0 +1,4 @@ +void mx_ramplr_vector2(vec2 valuel, vec2 valuer, vec2 texcoord, out vec2 result) +{ + result = mix (valuel, valuer, clamp(texcoord.x, 0, 1) ); +} diff --git a/materialx/libraries/stdlib/genglsl/mx_ramplr_vector3.glsl b/materialx/libraries/stdlib/genglsl/mx_ramplr_vector3.glsl new file mode 100644 index 000000000..1bf476173 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_ramplr_vector3.glsl @@ -0,0 +1,4 @@ +void mx_ramplr_vector3(vec3 valuel, vec3 valuer, vec2 texcoord, out vec3 result) +{ + result = mix (valuel, valuer, clamp(texcoord.x, 0, 1) ); +} diff --git a/materialx/libraries/stdlib/genglsl/mx_ramplr_vector4.glsl b/materialx/libraries/stdlib/genglsl/mx_ramplr_vector4.glsl new file mode 100644 index 000000000..458a2d749 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_ramplr_vector4.glsl @@ -0,0 +1,4 @@ +void mx_ramplr_vector4(vec4 valuel, vec4 valuer, vec2 texcoord, out vec4 result) +{ + result = mix (valuel, valuer, clamp(texcoord.x, 0, 1) ); +} diff --git a/materialx/libraries/stdlib/genglsl/mx_ramptb_float.glsl b/materialx/libraries/stdlib/genglsl/mx_ramptb_float.glsl new file mode 100644 index 000000000..41d854650 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_ramptb_float.glsl @@ -0,0 +1,4 @@ +void mx_ramptb_float(float valuet, float valueb, vec2 texcoord, out float result) +{ + result = mix (valuet, valueb, clamp(texcoord.y, 0, 1) ); +} diff --git a/materialx/libraries/stdlib/genglsl/mx_ramptb_vector2.glsl b/materialx/libraries/stdlib/genglsl/mx_ramptb_vector2.glsl new file mode 100644 index 000000000..f305eb652 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_ramptb_vector2.glsl @@ -0,0 +1,4 @@ +void mx_ramptb_vector2(vec2 valuet, vec2 valueb, vec2 texcoord, out vec2 result) +{ + result = mix (valuet, valueb, clamp(texcoord.y, 0, 1) ); +} diff --git a/materialx/libraries/stdlib/genglsl/mx_ramptb_vector3.glsl b/materialx/libraries/stdlib/genglsl/mx_ramptb_vector3.glsl new file mode 100644 index 000000000..870049f54 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_ramptb_vector3.glsl @@ -0,0 +1,4 @@ +void mx_ramptb_vector3(vec3 valuet, vec3 valueb, vec2 texcoord, out vec3 result) +{ + result = mix (valuet, valueb, clamp(texcoord.y, 0, 1) ); +} diff --git a/materialx/libraries/stdlib/genglsl/mx_ramptb_vector4.glsl b/materialx/libraries/stdlib/genglsl/mx_ramptb_vector4.glsl new file mode 100644 index 000000000..367daae36 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_ramptb_vector4.glsl @@ -0,0 +1,4 @@ +void mx_ramptb_vector4(vec4 valuet, vec4 valueb, vec2 texcoord, out vec4 result) +{ + result = mix (valuet, valueb, clamp(texcoord.y, 0, 1) ); +} diff --git a/materialx/libraries/stdlib/genglsl/mx_remap.inline b/materialx/libraries/stdlib/genglsl/mx_remap.inline new file mode 100644 index 000000000..540fe770e --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_remap.inline @@ -0,0 +1 @@ +{{outlow}} + ({{in}} - {{inlow}}) * ({{outhigh}} - {{outlow}}) / ({{inhigh}} - {{inlow}}) diff --git a/materialx/libraries/stdlib/genglsl/mx_rgbtohsv_color3.glsl b/materialx/libraries/stdlib/genglsl/mx_rgbtohsv_color3.glsl new file mode 100644 index 000000000..c49b0f889 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_rgbtohsv_color3.glsl @@ -0,0 +1,6 @@ +#include "stdlib/genglsl/lib/mx_hsv.glsl" + +void mx_rgbtohsv_color3(vec3 _in, out vec3 result) +{ + result = mx_rgbtohsv(_in); +} diff --git a/materialx/libraries/stdlib/genglsl/mx_rgbtohsv_color4.glsl b/materialx/libraries/stdlib/genglsl/mx_rgbtohsv_color4.glsl new file mode 100644 index 000000000..7cb931f8f --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_rgbtohsv_color4.glsl @@ -0,0 +1,6 @@ +#include "stdlib/genglsl/lib/mx_hsv.glsl" + +void mx_rgbtohsv_color4(vec4 _in, out vec4 result) +{ + result = vec4(mx_rgbtohsv(_in.rgb), 1.0); +} diff --git a/materialx/libraries/stdlib/genglsl/mx_rotate_vector2.glsl b/materialx/libraries/stdlib/genglsl/mx_rotate_vector2.glsl new file mode 100644 index 000000000..a66c17d0a --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_rotate_vector2.glsl @@ -0,0 +1,7 @@ +void mx_rotate_vector2(vec2 _in, float amount, out vec2 result) +{ + float rotationRadians = radians(amount); + float sa = sin(rotationRadians); + float ca = cos(rotationRadians); + result = vec2(ca*_in.x + sa*_in.y, -sa*_in.x + ca*_in.y); +} diff --git a/materialx/libraries/stdlib/genglsl/mx_rotate_vector3.glsl b/materialx/libraries/stdlib/genglsl/mx_rotate_vector3.glsl new file mode 100644 index 000000000..fb06e120e --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_rotate_vector3.glsl @@ -0,0 +1,19 @@ +mat4 mx_rotationMatrix(vec3 axis, float angle) +{ + axis = normalize(axis); + float s = sin(angle); + float c = cos(angle); + float oc = 1.0 - c; + + return mat4(oc * axis.x * axis.x + c, oc * axis.x * axis.y - axis.z * s, oc * axis.z * axis.x + axis.y * s, 0.0, + oc * axis.x * axis.y + axis.z * s, oc * axis.y * axis.y + c, oc * axis.y * axis.z - axis.x * s, 0.0, + oc * axis.z * axis.x - axis.y * s, oc * axis.y * axis.z + axis.x * s, oc * axis.z * axis.z + c, 0.0, + 0.0, 0.0, 0.0, 1.0); +} + +void mx_rotate_vector3(vec3 _in, float amount, vec3 axis, out vec3 result) +{ + float rotationRadians = radians(amount); + mat4 m = mx_rotationMatrix(axis, rotationRadians); + result = (m * vec4(_in, 1.0)).xyz; +} diff --git a/materialx/libraries/stdlib/genglsl/mx_screen.inline b/materialx/libraries/stdlib/genglsl/mx_screen.inline new file mode 100644 index 000000000..741b58d95 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_screen.inline @@ -0,0 +1 @@ +({{mix}}*((1.0 - (1.0 - {{fg}})) * (1 - {{bg}}))) + ((1.0-{{mix}})*{{bg}}) diff --git a/materialx/libraries/stdlib/genglsl/mx_sign.inline b/materialx/libraries/stdlib/genglsl/mx_sign.inline new file mode 100644 index 000000000..46e9499cd --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_sign.inline @@ -0,0 +1 @@ +sign({{in}}) diff --git a/materialx/libraries/stdlib/genglsl/mx_sin.inline b/materialx/libraries/stdlib/genglsl/mx_sin.inline new file mode 100644 index 000000000..8bf8c865a --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_sin.inline @@ -0,0 +1 @@ +sin({{in}}) diff --git a/materialx/libraries/stdlib/genglsl/mx_smoothstep_float.glsl b/materialx/libraries/stdlib/genglsl/mx_smoothstep_float.glsl new file mode 100644 index 000000000..1bca2e4d9 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_smoothstep_float.glsl @@ -0,0 +1,9 @@ +void mx_smoothstep_float(float val, float low, float high, out float result) +{ + if (val <= low) + result = 0.0; + else if (val >= high) + result = 1.0; + else + result = smoothstep(low, high, val); +} diff --git a/materialx/libraries/stdlib/genglsl/mx_smoothstep_vec2.glsl b/materialx/libraries/stdlib/genglsl/mx_smoothstep_vec2.glsl new file mode 100644 index 000000000..8af5c513b --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_smoothstep_vec2.glsl @@ -0,0 +1,7 @@ +#include "stdlib/genglsl/mx_smoothstep_float.glsl" + +void mx_smoothstep_vec2(vec2 val, vec2 low, vec2 high, out vec2 result) +{ + mx_smoothstep_float(val.x, low.x, high.x, result.x); + mx_smoothstep_float(val.y, low.y, high.y, result.y); +} diff --git a/materialx/libraries/stdlib/genglsl/mx_smoothstep_vec2FA.glsl b/materialx/libraries/stdlib/genglsl/mx_smoothstep_vec2FA.glsl new file mode 100644 index 000000000..0663c7f0b --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_smoothstep_vec2FA.glsl @@ -0,0 +1,7 @@ +#include "stdlib/genglsl/mx_smoothstep_float.glsl" + +void mx_smoothstep_vec2FA(vec2 val, float low, float high, out vec2 result) +{ + mx_smoothstep_float(val.x, low, high, result.x); + mx_smoothstep_float(val.y, low, high, result.y); +} diff --git a/materialx/libraries/stdlib/genglsl/mx_smoothstep_vec3.glsl b/materialx/libraries/stdlib/genglsl/mx_smoothstep_vec3.glsl new file mode 100644 index 000000000..29122d359 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_smoothstep_vec3.glsl @@ -0,0 +1,8 @@ +#include "stdlib/genglsl/mx_smoothstep_float.glsl" + +void mx_smoothstep_vec3(vec3 val, vec3 low, vec3 high, out vec3 result) +{ + mx_smoothstep_float(val.x, low.x, high.x, result.x); + mx_smoothstep_float(val.y, low.y, high.y, result.y); + mx_smoothstep_float(val.z, low.z, high.z, result.z); +} diff --git a/materialx/libraries/stdlib/genglsl/mx_smoothstep_vec3FA.glsl b/materialx/libraries/stdlib/genglsl/mx_smoothstep_vec3FA.glsl new file mode 100644 index 000000000..8b39dd6dd --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_smoothstep_vec3FA.glsl @@ -0,0 +1,8 @@ +#include "stdlib/genglsl/mx_smoothstep_float.glsl" + +void mx_smoothstep_vec3FA(vec3 val, float low, float high, out vec3 result) +{ + mx_smoothstep_float(val.x, low, high, result.x); + mx_smoothstep_float(val.y, low, high, result.y); + mx_smoothstep_float(val.z, low, high, result.z); +} diff --git a/materialx/libraries/stdlib/genglsl/mx_smoothstep_vec4.glsl b/materialx/libraries/stdlib/genglsl/mx_smoothstep_vec4.glsl new file mode 100644 index 000000000..7f9a849d0 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_smoothstep_vec4.glsl @@ -0,0 +1,9 @@ +#include "stdlib/genglsl/mx_smoothstep_float.glsl" + +void mx_smoothstep_vec4(vec4 val, vec4 low, vec4 high, out vec4 result) +{ + mx_smoothstep_float(val.x, low.x, high.x, result.x); + mx_smoothstep_float(val.y, low.y, high.y, result.y); + mx_smoothstep_float(val.z, low.z, high.z, result.z); + mx_smoothstep_float(val.w, low.w, high.w, result.w); +} diff --git a/materialx/libraries/stdlib/genglsl/mx_smoothstep_vec4FA.glsl b/materialx/libraries/stdlib/genglsl/mx_smoothstep_vec4FA.glsl new file mode 100644 index 000000000..cdce10593 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_smoothstep_vec4FA.glsl @@ -0,0 +1,9 @@ +#include "stdlib/genglsl/mx_smoothstep_float.glsl" + +void mx_smoothstep_vec4FA(vec4 val, float low, float high, out vec4 result) +{ + mx_smoothstep_float(val.x, low, high, result.x); + mx_smoothstep_float(val.y, low, high, result.y); + mx_smoothstep_float(val.z, low, high, result.z); + mx_smoothstep_float(val.w, low, high, result.w); +} diff --git a/materialx/libraries/stdlib/genglsl/mx_splitlr_float.glsl b/materialx/libraries/stdlib/genglsl/mx_splitlr_float.glsl new file mode 100644 index 000000000..cdfbbb2b1 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_splitlr_float.glsl @@ -0,0 +1,6 @@ +#include "stdlib/genglsl/mx_aastep.glsl" + +void mx_splitlr_float(float valuel, float valuer, float center, vec2 texcoord, out float result) +{ + result = mix(valuel, valuer, mx_aastep(center, texcoord.x)); +} diff --git a/materialx/libraries/stdlib/genglsl/mx_splitlr_vector2.glsl b/materialx/libraries/stdlib/genglsl/mx_splitlr_vector2.glsl new file mode 100644 index 000000000..eb08d40f9 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_splitlr_vector2.glsl @@ -0,0 +1,6 @@ +#include "stdlib/genglsl/mx_aastep.glsl" + +void mx_splitlr_vector2(vec2 valuel, vec2 valuer, float center, vec2 texcoord, out vec2 result) +{ + result = mix(valuel, valuer, mx_aastep(center, texcoord.x)); +} diff --git a/materialx/libraries/stdlib/genglsl/mx_splitlr_vector3.glsl b/materialx/libraries/stdlib/genglsl/mx_splitlr_vector3.glsl new file mode 100644 index 000000000..c7b4c5170 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_splitlr_vector3.glsl @@ -0,0 +1,6 @@ +#include "stdlib/genglsl/mx_aastep.glsl" + +void mx_splitlr_vector3(vec3 valuel, vec3 valuer, float center, vec2 texcoord, out vec3 result) +{ + result = mix(valuel, valuer, mx_aastep(center, texcoord.x)); +} diff --git a/materialx/libraries/stdlib/genglsl/mx_splitlr_vector4.glsl b/materialx/libraries/stdlib/genglsl/mx_splitlr_vector4.glsl new file mode 100644 index 000000000..c4b934d3e --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_splitlr_vector4.glsl @@ -0,0 +1,6 @@ +#include "stdlib/genglsl/mx_aastep.glsl" + +void mx_splitlr_vector4(vec4 valuel, vec4 valuer, float center, vec2 texcoord, out vec4 result) +{ + result = mix(valuel, valuer, mx_aastep(center, texcoord.x)); +} diff --git a/materialx/libraries/stdlib/genglsl/mx_splittb_float.glsl b/materialx/libraries/stdlib/genglsl/mx_splittb_float.glsl new file mode 100644 index 000000000..6f87687aa --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_splittb_float.glsl @@ -0,0 +1,6 @@ +#include "stdlib/genglsl/mx_aastep.glsl" + +void mx_splittb_float(float valuet, float valueb, float center, vec2 texcoord, out float result) +{ + result = mix(valuet, valueb, mx_aastep(center, texcoord.y)); +} diff --git a/materialx/libraries/stdlib/genglsl/mx_splittb_vector2.glsl b/materialx/libraries/stdlib/genglsl/mx_splittb_vector2.glsl new file mode 100644 index 000000000..91b4a69d6 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_splittb_vector2.glsl @@ -0,0 +1,6 @@ +#include "stdlib/genglsl/mx_aastep.glsl" + +void mx_splittb_vector2(vec2 valuet, vec2 valueb, float center, vec2 texcoord, out vec2 result) +{ + result = mix(valuet, valueb, mx_aastep(center, texcoord.y)); +} diff --git a/materialx/libraries/stdlib/genglsl/mx_splittb_vector3.glsl b/materialx/libraries/stdlib/genglsl/mx_splittb_vector3.glsl new file mode 100644 index 000000000..33bd96e80 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_splittb_vector3.glsl @@ -0,0 +1,6 @@ +#include "stdlib/genglsl/mx_aastep.glsl" + +void mx_splittb_vector3(vec3 valuet, vec3 valueb, float center, vec2 texcoord, out vec3 result) +{ + result = mix(valuet, valueb, mx_aastep(center, texcoord.y)); +} diff --git a/materialx/libraries/stdlib/genglsl/mx_splittb_vector4.glsl b/materialx/libraries/stdlib/genglsl/mx_splittb_vector4.glsl new file mode 100644 index 000000000..b44d4fe6e --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_splittb_vector4.glsl @@ -0,0 +1,6 @@ +#include "stdlib/genglsl/mx_aastep.glsl" + +void mx_splittb_vector4(vec4 valuet, vec4 valueb, float center, vec2 texcoord, out vec4 result) +{ + result = mix(valuet, valueb, mx_aastep(center, texcoord.y)); +} diff --git a/materialx/libraries/stdlib/genglsl/mx_sqrt.inline b/materialx/libraries/stdlib/genglsl/mx_sqrt.inline new file mode 100644 index 000000000..fdcb9ad4e --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_sqrt.inline @@ -0,0 +1 @@ +sqrt({{in}}) diff --git a/materialx/libraries/stdlib/genglsl/mx_srgb_texture_to_linear_color3.glsl b/materialx/libraries/stdlib/genglsl/mx_srgb_texture_to_linear_color3.glsl new file mode 100644 index 000000000..2903ec1a2 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_srgb_texture_to_linear_color3.glsl @@ -0,0 +1,13 @@ +void mx_srgb_texture_to_linear_color3(vec3 _in, out vec3 result) +{ + vec4 outColor = vec4(_in, 0.); + vec4 breakPnt = vec4(0.03928571566939354, 0.03928571566939354, 0.03928571566939354, 1.); + vec4 slope = vec4(0.07738015800714493, 0.07738015800714493, 0.07738015800714493, 1.); + vec4 scale = vec4(0.9478672742843628, 0.9478672742843628, 0.9478672742843628, 1.); + vec4 offset = vec4(0.05213269963860512, 0.05213269963860512, 0.05213269963860512, 0.); + vec4 gamma = vec4(2.4, 2.4, 2.4, 1.0); + vec4 isAboveBreak = vec4(greaterThan(outColor, breakPnt)); + vec4 linSeg = outColor * slope; + vec4 powSeg = pow( max( vec4(0., 0., 0., 0.), scale * outColor + offset), gamma); + result = (isAboveBreak * powSeg + ( vec4(1., 1., 1., 1.) - isAboveBreak ) * linSeg).rgb; +} diff --git a/materialx/libraries/stdlib/genglsl/mx_srgb_texture_to_linear_color4.glsl b/materialx/libraries/stdlib/genglsl/mx_srgb_texture_to_linear_color4.glsl new file mode 100644 index 000000000..46af938de --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_srgb_texture_to_linear_color4.glsl @@ -0,0 +1,13 @@ +void mx_srgb_texture_to_linear_color4(vec4 _in, out vec4 result) +{ + vec4 outColor = vec4(_in.rgb, 0.); + vec4 breakPnt = vec4(0.03928571566939354, 0.03928571566939354, 0.03928571566939354, 1.); + vec4 slope = vec4(0.07738015800714493, 0.07738015800714493, 0.07738015800714493, 1.); + vec4 scale = vec4(0.9478672742843628, 0.9478672742843628, 0.9478672742843628, 1.); + vec4 offset = vec4(0.05213269963860512, 0.05213269963860512, 0.05213269963860512, 0.); + vec4 gamma = vec4(2.4, 2.4, 2.4, 1.); + vec4 isAboveBreak = vec4(greaterThan(outColor, breakPnt)); + vec4 linSeg = outColor * slope; + vec4 powSeg = pow( max( vec4(0., 0., 0., 0.), scale * outColor + offset), gamma); + result = vec4((isAboveBreak * powSeg + ( vec4(1., 1., 1., 1.) - isAboveBreak ) * linSeg).rgb, _in.a); +} diff --git a/materialx/libraries/stdlib/genglsl/mx_subtract.inline b/materialx/libraries/stdlib/genglsl/mx_subtract.inline new file mode 100644 index 000000000..afa433965 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_subtract.inline @@ -0,0 +1 @@ +{{in1}} - {{in2}} diff --git a/materialx/libraries/stdlib/genglsl/mx_tan.inline b/materialx/libraries/stdlib/genglsl/mx_tan.inline new file mode 100644 index 000000000..086feffcb --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_tan.inline @@ -0,0 +1 @@ +tan({{in}}) diff --git a/materialx/libraries/stdlib/genglsl/mx_transformmatrix.inline b/materialx/libraries/stdlib/genglsl/mx_transformmatrix.inline new file mode 100644 index 000000000..06f4bf775 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_transformmatrix.inline @@ -0,0 +1 @@ +{{mat}} * {{in}} diff --git a/materialx/libraries/stdlib/genglsl/mx_transformmatrix_vector2M3.glsl b/materialx/libraries/stdlib/genglsl/mx_transformmatrix_vector2M3.glsl new file mode 100644 index 000000000..2afc0248f --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_transformmatrix_vector2M3.glsl @@ -0,0 +1,5 @@ +void mx_transformmatrix_vector2M3(vec2 val, mat3 transform, out vec2 result) +{ + vec3 res = transform * vec3(val, 1.0); + result = res.xy; +} diff --git a/materialx/libraries/stdlib/genglsl/mx_transformmatrix_vector3M4.glsl b/materialx/libraries/stdlib/genglsl/mx_transformmatrix_vector3M4.glsl new file mode 100644 index 000000000..2e1624426 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_transformmatrix_vector3M4.glsl @@ -0,0 +1,5 @@ +void mx_transformmatrix_vector3M4(vec3 val, mat4 transform, out vec3 result) +{ + vec4 res = transform * vec4(val, 1.0); + result = res.xyz; +} diff --git a/materialx/libraries/stdlib/genglsl/mx_transpose.inline b/materialx/libraries/stdlib/genglsl/mx_transpose.inline new file mode 100644 index 000000000..6a195a036 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_transpose.inline @@ -0,0 +1 @@ +transpose({{in}}) diff --git a/materialx/libraries/stdlib/genglsl/mx_unpremult_color4.glsl b/materialx/libraries/stdlib/genglsl/mx_unpremult_color4.glsl new file mode 100644 index 000000000..c4503b4e0 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/mx_unpremult_color4.glsl @@ -0,0 +1,4 @@ +void mx_unpremult_color4(vec4 _in, out vec4 result) +{ + result = vec4(_in.rgb / _in.a, _in.a); +} diff --git a/materialx/libraries/stdlib/genglsl/stdlib_genglsl_cm_impl.mtlx b/materialx/libraries/stdlib/genglsl/stdlib_genglsl_cm_impl.mtlx new file mode 100644 index 000000000..c6d2c3533 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/stdlib_genglsl_cm_impl.mtlx @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/materialx/libraries/stdlib/genglsl/stdlib_genglsl_impl.mtlx b/materialx/libraries/stdlib/genglsl/stdlib_genglsl_impl.mtlx new file mode 100644 index 000000000..6c2d990cd --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/stdlib_genglsl_impl.mtlx @@ -0,0 +1,769 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/materialx/libraries/stdlib/genglsl/stdlib_genglsl_unit_impl.mtlx b/materialx/libraries/stdlib/genglsl/stdlib_genglsl_unit_impl.mtlx new file mode 100644 index 000000000..d9cb96606 --- /dev/null +++ b/materialx/libraries/stdlib/genglsl/stdlib_genglsl_unit_impl.mtlx @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/materialx/libraries/stdlib/genmdl/stdlib_genmdl_cm_impl.mtlx b/materialx/libraries/stdlib/genmdl/stdlib_genmdl_cm_impl.mtlx new file mode 100644 index 000000000..df1420353 --- /dev/null +++ b/materialx/libraries/stdlib/genmdl/stdlib_genmdl_cm_impl.mtlx @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/materialx/libraries/stdlib/genmdl/stdlib_genmdl_impl.mtlx b/materialx/libraries/stdlib/genmdl/stdlib_genmdl_impl.mtlx new file mode 100644 index 000000000..f45330782 --- /dev/null +++ b/materialx/libraries/stdlib/genmdl/stdlib_genmdl_impl.mtlx @@ -0,0 +1,773 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/materialx/libraries/stdlib/genmdl/stdlib_genmdl_unit_impl.mtlx b/materialx/libraries/stdlib/genmdl/stdlib_genmdl_unit_impl.mtlx new file mode 100644 index 000000000..c11760edf --- /dev/null +++ b/materialx/libraries/stdlib/genmdl/stdlib_genmdl_unit_impl.mtlx @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/materialx/libraries/stdlib/genosl/lib/mx_sampling.osl b/materialx/libraries/stdlib/genosl/lib/mx_sampling.osl new file mode 100644 index 000000000..03e3d9f73 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/lib/mx_sampling.osl @@ -0,0 +1,150 @@ +// Restrict to 7x7 kernel size for performance reasons +#define MX_MAX_SAMPLE_COUNT 49 +// Size of all weights for all levels (including level 1) +#define MX_WEIGHT_ARRAY_SIZE 84 + +// +// Function to compute the sample size relative to a texture coordinate +// +vector2 mx_compute_sample_size_uv(vector2 uv, float filterSize, float filterOffset) +{ + vector derivUVx = Dx(vector(uv.x, uv.y, 0.0)) * 0.5; + vector derivUVy = Dy(vector(uv.x, uv.y, 0.0)) * 0.5; + float derivX = abs(derivUVx[0]) + abs(derivUVy[0]); + float derivY = abs(derivUVx[1]) + abs(derivUVy[1]); + float sampleSizeU = filterSize * derivX + filterOffset; + if (sampleSizeU < 1.0E-05) + sampleSizeU = 1.0E-05; + float sampleSizeV = filterSize * derivY + filterOffset; + if (sampleSizeV < 1.0E-05) + sampleSizeV = 1.0E-05; + return vector2(sampleSizeU, sampleSizeV); +} + +// Kernel weights for box filter +void mx_get_box_weights(output float W[MX_MAX_SAMPLE_COUNT], int filterSize) +{ + int sampleCount = filterSize*filterSize; + float value = 1.0 / float(sampleCount); + for (int i=0; i= 7) + { + W[0] = 0.000036; W[1] = 0.000363; W[2] = 0.001446; W[3] = 0.002291; W[4] = 0.001446; W[5] = 0.000363; W[6] = 0.000036; + W[7] = 0.000363; W[8] = 0.003676; W[9] = 0.014662; W[10] = 0.023226; W[11] = 0.014662; W[12] = 0.003676; W[13] = 0.000363; + W[14] = 0.001446; W[15] = 0.014662; W[16] = 0.058488; W[17] = 0.092651; W[18] = 0.058488; W[19] = 0.014662; W[20] = 0.001446; + W[21] = 0.002291; W[22] = 0.023226; W[23] = 0.092651; W[24] = 0.146768; W[25] = 0.092651; W[26] = 0.023226; W[27] = 0.002291; + W[28] = 0.001446; W[29] = 0.014662; W[30] = 0.058488; W[31] = 0.092651; W[32] = 0.058488; W[33] = 0.014662; W[34] = 0.001446; + W[35] = 0.000363; W[36] = 0.003676; W[37] = 0.014662; W[38] = 0.023226; W[39] = 0.014662; W[40] = 0.003676; W[41] = 0.000363; + W[42] = 0.000036; W[43] = 0.000363; W[44] = 0.001446; W[45] = 0.002291; W[46] = 0.001446; W[47] = 0.000363; W[48] = 0.000036; + } + else if (filterSize >= 5) + { + W[0] = 0.003765; W[1] = 0.015019; W[2] = 0.023792; W[3] = 0.015019; W[4] = 0.003765; + W[5] = 0.015019; W[6] = 0.059912; W[7] = 0.094907; W[8] = 0.059912; W[9] = 0.015019; + W[10] = 0.023792; W[11] = 0.094907; W[12] = 0.150342; W[13] = 0.094907; W[14] = 0.023792; + W[15] = 0.015019; W[16] = 0.059912; W[17] = 0.094907; W[18] = 0.059912; W[19] = 0.015019; + W[20] = 0.003765; W[21] = 0.015019; W[22] = 0.023792; W[23] = 0.015019; W[24] = 0.003765; + } + else if (filterSize >= 3) + { + W[0] = 0.0625; W[1] = 0.125; W[2] = 0.0625; + W[3] = 0.125; W[4] = 0.25; W[5] = 0.125; + W[6] = 0.0625; W[7] = 0.125; W[8] = 0.0625; + } + else + { + W[0] = 1.0; + } +} + +// +// Apply filter for float samples S, using weights W. +// sampleCount should be a square of a odd number in the range { 1, 3, 5, 7 } +// +float mx_convolution_float(float S[MX_MAX_SAMPLE_COUNT], float W[MX_WEIGHT_ARRAY_SIZE], int offset, int sampleCount) +{ + float result = 0.0; + for (int i = 0; i < sampleCount; i++) + { + result += S[i]*W[i+offset]; + } + return result; +} + +// +// Apply filter for vector2 samples S, using weights W. +// sampleCount should be a square of a odd number in the range { 1, 3, 5, 7 } +// +vector2 mx_convolution_vector2(vector2 S[MX_MAX_SAMPLE_COUNT], float W[MX_WEIGHT_ARRAY_SIZE], int offset, int sampleCount) +{ + vector2 result = vector2(0.0, 0.0); + for (int i=0; i1.0)) || + (vaddressmode == "constant" && (texcoord.y<0.0 || texcoord.y>1.0))) + { + out = default_value; + return; + } + + color missingColor = default_value; + vector2 st = mx_transform_uv(texcoord); + out = texture(file, st.x, st.y, "subimage", layer, "missingcolor", missingColor, "swrap", uaddressmode, "twrap", vaddressmode); +} diff --git a/materialx/libraries/stdlib/genosl/mx_image_color4.osl b/materialx/libraries/stdlib/genosl/mx_image_color4.osl new file mode 100644 index 000000000..feddf4978 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_image_color4.osl @@ -0,0 +1,21 @@ +#include "$fileTransformUv" + +void mx_image_color4(string file, string layer, color4 default_value, vector2 texcoord, string uaddressmode, string vaddressmode, string filtertype, string framerange, int frameoffset, string frameendaction, output color4 out) +{ + if (file == "" || + (uaddressmode == "constant" && (texcoord.x<0.0 || texcoord.x>1.0)) || + (vaddressmode == "constant" && (texcoord.y<0.0 || texcoord.y>1.0))) + { + out = default_value; + return; + } + + color missingColor = default_value.rgb; + float missingAlpha = default_value.a; + vector2 st = mx_transform_uv(texcoord); + float alpha; + color rgb = texture(file, st.x, st.y, "alpha", alpha, "subimage", layer, + "missingcolor", missingColor, "missingalpha", missingAlpha, "swrap", uaddressmode, "twrap", vaddressmode); + + out = color4(rgb, alpha); +} diff --git a/materialx/libraries/stdlib/genosl/mx_image_float.osl b/materialx/libraries/stdlib/genosl/mx_image_float.osl new file mode 100644 index 000000000..bc3083a52 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_image_float.osl @@ -0,0 +1,17 @@ +#include "$fileTransformUv" + +void mx_image_float(string file, string layer, float default_value, vector2 texcoord, string uaddressmode, string vaddressmode, string filtertype, string framerange, int frameoffset, string frameendaction, output float out) +{ + if (file == "" || + (uaddressmode == "constant" && (texcoord.x<0.0 || texcoord.x>1.0)) || + (vaddressmode == "constant" && (texcoord.y<0.0 || texcoord.y>1.0))) + { + out = default_value; + return; + } + + color missingColor = color(default_value); + vector2 st = mx_transform_uv(texcoord); + color rgb = texture(file, st.x, st.y, "subimage", layer, "missingcolor", missingColor, "swrap", uaddressmode, "twrap", vaddressmode); + out = rgb[0]; +} diff --git a/materialx/libraries/stdlib/genosl/mx_image_vector2.osl b/materialx/libraries/stdlib/genosl/mx_image_vector2.osl new file mode 100644 index 000000000..b4e11f305 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_image_vector2.osl @@ -0,0 +1,18 @@ +#include "$fileTransformUv" + +void mx_image_vector2(string file, string layer, vector2 default_value, vector2 texcoord, string uaddressmode, string vaddressmode, string filtertype, string framerange, int frameoffset, string frameendaction, output vector2 out) +{ + if (file == "" || + (uaddressmode == "constant" && (texcoord.x<0.0 || texcoord.x>1.0)) || + (vaddressmode == "constant" && (texcoord.y<0.0 || texcoord.y>1.0))) + { + out = default_value; + return; + } + + color missingColor = color(default_value.x, default_value.y, 0.0); + vector2 st = mx_transform_uv(texcoord); + color rgb = texture(file, st.x, st.y, "subimage", layer, "missingcolor", missingColor, "swrap", uaddressmode, "twrap", vaddressmode); + out.x = rgb[0]; + out.y = rgb[1]; +} diff --git a/materialx/libraries/stdlib/genosl/mx_image_vector3.osl b/materialx/libraries/stdlib/genosl/mx_image_vector3.osl new file mode 100644 index 000000000..177071cd5 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_image_vector3.osl @@ -0,0 +1,16 @@ +#include "$fileTransformUv" + +void mx_image_vector3(string file, string layer, vector default_value, vector2 texcoord, string uaddressmode, string vaddressmode, string filtertype, string framerange, int frameoffset, string frameendaction, output vector out) +{ + if (file == "" || + (uaddressmode == "constant" && (texcoord.x<0.0 || texcoord.x>1.0)) || + (vaddressmode == "constant" && (texcoord.y<0.0 || texcoord.y>1.0))) + { + out = default_value; + return; + } + + color missingColor = default_value; + vector2 st = mx_transform_uv(texcoord); + out = texture(file, st.x, st.y, "subimage", layer, "missingcolor", missingColor, "swrap", uaddressmode, "twrap", vaddressmode); +} diff --git a/materialx/libraries/stdlib/genosl/mx_image_vector4.osl b/materialx/libraries/stdlib/genosl/mx_image_vector4.osl new file mode 100644 index 000000000..9e1d2233c --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_image_vector4.osl @@ -0,0 +1,21 @@ +#include "$fileTransformUv" + +void mx_image_vector4(string file, string layer, vector4 default_value, vector2 texcoord, string uaddressmode, string vaddressmode, string filtertype, string framerange, int frameoffset, string frameendaction, output vector4 out) +{ + if (file == "" || + (uaddressmode == "constant" && (texcoord.x<0.0 || texcoord.x>1.0)) || + (vaddressmode == "constant" && (texcoord.y<0.0 || texcoord.y>1.0))) + { + out = default_value; + return; + } + + color missingColor = color(default_value.x, default_value.y, default_value.z); + float missingAlpha = default_value.w; + vector2 st = mx_transform_uv(texcoord); + float alpha; + color rgb = texture(file, st.x, st.y, "alpha", alpha, "subimage", layer, + "missingcolor", missingColor, "missingalpha", missingAlpha, "swrap", uaddressmode, "twrap", vaddressmode); + + out = vector4(rgb[0], rgb[1], rgb[2], alpha); +} diff --git a/materialx/libraries/stdlib/genosl/mx_in.inline b/materialx/libraries/stdlib/genosl/mx_in.inline new file mode 100644 index 000000000..0feffbdef --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_in.inline @@ -0,0 +1 @@ +({{fg}}*{{bg}}.a * {{mix}}) + ({{bg}} * (1.0-{{mix}})) diff --git a/materialx/libraries/stdlib/genosl/mx_inside.inline b/materialx/libraries/stdlib/genosl/mx_inside.inline new file mode 100644 index 000000000..9109f03f0 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_inside.inline @@ -0,0 +1 @@ +{{in}} * {{mask}} diff --git a/materialx/libraries/stdlib/genosl/mx_invert.inline b/materialx/libraries/stdlib/genosl/mx_invert.inline new file mode 100644 index 000000000..79af688a4 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_invert.inline @@ -0,0 +1 @@ +{{amount}} - {{in}} diff --git a/materialx/libraries/stdlib/genosl/mx_invertM.inline b/materialx/libraries/stdlib/genosl/mx_invertM.inline new file mode 100644 index 000000000..4581d92de --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_invertM.inline @@ -0,0 +1 @@ +1 / {{in}} diff --git a/materialx/libraries/stdlib/genosl/mx_ln.inline b/materialx/libraries/stdlib/genosl/mx_ln.inline new file mode 100644 index 000000000..2edf9002a --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_ln.inline @@ -0,0 +1 @@ +log({{in}}) diff --git a/materialx/libraries/stdlib/genosl/mx_luminance_color3.osl b/materialx/libraries/stdlib/genosl/mx_luminance_color3.osl new file mode 100644 index 000000000..8db9712a3 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_luminance_color3.osl @@ -0,0 +1,4 @@ +void mx_luminance_color3(color in, color lumacoeffs, output color result) +{ + result = dot(in, lumacoeffs); +} diff --git a/materialx/libraries/stdlib/genosl/mx_luminance_color4.osl b/materialx/libraries/stdlib/genosl/mx_luminance_color4.osl new file mode 100644 index 000000000..bee2298b7 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_luminance_color4.osl @@ -0,0 +1,4 @@ +void mx_luminance_color4(color4 in, color lumacoeffs, output color4 result) +{ + result = color4(dot(in.rgb, lumacoeffs), in.a); +} diff --git a/materialx/libraries/stdlib/genosl/mx_magnitude.inline b/materialx/libraries/stdlib/genosl/mx_magnitude.inline new file mode 100644 index 000000000..6316e30aa --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_magnitude.inline @@ -0,0 +1 @@ +length({{in}}) diff --git a/materialx/libraries/stdlib/genosl/mx_mask.inline b/materialx/libraries/stdlib/genosl/mx_mask.inline new file mode 100644 index 000000000..208c52e46 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_mask.inline @@ -0,0 +1 @@ +({{bg}}*{{fg}}.a * {{mix}}) + ({{bg}} * (1.0-{{mix}})); diff --git a/materialx/libraries/stdlib/genosl/mx_matte_color4.inline b/materialx/libraries/stdlib/genosl/mx_matte_color4.inline new file mode 100644 index 000000000..c518351ae --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_matte_color4.inline @@ -0,0 +1 @@ +color4({{fg}}.rgb*{{fg}}.a + {{bg}}.rgb*(1.0-{{fg}}.a), {{fg}}.a + ({{bg}}.a*(1.0-{{fg}}.a)) ) * {{mix}} + ({{bg}} * (1.0-{{mix}})) diff --git a/materialx/libraries/stdlib/genosl/mx_max.inline b/materialx/libraries/stdlib/genosl/mx_max.inline new file mode 100644 index 000000000..21f1cb084 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_max.inline @@ -0,0 +1 @@ +max({{in1}}, {{in2}}) diff --git a/materialx/libraries/stdlib/genosl/mx_min.inline b/materialx/libraries/stdlib/genosl/mx_min.inline new file mode 100644 index 000000000..58fb42416 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_min.inline @@ -0,0 +1 @@ +min({{in1}}, {{in2}}) diff --git a/materialx/libraries/stdlib/genosl/mx_minus.inline b/materialx/libraries/stdlib/genosl/mx_minus.inline new file mode 100644 index 000000000..82f6094ed --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_minus.inline @@ -0,0 +1 @@ +({{mix}}*({{bg}} - {{fg}})) + ((1.0-{{mix}})*{{bg}}) diff --git a/materialx/libraries/stdlib/genosl/mx_mix.inline b/materialx/libraries/stdlib/genosl/mx_mix.inline new file mode 100644 index 000000000..e06e87be5 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_mix.inline @@ -0,0 +1 @@ +mix({{bg}}, {{fg}}, {{mix}}) diff --git a/materialx/libraries/stdlib/genosl/mx_modulo.inline b/materialx/libraries/stdlib/genosl/mx_modulo.inline new file mode 100644 index 000000000..5d652aa4e --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_modulo.inline @@ -0,0 +1 @@ +mod({{in1}}, {{in2}}) diff --git a/materialx/libraries/stdlib/genosl/mx_modulo_color3FA.inline b/materialx/libraries/stdlib/genosl/mx_modulo_color3FA.inline new file mode 100644 index 000000000..ba68f10af --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_modulo_color3FA.inline @@ -0,0 +1 @@ +mod({{in1}}, color({{in2}},{{in2}},{{in2}})) diff --git a/materialx/libraries/stdlib/genosl/mx_modulo_vector3FA.inline b/materialx/libraries/stdlib/genosl/mx_modulo_vector3FA.inline new file mode 100644 index 000000000..8845cc566 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_modulo_vector3FA.inline @@ -0,0 +1 @@ +mod({{in1}}, vector({{in2}},{{in2}},{{in2}})) diff --git a/materialx/libraries/stdlib/genosl/mx_multiply.inline b/materialx/libraries/stdlib/genosl/mx_multiply.inline new file mode 100644 index 000000000..4c4799f44 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_multiply.inline @@ -0,0 +1 @@ +{{in1}} * {{in2}} diff --git a/materialx/libraries/stdlib/genosl/mx_noise2d_color3.osl b/materialx/libraries/stdlib/genosl/mx_noise2d_color3.osl new file mode 100644 index 000000000..37421ee81 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_noise2d_color3.osl @@ -0,0 +1,5 @@ +void mx_noise2d_color3(vector amplitude, float pivot, vector2 texcoord, output color result) +{ + color value = noise("snoise", texcoord.x, texcoord.y); + result = value * amplitude + pivot; +} diff --git a/materialx/libraries/stdlib/genosl/mx_noise2d_color4.osl b/materialx/libraries/stdlib/genosl/mx_noise2d_color4.osl new file mode 100644 index 000000000..124efda60 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_noise2d_color4.osl @@ -0,0 +1,5 @@ +void mx_noise2d_color4(vector4 amplitude, float pivot, vector2 texcoord, output color4 result) +{ + color4 value = noise("snoise", texcoord.x, texcoord.y); + result = value * color4(color(amplitude.x, amplitude.y, amplitude.z), amplitude.w) + pivot; +} diff --git a/materialx/libraries/stdlib/genosl/mx_noise2d_fa_color3.osl b/materialx/libraries/stdlib/genosl/mx_noise2d_fa_color3.osl new file mode 100644 index 000000000..29c09c1ae --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_noise2d_fa_color3.osl @@ -0,0 +1,5 @@ +void mx_noise2d_fa_color3(float amplitude, float pivot, vector2 texcoord, output color result) +{ + color value = noise("snoise", texcoord.x, texcoord.y); + result = value * amplitude + pivot; +} diff --git a/materialx/libraries/stdlib/genosl/mx_noise2d_fa_color4.osl b/materialx/libraries/stdlib/genosl/mx_noise2d_fa_color4.osl new file mode 100644 index 000000000..a1301d6d5 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_noise2d_fa_color4.osl @@ -0,0 +1,5 @@ +void mx_noise2d_fa_color4(float amplitude, float pivot, vector2 texcoord, output color4 result) +{ + color4 value = noise("snoise", texcoord.x, texcoord.y); + result = value * amplitude + pivot; +} diff --git a/materialx/libraries/stdlib/genosl/mx_noise2d_fa_vector2.osl b/materialx/libraries/stdlib/genosl/mx_noise2d_fa_vector2.osl new file mode 100644 index 000000000..00d7ec100 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_noise2d_fa_vector2.osl @@ -0,0 +1,5 @@ +void mx_noise2d_fa_vector2(float amplitude, float pivot, vector2 texcoord, output vector2 result) +{ + vector2 value = noise("snoise", texcoord.x, texcoord.y); + result = value * amplitude + pivot; +} diff --git a/materialx/libraries/stdlib/genosl/mx_noise2d_fa_vector3.osl b/materialx/libraries/stdlib/genosl/mx_noise2d_fa_vector3.osl new file mode 100644 index 000000000..c1f060a26 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_noise2d_fa_vector3.osl @@ -0,0 +1,5 @@ +void mx_noise2d_fa_vector3(float amplitude, float pivot, vector2 texcoord, output vector result) +{ + vector value = noise("snoise", texcoord.x, texcoord.y); + result = value * amplitude + pivot; +} diff --git a/materialx/libraries/stdlib/genosl/mx_noise2d_fa_vector4.osl b/materialx/libraries/stdlib/genosl/mx_noise2d_fa_vector4.osl new file mode 100644 index 000000000..3634d7b85 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_noise2d_fa_vector4.osl @@ -0,0 +1,5 @@ +void mx_noise2d_fa_vector4(float amplitude, float pivot, vector2 texcoord, output vector4 result) +{ + vector4 value = noise("snoise", texcoord.x, texcoord.y); + result = value * amplitude + pivot; +} diff --git a/materialx/libraries/stdlib/genosl/mx_noise2d_float.osl b/materialx/libraries/stdlib/genosl/mx_noise2d_float.osl new file mode 100644 index 000000000..2af1bd421 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_noise2d_float.osl @@ -0,0 +1,5 @@ +void mx_noise2d_float(float amplitude, float pivot, vector2 texcoord, output float result) +{ + float value = noise("snoise", texcoord.x, texcoord.y); + result = value * amplitude + pivot; +} diff --git a/materialx/libraries/stdlib/genosl/mx_noise2d_vector2.osl b/materialx/libraries/stdlib/genosl/mx_noise2d_vector2.osl new file mode 100644 index 000000000..3a89e760a --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_noise2d_vector2.osl @@ -0,0 +1,5 @@ +void mx_noise2d_vector2(vector2 amplitude, float pivot, vector2 texcoord, output vector2 result) +{ + vector2 value = noise("snoise", texcoord.x, texcoord.y); + result = value * amplitude + pivot; +} diff --git a/materialx/libraries/stdlib/genosl/mx_noise2d_vector3.osl b/materialx/libraries/stdlib/genosl/mx_noise2d_vector3.osl new file mode 100644 index 000000000..06d10cc26 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_noise2d_vector3.osl @@ -0,0 +1,5 @@ +void mx_noise2d_vector3(vector amplitude, float pivot, vector2 texcoord, output vector result) +{ + vector value = noise("snoise", texcoord.x, texcoord.y); + result = value * amplitude + pivot; +} diff --git a/materialx/libraries/stdlib/genosl/mx_noise2d_vector4.osl b/materialx/libraries/stdlib/genosl/mx_noise2d_vector4.osl new file mode 100644 index 000000000..880c8987f --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_noise2d_vector4.osl @@ -0,0 +1,5 @@ +void mx_noise2d_vector4(vector4 amplitude, float pivot, vector2 texcoord, output vector4 result) +{ + vector4 value = noise("snoise", texcoord.x, texcoord.y); + result = value * amplitude + pivot; +} diff --git a/materialx/libraries/stdlib/genosl/mx_noise3d_color3.osl b/materialx/libraries/stdlib/genosl/mx_noise3d_color3.osl new file mode 100644 index 000000000..f4649a598 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_noise3d_color3.osl @@ -0,0 +1,5 @@ +void mx_noise3d_color3(vector amplitude, float pivot, vector position, output color result) +{ + color value = noise("snoise", position); + result = value * amplitude + pivot; +} diff --git a/materialx/libraries/stdlib/genosl/mx_noise3d_color4.osl b/materialx/libraries/stdlib/genosl/mx_noise3d_color4.osl new file mode 100644 index 000000000..e8f228c7e --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_noise3d_color4.osl @@ -0,0 +1,5 @@ +void mx_noise3d_color4(vector4 amplitude, float pivot, vector position, output color4 result) +{ + color4 value = noise("snoise", position); + result = value * combine(amplitude.x, amplitude.y, amplitude.z, amplitude.w) + pivot; +} diff --git a/materialx/libraries/stdlib/genosl/mx_noise3d_fa_color3.osl b/materialx/libraries/stdlib/genosl/mx_noise3d_fa_color3.osl new file mode 100644 index 000000000..83b777b2f --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_noise3d_fa_color3.osl @@ -0,0 +1,5 @@ +void mx_noise3d_fa_color3(float amplitude, float pivot, vector position, output color result) +{ + color value = noise("snoise", position); + result = value * amplitude + pivot; +} diff --git a/materialx/libraries/stdlib/genosl/mx_noise3d_fa_color4.osl b/materialx/libraries/stdlib/genosl/mx_noise3d_fa_color4.osl new file mode 100644 index 000000000..aa0721eec --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_noise3d_fa_color4.osl @@ -0,0 +1,5 @@ +void mx_noise3d_fa_color4(float amplitude, float pivot, vector position, output color4 result) +{ + color4 value = noise("snoise", position); + result = value * amplitude + pivot; +} diff --git a/materialx/libraries/stdlib/genosl/mx_noise3d_fa_vector2.osl b/materialx/libraries/stdlib/genosl/mx_noise3d_fa_vector2.osl new file mode 100644 index 000000000..529a22d02 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_noise3d_fa_vector2.osl @@ -0,0 +1,5 @@ +void mx_noise3d_fa_vector2(float amplitude, float pivot, vector position, output vector2 result) +{ + vector2 value = noise("snoise", position); + result = value * amplitude + pivot; +} diff --git a/materialx/libraries/stdlib/genosl/mx_noise3d_fa_vector3.osl b/materialx/libraries/stdlib/genosl/mx_noise3d_fa_vector3.osl new file mode 100644 index 000000000..4e235febc --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_noise3d_fa_vector3.osl @@ -0,0 +1,5 @@ +void mx_noise3d_fa_vector3(float amplitude, float pivot, vector position, output vector result) +{ + vector value = noise("snoise", position); + result = value * amplitude + pivot; +} diff --git a/materialx/libraries/stdlib/genosl/mx_noise3d_fa_vector4.osl b/materialx/libraries/stdlib/genosl/mx_noise3d_fa_vector4.osl new file mode 100644 index 000000000..8f7ba3bed --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_noise3d_fa_vector4.osl @@ -0,0 +1,5 @@ +void mx_noise3d_fa_vector4(float amplitude, float pivot, vector position, output vector4 result) +{ + vector4 value = noise("snoise", position); + result = value * amplitude + pivot; +} diff --git a/materialx/libraries/stdlib/genosl/mx_noise3d_float.osl b/materialx/libraries/stdlib/genosl/mx_noise3d_float.osl new file mode 100644 index 000000000..23c598509 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_noise3d_float.osl @@ -0,0 +1,5 @@ +void mx_noise3d_float(float amplitude, float pivot, vector position, output float result) +{ + float value = noise("snoise", position); + result = value * amplitude + pivot; +} diff --git a/materialx/libraries/stdlib/genosl/mx_noise3d_vector2.osl b/materialx/libraries/stdlib/genosl/mx_noise3d_vector2.osl new file mode 100644 index 000000000..0ca391cd9 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_noise3d_vector2.osl @@ -0,0 +1,5 @@ +void mx_noise3d_vector2(vector2 amplitude, float pivot, vector position, output vector2 result) +{ + vector2 value = noise("snoise", position); + result = value * amplitude + pivot; +} diff --git a/materialx/libraries/stdlib/genosl/mx_noise3d_vector3.osl b/materialx/libraries/stdlib/genosl/mx_noise3d_vector3.osl new file mode 100644 index 000000000..cc6b2410e --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_noise3d_vector3.osl @@ -0,0 +1,5 @@ +void mx_noise3d_vector3(vector amplitude, float pivot, vector position, output vector result) +{ + vector value = noise("snoise", position); + result = value * amplitude + pivot; +} diff --git a/materialx/libraries/stdlib/genosl/mx_noise3d_vector4.osl b/materialx/libraries/stdlib/genosl/mx_noise3d_vector4.osl new file mode 100644 index 000000000..78c1078d0 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_noise3d_vector4.osl @@ -0,0 +1,5 @@ +void mx_noise3d_vector4(vector4 amplitude, float pivot, vector position, output vector4 result) +{ + vector4 value = noise("snoise", position); + result = value * amplitude + pivot; +} diff --git a/materialx/libraries/stdlib/genosl/mx_normal_vector3.inline b/materialx/libraries/stdlib/genosl/mx_normal_vector3.inline new file mode 100644 index 000000000..0f8bd35c4 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_normal_vector3.inline @@ -0,0 +1 @@ +transform({{space}}, N) diff --git a/materialx/libraries/stdlib/genosl/mx_normalize.inline b/materialx/libraries/stdlib/genosl/mx_normalize.inline new file mode 100644 index 000000000..debdc12ab --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_normalize.inline @@ -0,0 +1 @@ +normalize({{in}}) diff --git a/materialx/libraries/stdlib/genosl/mx_normalmap.osl b/materialx/libraries/stdlib/genosl/mx_normalmap.osl new file mode 100644 index 000000000..a1f276faf --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_normalmap.osl @@ -0,0 +1,17 @@ +void mx_normalmap(vector value, string map_space, float normal_scale, vector N, vector U, output vector result) +{ + // Tangent space + if (map_space == "tangent") + { + vector v = value * 2.0 - 1.0; + vector T = normalize(U - dot(U, N) * N); + vector B = normalize(cross(N, T)); + result = normalize(T * v[0] * normal_scale + B * v[1] * normal_scale + N * v[2]); + } + // Object space + else + { + vector n = value * 2.0 - 1.0; + result = normalize(n); + } +} diff --git a/materialx/libraries/stdlib/genosl/mx_out.inline b/materialx/libraries/stdlib/genosl/mx_out.inline new file mode 100644 index 000000000..32c73976f --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_out.inline @@ -0,0 +1 @@ +({{fg}}*(1.0-{{bg}}.a) * {{mix}}) + ({{bg}} * (1.0-{{mix}})) diff --git a/materialx/libraries/stdlib/genosl/mx_outside.inline b/materialx/libraries/stdlib/genosl/mx_outside.inline new file mode 100644 index 000000000..73a388ad7 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_outside.inline @@ -0,0 +1 @@ +{{in}} * (1.0 - {{mask}}) diff --git a/materialx/libraries/stdlib/genosl/mx_over.inline b/materialx/libraries/stdlib/genosl/mx_over.inline new file mode 100644 index 000000000..8ec28ab61 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_over.inline @@ -0,0 +1 @@ +({{fg}} + ({{bg}}*(1.0-{{fg}}.a))) * {{mix}} + {{bg}} * (1.0-{{mix}}) diff --git a/materialx/libraries/stdlib/genosl/mx_overlay.inline b/materialx/libraries/stdlib/genosl/mx_overlay.inline new file mode 100644 index 000000000..654aba2d3 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_overlay.inline @@ -0,0 +1 @@ +({{fg}} < 0.5) ? ({{mix}}*2.0*{{fg}}*{{bg}}) + ((1.0-{{mix}})*{{bg}}) : ({{mix}}*(1.0-(1.0-{{fg}})*(1.0-{{bg}}))) + ((1.0-{{mix}})*{{bg}}) diff --git a/materialx/libraries/stdlib/genosl/mx_overlay_color3.osl b/materialx/libraries/stdlib/genosl/mx_overlay_color3.osl new file mode 100644 index 000000000..387653fe0 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_overlay_color3.osl @@ -0,0 +1,16 @@ +float overlay(float fg, float bg) +{ + return (fg < 0.5) ? (2 * fg * bg) : (1 - (1 - fg) * (1 - bg)); +} + +color overlay(color fg, color bg) +{ + return color(overlay(fg[0], bg[0]), + overlay(fg[1], bg[1]), + overlay(fg[2], bg[2])); +} + +void mx_overlay_color3(color fg, color bg, float mix, output color out) +{ + out = mix * overlay(fg, bg) + (1-mix) * bg; +} diff --git a/materialx/libraries/stdlib/genosl/mx_overlay_color4.osl b/materialx/libraries/stdlib/genosl/mx_overlay_color4.osl new file mode 100644 index 000000000..1ae6a72c1 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_overlay_color4.osl @@ -0,0 +1,22 @@ +float overlay(float fg, float bg) +{ + return (fg < 0.5) ? (2 * fg * bg) : (1 - (1 - fg) * (1 - bg)); +} + +color overlay(color fg, color bg) +{ + return color(overlay(fg[0], bg[0]), + overlay(fg[1], bg[1]), + overlay(fg[2], bg[2])); +} + +color4 overlay(color4 fg, color4 bg) +{ + return color4(overlay(fg.rgb, bg.rgb), + overlay(fg.a, bg.a)); +} + +void mx_overlay_color4(color4 fg, color4 bg, float mix, output color4 out) +{ + out = mix * overlay(fg, bg) + (1-mix) * bg; +} diff --git a/materialx/libraries/stdlib/genosl/mx_plus.inline b/materialx/libraries/stdlib/genosl/mx_plus.inline new file mode 100644 index 000000000..bc5a3f6b1 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_plus.inline @@ -0,0 +1 @@ +({{mix}}*({{bg}} + {{fg}})) + ((1.0-{{mix}})*{{bg}}) diff --git a/materialx/libraries/stdlib/genosl/mx_position_vector3.inline b/materialx/libraries/stdlib/genosl/mx_position_vector3.inline new file mode 100644 index 000000000..0700aaaf3 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_position_vector3.inline @@ -0,0 +1 @@ +transform({{space}}, P) diff --git a/materialx/libraries/stdlib/genosl/mx_power.inline b/materialx/libraries/stdlib/genosl/mx_power.inline new file mode 100644 index 000000000..b48b1a2e2 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_power.inline @@ -0,0 +1 @@ +pow({{in1}}, {{in2}}) diff --git a/materialx/libraries/stdlib/genosl/mx_premult_color4.osl b/materialx/libraries/stdlib/genosl/mx_premult_color4.osl new file mode 100644 index 000000000..8e57e1392 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_premult_color4.osl @@ -0,0 +1,4 @@ +void mx_premult_color4(color4 in, output color4 result) +{ + result = color4(in.rgb * in.a, in.a); +} diff --git a/materialx/libraries/stdlib/genosl/mx_ramplr.inline b/materialx/libraries/stdlib/genosl/mx_ramplr.inline new file mode 100644 index 000000000..ed94295d4 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_ramplr.inline @@ -0,0 +1 @@ +mix({{valuel}}, {{valuer}}, clamp({{texcoord}}.x, 0, 1)) diff --git a/materialx/libraries/stdlib/genosl/mx_ramptb.inline b/materialx/libraries/stdlib/genosl/mx_ramptb.inline new file mode 100644 index 000000000..2964875e5 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_ramptb.inline @@ -0,0 +1 @@ +mix({{valuet}}, {{valueb}}, clamp({{texcoord}}.y, 0, 1)) diff --git a/materialx/libraries/stdlib/genosl/mx_remap.inline b/materialx/libraries/stdlib/genosl/mx_remap.inline new file mode 100644 index 000000000..298a66000 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_remap.inline @@ -0,0 +1 @@ +remap({{in}}, {{inlow}}, {{inhigh}}, {{outlow}}, {{outhigh}}, 0) diff --git a/materialx/libraries/stdlib/genosl/mx_rgbtohsv_color3.osl b/materialx/libraries/stdlib/genosl/mx_rgbtohsv_color3.osl new file mode 100644 index 000000000..7315ead9b --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_rgbtohsv_color3.osl @@ -0,0 +1,4 @@ +void mx_rgbtohsv_color3(vector _in, output vector result) +{ + result = transformc("rgb","hsv", _in); +} diff --git a/materialx/libraries/stdlib/genosl/mx_rgbtohsv_color4.osl b/materialx/libraries/stdlib/genosl/mx_rgbtohsv_color4.osl new file mode 100644 index 000000000..92edec0e7 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_rgbtohsv_color4.osl @@ -0,0 +1,4 @@ +void mx_rgbtohsv_color4(color4 _in, output color4 result) +{ + result = color4(transformc("rgb","hsv", _in.rgb), 1.0); +} diff --git a/materialx/libraries/stdlib/genosl/mx_rotate_vector2.osl b/materialx/libraries/stdlib/genosl/mx_rotate_vector2.osl new file mode 100644 index 000000000..7ac3dbfa5 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_rotate_vector2.osl @@ -0,0 +1,7 @@ +void mx_rotate_vector2(vector2 _in, float amount, output vector2 result) +{ + float rotationRadians = radians(amount); + float sa = sin(rotationRadians); + float ca = cos(rotationRadians); + result = vector2(ca*_in.x + sa*_in.y, -sa*_in.x + ca*_in.y); +} diff --git a/materialx/libraries/stdlib/genosl/mx_rotate_vector3.osl b/materialx/libraries/stdlib/genosl/mx_rotate_vector3.osl new file mode 100644 index 000000000..d036fe655 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_rotate_vector3.osl @@ -0,0 +1,20 @@ +matrix rotationMatrix(vector axis, float angle) +{ + vector nAxis = normalize(axis); + float s = sin(angle); + float c = cos(angle); + float oc = 1.0 - c; + + return matrix(oc * nAxis[0] * nAxis[0] + c, oc * nAxis[0] * nAxis[1] - nAxis[2] * s, oc * nAxis[2] * nAxis[0] + nAxis[1] * s, 0.0, + oc * nAxis[0] * nAxis[1] + nAxis[2] * s, oc * nAxis[1] * nAxis[1] + c, oc * nAxis[1] * nAxis[2] - nAxis[0] * s, 0.0, + oc * nAxis[2] * nAxis[0] - nAxis[1] * s, oc * nAxis[1] * nAxis[2] + nAxis[0] * s, oc * nAxis[2] * nAxis[2] + c, 0.0, + 0.0, 0.0, 0.0, 1.0); +} + +void mx_rotate_vector3(vector _in, float amount, vector axis, output vector result) +{ + float rotationRadians = radians(amount); + matrix m = rotationMatrix(axis, rotationRadians); + vector4 trans = transform(m, vector4(_in[0], _in[1], _in[2], 1.0)); + result = vector(trans.x, trans.y, trans.z); +} diff --git a/materialx/libraries/stdlib/genosl/mx_screen.inline b/materialx/libraries/stdlib/genosl/mx_screen.inline new file mode 100644 index 000000000..741b58d95 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_screen.inline @@ -0,0 +1 @@ +({{mix}}*((1.0 - (1.0 - {{fg}})) * (1 - {{bg}}))) + ((1.0-{{mix}})*{{bg}}) diff --git a/materialx/libraries/stdlib/genosl/mx_sign.inline b/materialx/libraries/stdlib/genosl/mx_sign.inline new file mode 100644 index 000000000..46e9499cd --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_sign.inline @@ -0,0 +1 @@ +sign({{in}}) diff --git a/materialx/libraries/stdlib/genosl/mx_sin.inline b/materialx/libraries/stdlib/genosl/mx_sin.inline new file mode 100644 index 000000000..8bf8c865a --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_sin.inline @@ -0,0 +1 @@ +sin({{in}}) diff --git a/materialx/libraries/stdlib/genosl/mx_smoothstep.inline b/materialx/libraries/stdlib/genosl/mx_smoothstep.inline new file mode 100644 index 000000000..71f060d87 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_smoothstep.inline @@ -0,0 +1 @@ +smoothstep({{low}}, {{high}}, {{in}}) \ No newline at end of file diff --git a/materialx/libraries/stdlib/genosl/mx_splitlr.inline b/materialx/libraries/stdlib/genosl/mx_splitlr.inline new file mode 100644 index 000000000..a9d867434 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_splitlr.inline @@ -0,0 +1 @@ +mix({{valuel}}, {{valuer}}, aastep({{center}}, {{texcoord}}.x)) diff --git a/materialx/libraries/stdlib/genosl/mx_splittb.inline b/materialx/libraries/stdlib/genosl/mx_splittb.inline new file mode 100644 index 000000000..4c06a5c98 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_splittb.inline @@ -0,0 +1 @@ +mix({{valuet}}, {{valueb}}, aastep({{center}}, {{texcoord}}.y)) diff --git a/materialx/libraries/stdlib/genosl/mx_sqrt.inline b/materialx/libraries/stdlib/genosl/mx_sqrt.inline new file mode 100644 index 000000000..fdcb9ad4e --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_sqrt.inline @@ -0,0 +1 @@ +sqrt({{in}}) diff --git a/materialx/libraries/stdlib/genosl/mx_srgb_texture_to_linear_color3.osl b/materialx/libraries/stdlib/genosl/mx_srgb_texture_to_linear_color3.osl new file mode 100644 index 000000000..a1b20a5ad --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_srgb_texture_to_linear_color3.osl @@ -0,0 +1,17 @@ +void mx_srgb_texture_to_linear_color3(color _in, output color result) +{ + color4 outColor = color4(_in, 0.); + color4 breakPnt = color4(color(0.03928571566939354, 0.03928571566939354, 0.03928571566939354), 1.); + color4 slope = color4(color(0.07738015800714493, 0.07738015800714493, 0.07738015800714493), 1.); + color4 scale = color4(color(0.9478672742843628, 0.9478672742843628, 0.9478672742843628), 1.); + color4 offset = color4(color(0.05213269963860512, 0.05213269963860512, 0.05213269963860512), 0.); + color4 gamma = color4(color(2.4, 2.4, 2.4), 1.0); + color4 isAboveBreak = color4(color(outColor.rgb[0] > breakPnt.rgb[0] ? 1.0 : 0.0, + outColor.rgb[1] > breakPnt.rgb[1] ? 1.0 : 0.0, + outColor.rgb[2] > breakPnt.rgb[2] ? 1.0 : 0.0), + outColor.a > breakPnt.a ? 1.0 : 0.0); + color4 linSeg = outColor * slope; + color4 powSeg = pow( max( color4(color(0., 0., 0.), 0.), scale * outColor + offset), gamma); + color4 resultColor4 = isAboveBreak * powSeg + ( color4(color(1., 1., 1.), 1.) - isAboveBreak ) * linSeg; + result = resultColor4.rgb; +} diff --git a/materialx/libraries/stdlib/genosl/mx_srgb_texture_to_linear_color4.osl b/materialx/libraries/stdlib/genosl/mx_srgb_texture_to_linear_color4.osl new file mode 100644 index 000000000..e26c1235c --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_srgb_texture_to_linear_color4.osl @@ -0,0 +1,19 @@ +void mx_srgb_texture_to_linear_color4(color4 _in, output color4 result) +{ + color4 outColor = color4(_in.rgb, 0.); + color4 breakPnt = color4(color(0.03928571566939354, 0.03928571566939354, 0.03928571566939354), 1.); + color4 slope = color4(color(0.07738015800714493, 0.07738015800714493, 0.07738015800714493), 1.); + color4 scale = color4(color(0.9478672742843628, 0.9478672742843628, 0.9478672742843628), 1.); + color4 offset = color4(color(0.05213269963860512, 0.05213269963860512, 0.05213269963860512), 0.); + color4 gamma = color4(color(2.4, 2.4, 2.4), 1.); + color4 isAboveBreak = color4(color(outColor.rgb[0] > breakPnt.rgb[0] ? 1.0 : 0.0, + outColor.rgb[1] > breakPnt.rgb[1] ? 1.0 : 0.0, + outColor.rgb[2] > breakPnt.rgb[2] ? 1.0 : 0.0), + outColor.a > breakPnt.a ? 1.0 : 0.0); + color4 linSeg = outColor * slope; + color4 tmpA = color4(color(0., 0., 0.), 0.); + color4 powSeg = pow( max( tmpA, scale * outColor + offset), gamma); + color4 tmpB = color4(color(1., 1., 1.), 1.); + color4 tmp = isAboveBreak * powSeg + ( tmpB - isAboveBreak ) * linSeg; + result = color4(tmp.rgb, _in.a); +} diff --git a/materialx/libraries/stdlib/genosl/mx_subtract.inline b/materialx/libraries/stdlib/genosl/mx_subtract.inline new file mode 100644 index 000000000..a70d4a12d --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_subtract.inline @@ -0,0 +1 @@ +mx_sub({{in1}}, {{in2}}) diff --git a/materialx/libraries/stdlib/genosl/mx_tan.inline b/materialx/libraries/stdlib/genosl/mx_tan.inline new file mode 100644 index 000000000..086feffcb --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_tan.inline @@ -0,0 +1 @@ +tan({{in}}) diff --git a/materialx/libraries/stdlib/genosl/mx_tangent_vector3.inline b/materialx/libraries/stdlib/genosl/mx_tangent_vector3.inline new file mode 100644 index 000000000..d58f97545 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_tangent_vector3.inline @@ -0,0 +1 @@ +transform({{space}}, dPdu) diff --git a/materialx/libraries/stdlib/genosl/mx_texcoord_vector2.inline b/materialx/libraries/stdlib/genosl/mx_texcoord_vector2.inline new file mode 100644 index 000000000..93b9dc4db --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_texcoord_vector2.inline @@ -0,0 +1 @@ +vector2(u,v) diff --git a/materialx/libraries/stdlib/genosl/mx_texcoord_vector3.inline b/materialx/libraries/stdlib/genosl/mx_texcoord_vector3.inline new file mode 100644 index 000000000..4a2056bf6 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_texcoord_vector3.inline @@ -0,0 +1 @@ +vector(u,v,0) \ No newline at end of file diff --git a/materialx/libraries/stdlib/genosl/mx_time_float.osl b/materialx/libraries/stdlib/genosl/mx_time_float.osl new file mode 100644 index 000000000..895e0c579 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_time_float.osl @@ -0,0 +1,6 @@ +void mx_time_float(float fps, output float result) +{ + float frame; + getattribute("frame", frame); + result = frame / fps; +} diff --git a/materialx/libraries/stdlib/genosl/mx_transformmatrix.inline b/materialx/libraries/stdlib/genosl/mx_transformmatrix.inline new file mode 100644 index 000000000..fd1213104 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_transformmatrix.inline @@ -0,0 +1 @@ +transform({{mat}}, {{in}}) diff --git a/materialx/libraries/stdlib/genosl/mx_transformmatrix_vector2M3.osl b/materialx/libraries/stdlib/genosl/mx_transformmatrix_vector2M3.osl new file mode 100644 index 000000000..fe1937b80 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_transformmatrix_vector2M3.osl @@ -0,0 +1,6 @@ +void mx_transformmatrix_vector2M3(vector2 val, matrix m, output vector2 result) +{ + point res = transform(m, point(val.x, val.y, 1.0)); + result.x = res[0]; + result.y = res[1]; +} diff --git a/materialx/libraries/stdlib/genosl/mx_transformnormal.inline b/materialx/libraries/stdlib/genosl/mx_transformnormal.inline new file mode 100644 index 000000000..4a6ad62b7 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_transformnormal.inline @@ -0,0 +1 @@ +transform({{fromspace}}, {{tospace}}, normal({{in}})) diff --git a/materialx/libraries/stdlib/genosl/mx_transformpoint.inline b/materialx/libraries/stdlib/genosl/mx_transformpoint.inline new file mode 100644 index 000000000..a5fe17757 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_transformpoint.inline @@ -0,0 +1 @@ +transform({{fromspace}}, {{tospace}}, point({{in}})) diff --git a/materialx/libraries/stdlib/genosl/mx_transformvector.inline b/materialx/libraries/stdlib/genosl/mx_transformvector.inline new file mode 100644 index 000000000..816abd8e5 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_transformvector.inline @@ -0,0 +1 @@ +transform({{fromspace}}, {{tospace}}, {{in}}) diff --git a/materialx/libraries/stdlib/genosl/mx_transpose.inline b/materialx/libraries/stdlib/genosl/mx_transpose.inline new file mode 100644 index 000000000..6a195a036 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_transpose.inline @@ -0,0 +1 @@ +transpose({{in}}) diff --git a/materialx/libraries/stdlib/genosl/mx_unpremult_color4.osl b/materialx/libraries/stdlib/genosl/mx_unpremult_color4.osl new file mode 100644 index 000000000..55d074c76 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/mx_unpremult_color4.osl @@ -0,0 +1,4 @@ +void mx_unpremult_color4(color4 in, output color4 result) +{ + result = color4(in.rgb / in.a, in.a); +} diff --git a/materialx/libraries/stdlib/genosl/stdlib_genosl_cm_impl.mtlx b/materialx/libraries/stdlib/genosl/stdlib_genosl_cm_impl.mtlx new file mode 100644 index 000000000..08baa7504 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/stdlib_genosl_cm_impl.mtlx @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/materialx/libraries/stdlib/genosl/stdlib_genosl_impl.mtlx b/materialx/libraries/stdlib/genosl/stdlib_genosl_impl.mtlx new file mode 100644 index 000000000..d06928cb2 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/stdlib_genosl_impl.mtlx @@ -0,0 +1,775 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/materialx/libraries/stdlib/genosl/stdlib_genosl_unit_impl.mtlx b/materialx/libraries/stdlib/genosl/stdlib_genosl_unit_impl.mtlx new file mode 100644 index 000000000..23d97d2b2 --- /dev/null +++ b/materialx/libraries/stdlib/genosl/stdlib_genosl_unit_impl.mtlx @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/materialx/libraries/stdlib/osl/README.md b/materialx/libraries/stdlib/osl/README.md new file mode 100644 index 000000000..74d70bf87 --- /dev/null +++ b/materialx/libraries/stdlib/osl/README.md @@ -0,0 +1,5 @@ +# OSL Reference Implementations + +This folder contains reference OSL implementations for the standard MaterialX nodes, documenting their intended functionality as of MaterialX v1.35. + +The Open Shading Language team maintains source file generators for the MaterialX nodes at https://github.com/imageworks/OpenShadingLanguage/tree/master/src/shaders/MaterialX, and these source files were built from [this version](https://github.com/imageworks/OpenShadingLanguage/tree/e9e55306ea7b4356b51c91c180e6e9ac1cad6bb1) of the repository. diff --git a/materialx/libraries/stdlib/osl/color4.h b/materialx/libraries/stdlib/osl/color4.h new file mode 100644 index 000000000..bd05d639a --- /dev/null +++ b/materialx/libraries/stdlib/osl/color4.h @@ -0,0 +1,332 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE + +#pragma once +#define COLOR4_H + + +// color4 is a color + alpha +struct color4 +{ + color rgb; + float a; +}; + + + +// +// For color4, define math operators to match color +// + +color4 __operator__neg__(color4 a) +{ + return color4(-a.rgb, -a.a); +} + +color4 __operator__add__(color4 a, color4 b) +{ + return color4(a.rgb + b.rgb, a.a + b.a); +} + +color4 __operator__add__(color4 a, int b) +{ + return a + color4(color(b), b); +} + +color4 __operator__add__(color4 a, float b) +{ + return a + color4(color(b), b); +} + +color4 __operator__add__(int a, color4 b) +{ + return color4(color(a), a) + b; +} + +color4 __operator__add__(float a, color4 b) +{ + return color4(color(a), a) + b; +} + +color4 __operator__sub__(color4 a, color4 b) +{ + return color4(a.rgb - b.rgb, a.a - b.a); +} + +color4 __operator__sub__(color4 a, int b) +{ + return a - color4(color(b), b); +} + +color4 __operator__sub__(color4 a, float b) +{ + return a - color4(color(b), b); +} + +color4 __operator__sub__(int a, color4 b) +{ + return color4(color(a), a) - b; +} + +color4 __operator__sub__(float a, color4 b) +{ + return color4(color(a), a) - b; +} + +color4 __operator__mul__(color4 a, color4 b) +{ + return color4(a.rgb * b.rgb, a.a * b.a); +} + +color4 __operator__mul__(color4 a, int b) +{ + return a * color4(color(b), b); +} + +color4 __operator__mul__(color4 a, float b) +{ + return a * color4(color(b), b); +} + +color4 __operator__mul__(int a, color4 b) +{ + return color4(color(a), a) * b; +} + +color4 __operator__mul__(float a, color4 b) +{ + return color4(color(a), a) * b; +} + +color4 __operator__div__(color4 a, color4 b) +{ + return color4(a.rgb / b.rgb, a.a / b.a); +} + +color4 __operator__div__(color4 a, int b) +{ + float b_inv = 1.0/b; + return a * color4(color(b_inv), b_inv); +} + +color4 __operator__div__(color4 a, float b) +{ + float b_inv = 1.0/b; + return a * color4(color(b_inv), b_inv); +} + +color4 __operator_div__(int a, color4 b) +{ + return color4(color(a), a) / b; +} + +color4 __operator__div__(float a, color4 b) +{ + return color4(color(a), a) / b; +} + +int __operator__eq__(color4 a, color4 b) +{ + return (a.rgb == b.rgb) && (a.a == b.a); +} + +int __operator__ne__(color4 a, color4 b) +{ + return (a.rgb != b.rgb) || (a.a != b.a); +} + + + +// +// For color4, define most of the stdosl functions to match color +// + +color4 abs(color4 a) +{ + return color4(abs(a.rgb), abs(a.a)); +} + +color4 ceil(color4 a) +{ + return color4(ceil(a.rgb), ceil(a.a)); +} + +color4 floor(color4 a) +{ + return color4(floor(a.rgb), floor(a.a)); +} + +color4 sqrt(color4 a) +{ + return color4(sqrt(a.rgb), sqrt(a.a)); +} + +color4 exp(color4 a) +{ + return color4(exp(a.rgb), exp(a.a)); +} + +color4 log(color4 a) +{ + return color4(log(a.rgb), log(a.a)); +} + +color4 log2(color4 a) +{ + return color4(log2(a.rgb), log2(a.a)); +} + +color4 mix(color4 a, color4 b, float x ) +{ + return color4(mix(a.rgb, b.rgb, x), + mix(a.a, b.a, x)); +} + +float dot(color4 a, color b) +{ + return dot(a.rgb, b); +} + +color4 smoothstep(color4 edge0, color4 edge1, color4 c) +{ + return color4(smoothstep(edge0.rgb, edge1.rgb, c.rgb), + smoothstep(edge0.a, edge1.a, c.a)); +} + +color4 smoothstep(float edge0, float edge1, color4 c) +{ + return smoothstep(color4(color(edge0), edge0), color4(color(edge1), edge1), c); +} + +color4 clamp(color4 c, color4 minval, color4 maxval) +{ + return color4(clamp(c.rgb, minval.rgb, maxval.rgb), + clamp(c.a, minval.a, maxval.a)); +} + +color4 clamp(color4 c, float minval, float maxval) +{ + return clamp(c, color4(color(minval), minval), color4(color(maxval), maxval)); +} + +color4 max(color4 a, color4 b) +{ + return color4(max(a.rgb, b.rgb), + max(a.a, b.a)); +} + +color4 max(color4 a, float b) +{ + return color4(max(a.rgb, b), + max(a.a, b)); +} + +color4 min(color4 a, color4 b) +{ + return color4(min(a.rgb, b.rgb), + min(a.a, b.a)); +} + +color4 min(color4 a, float b) +{ + return color4(min(a.rgb, b), + min(a.a, b)); +} + +color4 mod(color4 a, color4 b) +{ + return color4(mod(a.rgb, b.rgb), + mod(a.a, b.a)); +} + +color4 mod(color4 a, int b) +{ + return mod(a, color4(color(b), b)); +} + +color4 mod(color4 a, float b) +{ + return mod(a, color4(color(b), b)); +} + +color4 fmod(color4 a, color4 b) +{ + return color4(fmod(a.rgb, b.rgb), + fmod(a.a, b.a)); +} + +color4 fmod(color4 a, int b) +{ + return fmod(a, color4(color(b), b)); +} + +color4 fmod(color4 a, float b) +{ + return fmod(a, color4(color(b), b)); +} + +color4 pow(color4 base, color4 power) +{ + return color4(pow(base.rgb, power.rgb), + pow(base.a, power.a)); +} + +color4 pow(color4 base, float power) +{ + return color4(pow(base.rgb, power), + pow(base.a, power)); +} + +color4 sign(color4 a) +{ + return color4(sign(a.rgb), + sign(a.a)); +} + +color4 sin(color4 a) +{ + return color4(sin(a.rgb), + sin(a.a)); +} + +color4 cos(color4 a) +{ + return color4(cos(a.rgb), + cos(a.a)); +} + +color4 tan(color4 a) +{ + return color4(tan(a.rgb), + tan(a.a)); +} + +color4 asin(color4 a) +{ + return color4(asin(a.rgb), + asin(a.a)); +} + +color4 acos(color4 a) +{ + return color4(acos(a.rgb), + acos(a.a)); +} + +color4 atan2(color4 a, float f) +{ + return color4(atan2(a.rgb, f), + atan2(a.a, f)); +} + +color4 atan2(color4 a, color4 b) +{ + return color4(atan2(a.rgb, b.rgb), + atan2(a.a, b.a)); +} + + +color4 transformc (string fromspace, string tospace, color4 C) +{ + return color4 (transformc (fromspace, tospace, C.rgb), C.a); +} diff --git a/materialx/libraries/stdlib/osl/matrix33.h b/materialx/libraries/stdlib/osl/matrix33.h new file mode 100644 index 000000000..05537dea7 --- /dev/null +++ b/materialx/libraries/stdlib/osl/matrix33.h @@ -0,0 +1,165 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#pragma once +#define MATRIX33_H + + +struct matrix33 +{ + matrix m; +}; + +int isValidAs33(matrix m44) +{ + return m44[0][3] == 0 && + m44[1][3] == 0 && + m44[2][3] == 0 && + m44[3][0] == 0 && + m44[3][1] == 0 && + m44[3][2] == 0 && + m44[3][3] == 1; +} + +matrix matrix33To44 (matrix33 m33) +{ + return m33.m; +} + +// Convert an arbitrary m44 to m33 by removing the translation +//QUESTION: should we check if it's valid to represent the 4x4 as a 3x3? +matrix33 matrix44To33 (matrix m44) +{ + matrix33 m33; + m33.m = m44; + m33.m[0][3] = 0; + m33.m[1][3] = 0; + m33.m[2][3] = 0; + m33.m[3][0] = 0; + m33.m[3][1] = 0; + m33.m[3][2] = 0; + m33.m[3][3] = 1; + + return m33; +} + +matrix33 __operator__neg__(matrix33 a) +{ + matrix33 m33; + m33.m = -a.m; + return m33; +} + + +matrix33 __operator__mul__(int a, matrix33 b) +{ + matrix33 m33; + m33.m = a * b.m; + return m33; +} + +matrix33 __operator__mul__(float a, matrix33 b) +{ + matrix33 m33; + m33.m = a * b.m; + return m33; +} + +matrix33 __operator__mul__(matrix33 a, int b) +{ + matrix33 m33; + m33.m = a.m * b; + return m33; +} + +matrix33 __operator__mul__(matrix33 a, float b) +{ + matrix33 m33; + m33.m = a.m * b; + return m33; +} + +matrix33 __operator__mul__(matrix33 a, matrix33 b) +{ + matrix33 m33; + m33.m = a.m * b.m; + return m33; +} + +matrix33 __operator__div__(int a, matrix33 b) +{ + matrix33 m33; + m33.m = a / b.m; + return m33; +} + +matrix33 __operator__div__(float a, matrix33 b) +{ + matrix33 m33; + m33.m = a / b.m; + return m33; +} + +matrix33 __operator__div__(matrix33 a, int b) +{ + matrix33 m33; + m33.m = a.m / b; + return m33; +} + +matrix33 __operator__div__(matrix33 a, float b) +{ + matrix33 m33; + m33.m = a.m / b; + return m33; +} + +matrix33 __operator__div__(matrix33 a, matrix33 b) +{ + matrix33 m33; + m33.m = a.m / b.m; + return m33; +} + +int __operator__eq__(matrix33 a, matrix33 b) +{ + return a.m == b.m; +} + +int __operator__ne__(matrix33 a, matrix33 b) +{ + return a.m != b.m; +} + +float determinant (matrix33 a) +{ + return determinant(a.m); +} + +matrix33 transpose(matrix33 a) +{ + matrix33 m33; + m33.m = transpose(a.m); + return m33; +} + +point transform(matrix33 a, point b) +{ + return transform(a.m, b); +} + +vector transform(matrix33 a, vector b) +{ + return transform(a.m, b); +} + +normal transform(matrix33 a, normal b) +{ + return transform(a.m, b); +} + + + diff --git a/materialx/libraries/stdlib/osl/mx_absval_color.osl b/materialx/libraries/stdlib/osl/mx_absval_color.osl new file mode 100644 index 000000000..87f34904e --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_absval_color.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_absval_color + [[ string help = "The per-channel absolute value of the incoming float/color/vector." ]] + ( + color in = 0, + output color out = 0 + ) +{ + out = abs(in); +} diff --git a/materialx/libraries/stdlib/osl/mx_absval_color4.osl b/materialx/libraries/stdlib/osl/mx_absval_color4.osl new file mode 100644 index 000000000..c9973dc56 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_absval_color4.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_absval_color4 + [[ string help = "The per-channel absolute value of the incoming float/color/vector." ]] + ( + color4 in = {color(0,0,0), 0}, + output color4 out = {color(0,0,0), 0} + ) +{ + out = abs(in); +} diff --git a/materialx/libraries/stdlib/osl/mx_absval_float.osl b/materialx/libraries/stdlib/osl/mx_absval_float.osl new file mode 100644 index 000000000..ee23b2b8c --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_absval_float.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_absval_float + [[ string help = "The per-channel absolute value of the incoming float/color/vector." ]] + ( + float in = 0, + output float out = 0 + ) +{ + out = abs(in); +} diff --git a/materialx/libraries/stdlib/osl/mx_absval_vector.osl b/materialx/libraries/stdlib/osl/mx_absval_vector.osl new file mode 100644 index 000000000..6800614bd --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_absval_vector.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_absval_vector + [[ string help = "The per-channel absolute value of the incoming float/color/vector." ]] + ( + vector in = 0, + output vector out = 0 + ) +{ + out = abs(in); +} diff --git a/materialx/libraries/stdlib/osl/mx_absval_vector2.osl b/materialx/libraries/stdlib/osl/mx_absval_vector2.osl new file mode 100644 index 000000000..d56c18313 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_absval_vector2.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_absval_vector2 + [[ string help = "The per-channel absolute value of the incoming float/color/vector." ]] + ( + vector2 in = {0,0}, + output vector2 out = {0,0} + ) +{ + out = abs(in); +} diff --git a/materialx/libraries/stdlib/osl/mx_absval_vector4.osl b/materialx/libraries/stdlib/osl/mx_absval_vector4.osl new file mode 100644 index 000000000..133524090 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_absval_vector4.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_absval_vector4 + [[ string help = "The per-channel absolute value of the incoming float/color/vector." ]] + ( + vector4 in = {0,0,0,0}, + output vector4 out = {0,0,0,0} + ) +{ + out = abs(in); +} diff --git a/materialx/libraries/stdlib/osl/mx_acos_color.osl b/materialx/libraries/stdlib/osl/mx_acos_color.osl new file mode 100644 index 000000000..bd17e6a7e --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_acos_color.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_acos_color + [[ string help = "Color"" acos(in)" ]] + ( + color in = 0, + output color out = 0 + ) +{ + out = acos(in); +} diff --git a/materialx/libraries/stdlib/osl/mx_acos_color4.osl b/materialx/libraries/stdlib/osl/mx_acos_color4.osl new file mode 100644 index 000000000..5462b0b4e --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_acos_color4.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_acos_color4 + [[ string help = "Color4"" acos(in)" ]] + ( + color4 in = {color(0,0,0), 0}, + output color4 out = {color(0,0,0), 0} + ) +{ + out = acos(in); +} diff --git a/materialx/libraries/stdlib/osl/mx_acos_float.osl b/materialx/libraries/stdlib/osl/mx_acos_float.osl new file mode 100644 index 000000000..90f8c16f2 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_acos_float.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_acos_float + [[ string help = "Float"" acos(in)" ]] + ( + float in = 0, + output float out = 0 + ) +{ + out = acos(in); +} diff --git a/materialx/libraries/stdlib/osl/mx_acos_vector.osl b/materialx/libraries/stdlib/osl/mx_acos_vector.osl new file mode 100644 index 000000000..a4a9b309e --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_acos_vector.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_acos_vector + [[ string help = "Vector"" acos(in)" ]] + ( + vector in = 0, + output vector out = 0 + ) +{ + out = acos(in); +} diff --git a/materialx/libraries/stdlib/osl/mx_acos_vector2.osl b/materialx/libraries/stdlib/osl/mx_acos_vector2.osl new file mode 100644 index 000000000..faa8cd33c --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_acos_vector2.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_acos_vector2 + [[ string help = "Vector2"" acos(in)" ]] + ( + vector2 in = {0,0}, + output vector2 out = {0,0} + ) +{ + out = acos(in); +} diff --git a/materialx/libraries/stdlib/osl/mx_acos_vector4.osl b/materialx/libraries/stdlib/osl/mx_acos_vector4.osl new file mode 100644 index 000000000..48016c40d --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_acos_vector4.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_acos_vector4 + [[ string help = "Vector4"" acos(in)" ]] + ( + vector4 in = {0,0,0,0}, + output vector4 out = {0,0,0,0} + ) +{ + out = acos(in); +} diff --git a/materialx/libraries/stdlib/osl/mx_add_color.osl b/materialx/libraries/stdlib/osl/mx_add_color.osl new file mode 100644 index 000000000..6607a803c --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_add_color.osl @@ -0,0 +1,19 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + + +shader mx_add_color + [[ string help = "Color"" add in2 to the incoming data" ]] + ( + color in1 = 0, + color in2 = 0, + output color out = 0 + ) +{ + out = mx_add (in1, in2); +} diff --git a/materialx/libraries/stdlib/osl/mx_add_color4.osl b/materialx/libraries/stdlib/osl/mx_add_color4.osl new file mode 100644 index 000000000..4cb30c69a --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_add_color4.osl @@ -0,0 +1,19 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + + +shader mx_add_color4 + [[ string help = "Color4"" add in2 to the incoming data" ]] + ( + color4 in1 = {color(0,0,0), 0}, + color4 in2 = {color(0,0,0), 0}, + output color4 out = {color(0,0,0), 0} + ) +{ + out = mx_add (in1, in2); +} diff --git a/materialx/libraries/stdlib/osl/mx_add_float.osl b/materialx/libraries/stdlib/osl/mx_add_float.osl new file mode 100644 index 000000000..2703bfcd3 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_add_float.osl @@ -0,0 +1,19 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + + +shader mx_add_float + [[ string help = "Float"" add in2 to the incoming data" ]] + ( + float in1 = 0, + float in2 = 0, + output float out = 0 + ) +{ + out = mx_add (in1, in2); +} diff --git a/materialx/libraries/stdlib/osl/mx_add_float_color.osl b/materialx/libraries/stdlib/osl/mx_add_float_color.osl new file mode 100644 index 000000000..d3c7a7b9d --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_add_float_color.osl @@ -0,0 +1,18 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_add_float_color + [[ string help = "Color"" add in2 to the incoming data" ]] + ( + color in1 = 0, + float in2 = 0.0, + output color out = 0 + ) +{ + out = mx_add (in1, in2); +} diff --git a/materialx/libraries/stdlib/osl/mx_add_float_color4.osl b/materialx/libraries/stdlib/osl/mx_add_float_color4.osl new file mode 100644 index 000000000..b8912c3b4 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_add_float_color4.osl @@ -0,0 +1,18 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_add_float_color4 + [[ string help = "Color4"" add in2 to the incoming data" ]] + ( + color4 in1 = {color(0,0,0), 0}, + float in2 = 0.0, + output color4 out = {color(0,0,0), 0} + ) +{ + out = mx_add (in1, in2); +} diff --git a/materialx/libraries/stdlib/osl/mx_add_float_matrix33.osl b/materialx/libraries/stdlib/osl/mx_add_float_matrix33.osl new file mode 100644 index 000000000..6095b88ea --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_add_float_matrix33.osl @@ -0,0 +1,18 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_add_float_matrix33 + [[ string help = "Matrix33"" add in2 to the incoming data" ]] + ( + matrix in1 = matrix(0), + float in2 = 0.0, + output matrix out = matrix(0) + ) +{ + out = mx_add (in1, in2); +} diff --git a/materialx/libraries/stdlib/osl/mx_add_float_matrix44.osl b/materialx/libraries/stdlib/osl/mx_add_float_matrix44.osl new file mode 100644 index 000000000..2533aeb47 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_add_float_matrix44.osl @@ -0,0 +1,18 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_add_float_matrix44 + [[ string help = "Matrix44"" add in2 to the incoming data" ]] + ( + matrix in1 = matrix(0), + float in2 = 0.0, + output matrix out = matrix(0) + ) +{ + out = mx_add (in1, in2); +} diff --git a/materialx/libraries/stdlib/osl/mx_add_float_vector.osl b/materialx/libraries/stdlib/osl/mx_add_float_vector.osl new file mode 100644 index 000000000..e130766ee --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_add_float_vector.osl @@ -0,0 +1,18 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_add_float_vector + [[ string help = "Vector"" add in2 to the incoming data" ]] + ( + vector in1 = 0, + float in2 = 0.0, + output vector out = 0 + ) +{ + out = mx_add (in1, in2); +} diff --git a/materialx/libraries/stdlib/osl/mx_add_float_vector2.osl b/materialx/libraries/stdlib/osl/mx_add_float_vector2.osl new file mode 100644 index 000000000..724a893f6 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_add_float_vector2.osl @@ -0,0 +1,18 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_add_float_vector2 + [[ string help = "Vector2"" add in2 to the incoming data" ]] + ( + vector2 in1 = {0,0}, + float in2 = 0.0, + output vector2 out = {0,0} + ) +{ + out = mx_add (in1, in2); +} diff --git a/materialx/libraries/stdlib/osl/mx_add_float_vector4.osl b/materialx/libraries/stdlib/osl/mx_add_float_vector4.osl new file mode 100644 index 000000000..00b8b8a49 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_add_float_vector4.osl @@ -0,0 +1,18 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_add_float_vector4 + [[ string help = "Vector4"" add in2 to the incoming data" ]] + ( + vector4 in1 = {0,0,0,0}, + float in2 = 0.0, + output vector4 out = {0,0,0,0} + ) +{ + out = mx_add (in1, in2); +} diff --git a/materialx/libraries/stdlib/osl/mx_add_matrix33.osl b/materialx/libraries/stdlib/osl/mx_add_matrix33.osl new file mode 100644 index 000000000..75e7683b2 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_add_matrix33.osl @@ -0,0 +1,19 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + + +shader mx_add_matrix33 + [[ string help = "Matrix33"" add in2 to the incoming data" ]] + ( + matrix in1 = matrix(0), + matrix in2 = matrix(0), + output matrix out = matrix(0) + ) +{ + out = mx_add (in1, in2); +} diff --git a/materialx/libraries/stdlib/osl/mx_add_matrix44.osl b/materialx/libraries/stdlib/osl/mx_add_matrix44.osl new file mode 100644 index 000000000..b38e05ff9 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_add_matrix44.osl @@ -0,0 +1,19 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + + +shader mx_add_matrix44 + [[ string help = "Matrix44"" add in2 to the incoming data" ]] + ( + matrix in1 = matrix(0), + matrix in2 = matrix(0), + output matrix out = matrix(0) + ) +{ + out = mx_add (in1, in2); +} diff --git a/materialx/libraries/stdlib/osl/mx_add_surfaceshader.osl b/materialx/libraries/stdlib/osl/mx_add_surfaceshader.osl new file mode 100644 index 000000000..b980c7d15 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_add_surfaceshader.osl @@ -0,0 +1,19 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + + +shader mx_add_surfaceshader + [[ string help = "surfaceshader"" add in2 to the incoming data" ]] + ( + closure color in1 = 0, + closure color in2 = 0, + output closure color out = 0 + ) +{ + out = mx_add (in1, in2); +} diff --git a/materialx/libraries/stdlib/osl/mx_add_vector.osl b/materialx/libraries/stdlib/osl/mx_add_vector.osl new file mode 100644 index 000000000..a94ef17eb --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_add_vector.osl @@ -0,0 +1,19 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + + +shader mx_add_vector + [[ string help = "Vector"" add in2 to the incoming data" ]] + ( + vector in1 = 0, + vector in2 = 0, + output vector out = 0 + ) +{ + out = mx_add (in1, in2); +} diff --git a/materialx/libraries/stdlib/osl/mx_add_vector2.osl b/materialx/libraries/stdlib/osl/mx_add_vector2.osl new file mode 100644 index 000000000..5f8c57167 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_add_vector2.osl @@ -0,0 +1,19 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + + +shader mx_add_vector2 + [[ string help = "Vector2"" add in2 to the incoming data" ]] + ( + vector2 in1 = {0,0}, + vector2 in2 = {0,0}, + output vector2 out = {0,0} + ) +{ + out = mx_add (in1, in2); +} diff --git a/materialx/libraries/stdlib/osl/mx_add_vector4.osl b/materialx/libraries/stdlib/osl/mx_add_vector4.osl new file mode 100644 index 000000000..f179047f2 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_add_vector4.osl @@ -0,0 +1,19 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + + +shader mx_add_vector4 + [[ string help = "Vector4"" add in2 to the incoming data" ]] + ( + vector4 in1 = {0,0,0,0}, + vector4 in2 = {0,0,0,0}, + output vector4 out = {0,0,0,0} + ) +{ + out = mx_add (in1, in2); +} diff --git a/materialx/libraries/stdlib/osl/mx_ambientocclusion_float.osl b/materialx/libraries/stdlib/osl/mx_ambientocclusion_float.osl new file mode 100644 index 000000000..db6396e8e --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_ambientocclusion_float.osl @@ -0,0 +1,19 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_ambientocclusion_float + [[ string help = "Computes the ambient occlusion (0-1 float) at the current surface point." ]] + ( + float coneangle = 90, + float maxdistance = 1000000, + output float out = 0 + ) +{ + // This node is a stub and does not currently operate to specification + out = 0; +} diff --git a/materialx/libraries/stdlib/osl/mx_asin_color.osl b/materialx/libraries/stdlib/osl/mx_asin_color.osl new file mode 100644 index 000000000..de3bbada3 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_asin_color.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_asin_color + [[ string help = "Color"" asin(in)" ]] + ( + color in = 0, + output color out = 0 + ) +{ + out = asin(in); +} diff --git a/materialx/libraries/stdlib/osl/mx_asin_color4.osl b/materialx/libraries/stdlib/osl/mx_asin_color4.osl new file mode 100644 index 000000000..f9d359cc6 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_asin_color4.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_asin_color4 + [[ string help = "Color4"" asin(in)" ]] + ( + color4 in = {color(0,0,0), 0}, + output color4 out = {color(0,0,0), 0} + ) +{ + out = asin(in); +} diff --git a/materialx/libraries/stdlib/osl/mx_asin_float.osl b/materialx/libraries/stdlib/osl/mx_asin_float.osl new file mode 100644 index 000000000..ad7cae933 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_asin_float.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_asin_float + [[ string help = "Float"" asin(in)" ]] + ( + float in = 0, + output float out = 0 + ) +{ + out = asin(in); +} diff --git a/materialx/libraries/stdlib/osl/mx_asin_vector.osl b/materialx/libraries/stdlib/osl/mx_asin_vector.osl new file mode 100644 index 000000000..aa4663727 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_asin_vector.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_asin_vector + [[ string help = "Vector"" asin(in)" ]] + ( + vector in = 0, + output vector out = 0 + ) +{ + out = asin(in); +} diff --git a/materialx/libraries/stdlib/osl/mx_asin_vector2.osl b/materialx/libraries/stdlib/osl/mx_asin_vector2.osl new file mode 100644 index 000000000..65a1ce5e2 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_asin_vector2.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_asin_vector2 + [[ string help = "Vector2"" asin(in)" ]] + ( + vector2 in = {0,0}, + output vector2 out = {0,0} + ) +{ + out = asin(in); +} diff --git a/materialx/libraries/stdlib/osl/mx_asin_vector4.osl b/materialx/libraries/stdlib/osl/mx_asin_vector4.osl new file mode 100644 index 000000000..3d818ea7c --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_asin_vector4.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_asin_vector4 + [[ string help = "Vector4"" asin(in)" ]] + ( + vector4 in = {0,0,0,0}, + output vector4 out = {0,0,0,0} + ) +{ + out = asin(in); +} diff --git a/materialx/libraries/stdlib/osl/mx_atan2_color.osl b/materialx/libraries/stdlib/osl/mx_atan2_color.osl new file mode 100644 index 000000000..73c48db13 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_atan2_color.osl @@ -0,0 +1,19 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_atan2_color + [[ string help = "Color"" atan2(in1, in2)" ]] + ( + color in1 = 0, + color in2 = 0, + + output color out = 0 + ) +{ + out = atan2(in1, in2); +} diff --git a/materialx/libraries/stdlib/osl/mx_atan2_color4.osl b/materialx/libraries/stdlib/osl/mx_atan2_color4.osl new file mode 100644 index 000000000..e886f1d94 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_atan2_color4.osl @@ -0,0 +1,19 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_atan2_color4 + [[ string help = "Color4"" atan2(in1, in2)" ]] + ( + color4 in1 = {color(0,0,0), 0}, + color4 in2 = {color(0,0,0), 0}, + + output color4 out = {color(0,0,0), 0} + ) +{ + out = atan2(in1, in2); +} diff --git a/materialx/libraries/stdlib/osl/mx_atan2_float.osl b/materialx/libraries/stdlib/osl/mx_atan2_float.osl new file mode 100644 index 000000000..ab8007a47 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_atan2_float.osl @@ -0,0 +1,19 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_atan2_float + [[ string help = "Float"" atan2(in1, in2)" ]] + ( + float in1 = 0, + float in2 = 0, + + output float out = 0 + ) +{ + out = atan2(in1, in2); +} diff --git a/materialx/libraries/stdlib/osl/mx_atan2_float_color.osl b/materialx/libraries/stdlib/osl/mx_atan2_float_color.osl new file mode 100644 index 000000000..b9e9bc464 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_atan2_float_color.osl @@ -0,0 +1,19 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_atan2_float_color + [[ string help = "Color"" atan2(in1, in2)" ]] + ( + color in1 = 0, + float in2 = 0.0, + + output color out = 0 + ) +{ + out = atan2(in1, in2); +} diff --git a/materialx/libraries/stdlib/osl/mx_atan2_float_color4.osl b/materialx/libraries/stdlib/osl/mx_atan2_float_color4.osl new file mode 100644 index 000000000..32363a4ec --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_atan2_float_color4.osl @@ -0,0 +1,19 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_atan2_float_color4 + [[ string help = "Color4"" atan2(in1, in2)" ]] + ( + color4 in1 = {color(0,0,0), 0}, + float in2 = 0.0, + + output color4 out = {color(0,0,0), 0} + ) +{ + out = atan2(in1, in2); +} diff --git a/materialx/libraries/stdlib/osl/mx_atan2_float_vector.osl b/materialx/libraries/stdlib/osl/mx_atan2_float_vector.osl new file mode 100644 index 000000000..4be35e559 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_atan2_float_vector.osl @@ -0,0 +1,19 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_atan2_float_vector + [[ string help = "Vector"" atan2(in1, in2)" ]] + ( + vector in1 = 0, + float in2 = 0.0, + + output vector out = 0 + ) +{ + out = atan2(in1, in2); +} diff --git a/materialx/libraries/stdlib/osl/mx_atan2_float_vector2.osl b/materialx/libraries/stdlib/osl/mx_atan2_float_vector2.osl new file mode 100644 index 000000000..6df062e0b --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_atan2_float_vector2.osl @@ -0,0 +1,19 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_atan2_float_vector2 + [[ string help = "Vector2"" atan2(in1, in2)" ]] + ( + vector2 in1 = {0,0}, + float in2 = 0.0, + + output vector2 out = {0,0} + ) +{ + out = atan2(in1, in2); +} diff --git a/materialx/libraries/stdlib/osl/mx_atan2_float_vector4.osl b/materialx/libraries/stdlib/osl/mx_atan2_float_vector4.osl new file mode 100644 index 000000000..9b9a2fffd --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_atan2_float_vector4.osl @@ -0,0 +1,19 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_atan2_float_vector4 + [[ string help = "Vector4"" atan2(in1, in2)" ]] + ( + vector4 in1 = {0,0,0,0}, + float in2 = 0.0, + + output vector4 out = {0,0,0,0} + ) +{ + out = atan2(in1, in2); +} diff --git a/materialx/libraries/stdlib/osl/mx_atan2_vector.osl b/materialx/libraries/stdlib/osl/mx_atan2_vector.osl new file mode 100644 index 000000000..90a3b169a --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_atan2_vector.osl @@ -0,0 +1,19 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_atan2_vector + [[ string help = "Vector"" atan2(in1, in2)" ]] + ( + vector in1 = 0, + vector in2 = 0, + + output vector out = 0 + ) +{ + out = atan2(in1, in2); +} diff --git a/materialx/libraries/stdlib/osl/mx_atan2_vector2.osl b/materialx/libraries/stdlib/osl/mx_atan2_vector2.osl new file mode 100644 index 000000000..098c4e531 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_atan2_vector2.osl @@ -0,0 +1,19 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_atan2_vector2 + [[ string help = "Vector2"" atan2(in1, in2)" ]] + ( + vector2 in1 = {0,0}, + vector2 in2 = {0,0}, + + output vector2 out = {0,0} + ) +{ + out = atan2(in1, in2); +} diff --git a/materialx/libraries/stdlib/osl/mx_atan2_vector4.osl b/materialx/libraries/stdlib/osl/mx_atan2_vector4.osl new file mode 100644 index 000000000..a8dd1d9a2 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_atan2_vector4.osl @@ -0,0 +1,19 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_atan2_vector4 + [[ string help = "Vector4"" atan2(in1, in2)" ]] + ( + vector4 in1 = {0,0,0,0}, + vector4 in2 = {0,0,0,0}, + + output vector4 out = {0,0,0,0} + ) +{ + out = atan2(in1, in2); +} diff --git a/materialx/libraries/stdlib/osl/mx_bitangent_vector.osl b/materialx/libraries/stdlib/osl/mx_bitangent_vector.osl new file mode 100644 index 000000000..0ee208cfd --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_bitangent_vector.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_bitangent_vector + [[ string help = "The geometric bitangent vector in a specific coordinate space." ]] + ( + string space = "object", + output vector out = 0 + ) +{ + out = transform(space, dPdv); +} diff --git a/materialx/libraries/stdlib/osl/mx_blur_color.osl b/materialx/libraries/stdlib/osl/mx_blur_color.osl new file mode 100644 index 000000000..4f8429cbd --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_blur_color.osl @@ -0,0 +1,19 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_blur_color + [[ string help = "A gaussian-falloff blur." ]] + ( + color in = 0, + float amount = 0, + output color out = 0 + ) +{ + // This node is a stub and does not currently operate to specification + out = in; +} diff --git a/materialx/libraries/stdlib/osl/mx_blur_color4.osl b/materialx/libraries/stdlib/osl/mx_blur_color4.osl new file mode 100644 index 000000000..7f8050ad5 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_blur_color4.osl @@ -0,0 +1,19 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_blur_color4 + [[ string help = "A gaussian-falloff blur." ]] + ( + color4 in = {color(0,0,0), 0}, + float amount = 0, + output color4 out = {color(0,0,0), 0} + ) +{ + // This node is a stub and does not currently operate to specification + out = in; +} diff --git a/materialx/libraries/stdlib/osl/mx_blur_float.osl b/materialx/libraries/stdlib/osl/mx_blur_float.osl new file mode 100644 index 000000000..fcfd007a6 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_blur_float.osl @@ -0,0 +1,19 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_blur_float + [[ string help = "A gaussian-falloff blur." ]] + ( + float in = 0, + float amount = 0, + output float out = 0 + ) +{ + // This node is a stub and does not currently operate to specification + out = in; +} diff --git a/materialx/libraries/stdlib/osl/mx_blur_vector.osl b/materialx/libraries/stdlib/osl/mx_blur_vector.osl new file mode 100644 index 000000000..2763ec64c --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_blur_vector.osl @@ -0,0 +1,19 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_blur_vector + [[ string help = "A gaussian-falloff blur." ]] + ( + vector in = 0, + float amount = 0, + output vector out = 0 + ) +{ + // This node is a stub and does not currently operate to specification + out = in; +} diff --git a/materialx/libraries/stdlib/osl/mx_blur_vector2.osl b/materialx/libraries/stdlib/osl/mx_blur_vector2.osl new file mode 100644 index 000000000..219df4bdf --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_blur_vector2.osl @@ -0,0 +1,19 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_blur_vector2 + [[ string help = "A gaussian-falloff blur." ]] + ( + vector2 in = {0,0}, + float amount = 0, + output vector2 out = {0,0} + ) +{ + // This node is a stub and does not currently operate to specification + out = in; +} diff --git a/materialx/libraries/stdlib/osl/mx_blur_vector4.osl b/materialx/libraries/stdlib/osl/mx_blur_vector4.osl new file mode 100644 index 000000000..d3a07d836 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_blur_vector4.osl @@ -0,0 +1,19 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_blur_vector4 + [[ string help = "A gaussian-falloff blur." ]] + ( + vector4 in = {0,0,0,0}, + float amount = 0, + output vector4 out = {0,0,0,0} + ) +{ + // This node is a stub and does not currently operate to specification + out = in; +} diff --git a/materialx/libraries/stdlib/osl/mx_burn_color.osl b/materialx/libraries/stdlib/osl/mx_burn_color.osl new file mode 100644 index 000000000..ea5310f92 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_burn_color.osl @@ -0,0 +1,18 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_burn_color + [[ string help = "Color"" Take two 1-4 channel inputs and apply the same operator to all channels: 1-(1-B)/F" ]] + ( + color fg = 0, + color bg = 0, + output color out = 0 + ) +{ + out = 1 - ((1 - bg) / fg); +} diff --git a/materialx/libraries/stdlib/osl/mx_burn_color4.osl b/materialx/libraries/stdlib/osl/mx_burn_color4.osl new file mode 100644 index 000000000..87eaf90d4 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_burn_color4.osl @@ -0,0 +1,18 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_burn_color4 + [[ string help = "Color4"" Take two 1-4 channel inputs and apply the same operator to all channels: 1-(1-B)/F" ]] + ( + color4 fg = {color(0,0,0), 0}, + color4 bg = {color(0,0,0), 0}, + output color4 out = {color(0,0,0), 0} + ) +{ + out = 1 - ((1 - bg) / fg); +} diff --git a/materialx/libraries/stdlib/osl/mx_burn_float.osl b/materialx/libraries/stdlib/osl/mx_burn_float.osl new file mode 100644 index 000000000..f79305c02 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_burn_float.osl @@ -0,0 +1,18 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_burn_float + [[ string help = "Float"" Take two 1-4 channel inputs and apply the same operator to all channels: 1-(1-B)/F" ]] + ( + float fg = 0, + float bg = 0, + output float out = 0 + ) +{ + out = 1 - ((1 - bg) / fg); +} diff --git a/materialx/libraries/stdlib/osl/mx_ceil_color.osl b/materialx/libraries/stdlib/osl/mx_ceil_color.osl new file mode 100644 index 000000000..8c366512c --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_ceil_color.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_ceil_color + [[ string help = "Color"" Find the smallest integer less than or equal to the parameter." ]] + ( + color in = 0, + output color out = 0 + ) +{ + out = ceil(in); +} diff --git a/materialx/libraries/stdlib/osl/mx_ceil_color4.osl b/materialx/libraries/stdlib/osl/mx_ceil_color4.osl new file mode 100644 index 000000000..834c559a3 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_ceil_color4.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_ceil_color4 + [[ string help = "Color4"" Find the smallest integer less than or equal to the parameter." ]] + ( + color4 in = {color(0,0,0), 0}, + output color4 out = {color(0,0,0), 0} + ) +{ + out = ceil(in); +} diff --git a/materialx/libraries/stdlib/osl/mx_ceil_float.osl b/materialx/libraries/stdlib/osl/mx_ceil_float.osl new file mode 100644 index 000000000..5c553d843 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_ceil_float.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_ceil_float + [[ string help = "Float"" Find the smallest integer less than or equal to the parameter." ]] + ( + float in = 0, + output float out = 0 + ) +{ + out = ceil(in); +} diff --git a/materialx/libraries/stdlib/osl/mx_ceil_vector.osl b/materialx/libraries/stdlib/osl/mx_ceil_vector.osl new file mode 100644 index 000000000..64aa908d6 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_ceil_vector.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_ceil_vector + [[ string help = "Vector"" Find the smallest integer less than or equal to the parameter." ]] + ( + vector in = 0, + output vector out = 0 + ) +{ + out = ceil(in); +} diff --git a/materialx/libraries/stdlib/osl/mx_ceil_vector2.osl b/materialx/libraries/stdlib/osl/mx_ceil_vector2.osl new file mode 100644 index 000000000..df6933274 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_ceil_vector2.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_ceil_vector2 + [[ string help = "Vector2"" Find the smallest integer less than or equal to the parameter." ]] + ( + vector2 in = {0,0}, + output vector2 out = {0,0} + ) +{ + out = ceil(in); +} diff --git a/materialx/libraries/stdlib/osl/mx_ceil_vector4.osl b/materialx/libraries/stdlib/osl/mx_ceil_vector4.osl new file mode 100644 index 000000000..a844d6de8 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_ceil_vector4.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_ceil_vector4 + [[ string help = "Vector4"" Find the smallest integer less than or equal to the parameter." ]] + ( + vector4 in = {0,0,0,0}, + output vector4 out = {0,0,0,0} + ) +{ + out = ceil(in); +} diff --git a/materialx/libraries/stdlib/osl/mx_cellnoise2d_float.osl b/materialx/libraries/stdlib/osl/mx_cellnoise2d_float.osl new file mode 100644 index 000000000..97491ad23 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_cellnoise2d_float.osl @@ -0,0 +1,20 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_cellnoise2d_float + [[ string help = "2D cell noise in 1 channel" ]] + ( + vector2 texcoord = {u, v} + [[ string help = "input coordinate position", + int lockgeom = 0 ]], + + output float out = 0 + ) +{ + out = cellnoise (texcoord.x, texcoord.y); +} diff --git a/materialx/libraries/stdlib/osl/mx_cellnoise3d_float.osl b/materialx/libraries/stdlib/osl/mx_cellnoise3d_float.osl new file mode 100644 index 000000000..2d524b9ae --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_cellnoise3d_float.osl @@ -0,0 +1,20 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_cellnoise3d_float + [[ string help = "3D cell noise in one channel" ]] + ( + point position = transform ("object", P) + [[ string help = "input coordinate position (default: object space P)", + int lockgeom = 0 ]], + + output float out = 0 + ) +{ + out = cellnoise (position); +} diff --git a/materialx/libraries/stdlib/osl/mx_clamp_color.osl b/materialx/libraries/stdlib/osl/mx_clamp_color.osl new file mode 100644 index 000000000..1991029e5 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_clamp_color.osl @@ -0,0 +1,19 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_clamp_color + [[ string help = "Color"" Clamp incoming value to a specified range of values." ]] + ( + color in = 0, + color low = 0, + color high = 1, + output color out = 0 + ) +{ + out = clamp(in, low, high); +} diff --git a/materialx/libraries/stdlib/osl/mx_clamp_color4.osl b/materialx/libraries/stdlib/osl/mx_clamp_color4.osl new file mode 100644 index 000000000..85e65755a --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_clamp_color4.osl @@ -0,0 +1,19 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_clamp_color4 + [[ string help = "Color4"" Clamp incoming value to a specified range of values." ]] + ( + color4 in = {color(0,0,0), 0}, + color4 low = {color(0,0,0), 0}, + color4 high = {color(1,1,1), 1}, + output color4 out = {color(0,0,0), 0} + ) +{ + out = clamp(in, low, high); +} diff --git a/materialx/libraries/stdlib/osl/mx_clamp_float.osl b/materialx/libraries/stdlib/osl/mx_clamp_float.osl new file mode 100644 index 000000000..e27c7d3a3 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_clamp_float.osl @@ -0,0 +1,19 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_clamp_float + [[ string help = "Float"" Clamp incoming value to a specified range of values." ]] + ( + float in = 0, + float low = 0, + float high = 1, + output float out = 0 + ) +{ + out = clamp(in, low, high); +} diff --git a/materialx/libraries/stdlib/osl/mx_clamp_float_color.osl b/materialx/libraries/stdlib/osl/mx_clamp_float_color.osl new file mode 100644 index 000000000..b45f3b3e1 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_clamp_float_color.osl @@ -0,0 +1,19 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_clamp_float_color + [[ string help = "Color"" Clamp incoming value to a specified range of values." ]] + ( + color in = 0, + float low = 0.0, + float high = 1.0, + output color out = 0 + ) +{ + out = clamp(in, low, high); +} diff --git a/materialx/libraries/stdlib/osl/mx_clamp_float_color4.osl b/materialx/libraries/stdlib/osl/mx_clamp_float_color4.osl new file mode 100644 index 000000000..67ad0ce28 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_clamp_float_color4.osl @@ -0,0 +1,19 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_clamp_float_color4 + [[ string help = "Color4"" Clamp incoming value to a specified range of values." ]] + ( + color4 in = {color(0,0,0), 0}, + float low = 0.0, + float high = 1.0, + output color4 out = {color(0,0,0), 0} + ) +{ + out = clamp(in, low, high); +} diff --git a/materialx/libraries/stdlib/osl/mx_clamp_float_vector.osl b/materialx/libraries/stdlib/osl/mx_clamp_float_vector.osl new file mode 100644 index 000000000..7a5861d0c --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_clamp_float_vector.osl @@ -0,0 +1,19 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_clamp_float_vector + [[ string help = "Vector"" Clamp incoming value to a specified range of values." ]] + ( + vector in = 0, + float low = 0.0, + float high = 1.0, + output vector out = 0 + ) +{ + out = clamp(in, low, high); +} diff --git a/materialx/libraries/stdlib/osl/mx_clamp_float_vector2.osl b/materialx/libraries/stdlib/osl/mx_clamp_float_vector2.osl new file mode 100644 index 000000000..98a7c31eb --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_clamp_float_vector2.osl @@ -0,0 +1,19 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_clamp_float_vector2 + [[ string help = "Vector2"" Clamp incoming value to a specified range of values." ]] + ( + vector2 in = {0,0}, + float low = 0.0, + float high = 1.0, + output vector2 out = {0,0} + ) +{ + out = clamp(in, low, high); +} diff --git a/materialx/libraries/stdlib/osl/mx_clamp_float_vector4.osl b/materialx/libraries/stdlib/osl/mx_clamp_float_vector4.osl new file mode 100644 index 000000000..da19f9b9c --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_clamp_float_vector4.osl @@ -0,0 +1,19 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_clamp_float_vector4 + [[ string help = "Vector4"" Clamp incoming value to a specified range of values." ]] + ( + vector4 in = {0,0,0,0}, + float low = 0.0, + float high = 1.0, + output vector4 out = {0,0,0,0} + ) +{ + out = clamp(in, low, high); +} diff --git a/materialx/libraries/stdlib/osl/mx_clamp_vector.osl b/materialx/libraries/stdlib/osl/mx_clamp_vector.osl new file mode 100644 index 000000000..b6def6d80 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_clamp_vector.osl @@ -0,0 +1,19 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_clamp_vector + [[ string help = "Vector"" Clamp incoming value to a specified range of values." ]] + ( + vector in = 0, + vector low = 0, + vector high = 1, + output vector out = 0 + ) +{ + out = clamp(in, low, high); +} diff --git a/materialx/libraries/stdlib/osl/mx_clamp_vector2.osl b/materialx/libraries/stdlib/osl/mx_clamp_vector2.osl new file mode 100644 index 000000000..7ea046ff2 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_clamp_vector2.osl @@ -0,0 +1,19 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_clamp_vector2 + [[ string help = "Vector2"" Clamp incoming value to a specified range of values." ]] + ( + vector2 in = {0,0}, + vector2 low = {0,0}, + vector2 high = {1,1}, + output vector2 out = {0,0} + ) +{ + out = clamp(in, low, high); +} diff --git a/materialx/libraries/stdlib/osl/mx_clamp_vector4.osl b/materialx/libraries/stdlib/osl/mx_clamp_vector4.osl new file mode 100644 index 000000000..5377a13c2 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_clamp_vector4.osl @@ -0,0 +1,19 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_clamp_vector4 + [[ string help = "Vector4"" Clamp incoming value to a specified range of values." ]] + ( + vector4 in = {0,0,0,0}, + vector4 low = {0,0,0,0}, + vector4 high = {1,1,1,1}, + output vector4 out = {0,0,0,0} + ) +{ + out = clamp(in, low, high); +} diff --git a/materialx/libraries/stdlib/osl/mx_combine2_vector2.osl b/materialx/libraries/stdlib/osl/mx_combine2_vector2.osl new file mode 100644 index 000000000..ca4b6680d --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_combine2_vector2.osl @@ -0,0 +1,22 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_combine_vector2 + [[ string help = "Pack the channels from two, three or four streams into the same number of channels of a \ + single stream of a specified compatible type;" ]] + ( + float in1 = 0, + float in2 = 0, + float in3 = 0, + float in4 = 0, + + output vector2 out = {0,0} + ) +{ + out = pack (in1, in2, in3, in4); +} diff --git a/materialx/libraries/stdlib/osl/mx_combine3_color.osl b/materialx/libraries/stdlib/osl/mx_combine3_color.osl new file mode 100644 index 000000000..4c2bf5c5a --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_combine3_color.osl @@ -0,0 +1,22 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_combine_color + [[ string help = "Pack the channels from two, three or four streams into the same number of channels of a \ + single stream of a specified compatible type;" ]] + ( + float in1 = 0, + float in2 = 0, + float in3 = 0, + float in4 = 0, + + output color out = 0 + ) +{ + out = pack (in1, in2, in3, in4); +} diff --git a/materialx/libraries/stdlib/osl/mx_combine3_vector.osl b/materialx/libraries/stdlib/osl/mx_combine3_vector.osl new file mode 100644 index 000000000..3c110a265 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_combine3_vector.osl @@ -0,0 +1,22 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_combine_vector + [[ string help = "Pack the channels from two, three or four streams into the same number of channels of a \ + single stream of a specified compatible type;" ]] + ( + float in1 = 0, + float in2 = 0, + float in3 = 0, + float in4 = 0, + + output vector out = 0 + ) +{ + out = pack (in1, in2, in3, in4); +} diff --git a/materialx/libraries/stdlib/osl/mx_combine4_color4.osl b/materialx/libraries/stdlib/osl/mx_combine4_color4.osl new file mode 100644 index 000000000..4352ddc9e --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_combine4_color4.osl @@ -0,0 +1,22 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_combine_color4 + [[ string help = "Pack the channels from two, three or four streams into the same number of channels of a \ + single stream of a specified compatible type;" ]] + ( + float in1 = 0, + float in2 = 0, + float in3 = 0, + float in4 = 0, + + output color4 out = {color(0,0,0), 0} + ) +{ + out = pack (in1, in2, in3, in4); +} diff --git a/materialx/libraries/stdlib/osl/mx_combine4_vector4.osl b/materialx/libraries/stdlib/osl/mx_combine4_vector4.osl new file mode 100644 index 000000000..bd2719543 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_combine4_vector4.osl @@ -0,0 +1,22 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_combine_vector4 + [[ string help = "Pack the channels from two, three or four streams into the same number of channels of a \ + single stream of a specified compatible type;" ]] + ( + float in1 = 0, + float in2 = 0, + float in3 = 0, + float in4 = 0, + + output vector4 out = {0,0,0,0} + ) +{ + out = pack (in1, in2, in3, in4); +} diff --git a/materialx/libraries/stdlib/osl/mx_combine_cf_color4.osl b/materialx/libraries/stdlib/osl/mx_combine_cf_color4.osl new file mode 100644 index 000000000..69e2d2a7b --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_combine_cf_color4.osl @@ -0,0 +1,20 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_combine_cf_color4 + [[ string help = "Combine the channels from two, three or four streams into the same number of channels of a \ + single stream of a specified compatible type;" ]] + ( + color in1 = 0, + float in2 = 0, + output color4 out = {color(0),0} + ) +{ + out.rgb = in1; + out.a = in2; +} diff --git a/materialx/libraries/stdlib/osl/mx_combine_vf_vector4.osl b/materialx/libraries/stdlib/osl/mx_combine_vf_vector4.osl new file mode 100644 index 000000000..b94885a80 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_combine_vf_vector4.osl @@ -0,0 +1,22 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_combine_vf_vector4 + [[ string help = "Combine the channels from two, three or four streams into the same number of channels of a \ + single stream of a specified compatible type;" ]] + ( + vector in1 = 0, + float in2 = 0, + output vector4 out = {0,0,0,0} + ) +{ + out.x = in1[0]; + out.y = in1[1]; + out.z = in1[2]; + out.w = in2; +} diff --git a/materialx/libraries/stdlib/osl/mx_combine_vv_vector4.osl b/materialx/libraries/stdlib/osl/mx_combine_vv_vector4.osl new file mode 100644 index 000000000..3eefb14cc --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_combine_vv_vector4.osl @@ -0,0 +1,22 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_combine_vv_vector4 + [[ string help = "Combine the channels from two, three or four streams into the same number of channels of a \ + single stream of a specified compatible type;" ]] + ( + vector2 in1 = {0,0}, + vector2 in2 = {0.0}, + output vector4 out = {0,0,0,0} + ) +{ + out.x = in1.x; + out.y = in1.y; + out.z = in2.x; + out.w = in2.y; +} diff --git a/materialx/libraries/stdlib/osl/mx_compare_color.osl b/materialx/libraries/stdlib/osl/mx_compare_color.osl new file mode 100644 index 000000000..152a67588 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_compare_color.osl @@ -0,0 +1,26 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_compare_color + [[ string help = "Test the value of an incoming float selector stream against a specified cutoff value, \ + then pass the value of one of two other incoming streams depending on whether the selector stream \ + value is greater than the fixed cutoff value." ]] + ( + float intest = 0.0, + color in1 = 1, + color in2 = 0, + float cutoff = 0.0, + output color out = 0 + ) +{ + if (intest > cutoff) { + out = in2; + } else { + out = in1; + } +} diff --git a/materialx/libraries/stdlib/osl/mx_compare_color4.osl b/materialx/libraries/stdlib/osl/mx_compare_color4.osl new file mode 100644 index 000000000..29e3579bd --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_compare_color4.osl @@ -0,0 +1,26 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_compare_color4 + [[ string help = "Test the value of an incoming float selector stream against a specified cutoff value, \ + then pass the value of one of two other incoming streams depending on whether the selector stream \ + value is greater than the fixed cutoff value." ]] + ( + float intest = 0.0, + color4 in1 = {color(1,1,1), 1}, + color4 in2 = {color(0,0,0), 0}, + float cutoff = 0.0, + output color4 out = {color(0,0,0), 0} + ) +{ + if (intest > cutoff) { + out = in2; + } else { + out = in1; + } +} diff --git a/materialx/libraries/stdlib/osl/mx_compare_float.osl b/materialx/libraries/stdlib/osl/mx_compare_float.osl new file mode 100644 index 000000000..127244ab8 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_compare_float.osl @@ -0,0 +1,26 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_compare_float + [[ string help = "Test the value of an incoming float selector stream against a specified cutoff value, \ + then pass the value of one of two other incoming streams depending on whether the selector stream \ + value is greater than the fixed cutoff value." ]] + ( + float intest = 0.0, + float in1 = 1, + float in2 = 0, + float cutoff = 0.0, + output float out = 0 + ) +{ + if (intest > cutoff) { + out = in2; + } else { + out = in1; + } +} diff --git a/materialx/libraries/stdlib/osl/mx_compare_vector.osl b/materialx/libraries/stdlib/osl/mx_compare_vector.osl new file mode 100644 index 000000000..8428b1fc8 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_compare_vector.osl @@ -0,0 +1,26 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_compare_vector + [[ string help = "Test the value of an incoming float selector stream against a specified cutoff value, \ + then pass the value of one of two other incoming streams depending on whether the selector stream \ + value is greater than the fixed cutoff value." ]] + ( + float intest = 0.0, + vector in1 = 1, + vector in2 = 0, + float cutoff = 0.0, + output vector out = 0 + ) +{ + if (intest > cutoff) { + out = in2; + } else { + out = in1; + } +} diff --git a/materialx/libraries/stdlib/osl/mx_compare_vector2.osl b/materialx/libraries/stdlib/osl/mx_compare_vector2.osl new file mode 100644 index 000000000..07668fe06 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_compare_vector2.osl @@ -0,0 +1,26 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_compare_vector2 + [[ string help = "Test the value of an incoming float selector stream against a specified cutoff value, \ + then pass the value of one of two other incoming streams depending on whether the selector stream \ + value is greater than the fixed cutoff value." ]] + ( + float intest = 0.0, + vector2 in1 = {1,1}, + vector2 in2 = {0,0}, + float cutoff = 0.0, + output vector2 out = {0,0} + ) +{ + if (intest > cutoff) { + out = in2; + } else { + out = in1; + } +} diff --git a/materialx/libraries/stdlib/osl/mx_compare_vector4.osl b/materialx/libraries/stdlib/osl/mx_compare_vector4.osl new file mode 100644 index 000000000..83295cabe --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_compare_vector4.osl @@ -0,0 +1,26 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_compare_vector4 + [[ string help = "Test the value of an incoming float selector stream against a specified cutoff value, \ + then pass the value of one of two other incoming streams depending on whether the selector stream \ + value is greater than the fixed cutoff value." ]] + ( + float intest = 0.0, + vector4 in1 = {1,1,1,1}, + vector4 in2 = {0,0,0,0}, + float cutoff = 0.0, + output vector4 out = {0,0,0,0} + ) +{ + if (intest > cutoff) { + out = in2; + } else { + out = in1; + } +} diff --git a/materialx/libraries/stdlib/osl/mx_constant_bool.osl b/materialx/libraries/stdlib/osl/mx_constant_bool.osl new file mode 100644 index 000000000..b65bf5f12 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_constant_bool.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_constant_bool + [[ string help = "constant source" ]] + ( + int value = 0, + output int out = 0 + ) +{ + out = value; +} diff --git a/materialx/libraries/stdlib/osl/mx_constant_color.osl b/materialx/libraries/stdlib/osl/mx_constant_color.osl new file mode 100644 index 000000000..5e60f77fa --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_constant_color.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_constant_color + [[ string help = "constant source" ]] + ( + color value = 0, + output color out = 0 + ) +{ + out = value; +} diff --git a/materialx/libraries/stdlib/osl/mx_constant_color4.osl b/materialx/libraries/stdlib/osl/mx_constant_color4.osl new file mode 100644 index 000000000..56f234d35 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_constant_color4.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_constant_color4 + [[ string help = "constant source" ]] + ( + color4 value = {color(0,0,0), 0}, + output color4 out = {color(0,0,0), 0} + ) +{ + out = value; +} diff --git a/materialx/libraries/stdlib/osl/mx_constant_filename.osl b/materialx/libraries/stdlib/osl/mx_constant_filename.osl new file mode 100644 index 000000000..3ab4d90eb --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_constant_filename.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_constant_filename + [[ string help = "constant source" ]] + ( + string value = "default", + output string out = "default" + ) +{ + out = value; +} diff --git a/materialx/libraries/stdlib/osl/mx_constant_float.osl b/materialx/libraries/stdlib/osl/mx_constant_float.osl new file mode 100644 index 000000000..cd45ef4df --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_constant_float.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_constant_float + [[ string help = "constant source" ]] + ( + float value = 0, + output float out = 0 + ) +{ + out = value; +} diff --git a/materialx/libraries/stdlib/osl/mx_constant_int.osl b/materialx/libraries/stdlib/osl/mx_constant_int.osl new file mode 100644 index 000000000..62497a6e5 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_constant_int.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_constant_int + [[ string help = "constant source" ]] + ( + int value = 0, + output int out = 0 + ) +{ + out = value; +} diff --git a/materialx/libraries/stdlib/osl/mx_constant_matrix33.osl b/materialx/libraries/stdlib/osl/mx_constant_matrix33.osl new file mode 100644 index 000000000..b9e79a68c --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_constant_matrix33.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_constant_matrix33 + [[ string help = "constant source" ]] + ( + matrix value = matrix(0), + output matrix out = matrix(0) + ) +{ + out = value; +} diff --git a/materialx/libraries/stdlib/osl/mx_constant_matrix44.osl b/materialx/libraries/stdlib/osl/mx_constant_matrix44.osl new file mode 100644 index 000000000..4528a9b8b --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_constant_matrix44.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_constant_matrix44 + [[ string help = "constant source" ]] + ( + matrix value = matrix(0), + output matrix out = matrix(0) + ) +{ + out = value; +} diff --git a/materialx/libraries/stdlib/osl/mx_constant_string.osl b/materialx/libraries/stdlib/osl/mx_constant_string.osl new file mode 100644 index 000000000..ea7410e80 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_constant_string.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_constant_string + [[ string help = "constant source" ]] + ( + string value = "default", + output string out = "default" + ) +{ + out = value; +} diff --git a/materialx/libraries/stdlib/osl/mx_constant_vector.osl b/materialx/libraries/stdlib/osl/mx_constant_vector.osl new file mode 100644 index 000000000..83394399d --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_constant_vector.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_constant_vector + [[ string help = "constant source" ]] + ( + vector value = 0, + output vector out = 0 + ) +{ + out = value; +} diff --git a/materialx/libraries/stdlib/osl/mx_constant_vector2.osl b/materialx/libraries/stdlib/osl/mx_constant_vector2.osl new file mode 100644 index 000000000..f232e5707 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_constant_vector2.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_constant_vector2 + [[ string help = "constant source" ]] + ( + vector2 value = {0,0}, + output vector2 out = {0,0} + ) +{ + out = value; +} diff --git a/materialx/libraries/stdlib/osl/mx_constant_vector4.osl b/materialx/libraries/stdlib/osl/mx_constant_vector4.osl new file mode 100644 index 000000000..6b449bc67 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_constant_vector4.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_constant_vector4 + [[ string help = "constant source" ]] + ( + vector4 value = {0,0,0,0}, + output vector4 out = {0,0,0,0} + ) +{ + out = value; +} diff --git a/materialx/libraries/stdlib/osl/mx_cos_color.osl b/materialx/libraries/stdlib/osl/mx_cos_color.osl new file mode 100644 index 000000000..0cbbe867f --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_cos_color.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_cos_color + [[ string help = "Color"" cos(in)" ]] + ( + color in = 0, + output color out = 0 + ) +{ + out = cos(in); +} diff --git a/materialx/libraries/stdlib/osl/mx_cos_color4.osl b/materialx/libraries/stdlib/osl/mx_cos_color4.osl new file mode 100644 index 000000000..ca7bd0eb3 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_cos_color4.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_cos_color4 + [[ string help = "Color4"" cos(in)" ]] + ( + color4 in = {color(0,0,0), 0}, + output color4 out = {color(0,0,0), 0} + ) +{ + out = cos(in); +} diff --git a/materialx/libraries/stdlib/osl/mx_cos_float.osl b/materialx/libraries/stdlib/osl/mx_cos_float.osl new file mode 100644 index 000000000..beef8e91b --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_cos_float.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_cos_float + [[ string help = "Float"" cos(in)" ]] + ( + float in = 0, + output float out = 0 + ) +{ + out = cos(in); +} diff --git a/materialx/libraries/stdlib/osl/mx_cos_vector.osl b/materialx/libraries/stdlib/osl/mx_cos_vector.osl new file mode 100644 index 000000000..0d07f991a --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_cos_vector.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_cos_vector + [[ string help = "Vector"" cos(in)" ]] + ( + vector in = 0, + output vector out = 0 + ) +{ + out = cos(in); +} diff --git a/materialx/libraries/stdlib/osl/mx_cos_vector2.osl b/materialx/libraries/stdlib/osl/mx_cos_vector2.osl new file mode 100644 index 000000000..a7cd82b14 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_cos_vector2.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_cos_vector2 + [[ string help = "Vector2"" cos(in)" ]] + ( + vector2 in = {0,0}, + output vector2 out = {0,0} + ) +{ + out = cos(in); +} diff --git a/materialx/libraries/stdlib/osl/mx_cos_vector4.osl b/materialx/libraries/stdlib/osl/mx_cos_vector4.osl new file mode 100644 index 000000000..6f844d3ca --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_cos_vector4.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_cos_vector4 + [[ string help = "Vector4"" cos(in)" ]] + ( + vector4 in = {0,0,0,0}, + output vector4 out = {0,0,0,0} + ) +{ + out = cos(in); +} diff --git a/materialx/libraries/stdlib/osl/mx_crossproduct_vector.osl b/materialx/libraries/stdlib/osl/mx_crossproduct_vector.osl new file mode 100644 index 000000000..5bf4c85d7 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_crossproduct_vector.osl @@ -0,0 +1,18 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_crossproduct_vector + [[ string help = "Perform a cross product of two vectors" ]] + ( + vector in1 = 0, + vector in2 = 0, + output vector out = 0 + ) +{ + out = cross(in1, in2); +} diff --git a/materialx/libraries/stdlib/osl/mx_determinant_matrix33.osl b/materialx/libraries/stdlib/osl/mx_determinant_matrix33.osl new file mode 100644 index 000000000..3342253bf --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_determinant_matrix33.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_determinant_matrix33 + [[ string help = "Matrix33"" the determinant of matrix in" ]] + ( + matrix in = matrix(0), + output float out = 0 + ) +{ + out = determinant(in); +} diff --git a/materialx/libraries/stdlib/osl/mx_determinant_matrix44.osl b/materialx/libraries/stdlib/osl/mx_determinant_matrix44.osl new file mode 100644 index 000000000..a192f83bd --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_determinant_matrix44.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_determinant_matrix44 + [[ string help = "Matrix44"" the determinant of matrix in" ]] + ( + matrix in = matrix(0), + output float out = 0 + ) +{ + out = determinant(in); +} diff --git a/materialx/libraries/stdlib/osl/mx_disjointover_color4.osl b/materialx/libraries/stdlib/osl/mx_disjointover_color4.osl new file mode 100644 index 000000000..4f03361a5 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_disjointover_color4.osl @@ -0,0 +1,38 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + + +color4 disjointover(color4 fg, color4 bg) +{ + float summedAlpha = fg.a + bg.a; + + color4 out; + if (summedAlpha <= 1) { + out.rgb = fg.rgb + bg.rgb; + } else { + float x = (1 - fg.a) / bg.a; + out.rgb = fg.rgb + bg.rgb * x; + } + + out.a = min(summedAlpha, 1); + return out; +} + + + +shader mx_disjointover_color4 + [[ string help = "Color4"" Take two color4 inputs and use the built-in alpha \ + channel(s) to control the compositing of the fg and bg inputs" ]] + ( + color4 fg = {color(0,0,0), 0}, + color4 bg = {color(0,0,0), 0}, + output color4 out = {color(0,0,0), 0} + ) +{ + out = disjointover(fg, bg); +} diff --git a/materialx/libraries/stdlib/osl/mx_divide_color.osl b/materialx/libraries/stdlib/osl/mx_divide_color.osl new file mode 100644 index 000000000..77b201e78 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_divide_color.osl @@ -0,0 +1,18 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_divide_color + [[ string help = "Color"" divide an incoming float/color/vector by in2" ]] + ( + color in1 = 0, + color in2 = 1, + output color out = 0 + ) +{ + out = in1 / in2; +} diff --git a/materialx/libraries/stdlib/osl/mx_divide_color4.osl b/materialx/libraries/stdlib/osl/mx_divide_color4.osl new file mode 100644 index 000000000..ee4bf3ac3 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_divide_color4.osl @@ -0,0 +1,18 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_divide_color4 + [[ string help = "Color4"" divide an incoming float/color/vector by in2" ]] + ( + color4 in1 = {color(0,0,0), 0}, + color4 in2 = {color(1,1,1), 1}, + output color4 out = {color(0,0,0), 0} + ) +{ + out = in1 / in2; +} diff --git a/materialx/libraries/stdlib/osl/mx_divide_float.osl b/materialx/libraries/stdlib/osl/mx_divide_float.osl new file mode 100644 index 000000000..fc8e5bd9e --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_divide_float.osl @@ -0,0 +1,18 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_divide_float + [[ string help = "Float"" divide an incoming float/color/vector by in2" ]] + ( + float in1 = 0, + float in2 = 1, + output float out = 0 + ) +{ + out = in1 / in2; +} diff --git a/materialx/libraries/stdlib/osl/mx_divide_float_color.osl b/materialx/libraries/stdlib/osl/mx_divide_float_color.osl new file mode 100644 index 000000000..902f41d8b --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_divide_float_color.osl @@ -0,0 +1,18 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_divide_float_color + [[ string help = "Color"" Divide an incoming float/color/vector by the in2" ]] + ( + color in1 = 0, + float in2 = 1.0, + output color out = 0 + ) +{ + out = in1 / in2; +} diff --git a/materialx/libraries/stdlib/osl/mx_divide_float_color4.osl b/materialx/libraries/stdlib/osl/mx_divide_float_color4.osl new file mode 100644 index 000000000..710a20d71 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_divide_float_color4.osl @@ -0,0 +1,18 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_divide_float_color4 + [[ string help = "Color4"" Divide an incoming float/color/vector by the in2" ]] + ( + color4 in1 = {color(0,0,0), 0}, + float in2 = 1.0, + output color4 out = {color(0,0,0), 0} + ) +{ + out = in1 / in2; +} diff --git a/materialx/libraries/stdlib/osl/mx_divide_float_matrix33.osl b/materialx/libraries/stdlib/osl/mx_divide_float_matrix33.osl new file mode 100644 index 000000000..6742de36b --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_divide_float_matrix33.osl @@ -0,0 +1,18 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_divide_float_matrix33 + [[ string help = "Matrix33"" Divide an incoming float/color/vector by the in2" ]] + ( + matrix in1 = matrix(0), + float in2 = 1.0, + output matrix out = matrix(0) + ) +{ + out = in1 / in2; +} diff --git a/materialx/libraries/stdlib/osl/mx_divide_float_matrix44.osl b/materialx/libraries/stdlib/osl/mx_divide_float_matrix44.osl new file mode 100644 index 000000000..14be008fd --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_divide_float_matrix44.osl @@ -0,0 +1,18 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_divide_float_matrix44 + [[ string help = "Matrix44"" Divide an incoming float/color/vector by the in2" ]] + ( + matrix in1 = matrix(0), + float in2 = 1.0, + output matrix out = matrix(0) + ) +{ + out = in1 / in2; +} diff --git a/materialx/libraries/stdlib/osl/mx_divide_float_vector.osl b/materialx/libraries/stdlib/osl/mx_divide_float_vector.osl new file mode 100644 index 000000000..dc3101919 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_divide_float_vector.osl @@ -0,0 +1,18 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_divide_float_vector + [[ string help = "Vector"" Divide an incoming float/color/vector by the in2" ]] + ( + vector in1 = 0, + float in2 = 1.0, + output vector out = 0 + ) +{ + out = in1 / in2; +} diff --git a/materialx/libraries/stdlib/osl/mx_divide_float_vector2.osl b/materialx/libraries/stdlib/osl/mx_divide_float_vector2.osl new file mode 100644 index 000000000..b5599ea07 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_divide_float_vector2.osl @@ -0,0 +1,18 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_divide_float_vector2 + [[ string help = "Vector2"" Divide an incoming float/color/vector by the in2" ]] + ( + vector2 in1 = {0,0}, + float in2 = 1.0, + output vector2 out = {0,0} + ) +{ + out = in1 / in2; +} diff --git a/materialx/libraries/stdlib/osl/mx_divide_float_vector4.osl b/materialx/libraries/stdlib/osl/mx_divide_float_vector4.osl new file mode 100644 index 000000000..354541ac5 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_divide_float_vector4.osl @@ -0,0 +1,18 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_divide_float_vector4 + [[ string help = "Vector4"" Divide an incoming float/color/vector by the in2" ]] + ( + vector4 in1 = {0,0,0,0}, + float in2 = 1.0, + output vector4 out = {0,0,0,0} + ) +{ + out = in1 / in2; +} diff --git a/materialx/libraries/stdlib/osl/mx_divide_matrix33.osl b/materialx/libraries/stdlib/osl/mx_divide_matrix33.osl new file mode 100644 index 000000000..0828c543b --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_divide_matrix33.osl @@ -0,0 +1,18 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_divide_matrix33 + [[ string help = "Matrix33"" divide an incoming float/color/vector by in2" ]] + ( + matrix in1 = matrix(0), + matrix in2 = matrix(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,0), + output matrix out = matrix(0) + ) +{ + out = in1 / in2; +} diff --git a/materialx/libraries/stdlib/osl/mx_divide_matrix44.osl b/materialx/libraries/stdlib/osl/mx_divide_matrix44.osl new file mode 100644 index 000000000..97a883a0d --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_divide_matrix44.osl @@ -0,0 +1,18 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_divide_matrix44 + [[ string help = "Matrix44"" divide an incoming float/color/vector by in2" ]] + ( + matrix in1 = matrix(0), + matrix in2 = matrix(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1), + output matrix out = matrix(0) + ) +{ + out = in1 / in2; +} diff --git a/materialx/libraries/stdlib/osl/mx_divide_vector.osl b/materialx/libraries/stdlib/osl/mx_divide_vector.osl new file mode 100644 index 000000000..d3d3d14d4 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_divide_vector.osl @@ -0,0 +1,18 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_divide_vector + [[ string help = "Vector"" divide an incoming float/color/vector by in2" ]] + ( + vector in1 = 0, + vector in2 = 1, + output vector out = 0 + ) +{ + out = in1 / in2; +} diff --git a/materialx/libraries/stdlib/osl/mx_divide_vector2.osl b/materialx/libraries/stdlib/osl/mx_divide_vector2.osl new file mode 100644 index 000000000..400c15908 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_divide_vector2.osl @@ -0,0 +1,18 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_divide_vector2 + [[ string help = "Vector2"" divide an incoming float/color/vector by in2" ]] + ( + vector2 in1 = {0,0}, + vector2 in2 = {1,1}, + output vector2 out = {0,0} + ) +{ + out = in1 / in2; +} diff --git a/materialx/libraries/stdlib/osl/mx_divide_vector4.osl b/materialx/libraries/stdlib/osl/mx_divide_vector4.osl new file mode 100644 index 000000000..f096df371 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_divide_vector4.osl @@ -0,0 +1,18 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_divide_vector4 + [[ string help = "Vector4"" divide an incoming float/color/vector by in2" ]] + ( + vector4 in1 = {0,0,0,0}, + vector4 in2 = {1,1,1,1}, + output vector4 out = {0,0,0,0} + ) +{ + out = in1 / in2; +} diff --git a/materialx/libraries/stdlib/osl/mx_dodge_color.osl b/materialx/libraries/stdlib/osl/mx_dodge_color.osl new file mode 100644 index 000000000..ca483e003 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_dodge_color.osl @@ -0,0 +1,18 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_dodge_color + [[ string help = "Color"" Take two 1-4 channel inputs and apply the same operator to all channels: B/(1-F)" ]] + ( + color fg = 0, + color bg = 0, + output color out = 0 + ) +{ + out = bg / (1 - fg); +} diff --git a/materialx/libraries/stdlib/osl/mx_dodge_color4.osl b/materialx/libraries/stdlib/osl/mx_dodge_color4.osl new file mode 100644 index 000000000..45c555c67 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_dodge_color4.osl @@ -0,0 +1,18 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_dodge_color4 + [[ string help = "Color4"" Take two 1-4 channel inputs and apply the same operator to all channels: B/(1-F)" ]] + ( + color4 fg = {color(0,0,0), 0}, + color4 bg = {color(0,0,0), 0}, + output color4 out = {color(0,0,0), 0} + ) +{ + out = bg / (1 - fg); +} diff --git a/materialx/libraries/stdlib/osl/mx_dodge_float.osl b/materialx/libraries/stdlib/osl/mx_dodge_float.osl new file mode 100644 index 000000000..dcbc03e6e --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_dodge_float.osl @@ -0,0 +1,18 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_dodge_float + [[ string help = "Float"" Take two 1-4 channel inputs and apply the same operator to all channels: B/(1-F)" ]] + ( + float fg = 0, + float bg = 0, + output float out = 0 + ) +{ + out = bg / (1 - fg); +} diff --git a/materialx/libraries/stdlib/osl/mx_dot_bool.osl b/materialx/libraries/stdlib/osl/mx_dot_bool.osl new file mode 100644 index 000000000..e1cc0395b --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_dot_bool.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_dot_bool + [[ string help = "bool"" no-op " ]] + ( + int in = 0, + output int out = 0 + ) +{ + out = in; +} diff --git a/materialx/libraries/stdlib/osl/mx_dot_color.osl b/materialx/libraries/stdlib/osl/mx_dot_color.osl new file mode 100644 index 000000000..fda9105c1 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_dot_color.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_dot_color + [[ string help = "Color"" no-op " ]] + ( + color in = 0, + output color out = 0 + ) +{ + out = in; +} diff --git a/materialx/libraries/stdlib/osl/mx_dot_color4.osl b/materialx/libraries/stdlib/osl/mx_dot_color4.osl new file mode 100644 index 000000000..c73adc2bf --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_dot_color4.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_dot_color4 + [[ string help = "Color4"" no-op " ]] + ( + color4 in = {color(0,0,0), 0}, + output color4 out = {color(0,0,0), 0} + ) +{ + out = in; +} diff --git a/materialx/libraries/stdlib/osl/mx_dot_displacementshader.osl b/materialx/libraries/stdlib/osl/mx_dot_displacementshader.osl new file mode 100644 index 000000000..af21e6ccb --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_dot_displacementshader.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_dot_displacementshader + [[ string help = "displacementshader"" no-op " ]] + ( + displacement color in = 0, + output displacement color out = 0 + ) +{ + out = in; +} diff --git a/materialx/libraries/stdlib/osl/mx_dot_filename.osl b/materialx/libraries/stdlib/osl/mx_dot_filename.osl new file mode 100644 index 000000000..74612e87a --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_dot_filename.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_dot_filename + [[ string help = "filename"" no-op " ]] + ( + string in = "default", + output string out = "default" + ) +{ + out = in; +} diff --git a/materialx/libraries/stdlib/osl/mx_dot_float.osl b/materialx/libraries/stdlib/osl/mx_dot_float.osl new file mode 100644 index 000000000..d34d24769 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_dot_float.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_dot_float + [[ string help = "Float"" no-op " ]] + ( + float in = 0, + output float out = 0 + ) +{ + out = in; +} diff --git a/materialx/libraries/stdlib/osl/mx_dot_int.osl b/materialx/libraries/stdlib/osl/mx_dot_int.osl new file mode 100644 index 000000000..daac147de --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_dot_int.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_dot_int + [[ string help = "int"" no-op " ]] + ( + int in = 0, + output int out = 0 + ) +{ + out = in; +} diff --git a/materialx/libraries/stdlib/osl/mx_dot_lightshader.osl b/materialx/libraries/stdlib/osl/mx_dot_lightshader.osl new file mode 100644 index 000000000..975d742ab --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_dot_lightshader.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_dot_lightshader + [[ string help = "lightshader"" no-op " ]] + ( + color in = 0, + output color out = 0 + ) +{ + out = in; +} diff --git a/materialx/libraries/stdlib/osl/mx_dot_matrix33.osl b/materialx/libraries/stdlib/osl/mx_dot_matrix33.osl new file mode 100644 index 000000000..015430dac --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_dot_matrix33.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_dot_matrix33 + [[ string help = "Matrix33"" no-op " ]] + ( + matrix in = matrix(0), + output matrix out = matrix(0) + ) +{ + out = in; +} diff --git a/materialx/libraries/stdlib/osl/mx_dot_matrix44.osl b/materialx/libraries/stdlib/osl/mx_dot_matrix44.osl new file mode 100644 index 000000000..fbba7b3e8 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_dot_matrix44.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_dot_matrix44 + [[ string help = "Matrix44"" no-op " ]] + ( + matrix in = matrix(0), + output matrix out = matrix(0) + ) +{ + out = in; +} diff --git a/materialx/libraries/stdlib/osl/mx_dot_string.osl b/materialx/libraries/stdlib/osl/mx_dot_string.osl new file mode 100644 index 000000000..1ec01b4d0 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_dot_string.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_dot_string + [[ string help = "string"" no-op " ]] + ( + string in = "default", + output string out = "default" + ) +{ + out = in; +} diff --git a/materialx/libraries/stdlib/osl/mx_dot_surfaceshader.osl b/materialx/libraries/stdlib/osl/mx_dot_surfaceshader.osl new file mode 100644 index 000000000..98e520449 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_dot_surfaceshader.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_dot_surfaceshader + [[ string help = "surfaceshader"" no-op " ]] + ( + closure color in = 0, + output closure color out = 0 + ) +{ + out = in; +} diff --git a/materialx/libraries/stdlib/osl/mx_dot_vector.osl b/materialx/libraries/stdlib/osl/mx_dot_vector.osl new file mode 100644 index 000000000..29b2ff486 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_dot_vector.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_dot_vector + [[ string help = "Vector"" no-op " ]] + ( + vector in = 0, + output vector out = 0 + ) +{ + out = in; +} diff --git a/materialx/libraries/stdlib/osl/mx_dot_vector2.osl b/materialx/libraries/stdlib/osl/mx_dot_vector2.osl new file mode 100644 index 000000000..1699b353c --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_dot_vector2.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_dot_vector2 + [[ string help = "Vector2"" no-op " ]] + ( + vector2 in = {0,0}, + output vector2 out = {0,0} + ) +{ + out = in; +} diff --git a/materialx/libraries/stdlib/osl/mx_dot_vector4.osl b/materialx/libraries/stdlib/osl/mx_dot_vector4.osl new file mode 100644 index 000000000..96f6ed891 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_dot_vector4.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_dot_vector4 + [[ string help = "Vector4"" no-op " ]] + ( + vector4 in = {0,0,0,0}, + output vector4 out = {0,0,0,0} + ) +{ + out = in; +} diff --git a/materialx/libraries/stdlib/osl/mx_dot_volumeshader.osl b/materialx/libraries/stdlib/osl/mx_dot_volumeshader.osl new file mode 100644 index 000000000..6e89c7b9a --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_dot_volumeshader.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_dot_volumeshader + [[ string help = "volumeshader"" no-op " ]] + ( + closure color in = 0, + output closure color out = 0 + ) +{ + out = in; +} diff --git a/materialx/libraries/stdlib/osl/mx_dotproduct_vector.osl b/materialx/libraries/stdlib/osl/mx_dotproduct_vector.osl new file mode 100644 index 000000000..d9dd0f344 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_dotproduct_vector.osl @@ -0,0 +1,18 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_dotproduct_vector + [[ string help = "Vector"" Perform a dot product of two 2-4 channel vectors" ]] + ( + vector in1 = 0, + vector in2 = 0, + output float out = 0 + ) +{ + out = dot(in1, in2); +} diff --git a/materialx/libraries/stdlib/osl/mx_dotproduct_vector2.osl b/materialx/libraries/stdlib/osl/mx_dotproduct_vector2.osl new file mode 100644 index 000000000..3321346ac --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_dotproduct_vector2.osl @@ -0,0 +1,18 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_dotproduct_vector2 + [[ string help = "Vector2"" Perform a dot product of two 2-4 channel vectors" ]] + ( + vector2 in1 = {0,0}, + vector2 in2 = {0,0}, + output float out = 0 + ) +{ + out = dot(in1, in2); +} diff --git a/materialx/libraries/stdlib/osl/mx_dotproduct_vector4.osl b/materialx/libraries/stdlib/osl/mx_dotproduct_vector4.osl new file mode 100644 index 000000000..233965688 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_dotproduct_vector4.osl @@ -0,0 +1,18 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_dotproduct_vector4 + [[ string help = "Vector4"" Perform a dot product of two 2-4 channel vectors" ]] + ( + vector4 in1 = {0,0,0,0}, + vector4 in2 = {0,0,0,0}, + output float out = 0 + ) +{ + out = dot(in1, in2); +} diff --git a/materialx/libraries/stdlib/osl/mx_exp_color.osl b/materialx/libraries/stdlib/osl/mx_exp_color.osl new file mode 100644 index 000000000..e6d080adb --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_exp_color.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader exp_color + [[ string help = "Color"" e(in)" ]] + ( + color in = 0, + output color out = 0 + ) +{ + out = exp(in); +} diff --git a/materialx/libraries/stdlib/osl/mx_exp_color4.osl b/materialx/libraries/stdlib/osl/mx_exp_color4.osl new file mode 100644 index 000000000..8c7d9c3b4 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_exp_color4.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader exp_color4 + [[ string help = "Color4"" e(in)" ]] + ( + color4 in = {color(0,0,0), 0}, + output color4 out = {color(0,0,0), 0} + ) +{ + out = exp(in); +} diff --git a/materialx/libraries/stdlib/osl/mx_exp_float.osl b/materialx/libraries/stdlib/osl/mx_exp_float.osl new file mode 100644 index 000000000..67134e848 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_exp_float.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader exp_float + [[ string help = "Float"" e(in)" ]] + ( + float in = 0, + output float out = 0 + ) +{ + out = exp(in); +} diff --git a/materialx/libraries/stdlib/osl/mx_exp_vector.osl b/materialx/libraries/stdlib/osl/mx_exp_vector.osl new file mode 100644 index 000000000..a4cee41b8 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_exp_vector.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader exp_vector + [[ string help = "Vector"" e(in)" ]] + ( + vector in = 0, + output vector out = 0 + ) +{ + out = exp(in); +} diff --git a/materialx/libraries/stdlib/osl/mx_exp_vector2.osl b/materialx/libraries/stdlib/osl/mx_exp_vector2.osl new file mode 100644 index 000000000..12445e01f --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_exp_vector2.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader exp_vector2 + [[ string help = "Vector2"" e(in)" ]] + ( + vector2 in = {0,0}, + output vector2 out = {0,0} + ) +{ + out = exp(in); +} diff --git a/materialx/libraries/stdlib/osl/mx_exp_vector4.osl b/materialx/libraries/stdlib/osl/mx_exp_vector4.osl new file mode 100644 index 000000000..64f6e8f51 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_exp_vector4.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader exp_vector4 + [[ string help = "Vector4"" e(in)" ]] + ( + vector4 in = {0,0,0,0}, + output vector4 out = {0,0,0,0} + ) +{ + out = exp(in); +} diff --git a/materialx/libraries/stdlib/osl/mx_exponent_float.osl b/materialx/libraries/stdlib/osl/mx_exponent_float.osl new file mode 100644 index 000000000..2be5a5695 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_exponent_float.osl @@ -0,0 +1,18 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_exponent_float + [[ string help = "Float"" Raise incoming float/color/vector values to the in2 exponent value/stream" ]] + ( + float in1 = 0, + float in2 = 1, + output float out = 0 + ) +{ + out = pow(in1, in2); +} diff --git a/materialx/libraries/stdlib/osl/mx_exponent_vector.osl b/materialx/libraries/stdlib/osl/mx_exponent_vector.osl new file mode 100644 index 000000000..0dab52b5f --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_exponent_vector.osl @@ -0,0 +1,18 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_exponent_vector + [[ string help = "Vector"" Raise incoming float/color/vector values to the in2 exponent value/stream" ]] + ( + vector in1 = 0, + vector in2 = 1, + output vector out = 0 + ) +{ + out = pow(in1, in2); +} diff --git a/materialx/libraries/stdlib/osl/mx_exponent_vector2.osl b/materialx/libraries/stdlib/osl/mx_exponent_vector2.osl new file mode 100644 index 000000000..989dc4816 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_exponent_vector2.osl @@ -0,0 +1,18 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_exponent_vector2 + [[ string help = "Vector2"" Raise incoming float/color/vector values to the in2 exponent value/stream" ]] + ( + vector2 in1 = {0,0}, + vector2 in2 = {1,1}, + output vector2 out = {0,0} + ) +{ + out = pow(in1, in2); +} diff --git a/materialx/libraries/stdlib/osl/mx_exponent_vector4.osl b/materialx/libraries/stdlib/osl/mx_exponent_vector4.osl new file mode 100644 index 000000000..b0eff2390 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_exponent_vector4.osl @@ -0,0 +1,18 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_exponent_vector4 + [[ string help = "Vector4"" Raise incoming float/color/vector values to the in2 exponent value/stream" ]] + ( + vector4 in1 = {0,0,0,0}, + vector4 in2 = {1,1,1,1}, + output vector4 out = {0,0,0,0} + ) +{ + out = pow(in1, in2); +} diff --git a/materialx/libraries/stdlib/osl/mx_extract_color.osl b/materialx/libraries/stdlib/osl/mx_extract_color.osl new file mode 100644 index 000000000..7bec93da8 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_extract_color.osl @@ -0,0 +1,19 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + + +shader mx_extract_color + [[ string help = "Generate a float from an aggregate (vector, color, etc.)" ]] + ( + color in = 0, + int index = 0, + output float out = 0 + ) +{ + out = extract (in, index); +} diff --git a/materialx/libraries/stdlib/osl/mx_extract_color4.osl b/materialx/libraries/stdlib/osl/mx_extract_color4.osl new file mode 100644 index 000000000..73b4aae44 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_extract_color4.osl @@ -0,0 +1,19 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + + +shader mx_extract_color4 + [[ string help = "Generate a float from an aggregate (vector, color, etc.)" ]] + ( + color4 in = {color(0,0,0), 0}, + int index = 0, + output float out = 0 + ) +{ + out = extract (in, index); +} diff --git a/materialx/libraries/stdlib/osl/mx_extract_vector.osl b/materialx/libraries/stdlib/osl/mx_extract_vector.osl new file mode 100644 index 000000000..635f8e825 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_extract_vector.osl @@ -0,0 +1,19 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + + +shader mx_extract_vector + [[ string help = "Generate a float from an aggregate (vector, color, etc.)" ]] + ( + vector in = 0, + int index = 0, + output float out = 0 + ) +{ + out = extract (in, index); +} diff --git a/materialx/libraries/stdlib/osl/mx_extract_vector2.osl b/materialx/libraries/stdlib/osl/mx_extract_vector2.osl new file mode 100644 index 000000000..d70ad4c7f --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_extract_vector2.osl @@ -0,0 +1,19 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + + +shader mx_extract_vector2 + [[ string help = "Generate a float from an aggregate (vector, color, etc.)" ]] + ( + vector2 in = {0,0}, + int index = 0, + output float out = 0 + ) +{ + out = extract (in, index); +} diff --git a/materialx/libraries/stdlib/osl/mx_extract_vector4.osl b/materialx/libraries/stdlib/osl/mx_extract_vector4.osl new file mode 100644 index 000000000..d345cc609 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_extract_vector4.osl @@ -0,0 +1,19 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + + +shader mx_extract_vector4 + [[ string help = "Generate a float from an aggregate (vector, color, etc.)" ]] + ( + vector4 in = {0,0,0,0}, + int index = 0, + output float out = 0 + ) +{ + out = extract (in, index); +} diff --git a/materialx/libraries/stdlib/osl/mx_floor_color.osl b/materialx/libraries/stdlib/osl/mx_floor_color.osl new file mode 100644 index 000000000..2c7cf397f --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_floor_color.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_floor_color + [[ string help = "Color"" Find the nearest integer less than or equal to the parameter." ]] + ( + color in = 0, + output color out = 0 + ) +{ + out = floor(in); +} diff --git a/materialx/libraries/stdlib/osl/mx_floor_color4.osl b/materialx/libraries/stdlib/osl/mx_floor_color4.osl new file mode 100644 index 000000000..b2b5b9d5d --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_floor_color4.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_floor_color4 + [[ string help = "Color4"" Find the nearest integer less than or equal to the parameter." ]] + ( + color4 in = {color(0,0,0), 0}, + output color4 out = {color(0,0,0), 0} + ) +{ + out = floor(in); +} diff --git a/materialx/libraries/stdlib/osl/mx_floor_float.osl b/materialx/libraries/stdlib/osl/mx_floor_float.osl new file mode 100644 index 000000000..ebcb77667 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_floor_float.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_floor_float + [[ string help = "Float"" Find the nearest integer less than or equal to the parameter." ]] + ( + float in = 0, + output float out = 0 + ) +{ + out = floor(in); +} diff --git a/materialx/libraries/stdlib/osl/mx_floor_vector.osl b/materialx/libraries/stdlib/osl/mx_floor_vector.osl new file mode 100644 index 000000000..b6b9c33bd --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_floor_vector.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_floor_vector + [[ string help = "Vector"" Find the nearest integer less than or equal to the parameter." ]] + ( + vector in = 0, + output vector out = 0 + ) +{ + out = floor(in); +} diff --git a/materialx/libraries/stdlib/osl/mx_floor_vector2.osl b/materialx/libraries/stdlib/osl/mx_floor_vector2.osl new file mode 100644 index 000000000..5754dfbf7 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_floor_vector2.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_floor_vector2 + [[ string help = "Vector2"" Find the nearest integer less than or equal to the parameter." ]] + ( + vector2 in = {0,0}, + output vector2 out = {0,0} + ) +{ + out = floor(in); +} diff --git a/materialx/libraries/stdlib/osl/mx_floor_vector4.osl b/materialx/libraries/stdlib/osl/mx_floor_vector4.osl new file mode 100644 index 000000000..06e4b188a --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_floor_vector4.osl @@ -0,0 +1,17 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_floor_vector4 + [[ string help = "Vector4"" Find the nearest integer less than or equal to the parameter." ]] + ( + vector4 in = {0,0,0,0}, + output vector4 out = {0,0,0,0} + ) +{ + out = floor(in); +} diff --git a/materialx/libraries/stdlib/osl/mx_fractal3d_color.osl b/materialx/libraries/stdlib/osl/mx_fractal3d_color.osl new file mode 100644 index 000000000..ac5370b1c --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_fractal3d_color.osl @@ -0,0 +1,36 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_fractal3d_color + [[ string help = "3D fractal noise" ]] + ( + point position = transform ("object", P) + [[ string help = "input coordinate position (default: object space P)", + int lockgeom = 0 ]], + + color amplitude = 1 + [[ string help = "center-to-peak amplitude of the noise" ]], + + int octaves = 3 + [[ string help = "number of summed octaves" ]], + + float lacunarity = 2.0 + [[ string help = "exponential scale between successive octaves" ]], + + float diminish = 0.5 + [[ string help = "rate at which amplitude is diminished per octave"]], + + string noisetype = "snoise" + [[ string help = "type of noise" ]], + + output color out = 0 + ) +{ + color f = fBm(position, octaves, lacunarity, diminish, noisetype); + out = f * amplitude; +} diff --git a/materialx/libraries/stdlib/osl/mx_fractal3d_color4.osl b/materialx/libraries/stdlib/osl/mx_fractal3d_color4.osl new file mode 100644 index 000000000..6ec9a3d9c --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_fractal3d_color4.osl @@ -0,0 +1,36 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_fractal3d_color4 + [[ string help = "3D fractal noise" ]] + ( + point position = transform ("object", P) + [[ string help = "input coordinate position (default: object space P)", + int lockgeom = 0 ]], + + color4 amplitude = {color(1,1,1), 1} + [[ string help = "center-to-peak amplitude of the noise" ]], + + int octaves = 3 + [[ string help = "number of summed octaves" ]], + + float lacunarity = 2.0 + [[ string help = "exponential scale between successive octaves" ]], + + float diminish = 0.5 + [[ string help = "rate at which amplitude is diminished per octave"]], + + string noisetype = "snoise" + [[ string help = "type of noise" ]], + + output color4 out = {color(0,0,0), 0} + ) +{ + color4 f = fBm(position, octaves, lacunarity, diminish, noisetype); + out = f * amplitude; +} diff --git a/materialx/libraries/stdlib/osl/mx_fractal3d_fa_color.osl b/materialx/libraries/stdlib/osl/mx_fractal3d_fa_color.osl new file mode 100644 index 000000000..b6b87f69b --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_fractal3d_fa_color.osl @@ -0,0 +1,36 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_fractal3d_fa_color + [[ string help = "3D fractal noise" ]] + ( + point position = transform ("object", P) + [[ string help = "input coordinate position (default: object space P)", + int lockgeom = 0 ]], + + float amplitude = 1 + [[ string help = "center-to-peak amplitude of the noise" ]], + + int octaves = 3 + [[ string help = "number of summed octaves" ]], + + float lacunarity = 2.0 + [[ string help = "exponential scale between successive octaves" ]], + + float diminish = 0.5 + [[ string help = "rate at which amplitude is diminished per octave"]], + + string noisetype = "snoise" + [[ string help = "type of noise" ]], + + output color out = 0 + ) +{ + color f = fBm(position, octaves, lacunarity, diminish, noisetype); + out = f * amplitude; +} diff --git a/materialx/libraries/stdlib/osl/mx_fractal3d_fa_color4.osl b/materialx/libraries/stdlib/osl/mx_fractal3d_fa_color4.osl new file mode 100644 index 000000000..da89d771e --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_fractal3d_fa_color4.osl @@ -0,0 +1,36 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_fractal3d_fa_color4 + [[ string help = "3D fractal noise" ]] + ( + point position = transform ("object", P) + [[ string help = "input coordinate position (default: object space P)", + int lockgeom = 0 ]], + + float amplitude = 1 + [[ string help = "center-to-peak amplitude of the noise" ]], + + int octaves = 3 + [[ string help = "number of summed octaves" ]], + + float lacunarity = 2.0 + [[ string help = "exponential scale between successive octaves" ]], + + float diminish = 0.5 + [[ string help = "rate at which amplitude is diminished per octave"]], + + string noisetype = "snoise" + [[ string help = "type of noise" ]], + + output color4 out = {color(0,0,0), 0} + ) +{ + color4 f = fBm(position, octaves, lacunarity, diminish, noisetype); + out = f * amplitude; +} diff --git a/materialx/libraries/stdlib/osl/mx_fractal3d_fa_vector.osl b/materialx/libraries/stdlib/osl/mx_fractal3d_fa_vector.osl new file mode 100644 index 000000000..b8cf0b526 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_fractal3d_fa_vector.osl @@ -0,0 +1,36 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_fractal3d_fa_vector + [[ string help = "3D fractal noise" ]] + ( + point position = transform ("object", P) + [[ string help = "input coordinate position (default: object space P)", + int lockgeom = 0 ]], + + float amplitude = 1 + [[ string help = "center-to-peak amplitude of the noise" ]], + + int octaves = 3 + [[ string help = "number of summed octaves" ]], + + float lacunarity = 2.0 + [[ string help = "exponential scale between successive octaves" ]], + + float diminish = 0.5 + [[ string help = "rate at which amplitude is diminished per octave"]], + + string noisetype = "snoise" + [[ string help = "type of noise" ]], + + output vector out = 0 + ) +{ + vector f = fBm(position, octaves, lacunarity, diminish, noisetype); + out = f * amplitude; +} diff --git a/materialx/libraries/stdlib/osl/mx_fractal3d_fa_vector2.osl b/materialx/libraries/stdlib/osl/mx_fractal3d_fa_vector2.osl new file mode 100644 index 000000000..a453b482b --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_fractal3d_fa_vector2.osl @@ -0,0 +1,36 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_fractal3d_fa_vector2 + [[ string help = "3D fractal noise" ]] + ( + point position = transform ("object", P) + [[ string help = "input coordinate position (default: object space P)", + int lockgeom = 0 ]], + + float amplitude = 1 + [[ string help = "center-to-peak amplitude of the noise" ]], + + int octaves = 3 + [[ string help = "number of summed octaves" ]], + + float lacunarity = 2.0 + [[ string help = "exponential scale between successive octaves" ]], + + float diminish = 0.5 + [[ string help = "rate at which amplitude is diminished per octave"]], + + string noisetype = "snoise" + [[ string help = "type of noise" ]], + + output vector2 out = {0,0} + ) +{ + vector2 f = fBm(position, octaves, lacunarity, diminish, noisetype); + out = f * amplitude; +} diff --git a/materialx/libraries/stdlib/osl/mx_fractal3d_fa_vector4.osl b/materialx/libraries/stdlib/osl/mx_fractal3d_fa_vector4.osl new file mode 100644 index 000000000..4cf7c1b82 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_fractal3d_fa_vector4.osl @@ -0,0 +1,36 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_fractal3d_fa_vector4 + [[ string help = "3D fractal noise" ]] + ( + point position = transform ("object", P) + [[ string help = "input coordinate position (default: object space P)", + int lockgeom = 0 ]], + + float amplitude = 1 + [[ string help = "center-to-peak amplitude of the noise" ]], + + int octaves = 3 + [[ string help = "number of summed octaves" ]], + + float lacunarity = 2.0 + [[ string help = "exponential scale between successive octaves" ]], + + float diminish = 0.5 + [[ string help = "rate at which amplitude is diminished per octave"]], + + string noisetype = "snoise" + [[ string help = "type of noise" ]], + + output vector4 out = {0,0,0,0} + ) +{ + vector4 f = fBm(position, octaves, lacunarity, diminish, noisetype); + out = f * amplitude; +} diff --git a/materialx/libraries/stdlib/osl/mx_fractal3d_float.osl b/materialx/libraries/stdlib/osl/mx_fractal3d_float.osl new file mode 100644 index 000000000..581243462 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_fractal3d_float.osl @@ -0,0 +1,36 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_fractal3d_float + [[ string help = "3D fractal noise" ]] + ( + point position = transform ("object", P) + [[ string help = "input coordinate position (default: object space P)", + int lockgeom = 0 ]], + + float amplitude = 1 + [[ string help = "center-to-peak amplitude of the noise" ]], + + int octaves = 3 + [[ string help = "number of summed octaves" ]], + + float lacunarity = 2.0 + [[ string help = "exponential scale between successive octaves" ]], + + float diminish = 0.5 + [[ string help = "rate at which amplitude is diminished per octave"]], + + string noisetype = "snoise" + [[ string help = "type of noise" ]], + + output float out = 0 + ) +{ + float f = fBm(position, octaves, lacunarity, diminish, noisetype); + out = f * amplitude; +} diff --git a/materialx/libraries/stdlib/osl/mx_fractal3d_vector.osl b/materialx/libraries/stdlib/osl/mx_fractal3d_vector.osl new file mode 100644 index 000000000..2c349b4d1 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_fractal3d_vector.osl @@ -0,0 +1,36 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_fractal3d_vector + [[ string help = "3D fractal noise" ]] + ( + point position = transform ("object", P) + [[ string help = "input coordinate position (default: object space P)", + int lockgeom = 0 ]], + + vector amplitude = 1 + [[ string help = "center-to-peak amplitude of the noise" ]], + + int octaves = 3 + [[ string help = "number of summed octaves" ]], + + float lacunarity = 2.0 + [[ string help = "exponential scale between successive octaves" ]], + + float diminish = 0.5 + [[ string help = "rate at which amplitude is diminished per octave"]], + + string noisetype = "snoise" + [[ string help = "type of noise" ]], + + output vector out = 0 + ) +{ + vector f = fBm(position, octaves, lacunarity, diminish, noisetype); + out = f * amplitude; +} diff --git a/materialx/libraries/stdlib/osl/mx_fractal3d_vector2.osl b/materialx/libraries/stdlib/osl/mx_fractal3d_vector2.osl new file mode 100644 index 000000000..344c37510 --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_fractal3d_vector2.osl @@ -0,0 +1,36 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_fractal3d_vector2 + [[ string help = "3D fractal noise" ]] + ( + point position = transform ("object", P) + [[ string help = "input coordinate position (default: object space P)", + int lockgeom = 0 ]], + + vector2 amplitude = {1,1} + [[ string help = "center-to-peak amplitude of the noise" ]], + + int octaves = 3 + [[ string help = "number of summed octaves" ]], + + float lacunarity = 2.0 + [[ string help = "exponential scale between successive octaves" ]], + + float diminish = 0.5 + [[ string help = "rate at which amplitude is diminished per octave"]], + + string noisetype = "snoise" + [[ string help = "type of noise" ]], + + output vector2 out = {0,0} + ) +{ + vector2 f = fBm(position, octaves, lacunarity, diminish, noisetype); + out = f * amplitude; +} diff --git a/materialx/libraries/stdlib/osl/mx_fractal3d_vector4.osl b/materialx/libraries/stdlib/osl/mx_fractal3d_vector4.osl new file mode 100644 index 000000000..65b60ce2a --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_fractal3d_vector4.osl @@ -0,0 +1,36 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_fractal3d_vector4 + [[ string help = "3D fractal noise" ]] + ( + point position = transform ("object", P) + [[ string help = "input coordinate position (default: object space P)", + int lockgeom = 0 ]], + + vector4 amplitude = {1,1,1,1} + [[ string help = "center-to-peak amplitude of the noise" ]], + + int octaves = 3 + [[ string help = "number of summed octaves" ]], + + float lacunarity = 2.0 + [[ string help = "exponential scale between successive octaves" ]], + + float diminish = 0.5 + [[ string help = "rate at which amplitude is diminished per octave"]], + + string noisetype = "snoise" + [[ string help = "type of noise" ]], + + output vector4 out = {0,0,0,0} + ) +{ + vector4 f = fBm(position, octaves, lacunarity, diminish, noisetype); + out = f * amplitude; +} diff --git a/materialx/libraries/stdlib/osl/mx_frame_float.osl b/materialx/libraries/stdlib/osl/mx_frame_float.osl new file mode 100644 index 000000000..a9ffde8ee --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_frame_float.osl @@ -0,0 +1,16 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#include "mx_funcs.h" + +shader mx_frame_float + [[ string help = "The current frame number as defined by the host environment." ]] + ( + output float out = 0 + ) +{ + getattribute("frame", out); +} diff --git a/materialx/libraries/stdlib/osl/mx_funcs.h b/materialx/libraries/stdlib/osl/mx_funcs.h new file mode 100644 index 000000000..ba8a48fcc --- /dev/null +++ b/materialx/libraries/stdlib/osl/mx_funcs.h @@ -0,0 +1,817 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE +// +// MaterialX specification (c) 2017 Lucasfilm Ltd. +// http://www.materialx.org/ + +#pragma once +#include "color4.h" +#include "vector2.h" +#include "vector4.h" +#include "matrix33.h" + + +/////////////////////////////////////////////////////////////////////////// +// This file contains lots of functions helpful in the implementation of +// the MaterialX nodes. +/////////////////////////////////////////////////////////////////////////// + + +// Define mx_convert_type +// float -> colvecN +color mx_convert (float a) { return color(a); } +color4 mx_convert (float a) { return color4(a,a); } +vector mx_convert (float a) { return vector(a); } +vector2 mx_convert (float a) { return vector2(a,a); } +vector4 mx_convert (float a) { return vector4(a,a,a,a); } +// colN <-> vecN +vector mx_convert (color a) { return (vector)a; } +vector4 mx_convert (color4 a) { return vector4 (a.rgb[0], a.rgb[1], a.rgb[2], a.a); } +color mx_convert (vector a) { return (color)a; } +color4 mx_convert (vector4 a) { return color4 (color(a.x,a.y,a.z), a.w); } +// col3 <-> col4 +color mx_convert (color4 a) { return a.rgb; } +color4 mx_convert (color a) { return color4(a,1.0); } + +// Define mx_add() overloaded for all MX types. +float mx_add (float a, float b) { return a+b; } +point mx_add (point a, point b) { return a+b; } +point mx_add (point a, float b) { return a+b; } +vector mx_add (vector a, vector b) { return a+b; } +vector mx_add (vector a, float b) { return a+b; } +vector2 mx_add (vector2 a, vector2 b) { return a+b; } +vector2 mx_add (vector2 a, float b) { return a+b; } +vector4 mx_add (vector4 a, vector4 b) { return a+b; } +vector4 mx_add (vector4 a, float b) { return a+b; } +color mx_add (color a, color b) { return a+b; } +color mx_add (color a, float b) { return a+b; } +color4 mx_add (color4 a, color4 b) { return a+b; } +color4 mx_add (color4 a, float b) { return a+b; } +closure color mx_add (closure color a, closure color b) { return a+b; } + +matrix33 mx_add(matrix33 a, matrix33 b) +{ + return matrix33 (matrix( + a.m[0][0]+b.m[0][0], a.m[0][1]+b.m[0][1], a.m[0][2]+b.m[0][2], 0.0, + a.m[1][0]+b.m[1][0], a.m[1][1]+b.m[1][1], a.m[1][2]+b.m[1][2], 0.0, + a.m[2][0]+b.m[2][0], a.m[2][1]+b.m[2][1], a.m[2][2]+b.m[2][2], 0.0, + 0.0, 0.0, 0.0, 1.0)); +} + +matrix33 mx_add(matrix33 a, float b) +{ + return matrix33 (matrix(a.m[0][0]+b, a.m[0][1]+b, a.m[0][2]+b, 0.0, + a.m[1][0]+b, a.m[1][1]+b, a.m[1][2]+b, 0.0, + a.m[2][0]+b, a.m[2][1]+b, a.m[2][2]+b, 0.0, + 0.0, 0.0, 0.0, 1.0)); +} + +matrix mx_add(matrix a, matrix b) +{ + return matrix (a[0][0]+b[0][0], a[0][1]+b[0][1], a[0][2]+b[0][2], a[0][3]+b[0][3], + a[1][0]+b[1][0], a[1][1]+b[1][1], a[1][2]+b[1][2], a[1][3]+b[1][3], + a[2][0]+b[2][0], a[2][1]+b[2][1], a[2][2]+b[2][2], a[2][3]+b[2][3], + a[3][0]+b[3][0], a[3][1]+b[3][1], a[3][2]+b[3][2], a[3][3]+b[3][3]); +} + +matrix mx_add(matrix a, float b) +{ + return matrix (a[0][0]+b, a[0][1]+b, a[0][2]+b, a[0][3]+b, + a[1][0]+b, a[1][1]+b, a[1][2]+b, a[1][3]+b, + a[2][0]+b, a[2][1]+b, a[2][2]+b, a[2][3]+b, + a[3][0]+b, a[3][1]+b, a[3][2]+b, a[3][3]+b); +} + + +// Define mx_sub() overloaded for all MX types. +float mx_sub (float a, float b) { return a-b; } +point mx_sub (point a, point b) { return a-b; } +point mx_sub (point a, float b) { return a-b; } +vector mx_sub (vector a, vector b) { return a-b; } +vector mx_sub (vector a, float b) { return a-b; } +vector2 mx_sub (vector2 a, vector2 b) { return a-b; } +vector2 mx_sub (vector2 a, float b) { return a-b; } +vector4 mx_sub (vector4 a, vector4 b) { return a-b; } +vector4 mx_sub (vector4 a, float b) { return a-b; } +color mx_sub (color a, color b) { return a-b; } +color mx_sub (color a, float b) { return a-b; } +color4 mx_sub (color4 a, color4 b) { return a-b; } +color4 mx_sub (color4 a, float b) { return a-b; } + +matrix33 mx_sub (matrix33 a, matrix33 b) +{ + return matrix33 (matrix( + a.m[0][0]-b.m[0][0], a.m[0][1]-b.m[0][1], a.m[0][2]-b.m[0][2], 0.0, + a.m[1][0]-b.m[1][0], a.m[1][1]-b.m[1][1], a.m[1][2]-b.m[1][2], 0.0, + a.m[2][0]-b.m[2][0], a.m[2][1]-b.m[2][1], a.m[2][2]-b.m[2][2], 0.0, + 0.0, 0.0, 0.0, 1.0)); +} + +matrix33 mx_sub (matrix33 a, float b) +{ + return matrix33 (matrix( + a.m[0][0]-b, a.m[0][1]-b, a.m[0][2]-b, 0.0, + a.m[1][0]-b, a.m[1][1]-b, a.m[1][2]-b, 0.0, + a.m[2][0]-b, a.m[2][1]-b, a.m[2][2]-b, 0.0, + 0.0, 0.0, 0.0, 1.0)); +} + +matrix mx_sub (matrix a, matrix b) +{ + return matrix(a[0][0]-b[0][0], a[0][1]-b[0][1], a[0][2]-b[0][2], a[0][3]-b[0][3], + a[1][0]-b[1][0], a[1][1]-b[1][1], a[1][2]-b[1][2], a[1][3]-b[1][3], + a[2][0]-b[2][0], a[2][1]-b[2][1], a[2][2]-b[2][2], a[2][3]-b[2][3], + a[3][0]-b[3][0], a[3][1]-b[3][1], a[3][2]-b[3][2], a[3][3]-b[3][3]); +} + +matrix mx_sub (matrix a, float b) +{ + return matrix (a[0][0]-b, a[0][1]-b, a[0][2]-b, a[0][3]-b, + a[1][0]-b, a[1][1]-b, a[1][2]-b, a[1][3]-b, + a[2][0]-b, a[2][1]-b, a[2][2]-b, a[2][3]-b, + a[3][0]-b, a[3][1]-b, a[3][2]-b, a[3][3]-b); +} + + + +// remap `in` from [inLow, inHigh] to [outLow, outHigh], optionally clamping +// to the new range. +// +float remap(float in, float inLow, float inHigh, float outLow, float outHigh, int doClamp) +{ + float x = (in - inLow)/(inHigh-inLow); + if (doClamp == 1) { + x = clamp(x, 0, 1); + } + return outLow + (outHigh - outLow) * x; +} + +color remap(color in, color inLow, color inHigh, color outLow, color outHigh, int doClamp) +{ + color x = (in - inLow) / (inHigh - inLow); + if (doClamp == 1) { + x = clamp(x, 0, 1); + } + return outLow + (outHigh - outLow) * x; +} + +color remap(color in, float inLow, float inHigh, float outLow, float outHigh, int doClamp) +{ + color x = (in - inLow) / (inHigh - inLow); + if (doClamp == 1) { + x = clamp(x, 0, 1); + } + return outLow + (outHigh - outLow) * x; +} + +color4 remap(color4 c, color4 inLow, color4 inHigh, color4 outLow, color4 outHigh, int doClamp) +{ + return color4(remap(c.rgb, inLow.rgb, inHigh.rgb, outLow.rgb, outHigh.rgb, doClamp), + remap(c.a, inLow.a, inHigh.a, outLow.a, outHigh.a, doClamp)); +} + +color4 remap(color4 c, float inLow, float inHigh, float outLow, float outHigh, int doClamp) +{ + color4 c4_inLow = color4(color(inLow), inLow); + color4 c4_inHigh = color4(color(inHigh), inHigh); + color4 c4_outLow = color4(color(outLow), outLow); + color4 c4_outHigh = color4(color(outHigh), outHigh); + return remap(c, c4_inLow, c4_inHigh, c4_outLow, c4_outHigh, doClamp); +} + +vector2 remap(vector2 in, vector2 inLow, vector2 inHigh, vector2 outLow, vector2 outHigh, int doClamp) +{ + return vector2 (remap(in.x, inLow.x, inHigh.x, outLow.x, outHigh.x, doClamp), + remap(in.y, inLow.y, inHigh.y, outLow.y, outHigh.y, doClamp)); +} + +vector2 remap(vector2 in, float inLow, float inHigh, float outLow, float outHigh, int doClamp) +{ + return vector2 (remap(in.x, inLow, inHigh, outLow, outHigh, doClamp), + remap(in.y, inLow, inHigh, outLow, outHigh, doClamp)); +} + +vector4 remap(vector4 in, vector4 inLow, vector4 inHigh, vector4 outLow, vector4 outHigh, int doClamp) +{ + return vector4 (remap(in.x, inLow.x, inHigh.x, outLow.x, outHigh.x, doClamp), + remap(in.y, inLow.y, inHigh.y, outLow.y, outHigh.y, doClamp), + remap(in.z, inLow.z, inHigh.z, outLow.z, outHigh.z, doClamp), + remap(in.w, inLow.w, inHigh.w, outLow.w, outHigh.w, doClamp)); +} + +vector4 remap(vector4 in, float inLow, float inHigh, float outLow, float outHigh, int doClamp) +{ + return vector4 (remap(in.x, inLow, inHigh, outLow, outHigh, doClamp), + remap(in.y, inLow, inHigh, outLow, outHigh, doClamp), + remap(in.z, inLow, inHigh, outLow, outHigh, doClamp), + remap(in.w, inLow, inHigh, outLow, outHigh, doClamp)); +} + + + +float fgamma(float in, float g) +{ + return sign(in) * pow(abs(in), g); +} + +color fgamma(color in, color g) +{ + return sign(in) * pow(abs(in), g); +} + +color fgamma(color in, float g) +{ + return sign(in) * pow(abs(in), g); +} + +color4 fgamma(color4 a, color4 b) +{ + return color4(fgamma(a.rgb, b.rgb), fgamma(a.a, b.a)); +} + +color4 fgamma(color4 a, float b) +{ + return fgamma(a, color4(color(b), b)); +} + +vector2 fgamma(vector2 in, vector2 g) +{ + return vector2 (fgamma(in.x, g.x), fgamma(in.y, g.y)); +} + +vector2 fgamma(vector2 in, float g) +{ + return vector2 (fgamma(in.x, g), fgamma(in.y, g)); +} + +vector4 fgamma(vector4 in, vector4 g) +{ + return vector4 (fgamma(in.x, g.x), + fgamma(in.y, g.y), + fgamma(in.z, g.z), + fgamma(in.w, g.w)); +} + +vector4 fgamma(vector4 in, float g) +{ + return vector4 (fgamma(in.x, g), + fgamma(in.y, g), + fgamma(in.z, g), + fgamma(in.w, g)); +} + + + +// +// contrast scales the input around a central `pivot` value. +// +float contrast(float in, float amount, float pivot) +{ + float out = in - pivot; + out *= amount; + out += pivot; + return out; +} + +color contrast(color in, color amount, color pivot) +{ + color out = in - pivot; + out *= amount; + out += pivot; + return out; +} + +color contrast(color in, float amount, float pivot) +{ + color out = in - pivot; + out *= amount; + out += pivot; + return out; +} + +color4 contrast(color4 c, color4 amount, color4 pivot) +{ + return color4(contrast(c.rgb, amount.rgb, pivot.rgb), + contrast(c.a, amount.a, pivot.a)); +} + +color4 contrast(color4 c, float amount, float pivot) +{ + return contrast(c, color4(color(amount), amount), color4(color(pivot), pivot)); +} + +vector2 contrast(vector2 in, vector2 amount, vector2 pivot) +{ + return vector2 (contrast(in.x, amount.x, pivot.x), + contrast(in.y, amount.y, pivot.y)); +} + +vector2 contrast(vector2 in, float amount, float pivot) +{ + return contrast(in, vector2(amount, amount), vector2(pivot, pivot)); +} + +vector4 contrast(vector4 in, vector4 amount, vector4 pivot) +{ + return vector4 (contrast(in.x, amount.x, pivot.x), + contrast(in.y, amount.y, pivot.y), + contrast(in.z, amount.z, pivot.z), + contrast(in.w, amount.w, pivot.w)); +} + +vector4 contrast(vector4 in, float amount, float pivot) +{ + return vector4 (contrast(in.x, amount, pivot), + contrast(in.y, amount, pivot), + contrast(in.z, amount, pivot), + contrast(in.w, amount, pivot)); +} + + + +vector2 noise (string noisetype, float x, float y) +{ + color cnoise = (color) noise (noisetype, x, y); + return vector2 (cnoise[0], cnoise[1]); +} + +color4 noise (string noisetype, float x, float y) +{ + color cnoise = (color) noise (noisetype, x, y); + float fnoise = (float) noise (noisetype, x + 19, y + 73); + return color4 (cnoise, fnoise); +} + +vector4 noise (string noisetype, float x, float y) +{ + color cnoise = (color) noise (noisetype, x, y); + float fnoise = (float) noise (noisetype, x + 19, y + 73); + return vector4 (cnoise[0], cnoise[1], cnoise[2], fnoise); +} + + +vector2 noise (string noisetype, point position) +{ + color cnoise = (color) noise (noisetype, position); + return vector2 (cnoise[0], cnoise[1]); +} + +color4 noise (string noisetype, point position) +{ + color cnoise = (color) noise (noisetype, position); + float fnoise = (float) noise (noisetype, position+vector(19,73,29)); + return color4 (cnoise, fnoise); +} + +vector4 noise (string noisetype, point position) +{ + color cnoise = (color) noise (noisetype, position); + float fnoise = (float) noise (noisetype, position+vector(19,73,29)); + return vector4 (cnoise[0], cnoise[1], cnoise[2], fnoise); +} + + + +vector2 cellnoise (float x, float y) +{ + color cnoise = (color) cellnoise (x, y); + return vector2 (cnoise[0], cnoise[1]); +} + +color4 cellnoise (float x, float y) +{ + color cnoise = (color) cellnoise (x, y); + float fnoise = (float) cellnoise (x + 19, y + 73); + return color4 (cnoise, fnoise); +} + +vector4 cellnoise (float x, float y) +{ + color cnoise = (color) cellnoise (x, y); + float fnoise = (float) cellnoise (x + 19, y + 73); + return vector4 (cnoise[0], cnoise[1], cnoise[2], fnoise); +} + + + +vector2 cellnoise (point position) +{ + color cnoise = (color) cellnoise (position); + return vector2 (cnoise[0], cnoise[1]); +} + +color4 cellnoise (point position) +{ + color cnoise = (color) cellnoise (position); + float fnoise = (float) cellnoise (position+vector(19,73,29)); + return color4 (cnoise, fnoise); +} + +vector4 cellnoise (point position) +{ + color cnoise = (color) cellnoise (position); + float fnoise = (float) cellnoise (position+vector(19,73,29)); + return vector4 (cnoise[0], cnoise[1], cnoise[2], fnoise); +} + + + +// +// fractional Brownian motion +// +float fBm( point position, int octaves, float lacunarity, float diminish, string noisetype) +{ + float out = 0; + float amp = 1.0; + point p = position; + + for (int i = 0; i < octaves; i += 1) { + out += amp * noise(noisetype, p); + amp *= diminish; + p *= lacunarity; + } + return out; +} + +color fBm( point position, int octaves, float lacunarity, float diminish, string noisetype) +{ + color out = 0; + float amp = 1.0; + point p = position; + + for (int i = 0; i < octaves; i += 1) { + out += amp * (color)noise(noisetype, p); + amp *= diminish; + p *= lacunarity; + } + return out; +} + +vector2 fBm( point position, int octaves, float lacunarity, float diminish, string noisetype) +{ + return vector2 ((float) fBm (position, octaves, lacunarity, diminish, noisetype), + (float) fBm (position+point(19, 193, 17), octaves, lacunarity, diminish, noisetype)); +} + +color4 fBm( point position, int octaves, float lacunarity, float diminish, string noisetype) +{ + color c = (color) fBm (position, octaves, lacunarity, diminish, noisetype); + float f = (float) fBm (position+point(19, 193, 17), octaves, lacunarity, diminish, noisetype); + return color4 (c, f); +} + +vector4 fBm( point position, int octaves, float lacunarity, float diminish, string noisetype) +{ + color c = (color) fBm (position, octaves, lacunarity, diminish, noisetype); + float f = (float) fBm (position+point(19, 193, 17), octaves, lacunarity, diminish, noisetype); + return vector4 (c[0], c[1], c[2], f); +} + + + + + + +float swizzle_float (float in[4], string channels) +{ + float out; + float outF[4]; + int c_len = strlen(channels); + + for (int i=0; i 93 || x > 6 || y > 13) return 0; + int i = 98 * c + 7 * y + x; + return ((getchar("0@P01248@00120000P49B0000000000000:DXlW2UoDX@10008@h;IR4n@R000015A000000000000000000000000h?00" + "04@010000000000000000l0bGX@aL10000124XcX@Q25j300000000?Q248@8?000008@Pl5:DX@aL10" + "000000`CX@o24`70000`AP01N48@P0100000000l5:DX@aL12T70124XcX@Q25:40000@P0P348@P01>" + "00000240HP01248@P0a101248@T47B4940000HP01248@P01L00000000oBVS248@P000000000l48P7" + "@Pn0000048@`31248@030000000P@Q25:DP0124`1001248@P01248@P0007@P01" + "24`@P01R30000000S9S10000000", i / 6) - 48) >> (i % 6)) & 1; + } + int modp(int a, int b) { + int x = a % b; + return x < 0 ? x + b : x; + } + int len = strlen(str); + int jit = jitter ? hash(str) : 0; + int pix_w = len * 8; + int pix_h = 14; + int x = int(floor(s)); + int y = int(floor(t)); + if (wrap_s) x = modp(x + ( jitter & 15), pix_w + pix_h); + if (wrap_t) y = modp(y + ((jitter >> 16) & 15), pix_h + pix_h); + return float(glyph_pixel(getchar(str, x / 8), x - (x / 8) * 8, y)); +} + + +#endif /* OSLUTIL_H */ diff --git a/materialx/libraries/stdlib/osl/stdlib_osl_impl.mtlx b/materialx/libraries/stdlib/osl/stdlib_osl_impl.mtlx new file mode 100644 index 000000000..0d19f2e24 --- /dev/null +++ b/materialx/libraries/stdlib/osl/stdlib_osl_impl.mtlx @@ -0,0 +1,780 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/materialx/libraries/stdlib/osl/stdosl.h b/materialx/libraries/stdlib/osl/stdosl.h new file mode 100644 index 000000000..6254476b9 --- /dev/null +++ b/materialx/libraries/stdlib/osl/stdosl.h @@ -0,0 +1,601 @@ +///////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2009-2010 Sony Pictures Imageworks Inc., et al. All Rights Reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// * Neither the name of Sony Pictures Imageworks nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +///////////////////////////////////////////////////////////////////////////// + + +#ifndef STDOSL_H +#define STDOSL_H + + +#ifndef M_PI +#define M_PI 3.1415926535897932 /* pi */ +#define M_PI_2 1.5707963267948966 /* pi/2 */ +#define M_PI_4 0.7853981633974483 /* pi/4 */ +#define M_2_PI 0.6366197723675813 /* 2/pi */ +#define M_2PI 6.2831853071795865 /* 2*pi */ +#define M_4PI 12.566370614359173 /* 4*pi */ +#define M_2_SQRTPI 1.1283791670955126 /* 2/sqrt(pi) */ +#define M_E 2.7182818284590452 /* e (Euler's number) */ +#define M_LN2 0.6931471805599453 /* ln(2) */ +#define M_LN10 2.3025850929940457 /* ln(10) */ +#define M_LOG2E 1.4426950408889634 /* log_2(e) */ +#define M_LOG10E 0.4342944819032518 /* log_10(e) */ +#define M_SQRT2 1.4142135623730950 /* sqrt(2) */ +#define M_SQRT1_2 0.7071067811865475 /* 1/sqrt(2) */ +#endif + + + +// Declaration of built-in functions and closures +#define BUILTIN [[ int builtin = 1 ]] +#define BUILTIN_DERIV [[ int builtin = 1, int deriv = 1 ]] + +#define PERCOMP1(name) \ + normal name (normal x) BUILTIN; \ + vector name (vector x) BUILTIN; \ + point name (point x) BUILTIN; \ + color name (color x) BUILTIN; \ + float name (float x) BUILTIN; + +#define PERCOMP2(name) \ + normal name (normal x, normal y) BUILTIN; \ + vector name (vector x, vector y) BUILTIN; \ + point name (point x, point y) BUILTIN; \ + color name (color x, color y) BUILTIN; \ + float name (float x, float y) BUILTIN; + +#define PERCOMP2F(name) \ + normal name (normal x, float y) BUILTIN; \ + vector name (vector x, float y) BUILTIN; \ + point name (point x, float y) BUILTIN; \ + color name (color x, float y) BUILTIN; \ + float name (float x, float y) BUILTIN; + + +// Basic math +normal degrees (normal x) { return x*(180.0/M_PI); } +vector degrees (vector x) { return x*(180.0/M_PI); } +point degrees (point x) { return x*(180.0/M_PI); } +color degrees (color x) { return x*(180.0/M_PI); } +float degrees (float x) { return x*(180.0/M_PI); } +normal radians (normal x) { return x*(M_PI/180.0); } +vector radians (vector x) { return x*(M_PI/180.0); } +point radians (point x) { return x*(M_PI/180.0); } +color radians (color x) { return x*(M_PI/180.0); } +float radians (float x) { return x*(M_PI/180.0); } +PERCOMP1 (cos) +PERCOMP1 (sin) +PERCOMP1 (tan) +PERCOMP1 (acos) +PERCOMP1 (asin) +PERCOMP1 (atan) +PERCOMP2 (atan2) +PERCOMP1 (cosh) +PERCOMP1 (sinh) +PERCOMP1 (tanh) +PERCOMP2F (pow) +PERCOMP2 (pow) +PERCOMP1 (exp) +PERCOMP1 (exp2) +PERCOMP1 (expm1) +PERCOMP1 (log) +point log (point a, float b) { return log(a)/log(b); } +vector log (vector a, float b) { return log(a)/log(b); } +color log (color a, float b) { return log(a)/log(b); } +float log (float a, float b) { return log(a)/log(b); } +PERCOMP1 (log2) +PERCOMP1 (log10) +PERCOMP1 (logb) +PERCOMP1 (sqrt) +PERCOMP1 (inversesqrt) +float hypot (float a, float b) { return sqrt (a*a + b*b); } +float hypot (float a, float b, float c) { return sqrt (a*a + b*b + c*c); } +PERCOMP1 (abs) +int abs (int x) BUILTIN; +PERCOMP1 (fabs) +int fabs (int x) BUILTIN; +PERCOMP1 (sign) +PERCOMP1 (floor) +PERCOMP1 (ceil) +PERCOMP1 (round) +PERCOMP1 (trunc) +PERCOMP2 (fmod) +PERCOMP2F (fmod) +int mod (int a, int b) { return a - b*(int)floor(a/b); } +point mod (point a, point b) { return a - b*floor(a/b); } +vector mod (vector a, vector b) { return a - b*floor(a/b); } +normal mod (normal a, normal b) { return a - b*floor(a/b); } +color mod (color a, color b) { return a - b*floor(a/b); } +point mod (point a, float b) { return a - b*floor(a/b); } +vector mod (vector a, float b) { return a - b*floor(a/b); } +normal mod (normal a, float b) { return a - b*floor(a/b); } +color mod (color a, float b) { return a - b*floor(a/b); } +float mod (float a, float b) { return a - b*floor(a/b); } +PERCOMP2 (min) +int min (int a, int b) BUILTIN; +PERCOMP2 (max) +int max (int a, int b) BUILTIN; +normal clamp (normal x, normal minval, normal maxval) { return max(min(x,maxval),minval); } +vector clamp (vector x, vector minval, vector maxval) { return max(min(x,maxval),minval); } +point clamp (point x, point minval, point maxval) { return max(min(x,maxval),minval); } +color clamp (color x, color minval, color maxval) { return max(min(x,maxval),minval); } +float clamp (float x, float minval, float maxval) { return max(min(x,maxval),minval); } +int clamp (int x, int minval, int maxval) { return max(min(x,maxval),minval); } +#if 0 +normal mix (normal x, normal y, normal a) { return x*(1-a) + y*a; } +normal mix (normal x, normal y, float a) { return x*(1-a) + y*a; } +vector mix (vector x, vector y, vector a) { return x*(1-a) + y*a; } +vector mix (vector x, vector y, float a) { return x*(1-a) + y*a; } +point mix (point x, point y, point a) { return x*(1-a) + y*a; } +point mix (point x, point y, float a) { return x*(1-a) + y*a; } +color mix (color x, color y, color a) { return x*(1-a) + y*a; } +color mix (color x, color y, float a) { return x*(1-a) + y*a; } +float mix (float x, float y, float a) { return x*(1-a) + y*a; } +#else +normal mix (normal x, normal y, normal a) BUILTIN; +normal mix (normal x, normal y, float a) BUILTIN; +vector mix (vector x, vector y, vector a) BUILTIN; +vector mix (vector x, vector y, float a) BUILTIN; +point mix (point x, point y, point a) BUILTIN; +point mix (point x, point y, float a) BUILTIN; +color mix (color x, color y, color a) BUILTIN; +color mix (color x, color y, float a) BUILTIN; +float mix (float x, float y, float a) BUILTIN; +#endif +closure color mix (closure color x, closure color y, float a) { return x*(1-a) + y*a; } +closure color mix (closure color x, closure color y, color a) { return x*(1-a) + y*a; } + +normal select (normal x, normal y, normal cond) BUILTIN; +vector select (vector x, vector y, vector cond) BUILTIN; +point select (point x, point y, point cond) BUILTIN; +color select (color x, color y, color cond) BUILTIN; +float select (float x, float y, float cond) BUILTIN; +normal select (normal x, normal y, float cond) BUILTIN; +vector select (vector x, vector y, float cond) BUILTIN; +point select (point x, point y, float cond) BUILTIN; +color select (color x, color y, float cond) BUILTIN; +normal select (normal x, normal y, int cond) BUILTIN; +vector select (vector x, vector y, int cond) BUILTIN; +point select (point x, point y, int cond) BUILTIN; +color select (color x, color y, int cond) BUILTIN; +float select (float x, float y, int cond) BUILTIN; +int isnan (float x) BUILTIN; +int isinf (float x) BUILTIN; +int isfinite (float x) BUILTIN; +float erf (float x) BUILTIN; +float erfc (float x) BUILTIN; + +// Vector functions + +vector cross (vector a, vector b) BUILTIN; +float dot (vector a, vector b) BUILTIN; +float length (vector v) BUILTIN; +float distance (point a, point b) BUILTIN; +float distance (point a, point b, point q) +{ + vector d = b - a; + float dd = dot(d, d); + if(dd == 0.0) + return distance(q, a); + float t = dot(q - a, d)/dd; + return distance(q, a + clamp(t, 0.0, 1.0)*d); +} +normal normalize (normal v) BUILTIN; +vector normalize (vector v) BUILTIN; +vector faceforward (vector N, vector I, vector Nref) +{ + return (dot(I, Nref) > 0) ? -N : N; +} +vector faceforward (vector N, vector I) +{ + return faceforward(N, I, Ng); +} +vector reflect (vector I, vector N) { return I - 2*dot(N,I)*N; } +vector refract (vector I, vector N, float eta) { + float IdotN = dot (I, N); + float k = 1 - eta*eta * (1 - IdotN*IdotN); + return (k < 0) ? vector(0,0,0) : (eta*I - N * (eta*IdotN + sqrt(k))); +} +void fresnel (vector I, normal N, float eta, + output float Kr, output float Kt, + output vector R, output vector T) +{ + float sqr(float x) { return x*x; } + float c = dot(I, N); + if (c < 0) + c = -c; + R = reflect(I, N); + float g = 1.0 / sqr(eta) - 1.0 + c * c; + if (g >= 0.0) { + g = sqrt (g); + float beta = g - c; + float F = (c * (g+c) - 1.0) / (c * beta + 1.0); + F = 0.5 * (1.0 + sqr(F)); + F *= sqr (beta / (g+c)); + Kr = F; + Kt = (1.0 - Kr) * eta*eta; + // OPT: the following recomputes some of the above values, but it + // gives us the same result as if the shader-writer called refract() + T = refract(I, N, eta); + } else { + // total internal reflection + Kr = 1.0; + Kt = 0.0; + T = vector (0,0,0); + } +} + +void fresnel (vector I, normal N, float eta, + output float Kr, output float Kt) +{ + vector R, T; + fresnel(I, N, eta, Kr, Kt, R, T); +} + + +normal transform (matrix Mto, normal p) BUILTIN; +vector transform (matrix Mto, vector p) BUILTIN; +point transform (matrix Mto, point p) BUILTIN; +normal transform (string from, string to, normal p) BUILTIN; +vector transform (string from, string to, vector p) BUILTIN; +point transform (string from, string to, point p) BUILTIN; +normal transform (string to, normal p) { return transform("common",to,p); } +vector transform (string to, vector p) { return transform("common",to,p); } +point transform (string to, point p) { return transform("common",to,p); } + +float transformu (string tounits, float x) BUILTIN; +float transformu (string fromunits, string tounits, float x) BUILTIN; + +point rotate (point p, float angle, point a, point b) +{ + vector axis = normalize (b - a); + float cosang, sinang; + sincos (angle, sinang, cosang); + float cosang1 = 1.0 - cosang; + float x = axis[0], y = axis[1], z = axis[2]; + matrix M = matrix (x * x + (1.0 - x * x) * cosang, + x * y * cosang1 + z * sinang, + x * z * cosang1 - y * sinang, + 0.0, + x * y * cosang1 - z * sinang, + y * y + (1.0 - y * y) * cosang, + y * z * cosang1 + x * sinang, + 0.0, + x * z * cosang1 + y * sinang, + y * z * cosang1 - x * sinang, + z * z + (1.0 - z * z) * cosang, + 0.0, + 0.0, 0.0, 0.0, 1.0); + return transform (M, p-a) + a; +} + + + +// Color functions + +float luminance (color c) BUILTIN; +color blackbody (float temperatureK) BUILTIN; +color wavelength_color (float wavelength_nm) BUILTIN; + + +color transformc (string to, color x) +{ + color rgb_to_hsv (color rgb) { // See Foley & van Dam + float r = rgb[0], g = rgb[1], b = rgb[2]; + float mincomp = min (r, min (g, b)); + float maxcomp = max (r, max (g, b)); + float delta = maxcomp - mincomp; // chroma + float h, s, v; + v = maxcomp; + if (maxcomp > 0) + s = delta / maxcomp; + else s = 0; + if (s <= 0) + h = 0; + else { + if (r >= maxcomp) h = (g-b) / delta; + else if (g >= maxcomp) h = 2 + (b-r) / delta; + else h = 4 + (r-g) / delta; + h /= 6; + if (h < 0) + h += 1; + } + return color (h, s, v); + } + + color rgb_to_hsl (color rgb) { // See Foley & van Dam + // First convert rgb to hsv, then to hsl + float minval = min (rgb[0], min (rgb[1], rgb[2])); + color hsv = rgb_to_hsv (rgb); + float maxval = hsv[2]; // v == maxval + float h = hsv[0], s, l = (minval+maxval) / 2; + if (minval == maxval) + s = 0; // special 'achromatic' case, hue is 0 + else if (l <= 0.5) + s = (maxval - minval) / (maxval + minval); + else + s = (maxval - minval) / (2 - maxval - minval); + return color (h, s, l); + } + + color r; + if (to == "rgb" || to == "RGB") + r = x; + else if (to == "hsv") + r = rgb_to_hsv (x); + else if (to == "hsl") + r = rgb_to_hsl (x); + else if (to == "YIQ") + r = color (dot (vector(0.299, 0.587, 0.114), (vector)x), + dot (vector(0.596, -0.275, -0.321), (vector)x), + dot (vector(0.212, -0.523, 0.311), (vector)x)); + else if (to == "XYZ") + r = color (dot (vector(0.412453, 0.357580, 0.180423), (vector)x), + dot (vector(0.212671, 0.715160, 0.072169), (vector)x), + dot (vector(0.019334, 0.119193, 0.950227), (vector)x)); + else { + error ("Unknown color space \"%s\"", to); + r = x; + } + return r; +} + + +color transformc (string from, string to, color x) +{ + color hsv_to_rgb (color c) { // Reference: Foley & van Dam + float h = c[0], s = c[1], v = c[2]; + color r; + if (s < 0.0001) { + r = v; + } else { + h = 6 * (h - floor(h)); // expand to [0..6) + int hi = (int)h; + float f = h - hi; + float p = v * (1-s); + float q = v * (1-s*f); + float t = v * (1-s*(1-f)); + if (hi == 0) r = color (v, t, p); + else if (hi == 1) r = color (q, v, p); + else if (hi == 2) r = color (p, v, t); + else if (hi == 3) r = color (p, q, v); + else if (hi == 4) r = color (t, p, v); + else r = color (v, p, q); + } + return r; + } + + color hsl_to_rgb (color c) { + float h = c[0], s = c[1], l = c[2]; + // Easiest to convert hsl -> hsv, then hsv -> RGB (per Foley & van Dam) + float v = (l <= 0.5) ? (l * (1 + s)) : (l * (1 - s) + s); + color r; + if (v <= 0) { + r = 0; + } else { + float min = 2 * l - v; + s = (v - min) / v; + r = hsv_to_rgb (color (h, s, v)); + } + return r; + } + + color r; + if (from == "rgb" || from == "RGB") + r = x; + else if (from == "hsv") + r = hsv_to_rgb (x); + else if (from == "hsl") + r = hsl_to_rgb (x); + else if (from == "YIQ") + r = color (dot (vector(1, 0.9557, 0.6199), (vector)x), + dot (vector(1, -0.2716, -0.6469), (vector)x), + dot (vector(1, -1.1082, 1.7051), (vector)x)); + else if (from == "XYZ") + r = color (dot (vector( 3.240479, -1.537150, -0.498535), (vector)x), + dot (vector(-0.969256, 1.875991, 0.041556), (vector)x), + dot (vector( 0.055648, -0.204043, 1.057311), (vector)x)); + else { + error ("Unknown color space \"%s\"", to); + r = x; + } + return transformc (to, r); +} + + + +// Matrix functions + +float determinant (matrix m) BUILTIN; +matrix transpose (matrix m) BUILTIN; + + + +// Pattern generation + +color step (color edge, color x) BUILTIN; +point step (point edge, point x) BUILTIN; +vector step (vector edge, vector x) BUILTIN; +normal step (normal edge, normal x) BUILTIN; +float step (float edge, float x) BUILTIN; +float smoothstep (float edge0, float edge1, float x) BUILTIN; + +color smoothstep (color edge0, color edge1, color in) +{ + return color (smoothstep(edge0[0], edge1[0], in[0]), + smoothstep(edge0[1], edge1[1], in[1]), + smoothstep(edge0[2], edge1[2], in[2])); +} +vector smoothstep (vector edge0, vector edge1, vector in) +{ + return vector (smoothstep(edge0[0], edge1[0], in[0]), + smoothstep(edge0[1], edge1[1], in[1]), + smoothstep(edge0[2], edge1[2], in[2])); +} + +float linearstep (float edge0, float edge1, float x) { + float result; + if (edge0 != edge1) { + float xclamped = clamp (x, edge0, edge1); + result = (xclamped - edge0) / (edge1 - edge0); + } else { // special case: edges coincide + result = step (edge0, x); + } + return result; +} + +float smooth_linearstep (float edge0, float edge1, float x_, float eps_) { + float result; + if (edge0 != edge1) { + float rampup (float x, float r) { return 0.5/r * x*x; } + float width_inv = 1.0 / (edge1 - edge0); + float eps = eps_ * width_inv; + float x = (x_ - edge0) * width_inv; + if (x <= -eps) result = 0; + else if (x >= eps && x <= 1.0-eps) result = x; + else if (x >= 1.0+eps) result = 1; + else if (x < eps) result = rampup (x+eps, 2.0*eps); + else /* if (x < 1.0+eps) */ result = 1.0 - rampup (1.0+eps - x, 2.0*eps); + } else { + result = step (edge0, x_); + } + return result; +} + +float aastep (float edge, float s, float dedge, float ds) { + // Box filtered AA step + float width = fabs(dedge) + fabs(ds); + float halfwidth = 0.5*width; + float e1 = edge-halfwidth; + return (s <= e1) ? 0.0 : ((s >= (edge+halfwidth)) ? 1.0 : (s-e1)/width); +} +float aastep (float edge, float s, float ds) { + return aastep (edge, s, filterwidth(edge), ds); +} +float aastep (float edge, float s) { + return aastep (edge, s, filterwidth(edge), filterwidth(s)); +} + + +// Derivatives and area operators + + +// Displacement functions + + +// String functions +int strlen (string s) BUILTIN; +int hash (string s) BUILTIN; +int getchar (string s, int index) BUILTIN; +int startswith (string s, string prefix) BUILTIN; +int endswith (string s, string suffix) BUILTIN; +string substr (string s, int start, int len) BUILTIN; +string substr (string s, int start) { return substr (s, start, strlen(s)); } +float stof (string str) BUILTIN; +int stoi (string str) BUILTIN; + +// Define concat in terms of shorter concat +string concat (string a, string b, string c) { + return concat(concat(a,b), c); +} +string concat (string a, string b, string c, string d) { + return concat(concat(a,b,c), d); +} +string concat (string a, string b, string c, string d, string e) { + return concat(concat(a,b,c,d), e); +} +string concat (string a, string b, string c, string d, string e, string f) { + return concat(concat(a,b,c,d,e), f); +} + + +// Texture + + +// Closures + +closure color emission() BUILTIN; +closure color background() BUILTIN; +closure color diffuse(normal N) BUILTIN; +closure color oren_nayar(normal N, float sigma) BUILTIN; +closure color oren_nayar(normal N) { return oren_nayar(N, 0.0); } +closure color translucent(normal N, float sigma) BUILTIN; +closure color translucent(normal N) { return translucent(N, 0.0); } +#if 0 // arnold doesn't support these +closure color phong(normal N, float exponent) BUILTIN; +closure color ward(normal N, vector T,float ax, float ay) BUILTIN; +#endif +closure color microfacet(string distribution, normal N, vector U, float xalpha, + float yalpha, float eta, int refract) BUILTIN; +closure color microfacet(string distribution, normal N, float alpha, float eta, + int refr) +{ + return microfacet(distribution, N, vector(0), alpha, alpha, eta, refr); +} +closure color reflection(normal N, float eta) BUILTIN; +closure color reflection(normal N) { return reflection (N, 0.0); } +closure color refraction(normal N, float eta) BUILTIN; +closure color transparent() BUILTIN; +closure color debug(string tag) BUILTIN; +closure color holdout() BUILTIN; +#if 1 // Arnold specific +closure color empirical_bssrdf(vector mfp, color albedo) BUILTIN; +closure color randomwalk_bssrdf(vector mfp, color albedo, float g) BUILTIN; +closure color volume_absorption() BUILTIN; +closure color volume_emission() BUILTIN; +closure color volume_henyey_greenstein(color absorption, color scattering, + color emission, float g) BUILTIN; +closure color volume_matte() BUILTIN; +#else // arnold doesn't support these +closure color subsurface(float eta, float g, color mfp, color albedo) BUILTIN; +#endif + +// Renderer state +int backfacing () BUILTIN; +int raytype (string typename) BUILTIN; +// the individual 'isFOOray' functions are deprecated +int iscameraray () { return raytype("camera"); } +int isdiffuseray () { return raytype("diffuse"); } +int isglossyray () { return raytype("glossy"); } +int isshadowray () { return raytype("shadow"); } +int getmatrix (string fromspace, string tospace, output matrix M) BUILTIN; +int getmatrix (string fromspace, output matrix M) { + return getmatrix (fromspace, "common", M); +} + + +// Miscellaneous + + + + +#undef BUILTIN +#undef BUILTIN_DERIV +#undef PERCOMP1 +#undef PERCOMP2 +#undef PERCOMP2F + +#endif /* STDOSL_H */ diff --git a/materialx/libraries/stdlib/osl/vector2.h b/materialx/libraries/stdlib/osl/vector2.h new file mode 100644 index 000000000..1307ab40a --- /dev/null +++ b/materialx/libraries/stdlib/osl/vector2.h @@ -0,0 +1,326 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE + +#pragma once +#define VECTOR2_H + +// vector2 is a 2D vector +struct vector2 +{ + float x; + float y; +}; + + + +// +// For vector2, define math operators to match vector +// + +vector2 __operator__neg__(vector2 a) +{ + return vector2(-a.x, -a.y); +} + +vector2 __operator__add__(vector2 a, vector2 b) +{ + return vector2(a.x + b.x, a.y + b.y); +} + +vector2 __operator__add__(vector2 a, int b) +{ + return a + vector2(b, b); +} + +vector2 __operator__add__(vector2 a, float b) +{ + return a + vector2(b, b); +} + +vector2 __operator__add__(int a, vector2 b) +{ + return vector2(a, a) + b; +} + +vector2 __operator__add__(float a, vector2 b) +{ + return vector2(a, a) + b; +} + +vector2 __operator__sub__(vector2 a, vector2 b) +{ + return vector2(a.x - b.x, a.y - b.y); +} + +vector2 __operator__sub__(vector2 a, int b) +{ + return a - vector2(b, b); +} + +vector2 __operator__sub__(vector2 a, float b) +{ + return a - vector2(b, b); +} + +vector2 __operator__sub__(int a, vector2 b) +{ + return vector2(a, a) - b; +} + +vector2 __operator__sub__(float a, vector2 b) +{ + return vector2(a, a) - b; +} + +vector2 __operator__mul__(vector2 a, vector2 b) +{ + return vector2(a.x * b.x, a.y * b.y); +} + +vector2 __operator__mul__(vector2 a, int b) +{ + return a * vector2(b, b); +} + +vector2 __operator__mul__(vector2 a, float b) +{ + return a * vector2(b, b); +} + +vector2 __operator__mul__(int a, vector2 b) +{ + return b * vector2(a, a); +} + +vector2 __operator__mul__(float a, vector2 b) +{ + return b * vector2(a, a); +} + +vector2 __operator__div__(vector2 a, vector2 b) +{ + return vector2(a.x / b.x, a.y / b.y); +} + +vector2 __operator__div__(vector2 a, int b) +{ + float b_inv = 1.0/b; + return a * vector2(b_inv, b_inv); +} + +vector2 __operator__div__(vector2 a, float b) +{ + float b_inv = 1.0/b; + return a * vector2(b_inv, b_inv); +} + +vector2 __operator__div__(int a, vector2 b) +{ + return vector2(a, a) / b; +} + +vector2 __operator__div__(float a, vector2 b) +{ + return vector2(a, a) / b; +} + +int __operator__eq__(vector2 a, vector2 b) +{ + return (a.x == b.x) && (a.y == b.y); +} + +int __operator__ne__(vector2 a, vector2 b) +{ + return (a.x != b.x) || (a.y != b.y); +} + + + + +// +// For vector2, define most of the stdosl functions to match vector +// + +vector2 abs(vector2 a) +{ + return vector2 (abs(a.x), abs(a.y)); +} + +vector2 ceil(vector2 a) +{ + return vector2 (ceil(a.x), ceil(a.y)); +} + +vector2 floor(vector2 a) +{ + return vector2 (floor(a.x), floor(a.y)); +} + +vector2 sqrt(vector2 a) +{ + return vector2 (sqrt(a.x), sqrt(a.y)); +} + +vector2 exp(vector2 a) +{ + return vector2 (exp(a.x), exp(a.y)); +} + +vector2 log(vector2 a) +{ + return vector2 (log(a.x), log(a.y)); +} + +vector2 log2(vector2 a) +{ + return vector2 (log2(a.x), log2(a.y)); +} + +vector2 mix(vector2 a, vector2 b, float x ) +{ + return vector2 (mix(a.x, b.x, x), mix(a.y, b.y, x)); +} + +float dot(vector2 a, vector2 b) +{ + return (a.x * b.x + a.y * b.y); +} + +float length (vector2 a) +{ + return hypot (a.x, a.y); +} + +vector2 smoothstep(vector2 low, vector2 high, vector2 in) +{ + return vector2 (smoothstep(low.x, high.x, in.x), + smoothstep(low.y, high.y, in.y)); +} + +vector2 smoothstep(float low, float high, vector2 in) +{ + return vector2 (smoothstep(low, high, in.x), + smoothstep(low, high, in.y)); +} + +vector2 clamp(vector2 in, vector2 low, vector2 high) +{ + return vector2 (clamp(in.x, low.x, high.x), + clamp(in.y, low.y, high.y)); +} + +vector2 clamp(vector2 in, float low, float high) +{ + return clamp(in, vector2(low, low), vector2(high, high)); +} + +vector2 max(vector2 a, vector2 b) +{ + return vector2 (max(a.x, b.x), + max(a.y, b.y)); +} + +vector2 max(vector2 a, float b) +{ + return max(a, vector2(b, b)); +} + +vector2 normalize(vector2 a) +{ + return a / length(a); +} + +vector2 min(vector2 a, vector2 b) +{ + return vector2 (min(a.x, a.x), + min(b.y, b.y)); +} + +vector2 min(vector2 a, float b) +{ + return min(a, vector2(b, b)); +} + +vector2 mod(vector2 a, vector2 b) +{ + return vector2(mod(a.x, b.x), + mod(a.y, b.y)); +} + +vector2 mod(vector2 a, float b) +{ + return mod(a, vector2(b, b)); +} + +vector2 fmod(vector2 a, vector2 b) +{ + return vector2 (fmod(a.x, b.x), + fmod(a.y, b.y)); +} + +vector2 fmod(vector2 a, float b) +{ + return fmod(a, vector2(b, b)); +} + +vector2 pow(vector2 in, vector2 amount) +{ + return vector2(pow(in.x, amount.x), + pow(in.y, amount.y)); +} + +vector2 pow(vector2 in, float amount) +{ + return vector2(pow(in.x, amount), + pow(in.y, amount)); +} + +vector2 sign(vector2 a) +{ + return vector2(sign(a.x), + sign(a.y)); +} + +vector2 sin(vector2 a) +{ + return vector2(sin(a.x), + sin(a.y)); +} + +vector2 cos(vector2 a) +{ + return vector2(cos(a.x), + cos(a.y)); +} + +vector2 tan(vector2 a) +{ + return vector2(tan(a.x), + tan(a.y)); +} + +vector2 asin(vector2 a) +{ + return vector2(asin(a.x), + asin(a.y)); +} + +vector2 acos(vector2 a) +{ + return vector2(acos(a.x), + acos(a.y)); +} + +vector2 atan2(vector2 a, float f) +{ + return vector2(atan2(a.x, f), + atan2(a.y, f)); +} + +vector2 atan2(vector2 a, vector2 b) +{ + return vector2(atan2(a.x, b.x), + atan2(a.y, b.y)); +} + + diff --git a/materialx/libraries/stdlib/osl/vector4.h b/materialx/libraries/stdlib/osl/vector4.h new file mode 100644 index 000000000..ee3659735 --- /dev/null +++ b/materialx/libraries/stdlib/osl/vector4.h @@ -0,0 +1,407 @@ +// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. +// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE + +#pragma once +#define VECTOR4_H + + +// vector4 is a 4D vector +struct vector4 +{ + float x; + float y; + float z; + float w; +}; + + + +// +// For vector4, define math operators to match vector +// + +vector4 __operator__neg__(vector4 a) +{ + return vector4(-a.x, -a.y, -a.z, -a.w); +} + +vector4 __operator__add__(vector4 a, vector4 b) +{ + return vector4(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w); +} + +vector4 __operator__add__(vector4 a, int b) +{ + return a + vector4(b, b, b, b); +} + +vector4 __operator__add__(vector4 a, float b) +{ + return a + vector4(b, b, b, b); +} + +vector4 __operator__add__(int a, vector4 b) +{ + return vector4(a, a, a, a) + b; +} + +vector4 __operator__add__(float a, vector4 b) +{ + return vector4(a, a, a, a) + b; +} + +vector4 __operator__sub__(vector4 a, vector4 b) +{ + return vector4(a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w); +} + +vector4 __operator__sub__(vector4 a, int b) +{ + return a - vector4(b, b, b, b); +} + +vector4 __operator__sub__(vector4 a, float b) +{ + return a - vector4(b, b, b, b); +} + +vector4 __operator__sub__(int a, vector4 b) +{ + return vector4(a, a, a, a) - b; +} + +vector4 __operator__sub__(float a, vector4 b) +{ + return vector4(a, a, a, a) - b; +} + +vector4 __operator__mul__(vector4 a, vector4 b) +{ + return vector4(a.x * b.x, a.y * b.y, a.z * b.z, a.w * b.w); +} + +vector4 __operator__mul__(vector4 a, int b) +{ + return a * vector4(b, b, b, b); +} + +vector4 __operator__mul__(vector4 a, float b) +{ + return a * vector4(b, b, b, b); +} + +vector4 __operator__mul__(int a, vector4 b) +{ + return vector4(a, a, a, a) * b; +} + +vector4 __operator__mul__(float a, vector4 b) +{ + return vector4(a, a, a, a) * b; +} + +vector4 __operator__div__(vector4 a, vector4 b) +{ + return vector4(a.x / b.x, a.y / b.y, a.z / b.z, a.w / b.w); +} + +vector4 __operator__div__(vector4 a, int b) +{ + float b_inv = 1.0/b; + return a * vector4(b_inv, b_inv, b_inv, b_inv); +} + +vector4 __operator__div__(vector4 a, float b) +{ + float b_inv = 1.0/b; + return a * vector4(b_inv, b_inv, b_inv, b_inv); +} + +vector4 __operator__div__(int a, vector4 b) +{ + return vector4(a, a, a, a) / b; +} + +vector4 __operator__div__(float a, vector4 b) +{ + return vector4(a, a, a, a) / b; +} + +int __operator__eq__(vector4 a, vector4 b) +{ + return (a.x == b.x) && (a.y == b.y) && (a.z == b.z) && (a.w == b.w); +} + +int __operator__ne__(vector4 a, vector4 b) +{ + return (a.x != b.x) || (a.y != b.y) || (a.z != b.z) || (a.w != b.w); +} + + + + +// +// For vector4, define most of the stdosl functions to match vector +// + +vector4 abs(vector4 in) +{ + return vector4 (abs(in.x), + abs(in.y), + abs(in.z), + abs(in.w)); +} + +vector4 ceil(vector4 in) +{ + return vector4 (ceil(in.x), + ceil(in.y), + ceil(in.z), + ceil(in.w)); +} + +vector4 floor(vector4 in) +{ + return vector4 (floor(in.x), + floor(in.y), + floor(in.z), + floor(in.w)); +} + +vector4 sqrt(vector4 in) +{ + return vector4 (sqrt(in.x), + sqrt(in.y), + sqrt(in.z), + sqrt(in.w)); +} + +vector4 exp(vector4 in) +{ + return vector4 (exp(in.x), + exp(in.y), + exp(in.z), + exp(in.w)); +} + +vector4 log(vector4 in) +{ + return vector4 (log(in.x), + log(in.y), + log(in.z), + log(in.w)); +} + +vector4 log2(vector4 in) +{ + return vector4 (log2(in.x), + log2(in.y), + log2(in.z), + log2(in.w)); +} + +vector4 mix(vector4 value1, vector4 value2, float x ) +{ + return vector4 (mix( value1.x, value2.x, x), + mix( value1.y, value2.y, x), + mix( value1.z, value2.z, x), + mix( value1.w, value2.w, x)); +} + +vector vec4ToVec3(vector4 v) +{ + return vector(v.x, v.y, v.z) / v.w; +} + +float dot(vector4 a, vector4 b) +{ + return ((a.x * b.x) + (a.y * b.y) + (a.z * b.z) + (a.w * b.w)); +} + +float length (vector4 a) +{ + return sqrt (a.x*a.x + a.y*a.y + a.z*a.z + a.w*a.w); +} + +vector4 smoothstep(vector4 low, vector4 high, vector4 in) +{ + return vector4 (smoothstep(low.x, high.x, in.x), + smoothstep(low.y, high.y, in.y), + smoothstep(low.z, high.z, in.z), + smoothstep(low.w, high.w, in.w)); +} + +vector4 smoothstep(float low, float high, vector4 in) +{ + return vector4 (smoothstep(low, high, in.x), + smoothstep(low, high, in.y), + smoothstep(low, high, in.z), + smoothstep(low, high, in.w)); +} + +vector4 clamp(vector4 in, vector4 low, vector4 high) +{ + return vector4 (clamp(in.x, low.x, high.x), + clamp(in.y, low.y, high.y), + clamp(in.z, low.z, high.z), + clamp(in.w, low.w, high.w)); +} + +vector4 clamp(vector4 in, float low, float high) +{ + return vector4 (clamp(in.x, low, high), + clamp(in.y, low, high), + clamp(in.z, low, high), + clamp(in.w, low, high)); +} + +vector4 max(vector4 a, vector4 b) +{ + return vector4 (max(a.x, b.x), + max(a.y, b.y), + max(a.z, b.z), + max(a.w, b.w)); +} + +vector4 max(vector4 a, float b) +{ + return max(a, vector4(b, b, b, b)); +} + +vector4 normalize(vector4 a) +{ + return a / length(a); +} + +vector4 min(vector4 a, vector4 b) +{ + return vector4 (min(a.x, b.x), + min(a.y, b.y), + min(a.z, b.z), + min(a.w, b.w)); +} + +vector4 min(vector4 a, float b) +{ + return min(a, vector4(b, b, b, b)); +} + +vector4 mod(vector4 a, vector4 b) +{ + return vector4(mod(a.x, b.x), + mod(a.y, b.y), + mod(a.z, b.z), + mod(a.w, b.w)); +} + +vector4 mod(vector4 a, float b) +{ + return mod(a, vector4(b, b, b, b)); +} + +vector4 fmod(vector4 a, vector4 b) +{ + return vector4 (fmod(a.x, b.x), + fmod(a.y, b.y), + fmod(a.z, b.z), + fmod(a.w, b.w)); +} + +vector4 fmod(vector4 a, float b) +{ + return fmod(a, vector4(b, b, b, b)); +} + +vector4 pow(vector4 in, vector4 amount) +{ + return vector4 (pow(in.x, amount.x), + pow(in.y, amount.y), + pow(in.z, amount.z), + pow(in.w, amount.w)); +} + +vector4 pow(vector4 in, float amount) +{ + return vector4 (pow(in.x, amount), + pow(in.y, amount), + pow(in.z, amount), + pow(in.w, amount)); +} + +vector4 sign(vector4 a) +{ + return vector4(sign(a.x), + sign(a.y), + sign(a.z), + sign(a.w)); +} + +vector4 sin(vector4 a) +{ + return vector4(sin(a.x), + sin(a.y), + sin(a.z), + sin(a.w)); +} + +vector4 cos(vector4 a) +{ + return vector4(cos(a.x), + cos(a.y), + cos(a.z), + cos(a.w)); +} + +vector4 tan(vector4 a) +{ + return vector4(tan(a.x), + tan(a.y), + tan(a.z), + tan(a.w)); +} + +vector4 asin(vector4 a) +{ + return vector4(asin(a.x), + asin(a.y), + asin(a.z), + asin(a.w)); +} + +vector4 acos(vector4 a) +{ + return vector4(acos(a.x), + acos(a.y), + acos(a.z), + acos(a.w)); +} + +vector4 atan2(vector4 a, float f) +{ + return vector4(atan2(a.x, f), + atan2(a.y, f), + atan2(a.z, f), + atan2(a.w, f)); +} + +vector4 atan2(vector4 a, vector4 b) +{ + return vector4(atan2(a.x, b.x), + atan2(a.y, b.y), + atan2(a.z, b.z), + atan2(a.w, b.w)); +} + + +vector4 transform (matrix M, vector4 p) +{ + return vector4 (M[0][0]*p.x + M[0][1]*p.y + M[0][2]*p.z + M[0][3]*p.w, + M[1][0]*p.x + M[1][1]*p.y + M[1][2]*p.z + M[1][3]*p.w, + M[2][0]*p.x + M[2][1]*p.y + M[2][2]*p.z + M[2][3]*p.w, + M[3][0]*p.x + M[3][1]*p.y + M[3][2]*p.z + M[3][3]*p.w); +} + +vector4 transform (string fromspace, string tospace, vector4 p) +{ + return transform (matrix(fromspace,tospace), p); +} diff --git a/materialx/libraries/stdlib/stdlib_defs.mtlx b/materialx/libraries/stdlib/stdlib_defs.mtlx new file mode 100644 index 000000000..a18fcd7d2 --- /dev/null +++ b/materialx/libraries/stdlib/stdlib_defs.mtlx @@ -0,0 +1,4210 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/materialx/libraries/stdlib/stdlib_ng.mtlx b/materialx/libraries/stdlib/stdlib_ng.mtlx new file mode 100644 index 000000000..7dd8a262f --- /dev/null +++ b/materialx/libraries/stdlib/stdlib_ng.mtlx @@ -0,0 +1,2070 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/materialx/libraries/targets/genglsl.mtlx b/materialx/libraries/targets/genglsl.mtlx new file mode 100644 index 000000000..e53218ada --- /dev/null +++ b/materialx/libraries/targets/genglsl.mtlx @@ -0,0 +1,14 @@ + + + + + + + + + + + diff --git a/materialx/libraries/targets/genmdl.mtlx b/materialx/libraries/targets/genmdl.mtlx new file mode 100644 index 000000000..60da62e20 --- /dev/null +++ b/materialx/libraries/targets/genmdl.mtlx @@ -0,0 +1,14 @@ + + + + + + + + + + + diff --git a/materialx/libraries/targets/genosl.mtlx b/materialx/libraries/targets/genosl.mtlx new file mode 100644 index 000000000..6a9ec43b4 --- /dev/null +++ b/materialx/libraries/targets/genosl.mtlx @@ -0,0 +1,14 @@ + + + + + + + + + + + diff --git a/materialx/logging.py b/materialx/logging.py new file mode 100644 index 000000000..3d0688123 --- /dev/null +++ b/materialx/logging.py @@ -0,0 +1,67 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright 2022, AMD + +import sys +import logging.handlers + +from . import ADDON_PREFIX + + +FORMAT_STR = "%(asctime)s %(levelname)s %(name)s [%(thread)d]: %(message)s" + +# root logger for the addon +logger = logging.getLogger(ADDON_PREFIX) +logger.setLevel('DEBUG') + +# file_handler = logging.handlers.RotatingFileHandler(PLUGIN_ROOT_DIR / 'usdhydra.log', +# mode='w', encoding='utf-8', delay=True, +# backupCount=config.logging_backups) +# file_handler.doRollover() +# file_handler.setFormatter(logging.Formatter(FORMAT_STR)) +# logger.addHandler(file_handler) + +console_handler = logging.StreamHandler(stream=sys.stdout) +console_handler.setFormatter(logging.Formatter(FORMAT_STR)) +logger.addHandler(console_handler) + + +def msg(args): + return ", ".join(str(arg) for arg in args) + + +class Log: + def __init__(self, tag): + self.logger = logger.getChild(tag) + + def __call__(self, *args): + self.debug(*args) + + def debug(self, *args): + self.logger.debug(msg(args)) + + def info(self, *args): + self.logger.info(msg(args)) + + def warn(self, *args): + self.logger.warning(msg(args)) + + def error(self, *args): + self.logger.error(msg(args)) + + def critical(self, *args): + self.logger.critical(msg(args)) + + def dump_args(self, func): + """This decorator dumps out the arguments passed to a function before calling it""" + arg_names = func.__code__.co_varnames[:func.__code__.co_argcount] + + def echo_func(*args, **kwargs): + self.debug("<{}>: {}{}".format( + func.__name__, + tuple("{}={}".format(name, arg) for name, arg in zip(arg_names, args)), + # args if args else "", + " {}".format(kwargs.items()) if kwargs else "", + )) + return func(*args, **kwargs) + + return echo_func diff --git a/materialx/node_tree.py b/materialx/node_tree.py new file mode 100644 index 000000000..ee4c57f69 --- /dev/null +++ b/materialx/node_tree.py @@ -0,0 +1,277 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright 2022, AMD + +import MaterialX as mx + +import bpy + +from . import utils + +from . import logging +log = logging.Log('node_tree') + + +NODE_LAYER_SEPARATION_WIDTH = 280 +NODE_LAYER_SHIFT_X = 30 +NODE_LAYER_SHIFT_Y = 100 +AREA_TO_UPDATE = 'PROPERTIES' +REGION_TO_UPDATE = 'WINDOW' + + +class MxNodeTree(bpy.types.ShaderNodeTree): + """ + MaterialX NodeTree + """ + bl_label = "MaterialX" + bl_icon = "NODE_MATERIAL" + bl_idname = utils.with_prefix("MxNodeTree") + + _do_update = True + + @property + def output_node(self): + return next((node for node in self.nodes + if node.bl_idname == utils.with_prefix('MxNode_STD_surfacematerial')), None) + + @property + def output_node_volume(self): + return next((node for node in self.nodes + if node.bl_idname == utils.with_prefix('MxNode_STD_volumematerial')), None) + + def no_update_call(self, op, *args, **kwargs): + """This function prevents call of self.update() during calling our function""" + if not self._do_update: + return op(*args, **kwargs) + + self._do_update = False + try: + return op(*args, **kwargs) + finally: + self._do_update = True + + def export(self) -> mx.Document: + output_node = self.output_node + if not output_node: + return None + + doc = mx.createDocument() + + surfacematerial = output_node.compute(0, doc=doc) + if not surfacematerial: + return None + + return doc + + def import_(self, doc: mx.Document, file_path): + def prepare_for_import(): + surfacematerial = next( + (n for n in doc.getNodes() if n.getCategory() == 'surfacematerial'), None) + if surfacematerial: + return + + mat = doc.getMaterials()[0] + sr = mat.getShaderRefs()[0] + + doc.removeMaterial(mat.getName()) + + node_name = sr.getName() + if not node_name.startswith("SR_"): + node_name = f"SR_{node_name}" + node = doc.addNode(sr.getNodeString(), node_name, 'surfaceshader') + for sr_input in sr.getBindInputs(): + input = node.addInput(sr_input.getName(), sr_input.getType()) + ng_name = sr_input.getNodeGraphString() + if ng_name: + input.setAttribute('nodegraph', ng_name) + input.setAttribute('output', sr_input.getOutputString()) + else: + input.setValue(sr_input.getValue()) + + surfacematerial = doc.addNode('surfacematerial', mat.getName(), 'material') + input = surfacematerial.addInput('surfaceshader', node.getType()) + input.setNodeName(node.getName()) + + def do_import(): + from .nodes import get_mx_node_cls + + self.nodes.clear() + + def import_node(mx_node, mx_output_name=None, look_nodedef=True): + mx_nodegraph = mx_node.getParent() + node_path = mx_node.getNamePath() + file_prefix = utils.get_file_prefix(mx_node, file_path) + + if node_path in self.nodes: + return self.nodes[node_path] + + try: + MxNode_cls, data_type = get_mx_node_cls(mx_node) + + except KeyError as e: + if not look_nodedef: + log.warn(e) + return None + + # looking for nodedef and switching to another nodegraph defined in doc + nodedef = next(nd for nd in doc.getNodeDefs() + if nd.getNodeString() == mx_node.getCategory() and + nd.getType() == mx_node.getType()) + new_mx_nodegraph = next(ng for ng in doc.getNodeGraphs() + if ng.getNodeDefString() == nodedef.getName()) + + mx_output = new_mx_nodegraph.getOutput(mx_output_name) + node_name = mx_output.getNodeName() + new_mx_node = new_mx_nodegraph.getNode(node_name) + + return import_node(new_mx_node, None, False) + + node = self.nodes.new(MxNode_cls.bl_idname) + node.name = node_path + node.data_type = data_type + nodedef = node.nodedef + + for mx_input in mx_node.getInputs(): + input_name = mx_input.getName() + nd_input = nodedef.getInput(input_name) + if nd_input.getAttribute('uniform') == 'true': + node.set_param_value(input_name, utils.parse_value( + node, mx_input.getValue(), mx_input.getType(), file_prefix)) + continue + + if input_name not in node.inputs: + log.error(f"Incorrect input name '{input_name}' for node {node}") + continue + + val = mx_input.getValue() + if val is not None: + node.set_input_value(input_name, utils.parse_value( + node, val, mx_input.getType(), file_prefix)) + continue + + node_name = mx_input.getNodeName() + + if node_name: + new_mx_node = mx_nodegraph.getNode(node_name) + if not new_mx_node: + log.error(f"Couldn't find node '{node_name}' in nodegraph '{mx_nodegraph.getNamePath()}'") + continue + + new_node = import_node(new_mx_node) + + out_name = mx_input.getAttribute('output') + if len(new_node.nodedef.getOutputs()) > 1 and out_name: + new_node_output = new_node.outputs[out_name] + else: + new_node_output = new_node.outputs[0] + + self.links.new(new_node_output, node.inputs[input_name]) + continue + + new_nodegraph_name = mx_input.getAttribute('nodegraph') + if new_nodegraph_name: + mx_output_name = mx_input.getAttribute('output') + new_mx_nodegraph = mx_nodegraph.getNodeGraph(new_nodegraph_name) + mx_output = new_mx_nodegraph.getOutput(mx_output_name) + node_name = mx_output.getNodeName() + new_mx_node = new_mx_nodegraph.getNode(node_name) + new_node = import_node(new_mx_node, mx_output_name) + if not new_node: + continue + + out_name = mx_output.getAttribute('output') + if len(new_node.nodedef.getOutputs()) > 1 and out_name: + new_node_output = new_node.outputs[out_name] + else: + new_node_output = new_node.outputs[0] + + self.links.new(new_node_output, node.inputs[input_name]) + continue + + node.check_ui_folders() + return node + + mx_node = next(n for n in doc.getNodes() if n.getCategory() == 'surfacematerial') + output_node = import_node(mx_node, 0) + + if not output_node: + return + + # arranging nodes by layers + layer = {output_node} + layer_index = 0 + layers = {} + while layer: + new_layer = set() + for node in layer: + layers[node] = layer_index + for inp in node.inputs: + for link in inp.links: + new_layer.add(link.from_node) + layer = new_layer + layer_index += 1 + + node_layers = [[] for _ in range(max(layers.values()) + 1)] + for node in self.nodes: + node_layers[layers[node]].append(node) + + # placing nodes by layers + loc_x = 0 + for i, nodes in enumerate(node_layers): + loc_y = 0 + for node in nodes: + node.location = (loc_x, loc_y) + loc_y -= NODE_LAYER_SHIFT_Y + loc_x -= NODE_LAYER_SHIFT_X + + loc_x -= NODE_LAYER_SEPARATION_WIDTH + + prepare_for_import() + self.no_update_call(do_import) + self.update_() + + def create_basic_nodes(self, node_name='PBR_standard_surface'): + """ Reset basic node tree structure using scene or USD file as an input """ + def create_nodes(): + self.nodes.clear() + + mat_node = self.nodes.new(utils.with_prefix('MxNode_STD_surfacematerial')) + node = self.nodes.new(utils.with_prefix(f'MxNode_{node_name}')) + node.location = (mat_node.location[0] - NODE_LAYER_SEPARATION_WIDTH, + mat_node.location[1]) + self.links.new(node.outputs[0], mat_node.inputs[0]) + + self.no_update_call(create_nodes) + self.update_() + + # this is called from Blender + def update(self): + if not self._do_update: + return + + self.update_() + + def update_(self): + self.update_links() + + # TODO: Uncomment + # for material in bpy.data.materials: + # if material.hdusd.mx_node_tree and material.hdusd.mx_node_tree.name == self.name: + # material.hdusd.update() + + for window in bpy.context.window_manager.windows: + for area in window.screen.areas: + if area.type == AREA_TO_UPDATE: + for region in area.regions: + if region.type == REGION_TO_UPDATE: + region.tag_redraw() + + def update_links(self): + for link in self.links: + socket_from_type = link.from_socket.node.nodedef.getOutput(link.from_socket.name).getType() + socket_to_type = link.to_socket.node.nodedef.getInput(link.to_socket.name).getType() + + if socket_to_type != socket_from_type: + link.is_valid = False + continue + + link.is_valid = True diff --git a/materialx/nodes/.gitignore b/materialx/nodes/.gitignore new file mode 100644 index 000000000..625db102a --- /dev/null +++ b/materialx/nodes/.gitignore @@ -0,0 +1 @@ +gen_*.py diff --git a/materialx/nodes/__init__.py b/materialx/nodes/__init__.py new file mode 100644 index 000000000..d2eaae1fc --- /dev/null +++ b/materialx/nodes/__init__.py @@ -0,0 +1,80 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright 2022, AMD + +import importlib +from pathlib import Path + +import bpy +import nodeitems_utils + +from . import node, categories, generate_node_classes, ui +from ..utils import with_prefix + +generate_node_classes.generate_basic_classes() + +gen_modules = [importlib.import_module(f"materialx.nodes.{f.name[:-len(f.suffix)]}") + for f in Path(__file__).parent.glob("gen_*.py")] + +mx_node_classes = [] +for mod in gen_modules: + mx_node_classes.extend(mod.mx_node_classes) + +# sorting by category and label +mx_node_classes = sorted(mx_node_classes, key=lambda cls: (cls.category.lower(), cls.bl_label.lower())) + + +register_sockets, unregister_sockets = bpy.utils.register_classes_factory([ + node.MxNodeInputSocket, + node.MxNodeOutputSocket, +]) +register_ui, unregister_ui = bpy.utils.register_classes_factory([ + ui.NODES_OP_import_file, + ui.NODES_OP_export_file, + ui.NODES_OP_export_console, + ui.NODES_OP_create_basic_nodes, + ui.NODES_PT_tools, + ui.NODES_PT_dev, +]) + +register_nodes, unregister_nodes = bpy.utils.register_classes_factory(mx_node_classes) + + +def register(): + register_sockets() + register_ui() + register_nodes() + + nodeitems_utils.register_node_categories(with_prefix("MX_NODES"), categories.get_node_categories()) + + +def unregister(): + nodeitems_utils.unregister_node_categories(with_prefix("MX_NODES")) + + unregister_nodes() + unregister_ui() + unregister_sockets() + + +def get_mx_node_cls(mx_node): + node_name = mx_node.getCategory() + + suffix = f'_{node_name}' + classes = tuple(cls for cls in mx_node_classes if cls.__name__.endswith(suffix)) + if not classes: + raise KeyError(f"Unable to find MxNode class for {mx_node}") + + def params_set(node, out_type): + return {f"in_{p.getName()}:{p.getType()}" for p in node.getInputs()} | \ + {out_type} + + node_params_set = params_set(mx_node, mx_node.getType()) + + for cls in classes: + for nodedef, data_type in cls.get_nodedefs(): + nd_outputs = nodedef.getOutputs() + nd_params_set = params_set(nodedef, 'multioutput' if len(nd_outputs) > 1 else + nd_outputs[0].getType()) + if node_params_set.issubset(nd_params_set): + return cls, data_type + + raise TypeError(f"Unable to find suitable nodedef for {mx_node}") diff --git a/materialx/nodes/categories.py b/materialx/nodes/categories.py new file mode 100644 index 000000000..2ff2c6863 --- /dev/null +++ b/materialx/nodes/categories.py @@ -0,0 +1,47 @@ +# ********************************************************************** +# Copyright 2020 Advanced Micro Devices, Inc +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ******************************************************************** +from collections import defaultdict + +from nodeitems_utils import NodeCategory, NodeItem + +from ..utils import title_str, code_str, with_prefix + + +class MxNodeCategory(NodeCategory): + @classmethod + def poll(cls, context): + return context.space_data.tree_type == with_prefix('MxNodeTree') + + +def get_node_categories(): + from . import mx_node_classes + + d = defaultdict(list) + for MxNode_cls in mx_node_classes: + d[MxNode_cls.category].append(MxNode_cls) + + categories = [] + for category, category_classes in d.items(): + categories.append( + MxNodeCategory(with_prefix(code_str(category), '_MX_NG_'), title_str(category), + items=[NodeItem(MxNode_cls.bl_idname) + for MxNode_cls in category_classes])) + + categories.append( + MxNodeCategory(with_prefix('LAYOUT', '_MX_NG_'), 'Layout', + items=[NodeItem("NodeFrame"), + NodeItem("NodeReroute")])) + + return categories diff --git a/materialx/nodes/generate_node_classes.py b/materialx/nodes/generate_node_classes.py new file mode 100644 index 000000000..f7e786bd0 --- /dev/null +++ b/materialx/nodes/generate_node_classes.py @@ -0,0 +1,334 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright 2022, AMD + +import re +from collections import defaultdict + +import MaterialX as mx + +from .. import utils + +from .. import logging +log = logging.Log("nodes.generate_node_classes") + + +def parse_value_str(val_str, mx_type, *, first_only=False, is_enum=False): + if mx_type == 'string': + if is_enum: + res = tuple(x.strip() for x in val_str.split(',')) + return res[0] if first_only else res + return val_str + + if mx_type == 'integer': + return int(val_str) + if mx_type in ('float', 'angle'): + return float(val_str) + if mx_type == 'boolean': + return val_str == "true" + if mx_type.endswith('array'): + return val_str + + if mx_type.startswith('color') or mx_type.startswith('vector') or mx_type.startswith('matrix'): + res = tuple(float(x) for x in val_str.split(',')) + return res[0] if first_only else res + + return val_str + + +def generate_property_code(mx_param, category): + mx_type = mx_param.getType() + prop_attrs = {} + + prop_attrs['name'] = mx_param.getAttribute('uiname') if mx_param.hasAttribute('uiname') \ + else utils.title_str(mx_param.getName()) + + prop_attrs['description'] = mx_param.getAttribute('doc') + + while True: # one way loop just for having break instead using nested 'if else' + if mx_type == 'string': + if mx_param.hasAttribute('enum'): + prop_type = "EnumProperty" + items = parse_value_str(mx_param.getAttribute('enum'), mx_type, is_enum=True) + prop_attrs['items'] = tuple((it, utils.title_str(it), utils.title_str(it)) for it in items) + break + prop_type = "StringProperty" + break + if mx_type == 'filename': + if category in ("texture2d", "texture3d"): + prop_type = "PointerProperty" + break + + prop_type = "StringProperty" + prop_attrs['subtype'] = 'FILE_PATH' + break + if mx_type == 'integer': + prop_type = "IntProperty" + break + if mx_type == 'float': + prop_type = "FloatProperty" + break + if mx_type == 'boolean': + prop_type = "BoolProperty" + break + if mx_type == 'angle': + prop_type = "FloatProperty" + prop_attrs['subtype'] = 'ANGLE' + break + + if mx_type in ('surfaceshader', 'displacementshader', 'volumeshader', 'lightshader', + 'material', 'BSDF', 'VDF', 'EDF'): + prop_type = "StringProperty" + break + + m = re.fullmatch(r'matrix(\d)(\d)', mx_type) + if m: + prop_type = "FloatVectorProperty" + prop_attrs['subtype'] = 'MATRIX' + prop_attrs['size'] = int(m[1]) * int(m[2]) + break + + m = re.fullmatch(r'color(\d)', mx_type) + if m: + prop_type = "FloatVectorProperty" + prop_attrs['subtype'] = 'COLOR' + prop_attrs['size'] = int(m[1]) + prop_attrs['soft_min'] = 0.0 + prop_attrs['soft_max'] = 1.0 + break + + m = re.fullmatch(r'vector(\d)', mx_type) + if m: + prop_type = "FloatVectorProperty" + dim = int(m[1]) + prop_attrs['subtype'] = 'XYZ' if dim == 3 else 'NONE' + prop_attrs['size'] = dim + break + + m = re.fullmatch(r'(.+)array', mx_type) + if m: + prop_type = "StringProperty" + # TODO: Change to CollectionProperty + break + + prop_type = "StringProperty" + log.warn("Unsupported mx_type", mx_type, mx_param, mx_param.getParent().getName()) + break + + for mx_attr, prop_attr in (('uimin', 'min'), ('uimax', 'max'), + ('uisoftmin', 'soft_min'), ('uisoftmax', 'soft_max'), + ('value', 'default')): + if mx_param.hasAttribute(mx_attr): + if prop_attr == 'default' and category in ("texture2d", "texture3d") and mx_type == 'filename': + continue + + prop_attrs[prop_attr] = parse_value_str( + mx_param.getAttribute(mx_attr), mx_type, first_only=mx_attr != 'value') + + prop_attr_strings = [] + for name, val in prop_attrs.items(): + val_str = f'"{val}"' if isinstance(val, str) else str(val) + prop_attr_strings.append(f"{name}={val_str}") + + prop_attr_strings.append("update=MxNode.update_prop") + + if mx_type == 'filename' and category in ("texture2d", "texture3d"): + prop_attr_strings.insert(0, "type=bpy.types.Image") + + return f"{prop_type}({', '.join(prop_attr_strings)})" + + +def get_attr(mx_param, name, else_val=""): + return mx_param.getAttribute(name) if mx_param.hasAttribute(name) else else_val + + +def nodedef_data_type(nodedef): + nd_name = nodedef.getName() + node_name = nodedef.getNodeString() + + if nd_name.startswith('rpr_'): + return nodedef.getOutputs()[0].getType() + + m = re.fullmatch(rf'ND_{node_name}_(.+)', nd_name) + if m: + return m[1] + + return nodedef.getOutputs()[0].getType() + + +def generate_data_type(nodedef): + outputs = nodedef.getOutputs() + if len(outputs) != 1: + return f"{{'multitypes': {{'{nodedef.getName()}': None, 'nodedef_name': '{nodedef.getName()}'}}}}" + + return f"{{'{nodedef.getOutputs()[0].getType()}': {{'{nodedef.getName()}': None, 'nodedef_name': '{nodedef.getName()}'}}}}" + + +def input_prop_name(nd_type, name): + return f'nd_{nd_type}_in_{name}' + + +def output_prop_name(nd_type, name): + return f'nd_{nd_type}_out_{name}' + + +def folder_prop_name(name): + return 'f_' + utils.code_str(name.lower()) + + +def get_mx_node_class_name(nodedef, prefix): + return f"MxNode_{prefix}_{nodedef.getNodeString()}" + + +def generate_mx_node_class_code(nodedefs, prefix, category): + nodedef = nodedefs[0] + if not category: + category = get_attr(nodedef, 'nodegroup', prefix) + + class_name = get_mx_node_class_name(nodedef, prefix) + code_strings = [] + + data_types = {} + for nd in nodedefs: + data_types[nodedef_data_type(nd)] = {'nd_name': nd.getName(), 'nd': None } + + code_strings.append( +f""" +class {class_name}(MxNode): + _file_path = FILE_PATH + _data_types = {data_types} + + bl_label = '{get_attr(nodedef, 'uiname', utils.title_str(nodedef.getNodeString()))}' + bl_idname = '{utils.with_prefix(class_name)}' + bl_description = "{get_attr(nodedef, 'doc')}" + + category = '{category}' +""") + + ui_folders = [] + for mx_param in [*nodedef.getParameters(), *nodedef.getInputs()]: + f = mx_param.getAttribute("uifolder") + if f and f not in ui_folders: + ui_folders.append(f) + + if len(ui_folders) > 2 or category in ("texture2d", "texture3d"): + code_strings += [" bl_width_default = 250", ""] + + if ui_folders: + code_strings.append(f" _ui_folders = {tuple(ui_folders)}") + + data_type_items = [] + index_default = 0 + for i, nd in enumerate(nodedefs): + nd_type = nodedef_data_type(nd) + + data_type_items.append((nd_type, utils.title_str(nd_type), utils.title_str(nd_type))) + if nd_type == 'color3': + index_default = i + + code_strings += [ + f' data_type: EnumProperty(name="Type", description="Input Data Type", ' + f"items={data_type_items}, default='{data_type_items[index_default][0]}', " + f"update=MxNode.update_data_type)", + ] + + for i, f in enumerate(ui_folders): + if i == 0: + code_strings.append("") + + code_strings.append( + f' {folder_prop_name(f)}: BoolProperty(name="{f}", ' + f'description="Enable {f}", default={i == 0}, update=MxNode.update_ui_folders)') + + for nd in nodedefs: + nd_type = nodedef_data_type(nd) + code_strings.append("") + + for input in nd.getInputs(): + prop_code = generate_property_code(input, category) + code_strings.append(f" {input_prop_name(nd_type, input.getName())}: {prop_code}") + + for output in nd.getOutputs(): + prop_code = generate_property_code(output, category) + code_strings.append(f" {output_prop_name(nd_type, output.getName())}: {prop_code}") + + code_strings.append("") + return '\n'.join(code_strings) + + +def generate_classes_code(file_path, prefix, category): + IGNORE_NODEDEF_DATA_TYPE = ('matrix33', 'matrix44', 'matrix33FA', 'matrix44FA') + + code_strings = [] + code_strings.append( +f"""# Automatically generated classes for MaterialX nodes. +# Do not edit manually, changes will be overwritten. + +import bpy +from bpy.props import ( + EnumProperty, + FloatProperty, + IntProperty, + BoolProperty, + StringProperty, + PointerProperty, + FloatVectorProperty, +) +from .node import MxNode + + +FILE_PATH = r"{file_path.relative_to(utils.ADDON_ROOT_DIR)}" +""") + + doc = mx.createDocument() + search_path = mx.FileSearchPath(str(utils.MX_LIBS_DIR)) + mx.readFromXmlFile(doc, str(file_path), searchPath=search_path) + nodedefs = doc.getNodeDefs() + + # grouping node_def_classes by node and nodegroup + node_def_classes_by_node = defaultdict(list) + for nodedef in nodedefs: + if nodedef.getSourceUri(): + continue + + if nodedef_data_type(nodedef) in IGNORE_NODEDEF_DATA_TYPE: + log.warn(f"Ignoring nodedef {nodedef.getName()}") + continue + + node_def_classes_by_node[(nodedef.getNodeString(), nodedef.getAttribute('nodegroup'))].\ + append(nodedef) + + # creating MxNode types + mx_node_class_names = [] + for nodedefs_by_node in node_def_classes_by_node.values(): + code_strings.append(generate_mx_node_class_code(nodedefs_by_node, prefix, category)) + mx_node_class_names.append(get_mx_node_class_name(nodedefs_by_node[0], prefix)) + + code_strings.append(f""" +mx_node_classes = [{', '.join(mx_node_class_names)}] +""") + + return '\n'.join(code_strings) + + +def generate_basic_classes(): + gen_code_dir = utils.ADDON_ROOT_DIR / "nodes" + + files = [ + ('PBR', "PBR", utils.MX_LIBS_DIR / "bxdf/standard_surface.mtlx"), + ('USD', "USD", utils.MX_LIBS_DIR / "bxdf/usd_preview_surface.mtlx"), + ('STD', None, utils.MX_LIBS_DIR / "stdlib/stdlib_defs.mtlx"), + ('PBR', "PBR", utils.MX_LIBS_DIR / "pbrlib/pbrlib_defs.mtlx"), + ('ALG', "Algorithm", utils.MX_LIBS_DIR / "alglib/alglib_defs.mtlx"), + ] + + for prefix, category, file_path in files: + + module_name = f"gen_{file_path.name[:-len(file_path.suffix)]}" + module_file = gen_code_dir / f"{module_name}.py" + + if module_file.is_file(): + continue + + log(f"Generating {module_file} from {file_path}") + module_code = generate_classes_code(file_path, prefix, category) + module_file.write_text(module_code) diff --git a/materialx/nodes/node.py b/materialx/nodes/node.py new file mode 100644 index 000000000..89e93661f --- /dev/null +++ b/materialx/nodes/node.py @@ -0,0 +1,449 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright 2022, AMD + +import MaterialX as mx + +import bpy + +from .. import utils + +from .. import logging +log = logging.Log("nodes.node") + + +class MxNodeInputSocket(bpy.types.NodeSocket): + bl_idname = utils.with_prefix('MxNodeInputSocket') + bl_label = "MX Input Socket" + + def draw(self, context, layout, node, text): + if not is_mx_node_valid(node): + return + + nd = node.nodedef + nd_input = nd.getInput(self.name) + nd_type = nd_input.getType() + + uiname = utils.get_attr(nd_input, 'uiname', utils.title_str(nd_input.getName())) + is_prop_area = context.area.type == 'PROPERTIES' + if self.is_linked or utils.is_shader_type(nd_type) or nd_input.getValue() is None: + uitype = utils.title_str(nd_type) + layout.label(text=uitype if uiname.lower() == uitype.lower() or is_prop_area else f"{uiname}: {uitype}") + else: + if nd_type == 'boolean': + layout.use_property_split = False + layout.alignment = 'LEFT' + layout.prop(node, node._input_prop_name(self.name), text='' if is_prop_area else uiname) + + + def draw_color(self, context, node): + return utils.get_socket_color(node.nodedef.getInput(self.name).getType() + if is_mx_node_valid(node) else 'undefined') + + +class MxNodeOutputSocket(bpy.types.NodeSocket): + bl_idname = utils.with_prefix('MxNodeOutputSocket') + bl_label = "MX Output Socket" + + def draw(self, context, layout, node, text): + if not is_mx_node_valid(node): + return + + nd = node.nodedef + mx_output = nd.getOutput(self.name) + uiname = utils.get_attr(mx_output, 'uiname', utils.title_str(mx_output.getName())) + uitype = utils.title_str(mx_output.getType()) + if uiname.lower() == uitype.lower() or len(nd.getOutputs()) == 1: + layout.label(text=uitype) + else: + layout.label(text=f"{uiname}: {uitype}") + + def draw_color(self, context, node): + return utils.get_socket_color(node.nodedef.getOutput(self.name).getType() + if is_mx_node_valid(node) else 'undefined') + + +class MxNode(bpy.types.ShaderNode): + """Base node from which all MaterialX nodes will be made""" + _file_path: str + # bl_compatibility = {'USDHydra'} + # bl_icon = 'MATERIAL' + + bl_label = "" + bl_description = "" + bl_width_default = 200 + + _data_types = {} # available types and nodedefs + _ui_folders = () # list of ui folders mentioned in nodedef + category = "" + + @classmethod + def get_nodedef(cls, data_type): + if not cls._data_types[data_type]['nd']: + # loading nodedefs + doc = mx.createDocument() + search_path = mx.FileSearchPath(str(utils.MX_LIBS_DIR)) + mx.readFromXmlFile(doc, str(utils.ADDON_ROOT_DIR / cls._file_path), searchPath=search_path) + for val in cls._data_types.values(): + val['nd'] = doc.getNodeDef(val['nd_name']) + + return cls._data_types[data_type]['nd'] + + @classmethod + def get_nodedefs(cls): + for data_type in cls._data_types.keys(): + yield cls.get_nodedef(data_type), data_type + + @property + def nodedef(self): + return self.get_nodedef(self.data_type) + + @property + def mx_node_path(self): + nd = self.nodedef + if '/' in self.name or utils.is_shader_type(nd.getOutputs()[0].getType()): + return self.name + + return f"NG/{self.name}" + + def _folder_prop_name(self, name): + return f"f_{utils.code_str(name.lower())}" + + def _input_prop_name(self, name): + return f"nd_{self.data_type}_in_{name}" + + def update_prop(self, context): + nodetree = self.id_data + nodetree.update_() + + def update_data_type(self, context): + # updating names for inputs and outputs + nodedef = self.nodedef + for i, nd_input in enumerate(utils.get_nodedef_inputs(nodedef, False)): + self.inputs[i].name = nd_input.getName() + for i, nd_output in enumerate(nodedef.getOutputs()): + self.outputs[i].name = nd_output.getName() + + def init(self, context): + def init_(): + nodedef = self.nodedef + + for nd_input in utils.get_nodedef_inputs(nodedef, False): + self.create_input(nd_input) + + for nd_output in nodedef.getOutputs(): + self.create_output(nd_output) + + if self._ui_folders: + self.update_ui_folders(context) + + nodetree = self.id_data + nodetree.no_update_call(init_) + + def draw_buttons(self, context, layout): + is_prop_area = context.area.type == 'PROPERTIES' + if len(self._data_types) > 1: + layout1 = layout + if is_prop_area: + layout1 = layout1.split(factor=0.012, align=True) + col = layout1.column() + layout1 = layout1.column() + layout1.prop(self, 'data_type') + + nodedef = self.nodedef + + if self._ui_folders: + col = layout.column(align=True) + r = None + for i, f in enumerate(self._ui_folders): + if i % 3 == 0: # putting 3 buttons per row + col.use_property_split = False + col.use_property_decorate = False + r = col.row(align=True) + r.prop(self, self._folder_prop_name(f), toggle=True) + + for nd_input in utils.get_nodedef_inputs(nodedef, True): + f = nd_input.getAttribute('uifolder') + if f and not getattr(self, self._folder_prop_name(f)): + continue + + name = nd_input.getName() + if self.category in ("texture2d", "texture3d") and nd_input.getType() == 'filename': + split = layout.row(align=True).split(factor=0.4 if is_prop_area else 0.25, align=True) + col = split.column() + col.alignment='RIGHT' if is_prop_area else 'EXPAND' + col.label(text=nd_input.getAttribute('uiname') if nd_input.hasAttribute('uiname') + else utils.title_str(name)) + col = split.column() + col.template_ID(self, self._input_prop_name(name), + open="image.open", new="image.new") + + else: + layout1 = layout + if is_prop_area: + layout1 = layout1.split(factor=0.012, align=True) + col = layout1.column() + layout1 = layout1.column() + layout1.prop(self, self._input_prop_name(name)) + + def draw_node_view(self, context, layout): + return + + # TODO: enable implementation + from ...ui.material import USDHYDRA_MATERIAL_OP_invoke_popup_input_nodes + layout.use_property_split = True + layout.use_property_decorate = True + self.draw_buttons(context, layout) + + for i, socket_in in enumerate(self.inputs): + nd = self.nodedef + uiname = utils.get_attr(nd.getInput(socket_in.name), 'uiname', + utils.title_str(nd.getInput(socket_in.name).getName())) + if socket_in.is_linked: + link = next((link for link in socket_in.links if link.is_valid), None) + if not link: + continue + + link = utils.pass_node_reroute(link) + if not link or isinstance(link.from_node, bpy.types.NodeReroute): + continue + + split = layout.split(factor=0.4) + split_1 = split.split(factor=0.4) + + row = split_1.row() + row.use_property_split = False + row.use_property_decorate = False + row.alignment = 'LEFT' + row.prop(socket_in, "show_expanded", + icon="DISCLOSURE_TRI_DOWN" if socket_in.show_expanded else "DISCLOSURE_TRI_RIGHT", + icon_only=True, emboss=False) + row = split_1.row() + row.alignment = 'RIGHT' + row.label(text=uiname) + row = split.row(align=True) + row.use_property_decorate = False + + box = row.box() + box.scale_x = 0.7 + box.scale_y = 0.5 + box.emboss = 'NONE_OR_STATUS' + + op = box.operator(USDHYDRA_MATERIAL_OP_invoke_popup_input_nodes.bl_idname, icon='HANDLETYPE_AUTO_CLAMP_VEC') + op.input_num = i + op.current_node_name = self.name + + row.prop(link.from_node, 'name', text='') + row.label(icon='BLANK1') + + if socket_in.show_expanded: + link.from_node.draw_node_view(context, layout) + + else: + mx_input = self.nodedef.getInput(socket_in.name) + f = mx_input.getAttribute('uifolder') + is_draw = True + if f: + if not getattr(self, self._folder_prop_name(f)): + is_draw = False + + if is_draw: + split = layout.split(factor=0.4) + + row = split.row(align=True) + row.alignment = 'RIGHT' + row.label(text=uiname) + row = split.row(align=True) + box = row.box() + box.scale_x = 0.7 + box.scale_y = 0.5 + + op = box.operator(USDHYDRA_MATERIAL_OP_invoke_popup_input_nodes.bl_idname, + icon='HANDLETYPE_AUTO_CLAMP_VEC') + op.input_num = i + op.current_node_name = self.name + + socket_in.draw(context, row, self, '') + + # COMPUTE FUNCTION + def compute(self, out_key, **kwargs): + log("compute", self, out_key) + + doc = kwargs['doc'] + nodedef = self.nodedef + nd_output = self.get_nodedef_output(out_key) + node_path = self.mx_node_path + + values = [] + for in_key in range(len(self.inputs)): + nd_input = self.get_nodedef_input(in_key) + f = nd_input.getAttribute('uifolder') + if f and not getattr(self, self._folder_prop_name(f)): + continue + + values.append((in_key, self.get_input_value(in_key, **kwargs))) + + mx_nodegraph = utils.get_nodegraph_by_node_path(doc, node_path, True) + node_name = utils.get_node_name_by_node_path(node_path) + mx_node = mx_nodegraph.addNode(nodedef.getNodeString(), node_name, nd_output.getType()) + + for in_key, val in values: + nd_input = self.get_nodedef_input(in_key) + nd_type = nd_input.getType() + + if isinstance(val, mx.Node): + mx_input = mx_node.addInput(nd_input.getName(), nd_type) + utils.set_param_value(mx_input, val, nd_type) + continue + + if isinstance(val, tuple) and isinstance(val[0], mx.Node): + # node with multioutput type + in_node, in_nd_output = val + mx_input = mx_node.addInput(nd_input.getName(), nd_type) + utils.set_param_value(mx_input, in_node, nd_type, in_nd_output) + continue + + if utils.is_shader_type(nd_type): + continue + + nd_val = nd_input.getValue() + if nd_val is None: + continue + + mx_input = mx_node.addInput(nd_input.getName(), nd_type) + utils.set_param_value(mx_input, val, nd_type) + + for nd_input in utils.get_nodedef_inputs(nodedef, True): + f = nd_input.getAttribute('uifolder') + if f and not getattr(self, self._folder_prop_name(f)): + continue + + val = self.get_param_value(nd_input.getName()) + nd_type = nd_input.getType() + + mx_param = mx_node.addInput(nd_input.getName(), nd_type) + utils.set_param_value(mx_param, val, nd_type) + + if len(nodedef.getOutputs()) > 1: + mx_node.setType('multioutput') + return mx_node, nd_output + + return mx_node + + def _compute_node(self, node, out_key, **kwargs): + # checking if node is already in nodegraph + + doc = kwargs['doc'] + node_path = node.mx_node_path + mx_nodegraph = utils.get_nodegraph_by_node_path(doc, node_path) + if mx_nodegraph: + node_name = utils.get_node_name_by_node_path(node_path) + mx_node = mx_nodegraph.getNode(node_name) + if mx_node: + if mx_node.getType() == 'multioutput': + nd_output = node.get_nodedef_output(out_key) + return mx_node, nd_output + + return mx_node + + return node.compute(out_key, **kwargs) + + def get_input_link(self, in_key: [str, int], **kwargs): + """Returns linked parsed node or None if nothing is linked or not link is not valid""" + + socket_in = self.inputs[in_key] + if not socket_in.links: + return None + + link = socket_in.links[0] + if not link.is_valid: + log.warn("Invalid link found", link, socket_in, self) + return None + + link = utils.pass_node_reroute(link) + if not link: + return None + + if not is_mx_node_valid(link.from_node): + log.warn(f"Ignoring unsupported node {link.from_node.bl_idname}", link.from_node, link.from_node.id_data) + return None + + return self._compute_node(link.from_node, link.from_socket.name, **kwargs) + + def get_input_value(self, in_key: [str, int], **kwargs): + node = self.get_input_link(in_key, **kwargs) + if node: + return node + + return self.get_input_default(in_key) + + def get_input_default(self, in_key: [str, int]): + return getattr(self, self._input_prop_name(self.inputs[in_key].name)) + + def get_param_value(self, name): + return getattr(self, self._input_prop_name(name)) + + def get_nodedef_input(self, in_key: [str, int]): + return self.nodedef.getInput(self.inputs[in_key].name) + + def get_nodedef_output(self, out_key: [str, int]): + return self.nodedef.getOutput(self.outputs[out_key].name) + + def set_input_value(self, in_key, value): + setattr(self, self._input_prop_name(self.inputs[in_key].name), value) + + def set_param_value(self, name, value): + setattr(self, self._input_prop_name(name), value) + + @classmethod + def poll(cls, tree): + return tree.bl_idname == utils.with_prefix('MxNodeTree') + + def update_ui_folders(self, context): + for i, nd_input in enumerate(utils.get_nodedef_inputs(self.nodedef, False)): + f = nd_input.getAttribute('uifolder') + if f: + self.inputs[i].hide = not getattr(self, self._folder_prop_name(f)) + + nodetree = self.id_data + nodetree.update_() + + def check_ui_folders(self): + if not self._ui_folders: + return + + for f in self._ui_folders: + setattr(self, self._folder_prop_name(f), False) + + for in_key, nd_input in enumerate(utils.get_nodedef_inputs(self.nodedef, False)): + f = nd_input.getAttribute('uifolder') + if not f: + continue + + if self.inputs[in_key].links: + setattr(self, self._folder_prop_name(f), True) + continue + + nd_input = self.get_nodedef_input(in_key) + val = self.get_input_default(in_key) + nd_val = nd_input.getValue() + if nd_val is None or utils.is_value_equal(nd_val, val, nd_input.getType()): + continue + + setattr(self, self._folder_prop_name(f), True) + + self.update_ui_folders(None) + + def create_input(self, nd_input): + input = self.inputs.new(MxNodeInputSocket.bl_idname, f'in_{len(self.inputs)}') + input.name = nd_input.getName() + return input + + def create_output(self, mx_output): + output = self.outputs.new(MxNodeOutputSocket.bl_idname, f'out_{len(self.outputs)}') + output.name = mx_output.getName() + return output + + +def is_mx_node_valid(node): + # handle MaterialX 1.37 nodes + return hasattr(node, 'nodedef') diff --git a/materialx/nodes/ui.py b/materialx/nodes/ui.py new file mode 100644 index 000000000..f899f073f --- /dev/null +++ b/materialx/nodes/ui.py @@ -0,0 +1,204 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright 2022, AMD + +from pathlib import Path +import traceback + +import MaterialX as mx + +import bpy +from bpy_extras.io_utils import ImportHelper, ExportHelper + +from ..node_tree import MxNodeTree +from .. import utils + +from ..utils import logging +log = logging.Log('nodes.ui') + + +class NODES_OP_import_file(bpy.types.Operator, ImportHelper): + bl_idname = utils.with_prefix('nodes_import_file') + bl_label = "Import from File" + bl_description = "Import MaterialX node tree from .mtlx file" + + filename_ext = ".mtlx" + filepath: bpy.props.StringProperty( + name="File Path", + description="File path used for importing MaterialX node tree from .mtlx file", + maxlen=1024, subtype="FILE_PATH" + ) + filter_glob: bpy.props.StringProperty(default="*.mtlx", options={'HIDDEN'}, ) + + def execute(self, context): + mx_node_tree = context.space_data.edit_tree + mtlx_file = Path(self.filepath) + + doc = mx.createDocument() + search_path = mx.FileSearchPath(str(mtlx_file.parent)) + search_path.append(str(utils.MX_LIBS_DIR)) + try: + mx.readFromXmlFile(doc, str(mtlx_file)) + mx_node_tree.import_(doc, mtlx_file) + + except Exception as e: + log.error(traceback.format_exc(), mtlx_file) + return {'CANCELLED'} + + return {'FINISHED'} + + +class NODES_OP_export_file(bpy.types.Operator, ExportHelper): + bl_idname = utils.with_prefix('nodes_export_file') + bl_label = "Export MaterialX" + bl_description = "Export MaterialX node tree to .mtlx file" + + # region properties + filename_ext = ".mtlx" + + filepath: bpy.props.StringProperty( + name="File Path", + description="File path used for exporting MaterialX node tree to .mtlx file", + maxlen=1024, + subtype="FILE_PATH" + ) + filter_glob: bpy.props.StringProperty( + default="*.mtlx", + options={'HIDDEN'}, + ) + is_export_deps: bpy.props.BoolProperty( + name="Include dependencies", + description="Export used MaterialX dependencies", + default=False + ) + is_export_textures: bpy.props.BoolProperty( + name="Export bound textures", + description="Export bound textures to corresponded folder", + default=True + ) + is_clean_texture_folder: bpy.props.BoolProperty( + name="Сlean texture folder", + description="Сlean texture folder before export", + default=False + ) + is_clean_deps_folders: bpy.props.BoolProperty( + name="Сlean MaterialX dependencies folders", + description="Сlean MaterialX dependencies folders before export", + default=False + ) + texture_dir_name: bpy.props.StringProperty( + name="Texture folder name", + description="Texture folder name used for exporting files", + default='textures', + maxlen=1024 + ) + is_create_new_folder: bpy.props.BoolProperty( + name="Create new folder", + description="Create new folder for material", + default=True + ) + # endregion + + def execute(self, context): + mx_node_tree = context.space_data.edit_tree + doc = mx_node_tree.export() + if not doc: + log.warn("Incorrect node tree to export", mx_node_tree) + return {'CANCELLED'} + + if self.is_create_new_folder: + self.filepath = str(Path(self.filepath).parent / mx_node_tree.name_full / Path(self.filepath).name) + + utils.export_mx_to_file(doc, self.filepath, + mx_node_tree=mx_node_tree, + is_export_deps=self.is_export_deps, + is_export_textures=self.is_export_textures, + texture_dir_name=self.texture_dir_name, + is_clean_texture_folder=self.is_clean_texture_folder, + is_clean_deps_folders=self.is_clean_deps_folders) + + return {'FINISHED'} + + def draw(self, context): + self.layout.prop(self, 'is_create_new_folder') + self.layout.prop(self, 'is_export_deps') + + col = self.layout.column(align=False) + col.prop(self, 'is_export_textures') + + row = col.row() + row.enabled = self.is_export_textures + row.prop(self, 'texture_dir_name', text='') + + @staticmethod + def enabled(context): + return bool(context.space_data.edit_tree.output_node) + + +class NODES_OP_export_console(bpy.types.Operator): + bl_idname = utils.with_prefix('nodes_export_console') + bl_label = "Export MaterialX to Console" + bl_description = "Export MaterialX node tree to console" + + def execute(self, context): + mx_node_tree = context.space_data.edit_tree + doc = mx_node_tree.export() + if not doc: + log.warn("Incorrect node tree to export", mx_node_tree) + return {'CANCELLED'} + + print(mx.writeToXmlString(doc)) + return {'FINISHED'} + + @staticmethod + def enabled(context): + return bool(context.space_data.edit_tree.output_node) + + +class NODES_OP_create_basic_nodes(bpy.types.Operator): + bl_idname = utils.with_prefix("nodes_create_basic_nodes") + bl_label = "Create Basic Nodes" + bl_description = "Create basic MaterialX nodes" + + def execute(self, context): + mx_node_tree = context.space_data.edit_tree + mx_node_tree.create_basic_nodes() + return {'FINISHED'} + + +class NODES_PT_tools(bpy.types.Panel): + bl_idname = utils.with_prefix('NODES_PT_tools', '_', True) + bl_label = "MaterialX Tools" + bl_space_type = 'NODE_EDITOR' + bl_region_type = 'UI' + bl_category = "Tool" + + @classmethod + def poll(cls, context): + tree = context.space_data.edit_tree + return tree and tree.bl_idname == MxNodeTree.bl_idname + + def draw(self, context): + layout = self.layout + + layout.operator(NODES_OP_create_basic_nodes.bl_idname, icon='ADD') + layout.operator(NODES_OP_import_file.bl_idname, icon='IMPORT') + layout.operator(NODES_OP_export_file.bl_idname, icon='EXPORT', text='Export MaterialX to file') + + +class NODES_PT_dev(bpy.types.Panel): + bl_idname = utils.with_prefix('NODES_PT_dev', '_', True) + bl_parent_id = NODES_PT_tools.bl_idname + bl_label = "Dev" + bl_space_type = 'NODE_EDITOR' + bl_region_type = 'UI' + + @classmethod + def poll(cls, context): + # TODO: enable + # return config.show_dev_settings + return True + + def draw(self, context): + layout = self.layout + + layout.operator(NODES_OP_export_console.bl_idname) \ No newline at end of file diff --git a/materialx/preferences.py b/materialx/preferences.py new file mode 100644 index 000000000..b5167dddf --- /dev/null +++ b/materialx/preferences.py @@ -0,0 +1,14 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright 2022, AMD + +import bpy + +from .utils import with_prefix + + +class AddonPreferences(bpy.types.AddonPreferences): + bl_idname = with_prefix('AddonPreferences') + + def draw(self, context): + layout = self.layout + layout.label(text="MaterialX addon preferences") diff --git a/materialx/utils.py b/materialx/utils.py new file mode 100644 index 000000000..e5d623ae9 --- /dev/null +++ b/materialx/utils.py @@ -0,0 +1,374 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright 2022, AMD + +import os +from pathlib import Path +import tempfile +import shutil + +import MaterialX as mx +import bpy + +from . import ADDON_PREFIX + +from . import logging +log = logging.Log('utils') + + +ADDON_ROOT_DIR = Path(__file__).parent +MX_LIBS_FOLDER = "libraries" +MX_LIBS_DIR = ADDON_ROOT_DIR / "libraries" + +os.environ['MATERIALX_SEARCH_PATH'] = str(MX_LIBS_DIR) + + +def with_prefix(name, separator='.', upper=False): + return f"{ADDON_PREFIX.upper() if upper else ADDON_PREFIX}{separator}{name}" + + +def title_str(str): + s = str.replace('_', ' ') + return s[:1].upper() + s[1:] + + +def code_str(str): + return str.replace(' ', '_').replace('.', '_') + + +def set_param_value(mx_param, val, nd_type, nd_output=None): + if isinstance(val, mx.Node): + param_nodegraph = mx_param.getParent().getParent() + val_nodegraph = val.getParent() + node_name = val.getName() + if val_nodegraph == param_nodegraph: + mx_param.setNodeName(node_name) + if nd_output: + mx_param.setAttribute('output', nd_output.getName()) + else: + # checking nodegraph paths + val_ng_path = val_nodegraph.getNamePath() + param_ng_path = param_nodegraph.getNamePath() + ind = val_ng_path.rfind('/') + ind = ind if ind >= 0 else 0 + if param_ng_path != val_ng_path[:ind]: + raise ValueError(f"Inconsistent nodegraphs. Cannot connect input " + f"{mx_param.getNamePath()} to {val.getNamePath()}") + + mx_output_name = f'out_{node_name}' + if nd_output: + mx_output_name += f'_{nd_output.getName()}' + + mx_output = val_nodegraph.getOutput(mx_output_name) + if not mx_output: + mx_output = val_nodegraph.addOutput(mx_output_name, val.getType()) + mx_output.setNodeName(node_name) + if nd_output: + mx_output.setType(nd_output.getType()) + mx_output.setAttribute('output', nd_output.getName()) + + mx_param.setAttribute('nodegraph', val_nodegraph.getName()) + mx_param.setAttribute('output', mx_output.getName()) + + elif nd_type == 'filename': + if isinstance(val, bpy.types.Image): + image_path = cache_image_file(val) + if image_path: + mx_param.setValueString(str(image_path)) + else: + mx_param.setValueString(str(val)) + + else: + mx_type = getattr(mx, title_str(nd_type), None) + if mx_type: + val = mx_type(val) + elif nd_type == 'float' and isinstance(val, tuple): + val = val[0] + + mx_param.setValue(val) + + +def is_value_equal(mx_val, val, nd_type): + if nd_type in ('string', 'float', 'integer', 'boolean', 'angle'): + if nd_type == 'filename' and val is None: + val = "" + + return mx_val == val + + if nd_type == 'filename': + val = "" if val is None else val + return mx_val == val + + return tuple(mx_val) == tuple(val) + + +def is_shader_type(mx_type): + return not (mx_type in ('string', 'float', 'integer', 'boolean', 'filename', 'angle') or + mx_type.startswith('color') or + mx_type.startswith('vector') or + mx_type.endswith('array')) + + +def get_attr(mx_param, name, else_val=None): + return mx_param.getAttribute(name) if mx_param.hasAttribute(name) else else_val + + +def parse_value(node, mx_val, mx_type, file_prefix=None): + if mx_type in ('string', 'float', 'integer', 'boolean', 'filename', 'angle'): + if file_prefix and mx_type == 'filename': + mx_val = str((file_prefix / mx_val).resolve()) + + if node.category in ('texture2d', 'texture3d') and mx_type == 'filename': + file_path = Path(mx_val) + if file_path.exists(): + image = bpy.data.images.get(file_path.name) + if image and image.filepath_from_user() == str(file_path): + return image + + image = bpy.data.images.load(str(file_path)) + return image + + return None + + return mx_val + + return tuple(mx_val) + + +def parse_value_str(val_str, mx_type, *, first_only=False, is_enum=False): + if mx_type == 'string': + if is_enum: + res = tuple(x.strip() for x in val_str.split(',')) + return res[0] if first_only else res + return val_str + + if mx_type == 'integer': + return int(val_str) + if mx_type in ('float', 'angle'): + return float(val_str) + if mx_type == 'boolean': + return val_str == "true" + if mx_type.endswith('array'): + return val_str + + if mx_type.startswith('color') or mx_type.startswith('vector') or mx_type.startswith('matrix'): + res = tuple(float(x) for x in val_str.split(',')) + return res[0] if first_only else res + + return val_str + + +def get_nodedef_inputs(nodedef, uniform=None): + for nd_input in nodedef.getInputs(): + if (uniform is True and nd_input.getAttribute('uniform') != 'true') or \ + (uniform is False and nd_input.getAttribute('uniform') == 'true'): + continue + + yield nd_input + + +def get_file_prefix(mx_node, file_path): + file_prefix = file_path.parent + n = mx_node + while True: + n = n.getParent() + file_prefix /= n.getFilePrefix() + if isinstance(n, mx.Document): + break + + return file_prefix.resolve() + + +def get_nodegraph_by_path(doc, ng_path, do_create=False): + nodegraph_names = code_str(ng_path).split('/') if ng_path else () + mx_nodegraph = doc + for nodegraph_name in nodegraph_names: + next_mx_nodegraph = mx_nodegraph.getNodeGraph(nodegraph_name) + if not next_mx_nodegraph: + if do_create: + next_mx_nodegraph = mx_nodegraph.addNodeGraph(nodegraph_name) + else: + return None + + mx_nodegraph = next_mx_nodegraph + + return mx_nodegraph + + +def get_nodegraph_by_node_path(doc, node_path, do_create=False): + nodegraph_names = code_str(node_path).split('/')[:-1] + return get_nodegraph_by_path(doc, '/'.join(nodegraph_names), do_create) + + +def get_node_name_by_node_path(node_path): + return code_str(node_path.split('/')[-1]) + + +def get_socket_color(mx_type): + if mx_type.startswith('color'): + return (0.78, 0.78, 0.16, 1.0) + + if mx_type in ('integer', 'float', 'boolean'): + return (0.63, 0.63, 0.63, 1.0) + + if mx_type.startswith(('vector', 'matrix')) or mx_type in ('displacementshader'): + return (0.39, 0.39, 0.78, 1.0) + + if mx_type in ('string', 'filename'): + return (0.44, 0.7, 1.0, 1.0) + + if mx_type.endswith(('shader', 'material')) or mx_type in ('BSDF', 'EDF', 'VDF'): + return (0.39, 0.78, 0.39, 1.0) + + return (0.63, 0.63, 0.63, 1.0) + + +def export_mx_to_file(doc, filepath, *, mx_node_tree=None, is_export_deps=False, + is_export_textures=False, texture_dir_name='textures', + is_clean_texture_folder=True, is_clean_deps_folders=True): + root_dir = Path(filepath).parent + + if not os.path.isdir(root_dir): + Path(root_dir).mkdir(parents=True, exist_ok=True) + + if is_export_deps and mx_node_tree: + mx_libs_dir = root_dir / MX_LIBS_FOLDER + if os.path.isdir(mx_libs_dir) and is_clean_deps_folders: + shutil.rmtree(mx_libs_dir) + + # we need to export every deps only once + unique_paths = set(node._file_path for node in mx_node_tree.nodes) + + for mtlx_path in unique_paths: + # defining paths + source_path = MX_LIBS_DIR.parent / mtlx_path + full_dest_path = root_dir / mtlx_path + rel_dest_path = full_dest_path.relative_to(root_dir / MX_LIBS_FOLDER) + dest_path = root_dir / rel_dest_path + + Path(dest_path.parent).mkdir(parents=True, exist_ok=True) + shutil.copy(source_path, dest_path) + + mx.prependXInclude(doc, str(rel_dest_path)) + + if is_export_textures: + texture_dir = root_dir / texture_dir_name + if os.path.isdir(texture_dir) and is_clean_texture_folder: + shutil.rmtree(texture_dir) + + image_paths = set() + + i = 0 + + input_files = (v for v in doc.traverseTree() if isinstance(v, mx.Input) and v.getType() == 'filename') + for mx_input in input_files: + if not os.path.isdir(texture_dir): + Path(texture_dir).mkdir(parents=True, exist_ok=True) + + mx_value = mx_input.getValue() + if not mx_value: + log.warn(f"Skipping wrong {mx_input.getType()} input value. Expected: path, got {mx_value}") + continue + + source_path = Path(mx_value) + if not os.path.isfile(source_path): + log.warn("Image is missing", source_path) + continue + + dest_path = texture_dir / source_path.name + + if source_path not in image_paths: + image_paths.update([source_path]) + + if os.path.isfile(dest_path): + i += 1 + dest_path = texture_dir / f"{source_path.stem}_{i}{source_path.suffix}" + else: + dest_path = texture_dir / f"{source_path.stem}{source_path.suffix}" + + shutil.copy(source_path, dest_path) + log(f"Export file {source_path} to {dest_path}: completed successfuly") + + rel_dest_path = dest_path.relative_to(root_dir) + mx_input.setValue(str(rel_dest_path), mx_input.getType()) + + mx.writeToXmlFile(doc, filepath) + log(f"Export MaterialX to {filepath}: completed successfuly") + + +def temp_dir(): + d = Path(tempfile.gettempdir()) / "blender-mx" + if not d.is_dir(): + log("Creating temp dir", d) + d.mkdir() + + return d + + +def get_temp_file(suffix, name=None, is_rand=False): + if not name: + return Path(tempfile.mktemp(suffix, "tmp", temp_dir())) + + if suffix: + if is_rand: + return Path(tempfile.mktemp(suffix, f"{name}_", temp_dir())) + + name += suffix + + return temp_dir() / name + + +def cache_image_file(image: bpy.types.Image, cache_check=True): + SUPPORTED_FORMATS = {".png", ".jpeg", ".jpg", ".hdr", ".tga", ".bmp"} + DEFAULT_FORMAT = ".hdr" + BLENDER_DEFAULT_FORMAT = "HDR" + BLENDER_DEFAULT_COLOR_MODE = "RGB" + READONLY_IMAGE_FORMATS = {".dds"} # blender can read these formats, but can't write + + image_path = Path(image.filepath_from_user()) + if not image.packed_file and image.source != 'GENERATED': + if not image_path.is_file(): + # log.warn("Image is missing", image, image_path) + return None + + image_suffix = image_path.suffix.lower() + + if image_suffix in SUPPORTED_FORMATS and\ + f".{image.file_format.lower()}" in SUPPORTED_FORMATS and not image.is_dirty: + return image_path + + if image_suffix in READONLY_IMAGE_FORMATS: + return image_path + + temp_path = get_temp_file(DEFAULT_FORMAT, image_path.stem, False) + if cache_check and image.source != 'GENERATED' and temp_path.is_file(): + return temp_path + + scene = bpy.context.scene + user_format = scene.render.image_settings.file_format + user_color_mode = scene.render.image_settings.color_mode + + # in some scenes the color_mode is undefined + # we can read it but unable to assign back, so switch it to 'RGB' if color_mode isn't selected + if not user_color_mode: + user_color_mode = 'RGB' + + scene.render.image_settings.file_format = BLENDER_DEFAULT_FORMAT + scene.render.image_settings.color_mode = BLENDER_DEFAULT_COLOR_MODE + + try: + image.save_render(filepath=str(temp_path)) + finally: + scene.render.image_settings.file_format = user_format + scene.render.image_settings.color_mode = user_color_mode + + return temp_path + + +def pass_node_reroute(link): + while isinstance(link.from_node, bpy.types.NodeReroute): + if not link.from_node.inputs[0].links: + return None + + link = link.from_node.inputs[0].links[0] + + return link if link.is_valid else None -- 2.30.2 From e50fcd0df378a8a8074447b30c56cbca644813ee Mon Sep 17 00:00:00 2001 From: Vasyl Pidhirskyi <42581166+VascoPi@users.noreply.github.com> Date: Mon, 12 Sep 2022 17:31:17 +0300 Subject: [PATCH 02/28] BLEN-215: Move node classes generation code to Appdata (#1) Added constant variables ADDON_DATA_DIR, NODE_CLASSES_FOLDER, MX_LIBS_DIR. Added generate_init_code function to create __init__.py for node_classes. Small fixes. --- materialx/nodes/__init__.py | 14 ++++++++------ materialx/nodes/generate_node_classes.py | 15 +++++++++++---- materialx/utils.py | 16 +++++++++++----- 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/materialx/nodes/__init__.py b/materialx/nodes/__init__.py index d2eaae1fc..816ba1051 100644 --- a/materialx/nodes/__init__.py +++ b/materialx/nodes/__init__.py @@ -2,18 +2,20 @@ # Copyright 2022, AMD import importlib -from pathlib import Path import bpy import nodeitems_utils +import sys from . import node, categories, generate_node_classes, ui -from ..utils import with_prefix +from .. import utils + +sys.path.append(str(utils.ADDON_DATA_DIR)) generate_node_classes.generate_basic_classes() -gen_modules = [importlib.import_module(f"materialx.nodes.{f.name[:-len(f.suffix)]}") - for f in Path(__file__).parent.glob("gen_*.py")] +gen_modules = [importlib.import_module(f"{utils.NODE_CLASSES_FOLDER}.{f.name[:-len(f.suffix)]}") + for f in utils.NODE_CLASSES_DIR.glob("gen_*.py")] mx_node_classes = [] for mod in gen_modules: @@ -44,11 +46,11 @@ def register(): register_ui() register_nodes() - nodeitems_utils.register_node_categories(with_prefix("MX_NODES"), categories.get_node_categories()) + nodeitems_utils.register_node_categories(utils.with_prefix("MX_NODES"), categories.get_node_categories()) def unregister(): - nodeitems_utils.unregister_node_categories(with_prefix("MX_NODES")) + nodeitems_utils.unregister_node_categories(utils.with_prefix("MX_NODES")) unregister_nodes() unregister_ui() diff --git a/materialx/nodes/generate_node_classes.py b/materialx/nodes/generate_node_classes.py index f7e786bd0..e8129d5b7 100644 --- a/materialx/nodes/generate_node_classes.py +++ b/materialx/nodes/generate_node_classes.py @@ -7,7 +7,7 @@ from collections import defaultdict import MaterialX as mx from .. import utils - +from ..utils import NODE_CLASSES_DIR from .. import logging log = logging.Log("nodes.generate_node_classes") @@ -273,10 +273,10 @@ from bpy.props import ( PointerProperty, FloatVectorProperty, ) -from .node import MxNode +from materialx.nodes.node import MxNode -FILE_PATH = r"{file_path.relative_to(utils.ADDON_ROOT_DIR)}" +FILE_PATH = r"{file_path}" """) doc = mx.createDocument() @@ -311,7 +311,8 @@ mx_node_classes = [{', '.join(mx_node_class_names)}] def generate_basic_classes(): - gen_code_dir = utils.ADDON_ROOT_DIR / "nodes" + gen_code_dir = NODE_CLASSES_DIR + gen_code_dir.mkdir(exist_ok=True) files = [ ('PBR', "PBR", utils.MX_LIBS_DIR / "bxdf/standard_surface.mtlx"), @@ -332,3 +333,9 @@ def generate_basic_classes(): log(f"Generating {module_file} from {file_path}") module_code = generate_classes_code(file_path, prefix, category) module_file.write_text(module_code) + + module_file = gen_code_dir / "__init__.py" + module_file.write_text( +"""# Automatically generated classes for MaterialX nodes. +# Do not edit manually, changes will be overwritten. +""") diff --git a/materialx/utils.py b/materialx/utils.py index e5d623ae9..ccdb4646a 100644 --- a/materialx/utils.py +++ b/materialx/utils.py @@ -16,8 +16,14 @@ log = logging.Log('utils') ADDON_ROOT_DIR = Path(__file__).parent +ADDON_DATA_DIR = Path(bpy.utils.user_resource("SCRIPTS", path=f"addons/{ADDON_PREFIX}", create=True)) + MX_LIBS_FOLDER = "libraries" -MX_LIBS_DIR = ADDON_ROOT_DIR / "libraries" +MX_LIBS_DIR = ADDON_ROOT_DIR / MX_LIBS_FOLDER + +NODE_CLASSES_FOLDER = "materialx_nodes" +NODE_CLASSES_DIR = ADDON_DATA_DIR / NODE_CLASSES_FOLDER + os.environ['MATERIALX_SEARCH_PATH'] = str(MX_LIBS_DIR) @@ -26,13 +32,13 @@ def with_prefix(name, separator='.', upper=False): return f"{ADDON_PREFIX.upper() if upper else ADDON_PREFIX}{separator}{name}" -def title_str(str): - s = str.replace('_', ' ') +def title_str(val): + s = val.replace('_', ' ') return s[:1].upper() + s[1:] -def code_str(str): - return str.replace(' ', '_').replace('.', '_') +def code_str(val): + return val.replace(' ', '_').replace('.', '_') def set_param_value(mx_param, val, nd_type, nd_output=None): -- 2.30.2 From a83e948bb829bad14903f3a2a282e0ada90b91a2 Mon Sep 17 00:00:00 2001 From: Vasyl Pidhirskyi <42581166+VascoPi@users.noreply.github.com> Date: Mon, 12 Sep 2022 17:50:32 +0300 Subject: [PATCH 03/28] BLEN-216: Matlib implementation (#2) Added mathlib module, with ui.py and manager.py. Added properties module. Added class MaterialXProperties to be used as a parent for addon PropertyGroups. It sets "materialx" property as parent for addon properties (bpy.context.window_manager.materialx. ...) Added constant variables MATLIB_FOLDER, MATLIB_DIR, currently, it is set to save matlib to addon appdata folder. --- materialx/__init__.py | 3 + materialx/matlib/__init__.py | 34 +++ materialx/matlib/manager.py | 435 +++++++++++++++++++++++++++++++++ materialx/matlib/properties.py | 130 ++++++++++ materialx/matlib/ui.py | 187 ++++++++++++++ materialx/nodes/.gitignore | 1 - materialx/utils.py | 27 ++ 7 files changed, 816 insertions(+), 1 deletion(-) create mode 100644 materialx/matlib/__init__.py create mode 100644 materialx/matlib/manager.py create mode 100644 materialx/matlib/properties.py create mode 100644 materialx/matlib/ui.py delete mode 100644 materialx/nodes/.gitignore diff --git a/materialx/__init__.py b/materialx/__init__.py index 894d32ccd..1fcd5aec0 100644 --- a/materialx/__init__.py +++ b/materialx/__init__.py @@ -26,6 +26,7 @@ import bpy from . import preferences from . import node_tree from . import nodes +from . import matlib from . import logging log = logging.Log("") @@ -36,10 +37,12 @@ def register(): bpy.utils.register_class(preferences.AddonPreferences) bpy.utils.register_class(node_tree.MxNodeTree) nodes.register() + matlib.register() def unregister(): log("unregister") + matlib.unregister() nodes.unregister() bpy.utils.unregister_class(node_tree.MxNodeTree) bpy.utils.unregister_class(preferences.AddonPreferences) diff --git a/materialx/matlib/__init__.py b/materialx/matlib/__init__.py new file mode 100644 index 000000000..21f8d16b9 --- /dev/null +++ b/materialx/matlib/__init__.py @@ -0,0 +1,34 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright 2022, AMD + +import bpy + +from . import ui, properties + + +register_properties, unregister_properties = bpy.utils.register_classes_factory( + [ + properties.MatlibProperties, + properties.WindowManagerProperties, + ] +) +register_ui, unregister_ui = bpy.utils.register_classes_factory( + [ + ui.MATLIB_PT_matlib, + ui.MATLIB_PT_matlib_tools, + ui.MATLIB_OP_load_materials, + ui.MATLIB_OP_load_package, + ui.MATLIB_OP_import_material, + ui.MATERIAL_OP_matlib_clear_search, + ] +) + + +def register(): + register_properties() + register_ui() + + +def unregister(): + unregister_ui() + unregister_properties() diff --git a/materialx/matlib/manager.py b/materialx/matlib/manager.py new file mode 100644 index 000000000..dad1e40ff --- /dev/null +++ b/materialx/matlib/manager.py @@ -0,0 +1,435 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright 2022, AMD + +import requests +import weakref +from dataclasses import dataclass, field +import shutil +from pathlib import Path +import zipfile +import json +import threading +from concurrent import futures + +import bpy.utils.previews + +from ..utils import logging, update_ui, MATLIB_DIR +log = logging.Log('matlib.manager') + +URL = "https://api.matlib.gpuopen.com/api" + + +def download_file(url, path, cache_check=True): + if cache_check and path.is_file(): + return path + + log("download_file", f"{url=}, {path=}") + + path.parent.mkdir(parents=True, exist_ok=True) + with requests.get(url, stream=True) as response: + with open(path, 'wb') as f: + shutil.copyfileobj(response.raw, f) + + log("download_file", "done") + return path + + +def download_file_callback(url, path, update_callback, cache_check=True): + if cache_check and path.is_file(): + return None + + log("download_file_callback", f"{url=}, {path=}") + + path.parent.mkdir(parents=True, exist_ok=True) + path_raw = path.with_suffix(".raw") + + size = 0 + with requests.get(url, stream=True) as response: + with open(path_raw, 'wb') as f: + if update_callback: + for chunk in response.iter_content(chunk_size=8192): + size += len(chunk) + update_callback(size) + f.write(chunk) + + path_raw.rename(path) + log("download_file_callback", "done") + return path + + +def request_json(url, params, path, cache_check=True): + if cache_check and path and path.is_file(): + with open(path) as json_file: + return json.load(json_file) + + log("request_json", f"{url=}, {params=}, {path=}") + + response = requests.get(url, params=params) + res_json = response.json() + + if path: + save_json(res_json, path) + + log("request_json", "done") + return res_json + + +def save_json(json_obj, path): + path.parent.mkdir(parents=True, exist_ok=True) + with open(path, 'w') as outfile: + json.dump(json_obj, outfile) + + +@dataclass(init=False) +class Render: + id: str + author: str = field(init=False, default=None) + image: str = field(init=False, default=None) + image_url: str = field(init=False, default=None) + image_path: Path = field(init=False, default=None) + thumbnail: str = field(init=False, default=None) + thumbnail_url: str = field(init=False, default=None) + thumbnail_path: Path = field(init=False, default=None) + thumbnail_icon_id: int = field(init=False, default=None) + + def __init__(self, id, material): + self.id = id + self.material = weakref.ref(material) + + @property + def cache_dir(self): + return self.material().cache_dir + + def get_info(self, cache_chek=True): + json_data = request_json(f"{URL}/renders/{self.id}", None, + self.cache_dir / f"R-{self.id[:8]}.json", cache_chek) + + self.author = json_data['author'] + self.image = json_data['image'] + self.image_url = json_data['image_url'] + self.thumbnail = json_data['thumbnail'] + self.thumbnail_url = json_data['thumbnail_url'] + + def get_image(self, cache_check=True): + self.image_path = download_file(self.image_url, + self.cache_dir / self.image, cache_check) + + def get_thumbnail(self, cache_check=True): + self.thumbnail_path = download_file(self.thumbnail_url, + self.cache_dir / self.thumbnail, cache_check) + + def thumbnail_load(self, pcoll): + thumb = pcoll.get(self.thumbnail) + if not thumb: + thumb = pcoll.load(self.thumbnail, str(self.thumbnail_path), 'IMAGE') + self.thumbnail_icon_id = thumb.icon_id + + +@dataclass(init=False) +class Package: + id: str + author: str = field(init=False, default=None) + label: str = field(init=False, default=None) + file: str = field(init=False, default=None) + file_url: str = field(init=False, default=None) + size_str: str = field(init=False, default=None) + + def __init__(self, id, material): + self.id = id + self.material = weakref.ref(material) + self.size_load = None + + @property + def cache_dir(self): + return self.material().cache_dir / f"P-{self.id[:8]}" + + @property + def file_path(self): + return self.cache_dir / self.file + + @property + def has_file(self): + return self.file_path.is_file() + + def get_info(self, cache_check=True): + json_data = request_json(f"{URL}/packages/{self.id}", None, + self.cache_dir / "info.json", cache_check) + + self.author = json_data['author'] + self.file = json_data['file'] + self.file_url = json_data['file_url'] + self.label = json_data['label'] + self.size_str = json_data['size'] + + def download(self, cache_check=True): + def callback(size): + self.size_load = size + update_ui() + + download_file_callback(self.file_url, self.file_path, callback, cache_check) + + def unzip(self, path=None, cache_check=True): + if not path: + path = self.cache_dir / "package" + + if path.is_dir() and not cache_check: + shutil.rmtree(path, ignore_errors=True) + + if not path.is_dir(): + with zipfile.ZipFile(self.file_path) as z: + z.extractall(path=path) + + mtlx_file = next(path.glob("**/*.mtlx")) + return mtlx_file + + @property + def size(self): + n, b = self.size_str.split(" ") + size = float(n) + if b == "MB": + size *= 1048576 # 2 ** 20 + elif b == "KB": + size *= 1024 # 2 ** 10 + elif b == "GB": + size *= 2 ** 30 + + return int(size) + + def __lt__(self, other): + return self.size < other.size + + +@dataclass +class Category: + id: str + title: str = field(init=False, default=None) + + @property + def cache_dir(self): + return MATLIB_DIR + + def get_info(self, use_cache=True): + if not self.id: + return + + json_data = request_json(f"{URL}/categories/{self.id}", None, + self.cache_dir / f"C-{self.id[:8]}.json", use_cache) + + self.title = json_data['title'] + + def __lt__(self, other): + return self.title < other.title + + +@dataclass(init=False) +class Material: + id: str + author: str + title: str + description: str + category: Category + status: str + renders: list[Render] + packages: list[Package] + + def __init__(self, mat_json): + self.id = mat_json['id'] + self.author = mat_json['author'] + self.title = mat_json['title'] + self.description = mat_json['description'] + self.category = Category(mat_json['category']) + self.status = mat_json['status'] + + self.renders = [] + for id in mat_json['renders_order']: + self.renders.append(Render(id, self)) + + self.packages = [] + for id in mat_json['packages']: + self.packages.append(Package(id, self)) + + save_json(mat_json, self.cache_dir / "info.json") + + def __lt__(self, other): + return self.title.lower() < other.title.lower() + + @property + def cache_dir(self): + return MATLIB_DIR / f"M-{self.id[:8]}" + + @classmethod + def get_materials(cls): + offset = 0 + limit = 500 + + while True: + res_json = request_json(f"{URL}/materials", {'limit': limit, 'offset': offset}, None) + + count = res_json['count'] + + for mat_json in res_json['results']: + mat = Material(mat_json) + if not mat.packages or not mat.category.id: + continue + + yield mat + + offset += limit + if offset >= count: + break + + @classmethod + def get_materials_cache(cls): + for f in MATLIB_DIR.glob("M-*/info.json"): + with open(f) as json_file: + mat_json = json.load(json_file) + + yield Material(mat_json) + + +class Manager: + def __init__(self): + self.materials = None + self.categories = None + self.pcoll = None + self.load_thread = None + self.package_executor = None + self.status = "" + self.is_synced = None + + def __del__(self): + # bpy.utils.previews.remove(self.pcoll) + pass + + def set_status(self, msg): + self.status = msg + update_ui() + + @property + def materials_list(self): + # required for thread safe purposes + return list(manager.materials.values()) + + @property + def categories_list(self): + # required for thread safe purposes + return list(manager.categories.values()) + + def check_load_materials(self, reset=False): + # required is not None condition to prevent further update if no material is found at first time. + if self.materials is not None and not reset: + return True + + if reset and self.pcoll: + bpy.utils.previews.remove(self.pcoll) + + self.materials = {} + self.categories = {} + self.pcoll = bpy.utils.previews.new() + + def category_load(cat): + cat.get_info() + self.categories[cat.id] = cat + + def material_load(mat, is_cached): + for render in mat.renders: + render.get_info() + render.get_thumbnail() + render.thumbnail_load(self.pcoll) + + for package in mat.packages: + package.get_info() + + self.materials[mat.id] = mat + + self.set_status(f"Syncing {len(self.materials)} {'cached' if is_cached else 'online'} materials...") + + def load(): + self.is_synced = False + self.set_status("Start syncing...") + with futures.ThreadPoolExecutor() as executor: + try: + # + # getting cached materials + # + materials = {mat.id: mat for mat in Material.get_materials_cache()} + categories = {mat.category.id: mat.category for mat in materials.values()} + + # loading categories + category_loaders = [executor.submit(category_load, cat) + for cat in categories.values()] + for future in futures.as_completed(category_loaders): + future.result() + + # updating category for cached materials + for mat in materials.values(): + mat.category.get_info() + + # loading cached materials + material_loaders = [executor.submit(material_load, mat, True) + for mat in materials.values()] + for future in futures.as_completed(material_loaders): + future.result() + + # + # getting and syncing with online materials + # + online_materials = {mat.id: mat for mat in Material.get_materials()} + + # loading new categories + new_categories = {} + for mat in online_materials.values(): + cat = mat.category + if cat.id not in categories and cat.id not in new_categories: + new_categories[cat.id] = cat + + category_loaders = [executor.submit(category_load, cat) + for cat in new_categories.values()] + for future in futures.as_completed(category_loaders): + future.result() + + # updating categories for online materials + for mat in online_materials.values(): + mat.category.get_info() + + # loading online materials + material_loaders = [executor.submit(material_load, mat, False) + for mat in online_materials.values()] + for future in futures.as_completed(material_loaders): + future.result() + + self.set_status(f"Syncing {len(self.materials)} materials completed") + + except requests.exceptions.RequestException as err: + executor.shutdown(wait=True, cancel_futures=True) + self.set_status(f"Connection error. Synced {len(self.materials)} materials") + log.error(err) + + finally: + self.is_synced = True + + self.load_thread = threading.Thread(target=load, daemon=True) + self.load_thread.start() + + return False + + def load_package(self, package): + package.size_load = 0 + + def package_load(): + try: + package.download() + + except requests.exceptions.RequestException as err: + log.error(err) + package.size_load = None + + update_ui() + + if not self.package_executor: + self.package_executor = futures.ThreadPoolExecutor() + + self.package_executor.submit(package_load) + + +manager = Manager() diff --git a/materialx/matlib/properties.py b/materialx/matlib/properties.py new file mode 100644 index 000000000..2fe57d604 --- /dev/null +++ b/materialx/matlib/properties.py @@ -0,0 +1,130 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright 2022, AMD + +import bpy + +from ..matlib.manager import manager +from ..utils import MaterialXProperties + + +class MatlibProperties(bpy.types.PropertyGroup): + def get_materials(self) -> dict: + materials = {} + search_str = self.search.strip().lower() + + materials_list = manager.materials_list + for mat in materials_list: + if search_str not in mat.title.lower(): + continue + + if not (mat.category.id == self.category_id or self.category_id == 'ALL'): + continue + + materials[mat.id] = mat + + return materials + + def get_materials_prop(self, context): + materials = [] + for i, mat in enumerate(sorted(self.get_materials().values())): + description = mat.title + if mat.description: + description += f"\n{mat.description}" + description += f"\nCategory: {mat.category.title}\nAuthor: {mat.author}" + + icon_id = mat.renders[0].thumbnail_icon_id if mat.renders else 'MATERIAL' + materials.append((mat.id, mat.title, description, icon_id, i)) + + return materials + + def get_categories_prop(self, context): + categories = [] + if manager.categories is None: + return categories + + categories += [('ALL', "All Categories", "Show materials for all categories")] + + categories_list = manager.categories_list + categories += ((cat.id, cat.title, f"Show materials with category {cat.title}") + for cat in sorted(categories_list)) + return categories + + def get_packages_prop(self, context): + packages = [] + mat = self.material + if not mat: + return packages + + for i, p in enumerate(sorted(mat.packages)): + description = f"Package: {p.label} ({p.size_str})\nAuthor: {p.author}" + if p.has_file: + description += "\nReady to import" + icon_id = 'RADIOBUT_ON' if p.has_file else 'RADIOBUT_OFF' + + packages.append((p.id, f"{p.label} ({p.size_str})", description, icon_id, i)) + + return packages + + def update_material(self, context): + mat = self.material + if mat: + self.package_id = min(mat.packages).id + + def update_category(self, context): + materials = self.get_materials() + if not materials: + return + + mat = min(materials.values()) + self.material_id = mat.id + self.package_id = min(mat.packages).id + + def update_search(self, context): + materials = self.get_materials() + if not materials or self.material_id in materials: + return + + mat = min(materials.values()) + self.material_id = mat.id + self.package_id = min(mat.packages).id + + material_id: bpy.props.EnumProperty( + name="Material", + description="Select material", + items=get_materials_prop, + update=update_material, + ) + category_id: bpy.props.EnumProperty( + name="Category", + description="Select materials category", + items=get_categories_prop, + update=update_category, + ) + search: bpy.props.StringProperty( + name="Search", + description="Search materials by title", + update=update_search, + ) + package_id: bpy.props.EnumProperty( + name="Package", + description="Selected material package", + items=get_packages_prop, + ) + + @property + def material(self): + return manager.materials.get(self.material_id) + + @property + def package(self): + mat = self.material + if not mat: + return None + + return next((p for p in mat.packages if p.id == self.package_id), None) + + +class WindowManagerProperties(MaterialXProperties): + bl_type = bpy.types.WindowManager + + matlib: bpy.props.PointerProperty(type=MatlibProperties) diff --git a/materialx/matlib/ui.py b/materialx/matlib/ui.py new file mode 100644 index 000000000..9c8e2f4d3 --- /dev/null +++ b/materialx/matlib/ui.py @@ -0,0 +1,187 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright 2022, AMD + +import traceback +import textwrap + +import MaterialX as mx + +import bpy + +from .. import utils +from ..node_tree import MxNodeTree +from ..utils import mx as mx_utils +from .manager import manager +#from .. import config + +from ..utils import logging +log = logging.Log('matlib.ui') + + +class MATERIAL_OP_matlib_clear_search(bpy.types.Operator): + """Create new MaterialX node tree for selected material""" + bl_idname = utils.with_prefix("matlib_clear_search") + bl_label = "" + + def execute(self, context): + context.window_manager.materialx.matlib.search = '' + return {"FINISHED"} + + +class MATLIB_OP_load_materials(bpy.types.Operator): + """Load materials""" + bl_idname = utils.with_prefix("matlib_load") + bl_label = "Reload Library" + + def execute(self, context): + manager.check_load_materials(reset=True) + return {"FINISHED"} + + +class MATLIB_OP_import_material(bpy.types.Operator): + """Import Material Package to material""" + bl_idname = utils.with_prefix("matlib_import_material") + bl_label = "Import Material Package" + + def execute(self, context): + matlib_prop = context.window_manager.materialx.matlib + package = matlib_prop.package + + mtlx_file = package.unzip() + + # getting/creating MxNodeTree + bl_material = context.material + mx_node_tree = bl_material.materialx.mx_node_tree + if not bl_material.materialx.mx_node_tree: + mx_node_tree = bpy.data.node_groups.new(f"MX_{bl_material.name}", + type=MxNodeTree.bl_idname) + bl_material.materialx.mx_node_tree = mx_node_tree + + log(f"Reading: {mtlx_file}") + doc = mx.createDocument() + search_path = mx.FileSearchPath(str(mtlx_file.parent)) + search_path.append(str(mx_utils.MX_LIBS_DIR)) + try: + mx.readFromXmlFile(doc, str(mtlx_file), searchPath=search_path) + mx_node_tree.import_(doc, mtlx_file) + + except Exception as e: + log.error(traceback.format_exc(), mtlx_file) + return {'CANCELLED'} + + return {"FINISHED"} + + +class MATLIB_OP_load_package(bpy.types.Operator): + """Download material package""" + bl_idname = utils.with_prefix("matlib_load_package") + bl_label = "Download Package" + + def execute(self, context): + matlib_prop = context.window_manager.materialx.matlib + manager.load_package(matlib_prop.package) + + return {"FINISHED"} + + +class MATLIB_PT_matlib(bpy.types.Panel): + bl_idname = utils.with_prefix("MATLIB_PT_matlib", '_', True) + bl_label = "Material Library" + bl_context = "material" + bl_region_type = 'WINDOW' + bl_space_type = 'PROPERTIES' + bl_options = {'DEFAULT_CLOSED'} + + def draw(self, context): + layout = self.layout + matlib_prop = context.window_manager.materialx.matlib + + manager.check_load_materials() + + # category + layout.prop(matlib_prop, 'category_id') + + # search + row = layout.row(align=True) + row.prop(matlib_prop, 'search', text="", icon='VIEWZOOM') + if matlib_prop.search: + row.operator(MATERIAL_OP_matlib_clear_search.bl_idname, icon='X') + + # materials + col = layout.column(align=True) + materials = matlib_prop.get_materials() + if not materials: + col.label(text="Start syncing..." if not manager.materials else "No materials found") + return + + row = col.row() + row.alignment = 'RIGHT' + row.label(text=f"{len(materials)} materials") + + col.template_icon_view(matlib_prop, 'material_id', show_labels=True) + + mat = matlib_prop.material + if not mat: + return + + # other material renders + if len(mat.renders) > 1: + grid = col.grid_flow(align=True) + for i, render in enumerate(mat.renders): + if i % 6 == 0: + row = grid.row() + row.alignment = 'CENTER' + + row.template_icon(render.thumbnail_icon_id, scale=5) + + # material title + row = col.row() + row.alignment = 'CENTER' + row.label(text=mat.title) + + # material description + col = layout.column(align=True) + if mat.description: + for line in textwrap.wrap(mat.description, 60): + col.label(text=line) + + col = layout.column(align=True) + col.label(text=f"Category: {mat.category.title}") + col.label(text=f"Author: {mat.author}") + + # packages + package = matlib_prop.package + if not package: + return + + layout.prop(matlib_prop, 'package_id', icon='DOCUMENTS') + + row = layout.row() + if package.has_file: + row.operator(MATLIB_OP_import_material.bl_idname, icon='IMPORT') + else: + if package.size_load is None: + row.operator(MATLIB_OP_load_package.bl_idname, icon='IMPORT') + else: + percent = min(100, int(package.size_load * 100 / package.size)) + row.operator(MATLIB_OP_load_package.bl_idname, icon='IMPORT', + text=f"Downloading Package...{percent}%") + row.enabled = False + + +class MATLIB_PT_matlib_tools(bpy.types.Panel): + bl_label = "Tools" + bl_context = "material" + bl_region_type = 'WINDOW' + bl_space_type = 'PROPERTIES' + bl_parent_id = utils.with_prefix('MATLIB_PT_matlib', '_', True) + bl_options = {'DEFAULT_CLOSED'} + + def draw(self, context): + layout = self.layout + col = layout.column() + col.label(text=manager.status) + + row = col.row() + row.enabled = bool(manager.is_synced) + row.operator(MATLIB_OP_load_materials.bl_idname, icon='FILE_REFRESH') diff --git a/materialx/nodes/.gitignore b/materialx/nodes/.gitignore deleted file mode 100644 index 625db102a..000000000 --- a/materialx/nodes/.gitignore +++ /dev/null @@ -1 +0,0 @@ -gen_*.py diff --git a/materialx/utils.py b/materialx/utils.py index ccdb4646a..e8531092a 100644 --- a/materialx/utils.py +++ b/materialx/utils.py @@ -24,6 +24,8 @@ MX_LIBS_DIR = ADDON_ROOT_DIR / MX_LIBS_FOLDER NODE_CLASSES_FOLDER = "materialx_nodes" NODE_CLASSES_DIR = ADDON_DATA_DIR / NODE_CLASSES_FOLDER +MATLIB_FOLDER = "matlib" +MATLIB_DIR = ADDON_DATA_DIR / MATLIB_FOLDER os.environ['MATERIALX_SEARCH_PATH'] = str(MX_LIBS_DIR) @@ -378,3 +380,28 @@ def pass_node_reroute(link): link = link.from_node.inputs[0].links[0] return link if link.is_valid else None + + +def update_ui(area_type='PROPERTIES', region_type='WINDOW'): + for window in bpy.context.window_manager.windows: + for area in window.screen.areas: + if area.type == area_type: + for region in area.regions: + if region.type == region_type: + region.tag_redraw() + + +class MaterialXProperties(bpy.types.PropertyGroup): + bl_type = None + + @classmethod + def register(cls): + setattr(cls.bl_type, "materialx", bpy.props.PointerProperty( + name="MaterialX properties", + description="MaterialX properties", + type=cls, + )) + + @classmethod + def unregister(cls): + delattr(cls.bl_type, "materialx") -- 2.30.2 From d2fc8f497c1b2a9ff6c874741bd8d3335def27e9 Mon Sep 17 00:00:00 2001 From: Bogdan Nagirniak <33626169+bnagirniak@users.noreply.github.com> Date: Tue, 13 Sep 2022 10:02:07 +0300 Subject: [PATCH 04/28] Code cleanups (#4) Renamed ADDON_PREFIX to ADDON_ALIAS, made it to use in properties. Made code improvements. --- materialx/__init__.py | 2 +- materialx/logging.py | 4 ++-- materialx/matlib/ui.py | 18 ++++++++---------- materialx/nodes/generate_node_classes.py | 7 ++++--- materialx/utils.py | 14 +++++++++----- 5 files changed, 24 insertions(+), 21 deletions(-) diff --git a/materialx/__init__.py b/materialx/__init__.py index 1fcd5aec0..c5158351f 100644 --- a/materialx/__init__.py +++ b/materialx/__init__.py @@ -18,7 +18,7 @@ bl_info = { "category": "Material", } -ADDON_PREFIX = "materialx" +ADDON_ALIAS = "materialx" import bpy diff --git a/materialx/logging.py b/materialx/logging.py index 3d0688123..30b03c501 100644 --- a/materialx/logging.py +++ b/materialx/logging.py @@ -4,13 +4,13 @@ import sys import logging.handlers -from . import ADDON_PREFIX +from . import ADDON_ALIAS FORMAT_STR = "%(asctime)s %(levelname)s %(name)s [%(thread)d]: %(message)s" # root logger for the addon -logger = logging.getLogger(ADDON_PREFIX) +logger = logging.getLogger(ADDON_ALIAS) logger.setLevel('DEBUG') # file_handler = logging.handlers.RotatingFileHandler(PLUGIN_ROOT_DIR / 'usdhydra.log', diff --git a/materialx/matlib/ui.py b/materialx/matlib/ui.py index 9c8e2f4d3..49e76ee51 100644 --- a/materialx/matlib/ui.py +++ b/materialx/matlib/ui.py @@ -10,9 +10,7 @@ import bpy from .. import utils from ..node_tree import MxNodeTree -from ..utils import mx as mx_utils from .manager import manager -#from .. import config from ..utils import logging log = logging.Log('matlib.ui') @@ -24,7 +22,7 @@ class MATERIAL_OP_matlib_clear_search(bpy.types.Operator): bl_label = "" def execute(self, context): - context.window_manager.materialx.matlib.search = '' + utils.mx_properties(context.window_manager).matlib.search = '' return {"FINISHED"} @@ -44,23 +42,23 @@ class MATLIB_OP_import_material(bpy.types.Operator): bl_label = "Import Material Package" def execute(self, context): - matlib_prop = context.window_manager.materialx.matlib + matlib_prop = utils.mx_properties(context.window_manager).matlib package = matlib_prop.package mtlx_file = package.unzip() # getting/creating MxNodeTree bl_material = context.material - mx_node_tree = bl_material.materialx.mx_node_tree - if not bl_material.materialx.mx_node_tree: + mx_node_tree = utils.mx_properties(bl_material).mx_node_tree + if not mx_node_tree: mx_node_tree = bpy.data.node_groups.new(f"MX_{bl_material.name}", type=MxNodeTree.bl_idname) - bl_material.materialx.mx_node_tree = mx_node_tree + utils.mx_properties(bl_material).mx_node_tree = mx_node_tree log(f"Reading: {mtlx_file}") doc = mx.createDocument() search_path = mx.FileSearchPath(str(mtlx_file.parent)) - search_path.append(str(mx_utils.MX_LIBS_DIR)) + search_path.append(str(utils.MX_LIBS_DIR)) try: mx.readFromXmlFile(doc, str(mtlx_file), searchPath=search_path) mx_node_tree.import_(doc, mtlx_file) @@ -78,7 +76,7 @@ class MATLIB_OP_load_package(bpy.types.Operator): bl_label = "Download Package" def execute(self, context): - matlib_prop = context.window_manager.materialx.matlib + matlib_prop = utils.mx_properties(context.window_manager).matlib manager.load_package(matlib_prop.package) return {"FINISHED"} @@ -94,7 +92,7 @@ class MATLIB_PT_matlib(bpy.types.Panel): def draw(self, context): layout = self.layout - matlib_prop = context.window_manager.materialx.matlib + matlib_prop = utils.mx_properties(context.window_manager).matlib manager.check_load_materials() diff --git a/materialx/nodes/generate_node_classes.py b/materialx/nodes/generate_node_classes.py index e8129d5b7..20de7a963 100644 --- a/materialx/nodes/generate_node_classes.py +++ b/materialx/nodes/generate_node_classes.py @@ -7,7 +7,8 @@ from collections import defaultdict import MaterialX as mx from .. import utils -from ..utils import NODE_CLASSES_DIR +from .. import ADDON_ALIAS + from .. import logging log = logging.Log("nodes.generate_node_classes") @@ -273,7 +274,7 @@ from bpy.props import ( PointerProperty, FloatVectorProperty, ) -from materialx.nodes.node import MxNode +from {ADDON_ALIAS}.nodes.node import MxNode FILE_PATH = r"{file_path}" @@ -311,7 +312,7 @@ mx_node_classes = [{', '.join(mx_node_class_names)}] def generate_basic_classes(): - gen_code_dir = NODE_CLASSES_DIR + gen_code_dir = utils.NODE_CLASSES_DIR gen_code_dir.mkdir(exist_ok=True) files = [ diff --git a/materialx/utils.py b/materialx/utils.py index e8531092a..ecc659202 100644 --- a/materialx/utils.py +++ b/materialx/utils.py @@ -9,14 +9,14 @@ import shutil import MaterialX as mx import bpy -from . import ADDON_PREFIX +from . import ADDON_ALIAS from . import logging log = logging.Log('utils') ADDON_ROOT_DIR = Path(__file__).parent -ADDON_DATA_DIR = Path(bpy.utils.user_resource("SCRIPTS", path=f"addons/{ADDON_PREFIX}", create=True)) +ADDON_DATA_DIR = Path(bpy.utils.user_resource("SCRIPTS", path=f"addons/{ADDON_ALIAS}", create=True)) MX_LIBS_FOLDER = "libraries" MX_LIBS_DIR = ADDON_ROOT_DIR / MX_LIBS_FOLDER @@ -31,7 +31,7 @@ os.environ['MATERIALX_SEARCH_PATH'] = str(MX_LIBS_DIR) def with_prefix(name, separator='.', upper=False): - return f"{ADDON_PREFIX.upper() if upper else ADDON_PREFIX}{separator}{name}" + return f"{ADDON_ALIAS.upper() if upper else ADDON_ALIAS}{separator}{name}" def title_str(val): @@ -396,7 +396,7 @@ class MaterialXProperties(bpy.types.PropertyGroup): @classmethod def register(cls): - setattr(cls.bl_type, "materialx", bpy.props.PointerProperty( + setattr(cls.bl_type, ADDON_ALIAS, bpy.props.PointerProperty( name="MaterialX properties", description="MaterialX properties", type=cls, @@ -404,4 +404,8 @@ class MaterialXProperties(bpy.types.PropertyGroup): @classmethod def unregister(cls): - delattr(cls.bl_type, "materialx") + delattr(cls.bl_type, ADDON_ALIAS) + + +def mx_properties(obj): + return getattr(obj, ADDON_ALIAS) -- 2.30.2 From 23bc2562fc9c744c177abc1e7d17344645afee82 Mon Sep 17 00:00:00 2001 From: Georgiy Markelov <42409851+DagerD@users.noreply.github.com> Date: Tue, 13 Sep 2022 16:19:52 +0300 Subject: [PATCH 05/28] BLEN-217: MaterialX panel in material tab (#3) Added drawing MaterialX Node Tree inside Material panel. Co-authored-by: Bogdan Nagirniak --- materialx/__init__.py | 15 +- materialx/material/__init__.py | 61 +++ materialx/material/properties.py | 119 +++++ materialx/material/ui.py | 774 +++++++++++++++++++++++++++++++ materialx/nodes/node.py | 9 +- 5 files changed, 967 insertions(+), 11 deletions(-) create mode 100644 materialx/material/__init__.py create mode 100644 materialx/material/properties.py create mode 100644 materialx/material/ui.py diff --git a/materialx/__init__.py b/materialx/__init__.py index c5158351f..2660ad89b 100644 --- a/materialx/__init__.py +++ b/materialx/__init__.py @@ -23,13 +23,16 @@ ADDON_ALIAS = "materialx" import bpy -from . import preferences -from . import node_tree -from . import nodes -from . import matlib +from . import ( + preferences, + node_tree, + nodes, + matlib, + material, +) from . import logging -log = logging.Log("") +log = logging.Log("__init__") def register(): @@ -38,11 +41,13 @@ def register(): bpy.utils.register_class(node_tree.MxNodeTree) nodes.register() matlib.register() + material.register() def unregister(): log("unregister") matlib.unregister() nodes.unregister() + material.unregister() bpy.utils.unregister_class(node_tree.MxNodeTree) bpy.utils.unregister_class(preferences.AddonPreferences) diff --git a/materialx/material/__init__.py b/materialx/material/__init__.py new file mode 100644 index 000000000..5beba298b --- /dev/null +++ b/materialx/material/__init__.py @@ -0,0 +1,61 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright 2022, AMD + +import bpy + + +class MATERIALX_Panel(bpy.types.Panel): + bl_space_type = 'PROPERTIES' + bl_region_type = 'WINDOW' + bl_context = 'render' + + +class MATERIALX_ChildPanel(bpy.types.Panel): + bl_space_type = 'PROPERTIES' + bl_region_type = 'WINDOW' + bl_parent_id = '' + + +from . import ( + ui, + properties +) + +register_classes, unregister_classes = bpy.utils.register_classes_factory([ + ui.MATERIAL_PT_context, + ui.MATERIAL_PT_preview, + ui.MATERIAL_OP_new_mx_node_tree, + ui.MATERIAL_OP_duplicate_mx_node_tree, + ui.MATERIAL_OP_convert_shader_to_mx, + ui.MATERIAL_OP_duplicate_mat_mx_node_tree, + ui.MATERIAL_OP_link_mx_node_tree, + ui.MATERIAL_OP_unlink_mx_node_tree, + ui.MATERIAL_MT_mx_node_tree, + ui.MATERIAL_PT_material, + ui.MATERIAL_PT_material_settings_surface, + ui.MATERIAL_OP_link_mx_node, + ui.MATERIAL_OP_invoke_popup_input_nodes, + ui.MATERIAL_OP_invoke_popup_shader_nodes, + ui.MATERIAL_OP_remove_node, + ui.MATERIAL_OP_disconnect_node, + ui.MATERIAL_PT_material_settings_displacement, + ui.MATERIAL_PT_output_surface, + ui.MATERIAL_PT_output_displacement, + ui.MATERIAL_PT_output_volume, + ui.MATERIAL_OP_export_mx_file, + ui.MATERIAL_OP_export_mx_console, + ui.MATERIAL_PT_tools, + ui.MATERIAL_PT_dev, +]) + + +def register(): + ui.register() + properties.register() + register_classes() + + +def unregister(): + ui.unregister() + properties.unregister() + unregister_classes() diff --git a/materialx/material/properties.py b/materialx/material/properties.py new file mode 100644 index 000000000..2d66021ef --- /dev/null +++ b/materialx/material/properties.py @@ -0,0 +1,119 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright 2022, AMD + +import traceback + +import bpy +import MaterialX as mx + +from ..node_tree import MxNodeTree +from ..utils import MX_LIBS_DIR + +from ..utils import logging, get_temp_file, MaterialXProperties +log = logging.Log('material.properties') + + +class MaterialProperties(MaterialXProperties): + bl_type = bpy.types.Material + + def update_mx_node_tree(self, context): + self.update() + + mx_node_tree: bpy.props.PointerProperty(type=MxNodeTree, update=update_mx_node_tree) + + @property + def output_node(self): + material = self.id_data + + if not material.node_tree: + return None + + return next((node for node in material.node_tree.nodes if + # TODO add implementation + # node.bl_idname == ShaderNodeOutputMaterial.__name__ and + node.is_active_output), None) + + def export(self, obj: bpy.types.Object) -> [mx.Document, None]: + if self.mx_node_tree: + return self.mx_node_tree.export() + + material = self.id_data + output_node = self.output_node + + if not output_node: + return None + + doc = mx.createDocument() + + # TODO add implementation + # node_parser = ShaderNodeOutputMaterial(doc, material, output_node, obj) + # if not node_parser.export(): + # return None + + return doc + + def update(self, is_depsgraph=False): + """ + Main update callback function, which notifies that material was updated from both: + depsgraph or MaterialX node tree + """ + if is_depsgraph and self.mx_node_tree: + return + + material = self.id_data + # usd_node_tree.material_update(material) + # ViewportEngineScene.material_update(material) + + def convert_shader_to_mx(self, obj: bpy.types.Object = None): + mat = self.id_data + output_node = self.output_node + if not output_node: + log.warn("Incorrect node tree to export: output node doesn't exist") + return False + + mx_node_tree = bpy.data.node_groups.new(f"MX_{mat.name}", type=MxNodeTree.bl_idname) + + if obj: + doc = self.export(obj) + else: + doc = mx.createDocument() + + # TODO add implementation + # node_parser = ShaderNodeOutputMaterial(doc, mat, output_node, obj) + # if not node_parser.export(): + # return False + + if not doc: + log.warn("Incorrect node tree to export", mx_node_tree) + return False + + mtlx_file = get_temp_file(".mtlx", + f'{mat.name}_{self.mx_node_tree.name if self.mx_node_tree else ""}') + mx.writeToXmlFile(doc, str(mtlx_file)) + search_path = mx.FileSearchPath(str(mtlx_file.parent)) + search_path.append(str(MX_LIBS_DIR)) + + try: + mx.readFromXmlFile(doc, str(mtlx_file), searchPath=search_path) + mx_node_tree.import_(doc, mtlx_file) + self.mx_node_tree = mx_node_tree + except Exception as e: + log.error(traceback.format_exc(), mtlx_file) + return False + + return True + + +def depsgraph_update(depsgraph): + if not depsgraph.updates: + return + + # Undo operation sends modified object with other stuff (scene, collection, etc...) + mat = next((upd.id for upd in depsgraph.updates if isinstance(upd.id, bpy.types.Material)), None) + if mat: + mat.hdusd.update(True) + + +register, unregister = bpy.utils.register_classes_factory(( + MaterialProperties, +)) diff --git a/materialx/material/ui.py b/materialx/material/ui.py new file mode 100644 index 000000000..10398b6e4 --- /dev/null +++ b/materialx/material/ui.py @@ -0,0 +1,774 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright 2022, AMD + +from pathlib import Path + +import MaterialX as mx + +import bpy +from bpy_extras.io_utils import ExportHelper + +from . import MATERIALX_Panel, MATERIALX_ChildPanel +from ..node_tree import MxNodeTree, NODE_LAYER_SEPARATION_WIDTH +from ..nodes.node import is_mx_node_valid +from .. import utils +from ..utils import pass_node_reroute, title_str, mx_properties + +from ..utils import logging +log = logging.Log(tag='material.ui') + + +class MATERIAL_PT_context(MATERIALX_Panel): + bl_label = "" + bl_context = "material" + bl_options = {'HIDE_HEADER'} + + @classmethod + def poll(cls, context): + if context.active_object and context.active_object.type == 'GPENCIL': + return False + else: + return context.material or context.object + + def draw(self, context): + layout = self.layout + + material = context.material + object = context.object + slot = context.material_slot + space = context.space_data + + if object: + is_sortable = len(object.material_slots) > 1 + rows = 1 + if is_sortable: + rows = 4 + + row = layout.row() + + row.template_list("MATERIAL_UL_matslots", "", object, "material_slots", object, + "active_material_index", rows=rows) + + col = row.column(align=True) + col.operator("object.material_slot_add", icon='ADD', text="") + col.operator("object.material_slot_remove", icon='REMOVE', text="") + + col.menu("MATERIAL_MT_context_menu", icon='DOWNARROW_HLT', text="") + + if is_sortable: + col.separator() + + col.operator("object.material_slot_move", icon='TRIA_UP', text="").direction = 'UP' + col.operator("object.material_slot_move", icon='TRIA_DOWN', text="").direction = 'DOWN' + + if object.mode == 'EDIT': + row = layout.row(align=True) + row.operator("object.material_slot_assign", text="Assign") + row.operator("object.material_slot_select", text="Select") + row.operator("object.material_slot_deselect", text="Deselect") + + split = layout.split(factor=0.65) + + if object: + split.template_ID(object, "active_material", new=utils.with_prefix("material_duplicate_mat_mx_node_tree")) + row = split.row() + + if slot: + row.prop(slot, "link", text="") + else: + row.label() + elif material: + split.template_ID(space, "pin_id") + split.separator() + + +class MATERIAL_PT_preview(MATERIALX_Panel): + bl_label = "Preview" + bl_context = "material" + bl_options = {'DEFAULT_CLOSED'} + + @classmethod + def poll(cls, context): + return context.material + + def draw(self, context): + self.layout.template_preview(context.material) + + +class MATERIAL_OP_new_mx_node_tree(bpy.types.Operator): + """Create new MaterialX node tree for selected material""" + bl_idname = utils.with_prefix("material_new_mx_node_tree") + bl_label = "New" + + def execute(self, context): + mat = context.material + mx_node_tree = bpy.data.node_groups.new(f"MX_{mat.name}", type=MxNodeTree.bl_idname) + mx_node_tree.create_basic_nodes() + + mx_properties(mat).mx_node_tree = mx_node_tree + return {"FINISHED"} + + +class MATERIAL_OP_duplicate_mat_mx_node_tree(bpy.types.Operator): + """Create duplicates of Material and MaterialX node tree for selected material""" + bl_idname = utils.with_prefix("material_duplicate_mat_mx_node_tree") + bl_label = "" + + def execute(self, context): + bpy.ops.material.new() + bpy.ops.materialx.material_duplicate_mx_node_tree() + return {"FINISHED"} + + +class MATERIAL_OP_duplicate_mx_node_tree(bpy.types.Operator): + """Create duplicate of MaterialX node tree for selected material""" + bl_idname = utils.with_prefix("material_duplicate_mx_node_tree") + bl_label = "" + + def execute(self, context): + mat = context.object.active_material + mx_node_tree = mx_properties(mat).mx_node_tree + + if mx_node_tree: + mx_properties(mat).mx_node_tree = mx_node_tree.copy() + + return {"FINISHED"} + + +class MATERIAL_OP_convert_shader_to_mx(bpy.types.Operator): + """Converts standard shader node tree to MaterialX node tree for selected material""" + bl_idname = utils.with_prefix("material_convert_shader_to_mx") + bl_label = "Convert to MaterialX" + + def execute(self, context): + if not mx_properties(context.material).convert_shader_to_mx(context.object): + return {'CANCELLED'} + + return {"FINISHED"} + + +class MATERIAL_OP_link_mx_node_tree(bpy.types.Operator): + """Link MaterialX node tree to selected material""" + bl_idname = utils.with_prefix("material_link_mx_node_tree") + bl_label = "" + + mx_node_tree_name: bpy.props.StringProperty(default="") + + def execute(self, context): + mx_properties(context.material).mx_node_tree = bpy.data.node_groups[self.mx_node_tree_name] + return {"FINISHED"} + + +class MATERIAL_OP_unlink_mx_node_tree(bpy.types.Operator): + """Unlink MaterialX node tree from selected material""" + bl_idname = utils.with_prefix("material_unlink_mx_node_tree") + bl_label = "" + + def execute(self, context): + mx_properties(context.material).mx_node_tree = None + return {"FINISHED"} + + +class MATERIAL_MT_mx_node_tree(bpy.types.Menu): + bl_idname = "MATERIAL_MT_mx_node_tree" + bl_label = "MX Nodetree" + + def draw(self, context): + layout = self.layout + node_groups = bpy.data.node_groups + + for ng in node_groups: + if ng.bl_idname != utils.with_prefix('MxNodeTree'): + continue + + row = layout.row() + row.enabled = bool(ng.output_node) + op = row.operator(MATERIAL_OP_link_mx_node_tree.bl_idname, + text=ng.name, icon='MATERIAL') + op.mx_node_tree_name = ng.name + + +class MATERIAL_PT_material(MATERIALX_Panel): + bl_label = "" + bl_context = "material" + + @classmethod + def poll(cls, context): + return context.material + + def draw(self, context): + mat_materialx = mx_properties(context.material) + layout = self.layout + + split = layout.row(align=True).split(factor=0.4) + row = split.column() + row.alignment = 'RIGHT' + row.label(text="MaterialX") + row = split.row() + row = row.row(align=True) + row.menu(MATERIAL_MT_mx_node_tree.bl_idname, text="", icon='MATERIAL') + + if mat_materialx.mx_node_tree: + row.prop(mat_materialx.mx_node_tree, 'name', text="") + row.operator(MATERIAL_OP_convert_shader_to_mx.bl_idname, icon='FILE_TICK', text="") + row.operator(MATERIAL_OP_duplicate_mx_node_tree.bl_idname, icon='DUPLICATE') + row.operator(MATERIAL_OP_unlink_mx_node_tree.bl_idname, icon='X') + + else: + row.operator(MATERIAL_OP_convert_shader_to_mx.bl_idname, icon='FILE_TICK', text="Convert") + row.operator(MATERIAL_OP_new_mx_node_tree.bl_idname, icon='ADD', text="") + + def draw_header(self, context): + layout = self.layout + layout.label(text=f"Material: {context.material.name}") + + +class MATERIAL_OP_link_mx_node(bpy.types.Operator): + """Link MaterialX node""" + bl_idname = utils.with_prefix("material_link_mx_node") + bl_label = "" + + new_node_name: bpy.props.StringProperty() + input_num: bpy.props.IntProperty() + current_node_name: bpy.props.StringProperty() + + def execute(self, context): + layout = self.layout + + node_tree = mx_properties(context.material).mx_node_tree + current_node = mx_properties(context.material).mx_node_tree.nodes[self.current_node_name] + + input = current_node.inputs[self.input_num] + link = next((link for link in input.links), None) if input.is_linked else None + linked_node_name = link.from_node.bl_idname if link else None + + if linked_node_name: + if linked_node_name != self.new_node_name: + bpy.ops.materialx.material_remove_node(input_node_name=link.from_node.name) + else: + return {"FINISHED"} + + new_node = node_tree.nodes.new(self.new_node_name) + new_node.location = (current_node.location[0] - NODE_LAYER_SEPARATION_WIDTH, + current_node.location[1]) + node_tree.links.new(new_node.outputs[0], current_node.inputs[self.input_num]) + + return {"FINISHED"} + + +class MATERIAL_OP_invoke_popup_input_nodes(bpy.types.Operator): + """Open panel with nodes to link""" + bl_idname = utils.with_prefix("material_invoke_popup_input_nodes") + bl_label = "" + + input_num: bpy.props.IntProperty() + current_node_name: bpy.props.StringProperty() + + def execute(self, context): + return {'FINISHED'} + + def invoke(self, context, event): + return context.window_manager.invoke_popup(self, width=600) + + def draw(self, context): + from ..nodes import mx_node_classes + + MAX_COLUMN_ITEMS = 34 + + split = self.layout.split() + cat = "" + i = 0 + col = None + for cls in mx_node_classes: + if cls.category in ("PBR", "material"): + continue + + if not col or i >= MAX_COLUMN_ITEMS: + i = 0 + col = split.column() + col.emboss = 'PULLDOWN_MENU' + + if cat != cls.category: + cat = cls.category + col.label(text=title_str(cat), icon='NODE') + i += 1 + + row = col.row() + row.alignment = 'LEFT' + op = row.operator(MATERIAL_OP_link_mx_node.bl_idname, text=cls.bl_label) + op.new_node_name = cls.bl_idname + op.input_num = self.input_num + op.current_node_name = self.current_node_name + i += 1 + + input = mx_properties(context.material).mx_node_tree.nodes[self.current_node_name].inputs[self.input_num] + if input.is_linked: + link = input.links[0] + + col = split.column() + col.emboss = 'PULLDOWN_MENU' + col.label(text="Link") + + row = col.row() + row.alignment = 'LEFT' + op = row.operator(MATERIAL_OP_remove_node.bl_idname) + op.input_node_name = link.from_node.name + + row = col.row() + row.alignment = 'LEFT' + op = row.operator(MATERIAL_OP_disconnect_node.bl_idname) + op.output_node_name = link.to_node.name + op.input_num = self.input_num + + +class MATERIAL_OP_invoke_popup_shader_nodes(bpy.types.Operator): + """Open panel with shader nodes to link""" + bl_idname = utils.with_prefix("material_invoke_popup_shader_nodes") + bl_label = "" + + input_num: bpy.props.IntProperty() + new_node_name: bpy.props.StringProperty() + + def execute(self, context): + return {'FINISHED'} + + def invoke(self, context, event): + return context.window_manager.invoke_popup(self, width=300) + + def draw(self, context): + from ..nodes import mx_node_classes + + split = self.layout.split() + col = split.column() + col.emboss = 'PULLDOWN_MENU' + col.label(text="PBR", icon='NODE') + + output_node = mx_properties(context.material).mx_node_tree.output_node + for cls in mx_node_classes: + if cls.category != "PBR": + continue + + row = col.row() + row.alignment = 'LEFT' + op = row.operator(MATERIAL_OP_link_mx_node.bl_idname, text=cls.bl_label) + op.new_node_name = cls.bl_idname + op.input_num = self.input_num + op.current_node_name = output_node.name + + input = output_node.inputs[self.input_num] + if input.is_linked: + link = input.links[0] + + col = split.column() + col.emboss = 'PULLDOWN_MENU' + col.label(text="Link") + + row = col.row() + row.alignment = 'LEFT' + op = row.operator(MATERIAL_OP_remove_node.bl_idname) + op.input_node_name = link.from_node.name + + row = col.row() + row.alignment = 'LEFT' + op = row.operator(MATERIAL_OP_disconnect_node.bl_idname) + op.output_node_name = link.to_node.name + op.input_num = self.input_num + + +class MATERIAL_OP_remove_node(bpy.types.Operator): + """Remove linked node""" + bl_idname = utils.with_prefix("material_remove_node") + bl_label = "Remove" + + input_node_name: bpy.props.StringProperty() + + def remove_nodes(self, context, node): + for input in node.inputs: + if input.is_linked: + for link in input.links: + self.remove_nodes(context, link.from_node) + + mx_properties(context.material).mx_node_tree.nodes.remove(node) + + def execute(self, context): + node_tree = mx_properties(context.material).mx_node_tree + input_node = node_tree.nodes[self.input_node_name] + + self.remove_nodes(context, input_node) + + return {'FINISHED'} + + +class MATERIAL_OP_disconnect_node(bpy.types.Operator): + """Disconnect linked node""" + bl_idname = utils.with_prefix("material_disconnect_node") + bl_label = "Disconnect" + + output_node_name: bpy.props.StringProperty() + input_num: bpy.props.IntProperty() + + def execute(self, context): + node_tree = mx_properties(context.material).mx_node_tree + output_node = node_tree.nodes[self.output_node_name] + + links = output_node.inputs[self.input_num].links + link = next((link for link in links), None) + if link: + node_tree.links.remove(link) + + return {'FINISHED'} + + +class MATERIAL_PT_material_settings_surface(MATERIALX_ChildPanel): + bl_label = "surfaceshader" + bl_parent_id = 'MATERIAL_PT_material' + + @classmethod + def poll(cls, context): + return bool(mx_properties(context.material).mx_node_tree) + + def draw(self, context): + layout = self.layout + + node_tree = mx_properties(context.material).mx_node_tree + output_node = node_tree.output_node + if not output_node: + layout.label(text="No output node") + return + + input = output_node.inputs[self.bl_label] + link = next((link for link in input.links if link.is_valid), None) + + split = layout.split(factor=0.4) + row = split.row(align=True) + row.alignment = 'RIGHT' + row.label(text='Surface') + + row = split.row(align=True) + box = row.box() + box.scale_x = 0.7 + box.scale_y = 0.5 + op = box.operator(MATERIAL_OP_invoke_popup_shader_nodes.bl_idname, icon='HANDLETYPE_AUTO_CLAMP_VEC') + op.input_num = output_node.inputs.find(self.bl_label) + + if link and is_mx_node_valid(link.from_node): + row.prop(link.from_node, 'name', text="") + else: + box = row.box() + box.scale_y = 0.5 + box.label(text='None') + + row.label(icon='BLANK1') + + if not link: + layout.label(text="No input node") + return + + if not is_mx_node_valid(link.from_node): + layout.label(text="Unsupported node") + return + + link = pass_node_reroute(link) + if not link: + return + + layout.separator() + link.from_node.draw_node_view(context, layout) + + +class MATERIAL_PT_material_settings_displacement(MATERIALX_ChildPanel): + bl_label = "displacementshader" + bl_parent_id = 'MATERIAL_PT_material' + + @classmethod + def poll(cls, context): + return bool(mx_properties(context.material).mx_node_tree) + + def draw(self, context): + layout = self.layout + + node_tree = mx_properties(context.material).mx_node_tree + output_node = node_tree.output_node + if not output_node: + layout.label(text="No output node") + return + + input = output_node.inputs[self.bl_label] + link = next((link for link in input.links if link.is_valid), None) + + split = layout.split(factor=0.4) + row = split.row(align=True) + row.alignment = 'RIGHT' + row.label(text='Displacement') + + row = split.row(align=True) + box = row.box() + box.scale_x = 0.7 + box.scale_y = 0.5 + op = box.operator(MATERIAL_OP_invoke_popup_shader_nodes.bl_idname, icon='HANDLETYPE_AUTO_CLAMP_VEC') + op.input_num = output_node.inputs.find(self.bl_label) + + if link and is_mx_node_valid(link.from_node): + row.prop(link.from_node, 'name', text="") + else: + box = row.box() + box.scale_y = 0.5 + box.label(text='None') + + row.label(icon='BLANK1') + + if not link: + layout.label(text="No input node") + return + + if not is_mx_node_valid(link.from_node): + layout.label(text="Unsupported node") + return + + link = pass_node_reroute(link) + if not link: + return + + layout.separator() + + link.from_node.draw_node_view(context, layout) + + +class MATERIAL_PT_output_node(MATERIALX_ChildPanel): + bl_label = "" + bl_parent_id = 'MATERIAL_PT_material' + + @classmethod + def poll(cls, context): + return not bool(mx_properties(context.material).mx_node_tree) + + def draw(self, context): + layout = self.layout + + node_tree = context.material.node_tree + + output_node = mx_properties(context.material).output_node + if not output_node: + layout.label(text="No output node") + return + + input = output_node.inputs[self.bl_label] + layout.template_node_view(node_tree, output_node, input) + + +class MATERIAL_PT_output_surface(MATERIAL_PT_output_node): + bl_label = "Surface" + + +class MATERIAL_PT_output_displacement(MATERIAL_PT_output_node): + bl_label = "Displacement" + bl_options = {'DEFAULT_CLOSED'} + + +class MATERIAL_PT_output_volume(MATERIAL_PT_output_node): + bl_label = "Volume" + bl_options = {'DEFAULT_CLOSED'} + + +class MATERIAL_OP_export_mx_file(bpy.types.Operator, ExportHelper): + bl_idname = utils.with_prefix("material_export_mx_file") + bl_label = "Export MaterialX" + bl_description = "Export material as MaterialX node tree to .mtlx file" + + # region properties + filename_ext = ".mtlx" + + filepath: bpy.props.StringProperty( + name="File Path", + description="File path used for exporting material as MaterialX node tree to .mtlx file", + maxlen=1024, + subtype="FILE_PATH" + ) + filter_glob: bpy.props.StringProperty( + default="*.mtlx", + options={'HIDDEN'}, + ) + is_export_deps: bpy.props.BoolProperty( + name="Include dependencies", + description="Export used MaterialX dependencies", + default=False + ) + is_export_textures: bpy.props.BoolProperty( + name="Export bound textures", + description="Export bound textures to corresponded folder", + default=True + ) + is_clean_texture_folder: bpy.props.BoolProperty( + name="Сlean texture folder", + description="Сlean texture folder before export", + default=False + ) + is_clean_deps_folders: bpy.props.BoolProperty( + name="Сlean dependencies folders", + description="Сlean MaterialX dependencies folders before export", + default=False + ) + texture_dir_name: bpy.props.StringProperty( + name="Folder name", + description="Texture folder name used for exporting files", + default='textures', + maxlen=1024, + ) + is_create_new_folder: bpy.props.BoolProperty( + name="Create new folder", + description="Create new folder for material", + default=True + ) + # endregion + + def execute(self, context): + materialx_prop = mx_properties(context.material) + + if not materialx_prop.convert_shader_to_mx(): + return {'CANCELLED'} + + doc = mx_properties(context.material).export(None) + if not doc: + return {'CANCELLED'} + + if self.is_create_new_folder: + self.filepath = str(Path(self.filepath).parent / context.material.name_full / Path(self.filepath).name) + + utils.export_mx_to_file(doc, self.filepath, + mx_node_tree=materialx_prop.mx_node_tree, + is_export_deps=self.is_export_deps, + is_export_textures=self.is_export_textures, + texture_dir_name=self.texture_dir_name, + is_clean_texture_folder=self.is_clean_texture_folder, + is_clean_deps_folders=self.is_clean_deps_folders) + + bpy.data.node_groups.remove(materialx_prop.mx_node_tree) + return {'FINISHED'} + + def draw(self, context): + self.layout.prop(self, 'is_create_new_folder') + self.layout.prop(self, 'is_export_deps') + + col = self.layout.column(align=False) + col.prop(self, 'is_export_textures') + + row = col.row() + row.enabled = self.is_export_textures + row.prop(self, 'texture_dir_name', text='') + + +class MATERIAL_OP_export_mx_console(bpy.types.Operator): + bl_idname = utils.with_prefix("material_export_mx_console") + bl_label = "Export MaterialX to Console" + bl_description = "Export material as MaterialX node tree to console" + + def execute(self, context): + doc = mx_properties(context.material).export(context.object) + if not doc: + return {'CANCELLED'} + + print(mx.writeToXmlString(doc)) + return {'FINISHED'} + + +class MATERIAL_PT_tools(MATERIALX_Panel): + bl_label = "MaterialX Tools" + bl_space_type = "NODE_EDITOR" + bl_region_type = "UI" + bl_category = "Tool" + + @classmethod + def poll(cls, context): + tree = context.space_data.edit_tree + + return tree and tree.bl_idname == bpy.types.ShaderNodeTree.__name__ + + def draw(self, context): + layout = self.layout + + layout.operator(MATERIAL_OP_convert_shader_to_mx.bl_idname, icon='FILE_TICK') + layout.operator(MATERIAL_OP_export_mx_file.bl_idname, text="Export MaterialX to file", icon='EXPORT') + + +class MATERIAL_PT_dev(MATERIALX_ChildPanel): + bl_label = "Dev" + bl_parent_id = 'MATERIAL_PT_tools' + bl_space_type = "NODE_EDITOR" + bl_region_type = "UI" + + @classmethod + def poll(cls, context): + return config.show_dev_settings + + def draw(self, context): + layout = self.layout + + layout.operator(MATERIAL_OP_export_mx_console.bl_idname) + + +def depsgraph_update(depsgraph): + context = bpy.context + mx_node_tree = None + if hasattr(context, 'object') and context.object and context.object.active_material: + mx_node_tree = mx_properties(context.object.active_material).mx_node_tree + + # trying to show MaterialX area with node tree or Shader area + screen = context.screen + if not hasattr(screen, 'areas'): + return + + bpy.types.NODE_HT_header.remove(update_material_ui) + + for window in context.window_manager.windows: + for area in window.screen.areas: + if not mx_node_tree: + if area.ui_type != utils.with_prefix('MxNodeTree'): + continue + + area.ui_type = 'ShaderNodeTree' + continue + + if area.ui_type not in (utils.with_prefix('MxNodeTree'), 'ShaderNodeTree'): + continue + + space = next(s for s in area.spaces if s.type == 'NODE_EDITOR') + if space.pin or space.shader_type != 'OBJECT': + continue + + area.ui_type = utils.with_prefix('MxNodeTree') + space.node_tree = mx_node_tree + + mx_node_tree.update_links() + + bpy.types.NODE_HT_header.append(update_material_ui) + + +# update for material ui according to MaterialX nodetree header changes +def update_material_ui(self, context): + obj = context.active_object + if not obj: + return + + mat = obj.active_material + if not mat: + return + + space = context.space_data + if space.tree_type != utils.with_prefix('MxNodeTree'): + return + + ui_mx_node_tree = mx_properties(mat).mx_node_tree + editor_node_tree = space.node_tree + + if editor_node_tree != ui_mx_node_tree and not space.pin and editor_node_tree: + mx_properties(mat).mx_node_tree = editor_node_tree + + +def register(): + # set update for material ui according to MaterialX nodetree header changes + bpy.types.NODE_HT_header.append(update_material_ui) + + +def unregister(): + # remove update for material ui according to MaterialX nodetree header changes + bpy.types.NODE_HT_header.remove(update_material_ui) diff --git a/materialx/nodes/node.py b/materialx/nodes/node.py index 89e93661f..9f8cb0c28 100644 --- a/materialx/nodes/node.py +++ b/materialx/nodes/node.py @@ -186,10 +186,7 @@ class MxNode(bpy.types.ShaderNode): layout1.prop(self, self._input_prop_name(name)) def draw_node_view(self, context, layout): - return - - # TODO: enable implementation - from ...ui.material import USDHYDRA_MATERIAL_OP_invoke_popup_input_nodes + from ..material.ui import MATERIAL_OP_invoke_popup_input_nodes layout.use_property_split = True layout.use_property_decorate = True self.draw_buttons(context, layout) @@ -228,7 +225,7 @@ class MxNode(bpy.types.ShaderNode): box.scale_y = 0.5 box.emboss = 'NONE_OR_STATUS' - op = box.operator(USDHYDRA_MATERIAL_OP_invoke_popup_input_nodes.bl_idname, icon='HANDLETYPE_AUTO_CLAMP_VEC') + op = box.operator(MATERIAL_OP_invoke_popup_input_nodes.bl_idname, icon='HANDLETYPE_AUTO_CLAMP_VEC') op.input_num = i op.current_node_name = self.name @@ -257,7 +254,7 @@ class MxNode(bpy.types.ShaderNode): box.scale_x = 0.7 box.scale_y = 0.5 - op = box.operator(USDHYDRA_MATERIAL_OP_invoke_popup_input_nodes.bl_idname, + op = box.operator(MATERIAL_OP_invoke_popup_input_nodes.bl_idname, icon='HANDLETYPE_AUTO_CLAMP_VEC') op.input_num = i op.current_node_name = self.name -- 2.30.2 From c677f9dfe7f93d27a240f2db895470afe14cc76b Mon Sep 17 00:00:00 2001 From: Bogdan Nagirniak <33626169+bnagirniak@users.noreply.github.com> Date: Tue, 13 Sep 2022 16:23:20 +0300 Subject: [PATCH 06/28] BLEN-218: Add some tools to preferences (#5) Implemented AddonPreferences with log_level and dev_tools options. Changed appdata folder name: materialx -> materiax_data --- materialx/__init__.py | 16 +++++++++++----- materialx/nodes/ui.py | 5 ++--- materialx/preferences.py | 32 +++++++++++++++++++++++++++++--- materialx/utils.py | 2 +- 4 files changed, 43 insertions(+), 12 deletions(-) diff --git a/materialx/__init__.py b/materialx/__init__.py index 2660ad89b..4803911b0 100644 --- a/materialx/__init__.py +++ b/materialx/__init__.py @@ -35,10 +35,16 @@ from . import logging log = logging.Log("__init__") +register_classes, unregister_classes = bpy.utils.register_classes_factory([ + node_tree.MxNodeTree, + preferences.AddonPreferences, +]) + + def register(): log("register") - bpy.utils.register_class(preferences.AddonPreferences) - bpy.utils.register_class(node_tree.MxNodeTree) + + register_classes() nodes.register() matlib.register() material.register() @@ -46,8 +52,8 @@ def register(): def unregister(): log("unregister") + + material.unregister() matlib.unregister() nodes.unregister() - material.unregister() - bpy.utils.unregister_class(node_tree.MxNodeTree) - bpy.utils.unregister_class(preferences.AddonPreferences) + unregister_classes() diff --git a/materialx/nodes/ui.py b/materialx/nodes/ui.py index f899f073f..3bdc13841 100644 --- a/materialx/nodes/ui.py +++ b/materialx/nodes/ui.py @@ -11,6 +11,7 @@ from bpy_extras.io_utils import ImportHelper, ExportHelper from ..node_tree import MxNodeTree from .. import utils +from ..preferences import addon_preferences from ..utils import logging log = logging.Log('nodes.ui') @@ -194,9 +195,7 @@ class NODES_PT_dev(bpy.types.Panel): @classmethod def poll(cls, context): - # TODO: enable - # return config.show_dev_settings - return True + return addon_preferences().dev_tools def draw(self, context): layout = self.layout diff --git a/materialx/preferences.py b/materialx/preferences.py index b5167dddf..2a0020ace 100644 --- a/materialx/preferences.py +++ b/materialx/preferences.py @@ -3,12 +3,38 @@ import bpy -from .utils import with_prefix +from . import logging, ADDON_ALIAS class AddonPreferences(bpy.types.AddonPreferences): - bl_idname = with_prefix('AddonPreferences') + bl_idname = ADDON_ALIAS + + def update_log_level(self, context): + logging.logger.setLevel(self.log_level) + + dev_tools: bpy.props.BoolProperty( + name="Developer Tools", + description="Enable developer tools", + default=False, + ) + log_level: bpy.props.EnumProperty( + name="Log Level", + description="Select logging level", + items=(('DEBUG', "Debug", "Log level DEBUG"), + ('INFO', "Info", "Log level INFO"), + ('WARNING', "Warning", "Log level WARN"), + ('ERROR', "Error", "Log level ERROR"), + ('CRITICAL', "Critical", "Log level CRITICAL")), + default='INFO', + update=update_log_level, + ) def draw(self, context): layout = self.layout - layout.label(text="MaterialX addon preferences") + col = layout.column() + col.prop(self, "dev_tools") + col.prop(self, "log_level") + + +def addon_preferences(): + return bpy.context.preferences.addons[ADDON_ALIAS].preferences diff --git a/materialx/utils.py b/materialx/utils.py index ecc659202..12374edb1 100644 --- a/materialx/utils.py +++ b/materialx/utils.py @@ -16,7 +16,7 @@ log = logging.Log('utils') ADDON_ROOT_DIR = Path(__file__).parent -ADDON_DATA_DIR = Path(bpy.utils.user_resource("SCRIPTS", path=f"addons/{ADDON_ALIAS}", create=True)) +ADDON_DATA_DIR = Path(bpy.utils.user_resource("SCRIPTS", path=f"addons/{ADDON_ALIAS}_data", create=True)) MX_LIBS_FOLDER = "libraries" MX_LIBS_DIR = ADDON_ROOT_DIR / MX_LIBS_FOLDER -- 2.30.2 From 8c3745c39453c1bede14732f897d93896da317ac Mon Sep 17 00:00:00 2001 From: Vasyl Pidhirskyi <42581166+VascoPi@users.noreply.github.com> Date: Wed, 14 Sep 2022 15:11:04 +0300 Subject: [PATCH 07/28] BLEN-219: Export blender nodes to MX nodes (#6) * BLEN-219: Export blender nodes to MX nodes. Added bl_node module. Added bl_node.nodes module: - color.py - converter.py - input.py - output.py - shader.py - texture.py - vector.py Moved manager.URL to utils.MATLIB_URL. Remove redundant code from material.ui. Code cleanup. --- materialx/bl_nodes/__init__.py | 87 ++++++ materialx/bl_nodes/node_parser.py | 380 ++++++++++++++++++++++++++ materialx/bl_nodes/nodes/__init__.py | 10 + materialx/bl_nodes/nodes/color.py | 78 ++++++ materialx/bl_nodes/nodes/converter.py | 73 +++++ materialx/bl_nodes/nodes/input.py | 18 ++ materialx/bl_nodes/nodes/output.py | 31 +++ materialx/bl_nodes/nodes/shader.py | 266 ++++++++++++++++++ materialx/bl_nodes/nodes/texture.py | 32 +++ materialx/bl_nodes/nodes/vector.py | 33 +++ materialx/material/__init__.py | 2 - materialx/material/properties.py | 15 +- materialx/material/ui.py | 38 +-- materialx/matlib/manager.py | 12 +- materialx/nodes/categories.py | 17 +- materialx/utils.py | 93 ++++++- 16 files changed, 1104 insertions(+), 81 deletions(-) create mode 100644 materialx/bl_nodes/__init__.py create mode 100644 materialx/bl_nodes/node_parser.py create mode 100644 materialx/bl_nodes/nodes/__init__.py create mode 100644 materialx/bl_nodes/nodes/color.py create mode 100644 materialx/bl_nodes/nodes/converter.py create mode 100644 materialx/bl_nodes/nodes/input.py create mode 100644 materialx/bl_nodes/nodes/output.py create mode 100644 materialx/bl_nodes/nodes/shader.py create mode 100644 materialx/bl_nodes/nodes/texture.py create mode 100644 materialx/bl_nodes/nodes/vector.py diff --git a/materialx/bl_nodes/__init__.py b/materialx/bl_nodes/__init__.py new file mode 100644 index 000000000..86e832e68 --- /dev/null +++ b/materialx/bl_nodes/__init__.py @@ -0,0 +1,87 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright 2022, AMD + +from nodeitems_utils import ( + NodeCategory, + NodeItem, + register_node_categories, + unregister_node_categories, +) +from nodeitems_builtins import ( + ShaderNodeCategory, +) +from .. import utils + + +class CompatibleShaderNodeCategory(NodeCategory): + """ Appear with an active USD plugin in Material shader editor only """ + @classmethod + def poll(cls, context): + return context.space_data.tree_type == 'ShaderNodeTree' + + +# add nodes here once they are supported +node_categories = [ + CompatibleShaderNodeCategory(utils.with_prefix("SHADER_NODE_CATEGORY_INPUT", '_', True), "Input", items=[ + NodeItem('ShaderNodeRGB'), + NodeItem('ShaderNodeValue'), + ], ), + CompatibleShaderNodeCategory(utils.with_prefix("SHADER_NODE_CATEGORY_OUTPUT", '_', True), "Output", items=[ + NodeItem('ShaderNodeOutputMaterial'), + ], ), + CompatibleShaderNodeCategory(utils.with_prefix("SHADER_NODE_CATEGORY_SHADERS", '_', True), "Shader", items=[ + NodeItem('ShaderNodeBsdfDiffuse'), + NodeItem('ShaderNodeBsdfGlass'), + NodeItem('ShaderNodeEmission'), + NodeItem('ShaderNodeBsdfPrincipled'), + ]), + CompatibleShaderNodeCategory(utils.with_prefix("SHADER_NODE_CATEGORY_TEXTURE", '_', True), "Texture", items=[ + NodeItem('ShaderNodeTexImage'), + ], ), + CompatibleShaderNodeCategory(utils.with_prefix("SHADER_NODE_CATEGORY_COLOR", '_', True), "Color", items=[ + NodeItem('ShaderNodeInvert'), + NodeItem('ShaderNodeMixRGB'), + ], ), + CompatibleShaderNodeCategory(utils.with_prefix("SHADER_NODE_CATEGORY_CONVERTER", '_', True), "Converter", items=[ + NodeItem('ShaderNodeMath'), + ], ), + CompatibleShaderNodeCategory(utils.with_prefix("SHADER_NODE_CATEGORY_VECTOR", '_', True), "Vector", items=[ + NodeItem('ShaderNodeNormalMap'), + ], ), + CompatibleShaderNodeCategory(utils.with_prefix("SHADER_NODE_CATEGORY_LAYOUT", '_', True), "Layout", items=[ + NodeItem('NodeFrame'), + NodeItem('NodeReroute'), + ], ), +] + + +# some nodes are hidden from plugins by Cycles itself(like Material Output), some we could not support. +# thus we'll hide 'em all to show only selected set of supported Blender nodes +# custom HdUSD_CompatibleShaderNodeCategory will be used instead +# def hide_cycles_and_eevee_poll(method): +# @classmethod +# def func(cls, context): +# return not context.scene.render.engine == 'HdUSD' and method(context) +# return func + + +old_shader_node_category_poll = None + + +def register(): + # hide Cycles/Eevee menu + # global old_shader_node_category_poll + # old_shader_node_category_poll = ShaderNodeCategory.poll + # ShaderNodeCategory.poll = hide_cycles_and_eevee_poll(ShaderNodeCategory.poll) + + # use custom menu + register_node_categories(utils.with_prefix("NODES", '_', True), node_categories) + + +def unregister(): + # restore Cycles/Eevee menu + # if old_shader_node_category_poll and ShaderNodeCategory.poll is not old_shader_node_category_poll: + # ShaderNodeCategory.poll = old_shader_node_category_poll + + # remove custom menu + unregister_node_categories(utils.with_prefix("NODES", '_', True)) diff --git a/materialx/bl_nodes/node_parser.py b/materialx/bl_nodes/node_parser.py new file mode 100644 index 000000000..0f61faa13 --- /dev/null +++ b/materialx/bl_nodes/node_parser.py @@ -0,0 +1,380 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright 2022, AMD + +import math + +import bpy +import MaterialX as mx + +from .. import utils +from ..utils import pass_node_reroute +from ..nodes import get_mx_node_cls +from .. import logging +log = logging.Log("bl_nodes.node_parser") + + +OUTPUT_TYPE = {'RGBA': 'color3', + 'VALUE': 'float', + 'VECTOR': 'vector3'} + + +class Id: + def __init__(self): + self.id = 0 + + def __call__(self): + self.id += 1 + return self.id + + +class NodeItem: + """This class is a wrapper used for doing operations on MaterialX nodes, floats, and tuples""" + + def __init__(self, id: Id, ng: [mx.Document, mx.NodeGraph], data: [tuple, float, mx.Node]): + self.id = id + self.nodegraph = ng + self.data = data + self.nodedef = None + if isinstance(data, mx.Node): + MxNode_cls, _ = get_mx_node_cls(data) + self.nodedef = MxNode_cls.get_nodedef(self.type) + + def node_item(self, value): + if isinstance(value, NodeItem): + return value + + return NodeItem(self.id, self.nodegraph, value) + + @property + def type(self): + if isinstance(self.data, float): + return 'float_' + elif isinstance(self.data, tuple): + return 'tuple_' + else: + return self.data.getType() + + def set_input(self, name, value): + if value is None: + return + + val_data = value.data if isinstance(value, NodeItem) else value + nd_input = self.nodedef.getActiveInput(name) + input = self.data.addInput(name, nd_input.getType()) + utils.set_param_value(input, val_data, input.getType()) + + def set_inputs(self, inputs): + for name, value in inputs.items(): + self.set_input(name, value) + + # MATH OPERATIONS + def _arithmetic_helper(self, other, op_node, func): + ''' helper function for overridden math functions. + This simply creates an arithmetic node of rpr_type + if one of the operands has node data, else maps the function to data ''' + + if other is None: + if isinstance(self.data, float): + result_data = func(self.data) + elif isinstance(self.data, tuple): + result_data = tuple(map(func, self.data)) + else: + result_data = self.nodegraph.addNode(op_node, f"{op_node}_{self.id()}", + self.data.getType()) + input = result_data.addInput('in', self.data.getType()) + utils.set_param_value(input, self.data, self.data.getType()) + + else: + other_data = other.data if isinstance(other, NodeItem) else other + if isinstance(self.data, (float, tuple)) and isinstance(other_data, (float, tuple)): + if isinstance(self.data, float) and isinstance(other_data, float): + result_data = func(self.data, other_data) + else: + data = self.data + + # converting data or other_data to have equal length + if isinstance(data, float): + data = (data,) * len(other_data) + elif isinstance(other_data, float): + other_data = (other_data,) * len(data) + elif len(data) < len(other_data): + data = (*data, 1.0) + elif len(other_data) < len(data): + other_data = (*other_data, 1.0) + + result_data = tuple(map(func, data, other_data)) + + else: + nd_type = self.data.getType() if isinstance(self.data, mx.Node) else \ + other_data.getType() + + result_data = self.nodegraph.addNode(op_node, f"{op_node}_{self.id()}", nd_type) + input1 = result_data.addInput('in1', nd_type) + utils.set_param_value(input1, self.data, nd_type) + input2 = result_data.addInput('in2', nd_type) + utils.set_param_value(input2, other_data, nd_type) + + return self.node_item(result_data) + + def __add__(self, other): + return self._arithmetic_helper(other, 'add', lambda a, b: a + b) + + def __sub__(self, other): + return self._arithmetic_helper(other, 'subtract', lambda a, b: a - b) + + def __mul__(self, other): + return self._arithmetic_helper(other, 'multiply', lambda a, b: a * b) + + def __truediv__(self, other): + return self._arithmetic_helper(other, 'divide', + lambda a, b: a / b if not math.isclose(b, 0.0) else 0.0) + + def __mod__(self, other): + return self._arithmetic_helper(other, 'modulo', lambda a, b: a % b) + + def __pow__(self, other): + return self._arithmetic_helper(other, 'power', lambda a, b: a ** b) + + def __neg__(self): + return 0.0 - self + + def __abs__(self): + return self._arithmetic_helper(None, 'absval', lambda a: abs(a)) + + def floor(self): + return self._arithmetic_helper(None, 'floor', lambda a: float(math.floor(a))) + + def ceil(self): + return self._arithmetic_helper(None, 'ceil', lambda a: float(math.ceil(a))) + + # right hand methods for doing something like 1.0 - Node + def __radd__(self, other): + return self + other + + def __rsub__(self, other): + return self.node_item(other) - self + + def __rmul__(self, other): + return self * other + + def __rtruediv__(self, other): + return self.node_item(other) / self + + def __rmod__(self, other): + return self.node_item(other) % self + + def __rpow__(self, other): + return self.node_item(other) ** self + + def dot(self, other): + dot = self._arithmetic_helper(other, 'dotproduct', lambda a, b: a * b) + if isinstance(dot.data, tuple): + dot.data = sum(dot.data) + + return dot + + def if_else(self, cond: str, other, if_value, else_value): + if cond == '>': + res = self._arithmetic_helper(other, 'ifgreater', lambda a, b: float(a > b)) + elif cond == '>=': + res = self._arithmetic_helper(other, 'ifgreatereq', lambda a, b: float(a >= b)) + elif cond == '==': + res = self._arithmetic_helper(other, 'ifequal', lambda a, b: float(a == b)) + elif cond == '<': + return self.node_item(other).if_else('>', self, else_value, if_value) + elif cond == '<=': + return self.node_item(other).if_else('>=', self, else_value, if_value) + elif cond == '!=': + return self.if_else('==', other, else_value, if_value) + else: + raise ValueError("Incorrect condition:", cond) + + if isinstance(res.data, float): + return if_value if res.data == 1.0 else else_value + elif isinstance(res.data, tuple): + return if_value if res.data[0] == 1.0 else else_value + else: + res.set_input('value1', if_value) + res.set_input('value2', else_value) + return res + + def min(self, other): + return self._arithmetic_helper(other, 'min', lambda a, b: min(a, b)) + + def max(self, other): + return self._arithmetic_helper(other, 'max', lambda a, b: max(a, b)) + + def clamp(self, min_val=0.0, max_val=1.0): + """ clamp data to min/max """ + return self.min(max_val).max(min_val) + + def sin(self): + return self._arithmetic_helper(None, 'sin', lambda a: math.sin(a)) + + def cos(self): + return self._arithmetic_helper(None, 'cos', lambda a: math.cos(a)) + + def tan(self): + return self._arithmetic_helper(None, 'tan', lambda a: math.tan(a)) + + def asin(self): + return self._arithmetic_helper(None, 'asin', lambda a: math.asin(a)) + + def acos(self): + return self._arithmetic_helper(None, 'acos', lambda a: math.acos(a)) + + def atan(self): + return self._arithmetic_helper(None, 'atan', lambda a: math.atan(a)) + + def log(self): + return self._arithmetic_helper(None, 'ln', lambda a: math.log(a)) + + def blend(self, value1, value2): + """ Line interpolate value between value1(0.0) and value2(1.0) by self.data as factor """ + return self * value2 + (1.0 - self) * value1 + + +class NodeParser: + """ + This is the base class that parses a blender node. + Subclasses should override only export() function. + """ + + nodegraph_path = "NG" + + def __init__(self, id: Id, doc: mx.Document, material: bpy.types.Material, + node: bpy.types.Node, obj: bpy.types.Object, out_key, output_type, cached_nodes, + group_nodes=(), **kwargs): + self.id = id + self.doc = doc + self.material = material + self.node = node + self.object = obj + self.out_key = out_key + self.out_type = output_type + self.cached_nodes = cached_nodes + self.group_nodes = group_nodes + self.kwargs = kwargs + + @staticmethod + def get_output_type(to_socket): + # Need to check ShaderNodeNormalMap separately because + # if has input color3 type but materialx normalmap got vector3 + return 'vector3' if to_socket.node.type == 'NORMAL_MAP' else OUTPUT_TYPE.get(to_socket.type, 'color3') + + @staticmethod + def get_node_parser_cls(bl_idname): + """ Returns NodeParser class for node_idname or None if not found """ + from . import nodes + return getattr(nodes, bl_idname, None) + + # INTERNAL FUNCTIONS + def _export_node(self, node, out_key, to_socket, group_node=None): + if group_node: + if self.group_nodes: + group_nodes = self.group_nodes + (group_node,) + else: + group_nodes = (group_node,) + else: + group_nodes = self.group_nodes + + # dynamically define output type of node + output_type = self.get_output_type(to_socket) + + # check if this node was already parsed and cached + node_item = self.cached_nodes.get((node.name, out_key, output_type)) + if node_item: + return node_item + + # getting corresponded NodeParser class + NodeParser_cls = self.get_node_parser_cls(node.bl_idname) + if not NodeParser_cls: + log.warn(f"Ignoring unsupported node {node.bl_idname}", node, self.material) + self.cached_nodes[(node.name, out_key, output_type)] = None + return None + + node_parser = NodeParser_cls(self.id, self.doc, self.material, node, self.object, + out_key, output_type, self.cached_nodes, group_nodes, **self.kwargs) + + node_item = node_parser.export() + + self.cached_nodes[(node.name, out_key, output_type)] = node_item + return node_item + + def _parse_val(self, val): + """Turn blender socket value into python's value""" + + if isinstance(val, (int, float)): + return float(val) + + if len(val) in (3, 4): + return tuple(val) + + if isinstance(val, str): + return val + + raise TypeError("Unknown value type to pass to rpr", val) + + def node_item(self, value): + if isinstance(value, NodeItem): + return value + + nodegraph = utils.get_nodegraph_by_path(self.doc, self.nodegraph_path, True) + return NodeItem(self.id, nodegraph, value) + + # HELPER FUNCTIONS + # Child classes should use them to do their export + def get_output_default(self): + """ Returns default value of output socket """ + socket_out = self.node.outputs[self.out_key] + + return self.node_item(self._parse_val(socket_out.default_value)) + + def get_input_default(self, in_key): + """ Returns default value of input socket """ + + socket_in = self.node.inputs[in_key] + return self.node_item(self._parse_val(socket_in.default_value)) + + def get_input_link(self, in_key: [str, int]): + """Returns linked parsed node or None if nothing is linked or not link is not valid""" + + socket_in = self.node.inputs[in_key] + if not socket_in.links: + return None + + link = socket_in.links[0] + + if not link.is_valid: + log.warn("Invalid link ignored", link, socket_in, self.node, self.material) + return None + + link = pass_node_reroute(link) + if not link: + return None + + return self._export_node(link.from_node, link.from_socket.identifier, link.to_socket) + + def get_input_value(self, in_key): + """ Returns linked node or default socket value """ + + val = self.get_input_link(in_key) + if val is not None: + return val + + return self.get_input_default(in_key) + + def create_node(self, node_name, nd_type, inputs=None): + nodegraph = utils.get_nodegraph_by_path(self.doc, self.nodegraph_path, True) + node = nodegraph.addNode(node_name, f"{node_name}_{self.id()}", nd_type) + node_item = NodeItem(self.id, nodegraph, node) + + if inputs: + node_item.set_inputs(inputs) + + return node_item + + # EXPORT FUNCTION + def export(self) -> [NodeItem, None]: + """Main export function which should be overridable in child classes""" + return None diff --git a/materialx/bl_nodes/nodes/__init__.py b/materialx/bl_nodes/nodes/__init__.py new file mode 100644 index 000000000..6d0f9d3af --- /dev/null +++ b/materialx/bl_nodes/nodes/__init__.py @@ -0,0 +1,10 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright 2022, AMD + +from .input import * +from .output import * +from .shader import * +from .texture import * +from .color import * +from .converter import * +from .vector import * diff --git a/materialx/bl_nodes/nodes/color.py b/materialx/bl_nodes/nodes/color.py new file mode 100644 index 000000000..6b850895d --- /dev/null +++ b/materialx/bl_nodes/nodes/color.py @@ -0,0 +1,78 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright 2022, AMD + +from ..node_parser import NodeParser + +from ... import logging +log = logging.Log("bl_nodes.nodes.color") + + +class ShaderNodeInvert(NodeParser): + def export(self): + fac = self.get_input_value('Fac') + color = self.get_input_value('Color') + + return fac.blend(color, 1.0 - color) + + +class ShaderNodeMixRGB(NodeParser): + + def export(self): + fac = self.get_input_value('Fac') + color1 = self.get_input_value('Color1') + color2 = self.get_input_value('Color2') + + # these mix types are copied from cycles OSL + blend_type = self.node.blend_type + + if blend_type in ('MIX', 'COLOR'): + res = fac.blend(color1, color2) + + elif blend_type == 'ADD': + res = fac.blend(color1, color1 + color2) + + elif blend_type == 'MULTIPLY': + res = fac.blend(color1, color1 * color2) + + elif blend_type == 'SUBTRACT': + res = fac.blend(color1, color1 - color2) + + elif blend_type == 'DIVIDE': + res = fac.blend(color1, color1 / color2) + + elif blend_type == 'DIFFERENCE': + res = fac.blend(color1, abs(color1 - color2)) + + elif blend_type == 'DARKEN': + res = fac.blend(color1, color1.min(color2)) + + elif blend_type == 'LIGHTEN': + res = fac.blend(color1, color1.max(color2)) + + elif blend_type == 'VALUE': + res = color1 + + elif blend_type == 'SCREEN': + tm = 1.0 - fac + res = 1.0 - (tm + fac * (1.0 - color2)) * (1.0 - color1) + + elif blend_type == 'SOFT_LIGHT': + tm = 1.0 - fac + scr = 1.0 - (1.0 - color2) * (1.0 - color1) + res = tm * color1 + fac * ((1.0 - color1) * color2 * color1 + color1 * scr) + + elif blend_type == 'LINEAR_LIGHT': + test_val = color2 > 0.5 + res = test_val.if_else(color1 + fac * (2.0 * (color2 - 0.5)), + color1 + fac * (2.0 * color2 - 1.0)) + + else: + # TODO: support operations SATURATION, HUE, SCREEN, BURN, OVERLAY + log.warn("Ignoring unsupported Blend Type", blend_type, self.node, self.material, + "mix will be used") + res = fac.blend(color1, color2) + + if self.node.use_clamp: + res = res.clamp() + + return res diff --git a/materialx/bl_nodes/nodes/converter.py b/materialx/bl_nodes/nodes/converter.py new file mode 100644 index 000000000..f0f3a3df4 --- /dev/null +++ b/materialx/bl_nodes/nodes/converter.py @@ -0,0 +1,73 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright 2022, AMD + +from ..node_parser import NodeParser + +from ... import logging +log = logging.Log("bl_nodes.nodes.converter") + + +class ShaderNodeMath(NodeParser): + """ Map Blender operations to MaterialX definitions, see the stdlib_defs.mtlx in MaterialX """ + + def export(self): + op = self.node.operation + in1 = self.get_input_value(0) + # single operand operations + if op == 'SINE': + res = in1.sin() + elif op == 'COSINE': + res = in1.cos() + elif op == 'TANGENT': + res = in1.tan() + elif op == 'ARCSINE': + res = in1.asin() + elif op == 'ARCCOSINE': + res = in1.acos() + elif op == 'ARCTANGENT': + res = in1.atan() + elif op == 'LOGARITHM': + res = in1.log() + elif op == 'ABSOLUTE': + res = abs(in1) + elif op == 'FLOOR': + res = in1.floor() + elif op == 'FRACT': + res = in1 % 1.0 + elif op == 'CEIL': + res = in1.ceil() + elif op == 'ROUND': + f = in1.floor() + res = (in1 % 1.0).if_else('>=', 0.5, f + 1.0, f) + + else: # 2-operand operations + in2 = self.get_input_value(1) + + if op == 'ADD': + res = in1 + in2 + elif op == 'SUBTRACT': + res = in1 - in2 + elif op == 'MULTIPLY': + res = in1 * in2 + elif op == 'DIVIDE': + res = in1 / in2 + elif op == 'POWER': + res = in1 ** in2 + elif op == 'MINIMUM': + res = in1.min(in2) + elif op == 'MAXIMUM': + res = in1.max(in2) + + else: + in3 = self.get_input_value(2) + + if op == 'MULTIPLY_ADD': + res = in1 * in2 + in3 + else: + log.warn("Unsupported math operation", op) + return None + + if self.node.use_clamp: + res = res.clamp() + + return res diff --git a/materialx/bl_nodes/nodes/input.py b/materialx/bl_nodes/nodes/input.py new file mode 100644 index 000000000..37ccc9d5b --- /dev/null +++ b/materialx/bl_nodes/nodes/input.py @@ -0,0 +1,18 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright 2022, AMD + +from ..node_parser import NodeParser + + +class ShaderNodeValue(NodeParser): + """ Returns float value """ + + def export(self): + return self.get_output_default() + + +class ShaderNodeRGB(NodeParser): + """ Returns color value """ + + def export(self): + return self.get_output_default() diff --git a/materialx/bl_nodes/nodes/output.py b/materialx/bl_nodes/nodes/output.py new file mode 100644 index 000000000..aa9241404 --- /dev/null +++ b/materialx/bl_nodes/nodes/output.py @@ -0,0 +1,31 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright 2022, AMD + +from ..node_parser import NodeParser, Id + + +class ShaderNodeOutputMaterial(NodeParser): + nodegraph_path = "" + + def __init__(self, doc, material, node, obj, **kwargs): + super().__init__(Id(), doc, material, node, obj, None, None, {}, **kwargs) + + def export(self): + surface = self.get_input_link('Surface') + if surface is None: + return None + + if surface.type == 'BSDF': + surface = self.create_node('surface', 'surfaceshader', { + 'bsdf': surface, + }) + elif surface.type == 'EDF': + surface = self.create_node('surface', 'surfaceshader', { + 'edf': surface, + }) + + result = self.create_node('surfacematerial', 'material', { + 'surfaceshader': surface, + }) + + return result diff --git a/materialx/bl_nodes/nodes/shader.py b/materialx/bl_nodes/nodes/shader.py new file mode 100644 index 000000000..02b6173e1 --- /dev/null +++ b/materialx/bl_nodes/nodes/shader.py @@ -0,0 +1,266 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright 2022, AMD + +import math + +from ..node_parser import NodeParser + +from ... import logging +log = logging.Log("bl_nodes.nodes.shader") + + +SSS_MIN_RADIUS = 0.0001 +DEFAULT_WHITE_COLOR = (1.0, 1.0, 1.0) + + +def enabled(val): + if val is None: + return False + + if isinstance(val.data, float) and math.isclose(val.data, 0.0): + return False + + if isinstance(val.data, tuple) and \ + math.isclose(val.data[0], 0.0) and \ + math.isclose(val.data[1], 0.0) and \ + math.isclose(val.data[2], 0.0): + return False + + return True + + +class ShaderNodeBsdfPrincipled(NodeParser): + nodegraph_path = "" + + def export(self): + # GETTING REQUIRED INPUTS + # Note: if some inputs are not needed they won't be taken + + base_color = self.get_input_value('Base Color') + + subsurface = self.get_input_value('Subsurface') + subsurface_radius = None + subsurface_color = None + if enabled(subsurface): + subsurface_radius = self.get_input_value('Subsurface Radius') + subsurface_color = self.get_input_value('Subsurface Color') + + metallic = self.get_input_value('Metallic') + specular = self.get_input_value('Specular') + # specular_tint = self.get_input_value('Specular Tint') + roughness = self.get_input_value('Roughness') + + anisotropic = None + anisotropic_rotation = None + if enabled(metallic): + # TODO: use Specular Tint input + anisotropic = self.get_input_value('Anisotropic') + if enabled(anisotropic): + anisotropic_rotation = self.get_input_value('Anisotropic Rotation') + # anisotropic_rotation = 0.5 - (anisotropic_rotation % 1.0) + + sheen = self.get_input_value('Sheen') + # sheen_tint = None + # if enabled(sheen): + # sheen_tint = self.get_input_value('Sheen Tint') + + clearcoat = self.get_input_value('Clearcoat') + clearcoat_roughness = None + if enabled(clearcoat): + clearcoat_roughness = self.get_input_value('Clearcoat Roughness') + + ior = self.get_input_value('IOR') + + transmission = self.get_input_value('Transmission') + transmission_roughness = None + if enabled(transmission): + transmission_roughness = self.get_input_value('Transmission Roughness') + + emission = self.get_input_value('Emission') + emission_strength = self.get_input_value('Emission Strength') + + alpha = self.get_input_value('Alpha') + # transparency = 1.0 - alpha + + normal = self.get_input_link('Normal') + clearcoat_normal = self.get_input_link('Clearcoat Normal') + tangent = self.get_input_link('Tangent') + + # CREATING STANDARD SURFACE + result = self.create_node('standard_surface', 'surfaceshader', { + 'base': 1.0, + 'base_color': base_color, + 'diffuse_roughness': roughness, + 'normal': normal, + 'tangent': tangent, + }) + + if enabled(metallic): + result.set_input('metalness', metallic) + + if enabled(specular): + result.set_inputs({ + 'specular': specular, + 'specular_color': DEFAULT_WHITE_COLOR, + 'specular_roughness': roughness, + 'specular_IOR': ior, + 'specular_anisotropy': anisotropic, + 'specular_rotation': anisotropic_rotation, + }) + + if enabled(transmission): + result.set_inputs({ + 'transmission': transmission, + 'transmission_color': DEFAULT_WHITE_COLOR, + 'transmission_extra_roughness': transmission_roughness, + }) + + if enabled(subsurface): + result.set_inputs({ + 'subsurface': subsurface, + 'subsurface_color': subsurface_color, + 'subsurface_radius': subsurface_radius, + 'subsurface_anisotropy': anisotropic, + }) + + if enabled(sheen): + result.set_inputs({ + 'sheen': sheen, + 'sheen_color': DEFAULT_WHITE_COLOR, + 'sheen_roughness': roughness, + }) + + if enabled(clearcoat): + result.set_inputs({ + 'coat': clearcoat, + 'coat_color': DEFAULT_WHITE_COLOR, + 'coat_roughness': clearcoat_roughness, + 'coat_IOR': ior, + 'coat_anisotropy': anisotropic, + 'coat_rotation': anisotropic_rotation, + 'coat_normal': clearcoat_normal, + }) + + if enabled(emission): + result.set_inputs({ + 'emission': emission_strength, + 'emission_color': emission, + }) + + return result + + +class ShaderNodeBsdfDiffuse(NodeParser): + nodegraph_path = "" + + def export(self): + color = self.get_input_value('Color') + roughness = self.get_input_value('Roughness') + normal = self.get_input_link('Normal') + + # Also tried burley_diffuse_bsdf and oren_nayar_diffuse_bsdf here, but Blender crashes with them + # CREATING STANDARD SURFACE + result = self.create_node('standard_surface', 'surfaceshader', { + 'base_color': color, + 'diffuse_roughness': 1.0 - roughness, + 'normal': normal, + }) + + return result + + +class ShaderNodeBsdfGlass(NodeParser): + def export(self): + color = self.get_input_value('Color') + roughness = self.get_input_value('Roughness') + ior = self.get_input_value('IOR') + normal = self.get_input_link('Normal') + + # CREATING STANDARD SURFACE + result = self.create_node('standard_surface', 'surfaceshader', { + 'base': 0.0, + 'normal': normal, + 'specular': 1.0, + 'specular_color': color, + 'specular_roughness': roughness, + 'specular_IOR': ior, + 'specular_anisotropy': 0.0, + 'specular_rotation': 0.0, + 'transmission': 1.0, + 'transmission_color': color, + 'transmission_extra_roughness': roughness, + }) + + return result + + +class ShaderNodeEmission(NodeParser): + nodegraph_path = "" + + def export(self): + result = self.create_node('standard_surface', 'surfaceshader') + + color = self.get_input_value('Color') + strength = self.get_input_value('Strength') + + if enabled(color) and enabled(strength): + result.set_inputs({ + 'emission': 1.0, + 'emission_color': color * strength, + }) + + return result + + +class ShaderNodeMixShader(NodeParser): + nodegraph_path = "" + + def export(self): + factor = self.get_input_value(0) + shader1 = self.get_input_link(1) + shader2 = self.get_input_link(2) + + if shader1 is None and shader2 is None: + return None + + if shader1 is None: + return shader2 + + if shader2 is None: + return shader1 + + result = self.create_node('STD_mix', 'surfaceshader', { + 'fg': shader1, + 'bg': shader2, + 'mix': factor + }) + + log.warn(f"Known issue: node doesn't work correctly with {result.nodedef.getName()}", self.material, self.node) + + return result + + +class ShaderNodeAddShader(NodeParser): + nodegraph_path = "" + + def export(self): + shader1 = self.get_input_link(0) + shader2 = self.get_input_link(1) + + if shader1 is None and shader2 is None: + return None + + if shader1 is None: + return shader2 + + if shader2 is None: + return shader1 + + result = self.create_node('STD_add', 'surfaceshader', { + 'in1': shader1, + 'in2': shader2 + }) + + log.warn(f"Known issue: node doesn't work correctly with {result.nodedef.getName()}", self.material, self.node) + + return result diff --git a/materialx/bl_nodes/nodes/texture.py b/materialx/bl_nodes/nodes/texture.py new file mode 100644 index 000000000..95612cfe1 --- /dev/null +++ b/materialx/bl_nodes/nodes/texture.py @@ -0,0 +1,32 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright 2022, AMD + +from ..node_parser import NodeParser +from ...utils import cache_image_file + + +TEXTURE_ERROR_COLOR = (1.0, 0.0, 1.0) # following Cycles color for wrong Texture nodes + + +class ShaderNodeTexImage(NodeParser): + def export(self): + image_error_result = self.node_item(TEXTURE_ERROR_COLOR) + image = self.node.image + + # TODO support UDIM Tilesets and SEQUENCE + if not image or image.source in ('TILED', 'SEQUENCE'): + return image_error_result + + img_path = cache_image_file(image) + if not img_path: + return image_error_result + + # TODO use Vector input for UV + uv = self.create_node('texcoord', 'vector2', {}) + + result = self.create_node('image', self.out_type, { + 'file': img_path, + 'texcoord': uv, + }) + + return result diff --git a/materialx/bl_nodes/nodes/vector.py b/materialx/bl_nodes/nodes/vector.py new file mode 100644 index 000000000..8eed4e462 --- /dev/null +++ b/materialx/bl_nodes/nodes/vector.py @@ -0,0 +1,33 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright 2022, AMD + +from ..node_parser import NodeParser + +from ... import logging +log = logging.Log("bl_nodes.nodes.vector") + +DEFAULT_SPACE = 'OBJECT' + + +class ShaderNodeNormalMap(NodeParser): + def export(self): + color = self.get_input_value('Color') + strength = self.get_input_value('Strength') + space = self.node.space + + if space not in ('TANGENT', 'OBJECT'): + log.warn("Ignoring unsupported Space", space, self.node, self.material, + f"{DEFAULT_SPACE} will be used") + space = DEFAULT_SPACE + + if space == 'TANGENT': + log.warn("Ignoring unsupported UV Map", space, self.node, self.material, + "No UV Map will be used") + + result = self.create_node('normalmap', 'vector3', { + 'in': color , + 'scale': strength, + 'space': space.lower(), + }) + + return result diff --git a/materialx/material/__init__.py b/materialx/material/__init__.py index 5beba298b..374df142b 100644 --- a/materialx/material/__init__.py +++ b/materialx/material/__init__.py @@ -50,12 +50,10 @@ register_classes, unregister_classes = bpy.utils.register_classes_factory([ def register(): - ui.register() properties.register() register_classes() def unregister(): - ui.unregister() properties.unregister() unregister_classes() diff --git a/materialx/material/properties.py b/materialx/material/properties.py index 2d66021ef..b27269d33 100644 --- a/materialx/material/properties.py +++ b/materialx/material/properties.py @@ -7,6 +7,7 @@ import bpy import MaterialX as mx from ..node_tree import MxNodeTree +from ..bl_nodes.nodes import ShaderNodeOutputMaterial from ..utils import MX_LIBS_DIR from ..utils import logging, get_temp_file, MaterialXProperties @@ -45,10 +46,9 @@ class MaterialProperties(MaterialXProperties): doc = mx.createDocument() - # TODO add implementation - # node_parser = ShaderNodeOutputMaterial(doc, material, output_node, obj) - # if not node_parser.export(): - # return None + node_parser = ShaderNodeOutputMaterial(doc, material, output_node, obj) + if not node_parser.export(): + return None return doc @@ -78,10 +78,9 @@ class MaterialProperties(MaterialXProperties): else: doc = mx.createDocument() - # TODO add implementation - # node_parser = ShaderNodeOutputMaterial(doc, mat, output_node, obj) - # if not node_parser.export(): - # return False + node_parser = ShaderNodeOutputMaterial(doc, mat, output_node, obj) + if not node_parser.export(): + return False if not doc: log.warn("Incorrect node tree to export", mx_node_tree) diff --git a/materialx/material/ui.py b/materialx/material/ui.py index 10398b6e4..ef8fac0cf 100644 --- a/materialx/material/ui.py +++ b/materialx/material/ui.py @@ -12,6 +12,7 @@ from . import MATERIALX_Panel, MATERIALX_ChildPanel from ..node_tree import MxNodeTree, NODE_LAYER_SEPARATION_WIDTH from ..nodes.node import is_mx_node_valid from .. import utils +from ..preferences import addon_preferences from ..utils import pass_node_reroute, title_str, mx_properties from ..utils import logging @@ -698,7 +699,7 @@ class MATERIAL_PT_dev(MATERIALX_ChildPanel): @classmethod def poll(cls, context): - return config.show_dev_settings + return addon_preferences().dev_tools def draw(self, context): layout = self.layout @@ -717,8 +718,6 @@ def depsgraph_update(depsgraph): if not hasattr(screen, 'areas'): return - bpy.types.NODE_HT_header.remove(update_material_ui) - for window in context.window_manager.windows: for area in window.screen.areas: if not mx_node_tree: @@ -739,36 +738,3 @@ def depsgraph_update(depsgraph): space.node_tree = mx_node_tree mx_node_tree.update_links() - - bpy.types.NODE_HT_header.append(update_material_ui) - - -# update for material ui according to MaterialX nodetree header changes -def update_material_ui(self, context): - obj = context.active_object - if not obj: - return - - mat = obj.active_material - if not mat: - return - - space = context.space_data - if space.tree_type != utils.with_prefix('MxNodeTree'): - return - - ui_mx_node_tree = mx_properties(mat).mx_node_tree - editor_node_tree = space.node_tree - - if editor_node_tree != ui_mx_node_tree and not space.pin and editor_node_tree: - mx_properties(mat).mx_node_tree = editor_node_tree - - -def register(): - # set update for material ui according to MaterialX nodetree header changes - bpy.types.NODE_HT_header.append(update_material_ui) - - -def unregister(): - # remove update for material ui according to MaterialX nodetree header changes - bpy.types.NODE_HT_header.remove(update_material_ui) diff --git a/materialx/matlib/manager.py b/materialx/matlib/manager.py index dad1e40ff..761f46d6d 100644 --- a/materialx/matlib/manager.py +++ b/materialx/matlib/manager.py @@ -13,11 +13,9 @@ from concurrent import futures import bpy.utils.previews -from ..utils import logging, update_ui, MATLIB_DIR +from ..utils import logging, update_ui, MATLIB_DIR, MATLIB_URL log = logging.Log('matlib.manager') -URL = "https://api.matlib.gpuopen.com/api" - def download_file(url, path, cache_check=True): if cache_check and path.is_file(): @@ -101,7 +99,7 @@ class Render: return self.material().cache_dir def get_info(self, cache_chek=True): - json_data = request_json(f"{URL}/renders/{self.id}", None, + json_data = request_json(f"{MATLIB_URL}/renders/{self.id}", None, self.cache_dir / f"R-{self.id[:8]}.json", cache_chek) self.author = json_data['author'] @@ -152,7 +150,7 @@ class Package: return self.file_path.is_file() def get_info(self, cache_check=True): - json_data = request_json(f"{URL}/packages/{self.id}", None, + json_data = request_json(f"{MATLIB_URL}/packages/{self.id}", None, self.cache_dir / "info.json", cache_check) self.author = json_data['author'] @@ -212,7 +210,7 @@ class Category: if not self.id: return - json_data = request_json(f"{URL}/categories/{self.id}", None, + json_data = request_json(f"{MATLIB_URL}/categories/{self.id}", None, self.cache_dir / f"C-{self.id[:8]}.json", use_cache) self.title = json_data['title'] @@ -263,7 +261,7 @@ class Material: limit = 500 while True: - res_json = request_json(f"{URL}/materials", {'limit': limit, 'offset': offset}, None) + res_json = request_json(f"{MATLIB_URL}/materials", {'limit': limit, 'offset': offset}, None) count = res_json['count'] diff --git a/materialx/nodes/categories.py b/materialx/nodes/categories.py index 2ff2c6863..14467ee08 100644 --- a/materialx/nodes/categories.py +++ b/materialx/nodes/categories.py @@ -1,17 +1,6 @@ -# ********************************************************************** -# Copyright 2020 Advanced Micro Devices, Inc -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ******************************************************************** +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright 2022, AMD + from collections import defaultdict from nodeitems_utils import NodeCategory, NodeItem diff --git a/materialx/utils.py b/materialx/utils.py index 12374edb1..9b7abd423 100644 --- a/materialx/utils.py +++ b/materialx/utils.py @@ -26,10 +26,37 @@ NODE_CLASSES_DIR = ADDON_DATA_DIR / NODE_CLASSES_FOLDER MATLIB_FOLDER = "matlib" MATLIB_DIR = ADDON_DATA_DIR / MATLIB_FOLDER +MATLIB_URL = "https://api.matlib.gpuopen.com/api" + +SUPPORTED_FORMATS = {".png", ".jpeg", ".jpg", ".hdr", ".tga", ".bmp"} +DEFAULT_FORMAT = ".hdr" +BLENDER_DEFAULT_FORMAT = "HDR" +BLENDER_DEFAULT_COLOR_MODE = "RGB" +READONLY_IMAGE_FORMATS = {".dds"} # blender can read these formats, but can't write os.environ['MATERIALX_SEARCH_PATH'] = str(MX_LIBS_DIR) +class MaterialXProperties(bpy.types.PropertyGroup): + bl_type = None + + @classmethod + def register(cls): + setattr(cls.bl_type, ADDON_ALIAS, bpy.props.PointerProperty( + name="MaterialX properties", + description="MaterialX properties", + type=cls, + )) + + @classmethod + def unregister(cls): + delattr(cls.bl_type, ADDON_ALIAS) + + +def mx_properties(obj): + return getattr(obj, ADDON_ALIAS) + + def with_prefix(name, separator='.', upper=False): return f"{ADDON_ALIAS.upper() if upper else ADDON_ALIAS}{separator}{name}" @@ -391,21 +418,59 @@ def update_ui(area_type='PROPERTIES', region_type='WINDOW'): region.tag_redraw() -class MaterialXProperties(bpy.types.PropertyGroup): - bl_type = None +def cache_image_file(image: bpy.types.Image, cache_check=True): + image_path = Path(image.filepath_from_user()) + if not image.packed_file and image.source != 'GENERATED': + if not image_path.is_file(): + log.warn("Image is missing", image, image_path) + return None - @classmethod - def register(cls): - setattr(cls.bl_type, ADDON_ALIAS, bpy.props.PointerProperty( - name="MaterialX properties", - description="MaterialX properties", - type=cls, - )) + image_suffix = image_path.suffix.lower() - @classmethod - def unregister(cls): - delattr(cls.bl_type, ADDON_ALIAS) + if image_suffix in SUPPORTED_FORMATS and\ + f".{image.file_format.lower()}" in SUPPORTED_FORMATS and not image.is_dirty: + return image_path + + if image_suffix in READONLY_IMAGE_FORMATS: + return image_path + + temp_path = get_temp_file(DEFAULT_FORMAT, image_path.stem) + if cache_check and image.source != 'GENERATED' and temp_path.is_file(): + return temp_path + + scene = bpy.context.scene + user_format = scene.render.image_settings.file_format + user_color_mode = scene.render.image_settings.color_mode + + # in some scenes the color_mode is undefined + # we can read it but unable to assign back, so switch it to 'RGB' if color_mode isn't selected + if not user_color_mode: + user_color_mode = 'RGB' + + scene.render.image_settings.file_format = BLENDER_DEFAULT_FORMAT + scene.render.image_settings.color_mode = BLENDER_DEFAULT_COLOR_MODE + + try: + image.save_render(filepath=str(temp_path)) + finally: + scene.render.image_settings.file_format = user_format + scene.render.image_settings.color_mode = user_color_mode + + return temp_path -def mx_properties(obj): - return getattr(obj, ADDON_ALIAS) +def cache_image_file_path(image_path, cache_check=True): + if image_path.suffix.lower() in SUPPORTED_FORMATS: + return image_path + + if cache_check: + temp_path = get_temp_file(DEFAULT_FORMAT, image_path.name) + if temp_path.is_file(): + return temp_path + + image = bpy.data.images.load(str(image_path)) + try: + return cache_image_file(image, cache_check) + + finally: + bpy.data.images.remove(image) -- 2.30.2 From cc589bc9168036935f105fa97a505416aa5dcf46 Mon Sep 17 00:00:00 2001 From: Bogdan Nagirniak <33626169+bnagirniak@users.noreply.github.com> Date: Thu, 15 Sep 2022 12:37:08 +0300 Subject: [PATCH 08/28] BLEN-221: Code cleanups, UI improvements (#7) Made UI improvements: removed unused panels, fixed text, etc. Made code cleanups and improvements, removed unused code. Refactoring: moved NodeParser node classes to bl_nodes folder. Fixed some TODOs. --- materialx/__init__.py | 4 +- materialx/bl_nodes/__init__.py | 115 +++----- materialx/bl_nodes/{nodes => }/color.py | 6 +- materialx/bl_nodes/{nodes => }/converter.py | 6 +- materialx/bl_nodes/{nodes => }/input.py | 2 +- materialx/bl_nodes/node_parser.py | 5 +- materialx/bl_nodes/nodes/__init__.py | 10 - materialx/bl_nodes/{nodes => }/output.py | 2 +- materialx/bl_nodes/{nodes => }/shader.py | 6 +- materialx/bl_nodes/{nodes => }/texture.py | 4 +- materialx/bl_nodes/{nodes => }/vector.py | 5 +- materialx/logging.py | 2 +- materialx/material/__init__.py | 24 +- materialx/material/properties.py | 5 +- materialx/material/ui.py | 281 ++++---------------- materialx/matlib/ui.py | 6 +- materialx/node_tree.py | 8 +- materialx/nodes/ui.py | 3 +- materialx/preferences.py | 4 + materialx/utils.py | 4 +- 20 files changed, 119 insertions(+), 383 deletions(-) rename materialx/bl_nodes/{nodes => }/color.py (95%) rename materialx/bl_nodes/{nodes => }/converter.py (94%) rename materialx/bl_nodes/{nodes => }/input.py (89%) delete mode 100644 materialx/bl_nodes/nodes/__init__.py rename materialx/bl_nodes/{nodes => }/output.py (95%) rename materialx/bl_nodes/{nodes => }/shader.py (98%) rename materialx/bl_nodes/{nodes => }/texture.py (91%) rename materialx/bl_nodes/{nodes => }/vector.py (89%) diff --git a/materialx/__init__.py b/materialx/__init__.py index 4803911b0..4cf35f2ca 100644 --- a/materialx/__init__.py +++ b/materialx/__init__.py @@ -46,14 +46,14 @@ def register(): register_classes() nodes.register() - matlib.register() material.register() + matlib.register() def unregister(): log("unregister") - material.unregister() matlib.unregister() + material.unregister() nodes.unregister() unregister_classes() diff --git a/materialx/bl_nodes/__init__.py b/materialx/bl_nodes/__init__.py index 86e832e68..e00417f99 100644 --- a/materialx/bl_nodes/__init__.py +++ b/materialx/bl_nodes/__init__.py @@ -1,87 +1,38 @@ # SPDX-License-Identifier: GPL-2.0-or-later # Copyright 2022, AMD -from nodeitems_utils import ( - NodeCategory, - NodeItem, - register_node_categories, - unregister_node_categories, +from .. import logging +log = logging.Log("bl_nodes") + + +from . import ( + color, + converter, + input, + output, + shader, + texture, + vector, ) -from nodeitems_builtins import ( - ShaderNodeCategory, +node_parser_classes = ( + output.ShaderNodeOutputMaterial, + + color.ShaderNodeInvert, + color.ShaderNodeMixRGB, + + converter.ShaderNodeMath, + + input.ShaderNodeValue, + input.ShaderNodeRGB, + + shader.ShaderNodeAddShader, + shader.ShaderNodeMixShader, + shader.ShaderNodeEmission, + shader.ShaderNodeBsdfGlass, + shader.ShaderNodeBsdfDiffuse, + shader.ShaderNodeBsdfPrincipled, + + texture.ShaderNodeTexImage, + + vector.ShaderNodeNormalMap, ) -from .. import utils - - -class CompatibleShaderNodeCategory(NodeCategory): - """ Appear with an active USD plugin in Material shader editor only """ - @classmethod - def poll(cls, context): - return context.space_data.tree_type == 'ShaderNodeTree' - - -# add nodes here once they are supported -node_categories = [ - CompatibleShaderNodeCategory(utils.with_prefix("SHADER_NODE_CATEGORY_INPUT", '_', True), "Input", items=[ - NodeItem('ShaderNodeRGB'), - NodeItem('ShaderNodeValue'), - ], ), - CompatibleShaderNodeCategory(utils.with_prefix("SHADER_NODE_CATEGORY_OUTPUT", '_', True), "Output", items=[ - NodeItem('ShaderNodeOutputMaterial'), - ], ), - CompatibleShaderNodeCategory(utils.with_prefix("SHADER_NODE_CATEGORY_SHADERS", '_', True), "Shader", items=[ - NodeItem('ShaderNodeBsdfDiffuse'), - NodeItem('ShaderNodeBsdfGlass'), - NodeItem('ShaderNodeEmission'), - NodeItem('ShaderNodeBsdfPrincipled'), - ]), - CompatibleShaderNodeCategory(utils.with_prefix("SHADER_NODE_CATEGORY_TEXTURE", '_', True), "Texture", items=[ - NodeItem('ShaderNodeTexImage'), - ], ), - CompatibleShaderNodeCategory(utils.with_prefix("SHADER_NODE_CATEGORY_COLOR", '_', True), "Color", items=[ - NodeItem('ShaderNodeInvert'), - NodeItem('ShaderNodeMixRGB'), - ], ), - CompatibleShaderNodeCategory(utils.with_prefix("SHADER_NODE_CATEGORY_CONVERTER", '_', True), "Converter", items=[ - NodeItem('ShaderNodeMath'), - ], ), - CompatibleShaderNodeCategory(utils.with_prefix("SHADER_NODE_CATEGORY_VECTOR", '_', True), "Vector", items=[ - NodeItem('ShaderNodeNormalMap'), - ], ), - CompatibleShaderNodeCategory(utils.with_prefix("SHADER_NODE_CATEGORY_LAYOUT", '_', True), "Layout", items=[ - NodeItem('NodeFrame'), - NodeItem('NodeReroute'), - ], ), -] - - -# some nodes are hidden from plugins by Cycles itself(like Material Output), some we could not support. -# thus we'll hide 'em all to show only selected set of supported Blender nodes -# custom HdUSD_CompatibleShaderNodeCategory will be used instead -# def hide_cycles_and_eevee_poll(method): -# @classmethod -# def func(cls, context): -# return not context.scene.render.engine == 'HdUSD' and method(context) -# return func - - -old_shader_node_category_poll = None - - -def register(): - # hide Cycles/Eevee menu - # global old_shader_node_category_poll - # old_shader_node_category_poll = ShaderNodeCategory.poll - # ShaderNodeCategory.poll = hide_cycles_and_eevee_poll(ShaderNodeCategory.poll) - - # use custom menu - register_node_categories(utils.with_prefix("NODES", '_', True), node_categories) - - -def unregister(): - # restore Cycles/Eevee menu - # if old_shader_node_category_poll and ShaderNodeCategory.poll is not old_shader_node_category_poll: - # ShaderNodeCategory.poll = old_shader_node_category_poll - - # remove custom menu - unregister_node_categories(utils.with_prefix("NODES", '_', True)) diff --git a/materialx/bl_nodes/nodes/color.py b/materialx/bl_nodes/color.py similarity index 95% rename from materialx/bl_nodes/nodes/color.py rename to materialx/bl_nodes/color.py index 6b850895d..63bcbec03 100644 --- a/materialx/bl_nodes/nodes/color.py +++ b/materialx/bl_nodes/color.py @@ -1,10 +1,8 @@ # SPDX-License-Identifier: GPL-2.0-or-later # Copyright 2022, AMD -from ..node_parser import NodeParser - -from ... import logging -log = logging.Log("bl_nodes.nodes.color") +from .node_parser import NodeParser +from . import log class ShaderNodeInvert(NodeParser): diff --git a/materialx/bl_nodes/nodes/converter.py b/materialx/bl_nodes/converter.py similarity index 94% rename from materialx/bl_nodes/nodes/converter.py rename to materialx/bl_nodes/converter.py index f0f3a3df4..0154cd263 100644 --- a/materialx/bl_nodes/nodes/converter.py +++ b/materialx/bl_nodes/converter.py @@ -1,10 +1,8 @@ # SPDX-License-Identifier: GPL-2.0-or-later # Copyright 2022, AMD -from ..node_parser import NodeParser - -from ... import logging -log = logging.Log("bl_nodes.nodes.converter") +from .node_parser import NodeParser +from . import log class ShaderNodeMath(NodeParser): diff --git a/materialx/bl_nodes/nodes/input.py b/materialx/bl_nodes/input.py similarity index 89% rename from materialx/bl_nodes/nodes/input.py rename to materialx/bl_nodes/input.py index 37ccc9d5b..870f5a2c0 100644 --- a/materialx/bl_nodes/nodes/input.py +++ b/materialx/bl_nodes/input.py @@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-or-later # Copyright 2022, AMD -from ..node_parser import NodeParser +from .node_parser import NodeParser class ShaderNodeValue(NodeParser): diff --git a/materialx/bl_nodes/node_parser.py b/materialx/bl_nodes/node_parser.py index 0f61faa13..d6ecfbfd0 100644 --- a/materialx/bl_nodes/node_parser.py +++ b/materialx/bl_nodes/node_parser.py @@ -9,6 +9,7 @@ import MaterialX as mx from .. import utils from ..utils import pass_node_reroute from ..nodes import get_mx_node_cls + from .. import logging log = logging.Log("bl_nodes.node_parser") @@ -265,8 +266,8 @@ class NodeParser: @staticmethod def get_node_parser_cls(bl_idname): """ Returns NodeParser class for node_idname or None if not found """ - from . import nodes - return getattr(nodes, bl_idname, None) + from . import node_parser_classes + return next((cls for cls in node_parser_classes if cls.__name__ == bl_idname), None) # INTERNAL FUNCTIONS def _export_node(self, node, out_key, to_socket, group_node=None): diff --git a/materialx/bl_nodes/nodes/__init__.py b/materialx/bl_nodes/nodes/__init__.py deleted file mode 100644 index 6d0f9d3af..000000000 --- a/materialx/bl_nodes/nodes/__init__.py +++ /dev/null @@ -1,10 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-or-later -# Copyright 2022, AMD - -from .input import * -from .output import * -from .shader import * -from .texture import * -from .color import * -from .converter import * -from .vector import * diff --git a/materialx/bl_nodes/nodes/output.py b/materialx/bl_nodes/output.py similarity index 95% rename from materialx/bl_nodes/nodes/output.py rename to materialx/bl_nodes/output.py index aa9241404..2af4fb633 100644 --- a/materialx/bl_nodes/nodes/output.py +++ b/materialx/bl_nodes/output.py @@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-or-later # Copyright 2022, AMD -from ..node_parser import NodeParser, Id +from .node_parser import NodeParser, Id class ShaderNodeOutputMaterial(NodeParser): diff --git a/materialx/bl_nodes/nodes/shader.py b/materialx/bl_nodes/shader.py similarity index 98% rename from materialx/bl_nodes/nodes/shader.py rename to materialx/bl_nodes/shader.py index 02b6173e1..a780a6e5e 100644 --- a/materialx/bl_nodes/nodes/shader.py +++ b/materialx/bl_nodes/shader.py @@ -3,10 +3,8 @@ import math -from ..node_parser import NodeParser - -from ... import logging -log = logging.Log("bl_nodes.nodes.shader") +from .node_parser import NodeParser +from . import log SSS_MIN_RADIUS = 0.0001 diff --git a/materialx/bl_nodes/nodes/texture.py b/materialx/bl_nodes/texture.py similarity index 91% rename from materialx/bl_nodes/nodes/texture.py rename to materialx/bl_nodes/texture.py index 95612cfe1..eeda9d524 100644 --- a/materialx/bl_nodes/nodes/texture.py +++ b/materialx/bl_nodes/texture.py @@ -1,8 +1,8 @@ # SPDX-License-Identifier: GPL-2.0-or-later # Copyright 2022, AMD -from ..node_parser import NodeParser -from ...utils import cache_image_file +from .node_parser import NodeParser +from ..utils import cache_image_file TEXTURE_ERROR_COLOR = (1.0, 0.0, 1.0) # following Cycles color for wrong Texture nodes diff --git a/materialx/bl_nodes/nodes/vector.py b/materialx/bl_nodes/vector.py similarity index 89% rename from materialx/bl_nodes/nodes/vector.py rename to materialx/bl_nodes/vector.py index 8eed4e462..3c2e125f3 100644 --- a/materialx/bl_nodes/nodes/vector.py +++ b/materialx/bl_nodes/vector.py @@ -1,10 +1,9 @@ # SPDX-License-Identifier: GPL-2.0-or-later # Copyright 2022, AMD -from ..node_parser import NodeParser +from .node_parser import NodeParser +from . import log -from ... import logging -log = logging.Log("bl_nodes.nodes.vector") DEFAULT_SPACE = 'OBJECT' diff --git a/materialx/logging.py b/materialx/logging.py index 30b03c501..3e688d7cd 100644 --- a/materialx/logging.py +++ b/materialx/logging.py @@ -11,7 +11,7 @@ FORMAT_STR = "%(asctime)s %(levelname)s %(name)s [%(thread)d]: %(message)s" # root logger for the addon logger = logging.getLogger(ADDON_ALIAS) -logger.setLevel('DEBUG') +logger.setLevel('INFO') # file_handler = logging.handlers.RotatingFileHandler(PLUGIN_ROOT_DIR / 'usdhydra.log', # mode='w', encoding='utf-8', delay=True, diff --git a/materialx/material/__init__.py b/materialx/material/__init__.py index 374df142b..3e7eb6774 100644 --- a/materialx/material/__init__.py +++ b/materialx/material/__init__.py @@ -3,27 +3,12 @@ import bpy - -class MATERIALX_Panel(bpy.types.Panel): - bl_space_type = 'PROPERTIES' - bl_region_type = 'WINDOW' - bl_context = 'render' - - -class MATERIALX_ChildPanel(bpy.types.Panel): - bl_space_type = 'PROPERTIES' - bl_region_type = 'WINDOW' - bl_parent_id = '' - - from . import ( ui, properties ) register_classes, unregister_classes = bpy.utils.register_classes_factory([ - ui.MATERIAL_PT_context, - ui.MATERIAL_PT_preview, ui.MATERIAL_OP_new_mx_node_tree, ui.MATERIAL_OP_duplicate_mx_node_tree, ui.MATERIAL_OP_convert_shader_to_mx, @@ -31,17 +16,14 @@ register_classes, unregister_classes = bpy.utils.register_classes_factory([ ui.MATERIAL_OP_link_mx_node_tree, ui.MATERIAL_OP_unlink_mx_node_tree, ui.MATERIAL_MT_mx_node_tree, - ui.MATERIAL_PT_material, - ui.MATERIAL_PT_material_settings_surface, + ui.MATERIAL_PT_materialx, + ui.MATERIAL_PT_materialx_surfaceshader, + ui.MATERIAL_PT_materialx_displacementshader, ui.MATERIAL_OP_link_mx_node, ui.MATERIAL_OP_invoke_popup_input_nodes, ui.MATERIAL_OP_invoke_popup_shader_nodes, ui.MATERIAL_OP_remove_node, ui.MATERIAL_OP_disconnect_node, - ui.MATERIAL_PT_material_settings_displacement, - ui.MATERIAL_PT_output_surface, - ui.MATERIAL_PT_output_displacement, - ui.MATERIAL_PT_output_volume, ui.MATERIAL_OP_export_mx_file, ui.MATERIAL_OP_export_mx_console, ui.MATERIAL_PT_tools, diff --git a/materialx/material/properties.py b/materialx/material/properties.py index b27269d33..e59105c97 100644 --- a/materialx/material/properties.py +++ b/materialx/material/properties.py @@ -7,7 +7,7 @@ import bpy import MaterialX as mx from ..node_tree import MxNodeTree -from ..bl_nodes.nodes import ShaderNodeOutputMaterial +from ..bl_nodes.output import ShaderNodeOutputMaterial from ..utils import MX_LIBS_DIR from ..utils import logging, get_temp_file, MaterialXProperties @@ -30,8 +30,7 @@ class MaterialProperties(MaterialXProperties): return None return next((node for node in material.node_tree.nodes if - # TODO add implementation - # node.bl_idname == ShaderNodeOutputMaterial.__name__ and + node.bl_idname == ShaderNodeOutputMaterial.__name__ and node.is_active_output), None) def export(self, obj: bpy.types.Object) -> [mx.Document, None]: diff --git a/materialx/material/ui.py b/materialx/material/ui.py index ef8fac0cf..5c34f7d1d 100644 --- a/materialx/material/ui.py +++ b/materialx/material/ui.py @@ -8,97 +8,19 @@ import MaterialX as mx import bpy from bpy_extras.io_utils import ExportHelper -from . import MATERIALX_Panel, MATERIALX_ChildPanel from ..node_tree import MxNodeTree, NODE_LAYER_SEPARATION_WIDTH from ..nodes.node import is_mx_node_valid from .. import utils -from ..preferences import addon_preferences from ..utils import pass_node_reroute, title_str, mx_properties +from ..preferences import addon_preferences from ..utils import logging log = logging.Log(tag='material.ui') -class MATERIAL_PT_context(MATERIALX_Panel): - bl_label = "" - bl_context = "material" - bl_options = {'HIDE_HEADER'} - - @classmethod - def poll(cls, context): - if context.active_object and context.active_object.type == 'GPENCIL': - return False - else: - return context.material or context.object - - def draw(self, context): - layout = self.layout - - material = context.material - object = context.object - slot = context.material_slot - space = context.space_data - - if object: - is_sortable = len(object.material_slots) > 1 - rows = 1 - if is_sortable: - rows = 4 - - row = layout.row() - - row.template_list("MATERIAL_UL_matslots", "", object, "material_slots", object, - "active_material_index", rows=rows) - - col = row.column(align=True) - col.operator("object.material_slot_add", icon='ADD', text="") - col.operator("object.material_slot_remove", icon='REMOVE', text="") - - col.menu("MATERIAL_MT_context_menu", icon='DOWNARROW_HLT', text="") - - if is_sortable: - col.separator() - - col.operator("object.material_slot_move", icon='TRIA_UP', text="").direction = 'UP' - col.operator("object.material_slot_move", icon='TRIA_DOWN', text="").direction = 'DOWN' - - if object.mode == 'EDIT': - row = layout.row(align=True) - row.operator("object.material_slot_assign", text="Assign") - row.operator("object.material_slot_select", text="Select") - row.operator("object.material_slot_deselect", text="Deselect") - - split = layout.split(factor=0.65) - - if object: - split.template_ID(object, "active_material", new=utils.with_prefix("material_duplicate_mat_mx_node_tree")) - row = split.row() - - if slot: - row.prop(slot, "link", text="") - else: - row.label() - elif material: - split.template_ID(space, "pin_id") - split.separator() - - -class MATERIAL_PT_preview(MATERIALX_Panel): - bl_label = "Preview" - bl_context = "material" - bl_options = {'DEFAULT_CLOSED'} - - @classmethod - def poll(cls, context): - return context.material - - def draw(self, context): - self.layout.template_preview(context.material) - - class MATERIAL_OP_new_mx_node_tree(bpy.types.Operator): """Create new MaterialX node tree for selected material""" - bl_idname = utils.with_prefix("material_new_mx_node_tree") + bl_idname = utils.with_prefix('material_new_mx_node_tree') bl_label = "New" def execute(self, context): @@ -112,7 +34,7 @@ class MATERIAL_OP_new_mx_node_tree(bpy.types.Operator): class MATERIAL_OP_duplicate_mat_mx_node_tree(bpy.types.Operator): """Create duplicates of Material and MaterialX node tree for selected material""" - bl_idname = utils.with_prefix("material_duplicate_mat_mx_node_tree") + bl_idname = utils.with_prefix('material_duplicate_mat_mx_node_tree') bl_label = "" def execute(self, context): @@ -123,7 +45,7 @@ class MATERIAL_OP_duplicate_mat_mx_node_tree(bpy.types.Operator): class MATERIAL_OP_duplicate_mx_node_tree(bpy.types.Operator): """Create duplicate of MaterialX node tree for selected material""" - bl_idname = utils.with_prefix("material_duplicate_mx_node_tree") + bl_idname = utils.with_prefix('material_duplicate_mx_node_tree') bl_label = "" def execute(self, context): @@ -138,7 +60,7 @@ class MATERIAL_OP_duplicate_mx_node_tree(bpy.types.Operator): class MATERIAL_OP_convert_shader_to_mx(bpy.types.Operator): """Converts standard shader node tree to MaterialX node tree for selected material""" - bl_idname = utils.with_prefix("material_convert_shader_to_mx") + bl_idname = utils.with_prefix('material_convert_shader_to_mx') bl_label = "Convert to MaterialX" def execute(self, context): @@ -150,7 +72,7 @@ class MATERIAL_OP_convert_shader_to_mx(bpy.types.Operator): class MATERIAL_OP_link_mx_node_tree(bpy.types.Operator): """Link MaterialX node tree to selected material""" - bl_idname = utils.with_prefix("material_link_mx_node_tree") + bl_idname = utils.with_prefix('material_link_mx_node_tree') bl_label = "" mx_node_tree_name: bpy.props.StringProperty(default="") @@ -162,7 +84,7 @@ class MATERIAL_OP_link_mx_node_tree(bpy.types.Operator): class MATERIAL_OP_unlink_mx_node_tree(bpy.types.Operator): """Unlink MaterialX node tree from selected material""" - bl_idname = utils.with_prefix("material_unlink_mx_node_tree") + bl_idname = utils.with_prefix('material_unlink_mx_node_tree') bl_label = "" def execute(self, context): @@ -171,7 +93,7 @@ class MATERIAL_OP_unlink_mx_node_tree(bpy.types.Operator): class MATERIAL_MT_mx_node_tree(bpy.types.Menu): - bl_idname = "MATERIAL_MT_mx_node_tree" + bl_idname = utils.with_prefix('MATERIAL_MT_mx_node_tree', '_', True) bl_label = "MX Nodetree" def draw(self, context): @@ -189,8 +111,11 @@ class MATERIAL_MT_mx_node_tree(bpy.types.Menu): op.mx_node_tree_name = ng.name -class MATERIAL_PT_material(MATERIALX_Panel): - bl_label = "" +class MATERIAL_PT_materialx(bpy.types.Panel): + bl_idname = utils.with_prefix("MATERIAL_PT_materialx", '_', True) + bl_label = "MaterialX" + bl_space_type = 'PROPERTIES' + bl_region_type = 'WINDOW' bl_context = "material" @classmethod @@ -201,12 +126,7 @@ class MATERIAL_PT_material(MATERIALX_Panel): mat_materialx = mx_properties(context.material) layout = self.layout - split = layout.row(align=True).split(factor=0.4) - row = split.column() - row.alignment = 'RIGHT' - row.label(text="MaterialX") - row = split.row() - row = row.row(align=True) + row = layout.row(align=True) row.menu(MATERIAL_MT_mx_node_tree.bl_idname, text="", icon='MATERIAL') if mat_materialx.mx_node_tree: @@ -219,14 +139,10 @@ class MATERIAL_PT_material(MATERIALX_Panel): row.operator(MATERIAL_OP_convert_shader_to_mx.bl_idname, icon='FILE_TICK', text="Convert") row.operator(MATERIAL_OP_new_mx_node_tree.bl_idname, icon='ADD', text="") - def draw_header(self, context): - layout = self.layout - layout.label(text=f"Material: {context.material.name}") - class MATERIAL_OP_link_mx_node(bpy.types.Operator): """Link MaterialX node""" - bl_idname = utils.with_prefix("material_link_mx_node") + bl_idname = utils.with_prefix('material_link_mx_node') bl_label = "" new_node_name: bpy.props.StringProperty() @@ -259,7 +175,7 @@ class MATERIAL_OP_link_mx_node(bpy.types.Operator): class MATERIAL_OP_invoke_popup_input_nodes(bpy.types.Operator): """Open panel with nodes to link""" - bl_idname = utils.with_prefix("material_invoke_popup_input_nodes") + bl_idname = utils.with_prefix('material_invoke_popup_input_nodes') bl_label = "" input_num: bpy.props.IntProperty() @@ -324,7 +240,7 @@ class MATERIAL_OP_invoke_popup_input_nodes(bpy.types.Operator): class MATERIAL_OP_invoke_popup_shader_nodes(bpy.types.Operator): """Open panel with shader nodes to link""" - bl_idname = utils.with_prefix("material_invoke_popup_shader_nodes") + bl_idname = utils.with_prefix('material_invoke_popup_shader_nodes') bl_label = "" input_num: bpy.props.IntProperty() @@ -378,7 +294,7 @@ class MATERIAL_OP_invoke_popup_shader_nodes(bpy.types.Operator): class MATERIAL_OP_remove_node(bpy.types.Operator): """Remove linked node""" - bl_idname = utils.with_prefix("material_remove_node") + bl_idname = utils.with_prefix('material_remove_node') bl_label = "Remove" input_node_name: bpy.props.StringProperty() @@ -402,7 +318,7 @@ class MATERIAL_OP_remove_node(bpy.types.Operator): class MATERIAL_OP_disconnect_node(bpy.types.Operator): """Disconnect linked node""" - bl_idname = utils.with_prefix("material_disconnect_node") + bl_idname = utils.with_prefix('material_disconnect_node') bl_label = "Disconnect" output_node_name: bpy.props.StringProperty() @@ -420,9 +336,13 @@ class MATERIAL_OP_disconnect_node(bpy.types.Operator): return {'FINISHED'} -class MATERIAL_PT_material_settings_surface(MATERIALX_ChildPanel): - bl_label = "surfaceshader" - bl_parent_id = 'MATERIAL_PT_material' +class MATERIAL_PT_materialx_output(bpy.types.Panel): + bl_label = "" + bl_parent_id = MATERIAL_PT_materialx.bl_idname + bl_space_type = 'PROPERTIES' + bl_region_type = 'WINDOW' + + out_key = "" @classmethod def poll(cls, context): @@ -437,7 +357,7 @@ class MATERIAL_PT_material_settings_surface(MATERIALX_ChildPanel): layout.label(text="No output node") return - input = output_node.inputs[self.bl_label] + input = output_node.inputs[self.out_key] link = next((link for link in input.links if link.is_valid), None) split = layout.split(factor=0.4) @@ -450,7 +370,7 @@ class MATERIAL_PT_material_settings_surface(MATERIALX_ChildPanel): box.scale_x = 0.7 box.scale_y = 0.5 op = box.operator(MATERIAL_OP_invoke_popup_shader_nodes.bl_idname, icon='HANDLETYPE_AUTO_CLAMP_VEC') - op.input_num = output_node.inputs.find(self.bl_label) + op.input_num = output_node.inputs.find(self.out_key) if link and is_mx_node_valid(link.from_node): row.prop(link.from_node, 'name', text="") @@ -462,7 +382,6 @@ class MATERIAL_PT_material_settings_surface(MATERIALX_ChildPanel): row.label(icon='BLANK1') if not link: - layout.label(text="No input node") return if not is_mx_node_valid(link.from_node): @@ -477,102 +396,23 @@ class MATERIAL_PT_material_settings_surface(MATERIALX_ChildPanel): link.from_node.draw_node_view(context, layout) -class MATERIAL_PT_material_settings_displacement(MATERIALX_ChildPanel): - bl_label = "displacementshader" - bl_parent_id = 'MATERIAL_PT_material' +class MATERIAL_PT_materialx_surfaceshader(MATERIAL_PT_materialx_output): + bl_idname = utils.with_prefix('MATERIAL_PT_materialx_surfaceshader', '_', True) + bl_label = "Surface Shader" - @classmethod - def poll(cls, context): - return bool(mx_properties(context.material).mx_node_tree) - - def draw(self, context): - layout = self.layout - - node_tree = mx_properties(context.material).mx_node_tree - output_node = node_tree.output_node - if not output_node: - layout.label(text="No output node") - return - - input = output_node.inputs[self.bl_label] - link = next((link for link in input.links if link.is_valid), None) - - split = layout.split(factor=0.4) - row = split.row(align=True) - row.alignment = 'RIGHT' - row.label(text='Displacement') - - row = split.row(align=True) - box = row.box() - box.scale_x = 0.7 - box.scale_y = 0.5 - op = box.operator(MATERIAL_OP_invoke_popup_shader_nodes.bl_idname, icon='HANDLETYPE_AUTO_CLAMP_VEC') - op.input_num = output_node.inputs.find(self.bl_label) - - if link and is_mx_node_valid(link.from_node): - row.prop(link.from_node, 'name', text="") - else: - box = row.box() - box.scale_y = 0.5 - box.label(text='None') - - row.label(icon='BLANK1') - - if not link: - layout.label(text="No input node") - return - - if not is_mx_node_valid(link.from_node): - layout.label(text="Unsupported node") - return - - link = pass_node_reroute(link) - if not link: - return - - layout.separator() - - link.from_node.draw_node_view(context, layout) + out_key = 'surfaceshader' -class MATERIAL_PT_output_node(MATERIALX_ChildPanel): - bl_label = "" - bl_parent_id = 'MATERIAL_PT_material' - - @classmethod - def poll(cls, context): - return not bool(mx_properties(context.material).mx_node_tree) - - def draw(self, context): - layout = self.layout - - node_tree = context.material.node_tree - - output_node = mx_properties(context.material).output_node - if not output_node: - layout.label(text="No output node") - return - - input = output_node.inputs[self.bl_label] - layout.template_node_view(node_tree, output_node, input) - - -class MATERIAL_PT_output_surface(MATERIAL_PT_output_node): - bl_label = "Surface" - - -class MATERIAL_PT_output_displacement(MATERIAL_PT_output_node): - bl_label = "Displacement" +class MATERIAL_PT_materialx_displacementshader(MATERIAL_PT_materialx_output): + bl_idname = utils.with_prefix('MATERIAL_PT_materialx_sdisplacementshader', '_', True) + bl_label = "Displacement Shader" bl_options = {'DEFAULT_CLOSED'} - -class MATERIAL_PT_output_volume(MATERIAL_PT_output_node): - bl_label = "Volume" - bl_options = {'DEFAULT_CLOSED'} + out_key = 'displacementshader' class MATERIAL_OP_export_mx_file(bpy.types.Operator, ExportHelper): - bl_idname = utils.with_prefix("material_export_mx_file") + bl_idname = utils.with_prefix('material_export_mx_file') bl_label = "Export MaterialX" bl_description = "Export material as MaterialX node tree to .mtlx file" @@ -659,7 +499,7 @@ class MATERIAL_OP_export_mx_file(bpy.types.Operator, ExportHelper): class MATERIAL_OP_export_mx_console(bpy.types.Operator): - bl_idname = utils.with_prefix("material_export_mx_console") + bl_idname = utils.with_prefix('material_export_mx_console') bl_label = "Export MaterialX to Console" bl_description = "Export material as MaterialX node tree to console" @@ -672,7 +512,8 @@ class MATERIAL_OP_export_mx_console(bpy.types.Operator): return {'FINISHED'} -class MATERIAL_PT_tools(MATERIALX_Panel): +class MATERIAL_PT_tools(bpy.types.Panel): + bl_idname = utils.with_prefix('MATERIAL_PT_tools', '_', True) bl_label = "MaterialX Tools" bl_space_type = "NODE_EDITOR" bl_region_type = "UI" @@ -691,50 +532,18 @@ class MATERIAL_PT_tools(MATERIALX_Panel): layout.operator(MATERIAL_OP_export_mx_file.bl_idname, text="Export MaterialX to file", icon='EXPORT') -class MATERIAL_PT_dev(MATERIALX_ChildPanel): +class MATERIAL_PT_dev(bpy.types.Panel): + bl_idname = utils.with_prefix('MATERIAL_PT_dev', '_', True) bl_label = "Dev" - bl_parent_id = 'MATERIAL_PT_tools' + bl_parent_id = MATERIAL_PT_tools.bl_idname bl_space_type = "NODE_EDITOR" bl_region_type = "UI" @classmethod def poll(cls, context): - return addon_preferences().dev_tools + preferences = addon_preferences() + return preferences.dev_tools if preferences else True def draw(self, context): layout = self.layout - layout.operator(MATERIAL_OP_export_mx_console.bl_idname) - - -def depsgraph_update(depsgraph): - context = bpy.context - mx_node_tree = None - if hasattr(context, 'object') and context.object and context.object.active_material: - mx_node_tree = mx_properties(context.object.active_material).mx_node_tree - - # trying to show MaterialX area with node tree or Shader area - screen = context.screen - if not hasattr(screen, 'areas'): - return - - for window in context.window_manager.windows: - for area in window.screen.areas: - if not mx_node_tree: - if area.ui_type != utils.with_prefix('MxNodeTree'): - continue - - area.ui_type = 'ShaderNodeTree' - continue - - if area.ui_type not in (utils.with_prefix('MxNodeTree'), 'ShaderNodeTree'): - continue - - space = next(s for s in area.spaces if s.type == 'NODE_EDITOR') - if space.pin or space.shader_type != 'OBJECT': - continue - - area.ui_type = utils.with_prefix('MxNodeTree') - space.node_tree = mx_node_tree - - mx_node_tree.update_links() diff --git a/materialx/matlib/ui.py b/materialx/matlib/ui.py index 49e76ee51..4cbac19ec 100644 --- a/materialx/matlib/ui.py +++ b/materialx/matlib/ui.py @@ -84,12 +84,16 @@ class MATLIB_OP_load_package(bpy.types.Operator): class MATLIB_PT_matlib(bpy.types.Panel): bl_idname = utils.with_prefix("MATLIB_PT_matlib", '_', True) - bl_label = "Material Library" + bl_label = "MaterialX Library" bl_context = "material" bl_region_type = 'WINDOW' bl_space_type = 'PROPERTIES' bl_options = {'DEFAULT_CLOSED'} + @classmethod + def poll(cls, context): + return context.material + def draw(self, context): layout = self.layout matlib_prop = utils.mx_properties(context.window_manager).matlib diff --git a/materialx/node_tree.py b/materialx/node_tree.py index ee4c57f69..6567cf2b0 100644 --- a/materialx/node_tree.py +++ b/materialx/node_tree.py @@ -253,10 +253,10 @@ class MxNodeTree(bpy.types.ShaderNodeTree): def update_(self): self.update_links() - # TODO: Uncomment - # for material in bpy.data.materials: - # if material.hdusd.mx_node_tree and material.hdusd.mx_node_tree.name == self.name: - # material.hdusd.update() + for material in bpy.data.materials: + if utils.mx_properties(material).mx_node_tree and \ + utils.mx_properties(material).mx_node_tree.name == self.name: + utils.mx_properties(material).update() for window in bpy.context.window_manager.windows: for area in window.screen.areas: diff --git a/materialx/nodes/ui.py b/materialx/nodes/ui.py index 3bdc13841..947731363 100644 --- a/materialx/nodes/ui.py +++ b/materialx/nodes/ui.py @@ -195,7 +195,8 @@ class NODES_PT_dev(bpy.types.Panel): @classmethod def poll(cls, context): - return addon_preferences().dev_tools + preferences = addon_preferences() + return preferences.dev_tools if preferences else True def draw(self, context): layout = self.layout diff --git a/materialx/preferences.py b/materialx/preferences.py index 2a0020ace..47eeb106e 100644 --- a/materialx/preferences.py +++ b/materialx/preferences.py @@ -37,4 +37,8 @@ class AddonPreferences(bpy.types.AddonPreferences): def addon_preferences(): + if ADDON_ALIAS not in bpy.context.preferences.addons: + return None + return bpy.context.preferences.addons[ADDON_ALIAS].preferences + diff --git a/materialx/utils.py b/materialx/utils.py index 9b7abd423..2b24fee3e 100644 --- a/materialx/utils.py +++ b/materialx/utils.py @@ -28,6 +28,8 @@ MATLIB_FOLDER = "matlib" MATLIB_DIR = ADDON_DATA_DIR / MATLIB_FOLDER MATLIB_URL = "https://api.matlib.gpuopen.com/api" +TEMP_FOLDER = "bl-materialx" + SUPPORTED_FORMATS = {".png", ".jpeg", ".jpg", ".hdr", ".tga", ".bmp"} DEFAULT_FORMAT = ".hdr" BLENDER_DEFAULT_FORMAT = "HDR" @@ -331,7 +333,7 @@ def export_mx_to_file(doc, filepath, *, mx_node_tree=None, is_export_deps=False, def temp_dir(): - d = Path(tempfile.gettempdir()) / "blender-mx" + d = Path(tempfile.gettempdir()) / TEMP_FOLDER if not d.is_dir(): log("Creating temp dir", d) d.mkdir() -- 2.30.2 From 3f18d03ae94e30f7174ea80e088138243b3f5a9a Mon Sep 17 00:00:00 2001 From: Vasyl Pidhirskyi <42581166+VascoPi@users.noreply.github.com> Date: Mon, 19 Sep 2022 20:05:56 +0300 Subject: [PATCH 09/28] BLEN-222: Make node link invalid if connects different types (#8) * BLEN-222: Mike node link invalid if connects different types. Registered timer for update_links. Co-authored-by: Bogdan Nagirniak --- materialx/node_tree.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/materialx/node_tree.py b/materialx/node_tree.py index 6567cf2b0..29e3aad3c 100644 --- a/materialx/node_tree.py +++ b/materialx/node_tree.py @@ -251,8 +251,6 @@ class MxNodeTree(bpy.types.ShaderNodeTree): self.update_() def update_(self): - self.update_links() - for material in bpy.data.materials: if utils.mx_properties(material).mx_node_tree and \ utils.mx_properties(material).mx_node_tree.name == self.name: @@ -265,6 +263,11 @@ class MxNodeTree(bpy.types.ShaderNodeTree): if region.type == REGION_TO_UPDATE: region.tag_redraw() + # We have to call self.update_links via bpy.app.timers.register + # to have slight delay after self.update(). It'll be called once + bpy.app.timers.register(self.update_links) + + # this is called from Blender def update_links(self): for link in self.links: socket_from_type = link.from_socket.node.nodedef.getOutput(link.from_socket.name).getType() -- 2.30.2 From 2b3e80a3a2ee2cbe548d900defcaee14bde2f158 Mon Sep 17 00:00:00 2001 From: Bogdan Nagirniak <33626169+bnagirniak@users.noreply.github.com> Date: Tue, 20 Sep 2022 17:02:53 +0300 Subject: [PATCH 10/28] BLEN-226: Finalizing MaterialX addon. (#9) More fixes and cleanups. Implemented showing MxNodeTree node editor when mx_node_tree is changed. Fixed loading materialx from matlib. --- materialx/material/__init__.py | 6 +- materialx/material/properties.py | 57 ++++++++++--------- materialx/material/ui.py | 47 +++++++++------ materialx/node_tree.py | 14 +---- materialx/nodes/ui.py | 6 +- materialx/utils.py | 98 +++++++++----------------------- 6 files changed, 92 insertions(+), 136 deletions(-) diff --git a/materialx/material/__init__.py b/materialx/material/__init__.py index 3e7eb6774..b9ee175ba 100644 --- a/materialx/material/__init__.py +++ b/materialx/material/__init__.py @@ -11,7 +11,7 @@ from . import ( register_classes, unregister_classes = bpy.utils.register_classes_factory([ ui.MATERIAL_OP_new_mx_node_tree, ui.MATERIAL_OP_duplicate_mx_node_tree, - ui.MATERIAL_OP_convert_shader_to_mx, + ui.MATERIAL_OP_convert_to_materialx, ui.MATERIAL_OP_duplicate_mat_mx_node_tree, ui.MATERIAL_OP_link_mx_node_tree, ui.MATERIAL_OP_unlink_mx_node_tree, @@ -24,8 +24,8 @@ register_classes, unregister_classes = bpy.utils.register_classes_factory([ ui.MATERIAL_OP_invoke_popup_shader_nodes, ui.MATERIAL_OP_remove_node, ui.MATERIAL_OP_disconnect_node, - ui.MATERIAL_OP_export_mx_file, - ui.MATERIAL_OP_export_mx_console, + ui.MATERIAL_OP_export_file, + ui.MATERIAL_OP_export_console, ui.MATERIAL_PT_tools, ui.MATERIAL_PT_dev, ]) diff --git a/materialx/material/properties.py b/materialx/material/properties.py index e59105c97..3bb3afcd2 100644 --- a/materialx/material/properties.py +++ b/materialx/material/properties.py @@ -8,9 +8,9 @@ import MaterialX as mx from ..node_tree import MxNodeTree from ..bl_nodes.output import ShaderNodeOutputMaterial -from ..utils import MX_LIBS_DIR +from ..utils import MX_LIBS_DIR, mx_properties, get_temp_file, MaterialXProperties, with_prefix -from ..utils import logging, get_temp_file, MaterialXProperties +from .. import logging log = logging.Log('material.properties') @@ -18,7 +18,29 @@ class MaterialProperties(MaterialXProperties): bl_type = bpy.types.Material def update_mx_node_tree(self, context): - self.update() + # trying to show MaterialX area with node tree or Shader area + + material = self.id_data + mx_node_tree = mx_properties(material).mx_node_tree + + if not mx_node_tree: + return + + screen = context.screen + if not hasattr(screen, 'areas'): + return + + for window in context.window_manager.windows: + for area in window.screen.areas: + if area.ui_type not in (MxNodeTree.bl_idname, 'ShaderNodeTree'): + continue + + space = next(s for s in area.spaces if s.type == 'NODE_EDITOR') + if space.pin or space.shader_type != 'OBJECT': + continue + + area.ui_type = MxNodeTree.bl_idname + space.node_tree = mx_node_tree mx_node_tree: bpy.props.PointerProperty(type=MxNodeTree, update=update_mx_node_tree) @@ -33,8 +55,8 @@ class MaterialProperties(MaterialXProperties): node.bl_idname == ShaderNodeOutputMaterial.__name__ and node.is_active_output), None) - def export(self, obj: bpy.types.Object) -> [mx.Document, None]: - if self.mx_node_tree: + def export(self, obj: bpy.types.Object, check_mx_node_tree=True) -> [mx.Document, None]: + if check_mx_node_tree and self.mx_node_tree: return self.mx_node_tree.export() material = self.id_data @@ -51,19 +73,7 @@ class MaterialProperties(MaterialXProperties): return doc - def update(self, is_depsgraph=False): - """ - Main update callback function, which notifies that material was updated from both: - depsgraph or MaterialX node tree - """ - if is_depsgraph and self.mx_node_tree: - return - - material = self.id_data - # usd_node_tree.material_update(material) - # ViewportEngineScene.material_update(material) - - def convert_shader_to_mx(self, obj: bpy.types.Object = None): + def convert_to_materialx(self, obj: bpy.types.Object = None): mat = self.id_data output_node = self.output_node if not output_node: @@ -95,6 +105,7 @@ class MaterialProperties(MaterialXProperties): mx.readFromXmlFile(doc, str(mtlx_file), searchPath=search_path) mx_node_tree.import_(doc, mtlx_file) self.mx_node_tree = mx_node_tree + except Exception as e: log.error(traceback.format_exc(), mtlx_file) return False @@ -102,16 +113,6 @@ class MaterialProperties(MaterialXProperties): return True -def depsgraph_update(depsgraph): - if not depsgraph.updates: - return - - # Undo operation sends modified object with other stuff (scene, collection, etc...) - mat = next((upd.id for upd in depsgraph.updates if isinstance(upd.id, bpy.types.Material)), None) - if mat: - mat.hdusd.update(True) - - register, unregister = bpy.utils.register_classes_factory(( MaterialProperties, )) diff --git a/materialx/material/ui.py b/materialx/material/ui.py index 5c34f7d1d..ac6fd86bc 100644 --- a/materialx/material/ui.py +++ b/materialx/material/ui.py @@ -58,13 +58,13 @@ class MATERIAL_OP_duplicate_mx_node_tree(bpy.types.Operator): return {"FINISHED"} -class MATERIAL_OP_convert_shader_to_mx(bpy.types.Operator): +class MATERIAL_OP_convert_to_materialx(bpy.types.Operator): """Converts standard shader node tree to MaterialX node tree for selected material""" - bl_idname = utils.with_prefix('material_convert_shader_to_mx') + bl_idname = utils.with_prefix('material_convert_to_materialx') bl_label = "Convert to MaterialX" def execute(self, context): - if not mx_properties(context.material).convert_shader_to_mx(context.object): + if not mx_properties(context.material).convert_to_materialx(context.object): return {'CANCELLED'} return {"FINISHED"} @@ -131,12 +131,12 @@ class MATERIAL_PT_materialx(bpy.types.Panel): if mat_materialx.mx_node_tree: row.prop(mat_materialx.mx_node_tree, 'name', text="") - row.operator(MATERIAL_OP_convert_shader_to_mx.bl_idname, icon='FILE_TICK', text="") + row.operator(MATERIAL_OP_convert_to_materialx.bl_idname, icon='FILE_TICK', text="") row.operator(MATERIAL_OP_duplicate_mx_node_tree.bl_idname, icon='DUPLICATE') row.operator(MATERIAL_OP_unlink_mx_node_tree.bl_idname, icon='X') else: - row.operator(MATERIAL_OP_convert_shader_to_mx.bl_idname, icon='FILE_TICK', text="Convert") + row.operator(MATERIAL_OP_convert_to_materialx.bl_idname, icon='FILE_TICK', text="Convert") row.operator(MATERIAL_OP_new_mx_node_tree.bl_idname, icon='ADD', text="") @@ -404,15 +404,15 @@ class MATERIAL_PT_materialx_surfaceshader(MATERIAL_PT_materialx_output): class MATERIAL_PT_materialx_displacementshader(MATERIAL_PT_materialx_output): - bl_idname = utils.with_prefix('MATERIAL_PT_materialx_sdisplacementshader', '_', True) + bl_idname = utils.with_prefix('MATERIAL_PT_materialx_displacementshader', '_', True) bl_label = "Displacement Shader" bl_options = {'DEFAULT_CLOSED'} out_key = 'displacementshader' -class MATERIAL_OP_export_mx_file(bpy.types.Operator, ExportHelper): - bl_idname = utils.with_prefix('material_export_mx_file') +class MATERIAL_OP_export_file(bpy.types.Operator, ExportHelper): + bl_idname = utils.with_prefix('material_export_file') bl_label = "Export MaterialX" bl_description = "Export material as MaterialX node tree to .mtlx file" @@ -465,7 +465,7 @@ class MATERIAL_OP_export_mx_file(bpy.types.Operator, ExportHelper): def execute(self, context): materialx_prop = mx_properties(context.material) - if not materialx_prop.convert_shader_to_mx(): + if not materialx_prop.convert_to_materialx(): return {'CANCELLED'} doc = mx_properties(context.material).export(None) @@ -476,7 +476,7 @@ class MATERIAL_OP_export_mx_file(bpy.types.Operator, ExportHelper): self.filepath = str(Path(self.filepath).parent / context.material.name_full / Path(self.filepath).name) utils.export_mx_to_file(doc, self.filepath, - mx_node_tree=materialx_prop.mx_node_tree, + mx_node_tree=None, is_export_deps=self.is_export_deps, is_export_textures=self.is_export_textures, texture_dir_name=self.texture_dir_name, @@ -498,13 +498,13 @@ class MATERIAL_OP_export_mx_file(bpy.types.Operator, ExportHelper): row.prop(self, 'texture_dir_name', text='') -class MATERIAL_OP_export_mx_console(bpy.types.Operator): - bl_idname = utils.with_prefix('material_export_mx_console') - bl_label = "Export MaterialX to Console" +class MATERIAL_OP_export_console(bpy.types.Operator): + bl_idname = utils.with_prefix('material_export_console') + bl_label = "Export to Console" bl_description = "Export material as MaterialX node tree to console" def execute(self, context): - doc = mx_properties(context.material).export(context.object) + doc = mx_properties(context.material).export(context.object, False) if not doc: return {'CANCELLED'} @@ -526,10 +526,23 @@ class MATERIAL_PT_tools(bpy.types.Panel): return tree and tree.bl_idname == bpy.types.ShaderNodeTree.__name__ def draw(self, context): + mat_materialx = mx_properties(context.material) layout = self.layout - layout.operator(MATERIAL_OP_convert_shader_to_mx.bl_idname, icon='FILE_TICK') - layout.operator(MATERIAL_OP_export_mx_file.bl_idname, text="Export MaterialX to file", icon='EXPORT') + row = layout.row(align=True) + row.menu(MATERIAL_MT_mx_node_tree.bl_idname, text="", icon='MATERIAL') + + if mat_materialx.mx_node_tree: + row.prop(mat_materialx.mx_node_tree, 'name', text="") + row.operator(MATERIAL_OP_convert_to_materialx.bl_idname, icon='FILE_TICK', text="") + row.operator(MATERIAL_OP_duplicate_mx_node_tree.bl_idname, icon='DUPLICATE') + row.operator(MATERIAL_OP_unlink_mx_node_tree.bl_idname, icon='X') + + else: + row.operator(MATERIAL_OP_convert_to_materialx.bl_idname, icon='FILE_TICK', text="Convert") + row.operator(MATERIAL_OP_new_mx_node_tree.bl_idname, icon='ADD', text="") + + layout.operator(MATERIAL_OP_export_file.bl_idname, text="Export MaterialX to file", icon='EXPORT') class MATERIAL_PT_dev(bpy.types.Panel): @@ -546,4 +559,4 @@ class MATERIAL_PT_dev(bpy.types.Panel): def draw(self, context): layout = self.layout - layout.operator(MATERIAL_OP_export_mx_console.bl_idname) + layout.operator(MATERIAL_OP_export_console.bl_idname) diff --git a/materialx/node_tree.py b/materialx/node_tree.py index 29e3aad3c..64346a76b 100644 --- a/materialx/node_tree.py +++ b/materialx/node_tree.py @@ -14,8 +14,6 @@ log = logging.Log('node_tree') NODE_LAYER_SEPARATION_WIDTH = 280 NODE_LAYER_SHIFT_X = 30 NODE_LAYER_SHIFT_Y = 100 -AREA_TO_UPDATE = 'PROPERTIES' -REGION_TO_UPDATE = 'WINDOW' class MxNodeTree(bpy.types.ShaderNodeTree): @@ -251,17 +249,7 @@ class MxNodeTree(bpy.types.ShaderNodeTree): self.update_() def update_(self): - for material in bpy.data.materials: - if utils.mx_properties(material).mx_node_tree and \ - utils.mx_properties(material).mx_node_tree.name == self.name: - utils.mx_properties(material).update() - - for window in bpy.context.window_manager.windows: - for area in window.screen.areas: - if area.type == AREA_TO_UPDATE: - for region in area.regions: - if region.type == REGION_TO_UPDATE: - region.tag_redraw() + utils.update_ui() # We have to call self.update_links via bpy.app.timers.register # to have slight delay after self.update(). It'll be called once diff --git a/materialx/nodes/ui.py b/materialx/nodes/ui.py index 947731363..3b46aaa26 100644 --- a/materialx/nodes/ui.py +++ b/materialx/nodes/ui.py @@ -50,7 +50,7 @@ class NODES_OP_import_file(bpy.types.Operator, ImportHelper): class NODES_OP_export_file(bpy.types.Operator, ExportHelper): bl_idname = utils.with_prefix('nodes_export_file') - bl_label = "Export MaterialX" + bl_label = "Export to File" bl_description = "Export MaterialX node tree to .mtlx file" # region properties @@ -137,7 +137,7 @@ class NODES_OP_export_file(bpy.types.Operator, ExportHelper): class NODES_OP_export_console(bpy.types.Operator): bl_idname = utils.with_prefix('nodes_export_console') - bl_label = "Export MaterialX to Console" + bl_label = "Export to Console" bl_description = "Export MaterialX node tree to console" def execute(self, context): @@ -183,7 +183,7 @@ class NODES_PT_tools(bpy.types.Panel): layout.operator(NODES_OP_create_basic_nodes.bl_idname, icon='ADD') layout.operator(NODES_OP_import_file.bl_idname, icon='IMPORT') - layout.operator(NODES_OP_export_file.bl_idname, icon='EXPORT', text='Export MaterialX to file') + layout.operator(NODES_OP_export_file.bl_idname, icon='EXPORT') class NODES_PT_dev(bpy.types.Panel): diff --git a/materialx/utils.py b/materialx/utils.py index 2b24fee3e..e336e78dd 100644 --- a/materialx/utils.py +++ b/materialx/utils.py @@ -30,12 +30,6 @@ MATLIB_URL = "https://api.matlib.gpuopen.com/api" TEMP_FOLDER = "bl-materialx" -SUPPORTED_FORMATS = {".png", ".jpeg", ".jpg", ".hdr", ".tga", ".bmp"} -DEFAULT_FORMAT = ".hdr" -BLENDER_DEFAULT_FORMAT = "HDR" -BLENDER_DEFAULT_COLOR_MODE = "RGB" -READONLY_IMAGE_FORMATS = {".dds"} # blender can read these formats, but can't write - os.environ['MATERIALX_SEARCH_PATH'] = str(MX_LIBS_DIR) @@ -323,13 +317,13 @@ def export_mx_to_file(doc, filepath, *, mx_node_tree=None, is_export_deps=False, dest_path = texture_dir / f"{source_path.stem}{source_path.suffix}" shutil.copy(source_path, dest_path) - log(f"Export file {source_path} to {dest_path}: completed successfuly") + log(f"Export file {source_path} to {dest_path}: completed successfully") rel_dest_path = dest_path.relative_to(root_dir) mx_input.setValue(str(rel_dest_path), mx_input.getType()) mx.writeToXmlFile(doc, filepath) - log(f"Export MaterialX to {filepath}: completed successfuly") + log(f"Export MaterialX to {filepath}: completed successfully") def temp_dir(): @@ -354,13 +348,14 @@ def get_temp_file(suffix, name=None, is_rand=False): return temp_dir() / name -def cache_image_file(image: bpy.types.Image, cache_check=True): - SUPPORTED_FORMATS = {".png", ".jpeg", ".jpg", ".hdr", ".tga", ".bmp"} - DEFAULT_FORMAT = ".hdr" - BLENDER_DEFAULT_FORMAT = "HDR" - BLENDER_DEFAULT_COLOR_MODE = "RGB" - READONLY_IMAGE_FORMATS = {".dds"} # blender can read these formats, but can't write +SUPPORTED_FORMATS = {".png", ".jpeg", ".jpg", ".hdr", ".tga", ".bmp"} +DEFAULT_FORMAT = ".hdr" +BLENDER_DEFAULT_FORMAT = "HDR" +BLENDER_DEFAULT_COLOR_MODE = "RGB" +READONLY_IMAGE_FORMATS = {".dds"} # blender can read these formats, but can't write + +def cache_image_file(image: bpy.types.Image, cache_check=True): image_path = Path(image.filepath_from_user()) if not image.packed_file and image.source != 'GENERATED': if not image_path.is_file(): @@ -401,6 +396,23 @@ def cache_image_file(image: bpy.types.Image, cache_check=True): return temp_path +def cache_image_file_path(image_path, cache_check=True): + if image_path.suffix.lower() in SUPPORTED_FORMATS: + return image_path + + if cache_check: + temp_path = get_temp_file(DEFAULT_FORMAT, image_path.name) + if temp_path.is_file(): + return temp_path + + image = bpy.data.images.load(str(image_path)) + try: + return cache_image_file(image, cache_check) + + finally: + bpy.data.images.remove(image) + + def pass_node_reroute(link): while isinstance(link.from_node, bpy.types.NodeReroute): if not link.from_node.inputs[0].links: @@ -418,61 +430,3 @@ def update_ui(area_type='PROPERTIES', region_type='WINDOW'): for region in area.regions: if region.type == region_type: region.tag_redraw() - - -def cache_image_file(image: bpy.types.Image, cache_check=True): - image_path = Path(image.filepath_from_user()) - if not image.packed_file and image.source != 'GENERATED': - if not image_path.is_file(): - log.warn("Image is missing", image, image_path) - return None - - image_suffix = image_path.suffix.lower() - - if image_suffix in SUPPORTED_FORMATS and\ - f".{image.file_format.lower()}" in SUPPORTED_FORMATS and not image.is_dirty: - return image_path - - if image_suffix in READONLY_IMAGE_FORMATS: - return image_path - - temp_path = get_temp_file(DEFAULT_FORMAT, image_path.stem) - if cache_check and image.source != 'GENERATED' and temp_path.is_file(): - return temp_path - - scene = bpy.context.scene - user_format = scene.render.image_settings.file_format - user_color_mode = scene.render.image_settings.color_mode - - # in some scenes the color_mode is undefined - # we can read it but unable to assign back, so switch it to 'RGB' if color_mode isn't selected - if not user_color_mode: - user_color_mode = 'RGB' - - scene.render.image_settings.file_format = BLENDER_DEFAULT_FORMAT - scene.render.image_settings.color_mode = BLENDER_DEFAULT_COLOR_MODE - - try: - image.save_render(filepath=str(temp_path)) - finally: - scene.render.image_settings.file_format = user_format - scene.render.image_settings.color_mode = user_color_mode - - return temp_path - - -def cache_image_file_path(image_path, cache_check=True): - if image_path.suffix.lower() in SUPPORTED_FORMATS: - return image_path - - if cache_check: - temp_path = get_temp_file(DEFAULT_FORMAT, image_path.name) - if temp_path.is_file(): - return temp_path - - image = bpy.data.images.load(str(image_path)) - try: - return cache_image_file(image, cache_check) - - finally: - bpy.data.images.remove(image) -- 2.30.2 From c4e887d5a6673aad0b345a8822d762cc79b34682 Mon Sep 17 00:00:00 2001 From: Bogdan Nagirniak <33626169+bnagirniak@users.noreply.github.com> Date: Thu, 22 Sep 2022 11:07:50 +0300 Subject: [PATCH 11/28] BLEN-229: Adjust code to integrated MaterialX library (#10) Removed default libraries files. Fixed export Material editor and MaterialX editor to file. --- materialx/libraries/README.md | 70 - .../libraries/bxdf/disney_brdf_2012.mtlx | 18 - .../libraries/bxdf/disney_brdf_2015.mtlx | 25 - .../libraries/bxdf/standard_surface.mtlx | 327 -- .../libraries/bxdf/usd_preview_surface.mtlx | 335 -- .../lights/genglsl/lights_genglsl_impl.mtlx | 13 - .../lights/genglsl/mx_directional_light.glsl | 5 - .../lights/genglsl/mx_point_light.glsl | 8 - .../lights/genglsl/mx_spot_light.glsl | 13 - materialx/libraries/lights/lights_defs.mtlx | 57 - .../pbrlib/genglsl/lib/mx_defines.glsl | 4 - .../genglsl/lib/mx_environment_fis.glsl | 72 - .../genglsl/lib/mx_environment_none.glsl | 11 - .../genglsl/lib/mx_environment_prefilter.glsl | 29 - .../libraries/pbrlib/genglsl/lib/mx_math.glsl | 83 - .../pbrlib/genglsl/lib/mx_microfacet.glsl | 57 - .../genglsl/lib/mx_microfacet_diffuse.glsl | 84 - .../genglsl/lib/mx_microfacet_sheen.glsl | 52 - .../genglsl/lib/mx_microfacet_specular.glsl | 386 -- .../genglsl/lib/mx_refraction_index.glsl | 31 - .../pbrlib/genglsl/lib/mx_shadow.glsl | 23 - .../pbrlib/genglsl/lib/mx_table.glsl | 7 - .../libraries/pbrlib/genglsl/mx_add_bsdf.glsl | 14 - .../libraries/pbrlib/genglsl/mx_add_edf.glsl | 4 - .../pbrlib/genglsl/mx_artistic_ior.glsl | 6 - .../genglsl/mx_burley_diffuse_bsdf.glsl | 35 - .../pbrlib/genglsl/mx_conductor_bsdf.glsl | 55 - .../pbrlib/genglsl/mx_dielectric_bsdf.glsl | 96 - .../genglsl/mx_generalized_schlick_bsdf.glsl | 86 - .../libraries/pbrlib/genglsl/mx_mix_bsdf.glsl | 14 - .../libraries/pbrlib/genglsl/mx_mix_edf.glsl | 4 - .../genglsl/mx_multiply_bsdf_color.glsl | 14 - .../genglsl/mx_multiply_bsdf_float.glsl | 14 - .../pbrlib/genglsl/mx_multiply_edf_color.glsl | 4 - .../pbrlib/genglsl/mx_multiply_edf_float.glsl | 4 - .../genglsl/mx_oren_nayar_diffuse_bsdf.glsl | 34 - .../genglsl/mx_roughness_anisotropy.glsl | 15 - .../pbrlib/genglsl/mx_roughness_dual.glsl | 9 - .../pbrlib/genglsl/mx_sheen_bsdf.glsl | 50 - .../pbrlib/genglsl/mx_subsurface_bsdf.glsl | 32 - .../pbrlib/genglsl/mx_translucent_bsdf.glsl | 27 - .../pbrlib/genglsl/mx_uniform_edf.glsl | 4 - .../pbrlib/genglsl/pbrlib_genglsl_impl.mtlx | 66 - .../pbrlib/genmdl/pbrlib_genmdl_impl.mtlx | 92 - .../pbrlib/genosl/lib/mx_microfacet.osl | 125 - .../genosl/lib/mx_microfacet_specular.osl | 116 - .../pbrlib/genosl/lib/mx_refraction_index.osl | 31 - .../libraries/pbrlib/genosl/mx_add.inline | 1 - .../pbrlib/genosl/mx_artistic_ior.osl | 6 - .../pbrlib/genosl/mx_burley_diffuse_bsdf.osl | 5 - .../pbrlib/genosl/mx_conductor_bsdf.osl | 29 - .../pbrlib/genosl/mx_dielectric_bsdf.osl | 35 - .../pbrlib/genosl/mx_displacement_float.osl | 4 - .../pbrlib/genosl/mx_displacement_vector3.osl | 4 - .../genosl/mx_generalized_schlick_bsdf.osl | 32 - .../libraries/pbrlib/genosl/mx_mix.inline | 1 - .../pbrlib/genosl/mx_multiply_bsdf.inline | 1 - .../pbrlib/genosl/mx_multiply_edf.inline | 1 - .../genosl/mx_oren_nayar_diffuse_bsdf.inline | 1 - .../pbrlib/genosl/mx_roughness_anisotropy.osl | 15 - .../pbrlib/genosl/mx_roughness_dual.osl | 12 - .../libraries/pbrlib/genosl/mx_sheen_bsdf.osl | 61 - .../pbrlib/genosl/mx_subsurface_bsdf.osl | 5 - .../libraries/pbrlib/genosl/mx_surface.osl | 5 - .../pbrlib/genosl/mx_translucent_bsdf.inline | 1 - .../pbrlib/genosl/mx_uniform_edf.inline | 1 - .../pbrlib/genosl/pbrlib_genosl_impl.mtlx | 67 - materialx/libraries/pbrlib/pbrlib_defs.mtlx | 397 -- materialx/libraries/pbrlib/pbrlib_ng.mtlx | 22 - .../libraries/stdlib/genglsl/lib/mx_hsv.glsl | 91 - .../stdlib/genglsl/lib/mx_noise.glsl | 321 -- .../stdlib/genglsl/lib/mx_sampling.glsl | 91 - .../stdlib/genglsl/lib/mx_transform_uv.glsl | 5 - .../genglsl/lib/mx_transform_uv_vflip.glsl | 5 - .../libraries/stdlib/genglsl/mx_aastep.glsl | 5 - .../libraries/stdlib/genglsl/mx_absval.inline | 1 - .../genglsl/mx_acescg_to_linear_color3.glsl | 5 - .../genglsl/mx_acescg_to_linear_color4.glsl | 5 - .../libraries/stdlib/genglsl/mx_acos.inline | 1 - .../libraries/stdlib/genglsl/mx_add.inline | 1 - .../stdlib/genglsl/mx_add_surfaceshader.glsl | 5 - .../libraries/stdlib/genglsl/mx_asin.inline | 1 - .../libraries/stdlib/genglsl/mx_atan2.inline | 1 - .../stdlib/genglsl/mx_burn_color3.glsl | 8 - .../stdlib/genglsl/mx_burn_color4.glsl | 9 - .../stdlib/genglsl/mx_burn_float.glsl | 9 - .../libraries/stdlib/genglsl/mx_ceil.inline | 1 - .../stdlib/genglsl/mx_cellnoise2d_float.glsl | 6 - .../stdlib/genglsl/mx_cellnoise3d_float.glsl | 6 - .../libraries/stdlib/genglsl/mx_clamp.inline | 1 - .../stdlib/genglsl/mx_constant.inline | 1 - .../libraries/stdlib/genglsl/mx_cos.inline | 1 - .../stdlib/genglsl/mx_crossproduct.inline | 1 - .../stdlib/genglsl/mx_determinant.inline | 1 - .../stdlib/genglsl/mx_difference.inline | 1 - .../genglsl/mx_disjointover_color4.glsl | 25 - .../libraries/stdlib/genglsl/mx_divide.inline | 1 - .../libraries/stdlib/genglsl/mx_dodge.inline | 1 - .../stdlib/genglsl/mx_dodge_color3.glsl | 8 - .../stdlib/genglsl/mx_dodge_color4.glsl | 9 - .../stdlib/genglsl/mx_dodge_float.glsl | 9 - .../libraries/stdlib/genglsl/mx_dot.inline | 1 - .../stdlib/genglsl/mx_dotproduct.inline | 1 - .../libraries/stdlib/genglsl/mx_exp.inline | 1 - .../libraries/stdlib/genglsl/mx_floor.inline | 1 - .../genglsl/mx_fractal3d_fa_vector2.glsl | 7 - .../genglsl/mx_fractal3d_fa_vector3.glsl | 7 - .../genglsl/mx_fractal3d_fa_vector4.glsl | 8 - .../stdlib/genglsl/mx_fractal3d_float.glsl | 7 - .../stdlib/genglsl/mx_fractal3d_vector2.glsl | 7 - .../stdlib/genglsl/mx_fractal3d_vector3.glsl | 7 - .../stdlib/genglsl/mx_fractal3d_vector4.glsl | 8 - .../mx_g22_ap1_to_lin_rec709_color3.glsl | 6 - .../mx_g22_ap1_to_lin_rec709_color4.glsl | 6 - .../genglsl/mx_gamma18_to_linear_color3.glsl | 5 - .../genglsl/mx_gamma18_to_linear_color4.glsl | 5 - .../genglsl/mx_gamma22_to_linear_color3.glsl | 5 - .../genglsl/mx_gamma22_to_linear_color4.glsl | 5 - .../genglsl/mx_gamma24_to_linear_color3.glsl | 5 - .../genglsl/mx_gamma24_to_linear_color4.glsl | 5 - .../stdlib/genglsl/mx_hsvtorgb_color3.glsl | 6 - .../stdlib/genglsl/mx_hsvtorgb_color4.glsl | 6 - .../stdlib/genglsl/mx_image_color3.glsl | 14 - .../stdlib/genglsl/mx_image_color4.glsl | 14 - .../stdlib/genglsl/mx_image_float.glsl | 14 - .../stdlib/genglsl/mx_image_vector2.glsl | 14 - .../stdlib/genglsl/mx_image_vector3.glsl | 14 - .../stdlib/genglsl/mx_image_vector4.glsl | 14 - .../stdlib/genglsl/mx_in_color4.inline | 1 - .../libraries/stdlib/genglsl/mx_inside.inline | 1 - .../libraries/stdlib/genglsl/mx_invert.inline | 1 - .../stdlib/genglsl/mx_invertM.inline | 1 - .../libraries/stdlib/genglsl/mx_ln.inline | 1 - .../stdlib/genglsl/mx_luminance_color3.glsl | 4 - .../stdlib/genglsl/mx_luminance_color4.glsl | 4 - .../stdlib/genglsl/mx_magnitude.inline | 1 - .../stdlib/genglsl/mx_mask_color4.inline | 1 - .../stdlib/genglsl/mx_matte_color4.inline | 1 - .../libraries/stdlib/genglsl/mx_max.inline | 1 - .../libraries/stdlib/genglsl/mx_min.inline | 1 - .../libraries/stdlib/genglsl/mx_minus.inline | 1 - .../libraries/stdlib/genglsl/mx_mix.inline | 1 - .../stdlib/genglsl/mx_mix_surfaceshader.glsl | 5 - .../libraries/stdlib/genglsl/mx_modulo.inline | 1 - .../stdlib/genglsl/mx_multiply.inline | 1 - .../mx_multiply_surfaceshader_color3.glsl | 5 - .../mx_multiply_surfaceshader_float.glsl | 5 - .../stdlib/genglsl/mx_noise2d_fa_vector2.glsl | 7 - .../stdlib/genglsl/mx_noise2d_fa_vector3.glsl | 7 - .../stdlib/genglsl/mx_noise2d_fa_vector4.glsl | 8 - .../stdlib/genglsl/mx_noise2d_float.glsl | 7 - .../stdlib/genglsl/mx_noise2d_vector2.glsl | 7 - .../stdlib/genglsl/mx_noise2d_vector3.glsl | 7 - .../stdlib/genglsl/mx_noise2d_vector4.glsl | 8 - .../stdlib/genglsl/mx_noise3d_fa_vector2.glsl | 7 - .../stdlib/genglsl/mx_noise3d_fa_vector3.glsl | 7 - .../stdlib/genglsl/mx_noise3d_fa_vector4.glsl | 8 - .../stdlib/genglsl/mx_noise3d_float.glsl | 7 - .../stdlib/genglsl/mx_noise3d_vector2.glsl | 7 - .../stdlib/genglsl/mx_noise3d_vector3.glsl | 7 - .../stdlib/genglsl/mx_noise3d_vector4.glsl | 8 - .../stdlib/genglsl/mx_normalize.inline | 1 - .../stdlib/genglsl/mx_normalmap.glsl | 16 - .../stdlib/genglsl/mx_out_color2.inline | 1 - .../stdlib/genglsl/mx_out_color4.inline | 1 - .../stdlib/genglsl/mx_outside.inline | 1 - .../stdlib/genglsl/mx_over_color2.inline | 1 - .../stdlib/genglsl/mx_over_color4.inline | 1 - .../libraries/stdlib/genglsl/mx_overlay.glsl | 25 - .../stdlib/genglsl/mx_overlay_color3.glsl | 6 - .../stdlib/genglsl/mx_overlay_color4.glsl | 6 - .../stdlib/genglsl/mx_overlay_float.inline | 1 - .../libraries/stdlib/genglsl/mx_plus.inline | 1 - .../libraries/stdlib/genglsl/mx_power.inline | 1 - .../genglsl/mx_power_color3_float.inline | 1 - .../genglsl/mx_power_color4_float.inline | 1 - .../genglsl/mx_power_vector2_float.inline | 1 - .../genglsl/mx_power_vector3_float.inline | 1 - .../genglsl/mx_power_vector4_float.inline | 1 - .../stdlib/genglsl/mx_premult_color4.glsl | 4 - .../stdlib/genglsl/mx_ramplr_float.glsl | 4 - .../stdlib/genglsl/mx_ramplr_vector2.glsl | 4 - .../stdlib/genglsl/mx_ramplr_vector3.glsl | 4 - .../stdlib/genglsl/mx_ramplr_vector4.glsl | 4 - .../stdlib/genglsl/mx_ramptb_float.glsl | 4 - .../stdlib/genglsl/mx_ramptb_vector2.glsl | 4 - .../stdlib/genglsl/mx_ramptb_vector3.glsl | 4 - .../stdlib/genglsl/mx_ramptb_vector4.glsl | 4 - .../libraries/stdlib/genglsl/mx_remap.inline | 1 - .../stdlib/genglsl/mx_rgbtohsv_color3.glsl | 6 - .../stdlib/genglsl/mx_rgbtohsv_color4.glsl | 6 - .../stdlib/genglsl/mx_rotate_vector2.glsl | 7 - .../stdlib/genglsl/mx_rotate_vector3.glsl | 19 - .../libraries/stdlib/genglsl/mx_screen.inline | 1 - .../libraries/stdlib/genglsl/mx_sign.inline | 1 - .../libraries/stdlib/genglsl/mx_sin.inline | 1 - .../stdlib/genglsl/mx_smoothstep_float.glsl | 9 - .../stdlib/genglsl/mx_smoothstep_vec2.glsl | 7 - .../stdlib/genglsl/mx_smoothstep_vec2FA.glsl | 7 - .../stdlib/genglsl/mx_smoothstep_vec3.glsl | 8 - .../stdlib/genglsl/mx_smoothstep_vec3FA.glsl | 8 - .../stdlib/genglsl/mx_smoothstep_vec4.glsl | 9 - .../stdlib/genglsl/mx_smoothstep_vec4FA.glsl | 9 - .../stdlib/genglsl/mx_splitlr_float.glsl | 6 - .../stdlib/genglsl/mx_splitlr_vector2.glsl | 6 - .../stdlib/genglsl/mx_splitlr_vector3.glsl | 6 - .../stdlib/genglsl/mx_splitlr_vector4.glsl | 6 - .../stdlib/genglsl/mx_splittb_float.glsl | 6 - .../stdlib/genglsl/mx_splittb_vector2.glsl | 6 - .../stdlib/genglsl/mx_splittb_vector3.glsl | 6 - .../stdlib/genglsl/mx_splittb_vector4.glsl | 6 - .../libraries/stdlib/genglsl/mx_sqrt.inline | 1 - .../mx_srgb_texture_to_linear_color3.glsl | 13 - .../mx_srgb_texture_to_linear_color4.glsl | 13 - .../stdlib/genglsl/mx_subtract.inline | 1 - .../libraries/stdlib/genglsl/mx_tan.inline | 1 - .../stdlib/genglsl/mx_transformmatrix.inline | 1 - .../genglsl/mx_transformmatrix_vector2M3.glsl | 5 - .../genglsl/mx_transformmatrix_vector3M4.glsl | 5 - .../stdlib/genglsl/mx_transpose.inline | 1 - .../stdlib/genglsl/mx_unpremult_color4.glsl | 4 - .../genglsl/stdlib_genglsl_cm_impl.mtlx | 24 - .../stdlib/genglsl/stdlib_genglsl_impl.mtlx | 769 --- .../genglsl/stdlib_genglsl_unit_impl.mtlx | 18 - .../stdlib/genmdl/stdlib_genmdl_cm_impl.mtlx | 24 - .../stdlib/genmdl/stdlib_genmdl_impl.mtlx | 773 --- .../genmdl/stdlib_genmdl_unit_impl.mtlx | 18 - .../stdlib/genosl/lib/mx_sampling.osl | 150 - .../stdlib/genosl/lib/mx_transform_uv.osl | 4 - .../genosl/lib/mx_transform_uv_vflip.osl | 4 - .../libraries/stdlib/genosl/mx_absval.inline | 1 - .../genosl/mx_acescg_to_linear_color3.osl | 7 - .../genosl/mx_acescg_to_linear_color4.osl | 7 - .../libraries/stdlib/genosl/mx_acos.inline | 1 - .../libraries/stdlib/genosl/mx_add.inline | 1 - .../genosl/mx_ambientocclusion_float.osl | 5 - .../libraries/stdlib/genosl/mx_asin.inline | 1 - .../libraries/stdlib/genosl/mx_atan2.inline | 1 - .../stdlib/genosl/mx_bitangent_vector3.inline | 1 - .../stdlib/genosl/mx_burn_color3.osl | 8 - .../stdlib/genosl/mx_burn_color4.osl | 9 - .../libraries/stdlib/genosl/mx_burn_float.osl | 9 - .../libraries/stdlib/genosl/mx_ceil.inline | 1 - .../stdlib/genosl/mx_cellnoise2d_float.osl | 4 - .../stdlib/genosl/mx_cellnoise3d_float.osl | 4 - .../libraries/stdlib/genosl/mx_clamp.inline | 1 - .../stdlib/genosl/mx_constant.inline | 1 - .../stdlib/genosl/mx_contrast.inline | 1 - .../libraries/stdlib/genosl/mx_cos.inline | 1 - .../stdlib/genosl/mx_crossproduct.inline | 1 - .../stdlib/genosl/mx_determinant.inline | 1 - .../stdlib/genosl/mx_difference.inline | 1 - .../stdlib/genosl/mx_disjointover_color4.osl | 25 - .../libraries/stdlib/genosl/mx_divide.inline | 1 - .../stdlib/genosl/mx_dodge_color3.osl | 8 - .../stdlib/genosl/mx_dodge_color4.osl | 9 - .../stdlib/genosl/mx_dodge_float.osl | 9 - .../libraries/stdlib/genosl/mx_dot.inline | 1 - .../stdlib/genosl/mx_dotproduct.inline | 1 - .../libraries/stdlib/genosl/mx_exp.inline | 1 - .../libraries/stdlib/genosl/mx_floor.inline | 1 - .../stdlib/genosl/mx_fractal3d_color3.osl | 5 - .../stdlib/genosl/mx_fractal3d_color4.osl | 5 - .../stdlib/genosl/mx_fractal3d_fa_color3.osl | 5 - .../stdlib/genosl/mx_fractal3d_fa_color4.osl | 5 - .../stdlib/genosl/mx_fractal3d_fa_vector2.osl | 5 - .../stdlib/genosl/mx_fractal3d_fa_vector3.osl | 5 - .../stdlib/genosl/mx_fractal3d_fa_vector4.osl | 5 - .../stdlib/genosl/mx_fractal3d_float.osl | 5 - .../stdlib/genosl/mx_fractal3d_vector2.osl | 5 - .../stdlib/genosl/mx_fractal3d_vector3.osl | 5 - .../stdlib/genosl/mx_fractal3d_vector4.osl | 5 - .../stdlib/genosl/mx_frame_float.osl | 4 - .../mx_g22_ap1_to_lin_rec709_color3.osl | 11 - .../mx_g22_ap1_to_lin_rec709_color4.osl | 11 - .../genosl/mx_gamma18_to_linear_color3.osl | 5 - .../genosl/mx_gamma18_to_linear_color4.osl | 5 - .../genosl/mx_gamma22_to_linear_color3.osl | 5 - .../genosl/mx_gamma22_to_linear_color4.osl | 5 - .../genosl/mx_gamma24_to_linear_color3.osl | 5 - .../genosl/mx_gamma24_to_linear_color4.osl | 5 - .../stdlib/genosl/mx_geomcolor_color3.osl | 4 - .../stdlib/genosl/mx_geomcolor_color4.osl | 9 - .../stdlib/genosl/mx_geomcolor_float.osl | 4 - .../genosl/mx_geompropvalue_boolean.osl | 5 - .../stdlib/genosl/mx_geompropvalue_color3.osl | 5 - .../stdlib/genosl/mx_geompropvalue_color4.osl | 16 - .../stdlib/genosl/mx_geompropvalue_float.osl | 7 - .../genosl/mx_geompropvalue_integer.osl | 5 - .../stdlib/genosl/mx_geompropvalue_string.osl | 5 - .../genosl/mx_geompropvalue_vector2.osl | 13 - .../genosl/mx_geompropvalue_vector3.osl | 5 - .../genosl/mx_geompropvalue_vector4.osl | 15 - .../genosl/mx_heighttonormal_vector3.osl | 5 - .../stdlib/genosl/mx_hsvtorgb_color3.osl | 4 - .../stdlib/genosl/mx_hsvtorgb_color4.osl | 4 - .../stdlib/genosl/mx_image_color3.osl | 16 - .../stdlib/genosl/mx_image_color4.osl | 21 - .../stdlib/genosl/mx_image_float.osl | 17 - .../stdlib/genosl/mx_image_vector2.osl | 18 - .../stdlib/genosl/mx_image_vector3.osl | 16 - .../stdlib/genosl/mx_image_vector4.osl | 21 - .../libraries/stdlib/genosl/mx_in.inline | 1 - .../libraries/stdlib/genosl/mx_inside.inline | 1 - .../libraries/stdlib/genosl/mx_invert.inline | 1 - .../libraries/stdlib/genosl/mx_invertM.inline | 1 - .../libraries/stdlib/genosl/mx_ln.inline | 1 - .../stdlib/genosl/mx_luminance_color3.osl | 4 - .../stdlib/genosl/mx_luminance_color4.osl | 4 - .../stdlib/genosl/mx_magnitude.inline | 1 - .../libraries/stdlib/genosl/mx_mask.inline | 1 - .../stdlib/genosl/mx_matte_color4.inline | 1 - .../libraries/stdlib/genosl/mx_max.inline | 1 - .../libraries/stdlib/genosl/mx_min.inline | 1 - .../libraries/stdlib/genosl/mx_minus.inline | 1 - .../libraries/stdlib/genosl/mx_mix.inline | 1 - .../libraries/stdlib/genosl/mx_modulo.inline | 1 - .../stdlib/genosl/mx_modulo_color3FA.inline | 1 - .../stdlib/genosl/mx_modulo_vector3FA.inline | 1 - .../stdlib/genosl/mx_multiply.inline | 1 - .../stdlib/genosl/mx_noise2d_color3.osl | 5 - .../stdlib/genosl/mx_noise2d_color4.osl | 5 - .../stdlib/genosl/mx_noise2d_fa_color3.osl | 5 - .../stdlib/genosl/mx_noise2d_fa_color4.osl | 5 - .../stdlib/genosl/mx_noise2d_fa_vector2.osl | 5 - .../stdlib/genosl/mx_noise2d_fa_vector3.osl | 5 - .../stdlib/genosl/mx_noise2d_fa_vector4.osl | 5 - .../stdlib/genosl/mx_noise2d_float.osl | 5 - .../stdlib/genosl/mx_noise2d_vector2.osl | 5 - .../stdlib/genosl/mx_noise2d_vector3.osl | 5 - .../stdlib/genosl/mx_noise2d_vector4.osl | 5 - .../stdlib/genosl/mx_noise3d_color3.osl | 5 - .../stdlib/genosl/mx_noise3d_color4.osl | 5 - .../stdlib/genosl/mx_noise3d_fa_color3.osl | 5 - .../stdlib/genosl/mx_noise3d_fa_color4.osl | 5 - .../stdlib/genosl/mx_noise3d_fa_vector2.osl | 5 - .../stdlib/genosl/mx_noise3d_fa_vector3.osl | 5 - .../stdlib/genosl/mx_noise3d_fa_vector4.osl | 5 - .../stdlib/genosl/mx_noise3d_float.osl | 5 - .../stdlib/genosl/mx_noise3d_vector2.osl | 5 - .../stdlib/genosl/mx_noise3d_vector3.osl | 5 - .../stdlib/genosl/mx_noise3d_vector4.osl | 5 - .../stdlib/genosl/mx_normal_vector3.inline | 1 - .../stdlib/genosl/mx_normalize.inline | 1 - .../libraries/stdlib/genosl/mx_normalmap.osl | 17 - .../libraries/stdlib/genosl/mx_out.inline | 1 - .../libraries/stdlib/genosl/mx_outside.inline | 1 - .../libraries/stdlib/genosl/mx_over.inline | 1 - .../libraries/stdlib/genosl/mx_overlay.inline | 1 - .../stdlib/genosl/mx_overlay_color3.osl | 16 - .../stdlib/genosl/mx_overlay_color4.osl | 22 - .../libraries/stdlib/genosl/mx_plus.inline | 1 - .../stdlib/genosl/mx_position_vector3.inline | 1 - .../libraries/stdlib/genosl/mx_power.inline | 1 - .../stdlib/genosl/mx_premult_color4.osl | 4 - .../libraries/stdlib/genosl/mx_ramplr.inline | 1 - .../libraries/stdlib/genosl/mx_ramptb.inline | 1 - .../libraries/stdlib/genosl/mx_remap.inline | 1 - .../stdlib/genosl/mx_rgbtohsv_color3.osl | 4 - .../stdlib/genosl/mx_rgbtohsv_color4.osl | 4 - .../stdlib/genosl/mx_rotate_vector2.osl | 7 - .../stdlib/genosl/mx_rotate_vector3.osl | 20 - .../libraries/stdlib/genosl/mx_screen.inline | 1 - .../libraries/stdlib/genosl/mx_sign.inline | 1 - .../libraries/stdlib/genosl/mx_sin.inline | 1 - .../stdlib/genosl/mx_smoothstep.inline | 1 - .../libraries/stdlib/genosl/mx_splitlr.inline | 1 - .../libraries/stdlib/genosl/mx_splittb.inline | 1 - .../libraries/stdlib/genosl/mx_sqrt.inline | 1 - .../mx_srgb_texture_to_linear_color3.osl | 17 - .../mx_srgb_texture_to_linear_color4.osl | 19 - .../stdlib/genosl/mx_subtract.inline | 1 - .../libraries/stdlib/genosl/mx_tan.inline | 1 - .../stdlib/genosl/mx_tangent_vector3.inline | 1 - .../stdlib/genosl/mx_texcoord_vector2.inline | 1 - .../stdlib/genosl/mx_texcoord_vector3.inline | 1 - .../libraries/stdlib/genosl/mx_time_float.osl | 6 - .../stdlib/genosl/mx_transformmatrix.inline | 1 - .../genosl/mx_transformmatrix_vector2M3.osl | 6 - .../stdlib/genosl/mx_transformnormal.inline | 1 - .../stdlib/genosl/mx_transformpoint.inline | 1 - .../stdlib/genosl/mx_transformvector.inline | 1 - .../stdlib/genosl/mx_transpose.inline | 1 - .../stdlib/genosl/mx_unpremult_color4.osl | 4 - .../stdlib/genosl/stdlib_genosl_cm_impl.mtlx | 24 - .../stdlib/genosl/stdlib_genosl_impl.mtlx | 775 --- .../genosl/stdlib_genosl_unit_impl.mtlx | 18 - materialx/libraries/stdlib/osl/README.md | 5 - materialx/libraries/stdlib/osl/color4.h | 332 -- materialx/libraries/stdlib/osl/matrix33.h | 165 - .../libraries/stdlib/osl/mx_absval_color.osl | 17 - .../libraries/stdlib/osl/mx_absval_color4.osl | 17 - .../libraries/stdlib/osl/mx_absval_float.osl | 17 - .../libraries/stdlib/osl/mx_absval_vector.osl | 17 - .../stdlib/osl/mx_absval_vector2.osl | 17 - .../stdlib/osl/mx_absval_vector4.osl | 17 - .../libraries/stdlib/osl/mx_acos_color.osl | 17 - .../libraries/stdlib/osl/mx_acos_color4.osl | 17 - .../libraries/stdlib/osl/mx_acos_float.osl | 17 - .../libraries/stdlib/osl/mx_acos_vector.osl | 17 - .../libraries/stdlib/osl/mx_acos_vector2.osl | 17 - .../libraries/stdlib/osl/mx_acos_vector4.osl | 17 - .../libraries/stdlib/osl/mx_add_color.osl | 19 - .../libraries/stdlib/osl/mx_add_color4.osl | 19 - .../libraries/stdlib/osl/mx_add_float.osl | 19 - .../stdlib/osl/mx_add_float_color.osl | 18 - .../stdlib/osl/mx_add_float_color4.osl | 18 - .../stdlib/osl/mx_add_float_matrix33.osl | 18 - .../stdlib/osl/mx_add_float_matrix44.osl | 18 - .../stdlib/osl/mx_add_float_vector.osl | 18 - .../stdlib/osl/mx_add_float_vector2.osl | 18 - .../stdlib/osl/mx_add_float_vector4.osl | 18 - .../libraries/stdlib/osl/mx_add_matrix33.osl | 19 - .../libraries/stdlib/osl/mx_add_matrix44.osl | 19 - .../stdlib/osl/mx_add_surfaceshader.osl | 19 - .../libraries/stdlib/osl/mx_add_vector.osl | 19 - .../libraries/stdlib/osl/mx_add_vector2.osl | 19 - .../libraries/stdlib/osl/mx_add_vector4.osl | 19 - .../stdlib/osl/mx_ambientocclusion_float.osl | 19 - .../libraries/stdlib/osl/mx_asin_color.osl | 17 - .../libraries/stdlib/osl/mx_asin_color4.osl | 17 - .../libraries/stdlib/osl/mx_asin_float.osl | 17 - .../libraries/stdlib/osl/mx_asin_vector.osl | 17 - .../libraries/stdlib/osl/mx_asin_vector2.osl | 17 - .../libraries/stdlib/osl/mx_asin_vector4.osl | 17 - .../libraries/stdlib/osl/mx_atan2_color.osl | 19 - .../libraries/stdlib/osl/mx_atan2_color4.osl | 19 - .../libraries/stdlib/osl/mx_atan2_float.osl | 19 - .../stdlib/osl/mx_atan2_float_color.osl | 19 - .../stdlib/osl/mx_atan2_float_color4.osl | 19 - .../stdlib/osl/mx_atan2_float_vector.osl | 19 - .../stdlib/osl/mx_atan2_float_vector2.osl | 19 - .../stdlib/osl/mx_atan2_float_vector4.osl | 19 - .../libraries/stdlib/osl/mx_atan2_vector.osl | 19 - .../libraries/stdlib/osl/mx_atan2_vector2.osl | 19 - .../libraries/stdlib/osl/mx_atan2_vector4.osl | 19 - .../stdlib/osl/mx_bitangent_vector.osl | 17 - .../libraries/stdlib/osl/mx_blur_color.osl | 19 - .../libraries/stdlib/osl/mx_blur_color4.osl | 19 - .../libraries/stdlib/osl/mx_blur_float.osl | 19 - .../libraries/stdlib/osl/mx_blur_vector.osl | 19 - .../libraries/stdlib/osl/mx_blur_vector2.osl | 19 - .../libraries/stdlib/osl/mx_blur_vector4.osl | 19 - .../libraries/stdlib/osl/mx_burn_color.osl | 18 - .../libraries/stdlib/osl/mx_burn_color4.osl | 18 - .../libraries/stdlib/osl/mx_burn_float.osl | 18 - .../libraries/stdlib/osl/mx_ceil_color.osl | 17 - .../libraries/stdlib/osl/mx_ceil_color4.osl | 17 - .../libraries/stdlib/osl/mx_ceil_float.osl | 17 - .../libraries/stdlib/osl/mx_ceil_vector.osl | 17 - .../libraries/stdlib/osl/mx_ceil_vector2.osl | 17 - .../libraries/stdlib/osl/mx_ceil_vector4.osl | 17 - .../stdlib/osl/mx_cellnoise2d_float.osl | 20 - .../stdlib/osl/mx_cellnoise3d_float.osl | 20 - .../libraries/stdlib/osl/mx_clamp_color.osl | 19 - .../libraries/stdlib/osl/mx_clamp_color4.osl | 19 - .../libraries/stdlib/osl/mx_clamp_float.osl | 19 - .../stdlib/osl/mx_clamp_float_color.osl | 19 - .../stdlib/osl/mx_clamp_float_color4.osl | 19 - .../stdlib/osl/mx_clamp_float_vector.osl | 19 - .../stdlib/osl/mx_clamp_float_vector2.osl | 19 - .../stdlib/osl/mx_clamp_float_vector4.osl | 19 - .../libraries/stdlib/osl/mx_clamp_vector.osl | 19 - .../libraries/stdlib/osl/mx_clamp_vector2.osl | 19 - .../libraries/stdlib/osl/mx_clamp_vector4.osl | 19 - .../stdlib/osl/mx_combine2_vector2.osl | 22 - .../stdlib/osl/mx_combine3_color.osl | 22 - .../stdlib/osl/mx_combine3_vector.osl | 22 - .../stdlib/osl/mx_combine4_color4.osl | 22 - .../stdlib/osl/mx_combine4_vector4.osl | 22 - .../stdlib/osl/mx_combine_cf_color4.osl | 20 - .../stdlib/osl/mx_combine_vf_vector4.osl | 22 - .../stdlib/osl/mx_combine_vv_vector4.osl | 22 - .../libraries/stdlib/osl/mx_compare_color.osl | 26 - .../stdlib/osl/mx_compare_color4.osl | 26 - .../libraries/stdlib/osl/mx_compare_float.osl | 26 - .../stdlib/osl/mx_compare_vector.osl | 26 - .../stdlib/osl/mx_compare_vector2.osl | 26 - .../stdlib/osl/mx_compare_vector4.osl | 26 - .../libraries/stdlib/osl/mx_constant_bool.osl | 17 - .../stdlib/osl/mx_constant_color.osl | 17 - .../stdlib/osl/mx_constant_color4.osl | 17 - .../stdlib/osl/mx_constant_filename.osl | 17 - .../stdlib/osl/mx_constant_float.osl | 17 - .../libraries/stdlib/osl/mx_constant_int.osl | 17 - .../stdlib/osl/mx_constant_matrix33.osl | 17 - .../stdlib/osl/mx_constant_matrix44.osl | 17 - .../stdlib/osl/mx_constant_string.osl | 17 - .../stdlib/osl/mx_constant_vector.osl | 17 - .../stdlib/osl/mx_constant_vector2.osl | 17 - .../stdlib/osl/mx_constant_vector4.osl | 17 - .../libraries/stdlib/osl/mx_cos_color.osl | 17 - .../libraries/stdlib/osl/mx_cos_color4.osl | 17 - .../libraries/stdlib/osl/mx_cos_float.osl | 17 - .../libraries/stdlib/osl/mx_cos_vector.osl | 17 - .../libraries/stdlib/osl/mx_cos_vector2.osl | 17 - .../libraries/stdlib/osl/mx_cos_vector4.osl | 17 - .../stdlib/osl/mx_crossproduct_vector.osl | 18 - .../stdlib/osl/mx_determinant_matrix33.osl | 17 - .../stdlib/osl/mx_determinant_matrix44.osl | 17 - .../stdlib/osl/mx_disjointover_color4.osl | 38 - .../libraries/stdlib/osl/mx_divide_color.osl | 18 - .../libraries/stdlib/osl/mx_divide_color4.osl | 18 - .../libraries/stdlib/osl/mx_divide_float.osl | 18 - .../stdlib/osl/mx_divide_float_color.osl | 18 - .../stdlib/osl/mx_divide_float_color4.osl | 18 - .../stdlib/osl/mx_divide_float_matrix33.osl | 18 - .../stdlib/osl/mx_divide_float_matrix44.osl | 18 - .../stdlib/osl/mx_divide_float_vector.osl | 18 - .../stdlib/osl/mx_divide_float_vector2.osl | 18 - .../stdlib/osl/mx_divide_float_vector4.osl | 18 - .../stdlib/osl/mx_divide_matrix33.osl | 18 - .../stdlib/osl/mx_divide_matrix44.osl | 18 - .../libraries/stdlib/osl/mx_divide_vector.osl | 18 - .../stdlib/osl/mx_divide_vector2.osl | 18 - .../stdlib/osl/mx_divide_vector4.osl | 18 - .../libraries/stdlib/osl/mx_dodge_color.osl | 18 - .../libraries/stdlib/osl/mx_dodge_color4.osl | 18 - .../libraries/stdlib/osl/mx_dodge_float.osl | 18 - .../libraries/stdlib/osl/mx_dot_bool.osl | 17 - .../libraries/stdlib/osl/mx_dot_color.osl | 17 - .../libraries/stdlib/osl/mx_dot_color4.osl | 17 - .../stdlib/osl/mx_dot_displacementshader.osl | 17 - .../libraries/stdlib/osl/mx_dot_filename.osl | 17 - .../libraries/stdlib/osl/mx_dot_float.osl | 17 - materialx/libraries/stdlib/osl/mx_dot_int.osl | 17 - .../stdlib/osl/mx_dot_lightshader.osl | 17 - .../libraries/stdlib/osl/mx_dot_matrix33.osl | 17 - .../libraries/stdlib/osl/mx_dot_matrix44.osl | 17 - .../libraries/stdlib/osl/mx_dot_string.osl | 17 - .../stdlib/osl/mx_dot_surfaceshader.osl | 17 - .../libraries/stdlib/osl/mx_dot_vector.osl | 17 - .../libraries/stdlib/osl/mx_dot_vector2.osl | 17 - .../libraries/stdlib/osl/mx_dot_vector4.osl | 17 - .../stdlib/osl/mx_dot_volumeshader.osl | 17 - .../stdlib/osl/mx_dotproduct_vector.osl | 18 - .../stdlib/osl/mx_dotproduct_vector2.osl | 18 - .../stdlib/osl/mx_dotproduct_vector4.osl | 18 - .../libraries/stdlib/osl/mx_exp_color.osl | 17 - .../libraries/stdlib/osl/mx_exp_color4.osl | 17 - .../libraries/stdlib/osl/mx_exp_float.osl | 17 - .../libraries/stdlib/osl/mx_exp_vector.osl | 17 - .../libraries/stdlib/osl/mx_exp_vector2.osl | 17 - .../libraries/stdlib/osl/mx_exp_vector4.osl | 17 - .../stdlib/osl/mx_exponent_float.osl | 18 - .../stdlib/osl/mx_exponent_vector.osl | 18 - .../stdlib/osl/mx_exponent_vector2.osl | 18 - .../stdlib/osl/mx_exponent_vector4.osl | 18 - .../libraries/stdlib/osl/mx_extract_color.osl | 19 - .../stdlib/osl/mx_extract_color4.osl | 19 - .../stdlib/osl/mx_extract_vector.osl | 19 - .../stdlib/osl/mx_extract_vector2.osl | 19 - .../stdlib/osl/mx_extract_vector4.osl | 19 - .../libraries/stdlib/osl/mx_floor_color.osl | 17 - .../libraries/stdlib/osl/mx_floor_color4.osl | 17 - .../libraries/stdlib/osl/mx_floor_float.osl | 17 - .../libraries/stdlib/osl/mx_floor_vector.osl | 17 - .../libraries/stdlib/osl/mx_floor_vector2.osl | 17 - .../libraries/stdlib/osl/mx_floor_vector4.osl | 17 - .../stdlib/osl/mx_fractal3d_color.osl | 36 - .../stdlib/osl/mx_fractal3d_color4.osl | 36 - .../stdlib/osl/mx_fractal3d_fa_color.osl | 36 - .../stdlib/osl/mx_fractal3d_fa_color4.osl | 36 - .../stdlib/osl/mx_fractal3d_fa_vector.osl | 36 - .../stdlib/osl/mx_fractal3d_fa_vector2.osl | 36 - .../stdlib/osl/mx_fractal3d_fa_vector4.osl | 36 - .../stdlib/osl/mx_fractal3d_float.osl | 36 - .../stdlib/osl/mx_fractal3d_vector.osl | 36 - .../stdlib/osl/mx_fractal3d_vector2.osl | 36 - .../stdlib/osl/mx_fractal3d_vector4.osl | 36 - .../libraries/stdlib/osl/mx_frame_float.osl | 16 - materialx/libraries/stdlib/osl/mx_funcs.h | 817 ---- .../stdlib/osl/mx_geomcolor_color.osl | 16 - .../stdlib/osl/mx_geomcolor_color4.osl | 16 - .../stdlib/osl/mx_geomcolor_float.osl | 16 - .../stdlib/osl/mx_geompropvalue_bool.osl | 18 - .../stdlib/osl/mx_geompropvalue_color.osl | 18 - .../stdlib/osl/mx_geompropvalue_color4.osl | 18 - .../stdlib/osl/mx_geompropvalue_float.osl | 18 - .../stdlib/osl/mx_geompropvalue_int.osl | 18 - .../stdlib/osl/mx_geompropvalue_string.osl | 18 - .../stdlib/osl/mx_geompropvalue_vector.osl | 18 - .../stdlib/osl/mx_geompropvalue_vector2.osl | 18 - .../stdlib/osl/mx_geompropvalue_vector4.osl | 18 - .../stdlib/osl/mx_heighttonormal_vector.osl | 19 - .../stdlib/osl/mx_hsvadjust_color.osl | 41 - .../stdlib/osl/mx_hsvadjust_color4.osl | 41 - .../stdlib/osl/mx_hsvtorgb_color.osl | 18 - .../stdlib/osl/mx_hsvtorgb_color4.osl | 18 - .../stdlib/osl/mx_hueshift_color.osl | 43 - .../stdlib/osl/mx_hueshift_color4.osl | 43 - .../libraries/stdlib/osl/mx_image_color.osl | 50 - .../libraries/stdlib/osl/mx_image_color4.osl | 50 - .../libraries/stdlib/osl/mx_image_float.osl | 50 - .../libraries/stdlib/osl/mx_image_vector.osl | 50 - .../libraries/stdlib/osl/mx_image_vector2.osl | 50 - .../libraries/stdlib/osl/mx_image_vector4.osl | 50 - .../libraries/stdlib/osl/mx_in_color4.osl | 19 - .../libraries/stdlib/osl/mx_inside_color.osl | 19 - .../libraries/stdlib/osl/mx_inside_color4.osl | 19 - .../libraries/stdlib/osl/mx_inside_float.osl | 19 - .../libraries/stdlib/osl/mx_invert_color.osl | 18 - .../libraries/stdlib/osl/mx_invert_color4.osl | 18 - .../libraries/stdlib/osl/mx_invert_float.osl | 18 - .../stdlib/osl/mx_invert_float_color.osl | 18 - .../stdlib/osl/mx_invert_float_color4.osl | 18 - .../stdlib/osl/mx_invert_float_vector.osl | 18 - .../stdlib/osl/mx_invert_float_vector2.osl | 18 - .../stdlib/osl/mx_invert_float_vector4.osl | 18 - .../libraries/stdlib/osl/mx_invert_vector.osl | 18 - .../stdlib/osl/mx_invert_vector2.osl | 18 - .../stdlib/osl/mx_invert_vector4.osl | 18 - .../libraries/stdlib/osl/mx_ln_color.osl | 17 - .../libraries/stdlib/osl/mx_ln_color4.osl | 17 - .../libraries/stdlib/osl/mx_ln_float.osl | 17 - .../libraries/stdlib/osl/mx_ln_vector.osl | 17 - .../libraries/stdlib/osl/mx_ln_vector2.osl | 17 - .../libraries/stdlib/osl/mx_ln_vector4.osl | 17 - .../stdlib/osl/mx_luminance_color.osl | 35 - .../stdlib/osl/mx_luminance_color4.osl | 35 - .../stdlib/osl/mx_magnitude_vector.osl | 17 - .../stdlib/osl/mx_magnitude_vector2.osl | 17 - .../stdlib/osl/mx_magnitude_vector4.osl | 17 - .../libraries/stdlib/osl/mx_mask_color4.osl | 19 - .../stdlib/osl/mx_matrix_invert_matrix33.osl | 17 - .../stdlib/osl/mx_matrix_invert_matrix44.osl | 17 - .../libraries/stdlib/osl/mx_matte_color4.osl | 27 - .../libraries/stdlib/osl/mx_max_color.osl | 18 - .../libraries/stdlib/osl/mx_max_color4.osl | 18 - .../libraries/stdlib/osl/mx_max_float.osl | 18 - .../stdlib/osl/mx_max_float_color.osl | 18 - .../stdlib/osl/mx_max_float_color4.osl | 18 - .../stdlib/osl/mx_max_float_vector.osl | 18 - .../stdlib/osl/mx_max_float_vector2.osl | 18 - .../stdlib/osl/mx_max_float_vector4.osl | 18 - .../libraries/stdlib/osl/mx_max_vector.osl | 18 - .../libraries/stdlib/osl/mx_max_vector2.osl | 18 - .../libraries/stdlib/osl/mx_max_vector4.osl | 18 - .../libraries/stdlib/osl/mx_min_color.osl | 18 - .../libraries/stdlib/osl/mx_min_color4.osl | 18 - .../libraries/stdlib/osl/mx_min_float.osl | 18 - .../stdlib/osl/mx_min_float_color.osl | 18 - .../stdlib/osl/mx_min_float_color4.osl | 18 - .../stdlib/osl/mx_min_float_vector.osl | 18 - .../stdlib/osl/mx_min_float_vector2.osl | 18 - .../stdlib/osl/mx_min_float_vector4.osl | 18 - .../libraries/stdlib/osl/mx_min_vector.osl | 18 - .../libraries/stdlib/osl/mx_min_vector2.osl | 18 - .../libraries/stdlib/osl/mx_min_vector4.osl | 18 - .../libraries/stdlib/osl/mx_mix_color.osl | 19 - .../libraries/stdlib/osl/mx_mix_color4.osl | 19 - .../libraries/stdlib/osl/mx_mix_float.osl | 19 - .../stdlib/osl/mx_mix_surfaceshader.osl | 19 - .../libraries/stdlib/osl/mx_mix_vector.osl | 19 - .../libraries/stdlib/osl/mx_mix_vector2.osl | 19 - .../libraries/stdlib/osl/mx_mix_vector4.osl | 19 - .../libraries/stdlib/osl/mx_modulo_color.osl | 20 - .../libraries/stdlib/osl/mx_modulo_color4.osl | 20 - .../libraries/stdlib/osl/mx_modulo_float.osl | 20 - .../stdlib/osl/mx_modulo_float_color.osl | 20 - .../stdlib/osl/mx_modulo_float_color4.osl | 20 - .../stdlib/osl/mx_modulo_float_vector.osl | 20 - .../stdlib/osl/mx_modulo_float_vector2.osl | 20 - .../stdlib/osl/mx_modulo_float_vector4.osl | 20 - .../libraries/stdlib/osl/mx_modulo_vector.osl | 20 - .../stdlib/osl/mx_modulo_vector2.osl | 20 - .../stdlib/osl/mx_modulo_vector4.osl | 20 - .../osl/mx_mult_surfaceshader_color.osl | 18 - .../osl/mx_mult_surfaceshader_float.osl | 18 - .../stdlib/osl/mx_multiply_color.osl | 18 - .../stdlib/osl/mx_multiply_color4.osl | 18 - .../stdlib/osl/mx_multiply_float.osl | 18 - .../stdlib/osl/mx_multiply_float_color.osl | 18 - .../stdlib/osl/mx_multiply_float_color4.osl | 18 - .../stdlib/osl/mx_multiply_float_matrix33.osl | 18 - .../stdlib/osl/mx_multiply_float_matrix44.osl | 18 - .../stdlib/osl/mx_multiply_float_vector.osl | 18 - .../stdlib/osl/mx_multiply_float_vector2.osl | 18 - .../stdlib/osl/mx_multiply_float_vector4.osl | 18 - .../stdlib/osl/mx_multiply_matrix33.osl | 18 - .../stdlib/osl/mx_multiply_matrix44.osl | 18 - .../stdlib/osl/mx_multiply_vector.osl | 18 - .../stdlib/osl/mx_multiply_vector2.osl | 18 - .../stdlib/osl/mx_multiply_vector4.osl | 18 - .../libraries/stdlib/osl/mx_noise2d_color.osl | 29 - .../stdlib/osl/mx_noise2d_color4.osl | 29 - .../stdlib/osl/mx_noise2d_fa_color.osl | 30 - .../stdlib/osl/mx_noise2d_fa_color4.osl | 30 - .../stdlib/osl/mx_noise2d_fa_vector.osl | 30 - .../stdlib/osl/mx_noise2d_fa_vector2.osl | 30 - .../stdlib/osl/mx_noise2d_fa_vector4.osl | 30 - .../libraries/stdlib/osl/mx_noise2d_float.osl | 29 - .../stdlib/osl/mx_noise2d_vector.osl | 29 - .../stdlib/osl/mx_noise2d_vector2.osl | 29 - .../stdlib/osl/mx_noise2d_vector4.osl | 29 - .../libraries/stdlib/osl/mx_noise3d_color.osl | 29 - .../stdlib/osl/mx_noise3d_color4.osl | 29 - .../stdlib/osl/mx_noise3d_fa_color.osl | 30 - .../stdlib/osl/mx_noise3d_fa_color4.osl | 30 - .../stdlib/osl/mx_noise3d_fa_vector.osl | 30 - .../stdlib/osl/mx_noise3d_fa_vector2.osl | 30 - .../stdlib/osl/mx_noise3d_fa_vector4.osl | 30 - .../libraries/stdlib/osl/mx_noise3d_float.osl | 29 - .../stdlib/osl/mx_noise3d_vector.osl | 29 - .../stdlib/osl/mx_noise3d_vector2.osl | 29 - .../stdlib/osl/mx_noise3d_vector4.osl | 29 - .../libraries/stdlib/osl/mx_normal_vector.osl | 17 - .../stdlib/osl/mx_normalize_vector.osl | 17 - .../stdlib/osl/mx_normalize_vector2.osl | 17 - .../stdlib/osl/mx_normalize_vector4.osl | 17 - .../libraries/stdlib/osl/mx_out_color4.osl | 19 - .../libraries/stdlib/osl/mx_outside_color.osl | 19 - .../stdlib/osl/mx_outside_color4.osl | 19 - .../libraries/stdlib/osl/mx_outside_float.osl | 19 - .../libraries/stdlib/osl/mx_over_color4.osl | 19 - .../libraries/stdlib/osl/mx_overlay_color.osl | 39 - .../stdlib/osl/mx_overlay_color4.osl | 39 - .../libraries/stdlib/osl/mx_overlay_float.osl | 39 - .../stdlib/osl/mx_position_vector.osl | 17 - .../libraries/stdlib/osl/mx_power_color.osl | 18 - .../libraries/stdlib/osl/mx_power_color4.osl | 18 - .../libraries/stdlib/osl/mx_power_float.osl | 18 - .../stdlib/osl/mx_power_float_color.osl | 18 - .../stdlib/osl/mx_power_float_color4.osl | 18 - .../stdlib/osl/mx_power_float_vector.osl | 18 - .../stdlib/osl/mx_power_float_vector2.osl | 18 - .../stdlib/osl/mx_power_float_vector4.osl | 18 - .../libraries/stdlib/osl/mx_power_vector.osl | 18 - .../libraries/stdlib/osl/mx_power_vector2.osl | 18 - .../libraries/stdlib/osl/mx_power_vector4.osl | 18 - .../libraries/stdlib/osl/mx_premult_color.osl | 34 - .../stdlib/osl/mx_premult_color4.osl | 34 - .../libraries/stdlib/osl/mx_ramp4_color.osl | 31 - .../libraries/stdlib/osl/mx_ramp4_color4.osl | 31 - .../libraries/stdlib/osl/mx_ramp4_float.osl | 31 - .../libraries/stdlib/osl/mx_ramp4_vector.osl | 31 - .../libraries/stdlib/osl/mx_ramp4_vector2.osl | 31 - .../libraries/stdlib/osl/mx_ramp4_vector4.osl | 31 - .../libraries/stdlib/osl/mx_ramplr_color.osl | 26 - .../libraries/stdlib/osl/mx_ramplr_color4.osl | 26 - .../libraries/stdlib/osl/mx_ramplr_float.osl | 26 - .../libraries/stdlib/osl/mx_ramplr_vector.osl | 26 - .../stdlib/osl/mx_ramplr_vector2.osl | 26 - .../stdlib/osl/mx_ramplr_vector4.osl | 26 - .../libraries/stdlib/osl/mx_ramptb_color.osl | 23 - .../libraries/stdlib/osl/mx_ramptb_color4.osl | 23 - .../libraries/stdlib/osl/mx_ramptb_float.osl | 23 - .../libraries/stdlib/osl/mx_ramptb_vector.osl | 23 - .../stdlib/osl/mx_ramptb_vector2.osl | 23 - .../stdlib/osl/mx_ramptb_vector4.osl | 23 - .../libraries/stdlib/osl/mx_remap_color.osl | 33 - .../libraries/stdlib/osl/mx_remap_color4.osl | 33 - .../libraries/stdlib/osl/mx_remap_float.osl | 33 - .../stdlib/osl/mx_remap_float_color.osl | 31 - .../stdlib/osl/mx_remap_float_color4.osl | 31 - .../stdlib/osl/mx_remap_float_vector.osl | 31 - .../stdlib/osl/mx_remap_float_vector2.osl | 31 - .../stdlib/osl/mx_remap_float_vector4.osl | 31 - .../libraries/stdlib/osl/mx_remap_vector.osl | 33 - .../libraries/stdlib/osl/mx_remap_vector2.osl | 33 - .../libraries/stdlib/osl/mx_remap_vector4.osl | 33 - .../stdlib/osl/mx_rgbtohsv_color.osl | 18 - .../stdlib/osl/mx_rgbtohsv_color4.osl | 18 - .../stdlib/osl/mx_rotate2d_vector2.osl | 23 - .../libraries/stdlib/osl/mx_rotate_vector.osl | 21 - .../stdlib/osl/mx_rotate_vector2.osl | 21 - .../libraries/stdlib/osl/mx_scale_vector.osl | 19 - .../libraries/stdlib/osl/mx_scale_vector2.osl | 19 - .../libraries/stdlib/osl/mx_screen_color.osl | 18 - .../libraries/stdlib/osl/mx_screen_color4.osl | 18 - .../libraries/stdlib/osl/mx_screen_float.osl | 18 - .../stdlib/osl/mx_separate_color.osl | 75 - .../stdlib/osl/mx_separate_color4.osl | 75 - .../stdlib/osl/mx_separate_vector.osl | 75 - .../stdlib/osl/mx_separate_vector2.osl | 75 - .../stdlib/osl/mx_separate_vector4.osl | 75 - .../libraries/stdlib/osl/mx_sign_color.osl | 17 - .../libraries/stdlib/osl/mx_sign_color4.osl | 17 - .../libraries/stdlib/osl/mx_sign_float.osl | 17 - .../libraries/stdlib/osl/mx_sign_vector.osl | 17 - .../libraries/stdlib/osl/mx_sign_vector2.osl | 17 - .../libraries/stdlib/osl/mx_sign_vector4.osl | 17 - .../libraries/stdlib/osl/mx_sin_color.osl | 17 - .../libraries/stdlib/osl/mx_sin_color4.osl | 17 - .../libraries/stdlib/osl/mx_sin_float.osl | 17 - .../libraries/stdlib/osl/mx_sin_vector.osl | 17 - .../libraries/stdlib/osl/mx_sin_vector2.osl | 17 - .../libraries/stdlib/osl/mx_sin_vector4.osl | 17 - .../stdlib/osl/mx_smoothstep_color.osl | 22 - .../stdlib/osl/mx_smoothstep_color4.osl | 22 - .../stdlib/osl/mx_smoothstep_float.osl | 22 - .../stdlib/osl/mx_smoothstep_float_color.osl | 22 - .../stdlib/osl/mx_smoothstep_float_color4.osl | 22 - .../stdlib/osl/mx_smoothstep_float_vector.osl | 22 - .../osl/mx_smoothstep_float_vector2.osl | 22 - .../osl/mx_smoothstep_float_vector4.osl | 22 - .../stdlib/osl/mx_smoothstep_vector.osl | 22 - .../stdlib/osl/mx_smoothstep_vector2.osl | 22 - .../stdlib/osl/mx_smoothstep_vector4.osl | 22 - .../libraries/stdlib/osl/mx_splitlr_color.osl | 29 - .../stdlib/osl/mx_splitlr_color4.osl | 29 - .../libraries/stdlib/osl/mx_splitlr_float.osl | 29 - .../stdlib/osl/mx_splitlr_vector.osl | 29 - .../stdlib/osl/mx_splitlr_vector2.osl | 29 - .../stdlib/osl/mx_splitlr_vector4.osl | 29 - .../libraries/stdlib/osl/mx_splittb_color.osl | 29 - .../stdlib/osl/mx_splittb_color4.osl | 29 - .../libraries/stdlib/osl/mx_splittb_float.osl | 29 - .../stdlib/osl/mx_splittb_vector.osl | 29 - .../stdlib/osl/mx_splittb_vector2.osl | 29 - .../stdlib/osl/mx_splittb_vector4.osl | 29 - .../libraries/stdlib/osl/mx_sqrt_color.osl | 17 - .../libraries/stdlib/osl/mx_sqrt_color4.osl | 17 - .../libraries/stdlib/osl/mx_sqrt_float.osl | 17 - .../libraries/stdlib/osl/mx_sqrt_vector.osl | 17 - .../libraries/stdlib/osl/mx_sqrt_vector2.osl | 17 - .../libraries/stdlib/osl/mx_sqrt_vector4.osl | 17 - .../stdlib/osl/mx_subtract_color.osl | 19 - .../stdlib/osl/mx_subtract_color4.osl | 19 - .../stdlib/osl/mx_subtract_float.osl | 19 - .../stdlib/osl/mx_subtract_float_color.osl | 18 - .../stdlib/osl/mx_subtract_float_color4.osl | 18 - .../stdlib/osl/mx_subtract_float_matrix33.osl | 18 - .../stdlib/osl/mx_subtract_float_matrix44.osl | 18 - .../stdlib/osl/mx_subtract_float_vector.osl | 18 - .../stdlib/osl/mx_subtract_float_vector2.osl | 18 - .../stdlib/osl/mx_subtract_float_vector4.osl | 18 - .../stdlib/osl/mx_subtract_matrix33.osl | 19 - .../stdlib/osl/mx_subtract_matrix44.osl | 19 - .../stdlib/osl/mx_subtract_vector.osl | 19 - .../stdlib/osl/mx_subtract_vector2.osl | 19 - .../stdlib/osl/mx_subtract_vector4.osl | 19 - .../libraries/stdlib/osl/mx_switch_color.osl | 34 - .../libraries/stdlib/osl/mx_switch_color4.osl | 34 - .../libraries/stdlib/osl/mx_switch_float.osl | 34 - .../libraries/stdlib/osl/mx_switch_vector.osl | 34 - .../stdlib/osl/mx_switch_vector2.osl | 34 - .../stdlib/osl/mx_switch_vector4.osl | 34 - .../stdlib/osl/mx_swizzle_color4_color.osl | 27 - .../stdlib/osl/mx_swizzle_color4_color4.osl | 27 - .../stdlib/osl/mx_swizzle_color4_float.osl | 27 - .../stdlib/osl/mx_swizzle_color4_vector.osl | 27 - .../stdlib/osl/mx_swizzle_color4_vector2.osl | 27 - .../stdlib/osl/mx_swizzle_color4_vector4.osl | 27 - .../stdlib/osl/mx_swizzle_color_color.osl | 26 - .../stdlib/osl/mx_swizzle_color_color4.osl | 26 - .../stdlib/osl/mx_swizzle_color_float.osl | 26 - .../stdlib/osl/mx_swizzle_color_vector.osl | 26 - .../stdlib/osl/mx_swizzle_color_vector2.osl | 26 - .../stdlib/osl/mx_swizzle_color_vector4.osl | 26 - .../stdlib/osl/mx_swizzle_float_color.osl | 27 - .../stdlib/osl/mx_swizzle_float_color4.osl | 27 - .../stdlib/osl/mx_swizzle_float_vector.osl | 27 - .../stdlib/osl/mx_swizzle_float_vector2.osl | 27 - .../stdlib/osl/mx_swizzle_float_vector4.osl | 27 - .../stdlib/osl/mx_swizzle_vector2_color.osl | 25 - .../stdlib/osl/mx_swizzle_vector2_color4.osl | 25 - .../stdlib/osl/mx_swizzle_vector2_float.osl | 25 - .../stdlib/osl/mx_swizzle_vector2_vector.osl | 25 - .../stdlib/osl/mx_swizzle_vector2_vector2.osl | 25 - .../stdlib/osl/mx_swizzle_vector2_vector4.osl | 25 - .../stdlib/osl/mx_swizzle_vector4_color.osl | 27 - .../stdlib/osl/mx_swizzle_vector4_color4.osl | 27 - .../stdlib/osl/mx_swizzle_vector4_float.osl | 27 - .../stdlib/osl/mx_swizzle_vector4_vector.osl | 27 - .../stdlib/osl/mx_swizzle_vector4_vector2.osl | 27 - .../stdlib/osl/mx_swizzle_vector4_vector4.osl | 27 - .../stdlib/osl/mx_swizzle_vector_color.osl | 26 - .../stdlib/osl/mx_swizzle_vector_color4.osl | 26 - .../stdlib/osl/mx_swizzle_vector_float.osl | 26 - .../stdlib/osl/mx_swizzle_vector_vector.osl | 26 - .../stdlib/osl/mx_swizzle_vector_vector2.osl | 26 - .../stdlib/osl/mx_swizzle_vector_vector4.osl | 26 - .../libraries/stdlib/osl/mx_tan_color.osl | 17 - .../libraries/stdlib/osl/mx_tan_color4.osl | 17 - .../libraries/stdlib/osl/mx_tan_float.osl | 17 - .../libraries/stdlib/osl/mx_tan_vector.osl | 17 - .../libraries/stdlib/osl/mx_tan_vector2.osl | 17 - .../libraries/stdlib/osl/mx_tan_vector4.osl | 17 - .../stdlib/osl/mx_tangent_vector.osl | 17 - .../stdlib/osl/mx_texcoord_vector.osl | 30 - .../stdlib/osl/mx_texcoord_vector2.osl | 30 - .../stdlib/osl/mx_tiledimage_color.osl | 48 - .../stdlib/osl/mx_tiledimage_color4.osl | 48 - .../stdlib/osl/mx_tiledimage_float.osl | 48 - .../stdlib/osl/mx_tiledimage_vector.osl | 48 - .../stdlib/osl/mx_tiledimage_vector2.osl | 48 - .../stdlib/osl/mx_tiledimage_vector4.osl | 48 - .../libraries/stdlib/osl/mx_time_float.osl | 16 - .../stdlib/osl/mx_transformnormal_vector.osl | 27 - .../stdlib/osl/mx_transformnormal_vector4.osl | 27 - .../stdlib/osl/mx_transformpoint_vector.osl | 27 - .../stdlib/osl/mx_transformpoint_vector4.osl | 27 - .../stdlib/osl/mx_transformvector_vector.osl | 27 - .../stdlib/osl/mx_transformvector_vector4.osl | 27 - .../stdlib/osl/mx_transpose_matrix33.osl | 17 - .../stdlib/osl/mx_transpose_matrix44.osl | 17 - .../osl/mx_triplanarprojection_color.osl | 73 - .../osl/mx_triplanarprojection_color4.osl | 73 - .../osl/mx_triplanarprojection_float.osl | 73 - .../osl/mx_triplanarprojection_vector.osl | 73 - .../osl/mx_triplanarprojection_vector2.osl | 73 - .../osl/mx_triplanarprojection_vector4.osl | 73 - .../stdlib/osl/mx_unpremult_color.osl | 34 - .../stdlib/osl/mx_unpremult_color4.osl | 34 - .../stdlib/osl/mx_viewdirection_vector.osl | 14 - materialx/libraries/stdlib/osl/oslutil.h | 135 - .../libraries/stdlib/osl/stdlib_osl_impl.mtlx | 780 --- materialx/libraries/stdlib/osl/stdosl.h | 601 --- materialx/libraries/stdlib/osl/vector2.h | 326 -- materialx/libraries/stdlib/osl/vector4.h | 407 -- materialx/libraries/stdlib/stdlib_defs.mtlx | 4210 ----------------- materialx/libraries/stdlib/stdlib_ng.mtlx | 2070 -------- materialx/libraries/targets/genglsl.mtlx | 14 - materialx/libraries/targets/genmdl.mtlx | 14 - materialx/libraries/targets/genosl.mtlx | 14 - materialx/material/ui.py | 34 +- materialx/nodes/generate_node_classes.py | 5 +- materialx/nodes/ui.py | 27 +- materialx/utils.py | 8 +- 920 files changed, 16 insertions(+), 29938 deletions(-) delete mode 100644 materialx/libraries/README.md delete mode 100644 materialx/libraries/bxdf/disney_brdf_2012.mtlx delete mode 100644 materialx/libraries/bxdf/disney_brdf_2015.mtlx delete mode 100644 materialx/libraries/bxdf/standard_surface.mtlx delete mode 100644 materialx/libraries/bxdf/usd_preview_surface.mtlx delete mode 100644 materialx/libraries/lights/genglsl/lights_genglsl_impl.mtlx delete mode 100644 materialx/libraries/lights/genglsl/mx_directional_light.glsl delete mode 100644 materialx/libraries/lights/genglsl/mx_point_light.glsl delete mode 100644 materialx/libraries/lights/genglsl/mx_spot_light.glsl delete mode 100644 materialx/libraries/lights/lights_defs.mtlx delete mode 100644 materialx/libraries/pbrlib/genglsl/lib/mx_defines.glsl delete mode 100644 materialx/libraries/pbrlib/genglsl/lib/mx_environment_fis.glsl delete mode 100644 materialx/libraries/pbrlib/genglsl/lib/mx_environment_none.glsl delete mode 100644 materialx/libraries/pbrlib/genglsl/lib/mx_environment_prefilter.glsl delete mode 100644 materialx/libraries/pbrlib/genglsl/lib/mx_math.glsl delete mode 100644 materialx/libraries/pbrlib/genglsl/lib/mx_microfacet.glsl delete mode 100644 materialx/libraries/pbrlib/genglsl/lib/mx_microfacet_diffuse.glsl delete mode 100644 materialx/libraries/pbrlib/genglsl/lib/mx_microfacet_sheen.glsl delete mode 100644 materialx/libraries/pbrlib/genglsl/lib/mx_microfacet_specular.glsl delete mode 100644 materialx/libraries/pbrlib/genglsl/lib/mx_refraction_index.glsl delete mode 100644 materialx/libraries/pbrlib/genglsl/lib/mx_shadow.glsl delete mode 100644 materialx/libraries/pbrlib/genglsl/lib/mx_table.glsl delete mode 100644 materialx/libraries/pbrlib/genglsl/mx_add_bsdf.glsl delete mode 100644 materialx/libraries/pbrlib/genglsl/mx_add_edf.glsl delete mode 100644 materialx/libraries/pbrlib/genglsl/mx_artistic_ior.glsl delete mode 100644 materialx/libraries/pbrlib/genglsl/mx_burley_diffuse_bsdf.glsl delete mode 100644 materialx/libraries/pbrlib/genglsl/mx_conductor_bsdf.glsl delete mode 100644 materialx/libraries/pbrlib/genglsl/mx_dielectric_bsdf.glsl delete mode 100644 materialx/libraries/pbrlib/genglsl/mx_generalized_schlick_bsdf.glsl delete mode 100644 materialx/libraries/pbrlib/genglsl/mx_mix_bsdf.glsl delete mode 100644 materialx/libraries/pbrlib/genglsl/mx_mix_edf.glsl delete mode 100644 materialx/libraries/pbrlib/genglsl/mx_multiply_bsdf_color.glsl delete mode 100644 materialx/libraries/pbrlib/genglsl/mx_multiply_bsdf_float.glsl delete mode 100644 materialx/libraries/pbrlib/genglsl/mx_multiply_edf_color.glsl delete mode 100644 materialx/libraries/pbrlib/genglsl/mx_multiply_edf_float.glsl delete mode 100644 materialx/libraries/pbrlib/genglsl/mx_oren_nayar_diffuse_bsdf.glsl delete mode 100644 materialx/libraries/pbrlib/genglsl/mx_roughness_anisotropy.glsl delete mode 100644 materialx/libraries/pbrlib/genglsl/mx_roughness_dual.glsl delete mode 100644 materialx/libraries/pbrlib/genglsl/mx_sheen_bsdf.glsl delete mode 100644 materialx/libraries/pbrlib/genglsl/mx_subsurface_bsdf.glsl delete mode 100644 materialx/libraries/pbrlib/genglsl/mx_translucent_bsdf.glsl delete mode 100644 materialx/libraries/pbrlib/genglsl/mx_uniform_edf.glsl delete mode 100644 materialx/libraries/pbrlib/genglsl/pbrlib_genglsl_impl.mtlx delete mode 100644 materialx/libraries/pbrlib/genmdl/pbrlib_genmdl_impl.mtlx delete mode 100644 materialx/libraries/pbrlib/genosl/lib/mx_microfacet.osl delete mode 100644 materialx/libraries/pbrlib/genosl/lib/mx_microfacet_specular.osl delete mode 100644 materialx/libraries/pbrlib/genosl/lib/mx_refraction_index.osl delete mode 100644 materialx/libraries/pbrlib/genosl/mx_add.inline delete mode 100644 materialx/libraries/pbrlib/genosl/mx_artistic_ior.osl delete mode 100644 materialx/libraries/pbrlib/genosl/mx_burley_diffuse_bsdf.osl delete mode 100644 materialx/libraries/pbrlib/genosl/mx_conductor_bsdf.osl delete mode 100644 materialx/libraries/pbrlib/genosl/mx_dielectric_bsdf.osl delete mode 100644 materialx/libraries/pbrlib/genosl/mx_displacement_float.osl delete mode 100644 materialx/libraries/pbrlib/genosl/mx_displacement_vector3.osl delete mode 100644 materialx/libraries/pbrlib/genosl/mx_generalized_schlick_bsdf.osl delete mode 100644 materialx/libraries/pbrlib/genosl/mx_mix.inline delete mode 100644 materialx/libraries/pbrlib/genosl/mx_multiply_bsdf.inline delete mode 100644 materialx/libraries/pbrlib/genosl/mx_multiply_edf.inline delete mode 100644 materialx/libraries/pbrlib/genosl/mx_oren_nayar_diffuse_bsdf.inline delete mode 100644 materialx/libraries/pbrlib/genosl/mx_roughness_anisotropy.osl delete mode 100644 materialx/libraries/pbrlib/genosl/mx_roughness_dual.osl delete mode 100644 materialx/libraries/pbrlib/genosl/mx_sheen_bsdf.osl delete mode 100644 materialx/libraries/pbrlib/genosl/mx_subsurface_bsdf.osl delete mode 100644 materialx/libraries/pbrlib/genosl/mx_surface.osl delete mode 100644 materialx/libraries/pbrlib/genosl/mx_translucent_bsdf.inline delete mode 100644 materialx/libraries/pbrlib/genosl/mx_uniform_edf.inline delete mode 100644 materialx/libraries/pbrlib/genosl/pbrlib_genosl_impl.mtlx delete mode 100644 materialx/libraries/pbrlib/pbrlib_defs.mtlx delete mode 100644 materialx/libraries/pbrlib/pbrlib_ng.mtlx delete mode 100644 materialx/libraries/stdlib/genglsl/lib/mx_hsv.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/lib/mx_noise.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/lib/mx_sampling.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/lib/mx_transform_uv.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/lib/mx_transform_uv_vflip.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_aastep.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_absval.inline delete mode 100644 materialx/libraries/stdlib/genglsl/mx_acescg_to_linear_color3.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_acescg_to_linear_color4.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_acos.inline delete mode 100644 materialx/libraries/stdlib/genglsl/mx_add.inline delete mode 100644 materialx/libraries/stdlib/genglsl/mx_add_surfaceshader.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_asin.inline delete mode 100644 materialx/libraries/stdlib/genglsl/mx_atan2.inline delete mode 100644 materialx/libraries/stdlib/genglsl/mx_burn_color3.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_burn_color4.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_burn_float.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_ceil.inline delete mode 100644 materialx/libraries/stdlib/genglsl/mx_cellnoise2d_float.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_cellnoise3d_float.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_clamp.inline delete mode 100644 materialx/libraries/stdlib/genglsl/mx_constant.inline delete mode 100644 materialx/libraries/stdlib/genglsl/mx_cos.inline delete mode 100644 materialx/libraries/stdlib/genglsl/mx_crossproduct.inline delete mode 100644 materialx/libraries/stdlib/genglsl/mx_determinant.inline delete mode 100644 materialx/libraries/stdlib/genglsl/mx_difference.inline delete mode 100644 materialx/libraries/stdlib/genglsl/mx_disjointover_color4.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_divide.inline delete mode 100644 materialx/libraries/stdlib/genglsl/mx_dodge.inline delete mode 100644 materialx/libraries/stdlib/genglsl/mx_dodge_color3.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_dodge_color4.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_dodge_float.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_dot.inline delete mode 100644 materialx/libraries/stdlib/genglsl/mx_dotproduct.inline delete mode 100644 materialx/libraries/stdlib/genglsl/mx_exp.inline delete mode 100644 materialx/libraries/stdlib/genglsl/mx_floor.inline delete mode 100644 materialx/libraries/stdlib/genglsl/mx_fractal3d_fa_vector2.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_fractal3d_fa_vector3.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_fractal3d_fa_vector4.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_fractal3d_float.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_fractal3d_vector2.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_fractal3d_vector3.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_fractal3d_vector4.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_g22_ap1_to_lin_rec709_color3.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_g22_ap1_to_lin_rec709_color4.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_gamma18_to_linear_color3.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_gamma18_to_linear_color4.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_gamma22_to_linear_color3.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_gamma22_to_linear_color4.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_gamma24_to_linear_color3.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_gamma24_to_linear_color4.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_hsvtorgb_color3.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_hsvtorgb_color4.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_image_color3.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_image_color4.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_image_float.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_image_vector2.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_image_vector3.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_image_vector4.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_in_color4.inline delete mode 100644 materialx/libraries/stdlib/genglsl/mx_inside.inline delete mode 100644 materialx/libraries/stdlib/genglsl/mx_invert.inline delete mode 100644 materialx/libraries/stdlib/genglsl/mx_invertM.inline delete mode 100644 materialx/libraries/stdlib/genglsl/mx_ln.inline delete mode 100644 materialx/libraries/stdlib/genglsl/mx_luminance_color3.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_luminance_color4.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_magnitude.inline delete mode 100644 materialx/libraries/stdlib/genglsl/mx_mask_color4.inline delete mode 100644 materialx/libraries/stdlib/genglsl/mx_matte_color4.inline delete mode 100644 materialx/libraries/stdlib/genglsl/mx_max.inline delete mode 100644 materialx/libraries/stdlib/genglsl/mx_min.inline delete mode 100644 materialx/libraries/stdlib/genglsl/mx_minus.inline delete mode 100644 materialx/libraries/stdlib/genglsl/mx_mix.inline delete mode 100644 materialx/libraries/stdlib/genglsl/mx_mix_surfaceshader.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_modulo.inline delete mode 100644 materialx/libraries/stdlib/genglsl/mx_multiply.inline delete mode 100644 materialx/libraries/stdlib/genglsl/mx_multiply_surfaceshader_color3.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_multiply_surfaceshader_float.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_noise2d_fa_vector2.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_noise2d_fa_vector3.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_noise2d_fa_vector4.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_noise2d_float.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_noise2d_vector2.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_noise2d_vector3.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_noise2d_vector4.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_noise3d_fa_vector2.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_noise3d_fa_vector3.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_noise3d_fa_vector4.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_noise3d_float.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_noise3d_vector2.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_noise3d_vector3.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_noise3d_vector4.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_normalize.inline delete mode 100644 materialx/libraries/stdlib/genglsl/mx_normalmap.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_out_color2.inline delete mode 100644 materialx/libraries/stdlib/genglsl/mx_out_color4.inline delete mode 100644 materialx/libraries/stdlib/genglsl/mx_outside.inline delete mode 100644 materialx/libraries/stdlib/genglsl/mx_over_color2.inline delete mode 100644 materialx/libraries/stdlib/genglsl/mx_over_color4.inline delete mode 100644 materialx/libraries/stdlib/genglsl/mx_overlay.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_overlay_color3.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_overlay_color4.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_overlay_float.inline delete mode 100644 materialx/libraries/stdlib/genglsl/mx_plus.inline delete mode 100644 materialx/libraries/stdlib/genglsl/mx_power.inline delete mode 100644 materialx/libraries/stdlib/genglsl/mx_power_color3_float.inline delete mode 100644 materialx/libraries/stdlib/genglsl/mx_power_color4_float.inline delete mode 100644 materialx/libraries/stdlib/genglsl/mx_power_vector2_float.inline delete mode 100644 materialx/libraries/stdlib/genglsl/mx_power_vector3_float.inline delete mode 100644 materialx/libraries/stdlib/genglsl/mx_power_vector4_float.inline delete mode 100644 materialx/libraries/stdlib/genglsl/mx_premult_color4.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_ramplr_float.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_ramplr_vector2.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_ramplr_vector3.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_ramplr_vector4.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_ramptb_float.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_ramptb_vector2.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_ramptb_vector3.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_ramptb_vector4.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_remap.inline delete mode 100644 materialx/libraries/stdlib/genglsl/mx_rgbtohsv_color3.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_rgbtohsv_color4.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_rotate_vector2.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_rotate_vector3.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_screen.inline delete mode 100644 materialx/libraries/stdlib/genglsl/mx_sign.inline delete mode 100644 materialx/libraries/stdlib/genglsl/mx_sin.inline delete mode 100644 materialx/libraries/stdlib/genglsl/mx_smoothstep_float.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_smoothstep_vec2.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_smoothstep_vec2FA.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_smoothstep_vec3.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_smoothstep_vec3FA.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_smoothstep_vec4.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_smoothstep_vec4FA.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_splitlr_float.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_splitlr_vector2.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_splitlr_vector3.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_splitlr_vector4.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_splittb_float.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_splittb_vector2.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_splittb_vector3.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_splittb_vector4.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_sqrt.inline delete mode 100644 materialx/libraries/stdlib/genglsl/mx_srgb_texture_to_linear_color3.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_srgb_texture_to_linear_color4.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_subtract.inline delete mode 100644 materialx/libraries/stdlib/genglsl/mx_tan.inline delete mode 100644 materialx/libraries/stdlib/genglsl/mx_transformmatrix.inline delete mode 100644 materialx/libraries/stdlib/genglsl/mx_transformmatrix_vector2M3.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_transformmatrix_vector3M4.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/mx_transpose.inline delete mode 100644 materialx/libraries/stdlib/genglsl/mx_unpremult_color4.glsl delete mode 100644 materialx/libraries/stdlib/genglsl/stdlib_genglsl_cm_impl.mtlx delete mode 100644 materialx/libraries/stdlib/genglsl/stdlib_genglsl_impl.mtlx delete mode 100644 materialx/libraries/stdlib/genglsl/stdlib_genglsl_unit_impl.mtlx delete mode 100644 materialx/libraries/stdlib/genmdl/stdlib_genmdl_cm_impl.mtlx delete mode 100644 materialx/libraries/stdlib/genmdl/stdlib_genmdl_impl.mtlx delete mode 100644 materialx/libraries/stdlib/genmdl/stdlib_genmdl_unit_impl.mtlx delete mode 100644 materialx/libraries/stdlib/genosl/lib/mx_sampling.osl delete mode 100644 materialx/libraries/stdlib/genosl/lib/mx_transform_uv.osl delete mode 100644 materialx/libraries/stdlib/genosl/lib/mx_transform_uv_vflip.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_absval.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_acescg_to_linear_color3.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_acescg_to_linear_color4.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_acos.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_add.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_ambientocclusion_float.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_asin.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_atan2.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_bitangent_vector3.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_burn_color3.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_burn_color4.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_burn_float.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_ceil.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_cellnoise2d_float.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_cellnoise3d_float.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_clamp.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_constant.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_contrast.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_cos.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_crossproduct.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_determinant.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_difference.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_disjointover_color4.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_divide.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_dodge_color3.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_dodge_color4.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_dodge_float.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_dot.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_dotproduct.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_exp.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_floor.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_fractal3d_color3.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_fractal3d_color4.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_fractal3d_fa_color3.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_fractal3d_fa_color4.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_fractal3d_fa_vector2.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_fractal3d_fa_vector3.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_fractal3d_fa_vector4.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_fractal3d_float.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_fractal3d_vector2.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_fractal3d_vector3.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_fractal3d_vector4.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_frame_float.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_g22_ap1_to_lin_rec709_color3.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_g22_ap1_to_lin_rec709_color4.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_gamma18_to_linear_color3.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_gamma18_to_linear_color4.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_gamma22_to_linear_color3.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_gamma22_to_linear_color4.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_gamma24_to_linear_color3.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_gamma24_to_linear_color4.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_geomcolor_color3.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_geomcolor_color4.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_geomcolor_float.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_geompropvalue_boolean.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_geompropvalue_color3.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_geompropvalue_color4.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_geompropvalue_float.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_geompropvalue_integer.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_geompropvalue_string.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_geompropvalue_vector2.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_geompropvalue_vector3.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_geompropvalue_vector4.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_heighttonormal_vector3.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_hsvtorgb_color3.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_hsvtorgb_color4.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_image_color3.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_image_color4.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_image_float.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_image_vector2.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_image_vector3.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_image_vector4.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_in.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_inside.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_invert.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_invertM.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_ln.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_luminance_color3.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_luminance_color4.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_magnitude.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_mask.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_matte_color4.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_max.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_min.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_minus.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_mix.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_modulo.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_modulo_color3FA.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_modulo_vector3FA.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_multiply.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_noise2d_color3.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_noise2d_color4.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_noise2d_fa_color3.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_noise2d_fa_color4.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_noise2d_fa_vector2.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_noise2d_fa_vector3.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_noise2d_fa_vector4.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_noise2d_float.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_noise2d_vector2.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_noise2d_vector3.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_noise2d_vector4.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_noise3d_color3.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_noise3d_color4.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_noise3d_fa_color3.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_noise3d_fa_color4.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_noise3d_fa_vector2.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_noise3d_fa_vector3.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_noise3d_fa_vector4.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_noise3d_float.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_noise3d_vector2.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_noise3d_vector3.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_noise3d_vector4.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_normal_vector3.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_normalize.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_normalmap.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_out.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_outside.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_over.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_overlay.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_overlay_color3.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_overlay_color4.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_plus.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_position_vector3.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_power.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_premult_color4.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_ramplr.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_ramptb.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_remap.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_rgbtohsv_color3.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_rgbtohsv_color4.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_rotate_vector2.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_rotate_vector3.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_screen.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_sign.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_sin.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_smoothstep.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_splitlr.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_splittb.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_sqrt.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_srgb_texture_to_linear_color3.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_srgb_texture_to_linear_color4.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_subtract.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_tan.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_tangent_vector3.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_texcoord_vector2.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_texcoord_vector3.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_time_float.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_transformmatrix.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_transformmatrix_vector2M3.osl delete mode 100644 materialx/libraries/stdlib/genosl/mx_transformnormal.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_transformpoint.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_transformvector.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_transpose.inline delete mode 100644 materialx/libraries/stdlib/genosl/mx_unpremult_color4.osl delete mode 100644 materialx/libraries/stdlib/genosl/stdlib_genosl_cm_impl.mtlx delete mode 100644 materialx/libraries/stdlib/genosl/stdlib_genosl_impl.mtlx delete mode 100644 materialx/libraries/stdlib/genosl/stdlib_genosl_unit_impl.mtlx delete mode 100644 materialx/libraries/stdlib/osl/README.md delete mode 100644 materialx/libraries/stdlib/osl/color4.h delete mode 100644 materialx/libraries/stdlib/osl/matrix33.h delete mode 100644 materialx/libraries/stdlib/osl/mx_absval_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_absval_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_absval_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_absval_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_absval_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_absval_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_acos_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_acos_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_acos_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_acos_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_acos_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_acos_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_add_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_add_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_add_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_add_float_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_add_float_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_add_float_matrix33.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_add_float_matrix44.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_add_float_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_add_float_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_add_float_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_add_matrix33.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_add_matrix44.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_add_surfaceshader.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_add_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_add_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_add_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_ambientocclusion_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_asin_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_asin_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_asin_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_asin_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_asin_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_asin_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_atan2_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_atan2_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_atan2_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_atan2_float_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_atan2_float_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_atan2_float_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_atan2_float_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_atan2_float_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_atan2_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_atan2_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_atan2_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_bitangent_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_blur_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_blur_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_blur_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_blur_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_blur_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_blur_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_burn_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_burn_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_burn_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_ceil_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_ceil_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_ceil_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_ceil_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_ceil_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_ceil_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_cellnoise2d_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_cellnoise3d_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_clamp_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_clamp_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_clamp_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_clamp_float_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_clamp_float_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_clamp_float_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_clamp_float_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_clamp_float_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_clamp_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_clamp_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_clamp_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_combine2_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_combine3_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_combine3_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_combine4_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_combine4_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_combine_cf_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_combine_vf_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_combine_vv_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_compare_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_compare_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_compare_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_compare_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_compare_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_compare_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_constant_bool.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_constant_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_constant_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_constant_filename.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_constant_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_constant_int.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_constant_matrix33.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_constant_matrix44.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_constant_string.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_constant_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_constant_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_constant_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_cos_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_cos_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_cos_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_cos_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_cos_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_cos_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_crossproduct_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_determinant_matrix33.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_determinant_matrix44.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_disjointover_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_divide_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_divide_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_divide_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_divide_float_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_divide_float_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_divide_float_matrix33.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_divide_float_matrix44.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_divide_float_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_divide_float_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_divide_float_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_divide_matrix33.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_divide_matrix44.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_divide_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_divide_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_divide_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_dodge_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_dodge_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_dodge_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_dot_bool.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_dot_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_dot_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_dot_displacementshader.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_dot_filename.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_dot_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_dot_int.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_dot_lightshader.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_dot_matrix33.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_dot_matrix44.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_dot_string.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_dot_surfaceshader.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_dot_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_dot_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_dot_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_dot_volumeshader.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_dotproduct_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_dotproduct_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_dotproduct_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_exp_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_exp_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_exp_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_exp_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_exp_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_exp_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_exponent_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_exponent_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_exponent_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_exponent_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_extract_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_extract_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_extract_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_extract_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_extract_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_floor_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_floor_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_floor_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_floor_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_floor_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_floor_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_fractal3d_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_fractal3d_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_fractal3d_fa_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_fractal3d_fa_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_fractal3d_fa_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_fractal3d_fa_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_fractal3d_fa_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_fractal3d_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_fractal3d_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_fractal3d_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_fractal3d_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_frame_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_funcs.h delete mode 100644 materialx/libraries/stdlib/osl/mx_geomcolor_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_geomcolor_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_geomcolor_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_geompropvalue_bool.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_geompropvalue_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_geompropvalue_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_geompropvalue_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_geompropvalue_int.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_geompropvalue_string.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_geompropvalue_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_geompropvalue_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_geompropvalue_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_heighttonormal_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_hsvadjust_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_hsvadjust_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_hsvtorgb_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_hsvtorgb_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_hueshift_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_hueshift_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_image_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_image_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_image_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_image_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_image_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_image_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_in_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_inside_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_inside_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_inside_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_invert_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_invert_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_invert_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_invert_float_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_invert_float_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_invert_float_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_invert_float_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_invert_float_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_invert_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_invert_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_invert_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_ln_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_ln_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_ln_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_ln_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_ln_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_ln_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_luminance_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_luminance_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_magnitude_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_magnitude_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_magnitude_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_mask_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_matrix_invert_matrix33.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_matrix_invert_matrix44.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_matte_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_max_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_max_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_max_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_max_float_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_max_float_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_max_float_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_max_float_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_max_float_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_max_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_max_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_max_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_min_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_min_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_min_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_min_float_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_min_float_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_min_float_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_min_float_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_min_float_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_min_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_min_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_min_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_mix_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_mix_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_mix_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_mix_surfaceshader.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_mix_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_mix_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_mix_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_modulo_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_modulo_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_modulo_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_modulo_float_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_modulo_float_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_modulo_float_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_modulo_float_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_modulo_float_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_modulo_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_modulo_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_modulo_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_mult_surfaceshader_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_mult_surfaceshader_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_multiply_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_multiply_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_multiply_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_multiply_float_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_multiply_float_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_multiply_float_matrix33.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_multiply_float_matrix44.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_multiply_float_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_multiply_float_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_multiply_float_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_multiply_matrix33.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_multiply_matrix44.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_multiply_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_multiply_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_multiply_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_noise2d_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_noise2d_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_noise2d_fa_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_noise2d_fa_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_noise2d_fa_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_noise2d_fa_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_noise2d_fa_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_noise2d_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_noise2d_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_noise2d_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_noise2d_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_noise3d_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_noise3d_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_noise3d_fa_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_noise3d_fa_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_noise3d_fa_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_noise3d_fa_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_noise3d_fa_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_noise3d_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_noise3d_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_noise3d_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_noise3d_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_normal_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_normalize_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_normalize_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_normalize_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_out_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_outside_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_outside_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_outside_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_over_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_overlay_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_overlay_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_overlay_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_position_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_power_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_power_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_power_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_power_float_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_power_float_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_power_float_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_power_float_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_power_float_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_power_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_power_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_power_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_premult_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_premult_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_ramp4_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_ramp4_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_ramp4_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_ramp4_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_ramp4_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_ramp4_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_ramplr_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_ramplr_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_ramplr_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_ramplr_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_ramplr_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_ramplr_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_ramptb_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_ramptb_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_ramptb_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_ramptb_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_ramptb_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_ramptb_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_remap_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_remap_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_remap_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_remap_float_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_remap_float_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_remap_float_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_remap_float_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_remap_float_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_remap_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_remap_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_remap_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_rgbtohsv_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_rgbtohsv_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_rotate2d_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_rotate_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_rotate_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_scale_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_scale_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_screen_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_screen_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_screen_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_separate_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_separate_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_separate_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_separate_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_separate_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_sign_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_sign_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_sign_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_sign_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_sign_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_sign_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_sin_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_sin_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_sin_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_sin_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_sin_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_sin_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_smoothstep_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_smoothstep_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_smoothstep_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_smoothstep_float_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_smoothstep_float_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_smoothstep_float_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_smoothstep_float_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_smoothstep_float_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_smoothstep_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_smoothstep_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_smoothstep_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_splitlr_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_splitlr_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_splitlr_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_splitlr_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_splitlr_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_splitlr_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_splittb_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_splittb_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_splittb_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_splittb_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_splittb_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_splittb_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_sqrt_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_sqrt_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_sqrt_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_sqrt_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_sqrt_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_sqrt_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_subtract_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_subtract_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_subtract_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_subtract_float_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_subtract_float_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_subtract_float_matrix33.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_subtract_float_matrix44.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_subtract_float_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_subtract_float_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_subtract_float_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_subtract_matrix33.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_subtract_matrix44.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_subtract_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_subtract_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_subtract_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_switch_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_switch_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_switch_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_switch_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_switch_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_switch_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_color4_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_color4_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_color4_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_color4_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_color4_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_color4_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_color_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_color_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_color_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_color_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_color_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_color_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_float_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_float_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_float_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_float_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_float_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_vector2_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_vector2_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_vector2_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_vector2_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_vector2_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_vector2_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_vector4_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_vector4_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_vector4_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_vector4_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_vector4_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_vector4_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_vector_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_vector_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_vector_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_vector_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_vector_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_swizzle_vector_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_tan_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_tan_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_tan_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_tan_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_tan_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_tan_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_tangent_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_texcoord_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_texcoord_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_tiledimage_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_tiledimage_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_tiledimage_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_tiledimage_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_tiledimage_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_tiledimage_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_time_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_transformnormal_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_transformnormal_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_transformpoint_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_transformpoint_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_transformvector_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_transformvector_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_transpose_matrix33.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_transpose_matrix44.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_triplanarprojection_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_triplanarprojection_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_triplanarprojection_float.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_triplanarprojection_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_triplanarprojection_vector2.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_triplanarprojection_vector4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_unpremult_color.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_unpremult_color4.osl delete mode 100644 materialx/libraries/stdlib/osl/mx_viewdirection_vector.osl delete mode 100644 materialx/libraries/stdlib/osl/oslutil.h delete mode 100644 materialx/libraries/stdlib/osl/stdlib_osl_impl.mtlx delete mode 100644 materialx/libraries/stdlib/osl/stdosl.h delete mode 100644 materialx/libraries/stdlib/osl/vector2.h delete mode 100644 materialx/libraries/stdlib/osl/vector4.h delete mode 100644 materialx/libraries/stdlib/stdlib_defs.mtlx delete mode 100644 materialx/libraries/stdlib/stdlib_ng.mtlx delete mode 100644 materialx/libraries/targets/genglsl.mtlx delete mode 100644 materialx/libraries/targets/genmdl.mtlx delete mode 100644 materialx/libraries/targets/genosl.mtlx diff --git a/materialx/libraries/README.md b/materialx/libraries/README.md deleted file mode 100644 index d2e2b9369..000000000 --- a/materialx/libraries/README.md +++ /dev/null @@ -1,70 +0,0 @@ -# MaterialX Data Libraries - -The following is the layout of the definitions and implementations provided as part of the core libraries. - -These libraries can be used to build shading networks which can be accepted by code generators to produce shader code. - -The following core "targets": GLSL, MDL and OSL. - -## Standard Library -- [stdlib](stdlib) - - [stdlib_defs.mtlx](stdlib/stdlib_defs.mtlx) : Single node nodedef definitions file. - - [stdlib_ng.mtlx](stdlib/stdlib_ng.mtlx) : Node graph definitions file. - - [genglsl](stdlib/genglsl): GLSL language support. - - lib : Shader utility files. - - [stdlib_genglsl_impl.mtlx](stdlib/genglsl/stdlib_genglsl_impl.mtlx) : Mapping from definitions to implementations - - [stdlib_genglsl_cm_impl.mtlx](stdlib/genglsl/stdlib_genglsl_cm_impl.mtlx) : Minimal set of "default" color management implementations. - - [stdlib_genglsl_unit_impl.mtlx](stdlib/genosl/stdlib_genglsl_unit_impl.mtlx) : Real world unit support implementations. - - GLSL implementation files. - - [genosl](stdlib/genosl): OSL language support. - - lib: Shader utility files. - - [stdlib_genosl_impl.mtlx](stdlib/genosl/stdlib_genosl_impl.mtlx) : Mapping from definitions to implementations - - [stdlib_genosl_cm_impl.mtlx](stdlib/genosl/stdlib_genosl_cm_impl.mtlx) : Minimal set of "default" color management implementations. - - [stdlib_genosl_unit_impl.mtlx](stdlib/genosl/stdlib_genosl_unit_impl.mtlx) : Real world unit support implementations. - - OSL implementation files. - - [osl](stdlib/osl): OSL reference implementation - - OSL implementation files. - - [genmdl](stdlib/genmdl): MDL language support. - - [stdlib_genmdl_impl.mtlx](stdlib/genosl/stdlib_genmdl_impl.mtlx) : Mapping from definitions to implementations - - [stdlib_genmdl_cm_impl.mtlx](stdlib/genosl/stdlib_genmdl_cm_impl.mtlx) : Minimal set of "default" color management implementations. - - [stdlib_genmdl_unit_impl.mtlx](stdlib/genosl/stdlib_genmdl_unit_impl.mtlx) : Real world unit support implementations. - -## Physically-Based Shading Library -- [pbrlib](pbrlib) - - [pbrlib_defs.mtlx](pbrlib/pbrlib_defs.mtlx) : Single node definitions file. - - [pbrlib_ng.mtlx](pbrlib/pbrlib_ng.mtlx) : Node graph definitions file. - - [genglsl](pbrlib/genglsl) : GLSL language support - - lib : Shader utility files. - - [pbrlib_genglsl_impl.mtlx](pbrlib/genglsl/pbrlib_genglsl_impl.mtlx) : Mapping from definitions to implementations - - GLSL implementation files. - - [genosl](pbrlib/genosl) : OSL language support - - lib : Utilities - - [pbrlib_genosl_impl.mtlx](pbrlib/genosl/pbrlib_genosl_impl.mtlx) : Mapping from definitions to implementations - - OSL implementation files. - - [genmdl](pbrlib/genmdl) : MDL language support - - [pbrlib_genmdl_impl.mtlx](pbrlib/genosl/pbrlib_genmdl_impl.mtlx) : Mapping from definitions to implementations. - - Note: MDL implementation files are in a "package" folder found under - [source/MaterialXGenMdl/mdl/materialx](../source/MaterialXGenMdl/mdl/materialx) - -## Target Definitions -- Each target implementation requires a target definition for definition / implementation correspondence to work. -- [targets](targets) is the folder holding documents which declare these definitions. -- There are definition files for the following core targets: - - OSL : `genosl` - - Desktop GLSL : `genglsl` - - MDL : `genmdl` -- Any additional target files should be added under this folder and loaded in as required. - -### Target Support -- GLSL target support is for version 4.0 or higher. -- OSL target support is for version 1.9.10 or higher. -- MDL target support is for version 1.6. -- "Default" color management support includes OSL, GLSL, and MDL implementations for the following non-LUT transforms: - - lin_rec709, gamma18, gamma22, gamma24, acescg, g22_acescg, srgb_texture -- Basic GLSL `lightshader` node definitions and implementations are provided for the following light types: - - point, directional, spot -- Code generation does not currently support: - - `ambientocclusion` node. - - `arrayappend` node. - - `curveadjust` node. - - `displacementshader` and `volumeshader` nodes and associated operations (`add`, `multiply`, `mix`) for GLSL targets. diff --git a/materialx/libraries/bxdf/disney_brdf_2012.mtlx b/materialx/libraries/bxdf/disney_brdf_2012.mtlx deleted file mode 100644 index f6a66bb7a..000000000 --- a/materialx/libraries/bxdf/disney_brdf_2012.mtlx +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/materialx/libraries/bxdf/disney_brdf_2015.mtlx b/materialx/libraries/bxdf/disney_brdf_2015.mtlx deleted file mode 100644 index afc3c4311..000000000 --- a/materialx/libraries/bxdf/disney_brdf_2015.mtlx +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/materialx/libraries/bxdf/standard_surface.mtlx b/materialx/libraries/bxdf/standard_surface.mtlx deleted file mode 100644 index 68b5fe3fd..000000000 --- a/materialx/libraries/bxdf/standard_surface.mtlx +++ /dev/null @@ -1,327 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/materialx/libraries/bxdf/usd_preview_surface.mtlx b/materialx/libraries/bxdf/usd_preview_surface.mtlx deleted file mode 100644 index 04ce67ba5..000000000 --- a/materialx/libraries/bxdf/usd_preview_surface.mtlx +++ /dev/null @@ -1,335 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/materialx/libraries/lights/genglsl/lights_genglsl_impl.mtlx b/materialx/libraries/lights/genglsl/lights_genglsl_impl.mtlx deleted file mode 100644 index cde8de51e..000000000 --- a/materialx/libraries/lights/genglsl/lights_genglsl_impl.mtlx +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/materialx/libraries/lights/genglsl/mx_directional_light.glsl b/materialx/libraries/lights/genglsl/mx_directional_light.glsl deleted file mode 100644 index 634c5fe99..000000000 --- a/materialx/libraries/lights/genglsl/mx_directional_light.glsl +++ /dev/null @@ -1,5 +0,0 @@ -void mx_directional_light(LightData light, vec3 position, out lightshader result) -{ - result.direction = -light.direction; - result.intensity = light.color * light.intensity; -} diff --git a/materialx/libraries/lights/genglsl/mx_point_light.glsl b/materialx/libraries/lights/genglsl/mx_point_light.glsl deleted file mode 100644 index c94b2225a..000000000 --- a/materialx/libraries/lights/genglsl/mx_point_light.glsl +++ /dev/null @@ -1,8 +0,0 @@ -void mx_point_light(LightData light, vec3 position, out lightshader result) -{ - result.direction = light.position - position; - float distance = length(result.direction) + M_FLOAT_EPS; - float attenuation = pow(distance + 1.0, light.decay_rate + M_FLOAT_EPS); - result.intensity = light.color * light.intensity / attenuation; - result.direction /= distance; -} diff --git a/materialx/libraries/lights/genglsl/mx_spot_light.glsl b/materialx/libraries/lights/genglsl/mx_spot_light.glsl deleted file mode 100644 index b3607844c..000000000 --- a/materialx/libraries/lights/genglsl/mx_spot_light.glsl +++ /dev/null @@ -1,13 +0,0 @@ -void mx_spot_light(LightData light, vec3 position, out lightshader result) -{ - result.direction = light.position - position; - float distance = length(result.direction) + M_FLOAT_EPS; - float attenuation = pow(distance + 1.0, light.decay_rate + M_FLOAT_EPS); - result.intensity = light.color * light.intensity / attenuation; - result.direction /= distance; - float low = min(light.inner_angle, light.outer_angle); - float high = light.inner_angle; - float cosDir = dot(result.direction, -light.direction); - float spotAttenuation = smoothstep(low, high, cosDir); - result.intensity *= spotAttenuation; -} diff --git a/materialx/libraries/lights/lights_defs.mtlx b/materialx/libraries/lights/lights_defs.mtlx deleted file mode 100644 index f212a187e..000000000 --- a/materialx/libraries/lights/lights_defs.mtlx +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/materialx/libraries/pbrlib/genglsl/lib/mx_defines.glsl b/materialx/libraries/pbrlib/genglsl/lib/mx_defines.glsl deleted file mode 100644 index 7abee973e..000000000 --- a/materialx/libraries/pbrlib/genglsl/lib/mx_defines.glsl +++ /dev/null @@ -1,4 +0,0 @@ -#define M_PI 3.1415926535897932384626433832795 -#define M_PI_INV 1.0/3.1415926535897932384626433832795 -#define M_GOLDEN_RATIO 1.6180339887498948482045868343656 -#define M_FLOAT_EPS 1e-8 diff --git a/materialx/libraries/pbrlib/genglsl/lib/mx_environment_fis.glsl b/materialx/libraries/pbrlib/genglsl/lib/mx_environment_fis.glsl deleted file mode 100644 index 4f2ed7c62..000000000 --- a/materialx/libraries/pbrlib/genglsl/lib/mx_environment_fis.glsl +++ /dev/null @@ -1,72 +0,0 @@ -#include "pbrlib/genglsl/lib/mx_microfacet_specular.glsl" - -int numRadianceSamples() -{ - return min($envRadianceSamples, MAX_ENV_RADIANCE_SAMPLES); -} - -// https://developer.nvidia.com/gpugems/GPUGems3/gpugems3_ch20.html -// Section 20.4 Equation 13 -float mx_latlong_compute_lod(vec3 dir, float pdf, float maxMipLevel, int envSamples) -{ - const float MIP_LEVEL_OFFSET = 1.5; - float effectiveMaxMipLevel = maxMipLevel - MIP_LEVEL_OFFSET; - float distortion = sqrt(1.0 - mx_square(dir.y)); - return max(effectiveMaxMipLevel - 0.5 * log2(envSamples * pdf * distortion), 0.0); -} - -vec3 mx_environment_radiance(vec3 N, vec3 V, vec3 X, vec2 roughness, int distribution, FresnelData fd) -{ - vec3 Y = normalize(cross(N, X)); - X = cross(Y, N); - - // Compute shared dot products. - float NdotV = clamp(dot(N, V), M_FLOAT_EPS, 1.0); - - // Integrate outgoing radiance using filtered importance sampling. - // http://cgg.mff.cuni.cz/~jaroslav/papers/2008-egsr-fis/2008-egsr-fis-final-embedded.pdf - vec3 radiance = vec3(0.0); - int envRadianceSamples = numRadianceSamples(); - for (int i = 0; i < envRadianceSamples; i++) - { - vec2 Xi = mx_spherical_fibonacci(i, envRadianceSamples); - - // Compute the half vector and incoming light direction. - vec3 H = mx_ggx_importance_sample_NDF(Xi, X, Y, N, roughness.x, roughness.y); - vec3 L = -reflect(V, H); - - // Compute dot products for this sample. - float NdotH = clamp(dot(N, H), M_FLOAT_EPS, 1.0); - float NdotL = clamp(dot(N, L), M_FLOAT_EPS, 1.0); - float VdotH = clamp(dot(V, H), M_FLOAT_EPS, 1.0); - float LdotH = VdotH; - - // Sample the environment light from the given direction. - float pdf = mx_ggx_PDF(X, Y, H, NdotH, LdotH, roughness.x, roughness.y); - float lod = mx_latlong_compute_lod(L, pdf, $envRadianceMips - 1, envRadianceSamples); - vec3 sampleColor = mx_latlong_map_lookup(L, $envMatrix, lod, $envRadiance); - - // Compute the Fresnel term. - vec3 F = mx_compute_fresnel(VdotH, fd); - - // Compute the geometric term. - float G = mx_ggx_smith_G(NdotL, NdotV, mx_average_roughness(roughness)); - - // Add the radiance contribution of this sample. - // From https://cdn2.unrealengine.com/Resources/files/2013SiggraphPresentationsNotes-26915738.pdf - // incidentLight = sampleColor * NdotL - // microfacetSpecular = D * F * G / (4 * NdotL * NdotV) - // pdf = D * NdotH / (4 * VdotH) - // radiance = incidentLight * microfacetSpecular / pdf - radiance += sampleColor * F * G * VdotH / (NdotV * NdotH); - } - - // Normalize and return the final radiance. - radiance /= float(envRadianceSamples); - return radiance; -} - -vec3 mx_environment_irradiance(vec3 N) -{ - return mx_latlong_map_lookup(N, $envMatrix, 0.0, $envIrradiance); -} diff --git a/materialx/libraries/pbrlib/genglsl/lib/mx_environment_none.glsl b/materialx/libraries/pbrlib/genglsl/lib/mx_environment_none.glsl deleted file mode 100644 index 9e6ff48fe..000000000 --- a/materialx/libraries/pbrlib/genglsl/lib/mx_environment_none.glsl +++ /dev/null @@ -1,11 +0,0 @@ -#include "pbrlib/genglsl/lib/mx_microfacet_specular.glsl" - -vec3 mx_environment_radiance(vec3 N, vec3 V, vec3 X, vec2 roughness, int distribution, FresnelData fd) -{ - return vec3(0.0); -} - -vec3 mx_environment_irradiance(vec3 N) -{ - return vec3(0.0); -} diff --git a/materialx/libraries/pbrlib/genglsl/lib/mx_environment_prefilter.glsl b/materialx/libraries/pbrlib/genglsl/lib/mx_environment_prefilter.glsl deleted file mode 100644 index ff226d3f5..000000000 --- a/materialx/libraries/pbrlib/genglsl/lib/mx_environment_prefilter.glsl +++ /dev/null @@ -1,29 +0,0 @@ -#include "pbrlib/genglsl/lib/mx_microfacet_specular.glsl" - -float mx_latlong_compute_lod(float roughness) -{ - // Select a mip level based on input roughness. - float lodBias = roughness < 0.25 ? sqrt(roughness) : 0.5*roughness + 0.375; - return lodBias * $envRadianceMips; -} - -vec3 mx_environment_radiance(vec3 N, vec3 V, vec3 X, vec2 roughness, int distribution, FresnelData fd) -{ - N = mx_forward_facing_normal(N, V); - vec3 L = reflect(-V, N); - - float NdotV = clamp(dot(N, V), M_FLOAT_EPS, 1.0); - - float avgRoughness = mx_average_roughness(roughness); - vec3 F = mx_compute_fresnel(NdotV, fd); - float G = mx_ggx_smith_G(NdotV, NdotV, avgRoughness); - vec3 comp = mx_ggx_energy_compensation(NdotV, avgRoughness, F); - vec3 Li = mx_latlong_map_lookup(L, $envMatrix, mx_latlong_compute_lod(avgRoughness), $envRadiance); - - return Li * F * G * comp; -} - -vec3 mx_environment_irradiance(vec3 N) -{ - return mx_latlong_map_lookup(N, $envMatrix, 0.0, $envIrradiance); -} diff --git a/materialx/libraries/pbrlib/genglsl/lib/mx_math.glsl b/materialx/libraries/pbrlib/genglsl/lib/mx_math.glsl deleted file mode 100644 index 8460e665a..000000000 --- a/materialx/libraries/pbrlib/genglsl/lib/mx_math.glsl +++ /dev/null @@ -1,83 +0,0 @@ -float mx_square(float x) -{ - return x*x; -} - -vec2 mx_square(vec2 x) -{ - return x*x; -} - -vec3 mx_square(vec3 x) -{ - return x*x; -} - -vec4 mx_square(vec4 x) -{ - return x*x; -} - -float mx_pow5(float x) -{ - return mx_square(mx_square(x)) * x; -} - -float mx_max_component(vec2 v) -{ - return max(v.x, v.y); -} - -float mx_max_component(vec3 v) -{ - return max(max(v.x, v.y), v.z); -} - -float mx_max_component(vec4 v) -{ - return max(max(max(v.x, v.y), v.z), v.w); -} - -bool mx_is_tiny(float v) -{ - return abs(v) < M_FLOAT_EPS; -} - -bool mx_is_tiny(vec3 v) -{ - return all(lessThan(abs(v), vec3(M_FLOAT_EPS))); -} - -float mx_mix(float v00, float v01, float v10, float v11, - float x, float y) -{ - float v0_ = mix(v00, v01, x); - float v1_ = mix(v10, v11, x); - return mix(v0_, v1_, y); -} - -vec2 mx_latlong_projection(vec3 dir) -{ - float latitude = -asin(dir.y) * M_PI_INV + 0.5; - float longitude = atan(dir.x, -dir.z) * M_PI_INV * 0.5 + 0.5; - return vec2(longitude, latitude); -} - -vec3 mx_latlong_map_lookup(vec3 dir, mat4 transform, float lod, sampler2D sampler) -{ - vec3 envDir = normalize((transform * vec4(dir,0.0)).xyz); - vec2 uv = mx_latlong_projection(envDir); - return textureLod(sampler, uv, lod).rgb; -} - -vec3 mx_forward_facing_normal(vec3 N, vec3 V) -{ - if (dot(N, V) < 0.0) - { - return -N; - } - else - { - return N; - } -} diff --git a/materialx/libraries/pbrlib/genglsl/lib/mx_microfacet.glsl b/materialx/libraries/pbrlib/genglsl/lib/mx_microfacet.glsl deleted file mode 100644 index 0d5f3c731..000000000 --- a/materialx/libraries/pbrlib/genglsl/lib/mx_microfacet.glsl +++ /dev/null @@ -1,57 +0,0 @@ -// Standard Schlick Fresnel -float mx_fresnel_schlick(float cosTheta, float F0) -{ - float x = clamp(1.0 - cosTheta, 0.0, 1.0); - float x5 = mx_pow5(x); - return F0 + (1.0 - F0) * x5; -} -vec3 mx_fresnel_schlick(float cosTheta, vec3 F0) -{ - float x = clamp(1.0 - cosTheta, 0.0, 1.0); - float x5 = mx_pow5(x); - return F0 + (1.0 - F0) * x5; -} - -// Generalized Schlick Fresnel -float mx_fresnel_schlick(float cosTheta, float F0, float F90) -{ - float x = clamp(1.0 - cosTheta, 0.0, 1.0); - float x5 = mx_pow5(x); - return mix(F0, F90, x5); -} -vec3 mx_fresnel_schlick(float cosTheta, vec3 F0, vec3 F90) -{ - float x = clamp(1.0 - cosTheta, 0.0, 1.0); - float x5 = mx_pow5(x); - return mix(F0, F90, x5); -} - -// Generalized Schlick Fresnel with a variable exponent -float mx_fresnel_schlick(float cosTheta, float F0, float F90, float exponent) -{ - float x = clamp(1.0 - cosTheta, 0.0, 1.0); - return mix(F0, F90, pow(x, exponent)); -} -vec3 mx_fresnel_schlick(float cosTheta, vec3 F0, vec3 F90, float exponent) -{ - float x = clamp(1.0 - cosTheta, 0.0, 1.0); - return mix(F0, F90, pow(x, exponent)); -} - -// Compute the average of an anisotropic roughness pair -float mx_average_roughness(vec2 roughness) -{ - return sqrt(roughness.x * roughness.y); -} - -// https://www.graphics.rwth-aachen.de/publication/2/jgt.pdf -float mx_golden_ratio_sequence(int i) -{ - return fract((float(i) + 1.0) * M_GOLDEN_RATIO); -} - -// https://people.irisa.fr/Ricardo.Marques/articles/2013/SF_CGF.pdf -vec2 mx_spherical_fibonacci(int i, int numSamples) -{ - return vec2((float(i) + 0.5) / float(numSamples), mx_golden_ratio_sequence(i)); -} diff --git a/materialx/libraries/pbrlib/genglsl/lib/mx_microfacet_diffuse.glsl b/materialx/libraries/pbrlib/genglsl/lib/mx_microfacet_diffuse.glsl deleted file mode 100644 index 985486cd7..000000000 --- a/materialx/libraries/pbrlib/genglsl/lib/mx_microfacet_diffuse.glsl +++ /dev/null @@ -1,84 +0,0 @@ -#include "pbrlib/genglsl/lib/mx_microfacet.glsl" - -// Based on the OSL implementation of Oren-Nayar diffuse, which is in turn -// based on https://mimosa-pudica.net/improved-oren-nayar.html. -float mx_oren_nayar_diffuse(vec3 L, vec3 V, vec3 N, float NdotL, float roughness) -{ - float LdotV = clamp(dot(L, V), M_FLOAT_EPS, 1.0); - float NdotV = clamp(dot(N, V), M_FLOAT_EPS, 1.0); - float s = LdotV - NdotL * NdotV; - float stinv = (s > 0.0f) ? s / max(NdotL, NdotV) : 0.0; - - float sigma2 = mx_square(roughness * M_PI); - float A = 1.0 - 0.5 * (sigma2 / (sigma2 + 0.33)); - float B = 0.45 * sigma2 / (sigma2 + 0.09); - - return A + B * stinv; -} - -// https://disney-animation.s3.amazonaws.com/library/s2012_pbs_disney_brdf_notes_v2.pdf -// Section 5.3 -float mx_burley_diffuse(vec3 L, vec3 V, vec3 N, float NdotL, float roughness) -{ - vec3 H = normalize(L + V); - float LdotH = clamp(dot(L, H), M_FLOAT_EPS, 1.0); - float NdotV = clamp(dot(N, V), M_FLOAT_EPS, 1.0); - - float F90 = 0.5 + (2.0 * roughness * mx_square(LdotH)); - float refL = mx_fresnel_schlick(NdotL, 1.0, F90); - float refV = mx_fresnel_schlick(NdotV, 1.0, F90); - return refL * refV; -} - -// Compute the directional albedo component of Burley diffuse for the given -// view angle and roughness. Curve fit provided by Stephen Hill. -float mx_burley_diffuse_directional_albedo(float NdotV, float roughness) -{ - float x = NdotV; - float fit0 = 0.97619 - 0.488095 * mx_pow5(1 - x); - float fit1 = 1.55754 + (-2.02221 + (2.56283 - 1.06244 * x) * x) * x; - return mix(fit0, fit1, roughness); -} - -// Evaluate the Burley diffusion profile for the given distance and diffusion shape. -// Based on https://graphics.pixar.com/library/ApproxBSSRDF/ -vec3 mx_burley_diffusion_profile(float dist, vec3 shape) -{ - vec3 num1 = exp(-shape * dist); - vec3 num2 = exp(-shape * dist / 3.0); - float denom = max(dist, M_FLOAT_EPS); - return (num1 + num2) / denom; -} - -// Integrate the Burley diffusion profile over a sphere of the given radius. -// Inspired by Eric Penner's presentation in http://advances.realtimerendering.com/s2011/ -vec3 mx_integrate_burley_diffusion(vec3 N, vec3 L, float radius, vec3 mfp) -{ - float theta = acos(dot(N, L)); - - // Estimate the Burley diffusion shape from mean free path. - vec3 shape = vec3(1.0) / max(mfp, 0.1); - - // Integrate the profile over the sphere. - vec3 sumD = vec3(0.0); - vec3 sumR = vec3(0.0); - const int SAMPLE_COUNT = 32; - const float SAMPLE_WIDTH = (2.0 * M_PI) / SAMPLE_COUNT; - for (int i = 0; i < SAMPLE_COUNT; i++) - { - float x = -M_PI + (i + 0.5) * SAMPLE_WIDTH; - float dist = radius * abs(2.0 * sin(x * 0.5)); - vec3 R = mx_burley_diffusion_profile(dist, shape); - sumD += R * max(cos(theta + x), 0.0); - sumR += R; - } - - return sumD / sumR; -} - -vec3 mx_subsurface_scattering_approx(vec3 N, vec3 L, vec3 P, vec3 albedo, vec3 mfp) -{ - float curvature = length(fwidth(N)) / length(fwidth(P)); - float radius = 1.0 / max(curvature, 0.01); - return albedo * mx_integrate_burley_diffusion(N, L, radius, mfp) / vec3(M_PI); -} diff --git a/materialx/libraries/pbrlib/genglsl/lib/mx_microfacet_sheen.glsl b/materialx/libraries/pbrlib/genglsl/lib/mx_microfacet_sheen.glsl deleted file mode 100644 index c88bb16e4..000000000 --- a/materialx/libraries/pbrlib/genglsl/lib/mx_microfacet_sheen.glsl +++ /dev/null @@ -1,52 +0,0 @@ -#include "pbrlib/genglsl/lib/mx_microfacet.glsl" - -// http://www.aconty.com/pdf/s2017_pbs_imageworks_sheen.pdf -// Equation 2 -float mx_imageworks_sheen_NDF(float cosTheta, float roughness) -{ - float invRoughness = 1.0 / max(roughness, 0.0001); - float cos2 = cosTheta * cosTheta; - float sin2 = 1.0 - cos2; - return (2.0 + invRoughness) * pow(sin2, invRoughness * 0.5) / (2.0 * M_PI); -} - -// LUT for sheen directional albedo. -// A 2D table parameterized with 'cosTheta' (cosine of angle to normal) on x-axis and 'roughness' on y-axis. -#define SHEEN_ALBEDO_TABLE_SIZE 16 -const float u_sheenAlbedo[SHEEN_ALBEDO_TABLE_SIZE*SHEEN_ALBEDO_TABLE_SIZE] = float[]( - 1.6177, 0.978927, 0.618938, 0.391714, 0.245177, 0.150234, 0.0893475, 0.0511377, 0.0280191, 0.0144204, 0.00687674, 0.00295935, 0.00111049, 0.000336768, 7.07119e-05, 6.22646e-06, - 1.1084, 0.813928, 0.621389, 0.479304, 0.370299, 0.284835, 0.21724, 0.163558, 0.121254, 0.0878921, 0.0619052, 0.0419894, 0.0270556, 0.0161443, 0.00848212, 0.00342323, - 0.930468, 0.725652, 0.586532, 0.479542, 0.393596, 0.322736, 0.26353, 0.213565, 0.171456, 0.135718, 0.105481, 0.0800472, 0.0588117, 0.0412172, 0.0268329, 0.0152799, - 0.833791, 0.671201, 0.558957, 0.471006, 0.398823, 0.337883, 0.285615, 0.240206, 0.200696, 0.16597, 0.135422, 0.10859, 0.0850611, 0.0644477, 0.0464763, 0.0308878, - 0.771692, 0.633819, 0.537877, 0.461939, 0.398865, 0.344892, 0.297895, 0.256371, 0.219562, 0.186548, 0.156842, 0.130095, 0.10598, 0.0841919, 0.0645311, 0.04679, - 0.727979, 0.606373, 0.52141, 0.453769, 0.397174, 0.348337, 0.305403, 0.267056, 0.232655, 0.201398, 0.17286, 0.146756, 0.122808, 0.100751, 0.0804254, 0.0616485, - 0.695353, 0.585281, 0.508227, 0.44667, 0.394925, 0.350027, 0.310302, 0.274561, 0.242236, 0.212604, 0.185281, 0.16002, 0.13657, 0.114693, 0.0942543, 0.0750799, - 0.669981, 0.568519, 0.497442, 0.440542, 0.392567, 0.350786, 0.313656, 0.280075, 0.249533, 0.221359, 0.195196, 0.170824, 0.148012, 0.126537, 0.106279, 0.0870713, - 0.649644, 0.554855, 0.488453, 0.435237, 0.390279, 0.351028, 0.316036, 0.284274, 0.255266, 0.228387, 0.203297, 0.179796, 0.157665, 0.136695, 0.116774, 0.0977403, - 0.632951, 0.543489, 0.480849, 0.430619, 0.388132, 0.350974, 0.317777, 0.287562, 0.259885, 0.234153, 0.210041, 0.187365, 0.165914, 0.145488, 0.125983, 0.10724, - 0.61899, 0.533877, 0.47433, 0.426573, 0.386145, 0.35075, 0.319078, 0.290197, 0.263681, 0.238971, 0.215746, 0.193838, 0.173043, 0.153167, 0.134113, 0.115722, - 0.607131, 0.52564, 0.468678, 0.423001, 0.38432, 0.35043, 0.320072, 0.292349, 0.266856, 0.243055, 0.220636, 0.199438, 0.179264, 0.159926, 0.141332, 0.123323, - 0.596927, 0.518497, 0.463731, 0.419829, 0.382647, 0.350056, 0.320842, 0.294137, 0.269549, 0.246564, 0.224875, 0.204331, 0.18474, 0.165919, 0.147778, 0.130162, - 0.588052, 0.512241, 0.459365, 0.416996, 0.381114, 0.349657, 0.321448, 0.295641, 0.271862, 0.24961, 0.228584, 0.208643, 0.189596, 0.171266, 0.153566, 0.136341, - 0.580257, 0.506717, 0.455481, 0.41445, 0.379708, 0.34925, 0.321929, 0.296923, 0.273869, 0.252279, 0.231859, 0.212472, 0.193933, 0.176066, 0.158788, 0.141945, - 0.573355, 0.5018, 0.452005, 0.412151, 0.378416, 0.348844, 0.322316, 0.298028, 0.275627, 0.254638, 0.234772, 0.215896, 0.197828, 0.180398, 0.163522, 0.147049 -); - -float mx_imageworks_sheen_directional_albedo(float cosTheta, float roughness) -{ - float x = cosTheta * (SHEEN_ALBEDO_TABLE_SIZE - 1); - float y = roughness * (SHEEN_ALBEDO_TABLE_SIZE - 1); - int ix = int(x); - int iy = int(y); - int ix2 = clamp(ix + 1, 0, SHEEN_ALBEDO_TABLE_SIZE - 1); - int iy2 = clamp(iy + 1, 0, SHEEN_ALBEDO_TABLE_SIZE - 1); - float fx = x - ix; - float fy = y - iy; - - // Bi-linear interpolation of the LUT values - float v1 = mix(u_sheenAlbedo[iy * SHEEN_ALBEDO_TABLE_SIZE + ix], u_sheenAlbedo[iy * SHEEN_ALBEDO_TABLE_SIZE + ix2], fx); - float v2 = mix(u_sheenAlbedo[iy2 * SHEEN_ALBEDO_TABLE_SIZE + ix], u_sheenAlbedo[iy2 * SHEEN_ALBEDO_TABLE_SIZE + ix2], fx); - float albedo = mix(v1, v2, fy); - - return clamp(albedo, 0.0, 1.0); -} diff --git a/materialx/libraries/pbrlib/genglsl/lib/mx_microfacet_specular.glsl b/materialx/libraries/pbrlib/genglsl/lib/mx_microfacet_specular.glsl deleted file mode 100644 index 5aad7d3de..000000000 --- a/materialx/libraries/pbrlib/genglsl/lib/mx_microfacet_specular.glsl +++ /dev/null @@ -1,386 +0,0 @@ -#include "pbrlib/genglsl/lib/mx_microfacet.glsl" - -// https://disney-animation.s3.amazonaws.com/library/s2012_pbs_disney_brdf_notes_v2.pdf -// Appendix B.2 Equation 13 -float mx_ggx_NDF(vec3 X, vec3 Y, vec3 H, float NdotH, float alphaX, float alphaY) -{ - float XdotH = dot(X, H); - float YdotH = dot(Y, H); - float denom = mx_square(XdotH / alphaX) + mx_square(YdotH / alphaY) + mx_square(NdotH); - return 1.0 / (M_PI * alphaX * alphaY * mx_square(denom)); -} - -// https://disney-animation.s3.amazonaws.com/library/s2012_pbs_disney_brdf_notes_v2.pdf -// Appendix B.1 Equation 3 -float mx_ggx_PDF(vec3 X, vec3 Y, vec3 H, float NdotH, float LdotH, float alphaX, float alphaY) -{ - return mx_ggx_NDF(X, Y, H, NdotH, alphaX, alphaY) * NdotH / (4.0 * LdotH); -} - -// https://disney-animation.s3.amazonaws.com/library/s2012_pbs_disney_brdf_notes_v2.pdf -// Appendix B.2 Equation 15 -vec3 mx_ggx_importance_sample_NDF(vec2 Xi, vec3 X, vec3 Y, vec3 N, float alphaX, float alphaY) -{ - float phi = 2.0 * M_PI * Xi.x; - float tanTheta = sqrt(Xi.y / (1.0 - Xi.y)); - vec3 H = X * (tanTheta * alphaX * cos(phi)) + - Y * (tanTheta * alphaY * sin(phi)) + - N; - return normalize(H); -} - -// http://jcgt.org/published/0003/02/03/paper.pdf -// Equations 72 and 99 -float mx_ggx_smith_G(float NdotL, float NdotV, float alpha) -{ - float alpha2 = mx_square(alpha); - float lambdaL = sqrt(alpha2 + (1.0 - alpha2) * mx_square(NdotL)); - float lambdaV = sqrt(alpha2 + (1.0 - alpha2) * mx_square(NdotV)); - return 2.0 / (lambdaL / NdotL + lambdaV / NdotV); -} - -// https://www.unrealengine.com/blog/physically-based-shading-on-mobile -vec3 mx_ggx_directional_albedo_curve_fit(float NdotV, float roughness, vec3 F0, vec3 F90) -{ - const vec4 c0 = vec4(-1, -0.0275, -0.572, 0.022); - const vec4 c1 = vec4( 1, 0.0425, 1.04, -0.04 ); - vec4 r = roughness * c0 + c1; - float a004 = min(r.x * r.x, exp2(-9.28 * NdotV)) * r.x + r.y; - vec2 AB = vec2(-1.04, 1.04) * a004 + r.zw; - return F0 * AB.x + F90 * AB.y; -} - -vec3 mx_ggx_directional_albedo_table_lookup(float NdotV, float roughness, vec3 F0, vec3 F90) -{ -#if DIRECTIONAL_ALBEDO_METHOD == 1 - vec2 res = textureSize($albedoTable, 0); - if (res.x > 1) - { - vec2 AB = texture($albedoTable, vec2(NdotV, roughness)).rg; - return F0 * AB.x + F90 * AB.y; - } -#endif - return vec3(0.0); -} - -// https://cdn2.unrealengine.com/Resources/files/2013SiggraphPresentationsNotes-26915738.pdf -vec3 mx_ggx_directional_albedo_importance_sample(float NdotV, float roughness, vec3 F0, vec3 F90) -{ - NdotV = clamp(NdotV, M_FLOAT_EPS, 1.0); - vec3 V = vec3(sqrt(1.0f - mx_square(NdotV)), 0, NdotV); - - vec2 AB = vec2(0.0); - const int SAMPLE_COUNT = 64; - for (int i = 0; i < SAMPLE_COUNT; i++) - { - vec2 Xi = mx_spherical_fibonacci(i, SAMPLE_COUNT); - - // Compute the half vector and incoming light direction. - vec3 H = mx_ggx_importance_sample_NDF(Xi, vec3(1, 0, 0), vec3(0, 1, 0), vec3(0, 0, 1), roughness, roughness); - vec3 L = -reflect(V, H); - - // Compute dot products for this sample. - float NdotL = clamp(L.z, M_FLOAT_EPS, 1.0); - float NdotH = clamp(H.z, M_FLOAT_EPS, 1.0); - float VdotH = clamp(dot(V, H), M_FLOAT_EPS, 1.0); - - // Compute the Fresnel term. - float Fc = mx_fresnel_schlick(VdotH, 0.0, 1.0); - - // Compute the geometric visibility term. - float Gvis = mx_ggx_smith_G(NdotL, NdotV, roughness) * VdotH / (NdotH * NdotV); - - // Add the contribution of this sample. - AB += vec2(Gvis * (1 - Fc), Gvis * Fc); - } - - // Normalize integrated terms. - AB /= SAMPLE_COUNT; - - // Return the final directional albedo. - return F0 * AB.x + F90 * AB.y; -} - -vec3 mx_ggx_directional_albedo(float NdotV, float roughness, vec3 F0, vec3 F90) -{ -#if DIRECTIONAL_ALBEDO_METHOD == 0 - return mx_ggx_directional_albedo_curve_fit(NdotV, roughness, F0, F90); -#elif DIRECTIONAL_ALBEDO_METHOD == 1 - return mx_ggx_directional_albedo_table_lookup(NdotV, roughness, F0, F90); -#else - return mx_ggx_directional_albedo_importance_sample(NdotV, roughness, F0, F90); -#endif -} - -float mx_ggx_directional_albedo(float NdotV, float roughness, float F0, float F90) -{ - return mx_ggx_directional_albedo(NdotV, roughness, vec3(F0), vec3(F90)).x; -} - -// https://blog.selfshadow.com/publications/turquin/ms_comp_final.pdf -// Equations 14 and 16 -vec3 mx_ggx_energy_compensation(float NdotV, float roughness, vec3 Fss) -{ - float Ess = mx_ggx_directional_albedo(NdotV, roughness, 1.0, 1.0); - return 1.0 + Fss * (1.0 - Ess) / Ess; -} - -float mx_ggx_energy_compensation(float NdotV, float roughness, float Fss) -{ - return mx_ggx_energy_compensation(NdotV, roughness, vec3(Fss)).x; -} - -// Convert a real-valued index of refraction to normal-incidence reflectivity. -float mx_ior_to_f0(float ior) -{ - return mx_square((ior - 1.0) / (ior + 1.0)); -} - -// https://seblagarde.wordpress.com/2013/04/29/memo-on-fresnel-equations/ -float mx_fresnel_dielectric(float cosTheta, float ior) -{ - if (cosTheta < 0.0) - return 1.0; - - float g = ior*ior + cosTheta*cosTheta - 1.0; - // Check for total internal reflection - if (g < 0.0) - return 1.0; - - g = sqrt(g); - float gmc = g - cosTheta; - float gpc = g + cosTheta; - float x = gmc / gpc; - float y = (gpc * cosTheta - 1.0) / (gmc * cosTheta + 1.0); - return 0.5 * x * x * (1.0 + y * y); -} - -vec3 mx_fresnel_conductor(float cosTheta, vec3 n, vec3 k) -{ - float c2 = cosTheta*cosTheta; - vec3 n2_k2 = n*n + k*k; - vec3 nc2 = 2.0 * n * cosTheta; - - vec3 rs_a = n2_k2 + c2; - vec3 rp_a = n2_k2 * c2 + 1.0; - vec3 rs = (rs_a - nc2) / (rs_a + nc2); - vec3 rp = (rp_a - nc2) / (rp_a + nc2); - - return 0.5 * (rs + rp); -} - -// Fresnel for dielectric/dielectric interface and polarized light. -void mx_fresnel_dielectric_polarized(float cosTheta, float n1, float n2, out vec2 F, out vec2 phi) -{ - float eta2 = mx_square(n1 / n2); - float st2 = 1.0 - cosTheta*cosTheta; - - // Check for total internal reflection - if(eta2*st2 > 1.0) - { - F = vec2(1.0); - float s = sqrt(st2 - 1.0/eta2) / cosTheta; - phi = 2.0 * atan(vec2(-eta2 * s, -s)); - return; - } - - float cosTheta_t = sqrt(1 - eta2 * st2); - vec2 r = vec2((n2*cosTheta - n1*cosTheta_t) / (n2*cosTheta + n1*cosTheta_t), - (n1*cosTheta - n2*cosTheta_t) / (n1*cosTheta + n2*cosTheta_t)); - F = mx_square(r); - phi.x = (r.x < 0.0) ? M_PI : 0.0; - phi.y = (r.y < 0.0) ? M_PI : 0.0; -} - -// Fresnel for dielectric/conductor interface and polarized light. -// TODO: Optimize this functions and support wavelength dependent complex refraction index. -void mx_fresnel_conductor_polarized(float cosTheta, float n1, float n2, float k, out vec2 F, out vec2 phi) -{ - if (k == 0) - { - // Use dielectric formula to avoid numerical issues - mx_fresnel_dielectric_polarized(cosTheta, n1, n2, F, phi); - return; - } - - float A = mx_square(n2) * (1.0 - mx_square(k)) - mx_square(n1) * (1.0 - mx_square(cosTheta)); - float B = sqrt(mx_square(A) + mx_square(2.0 * mx_square(n2) * k)); - float U = sqrt((A+B) / 2.0); - float V = sqrt((B-A) / 2.0); - - F.y = (mx_square(n1*cosTheta - U) + mx_square(V)) / (mx_square(n1*cosTheta + U) + mx_square(V)); - phi.y = atan(2.0*n1 * V*cosTheta, mx_square(U) + mx_square(V) - mx_square(n1*cosTheta)) + M_PI; - - F.x = (mx_square(mx_square(n2) * (1.0 - mx_square(k)) * cosTheta - n1*U) + mx_square(2.0 * mx_square(n2) * k * cosTheta - n1*V)) / - (mx_square(mx_square(n2) * (1.0 - mx_square(k)) * cosTheta + n1*U) + mx_square(2.0 * mx_square(n2) * k * cosTheta + n1*V)); - phi.x = atan(2.0 * n1 * mx_square(n2) * cosTheta * (2*k*U - (1.0 - mx_square(k)) * V), mx_square(mx_square(n2) * (1.0 + mx_square(k)) * cosTheta) - mx_square(n1) * (mx_square(U) + mx_square(V))); -} - -// XYZ to CIE 1931 RGB color space (using neutral E illuminant) -const mat3 XYZ_TO_RGB = mat3(2.3706743, -0.5138850, 0.0052982, -0.9000405, 1.4253036, -0.0146949, -0.4706338, 0.0885814, 1.0093968); - -// Depolarization functions for natural light -float mx_depolarize(vec2 v) -{ - return 0.5 * (v.x + v.y); -} -vec3 mx_depolarize(vec3 s, vec3 p) -{ - return 0.5 * (s + p); -} - -// Evaluation XYZ sensitivity curves in Fourier space -vec3 mx_eval_sensitivity(float opd, float shift) -{ - // Use Gaussian fits, given by 3 parameters: val, pos and var - float phase = 2*M_PI * opd; - vec3 val = vec3(5.4856e-13, 4.4201e-13, 5.2481e-13); - vec3 pos = vec3(1.6810e+06, 1.7953e+06, 2.2084e+06); - vec3 var = vec3(4.3278e+09, 9.3046e+09, 6.6121e+09); - vec3 xyz = val * sqrt(2*M_PI * var) * cos(pos * phase + shift) * exp(- var * phase*phase); - xyz.x += 9.7470e-14 * sqrt(2*M_PI * 4.5282e+09) * cos(2.2399e+06 * phase + shift) * exp(- 4.5282e+09 * phase*phase); - return xyz / 1.0685e-7; -} - -// A Practical Extension to Microfacet Theory for the Modeling of Varying Iridescence -// https://belcour.github.io/blog/research/2017/05/01/brdf-thin-film.html -vec3 mx_fresnel_airy(float cosTheta, vec3 ior, vec3 extinction, float tf_thickness, float tf_ior) -{ - // Convert nm -> m - float d = tf_thickness * 1.0e-9; - - // Assume vacuum on the outside - float eta1 = 1.0; - float eta2 = tf_ior; - - // Optical path difference - float cosTheta2 = sqrt(1.0 - mx_square(eta1/eta2) * (1.0 - mx_square(cosTheta))); - float D = 2.0 * eta2 * d * cosTheta2; - - // First interface - vec2 R12, phi12; - mx_fresnel_dielectric_polarized(cosTheta, eta1, eta2, R12, phi12); - vec2 R21 = R12; - vec2 T121 = vec2(1.0) - R12; - vec2 phi21 = vec2(M_PI) - phi12; - - // Second interface - vec2 R23, phi23; - mx_fresnel_conductor_polarized(cosTheta2, eta2, ior.x, extinction.x, R23, phi23); - - // Phase shift - vec2 phi2 = phi21 + phi23; - - // Compound terms - vec3 R = vec3(0.0); - vec2 R123 = R12*R23; - vec2 r123 = sqrt(R123); - vec2 Rs = mx_square(T121)*R23 / (1-R123); - - // Reflectance term for m=0 (DC term amplitude) - vec2 C0 = R12 + Rs; - vec3 S0 = mx_eval_sensitivity(0.0, 0.0); - R += mx_depolarize(C0) * S0; - - // Reflectance term for m>0 (pairs of diracs) - vec2 Cm = Rs - T121; - for (int m=1; m<=3; ++m) - { - Cm *= r123; - vec3 SmS = 2.0 * mx_eval_sensitivity(m*D, m*phi2.x); - vec3 SmP = 2.0 * mx_eval_sensitivity(m*D, m*phi2.y); - R += mx_depolarize(Cm.x*SmS, Cm.y*SmP); - } - - // Convert back to RGB reflectance - R = clamp(XYZ_TO_RGB * R, vec3(0.0), vec3(1.0)); - - return R; -} - -// Parameters for Fresnel calculations. -struct FresnelData -{ - vec3 ior; // In Schlick Fresnel mode these two - vec3 extinction; // hold F0 and F90 reflectance values - float exponent; - float tf_thickness; - float tf_ior; - int model; -}; - -FresnelData mx_init_fresnel_dielectric(float ior) -{ - FresnelData fd = FresnelData(vec3(0), vec3(0), 0, 0, 0, -1); - fd.model = 0; - fd.ior = vec3(ior); - fd.tf_thickness = 0.0f; - return fd; -} - -FresnelData mx_init_fresnel_conductor(vec3 ior, vec3 extinction) -{ - FresnelData fd = FresnelData(vec3(0), vec3(0), 0, 0, 0, -1); - fd.model = 1; - fd.ior = ior; - fd.extinction = extinction; - fd.tf_thickness = 0.0f; - return fd; -} - -FresnelData mx_init_fresnel_schlick(vec3 F0) -{ - FresnelData fd = FresnelData(vec3(0), vec3(0), 0, 0, 0, -1); - fd.model = 2; - fd.ior = F0; - fd.extinction = vec3(1.0); - fd.exponent = 5.0f; - fd.tf_thickness = 0.0f; - return fd; -} - -FresnelData mx_init_fresnel_schlick(vec3 F0, vec3 F90, float exponent) -{ - FresnelData fd = FresnelData(vec3(0), vec3(0), 0, 0, 0, -1); - fd.model = 2; - fd.ior = F0; - fd.extinction = F90; - fd.exponent = exponent; - fd.tf_thickness = 0.0f; - return fd; -} - -FresnelData mx_init_fresnel_dielectric_airy(float ior, float tf_thickness, float tf_ior) -{ - FresnelData fd = FresnelData(vec3(0), vec3(0), 0, 0, 0, -1); - fd.model = 3; - fd.ior = vec3(ior); - fd.extinction = vec3(0.0); - fd.tf_thickness = tf_thickness; - fd.tf_ior = tf_ior; - return fd; -} - -FresnelData mx_init_fresnel_conductor_airy(vec3 ior, vec3 extinction, float tf_thickness, float tf_ior) -{ - FresnelData fd = FresnelData(vec3(0), vec3(0), 0, 0, 0, -1); - fd.model = 3; - fd.ior = ior; - fd.extinction = extinction; - fd.tf_thickness = tf_thickness; - fd.tf_ior = tf_ior; - return fd; -} - -vec3 mx_compute_fresnel(float cosTheta, FresnelData fd) -{ - if (fd.model == 0) - return vec3(mx_fresnel_dielectric(cosTheta, fd.ior.x)); - else if (fd.model == 1) - return mx_fresnel_conductor(cosTheta, fd.ior, fd.extinction); - else if (fd.model == 2) - // ior & extinction holds F0 & F90 - return mx_fresnel_schlick(cosTheta, fd.ior, fd.extinction, fd.exponent); - else - return mx_fresnel_airy(cosTheta, fd.ior, fd.extinction, fd.tf_thickness, fd.tf_ior); -} diff --git a/materialx/libraries/pbrlib/genglsl/lib/mx_refraction_index.glsl b/materialx/libraries/pbrlib/genglsl/lib/mx_refraction_index.glsl deleted file mode 100644 index 00433b0fa..000000000 --- a/materialx/libraries/pbrlib/genglsl/lib/mx_refraction_index.glsl +++ /dev/null @@ -1,31 +0,0 @@ -// "Artist Friendly Metallic Fresnel", Ole Gulbrandsen, 2014 -// http://jcgt.org/published/0003/04/03/paper.pdf - -void mx_complex_to_artistic_ior(vec3 ior, vec3 extinction, out vec3 reflectivity, out vec3 edge_color) -{ - vec3 nm1 = ior - 1.0; - vec3 np1 = ior + 1.0; - vec3 k2 = extinction * extinction; - vec3 r = (nm1*nm1 + k2) / (np1*np1 + k2); - reflectivity = r; - - vec3 r_sqrt = sqrt(r); - vec3 n_min = (1.0 - r) / (1.0 + r); - vec3 n_max = (1.0 + r_sqrt) / (1.0 - r_sqrt); - edge_color = (n_max - ior) / (n_max - n_min); -} - -void mx_artistic_to_complex_ior(vec3 reflectivity, vec3 edge_color, out vec3 ior, out vec3 extinction) -{ - vec3 r = clamp(reflectivity, 0.0, 0.99); - vec3 r_sqrt = sqrt(r); - vec3 n_min = (1.0 - r) / (1.0 + r); - vec3 n_max = (1.0 + r_sqrt) / (1.0 - r_sqrt); - ior = mix(n_max, n_min, edge_color); - - vec3 np1 = ior + 1.0; - vec3 nm1 = ior - 1.0; - vec3 k2 = (np1*np1 * r - nm1*nm1) / (1.0 - r); - k2 = max(k2, 0.0); - extinction = sqrt(k2); -} diff --git a/materialx/libraries/pbrlib/genglsl/lib/mx_shadow.glsl b/materialx/libraries/pbrlib/genglsl/lib/mx_shadow.glsl deleted file mode 100644 index 0a0fdb4f0..000000000 --- a/materialx/libraries/pbrlib/genglsl/lib/mx_shadow.glsl +++ /dev/null @@ -1,23 +0,0 @@ -// https://developer.nvidia.com/gpugems/gpugems3/part-ii-light-and-shadows/chapter-8-summed-area-variance-shadow-maps -float mx_variance_shadow_occlusion(vec2 moments, float fragmentDepth) -{ - const float MIN_VARIANCE = 0.00001; - - // One-tailed inequality valid if fragmentDepth > moments.x. - float p = (fragmentDepth <= moments.x) ? 1.0 : 0.0; - - // Compute variance. - float variance = moments.y - mx_square(moments.x); - variance = max(variance, MIN_VARIANCE); - - // Compute probabilistic upper bound. - float d = fragmentDepth - moments.x; - float pMax = variance / (variance + mx_square(d)); - return max(p, pMax); -} - -vec2 mx_compute_depth_moments() -{ - float depth = gl_FragCoord.z; - return vec2(depth, mx_square(depth)); -} diff --git a/materialx/libraries/pbrlib/genglsl/lib/mx_table.glsl b/materialx/libraries/pbrlib/genglsl/lib/mx_table.glsl deleted file mode 100644 index e453758d9..000000000 --- a/materialx/libraries/pbrlib/genglsl/lib/mx_table.glsl +++ /dev/null @@ -1,7 +0,0 @@ -#include "pbrlib/genglsl/lib/mx_microfacet_specular.glsl" - -vec2 mx_ggx_directional_albedo_generate_table() -{ - vec2 uv = gl_FragCoord.xy / $albedoTableSize; - return mx_ggx_directional_albedo_importance_sample(uv.x, uv.y, vec3(1, 0, 0), vec3(0, 1, 0)).xy; -} diff --git a/materialx/libraries/pbrlib/genglsl/mx_add_bsdf.glsl b/materialx/libraries/pbrlib/genglsl/mx_add_bsdf.glsl deleted file mode 100644 index d66a42521..000000000 --- a/materialx/libraries/pbrlib/genglsl/mx_add_bsdf.glsl +++ /dev/null @@ -1,14 +0,0 @@ -void mx_add_bsdf_reflection(vec3 L, vec3 V, vec3 P, float occlusion, BSDF in1, BSDF in2, out BSDF result) -{ - result = in1 + in2; -} - -void mx_add_bsdf_transmission(vec3 V, BSDF in1, BSDF in2, out BSDF result) -{ - result = in1 + in2; -} - -void mx_add_bsdf_indirect(vec3 V, vec3 in1, vec3 in2, out vec3 result) -{ - result = in1 + in2; -} diff --git a/materialx/libraries/pbrlib/genglsl/mx_add_edf.glsl b/materialx/libraries/pbrlib/genglsl/mx_add_edf.glsl deleted file mode 100644 index 0631c107b..000000000 --- a/materialx/libraries/pbrlib/genglsl/mx_add_edf.glsl +++ /dev/null @@ -1,4 +0,0 @@ -void mx_add_edf(vec3 N, vec3 L, EDF in1, EDF in2, out EDF result) -{ - result = in1 + in2; -} diff --git a/materialx/libraries/pbrlib/genglsl/mx_artistic_ior.glsl b/materialx/libraries/pbrlib/genglsl/mx_artistic_ior.glsl deleted file mode 100644 index 98a1021ad..000000000 --- a/materialx/libraries/pbrlib/genglsl/mx_artistic_ior.glsl +++ /dev/null @@ -1,6 +0,0 @@ -#include "pbrlib/genglsl/lib/mx_refraction_index.glsl" - -void mx_artistic_ior(vec3 reflectivity, vec3 edge_color, out vec3 ior, out vec3 extinction) -{ - mx_artistic_to_complex_ior(reflectivity, edge_color, ior, extinction); -} diff --git a/materialx/libraries/pbrlib/genglsl/mx_burley_diffuse_bsdf.glsl b/materialx/libraries/pbrlib/genglsl/mx_burley_diffuse_bsdf.glsl deleted file mode 100644 index d9f4c9aac..000000000 --- a/materialx/libraries/pbrlib/genglsl/mx_burley_diffuse_bsdf.glsl +++ /dev/null @@ -1,35 +0,0 @@ -#include "pbrlib/genglsl/lib/mx_microfacet_diffuse.glsl" - -void mx_burley_diffuse_bsdf_reflection(vec3 L, vec3 V, vec3 P, float occlusion, float weight, vec3 color, float roughness, vec3 normal, out BSDF result) -{ - if (weight < M_FLOAT_EPS) - { - result = BSDF(0.0); - return; - } - - normal = mx_forward_facing_normal(normal, V); - - float NdotL = clamp(dot(normal, L), M_FLOAT_EPS, 1.0); - - result = color * occlusion * weight * NdotL * M_PI_INV; - result *= mx_burley_diffuse(L, V, normal, NdotL, roughness); - return; -} - -void mx_burley_diffuse_bsdf_indirect(vec3 V, float weight, vec3 color, float roughness, vec3 normal, out BSDF result) -{ - if (weight < M_FLOAT_EPS) - { - result = BSDF(0.0); - return; - } - - normal = mx_forward_facing_normal(normal, V); - - float NdotV = clamp(dot(normal, V), M_FLOAT_EPS, 1.0); - - vec3 Li = mx_environment_irradiance(normal) * - mx_burley_diffuse_directional_albedo(NdotV, roughness); - result = Li * color * weight; -} diff --git a/materialx/libraries/pbrlib/genglsl/mx_conductor_bsdf.glsl b/materialx/libraries/pbrlib/genglsl/mx_conductor_bsdf.glsl deleted file mode 100644 index 18daeaae0..000000000 --- a/materialx/libraries/pbrlib/genglsl/mx_conductor_bsdf.glsl +++ /dev/null @@ -1,55 +0,0 @@ -#include "pbrlib/genglsl/lib/mx_microfacet_specular.glsl" - -void mx_conductor_bsdf_reflection(vec3 L, vec3 V, vec3 P, float occlusion, float weight, vec3 ior_n, vec3 ior_k, vec2 roughness, vec3 N, vec3 X, int distribution, thinfilm tf, out BSDF result) -{ - if (weight < M_FLOAT_EPS) - { - result = BSDF(0.0); - return; - } - - N = mx_forward_facing_normal(N, V); - - vec3 Y = normalize(cross(N, X)); - vec3 H = normalize(L + V); - - float NdotL = clamp(dot(N, L), M_FLOAT_EPS, 1.0); - float NdotV = clamp(dot(N, V), M_FLOAT_EPS, 1.0); - float NdotH = clamp(dot(N, H), M_FLOAT_EPS, 1.0); - float VdotH = clamp(dot(V, H), M_FLOAT_EPS, 1.0); - - FresnelData fd = tf.thickness > 0.0 ? mx_init_fresnel_conductor_airy(ior_n, ior_k, tf.thickness, tf.ior) : mx_init_fresnel_conductor(ior_n, ior_k); - vec3 F = mx_compute_fresnel(VdotH, fd); - - float avgRoughness = mx_average_roughness(roughness); - float D = mx_ggx_NDF(X, Y, H, NdotH, roughness.x, roughness.y); - float G = mx_ggx_smith_G(NdotL, NdotV, avgRoughness); - - vec3 comp = mx_ggx_energy_compensation(NdotV, avgRoughness, F); - - // Note: NdotL is cancelled out - result = D * F * G * comp * occlusion * weight / (4 * NdotV); -} - -void mx_conductor_bsdf_indirect(vec3 V, float weight, vec3 ior_n, vec3 ior_k, vec2 roughness, vec3 N, vec3 X, int distribution, thinfilm tf, out BSDF result) -{ - if (weight < M_FLOAT_EPS) - { - result = BSDF(0.0); - return; - } - - N = mx_forward_facing_normal(N, V); - - float NdotV = clamp(dot(N, V), M_FLOAT_EPS, 1.0); - - FresnelData fd = tf.thickness > 0.0 ? mx_init_fresnel_conductor_airy(ior_n, ior_k, tf.thickness, tf.ior) : mx_init_fresnel_conductor(ior_n, ior_k); - vec3 F = mx_compute_fresnel(NdotV, fd); - - vec3 Li = mx_environment_radiance(N, V, X, roughness, distribution, fd); - - float avgRoughness = mx_average_roughness(roughness); - vec3 comp = mx_ggx_energy_compensation(NdotV, avgRoughness, F); - - result = Li * comp * weight; -} diff --git a/materialx/libraries/pbrlib/genglsl/mx_dielectric_bsdf.glsl b/materialx/libraries/pbrlib/genglsl/mx_dielectric_bsdf.glsl deleted file mode 100644 index d0c77a26a..000000000 --- a/materialx/libraries/pbrlib/genglsl/mx_dielectric_bsdf.glsl +++ /dev/null @@ -1,96 +0,0 @@ -#include "pbrlib/genglsl/lib/mx_microfacet_specular.glsl" - -void mx_dielectric_bsdf_reflection(vec3 L, vec3 V, vec3 P, float occlusion, float weight, vec3 tint, float ior, vec2 roughness, vec3 N, vec3 X, int distribution, int scatter_mode, BSDF base, thinfilm tf, out BSDF result) -{ - if (weight < M_FLOAT_EPS) - { - result = base; - return; - } - - N = mx_forward_facing_normal(N, V); - - vec3 Y = normalize(cross(N, X)); - vec3 H = normalize(L + V); - - float NdotL = clamp(dot(N, L), M_FLOAT_EPS, 1.0); - float NdotV = clamp(dot(N, V), M_FLOAT_EPS, 1.0); - float NdotH = clamp(dot(N, H), M_FLOAT_EPS, 1.0); - float VdotH = clamp(dot(V, H), M_FLOAT_EPS, 1.0); - - float avgRoughness = mx_average_roughness(roughness); - - FresnelData fd = tf.thickness > 0.0 ? mx_init_fresnel_dielectric_airy(ior, tf.thickness, tf.ior) : mx_init_fresnel_dielectric(ior); - vec3 F = mx_compute_fresnel(VdotH, fd); - float D = mx_ggx_NDF(X, Y, H, NdotH, roughness.x, roughness.y); - float G = mx_ggx_smith_G(NdotL, NdotV, avgRoughness); - - float F0 = mx_ior_to_f0(ior); - vec3 comp = mx_ggx_energy_compensation(NdotV, avgRoughness, F); - vec3 dirAlbedo = mx_ggx_directional_albedo(NdotV, avgRoughness, F0, 1.0) * comp; - - // Note: NdotL is cancelled out - result = D * F * G * comp * tint * occlusion * weight / (4 * NdotV) // Top layer reflection - + base * (1.0 - dirAlbedo * weight); // Base layer reflection attenuated by top layer -} - -void mx_dielectric_bsdf_transmission(vec3 V, float weight, vec3 tint, float ior, vec2 roughness, vec3 N, vec3 X, int distribution, int scatter_mode, BSDF base, thinfilm tf, out BSDF result) -{ - if (scatter_mode == 1) - { - result = tint * weight; - return; - } - - if (scatter_mode == 2) - { - // No external layering in RT mode, - // the base is always T in this case. - base = tint * weight; - } - - if (weight < M_FLOAT_EPS) - { - result = base; - return; - } - - N = mx_forward_facing_normal(N, V); - float NdotV = clamp(dot(N, V), M_FLOAT_EPS, 1.0); - - FresnelData fd = tf.thickness > 0.0 ? mx_init_fresnel_dielectric_airy(ior, tf.thickness, tf.ior) : mx_init_fresnel_dielectric(ior); - vec3 F = mx_compute_fresnel(NdotV, fd); - - float avgRoughness = mx_average_roughness(roughness); - float F0 = mx_ior_to_f0(ior); - vec3 comp = mx_ggx_energy_compensation(NdotV, avgRoughness, F); - vec3 dirAlbedo = mx_ggx_directional_albedo(NdotV, avgRoughness, F0, 1.0) * comp; - - result = base * (1.0 - dirAlbedo * weight); // Transmission attenuated by reflection amount -} - -void mx_dielectric_bsdf_indirect(vec3 V, float weight, vec3 tint, float ior, vec2 roughness, vec3 N, vec3 X, int distribution, int scatter_mode, BSDF base, thinfilm tf, out BSDF result) -{ - if (weight < M_FLOAT_EPS) - { - result = base; - return; - } - - N = mx_forward_facing_normal(N, V); - - float NdotV = clamp(dot(N, V), M_FLOAT_EPS, 1.0); - - FresnelData fd = tf.thickness > 0.0 ? mx_init_fresnel_dielectric_airy(ior, tf.thickness, tf.ior) : mx_init_fresnel_dielectric(ior); - vec3 F = mx_compute_fresnel(NdotV, fd); - - float avgRoughness = mx_average_roughness(roughness); - float F0 = mx_ior_to_f0(ior); - vec3 comp = mx_ggx_energy_compensation(NdotV, avgRoughness, F); - vec3 dirAlbedo = mx_ggx_directional_albedo(NdotV, avgRoughness, F0, 1.0) * comp; - - vec3 Li = mx_environment_radiance(N, V, X, roughness, distribution, fd); - - result = Li * tint * comp * weight // Top layer reflection - + base * (1.0 - dirAlbedo * weight); // Base layer reflection attenuated by top layer -} diff --git a/materialx/libraries/pbrlib/genglsl/mx_generalized_schlick_bsdf.glsl b/materialx/libraries/pbrlib/genglsl/mx_generalized_schlick_bsdf.glsl deleted file mode 100644 index cf567db2d..000000000 --- a/materialx/libraries/pbrlib/genglsl/mx_generalized_schlick_bsdf.glsl +++ /dev/null @@ -1,86 +0,0 @@ -#include "pbrlib/genglsl/lib/mx_microfacet_specular.glsl" - -void mx_generalized_schlick_bsdf_reflection(vec3 L, vec3 V, vec3 P, float occlusion, float weight, vec3 color0, vec3 color90, float exponent, vec2 roughness, vec3 N, vec3 X, int distribution, int scatter_mode, BSDF base, thinfilm tf, out BSDF result) -{ - if (weight < M_FLOAT_EPS) - { - result = base; - return; - } - - N = mx_forward_facing_normal(N, V); - - vec3 Y = normalize(cross(N, X)); - vec3 H = normalize(L + V); - - float NdotL = clamp(dot(N, L), M_FLOAT_EPS, 1.0); - float NdotV = clamp(dot(N, V), M_FLOAT_EPS, 1.0); - float NdotH = clamp(dot(N, H), M_FLOAT_EPS, 1.0); - float VdotH = clamp(dot(V, H), M_FLOAT_EPS, 1.0); - - float avgRoughness = mx_average_roughness(roughness); - - FresnelData fd = mx_init_fresnel_schlick(color0, color90, exponent); - vec3 F = mx_compute_fresnel(VdotH, fd); - float D = mx_ggx_NDF(X, Y, H, NdotH, roughness.x, roughness.y); - float G = mx_ggx_smith_G(NdotL, NdotV, avgRoughness); - - vec3 comp = mx_ggx_energy_compensation(NdotV, avgRoughness, F); - vec3 dirAlbedo = mx_ggx_directional_albedo(NdotV, avgRoughness, color0, color90) * comp; - float avgDirAlbedo = dot(dirAlbedo, vec3(1.0 / 3.0)); - - // Note: NdotL is cancelled out - result = D * F * G * comp * occlusion * weight / (4 * NdotV) // Top layer reflection - + base * (1.0 - avgDirAlbedo * weight); // Base layer reflection attenuated by top layer -} - -void mx_generalized_schlick_bsdf_transmission(vec3 V, float weight, vec3 color0, vec3 color90, float exponent, vec2 roughness, vec3 N, vec3 X, int distribution, int scatter_mode, BSDF base, thinfilm tf, out BSDF result) -{ - // - // TODO: We need handling of transmission for generalized schlick - // - - if (weight < M_FLOAT_EPS) - { - result = base; - return; - } - - N = mx_forward_facing_normal(N, V); - float NdotV = clamp(dot(N, V), M_FLOAT_EPS, 1.0); - - FresnelData fd = mx_init_fresnel_schlick(color0, color90, exponent); - vec3 F = mx_compute_fresnel(NdotV, fd); - - float avgRoughness = mx_average_roughness(roughness); - vec3 comp = mx_ggx_energy_compensation(NdotV, avgRoughness, F); - vec3 dirAlbedo = mx_ggx_directional_albedo(NdotV, avgRoughness, color0, color90) * comp; - float avgDirAlbedo = dot(dirAlbedo, vec3(1.0 / 3.0)); - - result = base * (1.0 - avgDirAlbedo * weight); // Transmission attenuated by top layer -} - -void mx_generalized_schlick_bsdf_indirect(vec3 V, float weight, vec3 color0, vec3 color90, float exponent, vec2 roughness, vec3 N, vec3 X, int distribution, int scatter_mode, BSDF base, thinfilm tf, out BSDF result) -{ - if (weight < M_FLOAT_EPS) - { - result = base; - return; - } - - N = mx_forward_facing_normal(N, V); - float NdotV = clamp(dot(N, V), M_FLOAT_EPS, 1.0); - - FresnelData fd = mx_init_fresnel_schlick(color0, color90, exponent); - vec3 F = mx_compute_fresnel(NdotV, fd); - - float avgRoughness = mx_average_roughness(roughness); - vec3 comp = mx_ggx_energy_compensation(NdotV, avgRoughness, F); - vec3 dirAlbedo = mx_ggx_directional_albedo(NdotV, avgRoughness, color0, color90) * comp; - float avgDirAlbedo = dot(dirAlbedo, vec3(1.0 / 3.0)); - - vec3 Li = mx_environment_radiance(N, V, X, roughness, distribution, fd); - - result = Li * comp * weight // Top layer reflection - + base * (1.0 - avgDirAlbedo * weight); // Base layer reflection attenuated by top layer -} diff --git a/materialx/libraries/pbrlib/genglsl/mx_mix_bsdf.glsl b/materialx/libraries/pbrlib/genglsl/mx_mix_bsdf.glsl deleted file mode 100644 index 0c5316308..000000000 --- a/materialx/libraries/pbrlib/genglsl/mx_mix_bsdf.glsl +++ /dev/null @@ -1,14 +0,0 @@ -void mx_mix_bsdf_reflection(vec3 L, vec3 V, vec3 P, float occlusion, BSDF fg, BSDF bg, float w, out BSDF result) -{ - result = mix(bg, fg, clamp(w, 0.0, 1.0)); -} - -void mx_mix_bsdf_transmission(vec3 V, BSDF fg, BSDF bg, float w, out BSDF result) -{ - result = mix(bg, fg, clamp(w, 0.0, 1.0)); -} - -void mx_mix_bsdf_indirect(vec3 V, vec3 fg, vec3 bg, float w, out vec3 result) -{ - result = mix(bg, fg, clamp(w, 0.0, 1.0)); -} diff --git a/materialx/libraries/pbrlib/genglsl/mx_mix_edf.glsl b/materialx/libraries/pbrlib/genglsl/mx_mix_edf.glsl deleted file mode 100644 index 59c5606bc..000000000 --- a/materialx/libraries/pbrlib/genglsl/mx_mix_edf.glsl +++ /dev/null @@ -1,4 +0,0 @@ -void mx_mix_edf(vec3 N, vec3 L, EDF fg, EDF bg, float w, out EDF result) -{ - result = mix(bg, fg, clamp(w, 0.0, 1.0)); -} diff --git a/materialx/libraries/pbrlib/genglsl/mx_multiply_bsdf_color.glsl b/materialx/libraries/pbrlib/genglsl/mx_multiply_bsdf_color.glsl deleted file mode 100644 index d83a9ce64..000000000 --- a/materialx/libraries/pbrlib/genglsl/mx_multiply_bsdf_color.glsl +++ /dev/null @@ -1,14 +0,0 @@ -void mx_multiply_bsdf_color_reflection(vec3 L, vec3 V, vec3 P, float occlusion, BSDF in1, vec3 in2, out BSDF result) -{ - result = in1 * clamp(in2, 0.0, 1.0); -} - -void mx_multiply_bsdf_color_transmission(vec3 V, BSDF in1, vec3 in2, out BSDF result) -{ - result = in1 * clamp(in2, 0.0, 1.0); -} - -void mx_multiply_bsdf_color_indirect(vec3 V, vec3 in1, vec3 in2, out vec3 result) -{ - result = in1 * clamp(in2, 0.0, 1.0); -} diff --git a/materialx/libraries/pbrlib/genglsl/mx_multiply_bsdf_float.glsl b/materialx/libraries/pbrlib/genglsl/mx_multiply_bsdf_float.glsl deleted file mode 100644 index 6dd31da8f..000000000 --- a/materialx/libraries/pbrlib/genglsl/mx_multiply_bsdf_float.glsl +++ /dev/null @@ -1,14 +0,0 @@ -void mx_multiply_bsdf_float_reflection(vec3 L, vec3 V, vec3 P, float occlusion, BSDF in1, float in2, out BSDF result) -{ - result = in1 * clamp(in2, 0.0, 1.0); -} - -void mx_multiply_bsdf_float_transmission(vec3 V, BSDF in1, float in2, out BSDF result) -{ - result = in1 * clamp(in2, 0.0, 1.0); -} - -void mx_multiply_bsdf_float_indirect(vec3 V, vec3 in1, float in2, out vec3 result) -{ - result = in1 * clamp(in2, 0.0, 1.0); -} diff --git a/materialx/libraries/pbrlib/genglsl/mx_multiply_edf_color.glsl b/materialx/libraries/pbrlib/genglsl/mx_multiply_edf_color.glsl deleted file mode 100644 index f516e39c6..000000000 --- a/materialx/libraries/pbrlib/genglsl/mx_multiply_edf_color.glsl +++ /dev/null @@ -1,4 +0,0 @@ -void mx_multiply_edf_color(vec3 N, vec3 L, EDF in1, vec3 in2, out EDF result) -{ - result = in1 * in2; -} diff --git a/materialx/libraries/pbrlib/genglsl/mx_multiply_edf_float.glsl b/materialx/libraries/pbrlib/genglsl/mx_multiply_edf_float.glsl deleted file mode 100644 index fa61bff30..000000000 --- a/materialx/libraries/pbrlib/genglsl/mx_multiply_edf_float.glsl +++ /dev/null @@ -1,4 +0,0 @@ -void mx_multiply_edf_float(vec3 N, vec3 L, EDF in1, float in2, out EDF result) -{ - result = in1 * in2; -} diff --git a/materialx/libraries/pbrlib/genglsl/mx_oren_nayar_diffuse_bsdf.glsl b/materialx/libraries/pbrlib/genglsl/mx_oren_nayar_diffuse_bsdf.glsl deleted file mode 100644 index e4163119b..000000000 --- a/materialx/libraries/pbrlib/genglsl/mx_oren_nayar_diffuse_bsdf.glsl +++ /dev/null @@ -1,34 +0,0 @@ -#include "pbrlib/genglsl/lib/mx_microfacet_diffuse.glsl" - -void mx_oren_nayar_diffuse_bsdf_reflection(vec3 L, vec3 V, vec3 P, float occlusion, float weight, vec3 color, float roughness, vec3 normal, out BSDF result) -{ - if (weight < M_FLOAT_EPS) - { - result = BSDF(0.0); - return; - } - - normal = mx_forward_facing_normal(normal, V); - - float NdotL = clamp(dot(normal, L), M_FLOAT_EPS, 1.0); - - result = color * occlusion * weight * NdotL * M_PI_INV; - if (roughness > 0.0) - { - result *= mx_oren_nayar_diffuse(L, V, normal, NdotL, roughness); - } -} - -void mx_oren_nayar_diffuse_bsdf_indirect(vec3 V, float weight, vec3 color, float roughness, vec3 normal, out vec3 result) -{ - if (weight < M_FLOAT_EPS) - { - result = BSDF(0.0); - return; - } - - normal = mx_forward_facing_normal(normal, V); - - vec3 Li = mx_environment_irradiance(normal); - result = Li * color * weight; -} diff --git a/materialx/libraries/pbrlib/genglsl/mx_roughness_anisotropy.glsl b/materialx/libraries/pbrlib/genglsl/mx_roughness_anisotropy.glsl deleted file mode 100644 index 39d266eba..000000000 --- a/materialx/libraries/pbrlib/genglsl/mx_roughness_anisotropy.glsl +++ /dev/null @@ -1,15 +0,0 @@ -void mx_roughness_anisotropy(float roughness, float anisotropy, out vec2 result) -{ - float roughness_sqr = clamp(roughness*roughness, M_FLOAT_EPS, 1.0); - if (anisotropy > 0.0) - { - float aspect = sqrt(1.0 - clamp(anisotropy, 0.0, 0.98)); - result.x = min(roughness_sqr / aspect, 1.0); - result.y = roughness_sqr * aspect; - } - else - { - result.x = roughness_sqr; - result.y = roughness_sqr; - } -} diff --git a/materialx/libraries/pbrlib/genglsl/mx_roughness_dual.glsl b/materialx/libraries/pbrlib/genglsl/mx_roughness_dual.glsl deleted file mode 100644 index f4b538399..000000000 --- a/materialx/libraries/pbrlib/genglsl/mx_roughness_dual.glsl +++ /dev/null @@ -1,9 +0,0 @@ -void mx_roughness_dual(vec2 roughness, out vec2 result) -{ - if (roughness.y < 0.0) - { - roughness.y = roughness.x; - } - result.x = clamp(roughness.x * roughness.x, M_FLOAT_EPS, 1.0); - result.y = clamp(roughness.y * roughness.y, M_FLOAT_EPS, 1.0); -} diff --git a/materialx/libraries/pbrlib/genglsl/mx_sheen_bsdf.glsl b/materialx/libraries/pbrlib/genglsl/mx_sheen_bsdf.glsl deleted file mode 100644 index 5a7ac9606..000000000 --- a/materialx/libraries/pbrlib/genglsl/mx_sheen_bsdf.glsl +++ /dev/null @@ -1,50 +0,0 @@ -#include "pbrlib/genglsl/lib/mx_microfacet_sheen.glsl" - -void mx_sheen_bsdf_reflection(vec3 L, vec3 V, vec3 P, float occlusion, float weight, vec3 color, float roughness, vec3 N, BSDF base, out BSDF result) -{ - if (weight < M_FLOAT_EPS) - { - result = base; - return; - } - - N = mx_forward_facing_normal(N, V); - - vec3 H = normalize(L + V); - - float NdotL = clamp(dot(N, L), M_FLOAT_EPS, 1.0); - float NdotV = clamp(dot(N, V), M_FLOAT_EPS, 1.0); - float NdotH = clamp(dot(N, H), M_FLOAT_EPS, 1.0); - - float D = mx_imageworks_sheen_NDF(NdotH, roughness); - - // Geometry term is skipped and we use a smoother denominator, as in: - // https://blog.selfshadow.com/publications/s2013-shading-course/rad/s2013_pbs_rad_notes.pdf - vec3 fr = D * color / (4.0 * (NdotL + NdotV - NdotL*NdotV)); - - float dirAlbedo = mx_imageworks_sheen_directional_albedo(NdotV, roughness); - - // We need to include NdotL from the light integral here - // as in this case it's not cancelled out by the BRDF denominator. - result = fr * NdotL * occlusion * weight // Top layer reflection - + base * (1.0 - dirAlbedo * weight); // Base layer reflection attenuated by top layer -} - -void mx_sheen_bsdf_indirect(vec3 V, float weight, vec3 color, float roughness, vec3 N, BSDF base, out vec3 result) -{ - if (weight <= 0.0) - { - result = base; - return; - } - - N = mx_forward_facing_normal(N, V); - - float NdotV = clamp(dot(N, V), M_FLOAT_EPS, 1.0); - - float dirAlbedo = mx_imageworks_sheen_directional_albedo(NdotV, roughness); - - vec3 Li = mx_environment_irradiance(N); - result = Li * color * dirAlbedo * weight // Top layer reflection - + base * (1.0 - dirAlbedo * weight); // Base layer reflection attenuated by top layer -} diff --git a/materialx/libraries/pbrlib/genglsl/mx_subsurface_bsdf.glsl b/materialx/libraries/pbrlib/genglsl/mx_subsurface_bsdf.glsl deleted file mode 100644 index 0e255e4c1..000000000 --- a/materialx/libraries/pbrlib/genglsl/mx_subsurface_bsdf.glsl +++ /dev/null @@ -1,32 +0,0 @@ -#include "pbrlib/genglsl/lib/mx_microfacet_diffuse.glsl" - -void mx_subsurface_bsdf_reflection(vec3 L, vec3 V, vec3 P, float occlusion, float weight, vec3 color, vec3 radius, float anisotropy, vec3 normal, out BSDF result) -{ - if (weight < M_FLOAT_EPS) - { - result = BSDF(0.0); - return; - } - - normal = mx_forward_facing_normal(normal, V); - - vec3 sss = mx_subsurface_scattering_approx(normal, L, P, color, radius); - float NdotL = clamp(dot(normal, L), M_FLOAT_EPS, 1.0); - float visibleOcclusion = 1.0 - NdotL * (1.0 - occlusion); - result = sss * visibleOcclusion * weight; -} - -void mx_subsurface_bsdf_indirect(vec3 V, float weight, vec3 color, vec3 radius, float anisotropy, vec3 normal, out BSDF result) -{ - if (weight < M_FLOAT_EPS) - { - result = BSDF(0.0); - return; - } - - normal = mx_forward_facing_normal(normal, V); - - // For now, we render indirect subsurface as simple indirect diffuse. - vec3 Li = mx_environment_irradiance(normal); - result = Li * color * weight; -} diff --git a/materialx/libraries/pbrlib/genglsl/mx_translucent_bsdf.glsl b/materialx/libraries/pbrlib/genglsl/mx_translucent_bsdf.glsl deleted file mode 100644 index 4854173b5..000000000 --- a/materialx/libraries/pbrlib/genglsl/mx_translucent_bsdf.glsl +++ /dev/null @@ -1,27 +0,0 @@ -// We fake diffuse transmission by using diffuse reflection from the opposite side. -// So this BTDF is really a BRDF. -void mx_translucent_bsdf_reflection(vec3 L, vec3 V, vec3 P, float occlusion, float weight, vec3 color, vec3 normal, out BSDF result) -{ - // Invert normal since we're transmitting light from the other side - float NdotL = dot(L, -normal); - if (NdotL <= 0.0 || weight < M_FLOAT_EPS) - { - result = BSDF(0.0); - return; - } - - result = color * weight * NdotL * M_PI_INV; -} - -void mx_translucent_bsdf_indirect(vec3 V, float weight, vec3 color, vec3 normal, out BSDF result) -{ - if (weight < M_FLOAT_EPS) - { - result = BSDF(0.0); - return; - } - - // Invert normal since we're transmitting light from the other side - vec3 Li = mx_environment_irradiance(-normal); - result = Li * color * weight; -} diff --git a/materialx/libraries/pbrlib/genglsl/mx_uniform_edf.glsl b/materialx/libraries/pbrlib/genglsl/mx_uniform_edf.glsl deleted file mode 100644 index 31e8a450c..000000000 --- a/materialx/libraries/pbrlib/genglsl/mx_uniform_edf.glsl +++ /dev/null @@ -1,4 +0,0 @@ -void mx_uniform_edf(vec3 N, vec3 L, vec3 color, out EDF result) -{ - result = color; -} diff --git a/materialx/libraries/pbrlib/genglsl/pbrlib_genglsl_impl.mtlx b/materialx/libraries/pbrlib/genglsl/pbrlib_genglsl_impl.mtlx deleted file mode 100644 index dc799ff97..000000000 --- a/materialx/libraries/pbrlib/genglsl/pbrlib_genglsl_impl.mtlx +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/materialx/libraries/pbrlib/genmdl/pbrlib_genmdl_impl.mtlx b/materialx/libraries/pbrlib/genmdl/pbrlib_genmdl_impl.mtlx deleted file mode 100644 index 450dc0350..000000000 --- a/materialx/libraries/pbrlib/genmdl/pbrlib_genmdl_impl.mtlx +++ /dev/null @@ -1,92 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/materialx/libraries/pbrlib/genosl/lib/mx_microfacet.osl b/materialx/libraries/pbrlib/genosl/lib/mx_microfacet.osl deleted file mode 100644 index c0b78cf97..000000000 --- a/materialx/libraries/pbrlib/genosl/lib/mx_microfacet.osl +++ /dev/null @@ -1,125 +0,0 @@ -float mx_square(float x) -{ - return x*x; -} - -vector2 mx_square(vector2 x) -{ - return x*x; -} - -vector mx_square(vector x) -{ - return x*x; -} - -vector4 mx_square(vector4 x) -{ - return x*x; -} - -float mx_pow5(float x) -{ - return mx_square(mx_square(x)) * x; -} - -float mx_fract(float x) -{ - return x - floor(x); -} - -float mx_average_roughness(vector2 roughness) -{ - return sqrt(roughness.x * roughness.y); -} - -// https://www.graphics.rwth-aachen.de/publication/2/jgt.pdf -float mx_golden_ratio_sequence(int i) -{ - return mx_fract((float(i) + 1.0) * M_GOLDEN_RATIO); -} - -// https://people.irisa.fr/Ricardo.Marques/articles/2013/SF_CGF.pdf -vector2 mx_spherical_fibonacci(int i, int numSamples) -{ - return vector2((float(i) + 0.5) / float(numSamples), mx_golden_ratio_sequence(i)); -} - -// Convert a real-valued index of refraction to normal-incidence reflectivity. -float mx_ior_to_f0(float ior) -{ - return mx_square((ior - 1.0) / (ior + 1.0)); -} - -// https://seblagarde.wordpress.com/2013/04/29/memo-on-fresnel-equations/ -float mx_fresnel_dielectric(float cosTheta, float ior) -{ - if (cosTheta < 0.0 || ior == 0.0) - return 1.0; - - float g = ior*ior + cosTheta*cosTheta - 1.0; - // Check for total internal reflection - if (g < 0.0) - return 1.0; - - g = sqrt(g); - float gmc = g - cosTheta; - float gpc = g + cosTheta; - float x = gmc / gpc; - float y = (gpc * cosTheta - 1.0) / (gmc * cosTheta + 1.0); - return 0.5 * x * x * (1.0 + y * y); -} - -color mx_fresnel_conductor(float cosTheta, vector n, vector k) -{ - float c2 = cosTheta*cosTheta; - vector n2_k2 = n*n + k*k; - vector nc2 = 2.0 * n * cosTheta; - - vector rs_a = n2_k2 + c2; - vector rp_a = n2_k2 * c2 + 1.0; - vector rs = (rs_a - nc2) / (rs_a + nc2); - vector rp = (rp_a - nc2) / (rp_a + nc2); - - return 0.5 * (rs + rp); -} - -// Standard Schlick Fresnel -float mx_fresnel_schlick(float cosTheta, float F0) -{ - float x = clamp(1.0 - cosTheta, 0.0, 1.0); - float x5 = mx_pow5(x); - return F0 + (1.0 - F0) * x5; -} -color mx_fresnel_schlick(float cosTheta, color F0) -{ - float x = clamp(1.0 - cosTheta, 0.0, 1.0); - float x5 = mx_pow5(x); - return F0 + (1.0 - F0) * x5; -} - -// Generalized Schlick Fresnel -float mx_fresnel_schlick(float cosTheta, float F0, float F90) -{ - float x = clamp(1.0 - cosTheta, 0.0, 1.0); - float x5 = mx_pow5(x); - return mix(F0, F90, x5); -} -color mx_fresnel_schlick(float cosTheta, color F0, color F90) -{ - float x = clamp(1.0 - cosTheta, 0.0, 1.0); - float x5 = mx_pow5(x); - return mix(F0, F90, x5); -} - -// Generalized Schlick Fresnel with a variable exponent -color mx_fresnel_schlick(float cosTheta, float f0, float f90, float exponent) -{ - float x = clamp(1.0 - cosTheta, 0.0, 1.0); - return mix(f0, f90, pow(x, exponent)); -} -color mx_fresnel_schlick(float cosTheta, color f0, color f90, float exponent) -{ - float x = clamp(1.0 - cosTheta, 0.0, 1.0); - return mix(f0, f90, pow(x, exponent)); -} diff --git a/materialx/libraries/pbrlib/genosl/lib/mx_microfacet_specular.osl b/materialx/libraries/pbrlib/genosl/lib/mx_microfacet_specular.osl deleted file mode 100644 index aed6b34be..000000000 --- a/materialx/libraries/pbrlib/genosl/lib/mx_microfacet_specular.osl +++ /dev/null @@ -1,116 +0,0 @@ -#include "pbrlib/genosl/lib/mx_microfacet.osl" - -// https://disney-animation.s3.amazonaws.com/library/s2012_pbs_disney_brdf_notes_v2.pdf -// Appendix B.2 Equation 15 -vector mx_ggx_importance_sample_NDF(vector2 Xi, vector X, vector Y, vector N, float alphaX, float alphaY) -{ - float phi = 2.0 * M_PI * Xi.x; - float tanTheta = sqrt(Xi.y / (1.0 - Xi.y)); - vector H = X * (tanTheta * alphaX * cos(phi)) + - Y * (tanTheta * alphaY * sin(phi)) + - N; - return normalize(H); -} - -// http://jcgt.org/published/0003/02/03/paper.pdf -// Equations 72 and 99 -float mx_ggx_smith_G(float NdotL, float NdotV, float alpha) -{ - float alpha2 = mx_square(alpha); - float lambdaL = sqrt(alpha2 + (1.0 - alpha2) * mx_square(NdotL)); - float lambdaV = sqrt(alpha2 + (1.0 - alpha2) * mx_square(NdotV)); - return 2.0 / (lambdaL / NdotL + lambdaV / NdotV); -} - -// https://www.unrealengine.com/blog/physically-based-shading-on-mobile -color mx_ggx_directional_albedo_curve_fit(float NdotV, float roughness, color F0, color F90) -{ - vector4 c0 = vector4(-1, -0.0275, -0.572, 0.022); - vector4 c1 = vector4( 1, 0.0425, 1.04, -0.04 ); - vector4 r = roughness * c0 + c1; - float a004 = min(r.x * r.x, exp2(-9.28 * NdotV)) * r.x + r.y; - vector2 AB = vector2(-1.04, 1.04) * a004 + vector2(r.z, r.w); - return F0 * AB.x + F90 * AB.y; -} - -color mx_ggx_directional_albedo_table_lookup(float NdotV, float roughness, color F0, color F90) -{ - vector2 st = vector2(NdotV, roughness); - vector AB = texture(GGX_DIRECTIONAL_ALBEDO_TABLE, st.x, st.y); - return F0 * AB[0] + F90 * AB[1]; -} - -// https://cdn2.unrealengine.com/Resources/files/2013SiggraphPresentationsNotes-26915738.pdf -color mx_ggx_directional_albedo_importance_sample(float _NdotV, float roughness, color F0, color F90) -{ - float NdotV = clamp(_NdotV, M_FLOAT_EPS, 1.0); - vector V = vector(sqrt(1.0 - mx_square(NdotV)), 0.0, NdotV); - - vector2 AB = vector2(0.0, 0.0); - int SAMPLE_COUNT = 64; - for (int i = 0; i < SAMPLE_COUNT; i++) - { - vector2 Xi = mx_spherical_fibonacci(i, SAMPLE_COUNT); - - // Compute the half vector and incoming light direction. - vector H = mx_ggx_importance_sample_NDF(Xi, vector(1, 0, 0), vector(0, 1, 0), vector(0, 0, 1), roughness, roughness); - vector L = -reflect(V, H); - - // Compute dot products for this sample. - float NdotL = clamp(L[2], M_FLOAT_EPS, 1.0); - float NdotH = clamp(H[2], M_FLOAT_EPS, 1.0); - float VdotH = clamp(dot(V, H), M_FLOAT_EPS, 1.0); - - // Compute the Fresnel term. - float Fc = mx_fresnel_schlick(VdotH, 0.0, 1.0); - - // Compute the geometric visibility term. - float Gvis = mx_ggx_smith_G(NdotL, NdotV, roughness) * VdotH / (NdotH * NdotV); - - // Add the contribution of this sample. - AB += vector2(Gvis * (1 - Fc), Gvis * Fc); - } - - // Normalize integrated terms. - AB /= SAMPLE_COUNT; - - // Return the final directional albedo. - return F0 * AB.x + F90 * AB.y; -} - -color mx_ggx_directional_albedo(float NdotV, float roughness, color F0, color F90) -{ -#if GGX_DIRECTIONAL_ALBEDO_METHOD == 0 - return mx_ggx_directional_albedo_curve_fit(NdotV, roughness, F0, F90); -#elif GGX_DIRECTIONAL_ALBEDO_METHOD == 1 - return mx_ggx_directional_albedo_table_lookup(NdotV, roughness, F0, F90); -#else - return mx_ggx_directional_albedo_importance_sample(NdotV, roughness, F0, F90); -#endif -} - -float mx_ggx_directional_albedo(float NdotV, float roughness, float F0, float F90) -{ - color result = mx_ggx_directional_albedo(NdotV, roughness, color(F0), color(F90)); - return result[0]; -} - -float mx_ggx_directional_albedo(float NdotV, float roughness, float ior) -{ - color result = mx_ggx_directional_albedo(NdotV, roughness, color(mx_ior_to_f0(ior)), color(1.0)); - return result[0]; -} - -// https://blog.selfshadow.com/publications/turquin/ms_comp_final.pdf -// Equations 14 and 16 -color mx_ggx_energy_compensation(float NdotV, float roughness, color Fss) -{ - float Ess = mx_ggx_directional_albedo(NdotV, roughness, 1.0, 1.0); - return 1.0 + Fss * (1.0 - Ess) / Ess; -} - -float mx_ggx_energy_compensation(float NdotV, float roughness, float Fss) -{ - color result = mx_ggx_energy_compensation(NdotV, roughness, color(Fss)); - return result[0]; -} diff --git a/materialx/libraries/pbrlib/genosl/lib/mx_refraction_index.osl b/materialx/libraries/pbrlib/genosl/lib/mx_refraction_index.osl deleted file mode 100644 index 6fb20b093..000000000 --- a/materialx/libraries/pbrlib/genosl/lib/mx_refraction_index.osl +++ /dev/null @@ -1,31 +0,0 @@ -// "Artist Friendly Metallic Fresnel", Ole Gulbrandsen, 2014 -// http://jcgt.org/published/0003/04/03/paper.pdf - -void mx_complex_to_artistic_ior(vector ior, vector extinction, output color reflectivity, output color edge_color) -{ - vector nm1 = ior - 1.0; - vector np1 = ior + 1.0; - vector k2 = extinction * extinction; - vector r = (nm1*nm1 + k2) / (np1*np1 + k2); - reflectivity = r; - - vector r_sqrt = sqrt(r); - vector n_min = (1.0 - r) / (1.0 + r); - vector n_max = (1.0 + r_sqrt) / (1.0 - r_sqrt); - edge_color = (n_max - ior) / (n_max - n_min); -} - -void mx_artistic_to_complex_ior(color reflectivity, color edge_color, output vector ior, output vector extinction) -{ - color r = clamp(reflectivity, 0.0, 0.99); - color r_sqrt = sqrt(r); - color n_min = (1.0 - r) / (1.0 + r); - color n_max = (1.0 + r_sqrt) / (1.0 - r_sqrt); - ior = mix(n_max, n_min, edge_color); - - color np1 = ior + 1.0; - color nm1 = ior - 1.0; - color k2 = (np1*np1 * r - nm1*nm1) / (1.0 - r); - k2 = max(k2, 0.0); - extinction = sqrt(k2); -} diff --git a/materialx/libraries/pbrlib/genosl/mx_add.inline b/materialx/libraries/pbrlib/genosl/mx_add.inline deleted file mode 100644 index d16f1ab8c..000000000 --- a/materialx/libraries/pbrlib/genosl/mx_add.inline +++ /dev/null @@ -1 +0,0 @@ -mx_add({{in1}}, {{in2}}) diff --git a/materialx/libraries/pbrlib/genosl/mx_artistic_ior.osl b/materialx/libraries/pbrlib/genosl/mx_artistic_ior.osl deleted file mode 100644 index 32f343b8f..000000000 --- a/materialx/libraries/pbrlib/genosl/mx_artistic_ior.osl +++ /dev/null @@ -1,6 +0,0 @@ -#include "pbrlib/genosl/lib/mx_refraction_index.osl" - -void mx_artistic_ior(color reflectivity, color edge_color, output vector ior, output vector extinction) -{ - mx_artistic_to_complex_ior(reflectivity, edge_color, ior, extinction); -} diff --git a/materialx/libraries/pbrlib/genosl/mx_burley_diffuse_bsdf.osl b/materialx/libraries/pbrlib/genosl/mx_burley_diffuse_bsdf.osl deleted file mode 100644 index 62ead30f1..000000000 --- a/materialx/libraries/pbrlib/genosl/mx_burley_diffuse_bsdf.osl +++ /dev/null @@ -1,5 +0,0 @@ -void mx_burley_diffuse_bsdf(float weight, color reflectance, float roughness, normal N, output BSDF result) -{ - // TODO: Implement properly. - result = reflectance * weight * oren_nayar(N, roughness); -} diff --git a/materialx/libraries/pbrlib/genosl/mx_conductor_bsdf.osl b/materialx/libraries/pbrlib/genosl/mx_conductor_bsdf.osl deleted file mode 100644 index 67dce6508..000000000 --- a/materialx/libraries/pbrlib/genosl/mx_conductor_bsdf.osl +++ /dev/null @@ -1,29 +0,0 @@ -#include "pbrlib/genosl/lib/mx_microfacet_specular.osl" - -void mx_conductor_bsdf(float weight, color ior_n, color ior_k, vector2 roughness, normal N, vector U, string distribution, thinfilm tf, output BSDF result) -{ - if (weight < M_FLOAT_EPS) - { - result = 0; - return; - } - - // Calculate conductor fresnel - // - // Fresnel should be based on microfacet normal - // but we have no access to that from here, so just use - // view direction and surface normal instead - // - float NdotV = fabs(dot(N,-I)); - color F = mx_fresnel_conductor(NdotV, ior_n, ior_k); - - // Calculate compensation for multiple scattering. - // This should normally be done inside the closure - // but since vanilla OSL doesen't support this we - // add it here in shader code instead. - float avgRoughness = mx_average_roughness(roughness); - color comp = mx_ggx_energy_compensation(NdotV, avgRoughness, F); - - // Set ior to 0.0 to disable the internal dielectric fresnel - result = F * comp * weight * microfacet(distribution, N, U, roughness.x, roughness.y, 0.0, false); -} diff --git a/materialx/libraries/pbrlib/genosl/mx_dielectric_bsdf.osl b/materialx/libraries/pbrlib/genosl/mx_dielectric_bsdf.osl deleted file mode 100644 index 9c0780a67..000000000 --- a/materialx/libraries/pbrlib/genosl/mx_dielectric_bsdf.osl +++ /dev/null @@ -1,35 +0,0 @@ -#include "pbrlib/genosl/lib/mx_microfacet_specular.osl" - -void mx_dielectric_bsdf(float weight, color tint, float ior, vector2 roughness, normal N, vector U, string distribution, string scatter_mode, BSDF base, thinfilm tf, output BSDF result) -{ - if (scatter_mode == "T") - { - result = tint * weight * microfacet(distribution, N, U, roughness.x, roughness.y, ior, 1); - return; - } - - float NdotV = clamp(dot(N,-I), M_FLOAT_EPS, 1.0); - float F0 = mx_ior_to_f0(ior); - float F = mx_fresnel_schlick(NdotV, F0); - - // Calculate compensation for multiple scattering. - // This should normally be done inside the closure - // but since vanilla OSL doesen't support this we - // add it here in shader code instead. - float avgRoughness = mx_average_roughness(roughness); - float comp = mx_ggx_energy_compensation(NdotV, avgRoughness, F); - - if (scatter_mode == "R") - { - // Calculate directional albedo since we need - // to attenuate the base layer according to this. - float dirAlbedo = mx_ggx_directional_albedo(NdotV, avgRoughness, ior) * comp; - - result = tint * weight * comp * microfacet(distribution, N, U, roughness.x, roughness.y, ior, 0) - + base * (1.0 - dirAlbedo * weight); - } - else - { - result = tint * weight * comp * microfacet(distribution, N, U, roughness.x, roughness.y, ior, 2); - } -} diff --git a/materialx/libraries/pbrlib/genosl/mx_displacement_float.osl b/materialx/libraries/pbrlib/genosl/mx_displacement_float.osl deleted file mode 100644 index f28985f43..000000000 --- a/materialx/libraries/pbrlib/genosl/mx_displacement_float.osl +++ /dev/null @@ -1,4 +0,0 @@ -void mx_displacement_float(float displacement, float scale, output displacementshader result) -{ - result = vector(displacement * scale); -} diff --git a/materialx/libraries/pbrlib/genosl/mx_displacement_vector3.osl b/materialx/libraries/pbrlib/genosl/mx_displacement_vector3.osl deleted file mode 100644 index 2a59cb050..000000000 --- a/materialx/libraries/pbrlib/genosl/mx_displacement_vector3.osl +++ /dev/null @@ -1,4 +0,0 @@ -void mx_displacement_vector3(vector displacement, float scale, output displacementshader result) -{ - result = displacement * scale; -} diff --git a/materialx/libraries/pbrlib/genosl/mx_generalized_schlick_bsdf.osl b/materialx/libraries/pbrlib/genosl/mx_generalized_schlick_bsdf.osl deleted file mode 100644 index 85d201dbe..000000000 --- a/materialx/libraries/pbrlib/genosl/mx_generalized_schlick_bsdf.osl +++ /dev/null @@ -1,32 +0,0 @@ -#include "pbrlib/genosl/lib/mx_microfacet_specular.osl" - -void mx_generalized_schlick_bsdf(float weight, color color0, color color90, float exponent, vector2 roughness, normal N, vector U, string distribution, string scatter_mode, BSDF base, thinfilm tf, output BSDF result) -{ - // - // TODO: We need handling of transmission for generalized schlick - // - if (weight < M_FLOAT_EPS || scatter_mode == "T") - { - result = base; - return; - } - - float NdotV = fabs(dot(N,-I)); - color F = mx_fresnel_schlick(NdotV, color0, color90, exponent); - float avgRoughness = mx_average_roughness(roughness); - - // Calculate compensation for multiple scattering. - // This should normally be done inside the closure - // but since vanilla OSL doesen't support this we - // add it here in shader code instead. - color comp = mx_ggx_energy_compensation(NdotV, avgRoughness, F); - - // Calculate directional albedo since we need - // to attenuate the base layer according to this. - color dirAlbedo = mx_ggx_directional_albedo(NdotV, avgRoughness, color0, color90) * comp; - float avgDirAlbedo = dot(dirAlbedo, color(1.0 / 3.0)); - - // Set ior to 0.0 to disable the internal dielectric fresnel - result = F * comp * weight * microfacet(distribution, N, U, roughness.x, roughness.y, 0.0, 0) - + base * (1.0 - avgDirAlbedo * weight); -} diff --git a/materialx/libraries/pbrlib/genosl/mx_mix.inline b/materialx/libraries/pbrlib/genosl/mx_mix.inline deleted file mode 100644 index e06e87be5..000000000 --- a/materialx/libraries/pbrlib/genosl/mx_mix.inline +++ /dev/null @@ -1 +0,0 @@ -mix({{bg}}, {{fg}}, {{mix}}) diff --git a/materialx/libraries/pbrlib/genosl/mx_multiply_bsdf.inline b/materialx/libraries/pbrlib/genosl/mx_multiply_bsdf.inline deleted file mode 100644 index 50519f9d2..000000000 --- a/materialx/libraries/pbrlib/genosl/mx_multiply_bsdf.inline +++ /dev/null @@ -1 +0,0 @@ -{{in1}} * clamp({{in2}}, 0.0, 1.0) diff --git a/materialx/libraries/pbrlib/genosl/mx_multiply_edf.inline b/materialx/libraries/pbrlib/genosl/mx_multiply_edf.inline deleted file mode 100644 index 4c4799f44..000000000 --- a/materialx/libraries/pbrlib/genosl/mx_multiply_edf.inline +++ /dev/null @@ -1 +0,0 @@ -{{in1}} * {{in2}} diff --git a/materialx/libraries/pbrlib/genosl/mx_oren_nayar_diffuse_bsdf.inline b/materialx/libraries/pbrlib/genosl/mx_oren_nayar_diffuse_bsdf.inline deleted file mode 100644 index afeaccb96..000000000 --- a/materialx/libraries/pbrlib/genosl/mx_oren_nayar_diffuse_bsdf.inline +++ /dev/null @@ -1 +0,0 @@ -{{color}} * {{weight}} * oren_nayar({{normal}}, {{roughness}}) diff --git a/materialx/libraries/pbrlib/genosl/mx_roughness_anisotropy.osl b/materialx/libraries/pbrlib/genosl/mx_roughness_anisotropy.osl deleted file mode 100644 index 48b256e70..000000000 --- a/materialx/libraries/pbrlib/genosl/mx_roughness_anisotropy.osl +++ /dev/null @@ -1,15 +0,0 @@ -void mx_roughness_anisotropy(float roughness, float anisotropy, output vector2 result) -{ - float roughness_sqr = clamp(roughness*roughness, M_FLOAT_EPS, 1.0); - if (anisotropy > 0.0) - { - float aspect = sqrt(1.0 - clamp(anisotropy, 0.0, 0.98)); - result.x = min(roughness_sqr / aspect, 1.0); - result.y = roughness_sqr * aspect; - } - else - { - result.x = roughness_sqr; - result.y = roughness_sqr; - } -} diff --git a/materialx/libraries/pbrlib/genosl/mx_roughness_dual.osl b/materialx/libraries/pbrlib/genosl/mx_roughness_dual.osl deleted file mode 100644 index 6de64c73a..000000000 --- a/materialx/libraries/pbrlib/genosl/mx_roughness_dual.osl +++ /dev/null @@ -1,12 +0,0 @@ -void mx_roughness_dual(vector2 roughness, output vector2 result) -{ - result.x = clamp(roughness.x * roughness.x, M_FLOAT_EPS, 1.0); - if (roughness.y < 0.0) - { - result.y = result.x; - } - else - { - result.y = clamp(roughness.y * roughness.y, M_FLOAT_EPS, 1.0); - } -} diff --git a/materialx/libraries/pbrlib/genosl/mx_sheen_bsdf.osl b/materialx/libraries/pbrlib/genosl/mx_sheen_bsdf.osl deleted file mode 100644 index bef33d389..000000000 --- a/materialx/libraries/pbrlib/genosl/mx_sheen_bsdf.osl +++ /dev/null @@ -1,61 +0,0 @@ -float mx_imageworks_sheen_directional_albedo(float cosTheta, float roughness) -{ - // LUT for sheen directional albedo. - // A 2D table parameterized with 'cosTheta' (cosine of angle to normal) on x-axis and 'roughness' on y-axis. - int SHEEN_ALBEDO_TABLE_SIZE = 16; - float _sheenAlbedo[256] = { - 1.6177, 0.978927, 0.618938, 0.391714, 0.245177, 0.150234, 0.0893475, 0.0511377, 0.0280191, 0.0144204, 0.00687674, 0.00295935, 0.00111049, 0.000336768, 7.07119e-05, 6.22646e-06, - 1.1084, 0.813928, 0.621389, 0.479304, 0.370299, 0.284835, 0.21724, 0.163558, 0.121254, 0.0878921, 0.0619052, 0.0419894, 0.0270556, 0.0161443, 0.00848212, 0.00342323, - 0.930468, 0.725652, 0.586532, 0.479542, 0.393596, 0.322736, 0.26353, 0.213565, 0.171456, 0.135718, 0.105481, 0.0800472, 0.0588117, 0.0412172, 0.0268329, 0.0152799, - 0.833791, 0.671201, 0.558957, 0.471006, 0.398823, 0.337883, 0.285615, 0.240206, 0.200696, 0.16597, 0.135422, 0.10859, 0.0850611, 0.0644477, 0.0464763, 0.0308878, - 0.771692, 0.633819, 0.537877, 0.461939, 0.398865, 0.344892, 0.297895, 0.256371, 0.219562, 0.186548, 0.156842, 0.130095, 0.10598, 0.0841919, 0.0645311, 0.04679, - 0.727979, 0.606373, 0.52141, 0.453769, 0.397174, 0.348337, 0.305403, 0.267056, 0.232655, 0.201398, 0.17286, 0.146756, 0.122808, 0.100751, 0.0804254, 0.0616485, - 0.695353, 0.585281, 0.508227, 0.44667, 0.394925, 0.350027, 0.310302, 0.274561, 0.242236, 0.212604, 0.185281, 0.16002, 0.13657, 0.114693, 0.0942543, 0.0750799, - 0.669981, 0.568519, 0.497442, 0.440542, 0.392567, 0.350786, 0.313656, 0.280075, 0.249533, 0.221359, 0.195196, 0.170824, 0.148012, 0.126537, 0.106279, 0.0870713, - 0.649644, 0.554855, 0.488453, 0.435237, 0.390279, 0.351028, 0.316036, 0.284274, 0.255266, 0.228387, 0.203297, 0.179796, 0.157665, 0.136695, 0.116774, 0.0977403, - 0.632951, 0.543489, 0.480849, 0.430619, 0.388132, 0.350974, 0.317777, 0.287562, 0.259885, 0.234153, 0.210041, 0.187365, 0.165914, 0.145488, 0.125983, 0.10724, - 0.61899, 0.533877, 0.47433, 0.426573, 0.386145, 0.35075, 0.319078, 0.290197, 0.263681, 0.238971, 0.215746, 0.193838, 0.173043, 0.153167, 0.134113, 0.115722, - 0.607131, 0.52564, 0.468678, 0.423001, 0.38432, 0.35043, 0.320072, 0.292349, 0.266856, 0.243055, 0.220636, 0.199438, 0.179264, 0.159926, 0.141332, 0.123323, - 0.596927, 0.518497, 0.463731, 0.419829, 0.382647, 0.350056, 0.320842, 0.294137, 0.269549, 0.246564, 0.224875, 0.204331, 0.18474, 0.165919, 0.147778, 0.130162, - 0.588052, 0.512241, 0.459365, 0.416996, 0.381114, 0.349657, 0.321448, 0.295641, 0.271862, 0.24961, 0.228584, 0.208643, 0.189596, 0.171266, 0.153566, 0.136341, - 0.580257, 0.506717, 0.455481, 0.41445, 0.379708, 0.34925, 0.321929, 0.296923, 0.273869, 0.252279, 0.231859, 0.212472, 0.193933, 0.176066, 0.158788, 0.141945, - 0.573355, 0.5018, 0.452005, 0.412151, 0.378416, 0.348844, 0.322316, 0.298028, 0.275627, 0.254638, 0.234772, 0.215896, 0.197828, 0.180398, 0.163522, 0.147049 - }; - - float x = cosTheta * (SHEEN_ALBEDO_TABLE_SIZE - 1); - float y = roughness * (SHEEN_ALBEDO_TABLE_SIZE - 1); - int ix = int(x); - int iy = int(y); - int ix2 = clamp(ix + 1, 0, SHEEN_ALBEDO_TABLE_SIZE - 1); - int iy2 = clamp(iy + 1, 0, SHEEN_ALBEDO_TABLE_SIZE - 1); - float fx = x - ix; - float fy = y - iy; - - float v1 = mix(_sheenAlbedo[iy * SHEEN_ALBEDO_TABLE_SIZE + ix], _sheenAlbedo[iy * SHEEN_ALBEDO_TABLE_SIZE + ix2], fx); - float v2 = mix(_sheenAlbedo[iy2 * SHEEN_ALBEDO_TABLE_SIZE + ix], _sheenAlbedo[iy2 * SHEEN_ALBEDO_TABLE_SIZE + ix2], fx); - float albedo = mix(v1, v2, fy); - - return clamp(albedo, 0.0, 1.0); -} - -// TODO: Vanilla OSL doesn't have a proper sheen closure, -// so use 'diffuse' scaled by sheen directional albedo for now. -void mx_sheen_bsdf(float weight, color Ks, float roughness, vector N, BSDF base, output BSDF result) -{ - if (weight > M_FLOAT_EPS) - { - // TODO: Normalization should not be needed. My suspicion is that - // BSDF sampling of new outgoing direction in 'testrender' needs - // to be fixed. - vector V = normalize(-I); - - float NdotV = fabs(dot(N,V)); - float alpha = clamp(roughness, M_FLOAT_EPS, 1.0); - float albedo = weight * mx_imageworks_sheen_directional_albedo(NdotV, alpha); - result = albedo * Ks * diffuse(N) + (1.0 - albedo) * base; - } - else - { - result = base; - } -} diff --git a/materialx/libraries/pbrlib/genosl/mx_subsurface_bsdf.osl b/materialx/libraries/pbrlib/genosl/mx_subsurface_bsdf.osl deleted file mode 100644 index 744e2995b..000000000 --- a/materialx/libraries/pbrlib/genosl/mx_subsurface_bsdf.osl +++ /dev/null @@ -1,5 +0,0 @@ -void mx_subsurface_bsdf(float weight, color _color, vector radius, float anisotropy, vector _normal, output BSDF result) -{ - // TODO: Subsurface closure is not supported by vanilla OSL. - result = _color * weight * translucent(_normal); -} diff --git a/materialx/libraries/pbrlib/genosl/mx_surface.osl b/materialx/libraries/pbrlib/genosl/mx_surface.osl deleted file mode 100644 index a997b47fe..000000000 --- a/materialx/libraries/pbrlib/genosl/mx_surface.osl +++ /dev/null @@ -1,5 +0,0 @@ -void mx_surface(BSDF bsdf, EDF edf, float opacity, output surfaceshader result) -{ - float opacity_weight = clamp(opacity, 0.0, 1.0); - result = (bsdf + edf) * opacity_weight + transparent() * (1.0 - opacity_weight); -} diff --git a/materialx/libraries/pbrlib/genosl/mx_translucent_bsdf.inline b/materialx/libraries/pbrlib/genosl/mx_translucent_bsdf.inline deleted file mode 100644 index 34775217a..000000000 --- a/materialx/libraries/pbrlib/genosl/mx_translucent_bsdf.inline +++ /dev/null @@ -1 +0,0 @@ -{{color}} * {{weight}} * translucent({{normal}}) diff --git a/materialx/libraries/pbrlib/genosl/mx_uniform_edf.inline b/materialx/libraries/pbrlib/genosl/mx_uniform_edf.inline deleted file mode 100644 index aabebe91a..000000000 --- a/materialx/libraries/pbrlib/genosl/mx_uniform_edf.inline +++ /dev/null @@ -1 +0,0 @@ -{{color}} * emission() diff --git a/materialx/libraries/pbrlib/genosl/pbrlib_genosl_impl.mtlx b/materialx/libraries/pbrlib/genosl/pbrlib_genosl_impl.mtlx deleted file mode 100644 index 2817aefe3..000000000 --- a/materialx/libraries/pbrlib/genosl/pbrlib_genosl_impl.mtlx +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/materialx/libraries/pbrlib/pbrlib_defs.mtlx b/materialx/libraries/pbrlib/pbrlib_defs.mtlx deleted file mode 100644 index 1ac4df259..000000000 --- a/materialx/libraries/pbrlib/pbrlib_defs.mtlx +++ /dev/null @@ -1,397 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/materialx/libraries/pbrlib/pbrlib_ng.mtlx b/materialx/libraries/pbrlib/pbrlib_ng.mtlx deleted file mode 100644 index fb5c2ab76..000000000 --- a/materialx/libraries/pbrlib/pbrlib_ng.mtlx +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/materialx/libraries/stdlib/genglsl/lib/mx_hsv.glsl b/materialx/libraries/stdlib/genglsl/lib/mx_hsv.glsl deleted file mode 100644 index 923e9eac4..000000000 --- a/materialx/libraries/stdlib/genglsl/lib/mx_hsv.glsl +++ /dev/null @@ -1,91 +0,0 @@ -/* -Color transform functions. - -These funcions are modified versions of the color operators found in Open Shading Language: -github.com/imageworks/OpenShadingLanguage/blob/master/src/liboslexec/opcolor.cpp - -It contains the subset of color operators needed to implement the MaterialX -standard library. The modifications are for conversions from C++ to GLSL. - -Original copyright notice: ------------------------------------------------------------------------- -Copyright (c) 2009-2010 Sony Pictures Imageworks Inc., et al. -All Rights Reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: -* Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -* Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. -* Neither the name of Sony Pictures Imageworks nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ------------------------------------------------------------------------- -*/ - -vec3 mx_hsvtorgb(vec3 hsv) -{ - // Reference for this technique: Foley & van Dam - float h = hsv.x; float s = hsv.y; float v = hsv.z; - if (s < 0.0001f) { - return vec3 (v, v, v); - } else { - h = 6.0f * (h - floor(h)); // expand to [0..6) - int hi = int(trunc(h)); - float f = h - float(hi); - float p = v * (1.0f-s); - float q = v * (1.0f-s*f); - float t = v * (1.0f-s*(1.0f-f)); - if (hi == 0) - return vec3 (v, t, p); - else if (hi == 1) - return vec3 (q, v, p); - else if (hi == 2) - return vec3 (p, v, t); - else if (hi == 3) - return vec3 (p, q, v); - else if (hi == 4) - return vec3 (t, p, v); - return vec3 (v, p, q); - } -} - - -vec3 mx_rgbtohsv(vec3 c) -{ - // See Foley & van Dam - float r = c.x; float g = c.y; float b = c.z; - float mincomp = min (r, min(g, b)); - float maxcomp = max (r, max(g, b)); - float delta = maxcomp - mincomp; // chroma - float h, s, v; - v = maxcomp; - if (maxcomp > 0.0f) - s = delta / maxcomp; - else s = 0.0f; - if (s <= 0.0f) - h = 0.0f; - else { - if (r >= maxcomp) h = (g-b) / delta; - else if (g >= maxcomp) h = 2.0f + (b-r) / delta; - else h = 4.0f + (r-g) / delta; - h *= (1.0f/6.0f); - if (h < 0.0f) - h += 1.0f; - } - return vec3(h, s, v); -} diff --git a/materialx/libraries/stdlib/genglsl/lib/mx_noise.glsl b/materialx/libraries/stdlib/genglsl/lib/mx_noise.glsl deleted file mode 100644 index d1944cd4b..000000000 --- a/materialx/libraries/stdlib/genglsl/lib/mx_noise.glsl +++ /dev/null @@ -1,321 +0,0 @@ -/* -Noise Library. - -This library is a modified version of the noise library found in -Open Shading Language: -github.com/imageworks/OpenShadingLanguage/blob/master/src/include/OSL/oslnoise.h - -It contains the subset of noise types needed to implement the MaterialX -standard library. The modifications are mainly conversions from C++ to GLSL. -Produced results should be identical to the OSL noise functions. - -Original copyright notice: ------------------------------------------------------------------------- -Copyright (c) 2009-2010 Sony Pictures Imageworks Inc., et al. -All Rights Reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: -* Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -* Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. -* Neither the name of Sony Pictures Imageworks nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ------------------------------------------------------------------------- -*/ - -float mx_select(bool b, float t, float f) -{ - return b ? t : f; -} - -float mx_negate_if(float val, bool b) -{ - return b ? -val : val; -} - -int mx_floor(float x) -{ - // return the greatest integer <= x - return x < 0.0 ? int(x) - 1 : int(x); -} - -// return mx_floor as well as the fractional remainder -float mx_floorfrac(float x, out int i) -{ - i = mx_floor(x); - return x - i; -} - -float mx_bilerp(float v0, float v1, float v2, float v3, float s, float t) -{ - float s1 = 1.0 - s; - return (1.0 - t) * (v0*s1 + v1*s) + t * (v2*s1 + v3*s); -} -vec3 mx_bilerp(vec3 v0, vec3 v1, vec3 v2, vec3 v3, float s, float t) -{ - float s1 = 1.0 - s; - return (1.0 - t) * (v0*s1 + v1*s) + t * (v2*s1 + v3*s); -} -float mx_trilerp(float v0, float v1, float v2, float v3, float v4, float v5, float v6, float v7, float s, float t, float r) -{ - float s1 = 1.0 - s; - float t1 = 1.0 - t; - float r1 = 1.0 - r; - return (r1*(t1*(v0*s1 + v1*s) + t*(v2*s1 + v3*s)) + - r*(t1*(v4*s1 + v5*s) + t*(v6*s1 + v7*s))); -} -vec3 mx_trilerp(vec3 v0, vec3 v1, vec3 v2, vec3 v3, vec3 v4, vec3 v5, vec3 v6, vec3 v7, float s, float t, float r) -{ - float s1 = 1.0 - s; - float t1 = 1.0 - t; - float r1 = 1.0 - r; - return (r1*(t1*(v0*s1 + v1*s) + t*(v2*s1 + v3*s)) + - r*(t1*(v4*s1 + v5*s) + t*(v6*s1 + v7*s))); -} - -// 2 and 3 dimensional gradient functions - perform a dot product against a -// randomly chosen vector. Note that the gradient vector is not normalized, but -// this only affects the overal "scale" of the result, so we simply account for -// the scale by multiplying in the corresponding "perlin" function. -float mx_gradient_float(uint hash, float x, float y) -{ - // 8 possible directions (+-1,+-2) and (+-2,+-1) - uint h = hash & 7u; - float u = mx_select(h<4u, x, y); - float v = 2.0 * mx_select(h<4u, y, x); - // compute the dot product with (x,y). - return mx_negate_if(u, bool(h&1u)) + mx_negate_if(v, bool(h&2u)); -} -float mx_gradient_float(uint hash, float x, float y, float z) -{ - // use vectors pointing to the edges of the cube - uint h = hash & 15u; - float u = mx_select(h<8u, x, y); - float v = mx_select(h<4u, y, mx_select((h==12u)||(h==14u), x, z)); - return mx_negate_if(u, bool(h&1u)) + mx_negate_if(v, bool(h&2u)); -} -vec3 mx_gradient_vec3(uvec3 hash, float x, float y) -{ - return vec3(mx_gradient_float(hash.x, x, y), mx_gradient_float(hash.y, x, y), mx_gradient_float(hash.z, x, y)); -} -vec3 mx_gradient_vec3(uvec3 hash, float x, float y, float z) -{ - return vec3(mx_gradient_float(hash.x, x, y, z), mx_gradient_float(hash.y, x, y, z), mx_gradient_float(hash.z, x, y, z)); -} -// Scaling factors to normalize the result of gradients above. -// These factors were experimentally calculated to be: -// 2D: 0.6616 -// 3D: 0.9820 -float mx_gradient_scale2d(float v) { return 0.6616 * v; } -float mx_gradient_scale3d(float v) { return 0.9820 * v; } -vec3 mx_gradient_scale2d(vec3 v) { return 0.6616 * v; } -vec3 mx_gradient_scale3d(vec3 v) { return 0.9820 * v; } - -/// Bitwise circular rotation left by k bits (for 32 bit unsigned integers) -uint mx_rotl32(uint x, int k) -{ - return (x<>(32-k)); -} - -// Mix up and combine the bits of a, b, and c (doesn't change them, but -// returns a hash of those three original values). -uint mx_bjfinal(uint a, uint b, uint c) -{ - c ^= b; c -= mx_rotl32(b,14); - a ^= c; a -= mx_rotl32(c,11); - b ^= a; b -= mx_rotl32(a,25); - c ^= b; c -= mx_rotl32(b,16); - a ^= c; a -= mx_rotl32(c,4); - b ^= a; b -= mx_rotl32(a,14); - c ^= b; c -= mx_rotl32(b,24); - return c; -} - -// Convert a 32 bit integer into a floating point number in [0,1] -float mx_bits_to_01(uint bits) -{ - return float(bits) / float(uint(0xffffffff)); -} - -float mx_fade(float t) -{ - return t * t * t * (t * (t * 6.0 - 15.0) + 10.0); -} - -uint mx_hash_int(int x, int y) -{ - uint len = 2u; - uint a, b, c; - a = b = c = uint(0xdeadbeef) + (len << 2u) + 13u; - a += uint(x); - b += uint(y); - return mx_bjfinal(a, b, c); -} - -uint mx_hash_int(int x, int y, int z) -{ - uint len = 3u; - uint a, b, c; - a = b = c = uint(0xdeadbeef) + (len << 2u) + 13u; - a += uint(x); - b += uint(y); - c += uint(z); - return mx_bjfinal(a, b, c); -} - -uvec3 mx_hash_vec3(int x, int y) -{ - uint h = mx_hash_int(x, y); - // we only need the low-order bits to be random, so split out - // the 32 bit result into 3 parts for each channel - uvec3 result; - result.x = (h ) & 0xFFu; - result.y = (h >> 8 ) & 0xFFu; - result.z = (h >> 16) & 0xFFu; - return result; -} - -uvec3 mx_hash_vec3(int x, int y, int z) -{ - uint h = mx_hash_int(x, y, z); - // we only need the low-order bits to be random, so split out - // the 32 bit result into 3 parts for each channel - uvec3 result; - result.x = (h ) & 0xFFu; - result.y = (h >> 8 ) & 0xFFu; - result.z = (h >> 16) & 0xFFu; - return result; -} - -float mx_perlin_noise_float(vec2 p) -{ - int X, Y; - float fx = mx_floorfrac(p.x, X); - float fy = mx_floorfrac(p.y, Y); - float u = mx_fade(fx); - float v = mx_fade(fy); - float result = mx_bilerp( - mx_gradient_float(mx_hash_int(X , Y ), fx , fy ), - mx_gradient_float(mx_hash_int(X+1, Y ), fx-1.0, fy ), - mx_gradient_float(mx_hash_int(X , Y+1), fx , fy-1.0), - mx_gradient_float(mx_hash_int(X+1, Y+1), fx-1.0, fy-1.0), - u, v); - return mx_gradient_scale2d(result); -} - -float mx_perlin_noise_float(vec3 p) -{ - int X, Y, Z; - float fx = mx_floorfrac(p.x, X); - float fy = mx_floorfrac(p.y, Y); - float fz = mx_floorfrac(p.z, Z); - float u = mx_fade(fx); - float v = mx_fade(fy); - float w = mx_fade(fz); - float result = mx_trilerp( - mx_gradient_float(mx_hash_int(X , Y , Z ), fx , fy , fz ), - mx_gradient_float(mx_hash_int(X+1, Y , Z ), fx-1.0, fy , fz ), - mx_gradient_float(mx_hash_int(X , Y+1, Z ), fx , fy-1.0, fz ), - mx_gradient_float(mx_hash_int(X+1, Y+1, Z ), fx-1.0, fy-1.0, fz ), - mx_gradient_float(mx_hash_int(X , Y , Z+1), fx , fy , fz-1.0), - mx_gradient_float(mx_hash_int(X+1, Y , Z+1), fx-1.0, fy , fz-1.0), - mx_gradient_float(mx_hash_int(X , Y+1, Z+1), fx , fy-1.0, fz-1.0), - mx_gradient_float(mx_hash_int(X+1, Y+1, Z+1), fx-1.0, fy-1.0, fz-1.0), - u, v, w); - return mx_gradient_scale3d(result); -} - -vec3 mx_perlin_noise_vec3(vec2 p) -{ - int X, Y; - float fx = mx_floorfrac(p.x, X); - float fy = mx_floorfrac(p.y, Y); - float u = mx_fade(fx); - float v = mx_fade(fy); - vec3 result = mx_bilerp( - mx_gradient_vec3(mx_hash_vec3(X , Y ), fx , fy ), - mx_gradient_vec3(mx_hash_vec3(X+1, Y ), fx-1.0, fy ), - mx_gradient_vec3(mx_hash_vec3(X , Y+1), fx , fy-1.0), - mx_gradient_vec3(mx_hash_vec3(X+1, Y+1), fx-1.0, fy-1.0), - u, v); - return mx_gradient_scale2d(result); -} - -vec3 mx_perlin_noise_vec3(vec3 p) -{ - int X, Y, Z; - float fx = mx_floorfrac(p.x, X); - float fy = mx_floorfrac(p.y, Y); - float fz = mx_floorfrac(p.z, Z); - float u = mx_fade(fx); - float v = mx_fade(fy); - float w = mx_fade(fz); - vec3 result = mx_trilerp( - mx_gradient_vec3(mx_hash_vec3(X , Y , Z ), fx , fy , fz ), - mx_gradient_vec3(mx_hash_vec3(X+1, Y , Z ), fx-1.0, fy , fz ), - mx_gradient_vec3(mx_hash_vec3(X , Y+1, Z ), fx , fy-1.0, fz ), - mx_gradient_vec3(mx_hash_vec3(X+1, Y+1, Z ), fx-1.0, fy-1.0, fz ), - mx_gradient_vec3(mx_hash_vec3(X , Y , Z+1), fx , fy , fz-1.0), - mx_gradient_vec3(mx_hash_vec3(X+1, Y , Z+1), fx-1.0, fy , fz-1.0), - mx_gradient_vec3(mx_hash_vec3(X , Y+1, Z+1), fx , fy-1.0, fz-1.0), - mx_gradient_vec3(mx_hash_vec3(X+1, Y+1, Z+1), fx-1.0, fy-1.0, fz-1.0), - u, v, w); - return mx_gradient_scale3d(result); -} - -float mx_cell_noise_float(vec2 p) -{ - int ix = mx_floor(p.x); - int iy = mx_floor(p.y); - return mx_bits_to_01(mx_hash_int(ix, iy)); -} - -float mx_cell_noise_float(vec3 p) -{ - int ix = mx_floor(p.x); - int iy = mx_floor(p.y); - int iz = mx_floor(p.z); - return mx_bits_to_01(mx_hash_int(ix, iy, iz)); -} - -float mx_fractal_noise_float(vec3 p, int octaves, float lacunarity, float diminish) -{ - float result = 0.0; - float amplitude = 1.0; - for (int i = 0; i < octaves; ++i) - { - result += amplitude * mx_perlin_noise_float(p); - amplitude *= diminish; - p *= lacunarity; - } - return result; -} - -vec3 mx_fractal_noise_vec3(vec3 p, int octaves, float lacunarity, float diminish) -{ - vec3 result = vec3(0.0); - float amplitude = 1.0; - for (int i = 0; i < octaves; ++i) - { - result += amplitude * mx_perlin_noise_vec3(p); - amplitude *= diminish; - p *= lacunarity; - } - return result; -} diff --git a/materialx/libraries/stdlib/genglsl/lib/mx_sampling.glsl b/materialx/libraries/stdlib/genglsl/lib/mx_sampling.glsl deleted file mode 100644 index f112d0352..000000000 --- a/materialx/libraries/stdlib/genglsl/lib/mx_sampling.glsl +++ /dev/null @@ -1,91 +0,0 @@ -// Restrict to 7x7 kernel size for performance reasons -#define MX_MAX_SAMPLE_COUNT 49 -// Size of all weights for all levels (including level 1) -#define MX_WEIGHT_ARRAY_SIZE 84 - -// -// Function to compute the sample size relative to a texture coordinate -// -vec2 mx_compute_sample_size_uv(vec2 uv, float filterSize, float filterOffset) -{ - vec2 derivUVx = dFdx(uv) * 0.5f; - vec2 derivUVy = dFdy(uv) * 0.5f; - float derivX = abs(derivUVx.x) + abs(derivUVy.x); - float derivY = abs(derivUVx.y) + abs(derivUVy.y); - float sampleSizeU = 2.0f * filterSize * derivX + filterOffset; - if (sampleSizeU < 1.0E-05f) - sampleSizeU = 1.0E-05f; - float sampleSizeV = 2.0f * filterSize * derivY + filterOffset; - if (sampleSizeV < 1.0E-05f) - sampleSizeV = 1.0E-05f; - return vec2(sampleSizeU, sampleSizeV); -} - -// -// Compute a normal mapped to 0..1 space based on a set of input -// samples using a Sobel filter. -// -vec3 mx_normal_from_samples_sobel(float S[9], float _scale) -{ - float nx = S[0] - S[2] + (2.0*S[3]) - (2.0*S[5]) + S[6] - S[8]; - float ny = S[0] + (2.0*S[1]) + S[2] - S[6] - (2.0*S[7]) - S[8]; - float nz = max(_scale, M_FLOAT_EPS) * sqrt(max(1.0 - nx * nx - ny * ny, M_FLOAT_EPS)); - vec3 norm = normalize(vec3(nx, ny, nz)); - return (norm + 1.0) * 0.5; -} - -// -// Apply filter for float samples S, using weights W. -// sampleCount should be a square of a odd number in the range { 1, 3, 5, 7 } -// -float mx_convolution_float(float S[MX_MAX_SAMPLE_COUNT], float W[MX_WEIGHT_ARRAY_SIZE], int offset, int sampleCount) -{ - float result = 0.0; - for (int i = 0; i < sampleCount; i++) - { - result += S[i]*W[i+offset]; - } - return result; -} - -// -// Apply filter for vec2 samples S, using weights W. -// sampleCount should be a square of a odd number in the range { 1, 3, 5, 7 } -// -vec2 mx_convolution_vec2(vec2 S[MX_MAX_SAMPLE_COUNT], float W[MX_WEIGHT_ARRAY_SIZE], int offset, int sampleCount) -{ - vec2 result = vec2(0.0); - for (int i=0; i 1) - { - vec2 uv = mx_transform_uv(texcoord, uv_scale, uv_offset); - result = texture(tex_sampler, uv).rgb; - } - else - { - result = defaultval; - } -} diff --git a/materialx/libraries/stdlib/genglsl/mx_image_color4.glsl b/materialx/libraries/stdlib/genglsl/mx_image_color4.glsl deleted file mode 100644 index 0f5eb1ee9..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_image_color4.glsl +++ /dev/null @@ -1,14 +0,0 @@ -#include "$fileTransformUv" - -void mx_image_color4(sampler2D tex_sampler, int layer, vec4 defaultval, vec2 texcoord, int uaddressmode, int vaddressmode, int filtertype, int framerange, int frameoffset, int frameendaction, vec2 uv_scale, vec2 uv_offset, out vec4 result) -{ - if (textureSize(tex_sampler, 0).x > 1) - { - vec2 uv = mx_transform_uv(texcoord, uv_scale, uv_offset); - result = texture(tex_sampler, uv); - } - else - { - result = defaultval; - } -} diff --git a/materialx/libraries/stdlib/genglsl/mx_image_float.glsl b/materialx/libraries/stdlib/genglsl/mx_image_float.glsl deleted file mode 100644 index f1efe5f23..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_image_float.glsl +++ /dev/null @@ -1,14 +0,0 @@ -#include "$fileTransformUv" - -void mx_image_float(sampler2D tex_sampler, int layer, float defaultval, vec2 texcoord, int uaddressmode, int vaddressmode, int filtertype, int framerange, int frameoffset, int frameendaction, vec2 uv_scale, vec2 uv_offset, out float result) -{ - if (textureSize(tex_sampler, 0).x > 1) - { - vec2 uv = mx_transform_uv(texcoord, uv_scale, uv_offset); - result = texture(tex_sampler, uv).r; - } - else - { - result = defaultval; - } -} diff --git a/materialx/libraries/stdlib/genglsl/mx_image_vector2.glsl b/materialx/libraries/stdlib/genglsl/mx_image_vector2.glsl deleted file mode 100644 index 38739fe8d..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_image_vector2.glsl +++ /dev/null @@ -1,14 +0,0 @@ -#include "$fileTransformUv" - -void mx_image_vector2(sampler2D tex_sampler, int layer, vec2 defaultval, vec2 texcoord, int uaddressmode, int vaddressmode, int filtertype, int framerange, int frameoffset, int frameendaction, vec2 uv_scale, vec2 uv_offset, out vec2 result) -{ - if (textureSize(tex_sampler, 0).x > 1) - { - vec2 uv = mx_transform_uv(texcoord, uv_scale, uv_offset); - result = texture(tex_sampler, uv).rg; - } - else - { - result = defaultval; - } -} diff --git a/materialx/libraries/stdlib/genglsl/mx_image_vector3.glsl b/materialx/libraries/stdlib/genglsl/mx_image_vector3.glsl deleted file mode 100644 index dbb7b26a2..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_image_vector3.glsl +++ /dev/null @@ -1,14 +0,0 @@ -#include "$fileTransformUv" - -void mx_image_vector3(sampler2D tex_sampler, int layer, vec3 defaultval, vec2 texcoord, int uaddressmode, int vaddressmode, int filtertype, int framerange, int frameoffset, int frameendaction, vec2 uv_scale, vec2 uv_offset, out vec3 result) -{ - if (textureSize(tex_sampler, 0).x > 1) - { - vec2 uv = mx_transform_uv(texcoord, uv_scale, uv_offset); - result = texture(tex_sampler, uv).rgb; - } - else - { - result = defaultval; - } -} diff --git a/materialx/libraries/stdlib/genglsl/mx_image_vector4.glsl b/materialx/libraries/stdlib/genglsl/mx_image_vector4.glsl deleted file mode 100644 index a1fc7ffda..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_image_vector4.glsl +++ /dev/null @@ -1,14 +0,0 @@ -#include "$fileTransformUv" - -void mx_image_vector4(sampler2D tex_sampler, int layer, vec4 defaultval, vec2 texcoord, int uaddressmode, int vaddressmode, int filtertype, int framerange, int frameoffset, int frameendaction, vec2 uv_scale, vec2 uv_offset, out vec4 result) -{ - if (textureSize(tex_sampler, 0).x > 1) - { - vec2 uv = mx_transform_uv(texcoord, uv_scale, uv_offset); - result = texture(tex_sampler, uv); - } - else - { - result = defaultval; - } -} diff --git a/materialx/libraries/stdlib/genglsl/mx_in_color4.inline b/materialx/libraries/stdlib/genglsl/mx_in_color4.inline deleted file mode 100644 index 6c55bfb9a..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_in_color4.inline +++ /dev/null @@ -1 +0,0 @@ -({{fg}}*{{bg}}.a * {{mix}}) + ({{bg}} * (1.0-{{mix}})); diff --git a/materialx/libraries/stdlib/genglsl/mx_inside.inline b/materialx/libraries/stdlib/genglsl/mx_inside.inline deleted file mode 100644 index 9109f03f0..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_inside.inline +++ /dev/null @@ -1 +0,0 @@ -{{in}} * {{mask}} diff --git a/materialx/libraries/stdlib/genglsl/mx_invert.inline b/materialx/libraries/stdlib/genglsl/mx_invert.inline deleted file mode 100644 index 79af688a4..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_invert.inline +++ /dev/null @@ -1 +0,0 @@ -{{amount}} - {{in}} diff --git a/materialx/libraries/stdlib/genglsl/mx_invertM.inline b/materialx/libraries/stdlib/genglsl/mx_invertM.inline deleted file mode 100644 index 55e50dd15..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_invertM.inline +++ /dev/null @@ -1 +0,0 @@ -inverse({{in}}) diff --git a/materialx/libraries/stdlib/genglsl/mx_ln.inline b/materialx/libraries/stdlib/genglsl/mx_ln.inline deleted file mode 100644 index 2edf9002a..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_ln.inline +++ /dev/null @@ -1 +0,0 @@ -log({{in}}) diff --git a/materialx/libraries/stdlib/genglsl/mx_luminance_color3.glsl b/materialx/libraries/stdlib/genglsl/mx_luminance_color3.glsl deleted file mode 100644 index d60ba93a6..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_luminance_color3.glsl +++ /dev/null @@ -1,4 +0,0 @@ -void mx_luminance_color3(vec3 _in, vec3 lumacoeffs, out vec3 result) -{ - result = vec3(dot(_in, lumacoeffs)); -} diff --git a/materialx/libraries/stdlib/genglsl/mx_luminance_color4.glsl b/materialx/libraries/stdlib/genglsl/mx_luminance_color4.glsl deleted file mode 100644 index 28e794300..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_luminance_color4.glsl +++ /dev/null @@ -1,4 +0,0 @@ -void mx_luminance_color4(vec4 _in, vec3 lumacoeffs, out vec4 result) -{ - result = vec4(vec3(dot(_in.rgb, lumacoeffs)), _in.a); -} diff --git a/materialx/libraries/stdlib/genglsl/mx_magnitude.inline b/materialx/libraries/stdlib/genglsl/mx_magnitude.inline deleted file mode 100644 index 6316e30aa..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_magnitude.inline +++ /dev/null @@ -1 +0,0 @@ -length({{in}}) diff --git a/materialx/libraries/stdlib/genglsl/mx_mask_color4.inline b/materialx/libraries/stdlib/genglsl/mx_mask_color4.inline deleted file mode 100644 index 208c52e46..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_mask_color4.inline +++ /dev/null @@ -1 +0,0 @@ -({{bg}}*{{fg}}.a * {{mix}}) + ({{bg}} * (1.0-{{mix}})); diff --git a/materialx/libraries/stdlib/genglsl/mx_matte_color4.inline b/materialx/libraries/stdlib/genglsl/mx_matte_color4.inline deleted file mode 100644 index b83873554..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_matte_color4.inline +++ /dev/null @@ -1 +0,0 @@ -vec4( {{fg}}.xyz*{{fg}}.w + {{bg}}.xyz*(1.0-{{fg}}.w), {{fg}}.w + ({{bg}}.w*(1.0-{{fg}}.w)) ) * {{mix}} + ({{bg}} * (1.0-{{mix}})); diff --git a/materialx/libraries/stdlib/genglsl/mx_max.inline b/materialx/libraries/stdlib/genglsl/mx_max.inline deleted file mode 100644 index 21f1cb084..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_max.inline +++ /dev/null @@ -1 +0,0 @@ -max({{in1}}, {{in2}}) diff --git a/materialx/libraries/stdlib/genglsl/mx_min.inline b/materialx/libraries/stdlib/genglsl/mx_min.inline deleted file mode 100644 index 58fb42416..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_min.inline +++ /dev/null @@ -1 +0,0 @@ -min({{in1}}, {{in2}}) diff --git a/materialx/libraries/stdlib/genglsl/mx_minus.inline b/materialx/libraries/stdlib/genglsl/mx_minus.inline deleted file mode 100644 index 82f6094ed..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_minus.inline +++ /dev/null @@ -1 +0,0 @@ -({{mix}}*({{bg}} - {{fg}})) + ((1.0-{{mix}})*{{bg}}) diff --git a/materialx/libraries/stdlib/genglsl/mx_mix.inline b/materialx/libraries/stdlib/genglsl/mx_mix.inline deleted file mode 100644 index e06e87be5..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_mix.inline +++ /dev/null @@ -1 +0,0 @@ -mix({{bg}}, {{fg}}, {{mix}}) diff --git a/materialx/libraries/stdlib/genglsl/mx_mix_surfaceshader.glsl b/materialx/libraries/stdlib/genglsl/mx_mix_surfaceshader.glsl deleted file mode 100644 index 4ae6a0b44..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_mix_surfaceshader.glsl +++ /dev/null @@ -1,5 +0,0 @@ -void mx_mix_surfaceshader(surfaceshader fg, surfaceshader bg, float w, out surfaceshader returnshader) -{ - returnshader.color = mix(bg.color, fg.color, w); - returnshader.transparency = mix(bg.transparency, fg.transparency, w); -} diff --git a/materialx/libraries/stdlib/genglsl/mx_modulo.inline b/materialx/libraries/stdlib/genglsl/mx_modulo.inline deleted file mode 100644 index 5d652aa4e..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_modulo.inline +++ /dev/null @@ -1 +0,0 @@ -mod({{in1}}, {{in2}}) diff --git a/materialx/libraries/stdlib/genglsl/mx_multiply.inline b/materialx/libraries/stdlib/genglsl/mx_multiply.inline deleted file mode 100644 index 4c4799f44..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_multiply.inline +++ /dev/null @@ -1 +0,0 @@ -{{in1}} * {{in2}} diff --git a/materialx/libraries/stdlib/genglsl/mx_multiply_surfaceshader_color3.glsl b/materialx/libraries/stdlib/genglsl/mx_multiply_surfaceshader_color3.glsl deleted file mode 100644 index dfdb04132..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_multiply_surfaceshader_color3.glsl +++ /dev/null @@ -1,5 +0,0 @@ -void mx_multiply_surfaceshader_color3(surfaceshader shader1, vec3 value, out surfaceshader returnshader) -{ - returnshader.color = shader1.color * value; - returnshader.transparency = shader1.transparency; -} diff --git a/materialx/libraries/stdlib/genglsl/mx_multiply_surfaceshader_float.glsl b/materialx/libraries/stdlib/genglsl/mx_multiply_surfaceshader_float.glsl deleted file mode 100644 index 198b1a10d..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_multiply_surfaceshader_float.glsl +++ /dev/null @@ -1,5 +0,0 @@ -void mx_multiply_surfaceshader_float(surfaceshader shader1, float value, out surfaceshader returnshader) -{ - returnshader.color = shader1.color * vec3(value); - returnshader.transparency = shader1.transparency * value; -} diff --git a/materialx/libraries/stdlib/genglsl/mx_noise2d_fa_vector2.glsl b/materialx/libraries/stdlib/genglsl/mx_noise2d_fa_vector2.glsl deleted file mode 100644 index 6441cf9d0..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_noise2d_fa_vector2.glsl +++ /dev/null @@ -1,7 +0,0 @@ -#include "stdlib/genglsl/lib/mx_noise.glsl" - -void mx_noise2d_fa_vector2(float amplitude, float pivot, vec2 texcoord, out vec2 result) -{ - vec3 value = mx_perlin_noise_vec3(texcoord); - result = value.xy * amplitude + pivot; -} diff --git a/materialx/libraries/stdlib/genglsl/mx_noise2d_fa_vector3.glsl b/materialx/libraries/stdlib/genglsl/mx_noise2d_fa_vector3.glsl deleted file mode 100644 index 2d1dd3279..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_noise2d_fa_vector3.glsl +++ /dev/null @@ -1,7 +0,0 @@ -#include "stdlib/genglsl/lib/mx_noise.glsl" - -void mx_noise2d_fa_vector3(float amplitude, float pivot, vec2 texcoord, out vec3 result) -{ - vec3 value = mx_perlin_noise_vec3(texcoord); - result = value * amplitude + pivot; -} diff --git a/materialx/libraries/stdlib/genglsl/mx_noise2d_fa_vector4.glsl b/materialx/libraries/stdlib/genglsl/mx_noise2d_fa_vector4.glsl deleted file mode 100644 index fd8e245d8..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_noise2d_fa_vector4.glsl +++ /dev/null @@ -1,8 +0,0 @@ -#include "stdlib/genglsl/lib/mx_noise.glsl" - -void mx_noise2d_fa_vector4(float amplitude, float pivot, vec2 texcoord, out vec4 result) -{ - vec3 xyz = mx_perlin_noise_vec3(texcoord); - float w = mx_perlin_noise_float(texcoord + vec2(19, 73)); - result = vec4(xyz, w) * amplitude + pivot; -} diff --git a/materialx/libraries/stdlib/genglsl/mx_noise2d_float.glsl b/materialx/libraries/stdlib/genglsl/mx_noise2d_float.glsl deleted file mode 100644 index be780c40e..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_noise2d_float.glsl +++ /dev/null @@ -1,7 +0,0 @@ -#include "stdlib/genglsl/lib/mx_noise.glsl" - -void mx_noise2d_float(float amplitude, float pivot, vec2 texcoord, out float result) -{ - float value = mx_perlin_noise_float(texcoord); - result = value * amplitude + pivot; -} diff --git a/materialx/libraries/stdlib/genglsl/mx_noise2d_vector2.glsl b/materialx/libraries/stdlib/genglsl/mx_noise2d_vector2.glsl deleted file mode 100644 index 8a3831aa5..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_noise2d_vector2.glsl +++ /dev/null @@ -1,7 +0,0 @@ -#include "stdlib/genglsl/lib/mx_noise.glsl" - -void mx_noise2d_vector2(vec2 amplitude, float pivot, vec2 texcoord, out vec2 result) -{ - vec3 value = mx_perlin_noise_vec3(texcoord); - result = value.xy * amplitude + pivot; -} diff --git a/materialx/libraries/stdlib/genglsl/mx_noise2d_vector3.glsl b/materialx/libraries/stdlib/genglsl/mx_noise2d_vector3.glsl deleted file mode 100644 index 264c271cb..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_noise2d_vector3.glsl +++ /dev/null @@ -1,7 +0,0 @@ -#include "stdlib/genglsl/lib/mx_noise.glsl" - -void mx_noise2d_vector3(vec3 amplitude, float pivot, vec2 texcoord, out vec3 result) -{ - vec3 value = mx_perlin_noise_vec3(texcoord); - result = value * amplitude + pivot; -} diff --git a/materialx/libraries/stdlib/genglsl/mx_noise2d_vector4.glsl b/materialx/libraries/stdlib/genglsl/mx_noise2d_vector4.glsl deleted file mode 100644 index a7133e3e0..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_noise2d_vector4.glsl +++ /dev/null @@ -1,8 +0,0 @@ -#include "stdlib/genglsl/lib/mx_noise.glsl" - -void mx_noise2d_vector4(vec4 amplitude, float pivot, vec2 texcoord, out vec4 result) -{ - vec3 xyz = mx_perlin_noise_vec3(texcoord); - float w = mx_perlin_noise_float(texcoord + vec2(19, 73)); - result = vec4(xyz, w) * amplitude + pivot; -} diff --git a/materialx/libraries/stdlib/genglsl/mx_noise3d_fa_vector2.glsl b/materialx/libraries/stdlib/genglsl/mx_noise3d_fa_vector2.glsl deleted file mode 100644 index 0a6421723..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_noise3d_fa_vector2.glsl +++ /dev/null @@ -1,7 +0,0 @@ -#include "stdlib/genglsl/lib/mx_noise.glsl" - -void mx_noise3d_fa_vector2(float amplitude, float pivot, vec3 position, out vec2 result) -{ - vec3 value = mx_perlin_noise_vec3(position); - result = value.xy * amplitude + pivot; -} diff --git a/materialx/libraries/stdlib/genglsl/mx_noise3d_fa_vector3.glsl b/materialx/libraries/stdlib/genglsl/mx_noise3d_fa_vector3.glsl deleted file mode 100644 index 4c03ed74a..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_noise3d_fa_vector3.glsl +++ /dev/null @@ -1,7 +0,0 @@ -#include "stdlib/genglsl/lib/mx_noise.glsl" - -void mx_noise3d_fa_vector3(float amplitude, float pivot, vec3 position, out vec3 result) -{ - vec3 value = mx_perlin_noise_vec3(position); - result = value * amplitude + pivot; -} diff --git a/materialx/libraries/stdlib/genglsl/mx_noise3d_fa_vector4.glsl b/materialx/libraries/stdlib/genglsl/mx_noise3d_fa_vector4.glsl deleted file mode 100644 index d33f7f9a1..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_noise3d_fa_vector4.glsl +++ /dev/null @@ -1,8 +0,0 @@ -#include "stdlib/genglsl/lib/mx_noise.glsl" - -void mx_noise3d_fa_vector4(float amplitude, float pivot, vec3 position, out vec4 result) -{ - vec3 xyz = mx_perlin_noise_vec3(position); - float w = mx_perlin_noise_float(position + vec3(19, 73, 29)); - result = vec4(xyz, w) * amplitude + pivot; -} diff --git a/materialx/libraries/stdlib/genglsl/mx_noise3d_float.glsl b/materialx/libraries/stdlib/genglsl/mx_noise3d_float.glsl deleted file mode 100644 index 980327340..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_noise3d_float.glsl +++ /dev/null @@ -1,7 +0,0 @@ -#include "stdlib/genglsl/lib/mx_noise.glsl" - -void mx_noise3d_float(float amplitude, float pivot, vec3 position, out float result) -{ - float value = mx_perlin_noise_float(position); - result = value * amplitude + pivot; -} diff --git a/materialx/libraries/stdlib/genglsl/mx_noise3d_vector2.glsl b/materialx/libraries/stdlib/genglsl/mx_noise3d_vector2.glsl deleted file mode 100644 index 564eb4b4d..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_noise3d_vector2.glsl +++ /dev/null @@ -1,7 +0,0 @@ -#include "stdlib/genglsl/lib/mx_noise.glsl" - -void mx_noise3d_vector2(vec2 amplitude, float pivot, vec3 position, out vec2 result) -{ - vec3 value = mx_perlin_noise_vec3(position); - result = value.xy * amplitude + pivot; -} diff --git a/materialx/libraries/stdlib/genglsl/mx_noise3d_vector3.glsl b/materialx/libraries/stdlib/genglsl/mx_noise3d_vector3.glsl deleted file mode 100644 index 6c304e6dc..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_noise3d_vector3.glsl +++ /dev/null @@ -1,7 +0,0 @@ -#include "stdlib/genglsl/lib/mx_noise.glsl" - -void mx_noise3d_vector3(vec3 amplitude, float pivot, vec3 position, out vec3 result) -{ - vec3 value = mx_perlin_noise_vec3(position); - result = value * amplitude + pivot; -} diff --git a/materialx/libraries/stdlib/genglsl/mx_noise3d_vector4.glsl b/materialx/libraries/stdlib/genglsl/mx_noise3d_vector4.glsl deleted file mode 100644 index 21bbb405f..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_noise3d_vector4.glsl +++ /dev/null @@ -1,8 +0,0 @@ -#include "stdlib/genglsl/lib/mx_noise.glsl" - -void mx_noise3d_vector4(vec4 amplitude, float pivot, vec3 position, out vec4 result) -{ - vec3 xyz = mx_perlin_noise_vec3(position); - float w = mx_perlin_noise_float(position + vec3(19, 73, 29)); - result = vec4(xyz, w) * amplitude + pivot; -} diff --git a/materialx/libraries/stdlib/genglsl/mx_normalize.inline b/materialx/libraries/stdlib/genglsl/mx_normalize.inline deleted file mode 100644 index debdc12ab..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_normalize.inline +++ /dev/null @@ -1 +0,0 @@ -normalize({{in}}) diff --git a/materialx/libraries/stdlib/genglsl/mx_normalmap.glsl b/materialx/libraries/stdlib/genglsl/mx_normalmap.glsl deleted file mode 100644 index a6c5b39ac..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_normalmap.glsl +++ /dev/null @@ -1,16 +0,0 @@ -void mx_normalmap(vec3 value, int map_space, float normal_scale, vec3 N, vec3 T, out vec3 result) -{ - // Tangent space - if (map_space == 0) - { - vec3 v = value * 2.0 - 1.0; - vec3 B = normalize(cross(N, T)); - result = normalize(T * v.x * normal_scale + B * v.y * normal_scale + N * v.z); - } - // Object space - else - { - vec3 n = value * 2.0 - 1.0; - result = normalize(n); - } -} diff --git a/materialx/libraries/stdlib/genglsl/mx_out_color2.inline b/materialx/libraries/stdlib/genglsl/mx_out_color2.inline deleted file mode 100644 index 90e911989..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_out_color2.inline +++ /dev/null @@ -1 +0,0 @@ -({{fg}}*(1.0-{{bg}}.g) * {{mix}}) + ({{bg}} * (1.0-{{mix}})); diff --git a/materialx/libraries/stdlib/genglsl/mx_out_color4.inline b/materialx/libraries/stdlib/genglsl/mx_out_color4.inline deleted file mode 100644 index 5bd0cbde2..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_out_color4.inline +++ /dev/null @@ -1 +0,0 @@ -({{fg}}*(1.0-{{bg}}.a) * {{mix}}) + ({{bg}} * (1.0-{{mix}})); diff --git a/materialx/libraries/stdlib/genglsl/mx_outside.inline b/materialx/libraries/stdlib/genglsl/mx_outside.inline deleted file mode 100644 index 73a388ad7..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_outside.inline +++ /dev/null @@ -1 +0,0 @@ -{{in}} * (1.0 - {{mask}}) diff --git a/materialx/libraries/stdlib/genglsl/mx_over_color2.inline b/materialx/libraries/stdlib/genglsl/mx_over_color2.inline deleted file mode 100644 index b0a1e49c3..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_over_color2.inline +++ /dev/null @@ -1 +0,0 @@ -({{fg}} + ({{bg}}*(1.0-{{fg}}[1]))) * {{mix}} + {{bg}} * (1.0-{{mix}}) \ No newline at end of file diff --git a/materialx/libraries/stdlib/genglsl/mx_over_color4.inline b/materialx/libraries/stdlib/genglsl/mx_over_color4.inline deleted file mode 100644 index e6e8f671e..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_over_color4.inline +++ /dev/null @@ -1 +0,0 @@ -({{fg}} + ({{bg}}*(1.0-{{fg}}[3]))) * {{mix}} + {{bg}} * (1.0-{{mix}}) diff --git a/materialx/libraries/stdlib/genglsl/mx_overlay.glsl b/materialx/libraries/stdlib/genglsl/mx_overlay.glsl deleted file mode 100644 index fb9f42a24..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_overlay.glsl +++ /dev/null @@ -1,25 +0,0 @@ -float mx_overlay(float fg, float bg) -{ - return (fg < 0.5) ? (2 * fg * bg) : (1 - (1 - fg) * (1 - bg)); -} - -vec2 mx_overlay(vec2 fg, vec2 bg) -{ - return vec2(mx_overlay(fg.r, bg.r), - mx_overlay(fg.g, bg.g)); -} - -vec3 mx_overlay(vec3 fg, vec3 bg) -{ - return vec3(mx_overlay(fg.r, bg.r), - mx_overlay(fg.g, bg.g), - mx_overlay(fg.b, bg.b)); -} - -vec4 mx_overlay(vec4 fg, vec4 bg) -{ - return vec4(mx_overlay(fg.r, bg.r), - mx_overlay(fg.g, bg.g), - mx_overlay(fg.b, bg.b), - mx_overlay(fg.a, bg.a)); -} diff --git a/materialx/libraries/stdlib/genglsl/mx_overlay_color3.glsl b/materialx/libraries/stdlib/genglsl/mx_overlay_color3.glsl deleted file mode 100644 index 8fb062519..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_overlay_color3.glsl +++ /dev/null @@ -1,6 +0,0 @@ -#include "stdlib/genglsl/mx_overlay.glsl" - -void mx_overlay_color3(vec3 fg, vec3 bg, float mix, out vec3 result) -{ - result = mix * mx_overlay(fg, bg) + (1-mix) * bg; -} diff --git a/materialx/libraries/stdlib/genglsl/mx_overlay_color4.glsl b/materialx/libraries/stdlib/genglsl/mx_overlay_color4.glsl deleted file mode 100644 index 7b18db17b..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_overlay_color4.glsl +++ /dev/null @@ -1,6 +0,0 @@ -#include "stdlib/genglsl/mx_overlay.glsl" - -void mx_overlay_color4(vec4 fg, vec4 bg, float mix, out vec4 result) -{ - result = mix * mx_overlay(fg, bg) + (1-mix) * bg; -} diff --git a/materialx/libraries/stdlib/genglsl/mx_overlay_float.inline b/materialx/libraries/stdlib/genglsl/mx_overlay_float.inline deleted file mode 100644 index 654aba2d3..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_overlay_float.inline +++ /dev/null @@ -1 +0,0 @@ -({{fg}} < 0.5) ? ({{mix}}*2.0*{{fg}}*{{bg}}) + ((1.0-{{mix}})*{{bg}}) : ({{mix}}*(1.0-(1.0-{{fg}})*(1.0-{{bg}}))) + ((1.0-{{mix}})*{{bg}}) diff --git a/materialx/libraries/stdlib/genglsl/mx_plus.inline b/materialx/libraries/stdlib/genglsl/mx_plus.inline deleted file mode 100644 index bc5a3f6b1..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_plus.inline +++ /dev/null @@ -1 +0,0 @@ -({{mix}}*({{bg}} + {{fg}})) + ((1.0-{{mix}})*{{bg}}) diff --git a/materialx/libraries/stdlib/genglsl/mx_power.inline b/materialx/libraries/stdlib/genglsl/mx_power.inline deleted file mode 100644 index b48b1a2e2..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_power.inline +++ /dev/null @@ -1 +0,0 @@ -pow({{in1}}, {{in2}}) diff --git a/materialx/libraries/stdlib/genglsl/mx_power_color3_float.inline b/materialx/libraries/stdlib/genglsl/mx_power_color3_float.inline deleted file mode 100644 index 019e4ef92..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_power_color3_float.inline +++ /dev/null @@ -1 +0,0 @@ -pow({{in1}}, vec3({{in2}})) diff --git a/materialx/libraries/stdlib/genglsl/mx_power_color4_float.inline b/materialx/libraries/stdlib/genglsl/mx_power_color4_float.inline deleted file mode 100644 index 386f2baa9..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_power_color4_float.inline +++ /dev/null @@ -1 +0,0 @@ -pow({{in1}}, vec4({{in2}})) diff --git a/materialx/libraries/stdlib/genglsl/mx_power_vector2_float.inline b/materialx/libraries/stdlib/genglsl/mx_power_vector2_float.inline deleted file mode 100644 index 93f21bc37..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_power_vector2_float.inline +++ /dev/null @@ -1 +0,0 @@ -pow({{in1}}, vec2({{in2}})) diff --git a/materialx/libraries/stdlib/genglsl/mx_power_vector3_float.inline b/materialx/libraries/stdlib/genglsl/mx_power_vector3_float.inline deleted file mode 100644 index 019e4ef92..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_power_vector3_float.inline +++ /dev/null @@ -1 +0,0 @@ -pow({{in1}}, vec3({{in2}})) diff --git a/materialx/libraries/stdlib/genglsl/mx_power_vector4_float.inline b/materialx/libraries/stdlib/genglsl/mx_power_vector4_float.inline deleted file mode 100644 index 386f2baa9..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_power_vector4_float.inline +++ /dev/null @@ -1 +0,0 @@ -pow({{in1}}, vec4({{in2}})) diff --git a/materialx/libraries/stdlib/genglsl/mx_premult_color4.glsl b/materialx/libraries/stdlib/genglsl/mx_premult_color4.glsl deleted file mode 100644 index 0f45c3967..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_premult_color4.glsl +++ /dev/null @@ -1,4 +0,0 @@ -void mx_premult_color4(vec4 _in, out vec4 result) -{ - result = vec4(_in.rgb * _in.a, _in.a); -} diff --git a/materialx/libraries/stdlib/genglsl/mx_ramplr_float.glsl b/materialx/libraries/stdlib/genglsl/mx_ramplr_float.glsl deleted file mode 100644 index d19df8f75..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_ramplr_float.glsl +++ /dev/null @@ -1,4 +0,0 @@ -void mx_ramplr_float(float valuel, float valuer, vec2 texcoord, out float result) -{ - result = mix (valuel, valuer, clamp(texcoord.x, 0, 1) ); -} diff --git a/materialx/libraries/stdlib/genglsl/mx_ramplr_vector2.glsl b/materialx/libraries/stdlib/genglsl/mx_ramplr_vector2.glsl deleted file mode 100644 index 58b99a92d..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_ramplr_vector2.glsl +++ /dev/null @@ -1,4 +0,0 @@ -void mx_ramplr_vector2(vec2 valuel, vec2 valuer, vec2 texcoord, out vec2 result) -{ - result = mix (valuel, valuer, clamp(texcoord.x, 0, 1) ); -} diff --git a/materialx/libraries/stdlib/genglsl/mx_ramplr_vector3.glsl b/materialx/libraries/stdlib/genglsl/mx_ramplr_vector3.glsl deleted file mode 100644 index 1bf476173..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_ramplr_vector3.glsl +++ /dev/null @@ -1,4 +0,0 @@ -void mx_ramplr_vector3(vec3 valuel, vec3 valuer, vec2 texcoord, out vec3 result) -{ - result = mix (valuel, valuer, clamp(texcoord.x, 0, 1) ); -} diff --git a/materialx/libraries/stdlib/genglsl/mx_ramplr_vector4.glsl b/materialx/libraries/stdlib/genglsl/mx_ramplr_vector4.glsl deleted file mode 100644 index 458a2d749..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_ramplr_vector4.glsl +++ /dev/null @@ -1,4 +0,0 @@ -void mx_ramplr_vector4(vec4 valuel, vec4 valuer, vec2 texcoord, out vec4 result) -{ - result = mix (valuel, valuer, clamp(texcoord.x, 0, 1) ); -} diff --git a/materialx/libraries/stdlib/genglsl/mx_ramptb_float.glsl b/materialx/libraries/stdlib/genglsl/mx_ramptb_float.glsl deleted file mode 100644 index 41d854650..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_ramptb_float.glsl +++ /dev/null @@ -1,4 +0,0 @@ -void mx_ramptb_float(float valuet, float valueb, vec2 texcoord, out float result) -{ - result = mix (valuet, valueb, clamp(texcoord.y, 0, 1) ); -} diff --git a/materialx/libraries/stdlib/genglsl/mx_ramptb_vector2.glsl b/materialx/libraries/stdlib/genglsl/mx_ramptb_vector2.glsl deleted file mode 100644 index f305eb652..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_ramptb_vector2.glsl +++ /dev/null @@ -1,4 +0,0 @@ -void mx_ramptb_vector2(vec2 valuet, vec2 valueb, vec2 texcoord, out vec2 result) -{ - result = mix (valuet, valueb, clamp(texcoord.y, 0, 1) ); -} diff --git a/materialx/libraries/stdlib/genglsl/mx_ramptb_vector3.glsl b/materialx/libraries/stdlib/genglsl/mx_ramptb_vector3.glsl deleted file mode 100644 index 870049f54..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_ramptb_vector3.glsl +++ /dev/null @@ -1,4 +0,0 @@ -void mx_ramptb_vector3(vec3 valuet, vec3 valueb, vec2 texcoord, out vec3 result) -{ - result = mix (valuet, valueb, clamp(texcoord.y, 0, 1) ); -} diff --git a/materialx/libraries/stdlib/genglsl/mx_ramptb_vector4.glsl b/materialx/libraries/stdlib/genglsl/mx_ramptb_vector4.glsl deleted file mode 100644 index 367daae36..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_ramptb_vector4.glsl +++ /dev/null @@ -1,4 +0,0 @@ -void mx_ramptb_vector4(vec4 valuet, vec4 valueb, vec2 texcoord, out vec4 result) -{ - result = mix (valuet, valueb, clamp(texcoord.y, 0, 1) ); -} diff --git a/materialx/libraries/stdlib/genglsl/mx_remap.inline b/materialx/libraries/stdlib/genglsl/mx_remap.inline deleted file mode 100644 index 540fe770e..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_remap.inline +++ /dev/null @@ -1 +0,0 @@ -{{outlow}} + ({{in}} - {{inlow}}) * ({{outhigh}} - {{outlow}}) / ({{inhigh}} - {{inlow}}) diff --git a/materialx/libraries/stdlib/genglsl/mx_rgbtohsv_color3.glsl b/materialx/libraries/stdlib/genglsl/mx_rgbtohsv_color3.glsl deleted file mode 100644 index c49b0f889..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_rgbtohsv_color3.glsl +++ /dev/null @@ -1,6 +0,0 @@ -#include "stdlib/genglsl/lib/mx_hsv.glsl" - -void mx_rgbtohsv_color3(vec3 _in, out vec3 result) -{ - result = mx_rgbtohsv(_in); -} diff --git a/materialx/libraries/stdlib/genglsl/mx_rgbtohsv_color4.glsl b/materialx/libraries/stdlib/genglsl/mx_rgbtohsv_color4.glsl deleted file mode 100644 index 7cb931f8f..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_rgbtohsv_color4.glsl +++ /dev/null @@ -1,6 +0,0 @@ -#include "stdlib/genglsl/lib/mx_hsv.glsl" - -void mx_rgbtohsv_color4(vec4 _in, out vec4 result) -{ - result = vec4(mx_rgbtohsv(_in.rgb), 1.0); -} diff --git a/materialx/libraries/stdlib/genglsl/mx_rotate_vector2.glsl b/materialx/libraries/stdlib/genglsl/mx_rotate_vector2.glsl deleted file mode 100644 index a66c17d0a..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_rotate_vector2.glsl +++ /dev/null @@ -1,7 +0,0 @@ -void mx_rotate_vector2(vec2 _in, float amount, out vec2 result) -{ - float rotationRadians = radians(amount); - float sa = sin(rotationRadians); - float ca = cos(rotationRadians); - result = vec2(ca*_in.x + sa*_in.y, -sa*_in.x + ca*_in.y); -} diff --git a/materialx/libraries/stdlib/genglsl/mx_rotate_vector3.glsl b/materialx/libraries/stdlib/genglsl/mx_rotate_vector3.glsl deleted file mode 100644 index fb06e120e..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_rotate_vector3.glsl +++ /dev/null @@ -1,19 +0,0 @@ -mat4 mx_rotationMatrix(vec3 axis, float angle) -{ - axis = normalize(axis); - float s = sin(angle); - float c = cos(angle); - float oc = 1.0 - c; - - return mat4(oc * axis.x * axis.x + c, oc * axis.x * axis.y - axis.z * s, oc * axis.z * axis.x + axis.y * s, 0.0, - oc * axis.x * axis.y + axis.z * s, oc * axis.y * axis.y + c, oc * axis.y * axis.z - axis.x * s, 0.0, - oc * axis.z * axis.x - axis.y * s, oc * axis.y * axis.z + axis.x * s, oc * axis.z * axis.z + c, 0.0, - 0.0, 0.0, 0.0, 1.0); -} - -void mx_rotate_vector3(vec3 _in, float amount, vec3 axis, out vec3 result) -{ - float rotationRadians = radians(amount); - mat4 m = mx_rotationMatrix(axis, rotationRadians); - result = (m * vec4(_in, 1.0)).xyz; -} diff --git a/materialx/libraries/stdlib/genglsl/mx_screen.inline b/materialx/libraries/stdlib/genglsl/mx_screen.inline deleted file mode 100644 index 741b58d95..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_screen.inline +++ /dev/null @@ -1 +0,0 @@ -({{mix}}*((1.0 - (1.0 - {{fg}})) * (1 - {{bg}}))) + ((1.0-{{mix}})*{{bg}}) diff --git a/materialx/libraries/stdlib/genglsl/mx_sign.inline b/materialx/libraries/stdlib/genglsl/mx_sign.inline deleted file mode 100644 index 46e9499cd..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_sign.inline +++ /dev/null @@ -1 +0,0 @@ -sign({{in}}) diff --git a/materialx/libraries/stdlib/genglsl/mx_sin.inline b/materialx/libraries/stdlib/genglsl/mx_sin.inline deleted file mode 100644 index 8bf8c865a..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_sin.inline +++ /dev/null @@ -1 +0,0 @@ -sin({{in}}) diff --git a/materialx/libraries/stdlib/genglsl/mx_smoothstep_float.glsl b/materialx/libraries/stdlib/genglsl/mx_smoothstep_float.glsl deleted file mode 100644 index 1bca2e4d9..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_smoothstep_float.glsl +++ /dev/null @@ -1,9 +0,0 @@ -void mx_smoothstep_float(float val, float low, float high, out float result) -{ - if (val <= low) - result = 0.0; - else if (val >= high) - result = 1.0; - else - result = smoothstep(low, high, val); -} diff --git a/materialx/libraries/stdlib/genglsl/mx_smoothstep_vec2.glsl b/materialx/libraries/stdlib/genglsl/mx_smoothstep_vec2.glsl deleted file mode 100644 index 8af5c513b..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_smoothstep_vec2.glsl +++ /dev/null @@ -1,7 +0,0 @@ -#include "stdlib/genglsl/mx_smoothstep_float.glsl" - -void mx_smoothstep_vec2(vec2 val, vec2 low, vec2 high, out vec2 result) -{ - mx_smoothstep_float(val.x, low.x, high.x, result.x); - mx_smoothstep_float(val.y, low.y, high.y, result.y); -} diff --git a/materialx/libraries/stdlib/genglsl/mx_smoothstep_vec2FA.glsl b/materialx/libraries/stdlib/genglsl/mx_smoothstep_vec2FA.glsl deleted file mode 100644 index 0663c7f0b..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_smoothstep_vec2FA.glsl +++ /dev/null @@ -1,7 +0,0 @@ -#include "stdlib/genglsl/mx_smoothstep_float.glsl" - -void mx_smoothstep_vec2FA(vec2 val, float low, float high, out vec2 result) -{ - mx_smoothstep_float(val.x, low, high, result.x); - mx_smoothstep_float(val.y, low, high, result.y); -} diff --git a/materialx/libraries/stdlib/genglsl/mx_smoothstep_vec3.glsl b/materialx/libraries/stdlib/genglsl/mx_smoothstep_vec3.glsl deleted file mode 100644 index 29122d359..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_smoothstep_vec3.glsl +++ /dev/null @@ -1,8 +0,0 @@ -#include "stdlib/genglsl/mx_smoothstep_float.glsl" - -void mx_smoothstep_vec3(vec3 val, vec3 low, vec3 high, out vec3 result) -{ - mx_smoothstep_float(val.x, low.x, high.x, result.x); - mx_smoothstep_float(val.y, low.y, high.y, result.y); - mx_smoothstep_float(val.z, low.z, high.z, result.z); -} diff --git a/materialx/libraries/stdlib/genglsl/mx_smoothstep_vec3FA.glsl b/materialx/libraries/stdlib/genglsl/mx_smoothstep_vec3FA.glsl deleted file mode 100644 index 8b39dd6dd..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_smoothstep_vec3FA.glsl +++ /dev/null @@ -1,8 +0,0 @@ -#include "stdlib/genglsl/mx_smoothstep_float.glsl" - -void mx_smoothstep_vec3FA(vec3 val, float low, float high, out vec3 result) -{ - mx_smoothstep_float(val.x, low, high, result.x); - mx_smoothstep_float(val.y, low, high, result.y); - mx_smoothstep_float(val.z, low, high, result.z); -} diff --git a/materialx/libraries/stdlib/genglsl/mx_smoothstep_vec4.glsl b/materialx/libraries/stdlib/genglsl/mx_smoothstep_vec4.glsl deleted file mode 100644 index 7f9a849d0..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_smoothstep_vec4.glsl +++ /dev/null @@ -1,9 +0,0 @@ -#include "stdlib/genglsl/mx_smoothstep_float.glsl" - -void mx_smoothstep_vec4(vec4 val, vec4 low, vec4 high, out vec4 result) -{ - mx_smoothstep_float(val.x, low.x, high.x, result.x); - mx_smoothstep_float(val.y, low.y, high.y, result.y); - mx_smoothstep_float(val.z, low.z, high.z, result.z); - mx_smoothstep_float(val.w, low.w, high.w, result.w); -} diff --git a/materialx/libraries/stdlib/genglsl/mx_smoothstep_vec4FA.glsl b/materialx/libraries/stdlib/genglsl/mx_smoothstep_vec4FA.glsl deleted file mode 100644 index cdce10593..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_smoothstep_vec4FA.glsl +++ /dev/null @@ -1,9 +0,0 @@ -#include "stdlib/genglsl/mx_smoothstep_float.glsl" - -void mx_smoothstep_vec4FA(vec4 val, float low, float high, out vec4 result) -{ - mx_smoothstep_float(val.x, low, high, result.x); - mx_smoothstep_float(val.y, low, high, result.y); - mx_smoothstep_float(val.z, low, high, result.z); - mx_smoothstep_float(val.w, low, high, result.w); -} diff --git a/materialx/libraries/stdlib/genglsl/mx_splitlr_float.glsl b/materialx/libraries/stdlib/genglsl/mx_splitlr_float.glsl deleted file mode 100644 index cdfbbb2b1..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_splitlr_float.glsl +++ /dev/null @@ -1,6 +0,0 @@ -#include "stdlib/genglsl/mx_aastep.glsl" - -void mx_splitlr_float(float valuel, float valuer, float center, vec2 texcoord, out float result) -{ - result = mix(valuel, valuer, mx_aastep(center, texcoord.x)); -} diff --git a/materialx/libraries/stdlib/genglsl/mx_splitlr_vector2.glsl b/materialx/libraries/stdlib/genglsl/mx_splitlr_vector2.glsl deleted file mode 100644 index eb08d40f9..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_splitlr_vector2.glsl +++ /dev/null @@ -1,6 +0,0 @@ -#include "stdlib/genglsl/mx_aastep.glsl" - -void mx_splitlr_vector2(vec2 valuel, vec2 valuer, float center, vec2 texcoord, out vec2 result) -{ - result = mix(valuel, valuer, mx_aastep(center, texcoord.x)); -} diff --git a/materialx/libraries/stdlib/genglsl/mx_splitlr_vector3.glsl b/materialx/libraries/stdlib/genglsl/mx_splitlr_vector3.glsl deleted file mode 100644 index c7b4c5170..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_splitlr_vector3.glsl +++ /dev/null @@ -1,6 +0,0 @@ -#include "stdlib/genglsl/mx_aastep.glsl" - -void mx_splitlr_vector3(vec3 valuel, vec3 valuer, float center, vec2 texcoord, out vec3 result) -{ - result = mix(valuel, valuer, mx_aastep(center, texcoord.x)); -} diff --git a/materialx/libraries/stdlib/genglsl/mx_splitlr_vector4.glsl b/materialx/libraries/stdlib/genglsl/mx_splitlr_vector4.glsl deleted file mode 100644 index c4b934d3e..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_splitlr_vector4.glsl +++ /dev/null @@ -1,6 +0,0 @@ -#include "stdlib/genglsl/mx_aastep.glsl" - -void mx_splitlr_vector4(vec4 valuel, vec4 valuer, float center, vec2 texcoord, out vec4 result) -{ - result = mix(valuel, valuer, mx_aastep(center, texcoord.x)); -} diff --git a/materialx/libraries/stdlib/genglsl/mx_splittb_float.glsl b/materialx/libraries/stdlib/genglsl/mx_splittb_float.glsl deleted file mode 100644 index 6f87687aa..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_splittb_float.glsl +++ /dev/null @@ -1,6 +0,0 @@ -#include "stdlib/genglsl/mx_aastep.glsl" - -void mx_splittb_float(float valuet, float valueb, float center, vec2 texcoord, out float result) -{ - result = mix(valuet, valueb, mx_aastep(center, texcoord.y)); -} diff --git a/materialx/libraries/stdlib/genglsl/mx_splittb_vector2.glsl b/materialx/libraries/stdlib/genglsl/mx_splittb_vector2.glsl deleted file mode 100644 index 91b4a69d6..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_splittb_vector2.glsl +++ /dev/null @@ -1,6 +0,0 @@ -#include "stdlib/genglsl/mx_aastep.glsl" - -void mx_splittb_vector2(vec2 valuet, vec2 valueb, float center, vec2 texcoord, out vec2 result) -{ - result = mix(valuet, valueb, mx_aastep(center, texcoord.y)); -} diff --git a/materialx/libraries/stdlib/genglsl/mx_splittb_vector3.glsl b/materialx/libraries/stdlib/genglsl/mx_splittb_vector3.glsl deleted file mode 100644 index 33bd96e80..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_splittb_vector3.glsl +++ /dev/null @@ -1,6 +0,0 @@ -#include "stdlib/genglsl/mx_aastep.glsl" - -void mx_splittb_vector3(vec3 valuet, vec3 valueb, float center, vec2 texcoord, out vec3 result) -{ - result = mix(valuet, valueb, mx_aastep(center, texcoord.y)); -} diff --git a/materialx/libraries/stdlib/genglsl/mx_splittb_vector4.glsl b/materialx/libraries/stdlib/genglsl/mx_splittb_vector4.glsl deleted file mode 100644 index b44d4fe6e..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_splittb_vector4.glsl +++ /dev/null @@ -1,6 +0,0 @@ -#include "stdlib/genglsl/mx_aastep.glsl" - -void mx_splittb_vector4(vec4 valuet, vec4 valueb, float center, vec2 texcoord, out vec4 result) -{ - result = mix(valuet, valueb, mx_aastep(center, texcoord.y)); -} diff --git a/materialx/libraries/stdlib/genglsl/mx_sqrt.inline b/materialx/libraries/stdlib/genglsl/mx_sqrt.inline deleted file mode 100644 index fdcb9ad4e..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_sqrt.inline +++ /dev/null @@ -1 +0,0 @@ -sqrt({{in}}) diff --git a/materialx/libraries/stdlib/genglsl/mx_srgb_texture_to_linear_color3.glsl b/materialx/libraries/stdlib/genglsl/mx_srgb_texture_to_linear_color3.glsl deleted file mode 100644 index 2903ec1a2..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_srgb_texture_to_linear_color3.glsl +++ /dev/null @@ -1,13 +0,0 @@ -void mx_srgb_texture_to_linear_color3(vec3 _in, out vec3 result) -{ - vec4 outColor = vec4(_in, 0.); - vec4 breakPnt = vec4(0.03928571566939354, 0.03928571566939354, 0.03928571566939354, 1.); - vec4 slope = vec4(0.07738015800714493, 0.07738015800714493, 0.07738015800714493, 1.); - vec4 scale = vec4(0.9478672742843628, 0.9478672742843628, 0.9478672742843628, 1.); - vec4 offset = vec4(0.05213269963860512, 0.05213269963860512, 0.05213269963860512, 0.); - vec4 gamma = vec4(2.4, 2.4, 2.4, 1.0); - vec4 isAboveBreak = vec4(greaterThan(outColor, breakPnt)); - vec4 linSeg = outColor * slope; - vec4 powSeg = pow( max( vec4(0., 0., 0., 0.), scale * outColor + offset), gamma); - result = (isAboveBreak * powSeg + ( vec4(1., 1., 1., 1.) - isAboveBreak ) * linSeg).rgb; -} diff --git a/materialx/libraries/stdlib/genglsl/mx_srgb_texture_to_linear_color4.glsl b/materialx/libraries/stdlib/genglsl/mx_srgb_texture_to_linear_color4.glsl deleted file mode 100644 index 46af938de..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_srgb_texture_to_linear_color4.glsl +++ /dev/null @@ -1,13 +0,0 @@ -void mx_srgb_texture_to_linear_color4(vec4 _in, out vec4 result) -{ - vec4 outColor = vec4(_in.rgb, 0.); - vec4 breakPnt = vec4(0.03928571566939354, 0.03928571566939354, 0.03928571566939354, 1.); - vec4 slope = vec4(0.07738015800714493, 0.07738015800714493, 0.07738015800714493, 1.); - vec4 scale = vec4(0.9478672742843628, 0.9478672742843628, 0.9478672742843628, 1.); - vec4 offset = vec4(0.05213269963860512, 0.05213269963860512, 0.05213269963860512, 0.); - vec4 gamma = vec4(2.4, 2.4, 2.4, 1.); - vec4 isAboveBreak = vec4(greaterThan(outColor, breakPnt)); - vec4 linSeg = outColor * slope; - vec4 powSeg = pow( max( vec4(0., 0., 0., 0.), scale * outColor + offset), gamma); - result = vec4((isAboveBreak * powSeg + ( vec4(1., 1., 1., 1.) - isAboveBreak ) * linSeg).rgb, _in.a); -} diff --git a/materialx/libraries/stdlib/genglsl/mx_subtract.inline b/materialx/libraries/stdlib/genglsl/mx_subtract.inline deleted file mode 100644 index afa433965..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_subtract.inline +++ /dev/null @@ -1 +0,0 @@ -{{in1}} - {{in2}} diff --git a/materialx/libraries/stdlib/genglsl/mx_tan.inline b/materialx/libraries/stdlib/genglsl/mx_tan.inline deleted file mode 100644 index 086feffcb..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_tan.inline +++ /dev/null @@ -1 +0,0 @@ -tan({{in}}) diff --git a/materialx/libraries/stdlib/genglsl/mx_transformmatrix.inline b/materialx/libraries/stdlib/genglsl/mx_transformmatrix.inline deleted file mode 100644 index 06f4bf775..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_transformmatrix.inline +++ /dev/null @@ -1 +0,0 @@ -{{mat}} * {{in}} diff --git a/materialx/libraries/stdlib/genglsl/mx_transformmatrix_vector2M3.glsl b/materialx/libraries/stdlib/genglsl/mx_transformmatrix_vector2M3.glsl deleted file mode 100644 index 2afc0248f..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_transformmatrix_vector2M3.glsl +++ /dev/null @@ -1,5 +0,0 @@ -void mx_transformmatrix_vector2M3(vec2 val, mat3 transform, out vec2 result) -{ - vec3 res = transform * vec3(val, 1.0); - result = res.xy; -} diff --git a/materialx/libraries/stdlib/genglsl/mx_transformmatrix_vector3M4.glsl b/materialx/libraries/stdlib/genglsl/mx_transformmatrix_vector3M4.glsl deleted file mode 100644 index 2e1624426..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_transformmatrix_vector3M4.glsl +++ /dev/null @@ -1,5 +0,0 @@ -void mx_transformmatrix_vector3M4(vec3 val, mat4 transform, out vec3 result) -{ - vec4 res = transform * vec4(val, 1.0); - result = res.xyz; -} diff --git a/materialx/libraries/stdlib/genglsl/mx_transpose.inline b/materialx/libraries/stdlib/genglsl/mx_transpose.inline deleted file mode 100644 index 6a195a036..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_transpose.inline +++ /dev/null @@ -1 +0,0 @@ -transpose({{in}}) diff --git a/materialx/libraries/stdlib/genglsl/mx_unpremult_color4.glsl b/materialx/libraries/stdlib/genglsl/mx_unpremult_color4.glsl deleted file mode 100644 index c4503b4e0..000000000 --- a/materialx/libraries/stdlib/genglsl/mx_unpremult_color4.glsl +++ /dev/null @@ -1,4 +0,0 @@ -void mx_unpremult_color4(vec4 _in, out vec4 result) -{ - result = vec4(_in.rgb / _in.a, _in.a); -} diff --git a/materialx/libraries/stdlib/genglsl/stdlib_genglsl_cm_impl.mtlx b/materialx/libraries/stdlib/genglsl/stdlib_genglsl_cm_impl.mtlx deleted file mode 100644 index c6d2c3533..000000000 --- a/materialx/libraries/stdlib/genglsl/stdlib_genglsl_cm_impl.mtlx +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/materialx/libraries/stdlib/genglsl/stdlib_genglsl_impl.mtlx b/materialx/libraries/stdlib/genglsl/stdlib_genglsl_impl.mtlx deleted file mode 100644 index 6c2d990cd..000000000 --- a/materialx/libraries/stdlib/genglsl/stdlib_genglsl_impl.mtlx +++ /dev/null @@ -1,769 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/materialx/libraries/stdlib/genglsl/stdlib_genglsl_unit_impl.mtlx b/materialx/libraries/stdlib/genglsl/stdlib_genglsl_unit_impl.mtlx deleted file mode 100644 index d9cb96606..000000000 --- a/materialx/libraries/stdlib/genglsl/stdlib_genglsl_unit_impl.mtlx +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/materialx/libraries/stdlib/genmdl/stdlib_genmdl_cm_impl.mtlx b/materialx/libraries/stdlib/genmdl/stdlib_genmdl_cm_impl.mtlx deleted file mode 100644 index df1420353..000000000 --- a/materialx/libraries/stdlib/genmdl/stdlib_genmdl_cm_impl.mtlx +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/materialx/libraries/stdlib/genmdl/stdlib_genmdl_impl.mtlx b/materialx/libraries/stdlib/genmdl/stdlib_genmdl_impl.mtlx deleted file mode 100644 index f45330782..000000000 --- a/materialx/libraries/stdlib/genmdl/stdlib_genmdl_impl.mtlx +++ /dev/null @@ -1,773 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/materialx/libraries/stdlib/genmdl/stdlib_genmdl_unit_impl.mtlx b/materialx/libraries/stdlib/genmdl/stdlib_genmdl_unit_impl.mtlx deleted file mode 100644 index c11760edf..000000000 --- a/materialx/libraries/stdlib/genmdl/stdlib_genmdl_unit_impl.mtlx +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/materialx/libraries/stdlib/genosl/lib/mx_sampling.osl b/materialx/libraries/stdlib/genosl/lib/mx_sampling.osl deleted file mode 100644 index 03e3d9f73..000000000 --- a/materialx/libraries/stdlib/genosl/lib/mx_sampling.osl +++ /dev/null @@ -1,150 +0,0 @@ -// Restrict to 7x7 kernel size for performance reasons -#define MX_MAX_SAMPLE_COUNT 49 -// Size of all weights for all levels (including level 1) -#define MX_WEIGHT_ARRAY_SIZE 84 - -// -// Function to compute the sample size relative to a texture coordinate -// -vector2 mx_compute_sample_size_uv(vector2 uv, float filterSize, float filterOffset) -{ - vector derivUVx = Dx(vector(uv.x, uv.y, 0.0)) * 0.5; - vector derivUVy = Dy(vector(uv.x, uv.y, 0.0)) * 0.5; - float derivX = abs(derivUVx[0]) + abs(derivUVy[0]); - float derivY = abs(derivUVx[1]) + abs(derivUVy[1]); - float sampleSizeU = filterSize * derivX + filterOffset; - if (sampleSizeU < 1.0E-05) - sampleSizeU = 1.0E-05; - float sampleSizeV = filterSize * derivY + filterOffset; - if (sampleSizeV < 1.0E-05) - sampleSizeV = 1.0E-05; - return vector2(sampleSizeU, sampleSizeV); -} - -// Kernel weights for box filter -void mx_get_box_weights(output float W[MX_MAX_SAMPLE_COUNT], int filterSize) -{ - int sampleCount = filterSize*filterSize; - float value = 1.0 / float(sampleCount); - for (int i=0; i= 7) - { - W[0] = 0.000036; W[1] = 0.000363; W[2] = 0.001446; W[3] = 0.002291; W[4] = 0.001446; W[5] = 0.000363; W[6] = 0.000036; - W[7] = 0.000363; W[8] = 0.003676; W[9] = 0.014662; W[10] = 0.023226; W[11] = 0.014662; W[12] = 0.003676; W[13] = 0.000363; - W[14] = 0.001446; W[15] = 0.014662; W[16] = 0.058488; W[17] = 0.092651; W[18] = 0.058488; W[19] = 0.014662; W[20] = 0.001446; - W[21] = 0.002291; W[22] = 0.023226; W[23] = 0.092651; W[24] = 0.146768; W[25] = 0.092651; W[26] = 0.023226; W[27] = 0.002291; - W[28] = 0.001446; W[29] = 0.014662; W[30] = 0.058488; W[31] = 0.092651; W[32] = 0.058488; W[33] = 0.014662; W[34] = 0.001446; - W[35] = 0.000363; W[36] = 0.003676; W[37] = 0.014662; W[38] = 0.023226; W[39] = 0.014662; W[40] = 0.003676; W[41] = 0.000363; - W[42] = 0.000036; W[43] = 0.000363; W[44] = 0.001446; W[45] = 0.002291; W[46] = 0.001446; W[47] = 0.000363; W[48] = 0.000036; - } - else if (filterSize >= 5) - { - W[0] = 0.003765; W[1] = 0.015019; W[2] = 0.023792; W[3] = 0.015019; W[4] = 0.003765; - W[5] = 0.015019; W[6] = 0.059912; W[7] = 0.094907; W[8] = 0.059912; W[9] = 0.015019; - W[10] = 0.023792; W[11] = 0.094907; W[12] = 0.150342; W[13] = 0.094907; W[14] = 0.023792; - W[15] = 0.015019; W[16] = 0.059912; W[17] = 0.094907; W[18] = 0.059912; W[19] = 0.015019; - W[20] = 0.003765; W[21] = 0.015019; W[22] = 0.023792; W[23] = 0.015019; W[24] = 0.003765; - } - else if (filterSize >= 3) - { - W[0] = 0.0625; W[1] = 0.125; W[2] = 0.0625; - W[3] = 0.125; W[4] = 0.25; W[5] = 0.125; - W[6] = 0.0625; W[7] = 0.125; W[8] = 0.0625; - } - else - { - W[0] = 1.0; - } -} - -// -// Apply filter for float samples S, using weights W. -// sampleCount should be a square of a odd number in the range { 1, 3, 5, 7 } -// -float mx_convolution_float(float S[MX_MAX_SAMPLE_COUNT], float W[MX_WEIGHT_ARRAY_SIZE], int offset, int sampleCount) -{ - float result = 0.0; - for (int i = 0; i < sampleCount; i++) - { - result += S[i]*W[i+offset]; - } - return result; -} - -// -// Apply filter for vector2 samples S, using weights W. -// sampleCount should be a square of a odd number in the range { 1, 3, 5, 7 } -// -vector2 mx_convolution_vector2(vector2 S[MX_MAX_SAMPLE_COUNT], float W[MX_WEIGHT_ARRAY_SIZE], int offset, int sampleCount) -{ - vector2 result = vector2(0.0, 0.0); - for (int i=0; i1.0)) || - (vaddressmode == "constant" && (texcoord.y<0.0 || texcoord.y>1.0))) - { - out = default_value; - return; - } - - color missingColor = default_value; - vector2 st = mx_transform_uv(texcoord); - out = texture(file, st.x, st.y, "subimage", layer, "missingcolor", missingColor, "swrap", uaddressmode, "twrap", vaddressmode); -} diff --git a/materialx/libraries/stdlib/genosl/mx_image_color4.osl b/materialx/libraries/stdlib/genosl/mx_image_color4.osl deleted file mode 100644 index feddf4978..000000000 --- a/materialx/libraries/stdlib/genosl/mx_image_color4.osl +++ /dev/null @@ -1,21 +0,0 @@ -#include "$fileTransformUv" - -void mx_image_color4(string file, string layer, color4 default_value, vector2 texcoord, string uaddressmode, string vaddressmode, string filtertype, string framerange, int frameoffset, string frameendaction, output color4 out) -{ - if (file == "" || - (uaddressmode == "constant" && (texcoord.x<0.0 || texcoord.x>1.0)) || - (vaddressmode == "constant" && (texcoord.y<0.0 || texcoord.y>1.0))) - { - out = default_value; - return; - } - - color missingColor = default_value.rgb; - float missingAlpha = default_value.a; - vector2 st = mx_transform_uv(texcoord); - float alpha; - color rgb = texture(file, st.x, st.y, "alpha", alpha, "subimage", layer, - "missingcolor", missingColor, "missingalpha", missingAlpha, "swrap", uaddressmode, "twrap", vaddressmode); - - out = color4(rgb, alpha); -} diff --git a/materialx/libraries/stdlib/genosl/mx_image_float.osl b/materialx/libraries/stdlib/genosl/mx_image_float.osl deleted file mode 100644 index bc3083a52..000000000 --- a/materialx/libraries/stdlib/genosl/mx_image_float.osl +++ /dev/null @@ -1,17 +0,0 @@ -#include "$fileTransformUv" - -void mx_image_float(string file, string layer, float default_value, vector2 texcoord, string uaddressmode, string vaddressmode, string filtertype, string framerange, int frameoffset, string frameendaction, output float out) -{ - if (file == "" || - (uaddressmode == "constant" && (texcoord.x<0.0 || texcoord.x>1.0)) || - (vaddressmode == "constant" && (texcoord.y<0.0 || texcoord.y>1.0))) - { - out = default_value; - return; - } - - color missingColor = color(default_value); - vector2 st = mx_transform_uv(texcoord); - color rgb = texture(file, st.x, st.y, "subimage", layer, "missingcolor", missingColor, "swrap", uaddressmode, "twrap", vaddressmode); - out = rgb[0]; -} diff --git a/materialx/libraries/stdlib/genosl/mx_image_vector2.osl b/materialx/libraries/stdlib/genosl/mx_image_vector2.osl deleted file mode 100644 index b4e11f305..000000000 --- a/materialx/libraries/stdlib/genosl/mx_image_vector2.osl +++ /dev/null @@ -1,18 +0,0 @@ -#include "$fileTransformUv" - -void mx_image_vector2(string file, string layer, vector2 default_value, vector2 texcoord, string uaddressmode, string vaddressmode, string filtertype, string framerange, int frameoffset, string frameendaction, output vector2 out) -{ - if (file == "" || - (uaddressmode == "constant" && (texcoord.x<0.0 || texcoord.x>1.0)) || - (vaddressmode == "constant" && (texcoord.y<0.0 || texcoord.y>1.0))) - { - out = default_value; - return; - } - - color missingColor = color(default_value.x, default_value.y, 0.0); - vector2 st = mx_transform_uv(texcoord); - color rgb = texture(file, st.x, st.y, "subimage", layer, "missingcolor", missingColor, "swrap", uaddressmode, "twrap", vaddressmode); - out.x = rgb[0]; - out.y = rgb[1]; -} diff --git a/materialx/libraries/stdlib/genosl/mx_image_vector3.osl b/materialx/libraries/stdlib/genosl/mx_image_vector3.osl deleted file mode 100644 index 177071cd5..000000000 --- a/materialx/libraries/stdlib/genosl/mx_image_vector3.osl +++ /dev/null @@ -1,16 +0,0 @@ -#include "$fileTransformUv" - -void mx_image_vector3(string file, string layer, vector default_value, vector2 texcoord, string uaddressmode, string vaddressmode, string filtertype, string framerange, int frameoffset, string frameendaction, output vector out) -{ - if (file == "" || - (uaddressmode == "constant" && (texcoord.x<0.0 || texcoord.x>1.0)) || - (vaddressmode == "constant" && (texcoord.y<0.0 || texcoord.y>1.0))) - { - out = default_value; - return; - } - - color missingColor = default_value; - vector2 st = mx_transform_uv(texcoord); - out = texture(file, st.x, st.y, "subimage", layer, "missingcolor", missingColor, "swrap", uaddressmode, "twrap", vaddressmode); -} diff --git a/materialx/libraries/stdlib/genosl/mx_image_vector4.osl b/materialx/libraries/stdlib/genosl/mx_image_vector4.osl deleted file mode 100644 index 9e1d2233c..000000000 --- a/materialx/libraries/stdlib/genosl/mx_image_vector4.osl +++ /dev/null @@ -1,21 +0,0 @@ -#include "$fileTransformUv" - -void mx_image_vector4(string file, string layer, vector4 default_value, vector2 texcoord, string uaddressmode, string vaddressmode, string filtertype, string framerange, int frameoffset, string frameendaction, output vector4 out) -{ - if (file == "" || - (uaddressmode == "constant" && (texcoord.x<0.0 || texcoord.x>1.0)) || - (vaddressmode == "constant" && (texcoord.y<0.0 || texcoord.y>1.0))) - { - out = default_value; - return; - } - - color missingColor = color(default_value.x, default_value.y, default_value.z); - float missingAlpha = default_value.w; - vector2 st = mx_transform_uv(texcoord); - float alpha; - color rgb = texture(file, st.x, st.y, "alpha", alpha, "subimage", layer, - "missingcolor", missingColor, "missingalpha", missingAlpha, "swrap", uaddressmode, "twrap", vaddressmode); - - out = vector4(rgb[0], rgb[1], rgb[2], alpha); -} diff --git a/materialx/libraries/stdlib/genosl/mx_in.inline b/materialx/libraries/stdlib/genosl/mx_in.inline deleted file mode 100644 index 0feffbdef..000000000 --- a/materialx/libraries/stdlib/genosl/mx_in.inline +++ /dev/null @@ -1 +0,0 @@ -({{fg}}*{{bg}}.a * {{mix}}) + ({{bg}} * (1.0-{{mix}})) diff --git a/materialx/libraries/stdlib/genosl/mx_inside.inline b/materialx/libraries/stdlib/genosl/mx_inside.inline deleted file mode 100644 index 9109f03f0..000000000 --- a/materialx/libraries/stdlib/genosl/mx_inside.inline +++ /dev/null @@ -1 +0,0 @@ -{{in}} * {{mask}} diff --git a/materialx/libraries/stdlib/genosl/mx_invert.inline b/materialx/libraries/stdlib/genosl/mx_invert.inline deleted file mode 100644 index 79af688a4..000000000 --- a/materialx/libraries/stdlib/genosl/mx_invert.inline +++ /dev/null @@ -1 +0,0 @@ -{{amount}} - {{in}} diff --git a/materialx/libraries/stdlib/genosl/mx_invertM.inline b/materialx/libraries/stdlib/genosl/mx_invertM.inline deleted file mode 100644 index 4581d92de..000000000 --- a/materialx/libraries/stdlib/genosl/mx_invertM.inline +++ /dev/null @@ -1 +0,0 @@ -1 / {{in}} diff --git a/materialx/libraries/stdlib/genosl/mx_ln.inline b/materialx/libraries/stdlib/genosl/mx_ln.inline deleted file mode 100644 index 2edf9002a..000000000 --- a/materialx/libraries/stdlib/genosl/mx_ln.inline +++ /dev/null @@ -1 +0,0 @@ -log({{in}}) diff --git a/materialx/libraries/stdlib/genosl/mx_luminance_color3.osl b/materialx/libraries/stdlib/genosl/mx_luminance_color3.osl deleted file mode 100644 index 8db9712a3..000000000 --- a/materialx/libraries/stdlib/genosl/mx_luminance_color3.osl +++ /dev/null @@ -1,4 +0,0 @@ -void mx_luminance_color3(color in, color lumacoeffs, output color result) -{ - result = dot(in, lumacoeffs); -} diff --git a/materialx/libraries/stdlib/genosl/mx_luminance_color4.osl b/materialx/libraries/stdlib/genosl/mx_luminance_color4.osl deleted file mode 100644 index bee2298b7..000000000 --- a/materialx/libraries/stdlib/genosl/mx_luminance_color4.osl +++ /dev/null @@ -1,4 +0,0 @@ -void mx_luminance_color4(color4 in, color lumacoeffs, output color4 result) -{ - result = color4(dot(in.rgb, lumacoeffs), in.a); -} diff --git a/materialx/libraries/stdlib/genosl/mx_magnitude.inline b/materialx/libraries/stdlib/genosl/mx_magnitude.inline deleted file mode 100644 index 6316e30aa..000000000 --- a/materialx/libraries/stdlib/genosl/mx_magnitude.inline +++ /dev/null @@ -1 +0,0 @@ -length({{in}}) diff --git a/materialx/libraries/stdlib/genosl/mx_mask.inline b/materialx/libraries/stdlib/genosl/mx_mask.inline deleted file mode 100644 index 208c52e46..000000000 --- a/materialx/libraries/stdlib/genosl/mx_mask.inline +++ /dev/null @@ -1 +0,0 @@ -({{bg}}*{{fg}}.a * {{mix}}) + ({{bg}} * (1.0-{{mix}})); diff --git a/materialx/libraries/stdlib/genosl/mx_matte_color4.inline b/materialx/libraries/stdlib/genosl/mx_matte_color4.inline deleted file mode 100644 index c518351ae..000000000 --- a/materialx/libraries/stdlib/genosl/mx_matte_color4.inline +++ /dev/null @@ -1 +0,0 @@ -color4({{fg}}.rgb*{{fg}}.a + {{bg}}.rgb*(1.0-{{fg}}.a), {{fg}}.a + ({{bg}}.a*(1.0-{{fg}}.a)) ) * {{mix}} + ({{bg}} * (1.0-{{mix}})) diff --git a/materialx/libraries/stdlib/genosl/mx_max.inline b/materialx/libraries/stdlib/genosl/mx_max.inline deleted file mode 100644 index 21f1cb084..000000000 --- a/materialx/libraries/stdlib/genosl/mx_max.inline +++ /dev/null @@ -1 +0,0 @@ -max({{in1}}, {{in2}}) diff --git a/materialx/libraries/stdlib/genosl/mx_min.inline b/materialx/libraries/stdlib/genosl/mx_min.inline deleted file mode 100644 index 58fb42416..000000000 --- a/materialx/libraries/stdlib/genosl/mx_min.inline +++ /dev/null @@ -1 +0,0 @@ -min({{in1}}, {{in2}}) diff --git a/materialx/libraries/stdlib/genosl/mx_minus.inline b/materialx/libraries/stdlib/genosl/mx_minus.inline deleted file mode 100644 index 82f6094ed..000000000 --- a/materialx/libraries/stdlib/genosl/mx_minus.inline +++ /dev/null @@ -1 +0,0 @@ -({{mix}}*({{bg}} - {{fg}})) + ((1.0-{{mix}})*{{bg}}) diff --git a/materialx/libraries/stdlib/genosl/mx_mix.inline b/materialx/libraries/stdlib/genosl/mx_mix.inline deleted file mode 100644 index e06e87be5..000000000 --- a/materialx/libraries/stdlib/genosl/mx_mix.inline +++ /dev/null @@ -1 +0,0 @@ -mix({{bg}}, {{fg}}, {{mix}}) diff --git a/materialx/libraries/stdlib/genosl/mx_modulo.inline b/materialx/libraries/stdlib/genosl/mx_modulo.inline deleted file mode 100644 index 5d652aa4e..000000000 --- a/materialx/libraries/stdlib/genosl/mx_modulo.inline +++ /dev/null @@ -1 +0,0 @@ -mod({{in1}}, {{in2}}) diff --git a/materialx/libraries/stdlib/genosl/mx_modulo_color3FA.inline b/materialx/libraries/stdlib/genosl/mx_modulo_color3FA.inline deleted file mode 100644 index ba68f10af..000000000 --- a/materialx/libraries/stdlib/genosl/mx_modulo_color3FA.inline +++ /dev/null @@ -1 +0,0 @@ -mod({{in1}}, color({{in2}},{{in2}},{{in2}})) diff --git a/materialx/libraries/stdlib/genosl/mx_modulo_vector3FA.inline b/materialx/libraries/stdlib/genosl/mx_modulo_vector3FA.inline deleted file mode 100644 index 8845cc566..000000000 --- a/materialx/libraries/stdlib/genosl/mx_modulo_vector3FA.inline +++ /dev/null @@ -1 +0,0 @@ -mod({{in1}}, vector({{in2}},{{in2}},{{in2}})) diff --git a/materialx/libraries/stdlib/genosl/mx_multiply.inline b/materialx/libraries/stdlib/genosl/mx_multiply.inline deleted file mode 100644 index 4c4799f44..000000000 --- a/materialx/libraries/stdlib/genosl/mx_multiply.inline +++ /dev/null @@ -1 +0,0 @@ -{{in1}} * {{in2}} diff --git a/materialx/libraries/stdlib/genosl/mx_noise2d_color3.osl b/materialx/libraries/stdlib/genosl/mx_noise2d_color3.osl deleted file mode 100644 index 37421ee81..000000000 --- a/materialx/libraries/stdlib/genosl/mx_noise2d_color3.osl +++ /dev/null @@ -1,5 +0,0 @@ -void mx_noise2d_color3(vector amplitude, float pivot, vector2 texcoord, output color result) -{ - color value = noise("snoise", texcoord.x, texcoord.y); - result = value * amplitude + pivot; -} diff --git a/materialx/libraries/stdlib/genosl/mx_noise2d_color4.osl b/materialx/libraries/stdlib/genosl/mx_noise2d_color4.osl deleted file mode 100644 index 124efda60..000000000 --- a/materialx/libraries/stdlib/genosl/mx_noise2d_color4.osl +++ /dev/null @@ -1,5 +0,0 @@ -void mx_noise2d_color4(vector4 amplitude, float pivot, vector2 texcoord, output color4 result) -{ - color4 value = noise("snoise", texcoord.x, texcoord.y); - result = value * color4(color(amplitude.x, amplitude.y, amplitude.z), amplitude.w) + pivot; -} diff --git a/materialx/libraries/stdlib/genosl/mx_noise2d_fa_color3.osl b/materialx/libraries/stdlib/genosl/mx_noise2d_fa_color3.osl deleted file mode 100644 index 29c09c1ae..000000000 --- a/materialx/libraries/stdlib/genosl/mx_noise2d_fa_color3.osl +++ /dev/null @@ -1,5 +0,0 @@ -void mx_noise2d_fa_color3(float amplitude, float pivot, vector2 texcoord, output color result) -{ - color value = noise("snoise", texcoord.x, texcoord.y); - result = value * amplitude + pivot; -} diff --git a/materialx/libraries/stdlib/genosl/mx_noise2d_fa_color4.osl b/materialx/libraries/stdlib/genosl/mx_noise2d_fa_color4.osl deleted file mode 100644 index a1301d6d5..000000000 --- a/materialx/libraries/stdlib/genosl/mx_noise2d_fa_color4.osl +++ /dev/null @@ -1,5 +0,0 @@ -void mx_noise2d_fa_color4(float amplitude, float pivot, vector2 texcoord, output color4 result) -{ - color4 value = noise("snoise", texcoord.x, texcoord.y); - result = value * amplitude + pivot; -} diff --git a/materialx/libraries/stdlib/genosl/mx_noise2d_fa_vector2.osl b/materialx/libraries/stdlib/genosl/mx_noise2d_fa_vector2.osl deleted file mode 100644 index 00d7ec100..000000000 --- a/materialx/libraries/stdlib/genosl/mx_noise2d_fa_vector2.osl +++ /dev/null @@ -1,5 +0,0 @@ -void mx_noise2d_fa_vector2(float amplitude, float pivot, vector2 texcoord, output vector2 result) -{ - vector2 value = noise("snoise", texcoord.x, texcoord.y); - result = value * amplitude + pivot; -} diff --git a/materialx/libraries/stdlib/genosl/mx_noise2d_fa_vector3.osl b/materialx/libraries/stdlib/genosl/mx_noise2d_fa_vector3.osl deleted file mode 100644 index c1f060a26..000000000 --- a/materialx/libraries/stdlib/genosl/mx_noise2d_fa_vector3.osl +++ /dev/null @@ -1,5 +0,0 @@ -void mx_noise2d_fa_vector3(float amplitude, float pivot, vector2 texcoord, output vector result) -{ - vector value = noise("snoise", texcoord.x, texcoord.y); - result = value * amplitude + pivot; -} diff --git a/materialx/libraries/stdlib/genosl/mx_noise2d_fa_vector4.osl b/materialx/libraries/stdlib/genosl/mx_noise2d_fa_vector4.osl deleted file mode 100644 index 3634d7b85..000000000 --- a/materialx/libraries/stdlib/genosl/mx_noise2d_fa_vector4.osl +++ /dev/null @@ -1,5 +0,0 @@ -void mx_noise2d_fa_vector4(float amplitude, float pivot, vector2 texcoord, output vector4 result) -{ - vector4 value = noise("snoise", texcoord.x, texcoord.y); - result = value * amplitude + pivot; -} diff --git a/materialx/libraries/stdlib/genosl/mx_noise2d_float.osl b/materialx/libraries/stdlib/genosl/mx_noise2d_float.osl deleted file mode 100644 index 2af1bd421..000000000 --- a/materialx/libraries/stdlib/genosl/mx_noise2d_float.osl +++ /dev/null @@ -1,5 +0,0 @@ -void mx_noise2d_float(float amplitude, float pivot, vector2 texcoord, output float result) -{ - float value = noise("snoise", texcoord.x, texcoord.y); - result = value * amplitude + pivot; -} diff --git a/materialx/libraries/stdlib/genosl/mx_noise2d_vector2.osl b/materialx/libraries/stdlib/genosl/mx_noise2d_vector2.osl deleted file mode 100644 index 3a89e760a..000000000 --- a/materialx/libraries/stdlib/genosl/mx_noise2d_vector2.osl +++ /dev/null @@ -1,5 +0,0 @@ -void mx_noise2d_vector2(vector2 amplitude, float pivot, vector2 texcoord, output vector2 result) -{ - vector2 value = noise("snoise", texcoord.x, texcoord.y); - result = value * amplitude + pivot; -} diff --git a/materialx/libraries/stdlib/genosl/mx_noise2d_vector3.osl b/materialx/libraries/stdlib/genosl/mx_noise2d_vector3.osl deleted file mode 100644 index 06d10cc26..000000000 --- a/materialx/libraries/stdlib/genosl/mx_noise2d_vector3.osl +++ /dev/null @@ -1,5 +0,0 @@ -void mx_noise2d_vector3(vector amplitude, float pivot, vector2 texcoord, output vector result) -{ - vector value = noise("snoise", texcoord.x, texcoord.y); - result = value * amplitude + pivot; -} diff --git a/materialx/libraries/stdlib/genosl/mx_noise2d_vector4.osl b/materialx/libraries/stdlib/genosl/mx_noise2d_vector4.osl deleted file mode 100644 index 880c8987f..000000000 --- a/materialx/libraries/stdlib/genosl/mx_noise2d_vector4.osl +++ /dev/null @@ -1,5 +0,0 @@ -void mx_noise2d_vector4(vector4 amplitude, float pivot, vector2 texcoord, output vector4 result) -{ - vector4 value = noise("snoise", texcoord.x, texcoord.y); - result = value * amplitude + pivot; -} diff --git a/materialx/libraries/stdlib/genosl/mx_noise3d_color3.osl b/materialx/libraries/stdlib/genosl/mx_noise3d_color3.osl deleted file mode 100644 index f4649a598..000000000 --- a/materialx/libraries/stdlib/genosl/mx_noise3d_color3.osl +++ /dev/null @@ -1,5 +0,0 @@ -void mx_noise3d_color3(vector amplitude, float pivot, vector position, output color result) -{ - color value = noise("snoise", position); - result = value * amplitude + pivot; -} diff --git a/materialx/libraries/stdlib/genosl/mx_noise3d_color4.osl b/materialx/libraries/stdlib/genosl/mx_noise3d_color4.osl deleted file mode 100644 index e8f228c7e..000000000 --- a/materialx/libraries/stdlib/genosl/mx_noise3d_color4.osl +++ /dev/null @@ -1,5 +0,0 @@ -void mx_noise3d_color4(vector4 amplitude, float pivot, vector position, output color4 result) -{ - color4 value = noise("snoise", position); - result = value * combine(amplitude.x, amplitude.y, amplitude.z, amplitude.w) + pivot; -} diff --git a/materialx/libraries/stdlib/genosl/mx_noise3d_fa_color3.osl b/materialx/libraries/stdlib/genosl/mx_noise3d_fa_color3.osl deleted file mode 100644 index 83b777b2f..000000000 --- a/materialx/libraries/stdlib/genosl/mx_noise3d_fa_color3.osl +++ /dev/null @@ -1,5 +0,0 @@ -void mx_noise3d_fa_color3(float amplitude, float pivot, vector position, output color result) -{ - color value = noise("snoise", position); - result = value * amplitude + pivot; -} diff --git a/materialx/libraries/stdlib/genosl/mx_noise3d_fa_color4.osl b/materialx/libraries/stdlib/genosl/mx_noise3d_fa_color4.osl deleted file mode 100644 index aa0721eec..000000000 --- a/materialx/libraries/stdlib/genosl/mx_noise3d_fa_color4.osl +++ /dev/null @@ -1,5 +0,0 @@ -void mx_noise3d_fa_color4(float amplitude, float pivot, vector position, output color4 result) -{ - color4 value = noise("snoise", position); - result = value * amplitude + pivot; -} diff --git a/materialx/libraries/stdlib/genosl/mx_noise3d_fa_vector2.osl b/materialx/libraries/stdlib/genosl/mx_noise3d_fa_vector2.osl deleted file mode 100644 index 529a22d02..000000000 --- a/materialx/libraries/stdlib/genosl/mx_noise3d_fa_vector2.osl +++ /dev/null @@ -1,5 +0,0 @@ -void mx_noise3d_fa_vector2(float amplitude, float pivot, vector position, output vector2 result) -{ - vector2 value = noise("snoise", position); - result = value * amplitude + pivot; -} diff --git a/materialx/libraries/stdlib/genosl/mx_noise3d_fa_vector3.osl b/materialx/libraries/stdlib/genosl/mx_noise3d_fa_vector3.osl deleted file mode 100644 index 4e235febc..000000000 --- a/materialx/libraries/stdlib/genosl/mx_noise3d_fa_vector3.osl +++ /dev/null @@ -1,5 +0,0 @@ -void mx_noise3d_fa_vector3(float amplitude, float pivot, vector position, output vector result) -{ - vector value = noise("snoise", position); - result = value * amplitude + pivot; -} diff --git a/materialx/libraries/stdlib/genosl/mx_noise3d_fa_vector4.osl b/materialx/libraries/stdlib/genosl/mx_noise3d_fa_vector4.osl deleted file mode 100644 index 8f7ba3bed..000000000 --- a/materialx/libraries/stdlib/genosl/mx_noise3d_fa_vector4.osl +++ /dev/null @@ -1,5 +0,0 @@ -void mx_noise3d_fa_vector4(float amplitude, float pivot, vector position, output vector4 result) -{ - vector4 value = noise("snoise", position); - result = value * amplitude + pivot; -} diff --git a/materialx/libraries/stdlib/genosl/mx_noise3d_float.osl b/materialx/libraries/stdlib/genosl/mx_noise3d_float.osl deleted file mode 100644 index 23c598509..000000000 --- a/materialx/libraries/stdlib/genosl/mx_noise3d_float.osl +++ /dev/null @@ -1,5 +0,0 @@ -void mx_noise3d_float(float amplitude, float pivot, vector position, output float result) -{ - float value = noise("snoise", position); - result = value * amplitude + pivot; -} diff --git a/materialx/libraries/stdlib/genosl/mx_noise3d_vector2.osl b/materialx/libraries/stdlib/genosl/mx_noise3d_vector2.osl deleted file mode 100644 index 0ca391cd9..000000000 --- a/materialx/libraries/stdlib/genosl/mx_noise3d_vector2.osl +++ /dev/null @@ -1,5 +0,0 @@ -void mx_noise3d_vector2(vector2 amplitude, float pivot, vector position, output vector2 result) -{ - vector2 value = noise("snoise", position); - result = value * amplitude + pivot; -} diff --git a/materialx/libraries/stdlib/genosl/mx_noise3d_vector3.osl b/materialx/libraries/stdlib/genosl/mx_noise3d_vector3.osl deleted file mode 100644 index cc6b2410e..000000000 --- a/materialx/libraries/stdlib/genosl/mx_noise3d_vector3.osl +++ /dev/null @@ -1,5 +0,0 @@ -void mx_noise3d_vector3(vector amplitude, float pivot, vector position, output vector result) -{ - vector value = noise("snoise", position); - result = value * amplitude + pivot; -} diff --git a/materialx/libraries/stdlib/genosl/mx_noise3d_vector4.osl b/materialx/libraries/stdlib/genosl/mx_noise3d_vector4.osl deleted file mode 100644 index 78c1078d0..000000000 --- a/materialx/libraries/stdlib/genosl/mx_noise3d_vector4.osl +++ /dev/null @@ -1,5 +0,0 @@ -void mx_noise3d_vector4(vector4 amplitude, float pivot, vector position, output vector4 result) -{ - vector4 value = noise("snoise", position); - result = value * amplitude + pivot; -} diff --git a/materialx/libraries/stdlib/genosl/mx_normal_vector3.inline b/materialx/libraries/stdlib/genosl/mx_normal_vector3.inline deleted file mode 100644 index 0f8bd35c4..000000000 --- a/materialx/libraries/stdlib/genosl/mx_normal_vector3.inline +++ /dev/null @@ -1 +0,0 @@ -transform({{space}}, N) diff --git a/materialx/libraries/stdlib/genosl/mx_normalize.inline b/materialx/libraries/stdlib/genosl/mx_normalize.inline deleted file mode 100644 index debdc12ab..000000000 --- a/materialx/libraries/stdlib/genosl/mx_normalize.inline +++ /dev/null @@ -1 +0,0 @@ -normalize({{in}}) diff --git a/materialx/libraries/stdlib/genosl/mx_normalmap.osl b/materialx/libraries/stdlib/genosl/mx_normalmap.osl deleted file mode 100644 index a1f276faf..000000000 --- a/materialx/libraries/stdlib/genosl/mx_normalmap.osl +++ /dev/null @@ -1,17 +0,0 @@ -void mx_normalmap(vector value, string map_space, float normal_scale, vector N, vector U, output vector result) -{ - // Tangent space - if (map_space == "tangent") - { - vector v = value * 2.0 - 1.0; - vector T = normalize(U - dot(U, N) * N); - vector B = normalize(cross(N, T)); - result = normalize(T * v[0] * normal_scale + B * v[1] * normal_scale + N * v[2]); - } - // Object space - else - { - vector n = value * 2.0 - 1.0; - result = normalize(n); - } -} diff --git a/materialx/libraries/stdlib/genosl/mx_out.inline b/materialx/libraries/stdlib/genosl/mx_out.inline deleted file mode 100644 index 32c73976f..000000000 --- a/materialx/libraries/stdlib/genosl/mx_out.inline +++ /dev/null @@ -1 +0,0 @@ -({{fg}}*(1.0-{{bg}}.a) * {{mix}}) + ({{bg}} * (1.0-{{mix}})) diff --git a/materialx/libraries/stdlib/genosl/mx_outside.inline b/materialx/libraries/stdlib/genosl/mx_outside.inline deleted file mode 100644 index 73a388ad7..000000000 --- a/materialx/libraries/stdlib/genosl/mx_outside.inline +++ /dev/null @@ -1 +0,0 @@ -{{in}} * (1.0 - {{mask}}) diff --git a/materialx/libraries/stdlib/genosl/mx_over.inline b/materialx/libraries/stdlib/genosl/mx_over.inline deleted file mode 100644 index 8ec28ab61..000000000 --- a/materialx/libraries/stdlib/genosl/mx_over.inline +++ /dev/null @@ -1 +0,0 @@ -({{fg}} + ({{bg}}*(1.0-{{fg}}.a))) * {{mix}} + {{bg}} * (1.0-{{mix}}) diff --git a/materialx/libraries/stdlib/genosl/mx_overlay.inline b/materialx/libraries/stdlib/genosl/mx_overlay.inline deleted file mode 100644 index 654aba2d3..000000000 --- a/materialx/libraries/stdlib/genosl/mx_overlay.inline +++ /dev/null @@ -1 +0,0 @@ -({{fg}} < 0.5) ? ({{mix}}*2.0*{{fg}}*{{bg}}) + ((1.0-{{mix}})*{{bg}}) : ({{mix}}*(1.0-(1.0-{{fg}})*(1.0-{{bg}}))) + ((1.0-{{mix}})*{{bg}}) diff --git a/materialx/libraries/stdlib/genosl/mx_overlay_color3.osl b/materialx/libraries/stdlib/genosl/mx_overlay_color3.osl deleted file mode 100644 index 387653fe0..000000000 --- a/materialx/libraries/stdlib/genosl/mx_overlay_color3.osl +++ /dev/null @@ -1,16 +0,0 @@ -float overlay(float fg, float bg) -{ - return (fg < 0.5) ? (2 * fg * bg) : (1 - (1 - fg) * (1 - bg)); -} - -color overlay(color fg, color bg) -{ - return color(overlay(fg[0], bg[0]), - overlay(fg[1], bg[1]), - overlay(fg[2], bg[2])); -} - -void mx_overlay_color3(color fg, color bg, float mix, output color out) -{ - out = mix * overlay(fg, bg) + (1-mix) * bg; -} diff --git a/materialx/libraries/stdlib/genosl/mx_overlay_color4.osl b/materialx/libraries/stdlib/genosl/mx_overlay_color4.osl deleted file mode 100644 index 1ae6a72c1..000000000 --- a/materialx/libraries/stdlib/genosl/mx_overlay_color4.osl +++ /dev/null @@ -1,22 +0,0 @@ -float overlay(float fg, float bg) -{ - return (fg < 0.5) ? (2 * fg * bg) : (1 - (1 - fg) * (1 - bg)); -} - -color overlay(color fg, color bg) -{ - return color(overlay(fg[0], bg[0]), - overlay(fg[1], bg[1]), - overlay(fg[2], bg[2])); -} - -color4 overlay(color4 fg, color4 bg) -{ - return color4(overlay(fg.rgb, bg.rgb), - overlay(fg.a, bg.a)); -} - -void mx_overlay_color4(color4 fg, color4 bg, float mix, output color4 out) -{ - out = mix * overlay(fg, bg) + (1-mix) * bg; -} diff --git a/materialx/libraries/stdlib/genosl/mx_plus.inline b/materialx/libraries/stdlib/genosl/mx_plus.inline deleted file mode 100644 index bc5a3f6b1..000000000 --- a/materialx/libraries/stdlib/genosl/mx_plus.inline +++ /dev/null @@ -1 +0,0 @@ -({{mix}}*({{bg}} + {{fg}})) + ((1.0-{{mix}})*{{bg}}) diff --git a/materialx/libraries/stdlib/genosl/mx_position_vector3.inline b/materialx/libraries/stdlib/genosl/mx_position_vector3.inline deleted file mode 100644 index 0700aaaf3..000000000 --- a/materialx/libraries/stdlib/genosl/mx_position_vector3.inline +++ /dev/null @@ -1 +0,0 @@ -transform({{space}}, P) diff --git a/materialx/libraries/stdlib/genosl/mx_power.inline b/materialx/libraries/stdlib/genosl/mx_power.inline deleted file mode 100644 index b48b1a2e2..000000000 --- a/materialx/libraries/stdlib/genosl/mx_power.inline +++ /dev/null @@ -1 +0,0 @@ -pow({{in1}}, {{in2}}) diff --git a/materialx/libraries/stdlib/genosl/mx_premult_color4.osl b/materialx/libraries/stdlib/genosl/mx_premult_color4.osl deleted file mode 100644 index 8e57e1392..000000000 --- a/materialx/libraries/stdlib/genosl/mx_premult_color4.osl +++ /dev/null @@ -1,4 +0,0 @@ -void mx_premult_color4(color4 in, output color4 result) -{ - result = color4(in.rgb * in.a, in.a); -} diff --git a/materialx/libraries/stdlib/genosl/mx_ramplr.inline b/materialx/libraries/stdlib/genosl/mx_ramplr.inline deleted file mode 100644 index ed94295d4..000000000 --- a/materialx/libraries/stdlib/genosl/mx_ramplr.inline +++ /dev/null @@ -1 +0,0 @@ -mix({{valuel}}, {{valuer}}, clamp({{texcoord}}.x, 0, 1)) diff --git a/materialx/libraries/stdlib/genosl/mx_ramptb.inline b/materialx/libraries/stdlib/genosl/mx_ramptb.inline deleted file mode 100644 index 2964875e5..000000000 --- a/materialx/libraries/stdlib/genosl/mx_ramptb.inline +++ /dev/null @@ -1 +0,0 @@ -mix({{valuet}}, {{valueb}}, clamp({{texcoord}}.y, 0, 1)) diff --git a/materialx/libraries/stdlib/genosl/mx_remap.inline b/materialx/libraries/stdlib/genosl/mx_remap.inline deleted file mode 100644 index 298a66000..000000000 --- a/materialx/libraries/stdlib/genosl/mx_remap.inline +++ /dev/null @@ -1 +0,0 @@ -remap({{in}}, {{inlow}}, {{inhigh}}, {{outlow}}, {{outhigh}}, 0) diff --git a/materialx/libraries/stdlib/genosl/mx_rgbtohsv_color3.osl b/materialx/libraries/stdlib/genosl/mx_rgbtohsv_color3.osl deleted file mode 100644 index 7315ead9b..000000000 --- a/materialx/libraries/stdlib/genosl/mx_rgbtohsv_color3.osl +++ /dev/null @@ -1,4 +0,0 @@ -void mx_rgbtohsv_color3(vector _in, output vector result) -{ - result = transformc("rgb","hsv", _in); -} diff --git a/materialx/libraries/stdlib/genosl/mx_rgbtohsv_color4.osl b/materialx/libraries/stdlib/genosl/mx_rgbtohsv_color4.osl deleted file mode 100644 index 92edec0e7..000000000 --- a/materialx/libraries/stdlib/genosl/mx_rgbtohsv_color4.osl +++ /dev/null @@ -1,4 +0,0 @@ -void mx_rgbtohsv_color4(color4 _in, output color4 result) -{ - result = color4(transformc("rgb","hsv", _in.rgb), 1.0); -} diff --git a/materialx/libraries/stdlib/genosl/mx_rotate_vector2.osl b/materialx/libraries/stdlib/genosl/mx_rotate_vector2.osl deleted file mode 100644 index 7ac3dbfa5..000000000 --- a/materialx/libraries/stdlib/genosl/mx_rotate_vector2.osl +++ /dev/null @@ -1,7 +0,0 @@ -void mx_rotate_vector2(vector2 _in, float amount, output vector2 result) -{ - float rotationRadians = radians(amount); - float sa = sin(rotationRadians); - float ca = cos(rotationRadians); - result = vector2(ca*_in.x + sa*_in.y, -sa*_in.x + ca*_in.y); -} diff --git a/materialx/libraries/stdlib/genosl/mx_rotate_vector3.osl b/materialx/libraries/stdlib/genosl/mx_rotate_vector3.osl deleted file mode 100644 index d036fe655..000000000 --- a/materialx/libraries/stdlib/genosl/mx_rotate_vector3.osl +++ /dev/null @@ -1,20 +0,0 @@ -matrix rotationMatrix(vector axis, float angle) -{ - vector nAxis = normalize(axis); - float s = sin(angle); - float c = cos(angle); - float oc = 1.0 - c; - - return matrix(oc * nAxis[0] * nAxis[0] + c, oc * nAxis[0] * nAxis[1] - nAxis[2] * s, oc * nAxis[2] * nAxis[0] + nAxis[1] * s, 0.0, - oc * nAxis[0] * nAxis[1] + nAxis[2] * s, oc * nAxis[1] * nAxis[1] + c, oc * nAxis[1] * nAxis[2] - nAxis[0] * s, 0.0, - oc * nAxis[2] * nAxis[0] - nAxis[1] * s, oc * nAxis[1] * nAxis[2] + nAxis[0] * s, oc * nAxis[2] * nAxis[2] + c, 0.0, - 0.0, 0.0, 0.0, 1.0); -} - -void mx_rotate_vector3(vector _in, float amount, vector axis, output vector result) -{ - float rotationRadians = radians(amount); - matrix m = rotationMatrix(axis, rotationRadians); - vector4 trans = transform(m, vector4(_in[0], _in[1], _in[2], 1.0)); - result = vector(trans.x, trans.y, trans.z); -} diff --git a/materialx/libraries/stdlib/genosl/mx_screen.inline b/materialx/libraries/stdlib/genosl/mx_screen.inline deleted file mode 100644 index 741b58d95..000000000 --- a/materialx/libraries/stdlib/genosl/mx_screen.inline +++ /dev/null @@ -1 +0,0 @@ -({{mix}}*((1.0 - (1.0 - {{fg}})) * (1 - {{bg}}))) + ((1.0-{{mix}})*{{bg}}) diff --git a/materialx/libraries/stdlib/genosl/mx_sign.inline b/materialx/libraries/stdlib/genosl/mx_sign.inline deleted file mode 100644 index 46e9499cd..000000000 --- a/materialx/libraries/stdlib/genosl/mx_sign.inline +++ /dev/null @@ -1 +0,0 @@ -sign({{in}}) diff --git a/materialx/libraries/stdlib/genosl/mx_sin.inline b/materialx/libraries/stdlib/genosl/mx_sin.inline deleted file mode 100644 index 8bf8c865a..000000000 --- a/materialx/libraries/stdlib/genosl/mx_sin.inline +++ /dev/null @@ -1 +0,0 @@ -sin({{in}}) diff --git a/materialx/libraries/stdlib/genosl/mx_smoothstep.inline b/materialx/libraries/stdlib/genosl/mx_smoothstep.inline deleted file mode 100644 index 71f060d87..000000000 --- a/materialx/libraries/stdlib/genosl/mx_smoothstep.inline +++ /dev/null @@ -1 +0,0 @@ -smoothstep({{low}}, {{high}}, {{in}}) \ No newline at end of file diff --git a/materialx/libraries/stdlib/genosl/mx_splitlr.inline b/materialx/libraries/stdlib/genosl/mx_splitlr.inline deleted file mode 100644 index a9d867434..000000000 --- a/materialx/libraries/stdlib/genosl/mx_splitlr.inline +++ /dev/null @@ -1 +0,0 @@ -mix({{valuel}}, {{valuer}}, aastep({{center}}, {{texcoord}}.x)) diff --git a/materialx/libraries/stdlib/genosl/mx_splittb.inline b/materialx/libraries/stdlib/genosl/mx_splittb.inline deleted file mode 100644 index 4c06a5c98..000000000 --- a/materialx/libraries/stdlib/genosl/mx_splittb.inline +++ /dev/null @@ -1 +0,0 @@ -mix({{valuet}}, {{valueb}}, aastep({{center}}, {{texcoord}}.y)) diff --git a/materialx/libraries/stdlib/genosl/mx_sqrt.inline b/materialx/libraries/stdlib/genosl/mx_sqrt.inline deleted file mode 100644 index fdcb9ad4e..000000000 --- a/materialx/libraries/stdlib/genosl/mx_sqrt.inline +++ /dev/null @@ -1 +0,0 @@ -sqrt({{in}}) diff --git a/materialx/libraries/stdlib/genosl/mx_srgb_texture_to_linear_color3.osl b/materialx/libraries/stdlib/genosl/mx_srgb_texture_to_linear_color3.osl deleted file mode 100644 index a1b20a5ad..000000000 --- a/materialx/libraries/stdlib/genosl/mx_srgb_texture_to_linear_color3.osl +++ /dev/null @@ -1,17 +0,0 @@ -void mx_srgb_texture_to_linear_color3(color _in, output color result) -{ - color4 outColor = color4(_in, 0.); - color4 breakPnt = color4(color(0.03928571566939354, 0.03928571566939354, 0.03928571566939354), 1.); - color4 slope = color4(color(0.07738015800714493, 0.07738015800714493, 0.07738015800714493), 1.); - color4 scale = color4(color(0.9478672742843628, 0.9478672742843628, 0.9478672742843628), 1.); - color4 offset = color4(color(0.05213269963860512, 0.05213269963860512, 0.05213269963860512), 0.); - color4 gamma = color4(color(2.4, 2.4, 2.4), 1.0); - color4 isAboveBreak = color4(color(outColor.rgb[0] > breakPnt.rgb[0] ? 1.0 : 0.0, - outColor.rgb[1] > breakPnt.rgb[1] ? 1.0 : 0.0, - outColor.rgb[2] > breakPnt.rgb[2] ? 1.0 : 0.0), - outColor.a > breakPnt.a ? 1.0 : 0.0); - color4 linSeg = outColor * slope; - color4 powSeg = pow( max( color4(color(0., 0., 0.), 0.), scale * outColor + offset), gamma); - color4 resultColor4 = isAboveBreak * powSeg + ( color4(color(1., 1., 1.), 1.) - isAboveBreak ) * linSeg; - result = resultColor4.rgb; -} diff --git a/materialx/libraries/stdlib/genosl/mx_srgb_texture_to_linear_color4.osl b/materialx/libraries/stdlib/genosl/mx_srgb_texture_to_linear_color4.osl deleted file mode 100644 index e26c1235c..000000000 --- a/materialx/libraries/stdlib/genosl/mx_srgb_texture_to_linear_color4.osl +++ /dev/null @@ -1,19 +0,0 @@ -void mx_srgb_texture_to_linear_color4(color4 _in, output color4 result) -{ - color4 outColor = color4(_in.rgb, 0.); - color4 breakPnt = color4(color(0.03928571566939354, 0.03928571566939354, 0.03928571566939354), 1.); - color4 slope = color4(color(0.07738015800714493, 0.07738015800714493, 0.07738015800714493), 1.); - color4 scale = color4(color(0.9478672742843628, 0.9478672742843628, 0.9478672742843628), 1.); - color4 offset = color4(color(0.05213269963860512, 0.05213269963860512, 0.05213269963860512), 0.); - color4 gamma = color4(color(2.4, 2.4, 2.4), 1.); - color4 isAboveBreak = color4(color(outColor.rgb[0] > breakPnt.rgb[0] ? 1.0 : 0.0, - outColor.rgb[1] > breakPnt.rgb[1] ? 1.0 : 0.0, - outColor.rgb[2] > breakPnt.rgb[2] ? 1.0 : 0.0), - outColor.a > breakPnt.a ? 1.0 : 0.0); - color4 linSeg = outColor * slope; - color4 tmpA = color4(color(0., 0., 0.), 0.); - color4 powSeg = pow( max( tmpA, scale * outColor + offset), gamma); - color4 tmpB = color4(color(1., 1., 1.), 1.); - color4 tmp = isAboveBreak * powSeg + ( tmpB - isAboveBreak ) * linSeg; - result = color4(tmp.rgb, _in.a); -} diff --git a/materialx/libraries/stdlib/genosl/mx_subtract.inline b/materialx/libraries/stdlib/genosl/mx_subtract.inline deleted file mode 100644 index a70d4a12d..000000000 --- a/materialx/libraries/stdlib/genosl/mx_subtract.inline +++ /dev/null @@ -1 +0,0 @@ -mx_sub({{in1}}, {{in2}}) diff --git a/materialx/libraries/stdlib/genosl/mx_tan.inline b/materialx/libraries/stdlib/genosl/mx_tan.inline deleted file mode 100644 index 086feffcb..000000000 --- a/materialx/libraries/stdlib/genosl/mx_tan.inline +++ /dev/null @@ -1 +0,0 @@ -tan({{in}}) diff --git a/materialx/libraries/stdlib/genosl/mx_tangent_vector3.inline b/materialx/libraries/stdlib/genosl/mx_tangent_vector3.inline deleted file mode 100644 index d58f97545..000000000 --- a/materialx/libraries/stdlib/genosl/mx_tangent_vector3.inline +++ /dev/null @@ -1 +0,0 @@ -transform({{space}}, dPdu) diff --git a/materialx/libraries/stdlib/genosl/mx_texcoord_vector2.inline b/materialx/libraries/stdlib/genosl/mx_texcoord_vector2.inline deleted file mode 100644 index 93b9dc4db..000000000 --- a/materialx/libraries/stdlib/genosl/mx_texcoord_vector2.inline +++ /dev/null @@ -1 +0,0 @@ -vector2(u,v) diff --git a/materialx/libraries/stdlib/genosl/mx_texcoord_vector3.inline b/materialx/libraries/stdlib/genosl/mx_texcoord_vector3.inline deleted file mode 100644 index 4a2056bf6..000000000 --- a/materialx/libraries/stdlib/genosl/mx_texcoord_vector3.inline +++ /dev/null @@ -1 +0,0 @@ -vector(u,v,0) \ No newline at end of file diff --git a/materialx/libraries/stdlib/genosl/mx_time_float.osl b/materialx/libraries/stdlib/genosl/mx_time_float.osl deleted file mode 100644 index 895e0c579..000000000 --- a/materialx/libraries/stdlib/genosl/mx_time_float.osl +++ /dev/null @@ -1,6 +0,0 @@ -void mx_time_float(float fps, output float result) -{ - float frame; - getattribute("frame", frame); - result = frame / fps; -} diff --git a/materialx/libraries/stdlib/genosl/mx_transformmatrix.inline b/materialx/libraries/stdlib/genosl/mx_transformmatrix.inline deleted file mode 100644 index fd1213104..000000000 --- a/materialx/libraries/stdlib/genosl/mx_transformmatrix.inline +++ /dev/null @@ -1 +0,0 @@ -transform({{mat}}, {{in}}) diff --git a/materialx/libraries/stdlib/genosl/mx_transformmatrix_vector2M3.osl b/materialx/libraries/stdlib/genosl/mx_transformmatrix_vector2M3.osl deleted file mode 100644 index fe1937b80..000000000 --- a/materialx/libraries/stdlib/genosl/mx_transformmatrix_vector2M3.osl +++ /dev/null @@ -1,6 +0,0 @@ -void mx_transformmatrix_vector2M3(vector2 val, matrix m, output vector2 result) -{ - point res = transform(m, point(val.x, val.y, 1.0)); - result.x = res[0]; - result.y = res[1]; -} diff --git a/materialx/libraries/stdlib/genosl/mx_transformnormal.inline b/materialx/libraries/stdlib/genosl/mx_transformnormal.inline deleted file mode 100644 index 4a6ad62b7..000000000 --- a/materialx/libraries/stdlib/genosl/mx_transformnormal.inline +++ /dev/null @@ -1 +0,0 @@ -transform({{fromspace}}, {{tospace}}, normal({{in}})) diff --git a/materialx/libraries/stdlib/genosl/mx_transformpoint.inline b/materialx/libraries/stdlib/genosl/mx_transformpoint.inline deleted file mode 100644 index a5fe17757..000000000 --- a/materialx/libraries/stdlib/genosl/mx_transformpoint.inline +++ /dev/null @@ -1 +0,0 @@ -transform({{fromspace}}, {{tospace}}, point({{in}})) diff --git a/materialx/libraries/stdlib/genosl/mx_transformvector.inline b/materialx/libraries/stdlib/genosl/mx_transformvector.inline deleted file mode 100644 index 816abd8e5..000000000 --- a/materialx/libraries/stdlib/genosl/mx_transformvector.inline +++ /dev/null @@ -1 +0,0 @@ -transform({{fromspace}}, {{tospace}}, {{in}}) diff --git a/materialx/libraries/stdlib/genosl/mx_transpose.inline b/materialx/libraries/stdlib/genosl/mx_transpose.inline deleted file mode 100644 index 6a195a036..000000000 --- a/materialx/libraries/stdlib/genosl/mx_transpose.inline +++ /dev/null @@ -1 +0,0 @@ -transpose({{in}}) diff --git a/materialx/libraries/stdlib/genosl/mx_unpremult_color4.osl b/materialx/libraries/stdlib/genosl/mx_unpremult_color4.osl deleted file mode 100644 index 55d074c76..000000000 --- a/materialx/libraries/stdlib/genosl/mx_unpremult_color4.osl +++ /dev/null @@ -1,4 +0,0 @@ -void mx_unpremult_color4(color4 in, output color4 result) -{ - result = color4(in.rgb / in.a, in.a); -} diff --git a/materialx/libraries/stdlib/genosl/stdlib_genosl_cm_impl.mtlx b/materialx/libraries/stdlib/genosl/stdlib_genosl_cm_impl.mtlx deleted file mode 100644 index 08baa7504..000000000 --- a/materialx/libraries/stdlib/genosl/stdlib_genosl_cm_impl.mtlx +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/materialx/libraries/stdlib/genosl/stdlib_genosl_impl.mtlx b/materialx/libraries/stdlib/genosl/stdlib_genosl_impl.mtlx deleted file mode 100644 index d06928cb2..000000000 --- a/materialx/libraries/stdlib/genosl/stdlib_genosl_impl.mtlx +++ /dev/null @@ -1,775 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/materialx/libraries/stdlib/genosl/stdlib_genosl_unit_impl.mtlx b/materialx/libraries/stdlib/genosl/stdlib_genosl_unit_impl.mtlx deleted file mode 100644 index 23d97d2b2..000000000 --- a/materialx/libraries/stdlib/genosl/stdlib_genosl_unit_impl.mtlx +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/materialx/libraries/stdlib/osl/README.md b/materialx/libraries/stdlib/osl/README.md deleted file mode 100644 index 74d70bf87..000000000 --- a/materialx/libraries/stdlib/osl/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# OSL Reference Implementations - -This folder contains reference OSL implementations for the standard MaterialX nodes, documenting their intended functionality as of MaterialX v1.35. - -The Open Shading Language team maintains source file generators for the MaterialX nodes at https://github.com/imageworks/OpenShadingLanguage/tree/master/src/shaders/MaterialX, and these source files were built from [this version](https://github.com/imageworks/OpenShadingLanguage/tree/e9e55306ea7b4356b51c91c180e6e9ac1cad6bb1) of the repository. diff --git a/materialx/libraries/stdlib/osl/color4.h b/materialx/libraries/stdlib/osl/color4.h deleted file mode 100644 index bd05d639a..000000000 --- a/materialx/libraries/stdlib/osl/color4.h +++ /dev/null @@ -1,332 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE - -#pragma once -#define COLOR4_H - - -// color4 is a color + alpha -struct color4 -{ - color rgb; - float a; -}; - - - -// -// For color4, define math operators to match color -// - -color4 __operator__neg__(color4 a) -{ - return color4(-a.rgb, -a.a); -} - -color4 __operator__add__(color4 a, color4 b) -{ - return color4(a.rgb + b.rgb, a.a + b.a); -} - -color4 __operator__add__(color4 a, int b) -{ - return a + color4(color(b), b); -} - -color4 __operator__add__(color4 a, float b) -{ - return a + color4(color(b), b); -} - -color4 __operator__add__(int a, color4 b) -{ - return color4(color(a), a) + b; -} - -color4 __operator__add__(float a, color4 b) -{ - return color4(color(a), a) + b; -} - -color4 __operator__sub__(color4 a, color4 b) -{ - return color4(a.rgb - b.rgb, a.a - b.a); -} - -color4 __operator__sub__(color4 a, int b) -{ - return a - color4(color(b), b); -} - -color4 __operator__sub__(color4 a, float b) -{ - return a - color4(color(b), b); -} - -color4 __operator__sub__(int a, color4 b) -{ - return color4(color(a), a) - b; -} - -color4 __operator__sub__(float a, color4 b) -{ - return color4(color(a), a) - b; -} - -color4 __operator__mul__(color4 a, color4 b) -{ - return color4(a.rgb * b.rgb, a.a * b.a); -} - -color4 __operator__mul__(color4 a, int b) -{ - return a * color4(color(b), b); -} - -color4 __operator__mul__(color4 a, float b) -{ - return a * color4(color(b), b); -} - -color4 __operator__mul__(int a, color4 b) -{ - return color4(color(a), a) * b; -} - -color4 __operator__mul__(float a, color4 b) -{ - return color4(color(a), a) * b; -} - -color4 __operator__div__(color4 a, color4 b) -{ - return color4(a.rgb / b.rgb, a.a / b.a); -} - -color4 __operator__div__(color4 a, int b) -{ - float b_inv = 1.0/b; - return a * color4(color(b_inv), b_inv); -} - -color4 __operator__div__(color4 a, float b) -{ - float b_inv = 1.0/b; - return a * color4(color(b_inv), b_inv); -} - -color4 __operator_div__(int a, color4 b) -{ - return color4(color(a), a) / b; -} - -color4 __operator__div__(float a, color4 b) -{ - return color4(color(a), a) / b; -} - -int __operator__eq__(color4 a, color4 b) -{ - return (a.rgb == b.rgb) && (a.a == b.a); -} - -int __operator__ne__(color4 a, color4 b) -{ - return (a.rgb != b.rgb) || (a.a != b.a); -} - - - -// -// For color4, define most of the stdosl functions to match color -// - -color4 abs(color4 a) -{ - return color4(abs(a.rgb), abs(a.a)); -} - -color4 ceil(color4 a) -{ - return color4(ceil(a.rgb), ceil(a.a)); -} - -color4 floor(color4 a) -{ - return color4(floor(a.rgb), floor(a.a)); -} - -color4 sqrt(color4 a) -{ - return color4(sqrt(a.rgb), sqrt(a.a)); -} - -color4 exp(color4 a) -{ - return color4(exp(a.rgb), exp(a.a)); -} - -color4 log(color4 a) -{ - return color4(log(a.rgb), log(a.a)); -} - -color4 log2(color4 a) -{ - return color4(log2(a.rgb), log2(a.a)); -} - -color4 mix(color4 a, color4 b, float x ) -{ - return color4(mix(a.rgb, b.rgb, x), - mix(a.a, b.a, x)); -} - -float dot(color4 a, color b) -{ - return dot(a.rgb, b); -} - -color4 smoothstep(color4 edge0, color4 edge1, color4 c) -{ - return color4(smoothstep(edge0.rgb, edge1.rgb, c.rgb), - smoothstep(edge0.a, edge1.a, c.a)); -} - -color4 smoothstep(float edge0, float edge1, color4 c) -{ - return smoothstep(color4(color(edge0), edge0), color4(color(edge1), edge1), c); -} - -color4 clamp(color4 c, color4 minval, color4 maxval) -{ - return color4(clamp(c.rgb, minval.rgb, maxval.rgb), - clamp(c.a, minval.a, maxval.a)); -} - -color4 clamp(color4 c, float minval, float maxval) -{ - return clamp(c, color4(color(minval), minval), color4(color(maxval), maxval)); -} - -color4 max(color4 a, color4 b) -{ - return color4(max(a.rgb, b.rgb), - max(a.a, b.a)); -} - -color4 max(color4 a, float b) -{ - return color4(max(a.rgb, b), - max(a.a, b)); -} - -color4 min(color4 a, color4 b) -{ - return color4(min(a.rgb, b.rgb), - min(a.a, b.a)); -} - -color4 min(color4 a, float b) -{ - return color4(min(a.rgb, b), - min(a.a, b)); -} - -color4 mod(color4 a, color4 b) -{ - return color4(mod(a.rgb, b.rgb), - mod(a.a, b.a)); -} - -color4 mod(color4 a, int b) -{ - return mod(a, color4(color(b), b)); -} - -color4 mod(color4 a, float b) -{ - return mod(a, color4(color(b), b)); -} - -color4 fmod(color4 a, color4 b) -{ - return color4(fmod(a.rgb, b.rgb), - fmod(a.a, b.a)); -} - -color4 fmod(color4 a, int b) -{ - return fmod(a, color4(color(b), b)); -} - -color4 fmod(color4 a, float b) -{ - return fmod(a, color4(color(b), b)); -} - -color4 pow(color4 base, color4 power) -{ - return color4(pow(base.rgb, power.rgb), - pow(base.a, power.a)); -} - -color4 pow(color4 base, float power) -{ - return color4(pow(base.rgb, power), - pow(base.a, power)); -} - -color4 sign(color4 a) -{ - return color4(sign(a.rgb), - sign(a.a)); -} - -color4 sin(color4 a) -{ - return color4(sin(a.rgb), - sin(a.a)); -} - -color4 cos(color4 a) -{ - return color4(cos(a.rgb), - cos(a.a)); -} - -color4 tan(color4 a) -{ - return color4(tan(a.rgb), - tan(a.a)); -} - -color4 asin(color4 a) -{ - return color4(asin(a.rgb), - asin(a.a)); -} - -color4 acos(color4 a) -{ - return color4(acos(a.rgb), - acos(a.a)); -} - -color4 atan2(color4 a, float f) -{ - return color4(atan2(a.rgb, f), - atan2(a.a, f)); -} - -color4 atan2(color4 a, color4 b) -{ - return color4(atan2(a.rgb, b.rgb), - atan2(a.a, b.a)); -} - - -color4 transformc (string fromspace, string tospace, color4 C) -{ - return color4 (transformc (fromspace, tospace, C.rgb), C.a); -} diff --git a/materialx/libraries/stdlib/osl/matrix33.h b/materialx/libraries/stdlib/osl/matrix33.h deleted file mode 100644 index 05537dea7..000000000 --- a/materialx/libraries/stdlib/osl/matrix33.h +++ /dev/null @@ -1,165 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#pragma once -#define MATRIX33_H - - -struct matrix33 -{ - matrix m; -}; - -int isValidAs33(matrix m44) -{ - return m44[0][3] == 0 && - m44[1][3] == 0 && - m44[2][3] == 0 && - m44[3][0] == 0 && - m44[3][1] == 0 && - m44[3][2] == 0 && - m44[3][3] == 1; -} - -matrix matrix33To44 (matrix33 m33) -{ - return m33.m; -} - -// Convert an arbitrary m44 to m33 by removing the translation -//QUESTION: should we check if it's valid to represent the 4x4 as a 3x3? -matrix33 matrix44To33 (matrix m44) -{ - matrix33 m33; - m33.m = m44; - m33.m[0][3] = 0; - m33.m[1][3] = 0; - m33.m[2][3] = 0; - m33.m[3][0] = 0; - m33.m[3][1] = 0; - m33.m[3][2] = 0; - m33.m[3][3] = 1; - - return m33; -} - -matrix33 __operator__neg__(matrix33 a) -{ - matrix33 m33; - m33.m = -a.m; - return m33; -} - - -matrix33 __operator__mul__(int a, matrix33 b) -{ - matrix33 m33; - m33.m = a * b.m; - return m33; -} - -matrix33 __operator__mul__(float a, matrix33 b) -{ - matrix33 m33; - m33.m = a * b.m; - return m33; -} - -matrix33 __operator__mul__(matrix33 a, int b) -{ - matrix33 m33; - m33.m = a.m * b; - return m33; -} - -matrix33 __operator__mul__(matrix33 a, float b) -{ - matrix33 m33; - m33.m = a.m * b; - return m33; -} - -matrix33 __operator__mul__(matrix33 a, matrix33 b) -{ - matrix33 m33; - m33.m = a.m * b.m; - return m33; -} - -matrix33 __operator__div__(int a, matrix33 b) -{ - matrix33 m33; - m33.m = a / b.m; - return m33; -} - -matrix33 __operator__div__(float a, matrix33 b) -{ - matrix33 m33; - m33.m = a / b.m; - return m33; -} - -matrix33 __operator__div__(matrix33 a, int b) -{ - matrix33 m33; - m33.m = a.m / b; - return m33; -} - -matrix33 __operator__div__(matrix33 a, float b) -{ - matrix33 m33; - m33.m = a.m / b; - return m33; -} - -matrix33 __operator__div__(matrix33 a, matrix33 b) -{ - matrix33 m33; - m33.m = a.m / b.m; - return m33; -} - -int __operator__eq__(matrix33 a, matrix33 b) -{ - return a.m == b.m; -} - -int __operator__ne__(matrix33 a, matrix33 b) -{ - return a.m != b.m; -} - -float determinant (matrix33 a) -{ - return determinant(a.m); -} - -matrix33 transpose(matrix33 a) -{ - matrix33 m33; - m33.m = transpose(a.m); - return m33; -} - -point transform(matrix33 a, point b) -{ - return transform(a.m, b); -} - -vector transform(matrix33 a, vector b) -{ - return transform(a.m, b); -} - -normal transform(matrix33 a, normal b) -{ - return transform(a.m, b); -} - - - diff --git a/materialx/libraries/stdlib/osl/mx_absval_color.osl b/materialx/libraries/stdlib/osl/mx_absval_color.osl deleted file mode 100644 index 87f34904e..000000000 --- a/materialx/libraries/stdlib/osl/mx_absval_color.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_absval_color - [[ string help = "The per-channel absolute value of the incoming float/color/vector." ]] - ( - color in = 0, - output color out = 0 - ) -{ - out = abs(in); -} diff --git a/materialx/libraries/stdlib/osl/mx_absval_color4.osl b/materialx/libraries/stdlib/osl/mx_absval_color4.osl deleted file mode 100644 index c9973dc56..000000000 --- a/materialx/libraries/stdlib/osl/mx_absval_color4.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_absval_color4 - [[ string help = "The per-channel absolute value of the incoming float/color/vector." ]] - ( - color4 in = {color(0,0,0), 0}, - output color4 out = {color(0,0,0), 0} - ) -{ - out = abs(in); -} diff --git a/materialx/libraries/stdlib/osl/mx_absval_float.osl b/materialx/libraries/stdlib/osl/mx_absval_float.osl deleted file mode 100644 index ee23b2b8c..000000000 --- a/materialx/libraries/stdlib/osl/mx_absval_float.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_absval_float - [[ string help = "The per-channel absolute value of the incoming float/color/vector." ]] - ( - float in = 0, - output float out = 0 - ) -{ - out = abs(in); -} diff --git a/materialx/libraries/stdlib/osl/mx_absval_vector.osl b/materialx/libraries/stdlib/osl/mx_absval_vector.osl deleted file mode 100644 index 6800614bd..000000000 --- a/materialx/libraries/stdlib/osl/mx_absval_vector.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_absval_vector - [[ string help = "The per-channel absolute value of the incoming float/color/vector." ]] - ( - vector in = 0, - output vector out = 0 - ) -{ - out = abs(in); -} diff --git a/materialx/libraries/stdlib/osl/mx_absval_vector2.osl b/materialx/libraries/stdlib/osl/mx_absval_vector2.osl deleted file mode 100644 index d56c18313..000000000 --- a/materialx/libraries/stdlib/osl/mx_absval_vector2.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_absval_vector2 - [[ string help = "The per-channel absolute value of the incoming float/color/vector." ]] - ( - vector2 in = {0,0}, - output vector2 out = {0,0} - ) -{ - out = abs(in); -} diff --git a/materialx/libraries/stdlib/osl/mx_absval_vector4.osl b/materialx/libraries/stdlib/osl/mx_absval_vector4.osl deleted file mode 100644 index 133524090..000000000 --- a/materialx/libraries/stdlib/osl/mx_absval_vector4.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_absval_vector4 - [[ string help = "The per-channel absolute value of the incoming float/color/vector." ]] - ( - vector4 in = {0,0,0,0}, - output vector4 out = {0,0,0,0} - ) -{ - out = abs(in); -} diff --git a/materialx/libraries/stdlib/osl/mx_acos_color.osl b/materialx/libraries/stdlib/osl/mx_acos_color.osl deleted file mode 100644 index bd17e6a7e..000000000 --- a/materialx/libraries/stdlib/osl/mx_acos_color.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_acos_color - [[ string help = "Color"" acos(in)" ]] - ( - color in = 0, - output color out = 0 - ) -{ - out = acos(in); -} diff --git a/materialx/libraries/stdlib/osl/mx_acos_color4.osl b/materialx/libraries/stdlib/osl/mx_acos_color4.osl deleted file mode 100644 index 5462b0b4e..000000000 --- a/materialx/libraries/stdlib/osl/mx_acos_color4.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_acos_color4 - [[ string help = "Color4"" acos(in)" ]] - ( - color4 in = {color(0,0,0), 0}, - output color4 out = {color(0,0,0), 0} - ) -{ - out = acos(in); -} diff --git a/materialx/libraries/stdlib/osl/mx_acos_float.osl b/materialx/libraries/stdlib/osl/mx_acos_float.osl deleted file mode 100644 index 90f8c16f2..000000000 --- a/materialx/libraries/stdlib/osl/mx_acos_float.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_acos_float - [[ string help = "Float"" acos(in)" ]] - ( - float in = 0, - output float out = 0 - ) -{ - out = acos(in); -} diff --git a/materialx/libraries/stdlib/osl/mx_acos_vector.osl b/materialx/libraries/stdlib/osl/mx_acos_vector.osl deleted file mode 100644 index a4a9b309e..000000000 --- a/materialx/libraries/stdlib/osl/mx_acos_vector.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_acos_vector - [[ string help = "Vector"" acos(in)" ]] - ( - vector in = 0, - output vector out = 0 - ) -{ - out = acos(in); -} diff --git a/materialx/libraries/stdlib/osl/mx_acos_vector2.osl b/materialx/libraries/stdlib/osl/mx_acos_vector2.osl deleted file mode 100644 index faa8cd33c..000000000 --- a/materialx/libraries/stdlib/osl/mx_acos_vector2.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_acos_vector2 - [[ string help = "Vector2"" acos(in)" ]] - ( - vector2 in = {0,0}, - output vector2 out = {0,0} - ) -{ - out = acos(in); -} diff --git a/materialx/libraries/stdlib/osl/mx_acos_vector4.osl b/materialx/libraries/stdlib/osl/mx_acos_vector4.osl deleted file mode 100644 index 48016c40d..000000000 --- a/materialx/libraries/stdlib/osl/mx_acos_vector4.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_acos_vector4 - [[ string help = "Vector4"" acos(in)" ]] - ( - vector4 in = {0,0,0,0}, - output vector4 out = {0,0,0,0} - ) -{ - out = acos(in); -} diff --git a/materialx/libraries/stdlib/osl/mx_add_color.osl b/materialx/libraries/stdlib/osl/mx_add_color.osl deleted file mode 100644 index 6607a803c..000000000 --- a/materialx/libraries/stdlib/osl/mx_add_color.osl +++ /dev/null @@ -1,19 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - - -shader mx_add_color - [[ string help = "Color"" add in2 to the incoming data" ]] - ( - color in1 = 0, - color in2 = 0, - output color out = 0 - ) -{ - out = mx_add (in1, in2); -} diff --git a/materialx/libraries/stdlib/osl/mx_add_color4.osl b/materialx/libraries/stdlib/osl/mx_add_color4.osl deleted file mode 100644 index 4cb30c69a..000000000 --- a/materialx/libraries/stdlib/osl/mx_add_color4.osl +++ /dev/null @@ -1,19 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - - -shader mx_add_color4 - [[ string help = "Color4"" add in2 to the incoming data" ]] - ( - color4 in1 = {color(0,0,0), 0}, - color4 in2 = {color(0,0,0), 0}, - output color4 out = {color(0,0,0), 0} - ) -{ - out = mx_add (in1, in2); -} diff --git a/materialx/libraries/stdlib/osl/mx_add_float.osl b/materialx/libraries/stdlib/osl/mx_add_float.osl deleted file mode 100644 index 2703bfcd3..000000000 --- a/materialx/libraries/stdlib/osl/mx_add_float.osl +++ /dev/null @@ -1,19 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - - -shader mx_add_float - [[ string help = "Float"" add in2 to the incoming data" ]] - ( - float in1 = 0, - float in2 = 0, - output float out = 0 - ) -{ - out = mx_add (in1, in2); -} diff --git a/materialx/libraries/stdlib/osl/mx_add_float_color.osl b/materialx/libraries/stdlib/osl/mx_add_float_color.osl deleted file mode 100644 index d3c7a7b9d..000000000 --- a/materialx/libraries/stdlib/osl/mx_add_float_color.osl +++ /dev/null @@ -1,18 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_add_float_color - [[ string help = "Color"" add in2 to the incoming data" ]] - ( - color in1 = 0, - float in2 = 0.0, - output color out = 0 - ) -{ - out = mx_add (in1, in2); -} diff --git a/materialx/libraries/stdlib/osl/mx_add_float_color4.osl b/materialx/libraries/stdlib/osl/mx_add_float_color4.osl deleted file mode 100644 index b8912c3b4..000000000 --- a/materialx/libraries/stdlib/osl/mx_add_float_color4.osl +++ /dev/null @@ -1,18 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_add_float_color4 - [[ string help = "Color4"" add in2 to the incoming data" ]] - ( - color4 in1 = {color(0,0,0), 0}, - float in2 = 0.0, - output color4 out = {color(0,0,0), 0} - ) -{ - out = mx_add (in1, in2); -} diff --git a/materialx/libraries/stdlib/osl/mx_add_float_matrix33.osl b/materialx/libraries/stdlib/osl/mx_add_float_matrix33.osl deleted file mode 100644 index 6095b88ea..000000000 --- a/materialx/libraries/stdlib/osl/mx_add_float_matrix33.osl +++ /dev/null @@ -1,18 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_add_float_matrix33 - [[ string help = "Matrix33"" add in2 to the incoming data" ]] - ( - matrix in1 = matrix(0), - float in2 = 0.0, - output matrix out = matrix(0) - ) -{ - out = mx_add (in1, in2); -} diff --git a/materialx/libraries/stdlib/osl/mx_add_float_matrix44.osl b/materialx/libraries/stdlib/osl/mx_add_float_matrix44.osl deleted file mode 100644 index 2533aeb47..000000000 --- a/materialx/libraries/stdlib/osl/mx_add_float_matrix44.osl +++ /dev/null @@ -1,18 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_add_float_matrix44 - [[ string help = "Matrix44"" add in2 to the incoming data" ]] - ( - matrix in1 = matrix(0), - float in2 = 0.0, - output matrix out = matrix(0) - ) -{ - out = mx_add (in1, in2); -} diff --git a/materialx/libraries/stdlib/osl/mx_add_float_vector.osl b/materialx/libraries/stdlib/osl/mx_add_float_vector.osl deleted file mode 100644 index e130766ee..000000000 --- a/materialx/libraries/stdlib/osl/mx_add_float_vector.osl +++ /dev/null @@ -1,18 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_add_float_vector - [[ string help = "Vector"" add in2 to the incoming data" ]] - ( - vector in1 = 0, - float in2 = 0.0, - output vector out = 0 - ) -{ - out = mx_add (in1, in2); -} diff --git a/materialx/libraries/stdlib/osl/mx_add_float_vector2.osl b/materialx/libraries/stdlib/osl/mx_add_float_vector2.osl deleted file mode 100644 index 724a893f6..000000000 --- a/materialx/libraries/stdlib/osl/mx_add_float_vector2.osl +++ /dev/null @@ -1,18 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_add_float_vector2 - [[ string help = "Vector2"" add in2 to the incoming data" ]] - ( - vector2 in1 = {0,0}, - float in2 = 0.0, - output vector2 out = {0,0} - ) -{ - out = mx_add (in1, in2); -} diff --git a/materialx/libraries/stdlib/osl/mx_add_float_vector4.osl b/materialx/libraries/stdlib/osl/mx_add_float_vector4.osl deleted file mode 100644 index 00b8b8a49..000000000 --- a/materialx/libraries/stdlib/osl/mx_add_float_vector4.osl +++ /dev/null @@ -1,18 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_add_float_vector4 - [[ string help = "Vector4"" add in2 to the incoming data" ]] - ( - vector4 in1 = {0,0,0,0}, - float in2 = 0.0, - output vector4 out = {0,0,0,0} - ) -{ - out = mx_add (in1, in2); -} diff --git a/materialx/libraries/stdlib/osl/mx_add_matrix33.osl b/materialx/libraries/stdlib/osl/mx_add_matrix33.osl deleted file mode 100644 index 75e7683b2..000000000 --- a/materialx/libraries/stdlib/osl/mx_add_matrix33.osl +++ /dev/null @@ -1,19 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - - -shader mx_add_matrix33 - [[ string help = "Matrix33"" add in2 to the incoming data" ]] - ( - matrix in1 = matrix(0), - matrix in2 = matrix(0), - output matrix out = matrix(0) - ) -{ - out = mx_add (in1, in2); -} diff --git a/materialx/libraries/stdlib/osl/mx_add_matrix44.osl b/materialx/libraries/stdlib/osl/mx_add_matrix44.osl deleted file mode 100644 index b38e05ff9..000000000 --- a/materialx/libraries/stdlib/osl/mx_add_matrix44.osl +++ /dev/null @@ -1,19 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - - -shader mx_add_matrix44 - [[ string help = "Matrix44"" add in2 to the incoming data" ]] - ( - matrix in1 = matrix(0), - matrix in2 = matrix(0), - output matrix out = matrix(0) - ) -{ - out = mx_add (in1, in2); -} diff --git a/materialx/libraries/stdlib/osl/mx_add_surfaceshader.osl b/materialx/libraries/stdlib/osl/mx_add_surfaceshader.osl deleted file mode 100644 index b980c7d15..000000000 --- a/materialx/libraries/stdlib/osl/mx_add_surfaceshader.osl +++ /dev/null @@ -1,19 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - - -shader mx_add_surfaceshader - [[ string help = "surfaceshader"" add in2 to the incoming data" ]] - ( - closure color in1 = 0, - closure color in2 = 0, - output closure color out = 0 - ) -{ - out = mx_add (in1, in2); -} diff --git a/materialx/libraries/stdlib/osl/mx_add_vector.osl b/materialx/libraries/stdlib/osl/mx_add_vector.osl deleted file mode 100644 index a94ef17eb..000000000 --- a/materialx/libraries/stdlib/osl/mx_add_vector.osl +++ /dev/null @@ -1,19 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - - -shader mx_add_vector - [[ string help = "Vector"" add in2 to the incoming data" ]] - ( - vector in1 = 0, - vector in2 = 0, - output vector out = 0 - ) -{ - out = mx_add (in1, in2); -} diff --git a/materialx/libraries/stdlib/osl/mx_add_vector2.osl b/materialx/libraries/stdlib/osl/mx_add_vector2.osl deleted file mode 100644 index 5f8c57167..000000000 --- a/materialx/libraries/stdlib/osl/mx_add_vector2.osl +++ /dev/null @@ -1,19 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - - -shader mx_add_vector2 - [[ string help = "Vector2"" add in2 to the incoming data" ]] - ( - vector2 in1 = {0,0}, - vector2 in2 = {0,0}, - output vector2 out = {0,0} - ) -{ - out = mx_add (in1, in2); -} diff --git a/materialx/libraries/stdlib/osl/mx_add_vector4.osl b/materialx/libraries/stdlib/osl/mx_add_vector4.osl deleted file mode 100644 index f179047f2..000000000 --- a/materialx/libraries/stdlib/osl/mx_add_vector4.osl +++ /dev/null @@ -1,19 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - - -shader mx_add_vector4 - [[ string help = "Vector4"" add in2 to the incoming data" ]] - ( - vector4 in1 = {0,0,0,0}, - vector4 in2 = {0,0,0,0}, - output vector4 out = {0,0,0,0} - ) -{ - out = mx_add (in1, in2); -} diff --git a/materialx/libraries/stdlib/osl/mx_ambientocclusion_float.osl b/materialx/libraries/stdlib/osl/mx_ambientocclusion_float.osl deleted file mode 100644 index db6396e8e..000000000 --- a/materialx/libraries/stdlib/osl/mx_ambientocclusion_float.osl +++ /dev/null @@ -1,19 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_ambientocclusion_float - [[ string help = "Computes the ambient occlusion (0-1 float) at the current surface point." ]] - ( - float coneangle = 90, - float maxdistance = 1000000, - output float out = 0 - ) -{ - // This node is a stub and does not currently operate to specification - out = 0; -} diff --git a/materialx/libraries/stdlib/osl/mx_asin_color.osl b/materialx/libraries/stdlib/osl/mx_asin_color.osl deleted file mode 100644 index de3bbada3..000000000 --- a/materialx/libraries/stdlib/osl/mx_asin_color.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_asin_color - [[ string help = "Color"" asin(in)" ]] - ( - color in = 0, - output color out = 0 - ) -{ - out = asin(in); -} diff --git a/materialx/libraries/stdlib/osl/mx_asin_color4.osl b/materialx/libraries/stdlib/osl/mx_asin_color4.osl deleted file mode 100644 index f9d359cc6..000000000 --- a/materialx/libraries/stdlib/osl/mx_asin_color4.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_asin_color4 - [[ string help = "Color4"" asin(in)" ]] - ( - color4 in = {color(0,0,0), 0}, - output color4 out = {color(0,0,0), 0} - ) -{ - out = asin(in); -} diff --git a/materialx/libraries/stdlib/osl/mx_asin_float.osl b/materialx/libraries/stdlib/osl/mx_asin_float.osl deleted file mode 100644 index ad7cae933..000000000 --- a/materialx/libraries/stdlib/osl/mx_asin_float.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_asin_float - [[ string help = "Float"" asin(in)" ]] - ( - float in = 0, - output float out = 0 - ) -{ - out = asin(in); -} diff --git a/materialx/libraries/stdlib/osl/mx_asin_vector.osl b/materialx/libraries/stdlib/osl/mx_asin_vector.osl deleted file mode 100644 index aa4663727..000000000 --- a/materialx/libraries/stdlib/osl/mx_asin_vector.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_asin_vector - [[ string help = "Vector"" asin(in)" ]] - ( - vector in = 0, - output vector out = 0 - ) -{ - out = asin(in); -} diff --git a/materialx/libraries/stdlib/osl/mx_asin_vector2.osl b/materialx/libraries/stdlib/osl/mx_asin_vector2.osl deleted file mode 100644 index 65a1ce5e2..000000000 --- a/materialx/libraries/stdlib/osl/mx_asin_vector2.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_asin_vector2 - [[ string help = "Vector2"" asin(in)" ]] - ( - vector2 in = {0,0}, - output vector2 out = {0,0} - ) -{ - out = asin(in); -} diff --git a/materialx/libraries/stdlib/osl/mx_asin_vector4.osl b/materialx/libraries/stdlib/osl/mx_asin_vector4.osl deleted file mode 100644 index 3d818ea7c..000000000 --- a/materialx/libraries/stdlib/osl/mx_asin_vector4.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_asin_vector4 - [[ string help = "Vector4"" asin(in)" ]] - ( - vector4 in = {0,0,0,0}, - output vector4 out = {0,0,0,0} - ) -{ - out = asin(in); -} diff --git a/materialx/libraries/stdlib/osl/mx_atan2_color.osl b/materialx/libraries/stdlib/osl/mx_atan2_color.osl deleted file mode 100644 index 73c48db13..000000000 --- a/materialx/libraries/stdlib/osl/mx_atan2_color.osl +++ /dev/null @@ -1,19 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_atan2_color - [[ string help = "Color"" atan2(in1, in2)" ]] - ( - color in1 = 0, - color in2 = 0, - - output color out = 0 - ) -{ - out = atan2(in1, in2); -} diff --git a/materialx/libraries/stdlib/osl/mx_atan2_color4.osl b/materialx/libraries/stdlib/osl/mx_atan2_color4.osl deleted file mode 100644 index e886f1d94..000000000 --- a/materialx/libraries/stdlib/osl/mx_atan2_color4.osl +++ /dev/null @@ -1,19 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_atan2_color4 - [[ string help = "Color4"" atan2(in1, in2)" ]] - ( - color4 in1 = {color(0,0,0), 0}, - color4 in2 = {color(0,0,0), 0}, - - output color4 out = {color(0,0,0), 0} - ) -{ - out = atan2(in1, in2); -} diff --git a/materialx/libraries/stdlib/osl/mx_atan2_float.osl b/materialx/libraries/stdlib/osl/mx_atan2_float.osl deleted file mode 100644 index ab8007a47..000000000 --- a/materialx/libraries/stdlib/osl/mx_atan2_float.osl +++ /dev/null @@ -1,19 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_atan2_float - [[ string help = "Float"" atan2(in1, in2)" ]] - ( - float in1 = 0, - float in2 = 0, - - output float out = 0 - ) -{ - out = atan2(in1, in2); -} diff --git a/materialx/libraries/stdlib/osl/mx_atan2_float_color.osl b/materialx/libraries/stdlib/osl/mx_atan2_float_color.osl deleted file mode 100644 index b9e9bc464..000000000 --- a/materialx/libraries/stdlib/osl/mx_atan2_float_color.osl +++ /dev/null @@ -1,19 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_atan2_float_color - [[ string help = "Color"" atan2(in1, in2)" ]] - ( - color in1 = 0, - float in2 = 0.0, - - output color out = 0 - ) -{ - out = atan2(in1, in2); -} diff --git a/materialx/libraries/stdlib/osl/mx_atan2_float_color4.osl b/materialx/libraries/stdlib/osl/mx_atan2_float_color4.osl deleted file mode 100644 index 32363a4ec..000000000 --- a/materialx/libraries/stdlib/osl/mx_atan2_float_color4.osl +++ /dev/null @@ -1,19 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_atan2_float_color4 - [[ string help = "Color4"" atan2(in1, in2)" ]] - ( - color4 in1 = {color(0,0,0), 0}, - float in2 = 0.0, - - output color4 out = {color(0,0,0), 0} - ) -{ - out = atan2(in1, in2); -} diff --git a/materialx/libraries/stdlib/osl/mx_atan2_float_vector.osl b/materialx/libraries/stdlib/osl/mx_atan2_float_vector.osl deleted file mode 100644 index 4be35e559..000000000 --- a/materialx/libraries/stdlib/osl/mx_atan2_float_vector.osl +++ /dev/null @@ -1,19 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_atan2_float_vector - [[ string help = "Vector"" atan2(in1, in2)" ]] - ( - vector in1 = 0, - float in2 = 0.0, - - output vector out = 0 - ) -{ - out = atan2(in1, in2); -} diff --git a/materialx/libraries/stdlib/osl/mx_atan2_float_vector2.osl b/materialx/libraries/stdlib/osl/mx_atan2_float_vector2.osl deleted file mode 100644 index 6df062e0b..000000000 --- a/materialx/libraries/stdlib/osl/mx_atan2_float_vector2.osl +++ /dev/null @@ -1,19 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_atan2_float_vector2 - [[ string help = "Vector2"" atan2(in1, in2)" ]] - ( - vector2 in1 = {0,0}, - float in2 = 0.0, - - output vector2 out = {0,0} - ) -{ - out = atan2(in1, in2); -} diff --git a/materialx/libraries/stdlib/osl/mx_atan2_float_vector4.osl b/materialx/libraries/stdlib/osl/mx_atan2_float_vector4.osl deleted file mode 100644 index 9b9a2fffd..000000000 --- a/materialx/libraries/stdlib/osl/mx_atan2_float_vector4.osl +++ /dev/null @@ -1,19 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_atan2_float_vector4 - [[ string help = "Vector4"" atan2(in1, in2)" ]] - ( - vector4 in1 = {0,0,0,0}, - float in2 = 0.0, - - output vector4 out = {0,0,0,0} - ) -{ - out = atan2(in1, in2); -} diff --git a/materialx/libraries/stdlib/osl/mx_atan2_vector.osl b/materialx/libraries/stdlib/osl/mx_atan2_vector.osl deleted file mode 100644 index 90a3b169a..000000000 --- a/materialx/libraries/stdlib/osl/mx_atan2_vector.osl +++ /dev/null @@ -1,19 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_atan2_vector - [[ string help = "Vector"" atan2(in1, in2)" ]] - ( - vector in1 = 0, - vector in2 = 0, - - output vector out = 0 - ) -{ - out = atan2(in1, in2); -} diff --git a/materialx/libraries/stdlib/osl/mx_atan2_vector2.osl b/materialx/libraries/stdlib/osl/mx_atan2_vector2.osl deleted file mode 100644 index 098c4e531..000000000 --- a/materialx/libraries/stdlib/osl/mx_atan2_vector2.osl +++ /dev/null @@ -1,19 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_atan2_vector2 - [[ string help = "Vector2"" atan2(in1, in2)" ]] - ( - vector2 in1 = {0,0}, - vector2 in2 = {0,0}, - - output vector2 out = {0,0} - ) -{ - out = atan2(in1, in2); -} diff --git a/materialx/libraries/stdlib/osl/mx_atan2_vector4.osl b/materialx/libraries/stdlib/osl/mx_atan2_vector4.osl deleted file mode 100644 index a8dd1d9a2..000000000 --- a/materialx/libraries/stdlib/osl/mx_atan2_vector4.osl +++ /dev/null @@ -1,19 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_atan2_vector4 - [[ string help = "Vector4"" atan2(in1, in2)" ]] - ( - vector4 in1 = {0,0,0,0}, - vector4 in2 = {0,0,0,0}, - - output vector4 out = {0,0,0,0} - ) -{ - out = atan2(in1, in2); -} diff --git a/materialx/libraries/stdlib/osl/mx_bitangent_vector.osl b/materialx/libraries/stdlib/osl/mx_bitangent_vector.osl deleted file mode 100644 index 0ee208cfd..000000000 --- a/materialx/libraries/stdlib/osl/mx_bitangent_vector.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_bitangent_vector - [[ string help = "The geometric bitangent vector in a specific coordinate space." ]] - ( - string space = "object", - output vector out = 0 - ) -{ - out = transform(space, dPdv); -} diff --git a/materialx/libraries/stdlib/osl/mx_blur_color.osl b/materialx/libraries/stdlib/osl/mx_blur_color.osl deleted file mode 100644 index 4f8429cbd..000000000 --- a/materialx/libraries/stdlib/osl/mx_blur_color.osl +++ /dev/null @@ -1,19 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_blur_color - [[ string help = "A gaussian-falloff blur." ]] - ( - color in = 0, - float amount = 0, - output color out = 0 - ) -{ - // This node is a stub and does not currently operate to specification - out = in; -} diff --git a/materialx/libraries/stdlib/osl/mx_blur_color4.osl b/materialx/libraries/stdlib/osl/mx_blur_color4.osl deleted file mode 100644 index 7f8050ad5..000000000 --- a/materialx/libraries/stdlib/osl/mx_blur_color4.osl +++ /dev/null @@ -1,19 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_blur_color4 - [[ string help = "A gaussian-falloff blur." ]] - ( - color4 in = {color(0,0,0), 0}, - float amount = 0, - output color4 out = {color(0,0,0), 0} - ) -{ - // This node is a stub and does not currently operate to specification - out = in; -} diff --git a/materialx/libraries/stdlib/osl/mx_blur_float.osl b/materialx/libraries/stdlib/osl/mx_blur_float.osl deleted file mode 100644 index fcfd007a6..000000000 --- a/materialx/libraries/stdlib/osl/mx_blur_float.osl +++ /dev/null @@ -1,19 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_blur_float - [[ string help = "A gaussian-falloff blur." ]] - ( - float in = 0, - float amount = 0, - output float out = 0 - ) -{ - // This node is a stub and does not currently operate to specification - out = in; -} diff --git a/materialx/libraries/stdlib/osl/mx_blur_vector.osl b/materialx/libraries/stdlib/osl/mx_blur_vector.osl deleted file mode 100644 index 2763ec64c..000000000 --- a/materialx/libraries/stdlib/osl/mx_blur_vector.osl +++ /dev/null @@ -1,19 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_blur_vector - [[ string help = "A gaussian-falloff blur." ]] - ( - vector in = 0, - float amount = 0, - output vector out = 0 - ) -{ - // This node is a stub and does not currently operate to specification - out = in; -} diff --git a/materialx/libraries/stdlib/osl/mx_blur_vector2.osl b/materialx/libraries/stdlib/osl/mx_blur_vector2.osl deleted file mode 100644 index 219df4bdf..000000000 --- a/materialx/libraries/stdlib/osl/mx_blur_vector2.osl +++ /dev/null @@ -1,19 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_blur_vector2 - [[ string help = "A gaussian-falloff blur." ]] - ( - vector2 in = {0,0}, - float amount = 0, - output vector2 out = {0,0} - ) -{ - // This node is a stub and does not currently operate to specification - out = in; -} diff --git a/materialx/libraries/stdlib/osl/mx_blur_vector4.osl b/materialx/libraries/stdlib/osl/mx_blur_vector4.osl deleted file mode 100644 index d3a07d836..000000000 --- a/materialx/libraries/stdlib/osl/mx_blur_vector4.osl +++ /dev/null @@ -1,19 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_blur_vector4 - [[ string help = "A gaussian-falloff blur." ]] - ( - vector4 in = {0,0,0,0}, - float amount = 0, - output vector4 out = {0,0,0,0} - ) -{ - // This node is a stub and does not currently operate to specification - out = in; -} diff --git a/materialx/libraries/stdlib/osl/mx_burn_color.osl b/materialx/libraries/stdlib/osl/mx_burn_color.osl deleted file mode 100644 index ea5310f92..000000000 --- a/materialx/libraries/stdlib/osl/mx_burn_color.osl +++ /dev/null @@ -1,18 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_burn_color - [[ string help = "Color"" Take two 1-4 channel inputs and apply the same operator to all channels: 1-(1-B)/F" ]] - ( - color fg = 0, - color bg = 0, - output color out = 0 - ) -{ - out = 1 - ((1 - bg) / fg); -} diff --git a/materialx/libraries/stdlib/osl/mx_burn_color4.osl b/materialx/libraries/stdlib/osl/mx_burn_color4.osl deleted file mode 100644 index 87eaf90d4..000000000 --- a/materialx/libraries/stdlib/osl/mx_burn_color4.osl +++ /dev/null @@ -1,18 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_burn_color4 - [[ string help = "Color4"" Take two 1-4 channel inputs and apply the same operator to all channels: 1-(1-B)/F" ]] - ( - color4 fg = {color(0,0,0), 0}, - color4 bg = {color(0,0,0), 0}, - output color4 out = {color(0,0,0), 0} - ) -{ - out = 1 - ((1 - bg) / fg); -} diff --git a/materialx/libraries/stdlib/osl/mx_burn_float.osl b/materialx/libraries/stdlib/osl/mx_burn_float.osl deleted file mode 100644 index f79305c02..000000000 --- a/materialx/libraries/stdlib/osl/mx_burn_float.osl +++ /dev/null @@ -1,18 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_burn_float - [[ string help = "Float"" Take two 1-4 channel inputs and apply the same operator to all channels: 1-(1-B)/F" ]] - ( - float fg = 0, - float bg = 0, - output float out = 0 - ) -{ - out = 1 - ((1 - bg) / fg); -} diff --git a/materialx/libraries/stdlib/osl/mx_ceil_color.osl b/materialx/libraries/stdlib/osl/mx_ceil_color.osl deleted file mode 100644 index 8c366512c..000000000 --- a/materialx/libraries/stdlib/osl/mx_ceil_color.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_ceil_color - [[ string help = "Color"" Find the smallest integer less than or equal to the parameter." ]] - ( - color in = 0, - output color out = 0 - ) -{ - out = ceil(in); -} diff --git a/materialx/libraries/stdlib/osl/mx_ceil_color4.osl b/materialx/libraries/stdlib/osl/mx_ceil_color4.osl deleted file mode 100644 index 834c559a3..000000000 --- a/materialx/libraries/stdlib/osl/mx_ceil_color4.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_ceil_color4 - [[ string help = "Color4"" Find the smallest integer less than or equal to the parameter." ]] - ( - color4 in = {color(0,0,0), 0}, - output color4 out = {color(0,0,0), 0} - ) -{ - out = ceil(in); -} diff --git a/materialx/libraries/stdlib/osl/mx_ceil_float.osl b/materialx/libraries/stdlib/osl/mx_ceil_float.osl deleted file mode 100644 index 5c553d843..000000000 --- a/materialx/libraries/stdlib/osl/mx_ceil_float.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_ceil_float - [[ string help = "Float"" Find the smallest integer less than or equal to the parameter." ]] - ( - float in = 0, - output float out = 0 - ) -{ - out = ceil(in); -} diff --git a/materialx/libraries/stdlib/osl/mx_ceil_vector.osl b/materialx/libraries/stdlib/osl/mx_ceil_vector.osl deleted file mode 100644 index 64aa908d6..000000000 --- a/materialx/libraries/stdlib/osl/mx_ceil_vector.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_ceil_vector - [[ string help = "Vector"" Find the smallest integer less than or equal to the parameter." ]] - ( - vector in = 0, - output vector out = 0 - ) -{ - out = ceil(in); -} diff --git a/materialx/libraries/stdlib/osl/mx_ceil_vector2.osl b/materialx/libraries/stdlib/osl/mx_ceil_vector2.osl deleted file mode 100644 index df6933274..000000000 --- a/materialx/libraries/stdlib/osl/mx_ceil_vector2.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_ceil_vector2 - [[ string help = "Vector2"" Find the smallest integer less than or equal to the parameter." ]] - ( - vector2 in = {0,0}, - output vector2 out = {0,0} - ) -{ - out = ceil(in); -} diff --git a/materialx/libraries/stdlib/osl/mx_ceil_vector4.osl b/materialx/libraries/stdlib/osl/mx_ceil_vector4.osl deleted file mode 100644 index a844d6de8..000000000 --- a/materialx/libraries/stdlib/osl/mx_ceil_vector4.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_ceil_vector4 - [[ string help = "Vector4"" Find the smallest integer less than or equal to the parameter." ]] - ( - vector4 in = {0,0,0,0}, - output vector4 out = {0,0,0,0} - ) -{ - out = ceil(in); -} diff --git a/materialx/libraries/stdlib/osl/mx_cellnoise2d_float.osl b/materialx/libraries/stdlib/osl/mx_cellnoise2d_float.osl deleted file mode 100644 index 97491ad23..000000000 --- a/materialx/libraries/stdlib/osl/mx_cellnoise2d_float.osl +++ /dev/null @@ -1,20 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_cellnoise2d_float - [[ string help = "2D cell noise in 1 channel" ]] - ( - vector2 texcoord = {u, v} - [[ string help = "input coordinate position", - int lockgeom = 0 ]], - - output float out = 0 - ) -{ - out = cellnoise (texcoord.x, texcoord.y); -} diff --git a/materialx/libraries/stdlib/osl/mx_cellnoise3d_float.osl b/materialx/libraries/stdlib/osl/mx_cellnoise3d_float.osl deleted file mode 100644 index 2d524b9ae..000000000 --- a/materialx/libraries/stdlib/osl/mx_cellnoise3d_float.osl +++ /dev/null @@ -1,20 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_cellnoise3d_float - [[ string help = "3D cell noise in one channel" ]] - ( - point position = transform ("object", P) - [[ string help = "input coordinate position (default: object space P)", - int lockgeom = 0 ]], - - output float out = 0 - ) -{ - out = cellnoise (position); -} diff --git a/materialx/libraries/stdlib/osl/mx_clamp_color.osl b/materialx/libraries/stdlib/osl/mx_clamp_color.osl deleted file mode 100644 index 1991029e5..000000000 --- a/materialx/libraries/stdlib/osl/mx_clamp_color.osl +++ /dev/null @@ -1,19 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_clamp_color - [[ string help = "Color"" Clamp incoming value to a specified range of values." ]] - ( - color in = 0, - color low = 0, - color high = 1, - output color out = 0 - ) -{ - out = clamp(in, low, high); -} diff --git a/materialx/libraries/stdlib/osl/mx_clamp_color4.osl b/materialx/libraries/stdlib/osl/mx_clamp_color4.osl deleted file mode 100644 index 85e65755a..000000000 --- a/materialx/libraries/stdlib/osl/mx_clamp_color4.osl +++ /dev/null @@ -1,19 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_clamp_color4 - [[ string help = "Color4"" Clamp incoming value to a specified range of values." ]] - ( - color4 in = {color(0,0,0), 0}, - color4 low = {color(0,0,0), 0}, - color4 high = {color(1,1,1), 1}, - output color4 out = {color(0,0,0), 0} - ) -{ - out = clamp(in, low, high); -} diff --git a/materialx/libraries/stdlib/osl/mx_clamp_float.osl b/materialx/libraries/stdlib/osl/mx_clamp_float.osl deleted file mode 100644 index e27c7d3a3..000000000 --- a/materialx/libraries/stdlib/osl/mx_clamp_float.osl +++ /dev/null @@ -1,19 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_clamp_float - [[ string help = "Float"" Clamp incoming value to a specified range of values." ]] - ( - float in = 0, - float low = 0, - float high = 1, - output float out = 0 - ) -{ - out = clamp(in, low, high); -} diff --git a/materialx/libraries/stdlib/osl/mx_clamp_float_color.osl b/materialx/libraries/stdlib/osl/mx_clamp_float_color.osl deleted file mode 100644 index b45f3b3e1..000000000 --- a/materialx/libraries/stdlib/osl/mx_clamp_float_color.osl +++ /dev/null @@ -1,19 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_clamp_float_color - [[ string help = "Color"" Clamp incoming value to a specified range of values." ]] - ( - color in = 0, - float low = 0.0, - float high = 1.0, - output color out = 0 - ) -{ - out = clamp(in, low, high); -} diff --git a/materialx/libraries/stdlib/osl/mx_clamp_float_color4.osl b/materialx/libraries/stdlib/osl/mx_clamp_float_color4.osl deleted file mode 100644 index 67ad0ce28..000000000 --- a/materialx/libraries/stdlib/osl/mx_clamp_float_color4.osl +++ /dev/null @@ -1,19 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_clamp_float_color4 - [[ string help = "Color4"" Clamp incoming value to a specified range of values." ]] - ( - color4 in = {color(0,0,0), 0}, - float low = 0.0, - float high = 1.0, - output color4 out = {color(0,0,0), 0} - ) -{ - out = clamp(in, low, high); -} diff --git a/materialx/libraries/stdlib/osl/mx_clamp_float_vector.osl b/materialx/libraries/stdlib/osl/mx_clamp_float_vector.osl deleted file mode 100644 index 7a5861d0c..000000000 --- a/materialx/libraries/stdlib/osl/mx_clamp_float_vector.osl +++ /dev/null @@ -1,19 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_clamp_float_vector - [[ string help = "Vector"" Clamp incoming value to a specified range of values." ]] - ( - vector in = 0, - float low = 0.0, - float high = 1.0, - output vector out = 0 - ) -{ - out = clamp(in, low, high); -} diff --git a/materialx/libraries/stdlib/osl/mx_clamp_float_vector2.osl b/materialx/libraries/stdlib/osl/mx_clamp_float_vector2.osl deleted file mode 100644 index 98a7c31eb..000000000 --- a/materialx/libraries/stdlib/osl/mx_clamp_float_vector2.osl +++ /dev/null @@ -1,19 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_clamp_float_vector2 - [[ string help = "Vector2"" Clamp incoming value to a specified range of values." ]] - ( - vector2 in = {0,0}, - float low = 0.0, - float high = 1.0, - output vector2 out = {0,0} - ) -{ - out = clamp(in, low, high); -} diff --git a/materialx/libraries/stdlib/osl/mx_clamp_float_vector4.osl b/materialx/libraries/stdlib/osl/mx_clamp_float_vector4.osl deleted file mode 100644 index da19f9b9c..000000000 --- a/materialx/libraries/stdlib/osl/mx_clamp_float_vector4.osl +++ /dev/null @@ -1,19 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_clamp_float_vector4 - [[ string help = "Vector4"" Clamp incoming value to a specified range of values." ]] - ( - vector4 in = {0,0,0,0}, - float low = 0.0, - float high = 1.0, - output vector4 out = {0,0,0,0} - ) -{ - out = clamp(in, low, high); -} diff --git a/materialx/libraries/stdlib/osl/mx_clamp_vector.osl b/materialx/libraries/stdlib/osl/mx_clamp_vector.osl deleted file mode 100644 index b6def6d80..000000000 --- a/materialx/libraries/stdlib/osl/mx_clamp_vector.osl +++ /dev/null @@ -1,19 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_clamp_vector - [[ string help = "Vector"" Clamp incoming value to a specified range of values." ]] - ( - vector in = 0, - vector low = 0, - vector high = 1, - output vector out = 0 - ) -{ - out = clamp(in, low, high); -} diff --git a/materialx/libraries/stdlib/osl/mx_clamp_vector2.osl b/materialx/libraries/stdlib/osl/mx_clamp_vector2.osl deleted file mode 100644 index 7ea046ff2..000000000 --- a/materialx/libraries/stdlib/osl/mx_clamp_vector2.osl +++ /dev/null @@ -1,19 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_clamp_vector2 - [[ string help = "Vector2"" Clamp incoming value to a specified range of values." ]] - ( - vector2 in = {0,0}, - vector2 low = {0,0}, - vector2 high = {1,1}, - output vector2 out = {0,0} - ) -{ - out = clamp(in, low, high); -} diff --git a/materialx/libraries/stdlib/osl/mx_clamp_vector4.osl b/materialx/libraries/stdlib/osl/mx_clamp_vector4.osl deleted file mode 100644 index 5377a13c2..000000000 --- a/materialx/libraries/stdlib/osl/mx_clamp_vector4.osl +++ /dev/null @@ -1,19 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_clamp_vector4 - [[ string help = "Vector4"" Clamp incoming value to a specified range of values." ]] - ( - vector4 in = {0,0,0,0}, - vector4 low = {0,0,0,0}, - vector4 high = {1,1,1,1}, - output vector4 out = {0,0,0,0} - ) -{ - out = clamp(in, low, high); -} diff --git a/materialx/libraries/stdlib/osl/mx_combine2_vector2.osl b/materialx/libraries/stdlib/osl/mx_combine2_vector2.osl deleted file mode 100644 index ca4b6680d..000000000 --- a/materialx/libraries/stdlib/osl/mx_combine2_vector2.osl +++ /dev/null @@ -1,22 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_combine_vector2 - [[ string help = "Pack the channels from two, three or four streams into the same number of channels of a \ - single stream of a specified compatible type;" ]] - ( - float in1 = 0, - float in2 = 0, - float in3 = 0, - float in4 = 0, - - output vector2 out = {0,0} - ) -{ - out = pack (in1, in2, in3, in4); -} diff --git a/materialx/libraries/stdlib/osl/mx_combine3_color.osl b/materialx/libraries/stdlib/osl/mx_combine3_color.osl deleted file mode 100644 index 4c2bf5c5a..000000000 --- a/materialx/libraries/stdlib/osl/mx_combine3_color.osl +++ /dev/null @@ -1,22 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_combine_color - [[ string help = "Pack the channels from two, three or four streams into the same number of channels of a \ - single stream of a specified compatible type;" ]] - ( - float in1 = 0, - float in2 = 0, - float in3 = 0, - float in4 = 0, - - output color out = 0 - ) -{ - out = pack (in1, in2, in3, in4); -} diff --git a/materialx/libraries/stdlib/osl/mx_combine3_vector.osl b/materialx/libraries/stdlib/osl/mx_combine3_vector.osl deleted file mode 100644 index 3c110a265..000000000 --- a/materialx/libraries/stdlib/osl/mx_combine3_vector.osl +++ /dev/null @@ -1,22 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_combine_vector - [[ string help = "Pack the channels from two, three or four streams into the same number of channels of a \ - single stream of a specified compatible type;" ]] - ( - float in1 = 0, - float in2 = 0, - float in3 = 0, - float in4 = 0, - - output vector out = 0 - ) -{ - out = pack (in1, in2, in3, in4); -} diff --git a/materialx/libraries/stdlib/osl/mx_combine4_color4.osl b/materialx/libraries/stdlib/osl/mx_combine4_color4.osl deleted file mode 100644 index 4352ddc9e..000000000 --- a/materialx/libraries/stdlib/osl/mx_combine4_color4.osl +++ /dev/null @@ -1,22 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_combine_color4 - [[ string help = "Pack the channels from two, three or four streams into the same number of channels of a \ - single stream of a specified compatible type;" ]] - ( - float in1 = 0, - float in2 = 0, - float in3 = 0, - float in4 = 0, - - output color4 out = {color(0,0,0), 0} - ) -{ - out = pack (in1, in2, in3, in4); -} diff --git a/materialx/libraries/stdlib/osl/mx_combine4_vector4.osl b/materialx/libraries/stdlib/osl/mx_combine4_vector4.osl deleted file mode 100644 index bd2719543..000000000 --- a/materialx/libraries/stdlib/osl/mx_combine4_vector4.osl +++ /dev/null @@ -1,22 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_combine_vector4 - [[ string help = "Pack the channels from two, three or four streams into the same number of channels of a \ - single stream of a specified compatible type;" ]] - ( - float in1 = 0, - float in2 = 0, - float in3 = 0, - float in4 = 0, - - output vector4 out = {0,0,0,0} - ) -{ - out = pack (in1, in2, in3, in4); -} diff --git a/materialx/libraries/stdlib/osl/mx_combine_cf_color4.osl b/materialx/libraries/stdlib/osl/mx_combine_cf_color4.osl deleted file mode 100644 index 69e2d2a7b..000000000 --- a/materialx/libraries/stdlib/osl/mx_combine_cf_color4.osl +++ /dev/null @@ -1,20 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_combine_cf_color4 - [[ string help = "Combine the channels from two, three or four streams into the same number of channels of a \ - single stream of a specified compatible type;" ]] - ( - color in1 = 0, - float in2 = 0, - output color4 out = {color(0),0} - ) -{ - out.rgb = in1; - out.a = in2; -} diff --git a/materialx/libraries/stdlib/osl/mx_combine_vf_vector4.osl b/materialx/libraries/stdlib/osl/mx_combine_vf_vector4.osl deleted file mode 100644 index b94885a80..000000000 --- a/materialx/libraries/stdlib/osl/mx_combine_vf_vector4.osl +++ /dev/null @@ -1,22 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_combine_vf_vector4 - [[ string help = "Combine the channels from two, three or four streams into the same number of channels of a \ - single stream of a specified compatible type;" ]] - ( - vector in1 = 0, - float in2 = 0, - output vector4 out = {0,0,0,0} - ) -{ - out.x = in1[0]; - out.y = in1[1]; - out.z = in1[2]; - out.w = in2; -} diff --git a/materialx/libraries/stdlib/osl/mx_combine_vv_vector4.osl b/materialx/libraries/stdlib/osl/mx_combine_vv_vector4.osl deleted file mode 100644 index 3eefb14cc..000000000 --- a/materialx/libraries/stdlib/osl/mx_combine_vv_vector4.osl +++ /dev/null @@ -1,22 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_combine_vv_vector4 - [[ string help = "Combine the channels from two, three or four streams into the same number of channels of a \ - single stream of a specified compatible type;" ]] - ( - vector2 in1 = {0,0}, - vector2 in2 = {0.0}, - output vector4 out = {0,0,0,0} - ) -{ - out.x = in1.x; - out.y = in1.y; - out.z = in2.x; - out.w = in2.y; -} diff --git a/materialx/libraries/stdlib/osl/mx_compare_color.osl b/materialx/libraries/stdlib/osl/mx_compare_color.osl deleted file mode 100644 index 152a67588..000000000 --- a/materialx/libraries/stdlib/osl/mx_compare_color.osl +++ /dev/null @@ -1,26 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_compare_color - [[ string help = "Test the value of an incoming float selector stream against a specified cutoff value, \ - then pass the value of one of two other incoming streams depending on whether the selector stream \ - value is greater than the fixed cutoff value." ]] - ( - float intest = 0.0, - color in1 = 1, - color in2 = 0, - float cutoff = 0.0, - output color out = 0 - ) -{ - if (intest > cutoff) { - out = in2; - } else { - out = in1; - } -} diff --git a/materialx/libraries/stdlib/osl/mx_compare_color4.osl b/materialx/libraries/stdlib/osl/mx_compare_color4.osl deleted file mode 100644 index 29e3579bd..000000000 --- a/materialx/libraries/stdlib/osl/mx_compare_color4.osl +++ /dev/null @@ -1,26 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_compare_color4 - [[ string help = "Test the value of an incoming float selector stream against a specified cutoff value, \ - then pass the value of one of two other incoming streams depending on whether the selector stream \ - value is greater than the fixed cutoff value." ]] - ( - float intest = 0.0, - color4 in1 = {color(1,1,1), 1}, - color4 in2 = {color(0,0,0), 0}, - float cutoff = 0.0, - output color4 out = {color(0,0,0), 0} - ) -{ - if (intest > cutoff) { - out = in2; - } else { - out = in1; - } -} diff --git a/materialx/libraries/stdlib/osl/mx_compare_float.osl b/materialx/libraries/stdlib/osl/mx_compare_float.osl deleted file mode 100644 index 127244ab8..000000000 --- a/materialx/libraries/stdlib/osl/mx_compare_float.osl +++ /dev/null @@ -1,26 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_compare_float - [[ string help = "Test the value of an incoming float selector stream against a specified cutoff value, \ - then pass the value of one of two other incoming streams depending on whether the selector stream \ - value is greater than the fixed cutoff value." ]] - ( - float intest = 0.0, - float in1 = 1, - float in2 = 0, - float cutoff = 0.0, - output float out = 0 - ) -{ - if (intest > cutoff) { - out = in2; - } else { - out = in1; - } -} diff --git a/materialx/libraries/stdlib/osl/mx_compare_vector.osl b/materialx/libraries/stdlib/osl/mx_compare_vector.osl deleted file mode 100644 index 8428b1fc8..000000000 --- a/materialx/libraries/stdlib/osl/mx_compare_vector.osl +++ /dev/null @@ -1,26 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_compare_vector - [[ string help = "Test the value of an incoming float selector stream against a specified cutoff value, \ - then pass the value of one of two other incoming streams depending on whether the selector stream \ - value is greater than the fixed cutoff value." ]] - ( - float intest = 0.0, - vector in1 = 1, - vector in2 = 0, - float cutoff = 0.0, - output vector out = 0 - ) -{ - if (intest > cutoff) { - out = in2; - } else { - out = in1; - } -} diff --git a/materialx/libraries/stdlib/osl/mx_compare_vector2.osl b/materialx/libraries/stdlib/osl/mx_compare_vector2.osl deleted file mode 100644 index 07668fe06..000000000 --- a/materialx/libraries/stdlib/osl/mx_compare_vector2.osl +++ /dev/null @@ -1,26 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_compare_vector2 - [[ string help = "Test the value of an incoming float selector stream against a specified cutoff value, \ - then pass the value of one of two other incoming streams depending on whether the selector stream \ - value is greater than the fixed cutoff value." ]] - ( - float intest = 0.0, - vector2 in1 = {1,1}, - vector2 in2 = {0,0}, - float cutoff = 0.0, - output vector2 out = {0,0} - ) -{ - if (intest > cutoff) { - out = in2; - } else { - out = in1; - } -} diff --git a/materialx/libraries/stdlib/osl/mx_compare_vector4.osl b/materialx/libraries/stdlib/osl/mx_compare_vector4.osl deleted file mode 100644 index 83295cabe..000000000 --- a/materialx/libraries/stdlib/osl/mx_compare_vector4.osl +++ /dev/null @@ -1,26 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_compare_vector4 - [[ string help = "Test the value of an incoming float selector stream against a specified cutoff value, \ - then pass the value of one of two other incoming streams depending on whether the selector stream \ - value is greater than the fixed cutoff value." ]] - ( - float intest = 0.0, - vector4 in1 = {1,1,1,1}, - vector4 in2 = {0,0,0,0}, - float cutoff = 0.0, - output vector4 out = {0,0,0,0} - ) -{ - if (intest > cutoff) { - out = in2; - } else { - out = in1; - } -} diff --git a/materialx/libraries/stdlib/osl/mx_constant_bool.osl b/materialx/libraries/stdlib/osl/mx_constant_bool.osl deleted file mode 100644 index b65bf5f12..000000000 --- a/materialx/libraries/stdlib/osl/mx_constant_bool.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_constant_bool - [[ string help = "constant source" ]] - ( - int value = 0, - output int out = 0 - ) -{ - out = value; -} diff --git a/materialx/libraries/stdlib/osl/mx_constant_color.osl b/materialx/libraries/stdlib/osl/mx_constant_color.osl deleted file mode 100644 index 5e60f77fa..000000000 --- a/materialx/libraries/stdlib/osl/mx_constant_color.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_constant_color - [[ string help = "constant source" ]] - ( - color value = 0, - output color out = 0 - ) -{ - out = value; -} diff --git a/materialx/libraries/stdlib/osl/mx_constant_color4.osl b/materialx/libraries/stdlib/osl/mx_constant_color4.osl deleted file mode 100644 index 56f234d35..000000000 --- a/materialx/libraries/stdlib/osl/mx_constant_color4.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_constant_color4 - [[ string help = "constant source" ]] - ( - color4 value = {color(0,0,0), 0}, - output color4 out = {color(0,0,0), 0} - ) -{ - out = value; -} diff --git a/materialx/libraries/stdlib/osl/mx_constant_filename.osl b/materialx/libraries/stdlib/osl/mx_constant_filename.osl deleted file mode 100644 index 3ab4d90eb..000000000 --- a/materialx/libraries/stdlib/osl/mx_constant_filename.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_constant_filename - [[ string help = "constant source" ]] - ( - string value = "default", - output string out = "default" - ) -{ - out = value; -} diff --git a/materialx/libraries/stdlib/osl/mx_constant_float.osl b/materialx/libraries/stdlib/osl/mx_constant_float.osl deleted file mode 100644 index cd45ef4df..000000000 --- a/materialx/libraries/stdlib/osl/mx_constant_float.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_constant_float - [[ string help = "constant source" ]] - ( - float value = 0, - output float out = 0 - ) -{ - out = value; -} diff --git a/materialx/libraries/stdlib/osl/mx_constant_int.osl b/materialx/libraries/stdlib/osl/mx_constant_int.osl deleted file mode 100644 index 62497a6e5..000000000 --- a/materialx/libraries/stdlib/osl/mx_constant_int.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_constant_int - [[ string help = "constant source" ]] - ( - int value = 0, - output int out = 0 - ) -{ - out = value; -} diff --git a/materialx/libraries/stdlib/osl/mx_constant_matrix33.osl b/materialx/libraries/stdlib/osl/mx_constant_matrix33.osl deleted file mode 100644 index b9e79a68c..000000000 --- a/materialx/libraries/stdlib/osl/mx_constant_matrix33.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_constant_matrix33 - [[ string help = "constant source" ]] - ( - matrix value = matrix(0), - output matrix out = matrix(0) - ) -{ - out = value; -} diff --git a/materialx/libraries/stdlib/osl/mx_constant_matrix44.osl b/materialx/libraries/stdlib/osl/mx_constant_matrix44.osl deleted file mode 100644 index 4528a9b8b..000000000 --- a/materialx/libraries/stdlib/osl/mx_constant_matrix44.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_constant_matrix44 - [[ string help = "constant source" ]] - ( - matrix value = matrix(0), - output matrix out = matrix(0) - ) -{ - out = value; -} diff --git a/materialx/libraries/stdlib/osl/mx_constant_string.osl b/materialx/libraries/stdlib/osl/mx_constant_string.osl deleted file mode 100644 index ea7410e80..000000000 --- a/materialx/libraries/stdlib/osl/mx_constant_string.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_constant_string - [[ string help = "constant source" ]] - ( - string value = "default", - output string out = "default" - ) -{ - out = value; -} diff --git a/materialx/libraries/stdlib/osl/mx_constant_vector.osl b/materialx/libraries/stdlib/osl/mx_constant_vector.osl deleted file mode 100644 index 83394399d..000000000 --- a/materialx/libraries/stdlib/osl/mx_constant_vector.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_constant_vector - [[ string help = "constant source" ]] - ( - vector value = 0, - output vector out = 0 - ) -{ - out = value; -} diff --git a/materialx/libraries/stdlib/osl/mx_constant_vector2.osl b/materialx/libraries/stdlib/osl/mx_constant_vector2.osl deleted file mode 100644 index f232e5707..000000000 --- a/materialx/libraries/stdlib/osl/mx_constant_vector2.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_constant_vector2 - [[ string help = "constant source" ]] - ( - vector2 value = {0,0}, - output vector2 out = {0,0} - ) -{ - out = value; -} diff --git a/materialx/libraries/stdlib/osl/mx_constant_vector4.osl b/materialx/libraries/stdlib/osl/mx_constant_vector4.osl deleted file mode 100644 index 6b449bc67..000000000 --- a/materialx/libraries/stdlib/osl/mx_constant_vector4.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_constant_vector4 - [[ string help = "constant source" ]] - ( - vector4 value = {0,0,0,0}, - output vector4 out = {0,0,0,0} - ) -{ - out = value; -} diff --git a/materialx/libraries/stdlib/osl/mx_cos_color.osl b/materialx/libraries/stdlib/osl/mx_cos_color.osl deleted file mode 100644 index 0cbbe867f..000000000 --- a/materialx/libraries/stdlib/osl/mx_cos_color.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_cos_color - [[ string help = "Color"" cos(in)" ]] - ( - color in = 0, - output color out = 0 - ) -{ - out = cos(in); -} diff --git a/materialx/libraries/stdlib/osl/mx_cos_color4.osl b/materialx/libraries/stdlib/osl/mx_cos_color4.osl deleted file mode 100644 index ca7bd0eb3..000000000 --- a/materialx/libraries/stdlib/osl/mx_cos_color4.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_cos_color4 - [[ string help = "Color4"" cos(in)" ]] - ( - color4 in = {color(0,0,0), 0}, - output color4 out = {color(0,0,0), 0} - ) -{ - out = cos(in); -} diff --git a/materialx/libraries/stdlib/osl/mx_cos_float.osl b/materialx/libraries/stdlib/osl/mx_cos_float.osl deleted file mode 100644 index beef8e91b..000000000 --- a/materialx/libraries/stdlib/osl/mx_cos_float.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_cos_float - [[ string help = "Float"" cos(in)" ]] - ( - float in = 0, - output float out = 0 - ) -{ - out = cos(in); -} diff --git a/materialx/libraries/stdlib/osl/mx_cos_vector.osl b/materialx/libraries/stdlib/osl/mx_cos_vector.osl deleted file mode 100644 index 0d07f991a..000000000 --- a/materialx/libraries/stdlib/osl/mx_cos_vector.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_cos_vector - [[ string help = "Vector"" cos(in)" ]] - ( - vector in = 0, - output vector out = 0 - ) -{ - out = cos(in); -} diff --git a/materialx/libraries/stdlib/osl/mx_cos_vector2.osl b/materialx/libraries/stdlib/osl/mx_cos_vector2.osl deleted file mode 100644 index a7cd82b14..000000000 --- a/materialx/libraries/stdlib/osl/mx_cos_vector2.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_cos_vector2 - [[ string help = "Vector2"" cos(in)" ]] - ( - vector2 in = {0,0}, - output vector2 out = {0,0} - ) -{ - out = cos(in); -} diff --git a/materialx/libraries/stdlib/osl/mx_cos_vector4.osl b/materialx/libraries/stdlib/osl/mx_cos_vector4.osl deleted file mode 100644 index 6f844d3ca..000000000 --- a/materialx/libraries/stdlib/osl/mx_cos_vector4.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_cos_vector4 - [[ string help = "Vector4"" cos(in)" ]] - ( - vector4 in = {0,0,0,0}, - output vector4 out = {0,0,0,0} - ) -{ - out = cos(in); -} diff --git a/materialx/libraries/stdlib/osl/mx_crossproduct_vector.osl b/materialx/libraries/stdlib/osl/mx_crossproduct_vector.osl deleted file mode 100644 index 5bf4c85d7..000000000 --- a/materialx/libraries/stdlib/osl/mx_crossproduct_vector.osl +++ /dev/null @@ -1,18 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_crossproduct_vector - [[ string help = "Perform a cross product of two vectors" ]] - ( - vector in1 = 0, - vector in2 = 0, - output vector out = 0 - ) -{ - out = cross(in1, in2); -} diff --git a/materialx/libraries/stdlib/osl/mx_determinant_matrix33.osl b/materialx/libraries/stdlib/osl/mx_determinant_matrix33.osl deleted file mode 100644 index 3342253bf..000000000 --- a/materialx/libraries/stdlib/osl/mx_determinant_matrix33.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_determinant_matrix33 - [[ string help = "Matrix33"" the determinant of matrix in" ]] - ( - matrix in = matrix(0), - output float out = 0 - ) -{ - out = determinant(in); -} diff --git a/materialx/libraries/stdlib/osl/mx_determinant_matrix44.osl b/materialx/libraries/stdlib/osl/mx_determinant_matrix44.osl deleted file mode 100644 index a192f83bd..000000000 --- a/materialx/libraries/stdlib/osl/mx_determinant_matrix44.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_determinant_matrix44 - [[ string help = "Matrix44"" the determinant of matrix in" ]] - ( - matrix in = matrix(0), - output float out = 0 - ) -{ - out = determinant(in); -} diff --git a/materialx/libraries/stdlib/osl/mx_disjointover_color4.osl b/materialx/libraries/stdlib/osl/mx_disjointover_color4.osl deleted file mode 100644 index 4f03361a5..000000000 --- a/materialx/libraries/stdlib/osl/mx_disjointover_color4.osl +++ /dev/null @@ -1,38 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - - -color4 disjointover(color4 fg, color4 bg) -{ - float summedAlpha = fg.a + bg.a; - - color4 out; - if (summedAlpha <= 1) { - out.rgb = fg.rgb + bg.rgb; - } else { - float x = (1 - fg.a) / bg.a; - out.rgb = fg.rgb + bg.rgb * x; - } - - out.a = min(summedAlpha, 1); - return out; -} - - - -shader mx_disjointover_color4 - [[ string help = "Color4"" Take two color4 inputs and use the built-in alpha \ - channel(s) to control the compositing of the fg and bg inputs" ]] - ( - color4 fg = {color(0,0,0), 0}, - color4 bg = {color(0,0,0), 0}, - output color4 out = {color(0,0,0), 0} - ) -{ - out = disjointover(fg, bg); -} diff --git a/materialx/libraries/stdlib/osl/mx_divide_color.osl b/materialx/libraries/stdlib/osl/mx_divide_color.osl deleted file mode 100644 index 77b201e78..000000000 --- a/materialx/libraries/stdlib/osl/mx_divide_color.osl +++ /dev/null @@ -1,18 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_divide_color - [[ string help = "Color"" divide an incoming float/color/vector by in2" ]] - ( - color in1 = 0, - color in2 = 1, - output color out = 0 - ) -{ - out = in1 / in2; -} diff --git a/materialx/libraries/stdlib/osl/mx_divide_color4.osl b/materialx/libraries/stdlib/osl/mx_divide_color4.osl deleted file mode 100644 index ee4bf3ac3..000000000 --- a/materialx/libraries/stdlib/osl/mx_divide_color4.osl +++ /dev/null @@ -1,18 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_divide_color4 - [[ string help = "Color4"" divide an incoming float/color/vector by in2" ]] - ( - color4 in1 = {color(0,0,0), 0}, - color4 in2 = {color(1,1,1), 1}, - output color4 out = {color(0,0,0), 0} - ) -{ - out = in1 / in2; -} diff --git a/materialx/libraries/stdlib/osl/mx_divide_float.osl b/materialx/libraries/stdlib/osl/mx_divide_float.osl deleted file mode 100644 index fc8e5bd9e..000000000 --- a/materialx/libraries/stdlib/osl/mx_divide_float.osl +++ /dev/null @@ -1,18 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_divide_float - [[ string help = "Float"" divide an incoming float/color/vector by in2" ]] - ( - float in1 = 0, - float in2 = 1, - output float out = 0 - ) -{ - out = in1 / in2; -} diff --git a/materialx/libraries/stdlib/osl/mx_divide_float_color.osl b/materialx/libraries/stdlib/osl/mx_divide_float_color.osl deleted file mode 100644 index 902f41d8b..000000000 --- a/materialx/libraries/stdlib/osl/mx_divide_float_color.osl +++ /dev/null @@ -1,18 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_divide_float_color - [[ string help = "Color"" Divide an incoming float/color/vector by the in2" ]] - ( - color in1 = 0, - float in2 = 1.0, - output color out = 0 - ) -{ - out = in1 / in2; -} diff --git a/materialx/libraries/stdlib/osl/mx_divide_float_color4.osl b/materialx/libraries/stdlib/osl/mx_divide_float_color4.osl deleted file mode 100644 index 710a20d71..000000000 --- a/materialx/libraries/stdlib/osl/mx_divide_float_color4.osl +++ /dev/null @@ -1,18 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_divide_float_color4 - [[ string help = "Color4"" Divide an incoming float/color/vector by the in2" ]] - ( - color4 in1 = {color(0,0,0), 0}, - float in2 = 1.0, - output color4 out = {color(0,0,0), 0} - ) -{ - out = in1 / in2; -} diff --git a/materialx/libraries/stdlib/osl/mx_divide_float_matrix33.osl b/materialx/libraries/stdlib/osl/mx_divide_float_matrix33.osl deleted file mode 100644 index 6742de36b..000000000 --- a/materialx/libraries/stdlib/osl/mx_divide_float_matrix33.osl +++ /dev/null @@ -1,18 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_divide_float_matrix33 - [[ string help = "Matrix33"" Divide an incoming float/color/vector by the in2" ]] - ( - matrix in1 = matrix(0), - float in2 = 1.0, - output matrix out = matrix(0) - ) -{ - out = in1 / in2; -} diff --git a/materialx/libraries/stdlib/osl/mx_divide_float_matrix44.osl b/materialx/libraries/stdlib/osl/mx_divide_float_matrix44.osl deleted file mode 100644 index 14be008fd..000000000 --- a/materialx/libraries/stdlib/osl/mx_divide_float_matrix44.osl +++ /dev/null @@ -1,18 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_divide_float_matrix44 - [[ string help = "Matrix44"" Divide an incoming float/color/vector by the in2" ]] - ( - matrix in1 = matrix(0), - float in2 = 1.0, - output matrix out = matrix(0) - ) -{ - out = in1 / in2; -} diff --git a/materialx/libraries/stdlib/osl/mx_divide_float_vector.osl b/materialx/libraries/stdlib/osl/mx_divide_float_vector.osl deleted file mode 100644 index dc3101919..000000000 --- a/materialx/libraries/stdlib/osl/mx_divide_float_vector.osl +++ /dev/null @@ -1,18 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_divide_float_vector - [[ string help = "Vector"" Divide an incoming float/color/vector by the in2" ]] - ( - vector in1 = 0, - float in2 = 1.0, - output vector out = 0 - ) -{ - out = in1 / in2; -} diff --git a/materialx/libraries/stdlib/osl/mx_divide_float_vector2.osl b/materialx/libraries/stdlib/osl/mx_divide_float_vector2.osl deleted file mode 100644 index b5599ea07..000000000 --- a/materialx/libraries/stdlib/osl/mx_divide_float_vector2.osl +++ /dev/null @@ -1,18 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_divide_float_vector2 - [[ string help = "Vector2"" Divide an incoming float/color/vector by the in2" ]] - ( - vector2 in1 = {0,0}, - float in2 = 1.0, - output vector2 out = {0,0} - ) -{ - out = in1 / in2; -} diff --git a/materialx/libraries/stdlib/osl/mx_divide_float_vector4.osl b/materialx/libraries/stdlib/osl/mx_divide_float_vector4.osl deleted file mode 100644 index 354541ac5..000000000 --- a/materialx/libraries/stdlib/osl/mx_divide_float_vector4.osl +++ /dev/null @@ -1,18 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_divide_float_vector4 - [[ string help = "Vector4"" Divide an incoming float/color/vector by the in2" ]] - ( - vector4 in1 = {0,0,0,0}, - float in2 = 1.0, - output vector4 out = {0,0,0,0} - ) -{ - out = in1 / in2; -} diff --git a/materialx/libraries/stdlib/osl/mx_divide_matrix33.osl b/materialx/libraries/stdlib/osl/mx_divide_matrix33.osl deleted file mode 100644 index 0828c543b..000000000 --- a/materialx/libraries/stdlib/osl/mx_divide_matrix33.osl +++ /dev/null @@ -1,18 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_divide_matrix33 - [[ string help = "Matrix33"" divide an incoming float/color/vector by in2" ]] - ( - matrix in1 = matrix(0), - matrix in2 = matrix(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,0), - output matrix out = matrix(0) - ) -{ - out = in1 / in2; -} diff --git a/materialx/libraries/stdlib/osl/mx_divide_matrix44.osl b/materialx/libraries/stdlib/osl/mx_divide_matrix44.osl deleted file mode 100644 index 97a883a0d..000000000 --- a/materialx/libraries/stdlib/osl/mx_divide_matrix44.osl +++ /dev/null @@ -1,18 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_divide_matrix44 - [[ string help = "Matrix44"" divide an incoming float/color/vector by in2" ]] - ( - matrix in1 = matrix(0), - matrix in2 = matrix(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1), - output matrix out = matrix(0) - ) -{ - out = in1 / in2; -} diff --git a/materialx/libraries/stdlib/osl/mx_divide_vector.osl b/materialx/libraries/stdlib/osl/mx_divide_vector.osl deleted file mode 100644 index d3d3d14d4..000000000 --- a/materialx/libraries/stdlib/osl/mx_divide_vector.osl +++ /dev/null @@ -1,18 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_divide_vector - [[ string help = "Vector"" divide an incoming float/color/vector by in2" ]] - ( - vector in1 = 0, - vector in2 = 1, - output vector out = 0 - ) -{ - out = in1 / in2; -} diff --git a/materialx/libraries/stdlib/osl/mx_divide_vector2.osl b/materialx/libraries/stdlib/osl/mx_divide_vector2.osl deleted file mode 100644 index 400c15908..000000000 --- a/materialx/libraries/stdlib/osl/mx_divide_vector2.osl +++ /dev/null @@ -1,18 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_divide_vector2 - [[ string help = "Vector2"" divide an incoming float/color/vector by in2" ]] - ( - vector2 in1 = {0,0}, - vector2 in2 = {1,1}, - output vector2 out = {0,0} - ) -{ - out = in1 / in2; -} diff --git a/materialx/libraries/stdlib/osl/mx_divide_vector4.osl b/materialx/libraries/stdlib/osl/mx_divide_vector4.osl deleted file mode 100644 index f096df371..000000000 --- a/materialx/libraries/stdlib/osl/mx_divide_vector4.osl +++ /dev/null @@ -1,18 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_divide_vector4 - [[ string help = "Vector4"" divide an incoming float/color/vector by in2" ]] - ( - vector4 in1 = {0,0,0,0}, - vector4 in2 = {1,1,1,1}, - output vector4 out = {0,0,0,0} - ) -{ - out = in1 / in2; -} diff --git a/materialx/libraries/stdlib/osl/mx_dodge_color.osl b/materialx/libraries/stdlib/osl/mx_dodge_color.osl deleted file mode 100644 index ca483e003..000000000 --- a/materialx/libraries/stdlib/osl/mx_dodge_color.osl +++ /dev/null @@ -1,18 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_dodge_color - [[ string help = "Color"" Take two 1-4 channel inputs and apply the same operator to all channels: B/(1-F)" ]] - ( - color fg = 0, - color bg = 0, - output color out = 0 - ) -{ - out = bg / (1 - fg); -} diff --git a/materialx/libraries/stdlib/osl/mx_dodge_color4.osl b/materialx/libraries/stdlib/osl/mx_dodge_color4.osl deleted file mode 100644 index 45c555c67..000000000 --- a/materialx/libraries/stdlib/osl/mx_dodge_color4.osl +++ /dev/null @@ -1,18 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_dodge_color4 - [[ string help = "Color4"" Take two 1-4 channel inputs and apply the same operator to all channels: B/(1-F)" ]] - ( - color4 fg = {color(0,0,0), 0}, - color4 bg = {color(0,0,0), 0}, - output color4 out = {color(0,0,0), 0} - ) -{ - out = bg / (1 - fg); -} diff --git a/materialx/libraries/stdlib/osl/mx_dodge_float.osl b/materialx/libraries/stdlib/osl/mx_dodge_float.osl deleted file mode 100644 index dcbc03e6e..000000000 --- a/materialx/libraries/stdlib/osl/mx_dodge_float.osl +++ /dev/null @@ -1,18 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_dodge_float - [[ string help = "Float"" Take two 1-4 channel inputs and apply the same operator to all channels: B/(1-F)" ]] - ( - float fg = 0, - float bg = 0, - output float out = 0 - ) -{ - out = bg / (1 - fg); -} diff --git a/materialx/libraries/stdlib/osl/mx_dot_bool.osl b/materialx/libraries/stdlib/osl/mx_dot_bool.osl deleted file mode 100644 index e1cc0395b..000000000 --- a/materialx/libraries/stdlib/osl/mx_dot_bool.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_dot_bool - [[ string help = "bool"" no-op " ]] - ( - int in = 0, - output int out = 0 - ) -{ - out = in; -} diff --git a/materialx/libraries/stdlib/osl/mx_dot_color.osl b/materialx/libraries/stdlib/osl/mx_dot_color.osl deleted file mode 100644 index fda9105c1..000000000 --- a/materialx/libraries/stdlib/osl/mx_dot_color.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_dot_color - [[ string help = "Color"" no-op " ]] - ( - color in = 0, - output color out = 0 - ) -{ - out = in; -} diff --git a/materialx/libraries/stdlib/osl/mx_dot_color4.osl b/materialx/libraries/stdlib/osl/mx_dot_color4.osl deleted file mode 100644 index c73adc2bf..000000000 --- a/materialx/libraries/stdlib/osl/mx_dot_color4.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_dot_color4 - [[ string help = "Color4"" no-op " ]] - ( - color4 in = {color(0,0,0), 0}, - output color4 out = {color(0,0,0), 0} - ) -{ - out = in; -} diff --git a/materialx/libraries/stdlib/osl/mx_dot_displacementshader.osl b/materialx/libraries/stdlib/osl/mx_dot_displacementshader.osl deleted file mode 100644 index af21e6ccb..000000000 --- a/materialx/libraries/stdlib/osl/mx_dot_displacementshader.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_dot_displacementshader - [[ string help = "displacementshader"" no-op " ]] - ( - displacement color in = 0, - output displacement color out = 0 - ) -{ - out = in; -} diff --git a/materialx/libraries/stdlib/osl/mx_dot_filename.osl b/materialx/libraries/stdlib/osl/mx_dot_filename.osl deleted file mode 100644 index 74612e87a..000000000 --- a/materialx/libraries/stdlib/osl/mx_dot_filename.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_dot_filename - [[ string help = "filename"" no-op " ]] - ( - string in = "default", - output string out = "default" - ) -{ - out = in; -} diff --git a/materialx/libraries/stdlib/osl/mx_dot_float.osl b/materialx/libraries/stdlib/osl/mx_dot_float.osl deleted file mode 100644 index d34d24769..000000000 --- a/materialx/libraries/stdlib/osl/mx_dot_float.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_dot_float - [[ string help = "Float"" no-op " ]] - ( - float in = 0, - output float out = 0 - ) -{ - out = in; -} diff --git a/materialx/libraries/stdlib/osl/mx_dot_int.osl b/materialx/libraries/stdlib/osl/mx_dot_int.osl deleted file mode 100644 index daac147de..000000000 --- a/materialx/libraries/stdlib/osl/mx_dot_int.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_dot_int - [[ string help = "int"" no-op " ]] - ( - int in = 0, - output int out = 0 - ) -{ - out = in; -} diff --git a/materialx/libraries/stdlib/osl/mx_dot_lightshader.osl b/materialx/libraries/stdlib/osl/mx_dot_lightshader.osl deleted file mode 100644 index 975d742ab..000000000 --- a/materialx/libraries/stdlib/osl/mx_dot_lightshader.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_dot_lightshader - [[ string help = "lightshader"" no-op " ]] - ( - color in = 0, - output color out = 0 - ) -{ - out = in; -} diff --git a/materialx/libraries/stdlib/osl/mx_dot_matrix33.osl b/materialx/libraries/stdlib/osl/mx_dot_matrix33.osl deleted file mode 100644 index 015430dac..000000000 --- a/materialx/libraries/stdlib/osl/mx_dot_matrix33.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_dot_matrix33 - [[ string help = "Matrix33"" no-op " ]] - ( - matrix in = matrix(0), - output matrix out = matrix(0) - ) -{ - out = in; -} diff --git a/materialx/libraries/stdlib/osl/mx_dot_matrix44.osl b/materialx/libraries/stdlib/osl/mx_dot_matrix44.osl deleted file mode 100644 index fbba7b3e8..000000000 --- a/materialx/libraries/stdlib/osl/mx_dot_matrix44.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_dot_matrix44 - [[ string help = "Matrix44"" no-op " ]] - ( - matrix in = matrix(0), - output matrix out = matrix(0) - ) -{ - out = in; -} diff --git a/materialx/libraries/stdlib/osl/mx_dot_string.osl b/materialx/libraries/stdlib/osl/mx_dot_string.osl deleted file mode 100644 index 1ec01b4d0..000000000 --- a/materialx/libraries/stdlib/osl/mx_dot_string.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_dot_string - [[ string help = "string"" no-op " ]] - ( - string in = "default", - output string out = "default" - ) -{ - out = in; -} diff --git a/materialx/libraries/stdlib/osl/mx_dot_surfaceshader.osl b/materialx/libraries/stdlib/osl/mx_dot_surfaceshader.osl deleted file mode 100644 index 98e520449..000000000 --- a/materialx/libraries/stdlib/osl/mx_dot_surfaceshader.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_dot_surfaceshader - [[ string help = "surfaceshader"" no-op " ]] - ( - closure color in = 0, - output closure color out = 0 - ) -{ - out = in; -} diff --git a/materialx/libraries/stdlib/osl/mx_dot_vector.osl b/materialx/libraries/stdlib/osl/mx_dot_vector.osl deleted file mode 100644 index 29b2ff486..000000000 --- a/materialx/libraries/stdlib/osl/mx_dot_vector.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_dot_vector - [[ string help = "Vector"" no-op " ]] - ( - vector in = 0, - output vector out = 0 - ) -{ - out = in; -} diff --git a/materialx/libraries/stdlib/osl/mx_dot_vector2.osl b/materialx/libraries/stdlib/osl/mx_dot_vector2.osl deleted file mode 100644 index 1699b353c..000000000 --- a/materialx/libraries/stdlib/osl/mx_dot_vector2.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_dot_vector2 - [[ string help = "Vector2"" no-op " ]] - ( - vector2 in = {0,0}, - output vector2 out = {0,0} - ) -{ - out = in; -} diff --git a/materialx/libraries/stdlib/osl/mx_dot_vector4.osl b/materialx/libraries/stdlib/osl/mx_dot_vector4.osl deleted file mode 100644 index 96f6ed891..000000000 --- a/materialx/libraries/stdlib/osl/mx_dot_vector4.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_dot_vector4 - [[ string help = "Vector4"" no-op " ]] - ( - vector4 in = {0,0,0,0}, - output vector4 out = {0,0,0,0} - ) -{ - out = in; -} diff --git a/materialx/libraries/stdlib/osl/mx_dot_volumeshader.osl b/materialx/libraries/stdlib/osl/mx_dot_volumeshader.osl deleted file mode 100644 index 6e89c7b9a..000000000 --- a/materialx/libraries/stdlib/osl/mx_dot_volumeshader.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_dot_volumeshader - [[ string help = "volumeshader"" no-op " ]] - ( - closure color in = 0, - output closure color out = 0 - ) -{ - out = in; -} diff --git a/materialx/libraries/stdlib/osl/mx_dotproduct_vector.osl b/materialx/libraries/stdlib/osl/mx_dotproduct_vector.osl deleted file mode 100644 index d9dd0f344..000000000 --- a/materialx/libraries/stdlib/osl/mx_dotproduct_vector.osl +++ /dev/null @@ -1,18 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_dotproduct_vector - [[ string help = "Vector"" Perform a dot product of two 2-4 channel vectors" ]] - ( - vector in1 = 0, - vector in2 = 0, - output float out = 0 - ) -{ - out = dot(in1, in2); -} diff --git a/materialx/libraries/stdlib/osl/mx_dotproduct_vector2.osl b/materialx/libraries/stdlib/osl/mx_dotproduct_vector2.osl deleted file mode 100644 index 3321346ac..000000000 --- a/materialx/libraries/stdlib/osl/mx_dotproduct_vector2.osl +++ /dev/null @@ -1,18 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_dotproduct_vector2 - [[ string help = "Vector2"" Perform a dot product of two 2-4 channel vectors" ]] - ( - vector2 in1 = {0,0}, - vector2 in2 = {0,0}, - output float out = 0 - ) -{ - out = dot(in1, in2); -} diff --git a/materialx/libraries/stdlib/osl/mx_dotproduct_vector4.osl b/materialx/libraries/stdlib/osl/mx_dotproduct_vector4.osl deleted file mode 100644 index 233965688..000000000 --- a/materialx/libraries/stdlib/osl/mx_dotproduct_vector4.osl +++ /dev/null @@ -1,18 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_dotproduct_vector4 - [[ string help = "Vector4"" Perform a dot product of two 2-4 channel vectors" ]] - ( - vector4 in1 = {0,0,0,0}, - vector4 in2 = {0,0,0,0}, - output float out = 0 - ) -{ - out = dot(in1, in2); -} diff --git a/materialx/libraries/stdlib/osl/mx_exp_color.osl b/materialx/libraries/stdlib/osl/mx_exp_color.osl deleted file mode 100644 index e6d080adb..000000000 --- a/materialx/libraries/stdlib/osl/mx_exp_color.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader exp_color - [[ string help = "Color"" e(in)" ]] - ( - color in = 0, - output color out = 0 - ) -{ - out = exp(in); -} diff --git a/materialx/libraries/stdlib/osl/mx_exp_color4.osl b/materialx/libraries/stdlib/osl/mx_exp_color4.osl deleted file mode 100644 index 8c7d9c3b4..000000000 --- a/materialx/libraries/stdlib/osl/mx_exp_color4.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader exp_color4 - [[ string help = "Color4"" e(in)" ]] - ( - color4 in = {color(0,0,0), 0}, - output color4 out = {color(0,0,0), 0} - ) -{ - out = exp(in); -} diff --git a/materialx/libraries/stdlib/osl/mx_exp_float.osl b/materialx/libraries/stdlib/osl/mx_exp_float.osl deleted file mode 100644 index 67134e848..000000000 --- a/materialx/libraries/stdlib/osl/mx_exp_float.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader exp_float - [[ string help = "Float"" e(in)" ]] - ( - float in = 0, - output float out = 0 - ) -{ - out = exp(in); -} diff --git a/materialx/libraries/stdlib/osl/mx_exp_vector.osl b/materialx/libraries/stdlib/osl/mx_exp_vector.osl deleted file mode 100644 index a4cee41b8..000000000 --- a/materialx/libraries/stdlib/osl/mx_exp_vector.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader exp_vector - [[ string help = "Vector"" e(in)" ]] - ( - vector in = 0, - output vector out = 0 - ) -{ - out = exp(in); -} diff --git a/materialx/libraries/stdlib/osl/mx_exp_vector2.osl b/materialx/libraries/stdlib/osl/mx_exp_vector2.osl deleted file mode 100644 index 12445e01f..000000000 --- a/materialx/libraries/stdlib/osl/mx_exp_vector2.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader exp_vector2 - [[ string help = "Vector2"" e(in)" ]] - ( - vector2 in = {0,0}, - output vector2 out = {0,0} - ) -{ - out = exp(in); -} diff --git a/materialx/libraries/stdlib/osl/mx_exp_vector4.osl b/materialx/libraries/stdlib/osl/mx_exp_vector4.osl deleted file mode 100644 index 64f6e8f51..000000000 --- a/materialx/libraries/stdlib/osl/mx_exp_vector4.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader exp_vector4 - [[ string help = "Vector4"" e(in)" ]] - ( - vector4 in = {0,0,0,0}, - output vector4 out = {0,0,0,0} - ) -{ - out = exp(in); -} diff --git a/materialx/libraries/stdlib/osl/mx_exponent_float.osl b/materialx/libraries/stdlib/osl/mx_exponent_float.osl deleted file mode 100644 index 2be5a5695..000000000 --- a/materialx/libraries/stdlib/osl/mx_exponent_float.osl +++ /dev/null @@ -1,18 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_exponent_float - [[ string help = "Float"" Raise incoming float/color/vector values to the in2 exponent value/stream" ]] - ( - float in1 = 0, - float in2 = 1, - output float out = 0 - ) -{ - out = pow(in1, in2); -} diff --git a/materialx/libraries/stdlib/osl/mx_exponent_vector.osl b/materialx/libraries/stdlib/osl/mx_exponent_vector.osl deleted file mode 100644 index 0dab52b5f..000000000 --- a/materialx/libraries/stdlib/osl/mx_exponent_vector.osl +++ /dev/null @@ -1,18 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_exponent_vector - [[ string help = "Vector"" Raise incoming float/color/vector values to the in2 exponent value/stream" ]] - ( - vector in1 = 0, - vector in2 = 1, - output vector out = 0 - ) -{ - out = pow(in1, in2); -} diff --git a/materialx/libraries/stdlib/osl/mx_exponent_vector2.osl b/materialx/libraries/stdlib/osl/mx_exponent_vector2.osl deleted file mode 100644 index 989dc4816..000000000 --- a/materialx/libraries/stdlib/osl/mx_exponent_vector2.osl +++ /dev/null @@ -1,18 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_exponent_vector2 - [[ string help = "Vector2"" Raise incoming float/color/vector values to the in2 exponent value/stream" ]] - ( - vector2 in1 = {0,0}, - vector2 in2 = {1,1}, - output vector2 out = {0,0} - ) -{ - out = pow(in1, in2); -} diff --git a/materialx/libraries/stdlib/osl/mx_exponent_vector4.osl b/materialx/libraries/stdlib/osl/mx_exponent_vector4.osl deleted file mode 100644 index b0eff2390..000000000 --- a/materialx/libraries/stdlib/osl/mx_exponent_vector4.osl +++ /dev/null @@ -1,18 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_exponent_vector4 - [[ string help = "Vector4"" Raise incoming float/color/vector values to the in2 exponent value/stream" ]] - ( - vector4 in1 = {0,0,0,0}, - vector4 in2 = {1,1,1,1}, - output vector4 out = {0,0,0,0} - ) -{ - out = pow(in1, in2); -} diff --git a/materialx/libraries/stdlib/osl/mx_extract_color.osl b/materialx/libraries/stdlib/osl/mx_extract_color.osl deleted file mode 100644 index 7bec93da8..000000000 --- a/materialx/libraries/stdlib/osl/mx_extract_color.osl +++ /dev/null @@ -1,19 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - - -shader mx_extract_color - [[ string help = "Generate a float from an aggregate (vector, color, etc.)" ]] - ( - color in = 0, - int index = 0, - output float out = 0 - ) -{ - out = extract (in, index); -} diff --git a/materialx/libraries/stdlib/osl/mx_extract_color4.osl b/materialx/libraries/stdlib/osl/mx_extract_color4.osl deleted file mode 100644 index 73b4aae44..000000000 --- a/materialx/libraries/stdlib/osl/mx_extract_color4.osl +++ /dev/null @@ -1,19 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - - -shader mx_extract_color4 - [[ string help = "Generate a float from an aggregate (vector, color, etc.)" ]] - ( - color4 in = {color(0,0,0), 0}, - int index = 0, - output float out = 0 - ) -{ - out = extract (in, index); -} diff --git a/materialx/libraries/stdlib/osl/mx_extract_vector.osl b/materialx/libraries/stdlib/osl/mx_extract_vector.osl deleted file mode 100644 index 635f8e825..000000000 --- a/materialx/libraries/stdlib/osl/mx_extract_vector.osl +++ /dev/null @@ -1,19 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - - -shader mx_extract_vector - [[ string help = "Generate a float from an aggregate (vector, color, etc.)" ]] - ( - vector in = 0, - int index = 0, - output float out = 0 - ) -{ - out = extract (in, index); -} diff --git a/materialx/libraries/stdlib/osl/mx_extract_vector2.osl b/materialx/libraries/stdlib/osl/mx_extract_vector2.osl deleted file mode 100644 index d70ad4c7f..000000000 --- a/materialx/libraries/stdlib/osl/mx_extract_vector2.osl +++ /dev/null @@ -1,19 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - - -shader mx_extract_vector2 - [[ string help = "Generate a float from an aggregate (vector, color, etc.)" ]] - ( - vector2 in = {0,0}, - int index = 0, - output float out = 0 - ) -{ - out = extract (in, index); -} diff --git a/materialx/libraries/stdlib/osl/mx_extract_vector4.osl b/materialx/libraries/stdlib/osl/mx_extract_vector4.osl deleted file mode 100644 index d345cc609..000000000 --- a/materialx/libraries/stdlib/osl/mx_extract_vector4.osl +++ /dev/null @@ -1,19 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - - -shader mx_extract_vector4 - [[ string help = "Generate a float from an aggregate (vector, color, etc.)" ]] - ( - vector4 in = {0,0,0,0}, - int index = 0, - output float out = 0 - ) -{ - out = extract (in, index); -} diff --git a/materialx/libraries/stdlib/osl/mx_floor_color.osl b/materialx/libraries/stdlib/osl/mx_floor_color.osl deleted file mode 100644 index 2c7cf397f..000000000 --- a/materialx/libraries/stdlib/osl/mx_floor_color.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_floor_color - [[ string help = "Color"" Find the nearest integer less than or equal to the parameter." ]] - ( - color in = 0, - output color out = 0 - ) -{ - out = floor(in); -} diff --git a/materialx/libraries/stdlib/osl/mx_floor_color4.osl b/materialx/libraries/stdlib/osl/mx_floor_color4.osl deleted file mode 100644 index b2b5b9d5d..000000000 --- a/materialx/libraries/stdlib/osl/mx_floor_color4.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_floor_color4 - [[ string help = "Color4"" Find the nearest integer less than or equal to the parameter." ]] - ( - color4 in = {color(0,0,0), 0}, - output color4 out = {color(0,0,0), 0} - ) -{ - out = floor(in); -} diff --git a/materialx/libraries/stdlib/osl/mx_floor_float.osl b/materialx/libraries/stdlib/osl/mx_floor_float.osl deleted file mode 100644 index ebcb77667..000000000 --- a/materialx/libraries/stdlib/osl/mx_floor_float.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_floor_float - [[ string help = "Float"" Find the nearest integer less than or equal to the parameter." ]] - ( - float in = 0, - output float out = 0 - ) -{ - out = floor(in); -} diff --git a/materialx/libraries/stdlib/osl/mx_floor_vector.osl b/materialx/libraries/stdlib/osl/mx_floor_vector.osl deleted file mode 100644 index b6b9c33bd..000000000 --- a/materialx/libraries/stdlib/osl/mx_floor_vector.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_floor_vector - [[ string help = "Vector"" Find the nearest integer less than or equal to the parameter." ]] - ( - vector in = 0, - output vector out = 0 - ) -{ - out = floor(in); -} diff --git a/materialx/libraries/stdlib/osl/mx_floor_vector2.osl b/materialx/libraries/stdlib/osl/mx_floor_vector2.osl deleted file mode 100644 index 5754dfbf7..000000000 --- a/materialx/libraries/stdlib/osl/mx_floor_vector2.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_floor_vector2 - [[ string help = "Vector2"" Find the nearest integer less than or equal to the parameter." ]] - ( - vector2 in = {0,0}, - output vector2 out = {0,0} - ) -{ - out = floor(in); -} diff --git a/materialx/libraries/stdlib/osl/mx_floor_vector4.osl b/materialx/libraries/stdlib/osl/mx_floor_vector4.osl deleted file mode 100644 index 06e4b188a..000000000 --- a/materialx/libraries/stdlib/osl/mx_floor_vector4.osl +++ /dev/null @@ -1,17 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_floor_vector4 - [[ string help = "Vector4"" Find the nearest integer less than or equal to the parameter." ]] - ( - vector4 in = {0,0,0,0}, - output vector4 out = {0,0,0,0} - ) -{ - out = floor(in); -} diff --git a/materialx/libraries/stdlib/osl/mx_fractal3d_color.osl b/materialx/libraries/stdlib/osl/mx_fractal3d_color.osl deleted file mode 100644 index ac5370b1c..000000000 --- a/materialx/libraries/stdlib/osl/mx_fractal3d_color.osl +++ /dev/null @@ -1,36 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_fractal3d_color - [[ string help = "3D fractal noise" ]] - ( - point position = transform ("object", P) - [[ string help = "input coordinate position (default: object space P)", - int lockgeom = 0 ]], - - color amplitude = 1 - [[ string help = "center-to-peak amplitude of the noise" ]], - - int octaves = 3 - [[ string help = "number of summed octaves" ]], - - float lacunarity = 2.0 - [[ string help = "exponential scale between successive octaves" ]], - - float diminish = 0.5 - [[ string help = "rate at which amplitude is diminished per octave"]], - - string noisetype = "snoise" - [[ string help = "type of noise" ]], - - output color out = 0 - ) -{ - color f = fBm(position, octaves, lacunarity, diminish, noisetype); - out = f * amplitude; -} diff --git a/materialx/libraries/stdlib/osl/mx_fractal3d_color4.osl b/materialx/libraries/stdlib/osl/mx_fractal3d_color4.osl deleted file mode 100644 index 6ec9a3d9c..000000000 --- a/materialx/libraries/stdlib/osl/mx_fractal3d_color4.osl +++ /dev/null @@ -1,36 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_fractal3d_color4 - [[ string help = "3D fractal noise" ]] - ( - point position = transform ("object", P) - [[ string help = "input coordinate position (default: object space P)", - int lockgeom = 0 ]], - - color4 amplitude = {color(1,1,1), 1} - [[ string help = "center-to-peak amplitude of the noise" ]], - - int octaves = 3 - [[ string help = "number of summed octaves" ]], - - float lacunarity = 2.0 - [[ string help = "exponential scale between successive octaves" ]], - - float diminish = 0.5 - [[ string help = "rate at which amplitude is diminished per octave"]], - - string noisetype = "snoise" - [[ string help = "type of noise" ]], - - output color4 out = {color(0,0,0), 0} - ) -{ - color4 f = fBm(position, octaves, lacunarity, diminish, noisetype); - out = f * amplitude; -} diff --git a/materialx/libraries/stdlib/osl/mx_fractal3d_fa_color.osl b/materialx/libraries/stdlib/osl/mx_fractal3d_fa_color.osl deleted file mode 100644 index b6b87f69b..000000000 --- a/materialx/libraries/stdlib/osl/mx_fractal3d_fa_color.osl +++ /dev/null @@ -1,36 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_fractal3d_fa_color - [[ string help = "3D fractal noise" ]] - ( - point position = transform ("object", P) - [[ string help = "input coordinate position (default: object space P)", - int lockgeom = 0 ]], - - float amplitude = 1 - [[ string help = "center-to-peak amplitude of the noise" ]], - - int octaves = 3 - [[ string help = "number of summed octaves" ]], - - float lacunarity = 2.0 - [[ string help = "exponential scale between successive octaves" ]], - - float diminish = 0.5 - [[ string help = "rate at which amplitude is diminished per octave"]], - - string noisetype = "snoise" - [[ string help = "type of noise" ]], - - output color out = 0 - ) -{ - color f = fBm(position, octaves, lacunarity, diminish, noisetype); - out = f * amplitude; -} diff --git a/materialx/libraries/stdlib/osl/mx_fractal3d_fa_color4.osl b/materialx/libraries/stdlib/osl/mx_fractal3d_fa_color4.osl deleted file mode 100644 index da89d771e..000000000 --- a/materialx/libraries/stdlib/osl/mx_fractal3d_fa_color4.osl +++ /dev/null @@ -1,36 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_fractal3d_fa_color4 - [[ string help = "3D fractal noise" ]] - ( - point position = transform ("object", P) - [[ string help = "input coordinate position (default: object space P)", - int lockgeom = 0 ]], - - float amplitude = 1 - [[ string help = "center-to-peak amplitude of the noise" ]], - - int octaves = 3 - [[ string help = "number of summed octaves" ]], - - float lacunarity = 2.0 - [[ string help = "exponential scale between successive octaves" ]], - - float diminish = 0.5 - [[ string help = "rate at which amplitude is diminished per octave"]], - - string noisetype = "snoise" - [[ string help = "type of noise" ]], - - output color4 out = {color(0,0,0), 0} - ) -{ - color4 f = fBm(position, octaves, lacunarity, diminish, noisetype); - out = f * amplitude; -} diff --git a/materialx/libraries/stdlib/osl/mx_fractal3d_fa_vector.osl b/materialx/libraries/stdlib/osl/mx_fractal3d_fa_vector.osl deleted file mode 100644 index b8cf0b526..000000000 --- a/materialx/libraries/stdlib/osl/mx_fractal3d_fa_vector.osl +++ /dev/null @@ -1,36 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_fractal3d_fa_vector - [[ string help = "3D fractal noise" ]] - ( - point position = transform ("object", P) - [[ string help = "input coordinate position (default: object space P)", - int lockgeom = 0 ]], - - float amplitude = 1 - [[ string help = "center-to-peak amplitude of the noise" ]], - - int octaves = 3 - [[ string help = "number of summed octaves" ]], - - float lacunarity = 2.0 - [[ string help = "exponential scale between successive octaves" ]], - - float diminish = 0.5 - [[ string help = "rate at which amplitude is diminished per octave"]], - - string noisetype = "snoise" - [[ string help = "type of noise" ]], - - output vector out = 0 - ) -{ - vector f = fBm(position, octaves, lacunarity, diminish, noisetype); - out = f * amplitude; -} diff --git a/materialx/libraries/stdlib/osl/mx_fractal3d_fa_vector2.osl b/materialx/libraries/stdlib/osl/mx_fractal3d_fa_vector2.osl deleted file mode 100644 index a453b482b..000000000 --- a/materialx/libraries/stdlib/osl/mx_fractal3d_fa_vector2.osl +++ /dev/null @@ -1,36 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_fractal3d_fa_vector2 - [[ string help = "3D fractal noise" ]] - ( - point position = transform ("object", P) - [[ string help = "input coordinate position (default: object space P)", - int lockgeom = 0 ]], - - float amplitude = 1 - [[ string help = "center-to-peak amplitude of the noise" ]], - - int octaves = 3 - [[ string help = "number of summed octaves" ]], - - float lacunarity = 2.0 - [[ string help = "exponential scale between successive octaves" ]], - - float diminish = 0.5 - [[ string help = "rate at which amplitude is diminished per octave"]], - - string noisetype = "snoise" - [[ string help = "type of noise" ]], - - output vector2 out = {0,0} - ) -{ - vector2 f = fBm(position, octaves, lacunarity, diminish, noisetype); - out = f * amplitude; -} diff --git a/materialx/libraries/stdlib/osl/mx_fractal3d_fa_vector4.osl b/materialx/libraries/stdlib/osl/mx_fractal3d_fa_vector4.osl deleted file mode 100644 index 4cf7c1b82..000000000 --- a/materialx/libraries/stdlib/osl/mx_fractal3d_fa_vector4.osl +++ /dev/null @@ -1,36 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_fractal3d_fa_vector4 - [[ string help = "3D fractal noise" ]] - ( - point position = transform ("object", P) - [[ string help = "input coordinate position (default: object space P)", - int lockgeom = 0 ]], - - float amplitude = 1 - [[ string help = "center-to-peak amplitude of the noise" ]], - - int octaves = 3 - [[ string help = "number of summed octaves" ]], - - float lacunarity = 2.0 - [[ string help = "exponential scale between successive octaves" ]], - - float diminish = 0.5 - [[ string help = "rate at which amplitude is diminished per octave"]], - - string noisetype = "snoise" - [[ string help = "type of noise" ]], - - output vector4 out = {0,0,0,0} - ) -{ - vector4 f = fBm(position, octaves, lacunarity, diminish, noisetype); - out = f * amplitude; -} diff --git a/materialx/libraries/stdlib/osl/mx_fractal3d_float.osl b/materialx/libraries/stdlib/osl/mx_fractal3d_float.osl deleted file mode 100644 index 581243462..000000000 --- a/materialx/libraries/stdlib/osl/mx_fractal3d_float.osl +++ /dev/null @@ -1,36 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_fractal3d_float - [[ string help = "3D fractal noise" ]] - ( - point position = transform ("object", P) - [[ string help = "input coordinate position (default: object space P)", - int lockgeom = 0 ]], - - float amplitude = 1 - [[ string help = "center-to-peak amplitude of the noise" ]], - - int octaves = 3 - [[ string help = "number of summed octaves" ]], - - float lacunarity = 2.0 - [[ string help = "exponential scale between successive octaves" ]], - - float diminish = 0.5 - [[ string help = "rate at which amplitude is diminished per octave"]], - - string noisetype = "snoise" - [[ string help = "type of noise" ]], - - output float out = 0 - ) -{ - float f = fBm(position, octaves, lacunarity, diminish, noisetype); - out = f * amplitude; -} diff --git a/materialx/libraries/stdlib/osl/mx_fractal3d_vector.osl b/materialx/libraries/stdlib/osl/mx_fractal3d_vector.osl deleted file mode 100644 index 2c349b4d1..000000000 --- a/materialx/libraries/stdlib/osl/mx_fractal3d_vector.osl +++ /dev/null @@ -1,36 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_fractal3d_vector - [[ string help = "3D fractal noise" ]] - ( - point position = transform ("object", P) - [[ string help = "input coordinate position (default: object space P)", - int lockgeom = 0 ]], - - vector amplitude = 1 - [[ string help = "center-to-peak amplitude of the noise" ]], - - int octaves = 3 - [[ string help = "number of summed octaves" ]], - - float lacunarity = 2.0 - [[ string help = "exponential scale between successive octaves" ]], - - float diminish = 0.5 - [[ string help = "rate at which amplitude is diminished per octave"]], - - string noisetype = "snoise" - [[ string help = "type of noise" ]], - - output vector out = 0 - ) -{ - vector f = fBm(position, octaves, lacunarity, diminish, noisetype); - out = f * amplitude; -} diff --git a/materialx/libraries/stdlib/osl/mx_fractal3d_vector2.osl b/materialx/libraries/stdlib/osl/mx_fractal3d_vector2.osl deleted file mode 100644 index 344c37510..000000000 --- a/materialx/libraries/stdlib/osl/mx_fractal3d_vector2.osl +++ /dev/null @@ -1,36 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_fractal3d_vector2 - [[ string help = "3D fractal noise" ]] - ( - point position = transform ("object", P) - [[ string help = "input coordinate position (default: object space P)", - int lockgeom = 0 ]], - - vector2 amplitude = {1,1} - [[ string help = "center-to-peak amplitude of the noise" ]], - - int octaves = 3 - [[ string help = "number of summed octaves" ]], - - float lacunarity = 2.0 - [[ string help = "exponential scale between successive octaves" ]], - - float diminish = 0.5 - [[ string help = "rate at which amplitude is diminished per octave"]], - - string noisetype = "snoise" - [[ string help = "type of noise" ]], - - output vector2 out = {0,0} - ) -{ - vector2 f = fBm(position, octaves, lacunarity, diminish, noisetype); - out = f * amplitude; -} diff --git a/materialx/libraries/stdlib/osl/mx_fractal3d_vector4.osl b/materialx/libraries/stdlib/osl/mx_fractal3d_vector4.osl deleted file mode 100644 index 65b60ce2a..000000000 --- a/materialx/libraries/stdlib/osl/mx_fractal3d_vector4.osl +++ /dev/null @@ -1,36 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_fractal3d_vector4 - [[ string help = "3D fractal noise" ]] - ( - point position = transform ("object", P) - [[ string help = "input coordinate position (default: object space P)", - int lockgeom = 0 ]], - - vector4 amplitude = {1,1,1,1} - [[ string help = "center-to-peak amplitude of the noise" ]], - - int octaves = 3 - [[ string help = "number of summed octaves" ]], - - float lacunarity = 2.0 - [[ string help = "exponential scale between successive octaves" ]], - - float diminish = 0.5 - [[ string help = "rate at which amplitude is diminished per octave"]], - - string noisetype = "snoise" - [[ string help = "type of noise" ]], - - output vector4 out = {0,0,0,0} - ) -{ - vector4 f = fBm(position, octaves, lacunarity, diminish, noisetype); - out = f * amplitude; -} diff --git a/materialx/libraries/stdlib/osl/mx_frame_float.osl b/materialx/libraries/stdlib/osl/mx_frame_float.osl deleted file mode 100644 index a9ffde8ee..000000000 --- a/materialx/libraries/stdlib/osl/mx_frame_float.osl +++ /dev/null @@ -1,16 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#include "mx_funcs.h" - -shader mx_frame_float - [[ string help = "The current frame number as defined by the host environment." ]] - ( - output float out = 0 - ) -{ - getattribute("frame", out); -} diff --git a/materialx/libraries/stdlib/osl/mx_funcs.h b/materialx/libraries/stdlib/osl/mx_funcs.h deleted file mode 100644 index ba8a48fcc..000000000 --- a/materialx/libraries/stdlib/osl/mx_funcs.h +++ /dev/null @@ -1,817 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE -// -// MaterialX specification (c) 2017 Lucasfilm Ltd. -// http://www.materialx.org/ - -#pragma once -#include "color4.h" -#include "vector2.h" -#include "vector4.h" -#include "matrix33.h" - - -/////////////////////////////////////////////////////////////////////////// -// This file contains lots of functions helpful in the implementation of -// the MaterialX nodes. -/////////////////////////////////////////////////////////////////////////// - - -// Define mx_convert_type -// float -> colvecN -color mx_convert (float a) { return color(a); } -color4 mx_convert (float a) { return color4(a,a); } -vector mx_convert (float a) { return vector(a); } -vector2 mx_convert (float a) { return vector2(a,a); } -vector4 mx_convert (float a) { return vector4(a,a,a,a); } -// colN <-> vecN -vector mx_convert (color a) { return (vector)a; } -vector4 mx_convert (color4 a) { return vector4 (a.rgb[0], a.rgb[1], a.rgb[2], a.a); } -color mx_convert (vector a) { return (color)a; } -color4 mx_convert (vector4 a) { return color4 (color(a.x,a.y,a.z), a.w); } -// col3 <-> col4 -color mx_convert (color4 a) { return a.rgb; } -color4 mx_convert (color a) { return color4(a,1.0); } - -// Define mx_add() overloaded for all MX types. -float mx_add (float a, float b) { return a+b; } -point mx_add (point a, point b) { return a+b; } -point mx_add (point a, float b) { return a+b; } -vector mx_add (vector a, vector b) { return a+b; } -vector mx_add (vector a, float b) { return a+b; } -vector2 mx_add (vector2 a, vector2 b) { return a+b; } -vector2 mx_add (vector2 a, float b) { return a+b; } -vector4 mx_add (vector4 a, vector4 b) { return a+b; } -vector4 mx_add (vector4 a, float b) { return a+b; } -color mx_add (color a, color b) { return a+b; } -color mx_add (color a, float b) { return a+b; } -color4 mx_add (color4 a, color4 b) { return a+b; } -color4 mx_add (color4 a, float b) { return a+b; } -closure color mx_add (closure color a, closure color b) { return a+b; } - -matrix33 mx_add(matrix33 a, matrix33 b) -{ - return matrix33 (matrix( - a.m[0][0]+b.m[0][0], a.m[0][1]+b.m[0][1], a.m[0][2]+b.m[0][2], 0.0, - a.m[1][0]+b.m[1][0], a.m[1][1]+b.m[1][1], a.m[1][2]+b.m[1][2], 0.0, - a.m[2][0]+b.m[2][0], a.m[2][1]+b.m[2][1], a.m[2][2]+b.m[2][2], 0.0, - 0.0, 0.0, 0.0, 1.0)); -} - -matrix33 mx_add(matrix33 a, float b) -{ - return matrix33 (matrix(a.m[0][0]+b, a.m[0][1]+b, a.m[0][2]+b, 0.0, - a.m[1][0]+b, a.m[1][1]+b, a.m[1][2]+b, 0.0, - a.m[2][0]+b, a.m[2][1]+b, a.m[2][2]+b, 0.0, - 0.0, 0.0, 0.0, 1.0)); -} - -matrix mx_add(matrix a, matrix b) -{ - return matrix (a[0][0]+b[0][0], a[0][1]+b[0][1], a[0][2]+b[0][2], a[0][3]+b[0][3], - a[1][0]+b[1][0], a[1][1]+b[1][1], a[1][2]+b[1][2], a[1][3]+b[1][3], - a[2][0]+b[2][0], a[2][1]+b[2][1], a[2][2]+b[2][2], a[2][3]+b[2][3], - a[3][0]+b[3][0], a[3][1]+b[3][1], a[3][2]+b[3][2], a[3][3]+b[3][3]); -} - -matrix mx_add(matrix a, float b) -{ - return matrix (a[0][0]+b, a[0][1]+b, a[0][2]+b, a[0][3]+b, - a[1][0]+b, a[1][1]+b, a[1][2]+b, a[1][3]+b, - a[2][0]+b, a[2][1]+b, a[2][2]+b, a[2][3]+b, - a[3][0]+b, a[3][1]+b, a[3][2]+b, a[3][3]+b); -} - - -// Define mx_sub() overloaded for all MX types. -float mx_sub (float a, float b) { return a-b; } -point mx_sub (point a, point b) { return a-b; } -point mx_sub (point a, float b) { return a-b; } -vector mx_sub (vector a, vector b) { return a-b; } -vector mx_sub (vector a, float b) { return a-b; } -vector2 mx_sub (vector2 a, vector2 b) { return a-b; } -vector2 mx_sub (vector2 a, float b) { return a-b; } -vector4 mx_sub (vector4 a, vector4 b) { return a-b; } -vector4 mx_sub (vector4 a, float b) { return a-b; } -color mx_sub (color a, color b) { return a-b; } -color mx_sub (color a, float b) { return a-b; } -color4 mx_sub (color4 a, color4 b) { return a-b; } -color4 mx_sub (color4 a, float b) { return a-b; } - -matrix33 mx_sub (matrix33 a, matrix33 b) -{ - return matrix33 (matrix( - a.m[0][0]-b.m[0][0], a.m[0][1]-b.m[0][1], a.m[0][2]-b.m[0][2], 0.0, - a.m[1][0]-b.m[1][0], a.m[1][1]-b.m[1][1], a.m[1][2]-b.m[1][2], 0.0, - a.m[2][0]-b.m[2][0], a.m[2][1]-b.m[2][1], a.m[2][2]-b.m[2][2], 0.0, - 0.0, 0.0, 0.0, 1.0)); -} - -matrix33 mx_sub (matrix33 a, float b) -{ - return matrix33 (matrix( - a.m[0][0]-b, a.m[0][1]-b, a.m[0][2]-b, 0.0, - a.m[1][0]-b, a.m[1][1]-b, a.m[1][2]-b, 0.0, - a.m[2][0]-b, a.m[2][1]-b, a.m[2][2]-b, 0.0, - 0.0, 0.0, 0.0, 1.0)); -} - -matrix mx_sub (matrix a, matrix b) -{ - return matrix(a[0][0]-b[0][0], a[0][1]-b[0][1], a[0][2]-b[0][2], a[0][3]-b[0][3], - a[1][0]-b[1][0], a[1][1]-b[1][1], a[1][2]-b[1][2], a[1][3]-b[1][3], - a[2][0]-b[2][0], a[2][1]-b[2][1], a[2][2]-b[2][2], a[2][3]-b[2][3], - a[3][0]-b[3][0], a[3][1]-b[3][1], a[3][2]-b[3][2], a[3][3]-b[3][3]); -} - -matrix mx_sub (matrix a, float b) -{ - return matrix (a[0][0]-b, a[0][1]-b, a[0][2]-b, a[0][3]-b, - a[1][0]-b, a[1][1]-b, a[1][2]-b, a[1][3]-b, - a[2][0]-b, a[2][1]-b, a[2][2]-b, a[2][3]-b, - a[3][0]-b, a[3][1]-b, a[3][2]-b, a[3][3]-b); -} - - - -// remap `in` from [inLow, inHigh] to [outLow, outHigh], optionally clamping -// to the new range. -// -float remap(float in, float inLow, float inHigh, float outLow, float outHigh, int doClamp) -{ - float x = (in - inLow)/(inHigh-inLow); - if (doClamp == 1) { - x = clamp(x, 0, 1); - } - return outLow + (outHigh - outLow) * x; -} - -color remap(color in, color inLow, color inHigh, color outLow, color outHigh, int doClamp) -{ - color x = (in - inLow) / (inHigh - inLow); - if (doClamp == 1) { - x = clamp(x, 0, 1); - } - return outLow + (outHigh - outLow) * x; -} - -color remap(color in, float inLow, float inHigh, float outLow, float outHigh, int doClamp) -{ - color x = (in - inLow) / (inHigh - inLow); - if (doClamp == 1) { - x = clamp(x, 0, 1); - } - return outLow + (outHigh - outLow) * x; -} - -color4 remap(color4 c, color4 inLow, color4 inHigh, color4 outLow, color4 outHigh, int doClamp) -{ - return color4(remap(c.rgb, inLow.rgb, inHigh.rgb, outLow.rgb, outHigh.rgb, doClamp), - remap(c.a, inLow.a, inHigh.a, outLow.a, outHigh.a, doClamp)); -} - -color4 remap(color4 c, float inLow, float inHigh, float outLow, float outHigh, int doClamp) -{ - color4 c4_inLow = color4(color(inLow), inLow); - color4 c4_inHigh = color4(color(inHigh), inHigh); - color4 c4_outLow = color4(color(outLow), outLow); - color4 c4_outHigh = color4(color(outHigh), outHigh); - return remap(c, c4_inLow, c4_inHigh, c4_outLow, c4_outHigh, doClamp); -} - -vector2 remap(vector2 in, vector2 inLow, vector2 inHigh, vector2 outLow, vector2 outHigh, int doClamp) -{ - return vector2 (remap(in.x, inLow.x, inHigh.x, outLow.x, outHigh.x, doClamp), - remap(in.y, inLow.y, inHigh.y, outLow.y, outHigh.y, doClamp)); -} - -vector2 remap(vector2 in, float inLow, float inHigh, float outLow, float outHigh, int doClamp) -{ - return vector2 (remap(in.x, inLow, inHigh, outLow, outHigh, doClamp), - remap(in.y, inLow, inHigh, outLow, outHigh, doClamp)); -} - -vector4 remap(vector4 in, vector4 inLow, vector4 inHigh, vector4 outLow, vector4 outHigh, int doClamp) -{ - return vector4 (remap(in.x, inLow.x, inHigh.x, outLow.x, outHigh.x, doClamp), - remap(in.y, inLow.y, inHigh.y, outLow.y, outHigh.y, doClamp), - remap(in.z, inLow.z, inHigh.z, outLow.z, outHigh.z, doClamp), - remap(in.w, inLow.w, inHigh.w, outLow.w, outHigh.w, doClamp)); -} - -vector4 remap(vector4 in, float inLow, float inHigh, float outLow, float outHigh, int doClamp) -{ - return vector4 (remap(in.x, inLow, inHigh, outLow, outHigh, doClamp), - remap(in.y, inLow, inHigh, outLow, outHigh, doClamp), - remap(in.z, inLow, inHigh, outLow, outHigh, doClamp), - remap(in.w, inLow, inHigh, outLow, outHigh, doClamp)); -} - - - -float fgamma(float in, float g) -{ - return sign(in) * pow(abs(in), g); -} - -color fgamma(color in, color g) -{ - return sign(in) * pow(abs(in), g); -} - -color fgamma(color in, float g) -{ - return sign(in) * pow(abs(in), g); -} - -color4 fgamma(color4 a, color4 b) -{ - return color4(fgamma(a.rgb, b.rgb), fgamma(a.a, b.a)); -} - -color4 fgamma(color4 a, float b) -{ - return fgamma(a, color4(color(b), b)); -} - -vector2 fgamma(vector2 in, vector2 g) -{ - return vector2 (fgamma(in.x, g.x), fgamma(in.y, g.y)); -} - -vector2 fgamma(vector2 in, float g) -{ - return vector2 (fgamma(in.x, g), fgamma(in.y, g)); -} - -vector4 fgamma(vector4 in, vector4 g) -{ - return vector4 (fgamma(in.x, g.x), - fgamma(in.y, g.y), - fgamma(in.z, g.z), - fgamma(in.w, g.w)); -} - -vector4 fgamma(vector4 in, float g) -{ - return vector4 (fgamma(in.x, g), - fgamma(in.y, g), - fgamma(in.z, g), - fgamma(in.w, g)); -} - - - -// -// contrast scales the input around a central `pivot` value. -// -float contrast(float in, float amount, float pivot) -{ - float out = in - pivot; - out *= amount; - out += pivot; - return out; -} - -color contrast(color in, color amount, color pivot) -{ - color out = in - pivot; - out *= amount; - out += pivot; - return out; -} - -color contrast(color in, float amount, float pivot) -{ - color out = in - pivot; - out *= amount; - out += pivot; - return out; -} - -color4 contrast(color4 c, color4 amount, color4 pivot) -{ - return color4(contrast(c.rgb, amount.rgb, pivot.rgb), - contrast(c.a, amount.a, pivot.a)); -} - -color4 contrast(color4 c, float amount, float pivot) -{ - return contrast(c, color4(color(amount), amount), color4(color(pivot), pivot)); -} - -vector2 contrast(vector2 in, vector2 amount, vector2 pivot) -{ - return vector2 (contrast(in.x, amount.x, pivot.x), - contrast(in.y, amount.y, pivot.y)); -} - -vector2 contrast(vector2 in, float amount, float pivot) -{ - return contrast(in, vector2(amount, amount), vector2(pivot, pivot)); -} - -vector4 contrast(vector4 in, vector4 amount, vector4 pivot) -{ - return vector4 (contrast(in.x, amount.x, pivot.x), - contrast(in.y, amount.y, pivot.y), - contrast(in.z, amount.z, pivot.z), - contrast(in.w, amount.w, pivot.w)); -} - -vector4 contrast(vector4 in, float amount, float pivot) -{ - return vector4 (contrast(in.x, amount, pivot), - contrast(in.y, amount, pivot), - contrast(in.z, amount, pivot), - contrast(in.w, amount, pivot)); -} - - - -vector2 noise (string noisetype, float x, float y) -{ - color cnoise = (color) noise (noisetype, x, y); - return vector2 (cnoise[0], cnoise[1]); -} - -color4 noise (string noisetype, float x, float y) -{ - color cnoise = (color) noise (noisetype, x, y); - float fnoise = (float) noise (noisetype, x + 19, y + 73); - return color4 (cnoise, fnoise); -} - -vector4 noise (string noisetype, float x, float y) -{ - color cnoise = (color) noise (noisetype, x, y); - float fnoise = (float) noise (noisetype, x + 19, y + 73); - return vector4 (cnoise[0], cnoise[1], cnoise[2], fnoise); -} - - -vector2 noise (string noisetype, point position) -{ - color cnoise = (color) noise (noisetype, position); - return vector2 (cnoise[0], cnoise[1]); -} - -color4 noise (string noisetype, point position) -{ - color cnoise = (color) noise (noisetype, position); - float fnoise = (float) noise (noisetype, position+vector(19,73,29)); - return color4 (cnoise, fnoise); -} - -vector4 noise (string noisetype, point position) -{ - color cnoise = (color) noise (noisetype, position); - float fnoise = (float) noise (noisetype, position+vector(19,73,29)); - return vector4 (cnoise[0], cnoise[1], cnoise[2], fnoise); -} - - - -vector2 cellnoise (float x, float y) -{ - color cnoise = (color) cellnoise (x, y); - return vector2 (cnoise[0], cnoise[1]); -} - -color4 cellnoise (float x, float y) -{ - color cnoise = (color) cellnoise (x, y); - float fnoise = (float) cellnoise (x + 19, y + 73); - return color4 (cnoise, fnoise); -} - -vector4 cellnoise (float x, float y) -{ - color cnoise = (color) cellnoise (x, y); - float fnoise = (float) cellnoise (x + 19, y + 73); - return vector4 (cnoise[0], cnoise[1], cnoise[2], fnoise); -} - - - -vector2 cellnoise (point position) -{ - color cnoise = (color) cellnoise (position); - return vector2 (cnoise[0], cnoise[1]); -} - -color4 cellnoise (point position) -{ - color cnoise = (color) cellnoise (position); - float fnoise = (float) cellnoise (position+vector(19,73,29)); - return color4 (cnoise, fnoise); -} - -vector4 cellnoise (point position) -{ - color cnoise = (color) cellnoise (position); - float fnoise = (float) cellnoise (position+vector(19,73,29)); - return vector4 (cnoise[0], cnoise[1], cnoise[2], fnoise); -} - - - -// -// fractional Brownian motion -// -float fBm( point position, int octaves, float lacunarity, float diminish, string noisetype) -{ - float out = 0; - float amp = 1.0; - point p = position; - - for (int i = 0; i < octaves; i += 1) { - out += amp * noise(noisetype, p); - amp *= diminish; - p *= lacunarity; - } - return out; -} - -color fBm( point position, int octaves, float lacunarity, float diminish, string noisetype) -{ - color out = 0; - float amp = 1.0; - point p = position; - - for (int i = 0; i < octaves; i += 1) { - out += amp * (color)noise(noisetype, p); - amp *= diminish; - p *= lacunarity; - } - return out; -} - -vector2 fBm( point position, int octaves, float lacunarity, float diminish, string noisetype) -{ - return vector2 ((float) fBm (position, octaves, lacunarity, diminish, noisetype), - (float) fBm (position+point(19, 193, 17), octaves, lacunarity, diminish, noisetype)); -} - -color4 fBm( point position, int octaves, float lacunarity, float diminish, string noisetype) -{ - color c = (color) fBm (position, octaves, lacunarity, diminish, noisetype); - float f = (float) fBm (position+point(19, 193, 17), octaves, lacunarity, diminish, noisetype); - return color4 (c, f); -} - -vector4 fBm( point position, int octaves, float lacunarity, float diminish, string noisetype) -{ - color c = (color) fBm (position, octaves, lacunarity, diminish, noisetype); - float f = (float) fBm (position+point(19, 193, 17), octaves, lacunarity, diminish, noisetype); - return vector4 (c[0], c[1], c[2], f); -} - - - - - - -float swizzle_float (float in[4], string channels) -{ - float out; - float outF[4]; - int c_len = strlen(channels); - - for (int i=0; i 93 || x > 6 || y > 13) return 0; - int i = 98 * c + 7 * y + x; - return ((getchar("0@P01248@00120000P49B0000000000000:DXlW2UoDX@10008@h;IR4n@R000015A000000000000000000000000h?00" - "04@010000000000000000l0bGX@aL10000124XcX@Q25j300000000?Q248@8?000008@Pl5:DX@aL10" - "000000`CX@o24`70000`AP01N48@P0100000000l5:DX@aL12T70124XcX@Q25:40000@P0P348@P01>" - "00000240HP01248@P0a101248@T47B4940000HP01248@P01L00000000oBVS248@P000000000l48P7" - "@Pn0000048@`31248@030000000P@Q25:DP0124`1001248@P01248@P0007@P01" - "24`@P01R30000000S9S10000000", i / 6) - 48) >> (i % 6)) & 1; - } - int modp(int a, int b) { - int x = a % b; - return x < 0 ? x + b : x; - } - int len = strlen(str); - int jit = jitter ? hash(str) : 0; - int pix_w = len * 8; - int pix_h = 14; - int x = int(floor(s)); - int y = int(floor(t)); - if (wrap_s) x = modp(x + ( jitter & 15), pix_w + pix_h); - if (wrap_t) y = modp(y + ((jitter >> 16) & 15), pix_h + pix_h); - return float(glyph_pixel(getchar(str, x / 8), x - (x / 8) * 8, y)); -} - - -#endif /* OSLUTIL_H */ diff --git a/materialx/libraries/stdlib/osl/stdlib_osl_impl.mtlx b/materialx/libraries/stdlib/osl/stdlib_osl_impl.mtlx deleted file mode 100644 index 0d19f2e24..000000000 --- a/materialx/libraries/stdlib/osl/stdlib_osl_impl.mtlx +++ /dev/null @@ -1,780 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/materialx/libraries/stdlib/osl/stdosl.h b/materialx/libraries/stdlib/osl/stdosl.h deleted file mode 100644 index 6254476b9..000000000 --- a/materialx/libraries/stdlib/osl/stdosl.h +++ /dev/null @@ -1,601 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2009-2010 Sony Pictures Imageworks Inc., et al. All Rights Reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of Sony Pictures Imageworks nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -///////////////////////////////////////////////////////////////////////////// - - -#ifndef STDOSL_H -#define STDOSL_H - - -#ifndef M_PI -#define M_PI 3.1415926535897932 /* pi */ -#define M_PI_2 1.5707963267948966 /* pi/2 */ -#define M_PI_4 0.7853981633974483 /* pi/4 */ -#define M_2_PI 0.6366197723675813 /* 2/pi */ -#define M_2PI 6.2831853071795865 /* 2*pi */ -#define M_4PI 12.566370614359173 /* 4*pi */ -#define M_2_SQRTPI 1.1283791670955126 /* 2/sqrt(pi) */ -#define M_E 2.7182818284590452 /* e (Euler's number) */ -#define M_LN2 0.6931471805599453 /* ln(2) */ -#define M_LN10 2.3025850929940457 /* ln(10) */ -#define M_LOG2E 1.4426950408889634 /* log_2(e) */ -#define M_LOG10E 0.4342944819032518 /* log_10(e) */ -#define M_SQRT2 1.4142135623730950 /* sqrt(2) */ -#define M_SQRT1_2 0.7071067811865475 /* 1/sqrt(2) */ -#endif - - - -// Declaration of built-in functions and closures -#define BUILTIN [[ int builtin = 1 ]] -#define BUILTIN_DERIV [[ int builtin = 1, int deriv = 1 ]] - -#define PERCOMP1(name) \ - normal name (normal x) BUILTIN; \ - vector name (vector x) BUILTIN; \ - point name (point x) BUILTIN; \ - color name (color x) BUILTIN; \ - float name (float x) BUILTIN; - -#define PERCOMP2(name) \ - normal name (normal x, normal y) BUILTIN; \ - vector name (vector x, vector y) BUILTIN; \ - point name (point x, point y) BUILTIN; \ - color name (color x, color y) BUILTIN; \ - float name (float x, float y) BUILTIN; - -#define PERCOMP2F(name) \ - normal name (normal x, float y) BUILTIN; \ - vector name (vector x, float y) BUILTIN; \ - point name (point x, float y) BUILTIN; \ - color name (color x, float y) BUILTIN; \ - float name (float x, float y) BUILTIN; - - -// Basic math -normal degrees (normal x) { return x*(180.0/M_PI); } -vector degrees (vector x) { return x*(180.0/M_PI); } -point degrees (point x) { return x*(180.0/M_PI); } -color degrees (color x) { return x*(180.0/M_PI); } -float degrees (float x) { return x*(180.0/M_PI); } -normal radians (normal x) { return x*(M_PI/180.0); } -vector radians (vector x) { return x*(M_PI/180.0); } -point radians (point x) { return x*(M_PI/180.0); } -color radians (color x) { return x*(M_PI/180.0); } -float radians (float x) { return x*(M_PI/180.0); } -PERCOMP1 (cos) -PERCOMP1 (sin) -PERCOMP1 (tan) -PERCOMP1 (acos) -PERCOMP1 (asin) -PERCOMP1 (atan) -PERCOMP2 (atan2) -PERCOMP1 (cosh) -PERCOMP1 (sinh) -PERCOMP1 (tanh) -PERCOMP2F (pow) -PERCOMP2 (pow) -PERCOMP1 (exp) -PERCOMP1 (exp2) -PERCOMP1 (expm1) -PERCOMP1 (log) -point log (point a, float b) { return log(a)/log(b); } -vector log (vector a, float b) { return log(a)/log(b); } -color log (color a, float b) { return log(a)/log(b); } -float log (float a, float b) { return log(a)/log(b); } -PERCOMP1 (log2) -PERCOMP1 (log10) -PERCOMP1 (logb) -PERCOMP1 (sqrt) -PERCOMP1 (inversesqrt) -float hypot (float a, float b) { return sqrt (a*a + b*b); } -float hypot (float a, float b, float c) { return sqrt (a*a + b*b + c*c); } -PERCOMP1 (abs) -int abs (int x) BUILTIN; -PERCOMP1 (fabs) -int fabs (int x) BUILTIN; -PERCOMP1 (sign) -PERCOMP1 (floor) -PERCOMP1 (ceil) -PERCOMP1 (round) -PERCOMP1 (trunc) -PERCOMP2 (fmod) -PERCOMP2F (fmod) -int mod (int a, int b) { return a - b*(int)floor(a/b); } -point mod (point a, point b) { return a - b*floor(a/b); } -vector mod (vector a, vector b) { return a - b*floor(a/b); } -normal mod (normal a, normal b) { return a - b*floor(a/b); } -color mod (color a, color b) { return a - b*floor(a/b); } -point mod (point a, float b) { return a - b*floor(a/b); } -vector mod (vector a, float b) { return a - b*floor(a/b); } -normal mod (normal a, float b) { return a - b*floor(a/b); } -color mod (color a, float b) { return a - b*floor(a/b); } -float mod (float a, float b) { return a - b*floor(a/b); } -PERCOMP2 (min) -int min (int a, int b) BUILTIN; -PERCOMP2 (max) -int max (int a, int b) BUILTIN; -normal clamp (normal x, normal minval, normal maxval) { return max(min(x,maxval),minval); } -vector clamp (vector x, vector minval, vector maxval) { return max(min(x,maxval),minval); } -point clamp (point x, point minval, point maxval) { return max(min(x,maxval),minval); } -color clamp (color x, color minval, color maxval) { return max(min(x,maxval),minval); } -float clamp (float x, float minval, float maxval) { return max(min(x,maxval),minval); } -int clamp (int x, int minval, int maxval) { return max(min(x,maxval),minval); } -#if 0 -normal mix (normal x, normal y, normal a) { return x*(1-a) + y*a; } -normal mix (normal x, normal y, float a) { return x*(1-a) + y*a; } -vector mix (vector x, vector y, vector a) { return x*(1-a) + y*a; } -vector mix (vector x, vector y, float a) { return x*(1-a) + y*a; } -point mix (point x, point y, point a) { return x*(1-a) + y*a; } -point mix (point x, point y, float a) { return x*(1-a) + y*a; } -color mix (color x, color y, color a) { return x*(1-a) + y*a; } -color mix (color x, color y, float a) { return x*(1-a) + y*a; } -float mix (float x, float y, float a) { return x*(1-a) + y*a; } -#else -normal mix (normal x, normal y, normal a) BUILTIN; -normal mix (normal x, normal y, float a) BUILTIN; -vector mix (vector x, vector y, vector a) BUILTIN; -vector mix (vector x, vector y, float a) BUILTIN; -point mix (point x, point y, point a) BUILTIN; -point mix (point x, point y, float a) BUILTIN; -color mix (color x, color y, color a) BUILTIN; -color mix (color x, color y, float a) BUILTIN; -float mix (float x, float y, float a) BUILTIN; -#endif -closure color mix (closure color x, closure color y, float a) { return x*(1-a) + y*a; } -closure color mix (closure color x, closure color y, color a) { return x*(1-a) + y*a; } - -normal select (normal x, normal y, normal cond) BUILTIN; -vector select (vector x, vector y, vector cond) BUILTIN; -point select (point x, point y, point cond) BUILTIN; -color select (color x, color y, color cond) BUILTIN; -float select (float x, float y, float cond) BUILTIN; -normal select (normal x, normal y, float cond) BUILTIN; -vector select (vector x, vector y, float cond) BUILTIN; -point select (point x, point y, float cond) BUILTIN; -color select (color x, color y, float cond) BUILTIN; -normal select (normal x, normal y, int cond) BUILTIN; -vector select (vector x, vector y, int cond) BUILTIN; -point select (point x, point y, int cond) BUILTIN; -color select (color x, color y, int cond) BUILTIN; -float select (float x, float y, int cond) BUILTIN; -int isnan (float x) BUILTIN; -int isinf (float x) BUILTIN; -int isfinite (float x) BUILTIN; -float erf (float x) BUILTIN; -float erfc (float x) BUILTIN; - -// Vector functions - -vector cross (vector a, vector b) BUILTIN; -float dot (vector a, vector b) BUILTIN; -float length (vector v) BUILTIN; -float distance (point a, point b) BUILTIN; -float distance (point a, point b, point q) -{ - vector d = b - a; - float dd = dot(d, d); - if(dd == 0.0) - return distance(q, a); - float t = dot(q - a, d)/dd; - return distance(q, a + clamp(t, 0.0, 1.0)*d); -} -normal normalize (normal v) BUILTIN; -vector normalize (vector v) BUILTIN; -vector faceforward (vector N, vector I, vector Nref) -{ - return (dot(I, Nref) > 0) ? -N : N; -} -vector faceforward (vector N, vector I) -{ - return faceforward(N, I, Ng); -} -vector reflect (vector I, vector N) { return I - 2*dot(N,I)*N; } -vector refract (vector I, vector N, float eta) { - float IdotN = dot (I, N); - float k = 1 - eta*eta * (1 - IdotN*IdotN); - return (k < 0) ? vector(0,0,0) : (eta*I - N * (eta*IdotN + sqrt(k))); -} -void fresnel (vector I, normal N, float eta, - output float Kr, output float Kt, - output vector R, output vector T) -{ - float sqr(float x) { return x*x; } - float c = dot(I, N); - if (c < 0) - c = -c; - R = reflect(I, N); - float g = 1.0 / sqr(eta) - 1.0 + c * c; - if (g >= 0.0) { - g = sqrt (g); - float beta = g - c; - float F = (c * (g+c) - 1.0) / (c * beta + 1.0); - F = 0.5 * (1.0 + sqr(F)); - F *= sqr (beta / (g+c)); - Kr = F; - Kt = (1.0 - Kr) * eta*eta; - // OPT: the following recomputes some of the above values, but it - // gives us the same result as if the shader-writer called refract() - T = refract(I, N, eta); - } else { - // total internal reflection - Kr = 1.0; - Kt = 0.0; - T = vector (0,0,0); - } -} - -void fresnel (vector I, normal N, float eta, - output float Kr, output float Kt) -{ - vector R, T; - fresnel(I, N, eta, Kr, Kt, R, T); -} - - -normal transform (matrix Mto, normal p) BUILTIN; -vector transform (matrix Mto, vector p) BUILTIN; -point transform (matrix Mto, point p) BUILTIN; -normal transform (string from, string to, normal p) BUILTIN; -vector transform (string from, string to, vector p) BUILTIN; -point transform (string from, string to, point p) BUILTIN; -normal transform (string to, normal p) { return transform("common",to,p); } -vector transform (string to, vector p) { return transform("common",to,p); } -point transform (string to, point p) { return transform("common",to,p); } - -float transformu (string tounits, float x) BUILTIN; -float transformu (string fromunits, string tounits, float x) BUILTIN; - -point rotate (point p, float angle, point a, point b) -{ - vector axis = normalize (b - a); - float cosang, sinang; - sincos (angle, sinang, cosang); - float cosang1 = 1.0 - cosang; - float x = axis[0], y = axis[1], z = axis[2]; - matrix M = matrix (x * x + (1.0 - x * x) * cosang, - x * y * cosang1 + z * sinang, - x * z * cosang1 - y * sinang, - 0.0, - x * y * cosang1 - z * sinang, - y * y + (1.0 - y * y) * cosang, - y * z * cosang1 + x * sinang, - 0.0, - x * z * cosang1 + y * sinang, - y * z * cosang1 - x * sinang, - z * z + (1.0 - z * z) * cosang, - 0.0, - 0.0, 0.0, 0.0, 1.0); - return transform (M, p-a) + a; -} - - - -// Color functions - -float luminance (color c) BUILTIN; -color blackbody (float temperatureK) BUILTIN; -color wavelength_color (float wavelength_nm) BUILTIN; - - -color transformc (string to, color x) -{ - color rgb_to_hsv (color rgb) { // See Foley & van Dam - float r = rgb[0], g = rgb[1], b = rgb[2]; - float mincomp = min (r, min (g, b)); - float maxcomp = max (r, max (g, b)); - float delta = maxcomp - mincomp; // chroma - float h, s, v; - v = maxcomp; - if (maxcomp > 0) - s = delta / maxcomp; - else s = 0; - if (s <= 0) - h = 0; - else { - if (r >= maxcomp) h = (g-b) / delta; - else if (g >= maxcomp) h = 2 + (b-r) / delta; - else h = 4 + (r-g) / delta; - h /= 6; - if (h < 0) - h += 1; - } - return color (h, s, v); - } - - color rgb_to_hsl (color rgb) { // See Foley & van Dam - // First convert rgb to hsv, then to hsl - float minval = min (rgb[0], min (rgb[1], rgb[2])); - color hsv = rgb_to_hsv (rgb); - float maxval = hsv[2]; // v == maxval - float h = hsv[0], s, l = (minval+maxval) / 2; - if (minval == maxval) - s = 0; // special 'achromatic' case, hue is 0 - else if (l <= 0.5) - s = (maxval - minval) / (maxval + minval); - else - s = (maxval - minval) / (2 - maxval - minval); - return color (h, s, l); - } - - color r; - if (to == "rgb" || to == "RGB") - r = x; - else if (to == "hsv") - r = rgb_to_hsv (x); - else if (to == "hsl") - r = rgb_to_hsl (x); - else if (to == "YIQ") - r = color (dot (vector(0.299, 0.587, 0.114), (vector)x), - dot (vector(0.596, -0.275, -0.321), (vector)x), - dot (vector(0.212, -0.523, 0.311), (vector)x)); - else if (to == "XYZ") - r = color (dot (vector(0.412453, 0.357580, 0.180423), (vector)x), - dot (vector(0.212671, 0.715160, 0.072169), (vector)x), - dot (vector(0.019334, 0.119193, 0.950227), (vector)x)); - else { - error ("Unknown color space \"%s\"", to); - r = x; - } - return r; -} - - -color transformc (string from, string to, color x) -{ - color hsv_to_rgb (color c) { // Reference: Foley & van Dam - float h = c[0], s = c[1], v = c[2]; - color r; - if (s < 0.0001) { - r = v; - } else { - h = 6 * (h - floor(h)); // expand to [0..6) - int hi = (int)h; - float f = h - hi; - float p = v * (1-s); - float q = v * (1-s*f); - float t = v * (1-s*(1-f)); - if (hi == 0) r = color (v, t, p); - else if (hi == 1) r = color (q, v, p); - else if (hi == 2) r = color (p, v, t); - else if (hi == 3) r = color (p, q, v); - else if (hi == 4) r = color (t, p, v); - else r = color (v, p, q); - } - return r; - } - - color hsl_to_rgb (color c) { - float h = c[0], s = c[1], l = c[2]; - // Easiest to convert hsl -> hsv, then hsv -> RGB (per Foley & van Dam) - float v = (l <= 0.5) ? (l * (1 + s)) : (l * (1 - s) + s); - color r; - if (v <= 0) { - r = 0; - } else { - float min = 2 * l - v; - s = (v - min) / v; - r = hsv_to_rgb (color (h, s, v)); - } - return r; - } - - color r; - if (from == "rgb" || from == "RGB") - r = x; - else if (from == "hsv") - r = hsv_to_rgb (x); - else if (from == "hsl") - r = hsl_to_rgb (x); - else if (from == "YIQ") - r = color (dot (vector(1, 0.9557, 0.6199), (vector)x), - dot (vector(1, -0.2716, -0.6469), (vector)x), - dot (vector(1, -1.1082, 1.7051), (vector)x)); - else if (from == "XYZ") - r = color (dot (vector( 3.240479, -1.537150, -0.498535), (vector)x), - dot (vector(-0.969256, 1.875991, 0.041556), (vector)x), - dot (vector( 0.055648, -0.204043, 1.057311), (vector)x)); - else { - error ("Unknown color space \"%s\"", to); - r = x; - } - return transformc (to, r); -} - - - -// Matrix functions - -float determinant (matrix m) BUILTIN; -matrix transpose (matrix m) BUILTIN; - - - -// Pattern generation - -color step (color edge, color x) BUILTIN; -point step (point edge, point x) BUILTIN; -vector step (vector edge, vector x) BUILTIN; -normal step (normal edge, normal x) BUILTIN; -float step (float edge, float x) BUILTIN; -float smoothstep (float edge0, float edge1, float x) BUILTIN; - -color smoothstep (color edge0, color edge1, color in) -{ - return color (smoothstep(edge0[0], edge1[0], in[0]), - smoothstep(edge0[1], edge1[1], in[1]), - smoothstep(edge0[2], edge1[2], in[2])); -} -vector smoothstep (vector edge0, vector edge1, vector in) -{ - return vector (smoothstep(edge0[0], edge1[0], in[0]), - smoothstep(edge0[1], edge1[1], in[1]), - smoothstep(edge0[2], edge1[2], in[2])); -} - -float linearstep (float edge0, float edge1, float x) { - float result; - if (edge0 != edge1) { - float xclamped = clamp (x, edge0, edge1); - result = (xclamped - edge0) / (edge1 - edge0); - } else { // special case: edges coincide - result = step (edge0, x); - } - return result; -} - -float smooth_linearstep (float edge0, float edge1, float x_, float eps_) { - float result; - if (edge0 != edge1) { - float rampup (float x, float r) { return 0.5/r * x*x; } - float width_inv = 1.0 / (edge1 - edge0); - float eps = eps_ * width_inv; - float x = (x_ - edge0) * width_inv; - if (x <= -eps) result = 0; - else if (x >= eps && x <= 1.0-eps) result = x; - else if (x >= 1.0+eps) result = 1; - else if (x < eps) result = rampup (x+eps, 2.0*eps); - else /* if (x < 1.0+eps) */ result = 1.0 - rampup (1.0+eps - x, 2.0*eps); - } else { - result = step (edge0, x_); - } - return result; -} - -float aastep (float edge, float s, float dedge, float ds) { - // Box filtered AA step - float width = fabs(dedge) + fabs(ds); - float halfwidth = 0.5*width; - float e1 = edge-halfwidth; - return (s <= e1) ? 0.0 : ((s >= (edge+halfwidth)) ? 1.0 : (s-e1)/width); -} -float aastep (float edge, float s, float ds) { - return aastep (edge, s, filterwidth(edge), ds); -} -float aastep (float edge, float s) { - return aastep (edge, s, filterwidth(edge), filterwidth(s)); -} - - -// Derivatives and area operators - - -// Displacement functions - - -// String functions -int strlen (string s) BUILTIN; -int hash (string s) BUILTIN; -int getchar (string s, int index) BUILTIN; -int startswith (string s, string prefix) BUILTIN; -int endswith (string s, string suffix) BUILTIN; -string substr (string s, int start, int len) BUILTIN; -string substr (string s, int start) { return substr (s, start, strlen(s)); } -float stof (string str) BUILTIN; -int stoi (string str) BUILTIN; - -// Define concat in terms of shorter concat -string concat (string a, string b, string c) { - return concat(concat(a,b), c); -} -string concat (string a, string b, string c, string d) { - return concat(concat(a,b,c), d); -} -string concat (string a, string b, string c, string d, string e) { - return concat(concat(a,b,c,d), e); -} -string concat (string a, string b, string c, string d, string e, string f) { - return concat(concat(a,b,c,d,e), f); -} - - -// Texture - - -// Closures - -closure color emission() BUILTIN; -closure color background() BUILTIN; -closure color diffuse(normal N) BUILTIN; -closure color oren_nayar(normal N, float sigma) BUILTIN; -closure color oren_nayar(normal N) { return oren_nayar(N, 0.0); } -closure color translucent(normal N, float sigma) BUILTIN; -closure color translucent(normal N) { return translucent(N, 0.0); } -#if 0 // arnold doesn't support these -closure color phong(normal N, float exponent) BUILTIN; -closure color ward(normal N, vector T,float ax, float ay) BUILTIN; -#endif -closure color microfacet(string distribution, normal N, vector U, float xalpha, - float yalpha, float eta, int refract) BUILTIN; -closure color microfacet(string distribution, normal N, float alpha, float eta, - int refr) -{ - return microfacet(distribution, N, vector(0), alpha, alpha, eta, refr); -} -closure color reflection(normal N, float eta) BUILTIN; -closure color reflection(normal N) { return reflection (N, 0.0); } -closure color refraction(normal N, float eta) BUILTIN; -closure color transparent() BUILTIN; -closure color debug(string tag) BUILTIN; -closure color holdout() BUILTIN; -#if 1 // Arnold specific -closure color empirical_bssrdf(vector mfp, color albedo) BUILTIN; -closure color randomwalk_bssrdf(vector mfp, color albedo, float g) BUILTIN; -closure color volume_absorption() BUILTIN; -closure color volume_emission() BUILTIN; -closure color volume_henyey_greenstein(color absorption, color scattering, - color emission, float g) BUILTIN; -closure color volume_matte() BUILTIN; -#else // arnold doesn't support these -closure color subsurface(float eta, float g, color mfp, color albedo) BUILTIN; -#endif - -// Renderer state -int backfacing () BUILTIN; -int raytype (string typename) BUILTIN; -// the individual 'isFOOray' functions are deprecated -int iscameraray () { return raytype("camera"); } -int isdiffuseray () { return raytype("diffuse"); } -int isglossyray () { return raytype("glossy"); } -int isshadowray () { return raytype("shadow"); } -int getmatrix (string fromspace, string tospace, output matrix M) BUILTIN; -int getmatrix (string fromspace, output matrix M) { - return getmatrix (fromspace, "common", M); -} - - -// Miscellaneous - - - - -#undef BUILTIN -#undef BUILTIN_DERIV -#undef PERCOMP1 -#undef PERCOMP2 -#undef PERCOMP2F - -#endif /* STDOSL_H */ diff --git a/materialx/libraries/stdlib/osl/vector2.h b/materialx/libraries/stdlib/osl/vector2.h deleted file mode 100644 index 1307ab40a..000000000 --- a/materialx/libraries/stdlib/osl/vector2.h +++ /dev/null @@ -1,326 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE - -#pragma once -#define VECTOR2_H - -// vector2 is a 2D vector -struct vector2 -{ - float x; - float y; -}; - - - -// -// For vector2, define math operators to match vector -// - -vector2 __operator__neg__(vector2 a) -{ - return vector2(-a.x, -a.y); -} - -vector2 __operator__add__(vector2 a, vector2 b) -{ - return vector2(a.x + b.x, a.y + b.y); -} - -vector2 __operator__add__(vector2 a, int b) -{ - return a + vector2(b, b); -} - -vector2 __operator__add__(vector2 a, float b) -{ - return a + vector2(b, b); -} - -vector2 __operator__add__(int a, vector2 b) -{ - return vector2(a, a) + b; -} - -vector2 __operator__add__(float a, vector2 b) -{ - return vector2(a, a) + b; -} - -vector2 __operator__sub__(vector2 a, vector2 b) -{ - return vector2(a.x - b.x, a.y - b.y); -} - -vector2 __operator__sub__(vector2 a, int b) -{ - return a - vector2(b, b); -} - -vector2 __operator__sub__(vector2 a, float b) -{ - return a - vector2(b, b); -} - -vector2 __operator__sub__(int a, vector2 b) -{ - return vector2(a, a) - b; -} - -vector2 __operator__sub__(float a, vector2 b) -{ - return vector2(a, a) - b; -} - -vector2 __operator__mul__(vector2 a, vector2 b) -{ - return vector2(a.x * b.x, a.y * b.y); -} - -vector2 __operator__mul__(vector2 a, int b) -{ - return a * vector2(b, b); -} - -vector2 __operator__mul__(vector2 a, float b) -{ - return a * vector2(b, b); -} - -vector2 __operator__mul__(int a, vector2 b) -{ - return b * vector2(a, a); -} - -vector2 __operator__mul__(float a, vector2 b) -{ - return b * vector2(a, a); -} - -vector2 __operator__div__(vector2 a, vector2 b) -{ - return vector2(a.x / b.x, a.y / b.y); -} - -vector2 __operator__div__(vector2 a, int b) -{ - float b_inv = 1.0/b; - return a * vector2(b_inv, b_inv); -} - -vector2 __operator__div__(vector2 a, float b) -{ - float b_inv = 1.0/b; - return a * vector2(b_inv, b_inv); -} - -vector2 __operator__div__(int a, vector2 b) -{ - return vector2(a, a) / b; -} - -vector2 __operator__div__(float a, vector2 b) -{ - return vector2(a, a) / b; -} - -int __operator__eq__(vector2 a, vector2 b) -{ - return (a.x == b.x) && (a.y == b.y); -} - -int __operator__ne__(vector2 a, vector2 b) -{ - return (a.x != b.x) || (a.y != b.y); -} - - - - -// -// For vector2, define most of the stdosl functions to match vector -// - -vector2 abs(vector2 a) -{ - return vector2 (abs(a.x), abs(a.y)); -} - -vector2 ceil(vector2 a) -{ - return vector2 (ceil(a.x), ceil(a.y)); -} - -vector2 floor(vector2 a) -{ - return vector2 (floor(a.x), floor(a.y)); -} - -vector2 sqrt(vector2 a) -{ - return vector2 (sqrt(a.x), sqrt(a.y)); -} - -vector2 exp(vector2 a) -{ - return vector2 (exp(a.x), exp(a.y)); -} - -vector2 log(vector2 a) -{ - return vector2 (log(a.x), log(a.y)); -} - -vector2 log2(vector2 a) -{ - return vector2 (log2(a.x), log2(a.y)); -} - -vector2 mix(vector2 a, vector2 b, float x ) -{ - return vector2 (mix(a.x, b.x, x), mix(a.y, b.y, x)); -} - -float dot(vector2 a, vector2 b) -{ - return (a.x * b.x + a.y * b.y); -} - -float length (vector2 a) -{ - return hypot (a.x, a.y); -} - -vector2 smoothstep(vector2 low, vector2 high, vector2 in) -{ - return vector2 (smoothstep(low.x, high.x, in.x), - smoothstep(low.y, high.y, in.y)); -} - -vector2 smoothstep(float low, float high, vector2 in) -{ - return vector2 (smoothstep(low, high, in.x), - smoothstep(low, high, in.y)); -} - -vector2 clamp(vector2 in, vector2 low, vector2 high) -{ - return vector2 (clamp(in.x, low.x, high.x), - clamp(in.y, low.y, high.y)); -} - -vector2 clamp(vector2 in, float low, float high) -{ - return clamp(in, vector2(low, low), vector2(high, high)); -} - -vector2 max(vector2 a, vector2 b) -{ - return vector2 (max(a.x, b.x), - max(a.y, b.y)); -} - -vector2 max(vector2 a, float b) -{ - return max(a, vector2(b, b)); -} - -vector2 normalize(vector2 a) -{ - return a / length(a); -} - -vector2 min(vector2 a, vector2 b) -{ - return vector2 (min(a.x, a.x), - min(b.y, b.y)); -} - -vector2 min(vector2 a, float b) -{ - return min(a, vector2(b, b)); -} - -vector2 mod(vector2 a, vector2 b) -{ - return vector2(mod(a.x, b.x), - mod(a.y, b.y)); -} - -vector2 mod(vector2 a, float b) -{ - return mod(a, vector2(b, b)); -} - -vector2 fmod(vector2 a, vector2 b) -{ - return vector2 (fmod(a.x, b.x), - fmod(a.y, b.y)); -} - -vector2 fmod(vector2 a, float b) -{ - return fmod(a, vector2(b, b)); -} - -vector2 pow(vector2 in, vector2 amount) -{ - return vector2(pow(in.x, amount.x), - pow(in.y, amount.y)); -} - -vector2 pow(vector2 in, float amount) -{ - return vector2(pow(in.x, amount), - pow(in.y, amount)); -} - -vector2 sign(vector2 a) -{ - return vector2(sign(a.x), - sign(a.y)); -} - -vector2 sin(vector2 a) -{ - return vector2(sin(a.x), - sin(a.y)); -} - -vector2 cos(vector2 a) -{ - return vector2(cos(a.x), - cos(a.y)); -} - -vector2 tan(vector2 a) -{ - return vector2(tan(a.x), - tan(a.y)); -} - -vector2 asin(vector2 a) -{ - return vector2(asin(a.x), - asin(a.y)); -} - -vector2 acos(vector2 a) -{ - return vector2(acos(a.x), - acos(a.y)); -} - -vector2 atan2(vector2 a, float f) -{ - return vector2(atan2(a.x, f), - atan2(a.y, f)); -} - -vector2 atan2(vector2 a, vector2 b) -{ - return vector2(atan2(a.x, b.x), - atan2(a.y, b.y)); -} - - diff --git a/materialx/libraries/stdlib/osl/vector4.h b/materialx/libraries/stdlib/osl/vector4.h deleted file mode 100644 index ee3659735..000000000 --- a/materialx/libraries/stdlib/osl/vector4.h +++ /dev/null @@ -1,407 +0,0 @@ -// Open Shading Language : Copyright (c) 2009-2017 Sony Pictures Imageworks Inc., et al. -// https://github.com/imageworks/OpenShadingLanguage/blob/master/LICENSE - -#pragma once -#define VECTOR4_H - - -// vector4 is a 4D vector -struct vector4 -{ - float x; - float y; - float z; - float w; -}; - - - -// -// For vector4, define math operators to match vector -// - -vector4 __operator__neg__(vector4 a) -{ - return vector4(-a.x, -a.y, -a.z, -a.w); -} - -vector4 __operator__add__(vector4 a, vector4 b) -{ - return vector4(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w); -} - -vector4 __operator__add__(vector4 a, int b) -{ - return a + vector4(b, b, b, b); -} - -vector4 __operator__add__(vector4 a, float b) -{ - return a + vector4(b, b, b, b); -} - -vector4 __operator__add__(int a, vector4 b) -{ - return vector4(a, a, a, a) + b; -} - -vector4 __operator__add__(float a, vector4 b) -{ - return vector4(a, a, a, a) + b; -} - -vector4 __operator__sub__(vector4 a, vector4 b) -{ - return vector4(a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w); -} - -vector4 __operator__sub__(vector4 a, int b) -{ - return a - vector4(b, b, b, b); -} - -vector4 __operator__sub__(vector4 a, float b) -{ - return a - vector4(b, b, b, b); -} - -vector4 __operator__sub__(int a, vector4 b) -{ - return vector4(a, a, a, a) - b; -} - -vector4 __operator__sub__(float a, vector4 b) -{ - return vector4(a, a, a, a) - b; -} - -vector4 __operator__mul__(vector4 a, vector4 b) -{ - return vector4(a.x * b.x, a.y * b.y, a.z * b.z, a.w * b.w); -} - -vector4 __operator__mul__(vector4 a, int b) -{ - return a * vector4(b, b, b, b); -} - -vector4 __operator__mul__(vector4 a, float b) -{ - return a * vector4(b, b, b, b); -} - -vector4 __operator__mul__(int a, vector4 b) -{ - return vector4(a, a, a, a) * b; -} - -vector4 __operator__mul__(float a, vector4 b) -{ - return vector4(a, a, a, a) * b; -} - -vector4 __operator__div__(vector4 a, vector4 b) -{ - return vector4(a.x / b.x, a.y / b.y, a.z / b.z, a.w / b.w); -} - -vector4 __operator__div__(vector4 a, int b) -{ - float b_inv = 1.0/b; - return a * vector4(b_inv, b_inv, b_inv, b_inv); -} - -vector4 __operator__div__(vector4 a, float b) -{ - float b_inv = 1.0/b; - return a * vector4(b_inv, b_inv, b_inv, b_inv); -} - -vector4 __operator__div__(int a, vector4 b) -{ - return vector4(a, a, a, a) / b; -} - -vector4 __operator__div__(float a, vector4 b) -{ - return vector4(a, a, a, a) / b; -} - -int __operator__eq__(vector4 a, vector4 b) -{ - return (a.x == b.x) && (a.y == b.y) && (a.z == b.z) && (a.w == b.w); -} - -int __operator__ne__(vector4 a, vector4 b) -{ - return (a.x != b.x) || (a.y != b.y) || (a.z != b.z) || (a.w != b.w); -} - - - - -// -// For vector4, define most of the stdosl functions to match vector -// - -vector4 abs(vector4 in) -{ - return vector4 (abs(in.x), - abs(in.y), - abs(in.z), - abs(in.w)); -} - -vector4 ceil(vector4 in) -{ - return vector4 (ceil(in.x), - ceil(in.y), - ceil(in.z), - ceil(in.w)); -} - -vector4 floor(vector4 in) -{ - return vector4 (floor(in.x), - floor(in.y), - floor(in.z), - floor(in.w)); -} - -vector4 sqrt(vector4 in) -{ - return vector4 (sqrt(in.x), - sqrt(in.y), - sqrt(in.z), - sqrt(in.w)); -} - -vector4 exp(vector4 in) -{ - return vector4 (exp(in.x), - exp(in.y), - exp(in.z), - exp(in.w)); -} - -vector4 log(vector4 in) -{ - return vector4 (log(in.x), - log(in.y), - log(in.z), - log(in.w)); -} - -vector4 log2(vector4 in) -{ - return vector4 (log2(in.x), - log2(in.y), - log2(in.z), - log2(in.w)); -} - -vector4 mix(vector4 value1, vector4 value2, float x ) -{ - return vector4 (mix( value1.x, value2.x, x), - mix( value1.y, value2.y, x), - mix( value1.z, value2.z, x), - mix( value1.w, value2.w, x)); -} - -vector vec4ToVec3(vector4 v) -{ - return vector(v.x, v.y, v.z) / v.w; -} - -float dot(vector4 a, vector4 b) -{ - return ((a.x * b.x) + (a.y * b.y) + (a.z * b.z) + (a.w * b.w)); -} - -float length (vector4 a) -{ - return sqrt (a.x*a.x + a.y*a.y + a.z*a.z + a.w*a.w); -} - -vector4 smoothstep(vector4 low, vector4 high, vector4 in) -{ - return vector4 (smoothstep(low.x, high.x, in.x), - smoothstep(low.y, high.y, in.y), - smoothstep(low.z, high.z, in.z), - smoothstep(low.w, high.w, in.w)); -} - -vector4 smoothstep(float low, float high, vector4 in) -{ - return vector4 (smoothstep(low, high, in.x), - smoothstep(low, high, in.y), - smoothstep(low, high, in.z), - smoothstep(low, high, in.w)); -} - -vector4 clamp(vector4 in, vector4 low, vector4 high) -{ - return vector4 (clamp(in.x, low.x, high.x), - clamp(in.y, low.y, high.y), - clamp(in.z, low.z, high.z), - clamp(in.w, low.w, high.w)); -} - -vector4 clamp(vector4 in, float low, float high) -{ - return vector4 (clamp(in.x, low, high), - clamp(in.y, low, high), - clamp(in.z, low, high), - clamp(in.w, low, high)); -} - -vector4 max(vector4 a, vector4 b) -{ - return vector4 (max(a.x, b.x), - max(a.y, b.y), - max(a.z, b.z), - max(a.w, b.w)); -} - -vector4 max(vector4 a, float b) -{ - return max(a, vector4(b, b, b, b)); -} - -vector4 normalize(vector4 a) -{ - return a / length(a); -} - -vector4 min(vector4 a, vector4 b) -{ - return vector4 (min(a.x, b.x), - min(a.y, b.y), - min(a.z, b.z), - min(a.w, b.w)); -} - -vector4 min(vector4 a, float b) -{ - return min(a, vector4(b, b, b, b)); -} - -vector4 mod(vector4 a, vector4 b) -{ - return vector4(mod(a.x, b.x), - mod(a.y, b.y), - mod(a.z, b.z), - mod(a.w, b.w)); -} - -vector4 mod(vector4 a, float b) -{ - return mod(a, vector4(b, b, b, b)); -} - -vector4 fmod(vector4 a, vector4 b) -{ - return vector4 (fmod(a.x, b.x), - fmod(a.y, b.y), - fmod(a.z, b.z), - fmod(a.w, b.w)); -} - -vector4 fmod(vector4 a, float b) -{ - return fmod(a, vector4(b, b, b, b)); -} - -vector4 pow(vector4 in, vector4 amount) -{ - return vector4 (pow(in.x, amount.x), - pow(in.y, amount.y), - pow(in.z, amount.z), - pow(in.w, amount.w)); -} - -vector4 pow(vector4 in, float amount) -{ - return vector4 (pow(in.x, amount), - pow(in.y, amount), - pow(in.z, amount), - pow(in.w, amount)); -} - -vector4 sign(vector4 a) -{ - return vector4(sign(a.x), - sign(a.y), - sign(a.z), - sign(a.w)); -} - -vector4 sin(vector4 a) -{ - return vector4(sin(a.x), - sin(a.y), - sin(a.z), - sin(a.w)); -} - -vector4 cos(vector4 a) -{ - return vector4(cos(a.x), - cos(a.y), - cos(a.z), - cos(a.w)); -} - -vector4 tan(vector4 a) -{ - return vector4(tan(a.x), - tan(a.y), - tan(a.z), - tan(a.w)); -} - -vector4 asin(vector4 a) -{ - return vector4(asin(a.x), - asin(a.y), - asin(a.z), - asin(a.w)); -} - -vector4 acos(vector4 a) -{ - return vector4(acos(a.x), - acos(a.y), - acos(a.z), - acos(a.w)); -} - -vector4 atan2(vector4 a, float f) -{ - return vector4(atan2(a.x, f), - atan2(a.y, f), - atan2(a.z, f), - atan2(a.w, f)); -} - -vector4 atan2(vector4 a, vector4 b) -{ - return vector4(atan2(a.x, b.x), - atan2(a.y, b.y), - atan2(a.z, b.z), - atan2(a.w, b.w)); -} - - -vector4 transform (matrix M, vector4 p) -{ - return vector4 (M[0][0]*p.x + M[0][1]*p.y + M[0][2]*p.z + M[0][3]*p.w, - M[1][0]*p.x + M[1][1]*p.y + M[1][2]*p.z + M[1][3]*p.w, - M[2][0]*p.x + M[2][1]*p.y + M[2][2]*p.z + M[2][3]*p.w, - M[3][0]*p.x + M[3][1]*p.y + M[3][2]*p.z + M[3][3]*p.w); -} - -vector4 transform (string fromspace, string tospace, vector4 p) -{ - return transform (matrix(fromspace,tospace), p); -} diff --git a/materialx/libraries/stdlib/stdlib_defs.mtlx b/materialx/libraries/stdlib/stdlib_defs.mtlx deleted file mode 100644 index a18fcd7d2..000000000 --- a/materialx/libraries/stdlib/stdlib_defs.mtlx +++ /dev/null @@ -1,4210 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/materialx/libraries/stdlib/stdlib_ng.mtlx b/materialx/libraries/stdlib/stdlib_ng.mtlx deleted file mode 100644 index 7dd8a262f..000000000 --- a/materialx/libraries/stdlib/stdlib_ng.mtlx +++ /dev/null @@ -1,2070 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/materialx/libraries/targets/genglsl.mtlx b/materialx/libraries/targets/genglsl.mtlx deleted file mode 100644 index e53218ada..000000000 --- a/materialx/libraries/targets/genglsl.mtlx +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - diff --git a/materialx/libraries/targets/genmdl.mtlx b/materialx/libraries/targets/genmdl.mtlx deleted file mode 100644 index 60da62e20..000000000 --- a/materialx/libraries/targets/genmdl.mtlx +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - diff --git a/materialx/libraries/targets/genosl.mtlx b/materialx/libraries/targets/genosl.mtlx deleted file mode 100644 index 6a9ec43b4..000000000 --- a/materialx/libraries/targets/genosl.mtlx +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - diff --git a/materialx/material/ui.py b/materialx/material/ui.py index ac6fd86bc..4ef344c97 100644 --- a/materialx/material/ui.py +++ b/materialx/material/ui.py @@ -413,7 +413,7 @@ class MATERIAL_PT_materialx_displacementshader(MATERIAL_PT_materialx_output): class MATERIAL_OP_export_file(bpy.types.Operator, ExportHelper): bl_idname = utils.with_prefix('material_export_file') - bl_label = "Export MaterialX" + bl_label = "Export to File" bl_description = "Export material as MaterialX node tree to .mtlx file" # region properties @@ -435,7 +435,7 @@ class MATERIAL_OP_export_file(bpy.types.Operator, ExportHelper): default=False ) is_export_textures: bpy.props.BoolProperty( - name="Export bound textures", + name="Export textures", description="Export bound textures to corresponded folder", default=True ) @@ -444,51 +444,31 @@ class MATERIAL_OP_export_file(bpy.types.Operator, ExportHelper): description="Сlean texture folder before export", default=False ) - is_clean_deps_folders: bpy.props.BoolProperty( - name="Сlean dependencies folders", - description="Сlean MaterialX dependencies folders before export", - default=False - ) texture_dir_name: bpy.props.StringProperty( name="Folder name", description="Texture folder name used for exporting files", default='textures', maxlen=1024, ) - is_create_new_folder: bpy.props.BoolProperty( - name="Create new folder", - description="Create new folder for material", - default=True - ) # endregion def execute(self, context): materialx_prop = mx_properties(context.material) - if not materialx_prop.convert_to_materialx(): - return {'CANCELLED'} - - doc = mx_properties(context.material).export(None) + doc = materialx_prop.export(None, False) if not doc: return {'CANCELLED'} - if self.is_create_new_folder: - self.filepath = str(Path(self.filepath).parent / context.material.name_full / Path(self.filepath).name) - utils.export_mx_to_file(doc, self.filepath, mx_node_tree=None, - is_export_deps=self.is_export_deps, + # is_export_deps=self.is_export_deps, is_export_textures=self.is_export_textures, - texture_dir_name=self.texture_dir_name, - is_clean_texture_folder=self.is_clean_texture_folder, - is_clean_deps_folders=self.is_clean_deps_folders) + texture_dir_name=self.texture_dir_name) - bpy.data.node_groups.remove(materialx_prop.mx_node_tree) return {'FINISHED'} def draw(self, context): - self.layout.prop(self, 'is_create_new_folder') - self.layout.prop(self, 'is_export_deps') + # self.layout.prop(self, 'is_export_deps') col = self.layout.column(align=False) col.prop(self, 'is_export_textures') @@ -542,7 +522,7 @@ class MATERIAL_PT_tools(bpy.types.Panel): row.operator(MATERIAL_OP_convert_to_materialx.bl_idname, icon='FILE_TICK', text="Convert") row.operator(MATERIAL_OP_new_mx_node_tree.bl_idname, icon='ADD', text="") - layout.operator(MATERIAL_OP_export_file.bl_idname, text="Export MaterialX to file", icon='EXPORT') + layout.operator(MATERIAL_OP_export_file.bl_idname, icon='EXPORT') class MATERIAL_PT_dev(bpy.types.Panel): diff --git a/materialx/nodes/generate_node_classes.py b/materialx/nodes/generate_node_classes.py index 20de7a963..535d8b124 100644 --- a/materialx/nodes/generate_node_classes.py +++ b/materialx/nodes/generate_node_classes.py @@ -277,7 +277,7 @@ from bpy.props import ( from {ADDON_ALIAS}.nodes.node import MxNode -FILE_PATH = r"{file_path}" +FILE_PATH = "{file_path.as_posix()}" """) doc = mx.createDocument() @@ -320,11 +320,10 @@ def generate_basic_classes(): ('USD', "USD", utils.MX_LIBS_DIR / "bxdf/usd_preview_surface.mtlx"), ('STD', None, utils.MX_LIBS_DIR / "stdlib/stdlib_defs.mtlx"), ('PBR', "PBR", utils.MX_LIBS_DIR / "pbrlib/pbrlib_defs.mtlx"), - ('ALG', "Algorithm", utils.MX_LIBS_DIR / "alglib/alglib_defs.mtlx"), + ('ALG', "Algorithm", utils.MX_ADDON_LIBS_DIR / "alglib/alglib_defs.mtlx"), ] for prefix, category, file_path in files: - module_name = f"gen_{file_path.name[:-len(file_path.suffix)]}" module_file = gen_code_dir / f"{module_name}.py" diff --git a/materialx/nodes/ui.py b/materialx/nodes/ui.py index 3b46aaa26..82b87de04 100644 --- a/materialx/nodes/ui.py +++ b/materialx/nodes/ui.py @@ -76,27 +76,12 @@ class NODES_OP_export_file(bpy.types.Operator, ExportHelper): description="Export bound textures to corresponded folder", default=True ) - is_clean_texture_folder: bpy.props.BoolProperty( - name="Сlean texture folder", - description="Сlean texture folder before export", - default=False - ) - is_clean_deps_folders: bpy.props.BoolProperty( - name="Сlean MaterialX dependencies folders", - description="Сlean MaterialX dependencies folders before export", - default=False - ) texture_dir_name: bpy.props.StringProperty( name="Texture folder name", description="Texture folder name used for exporting files", default='textures', maxlen=1024 ) - is_create_new_folder: bpy.props.BoolProperty( - name="Create new folder", - description="Create new folder for material", - default=True - ) # endregion def execute(self, context): @@ -106,22 +91,16 @@ class NODES_OP_export_file(bpy.types.Operator, ExportHelper): log.warn("Incorrect node tree to export", mx_node_tree) return {'CANCELLED'} - if self.is_create_new_folder: - self.filepath = str(Path(self.filepath).parent / mx_node_tree.name_full / Path(self.filepath).name) - utils.export_mx_to_file(doc, self.filepath, mx_node_tree=mx_node_tree, - is_export_deps=self.is_export_deps, + # is_export_deps=self.is_export_deps, is_export_textures=self.is_export_textures, - texture_dir_name=self.texture_dir_name, - is_clean_texture_folder=self.is_clean_texture_folder, - is_clean_deps_folders=self.is_clean_deps_folders) + texture_dir_name=self.texture_dir_name) return {'FINISHED'} def draw(self, context): - self.layout.prop(self, 'is_create_new_folder') - self.layout.prop(self, 'is_export_deps') + # self.layout.prop(self, 'is_export_deps') col = self.layout.column(align=False) col.prop(self, 'is_export_textures') diff --git a/materialx/utils.py b/materialx/utils.py index e336e78dd..cdf63109a 100644 --- a/materialx/utils.py +++ b/materialx/utils.py @@ -16,10 +16,12 @@ log = logging.Log('utils') ADDON_ROOT_DIR = Path(__file__).parent -ADDON_DATA_DIR = Path(bpy.utils.user_resource("SCRIPTS", path=f"addons/{ADDON_ALIAS}_data", create=True)) +ADDON_DATA_DIR = Path(bpy.utils.user_resource('SCRIPTS', path=f"addons/{ADDON_ALIAS}_data", create=True)) +BL_DATA_DIR = Path(bpy.utils.resource_path('LOCAL')) / "datafiles/materialx" MX_LIBS_FOLDER = "libraries" -MX_LIBS_DIR = ADDON_ROOT_DIR / MX_LIBS_FOLDER +MX_LIBS_DIR = BL_DATA_DIR / MX_LIBS_FOLDER +MX_ADDON_LIBS_DIR = ADDON_ROOT_DIR / MX_LIBS_FOLDER NODE_CLASSES_FOLDER = "materialx_nodes" NODE_CLASSES_DIR = ADDON_DATA_DIR / NODE_CLASSES_FOLDER @@ -30,8 +32,6 @@ MATLIB_URL = "https://api.matlib.gpuopen.com/api" TEMP_FOLDER = "bl-materialx" -os.environ['MATERIALX_SEARCH_PATH'] = str(MX_LIBS_DIR) - class MaterialXProperties(bpy.types.PropertyGroup): bl_type = None -- 2.30.2 From eaac854bd14f8b6582a08cafd2b8ab746b2e4466 Mon Sep 17 00:00:00 2001 From: Vasyl Pidhirskyi <42581166+VascoPi@users.noreply.github.com> Date: Tue, 25 Oct 2022 12:32:53 +0300 Subject: [PATCH 12/28] BLEN-235: Use MaterialX addon instead mx related code. (#11) Added get_materialx_data method. --- materialx/material/properties.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/materialx/material/properties.py b/materialx/material/properties.py index 3bb3afcd2..68905da86 100644 --- a/materialx/material/properties.py +++ b/materialx/material/properties.py @@ -73,6 +73,18 @@ class MaterialProperties(MaterialXProperties): return doc + def get_materialx_data(self, obj: bpy.types.Object): + doc = self.export(obj) + if not doc: + return None, None + + mat = self.id_data + mtlx_file = get_temp_file(".mtlx", f'{mat.name}_{self.mx_node_tree.name if self.mx_node_tree else ""}') + mx.writeToXmlFile(doc, str(mtlx_file)) + + return mtlx_file, doc + + def convert_to_materialx(self, obj: bpy.types.Object = None): mat = self.id_data output_node = self.output_node -- 2.30.2 From abcd6a82d11e1b62350998b829f399a6a4b72806 Mon Sep 17 00:00:00 2001 From: Georgiy Markelov <42409851+DagerD@users.noreply.github.com> Date: Wed, 26 Oct 2022 19:47:34 +0300 Subject: [PATCH 13/28] added clear_temp_dir on Blender exit (#13) --- materialx/__init__.py | 3 +++ materialx/utils.py | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/materialx/__init__.py b/materialx/__init__.py index 4cf35f2ca..93a8d544a 100644 --- a/materialx/__init__.py +++ b/materialx/__init__.py @@ -29,6 +29,7 @@ from . import ( nodes, matlib, material, + utils, ) from . import logging @@ -53,6 +54,8 @@ def register(): def unregister(): log("unregister") + utils.clear_temp_dir() + matlib.unregister() material.unregister() nodes.unregister() diff --git a/materialx/utils.py b/materialx/utils.py index cdf63109a..6f6b39b23 100644 --- a/materialx/utils.py +++ b/materialx/utils.py @@ -335,6 +335,20 @@ def temp_dir(): return d +def clear_temp_dir(): + d = temp_dir() + paths = tuple(d.iterdir()) + if not paths: + return + + log("Clearing temp dir", d) + for path in paths: + if path.is_dir(): + shutil.rmtree(path, ignore_errors=True) + else: + os.remove(path) + + def get_temp_file(suffix, name=None, is_rand=False): if not name: return Path(tempfile.mktemp(suffix, "tmp", temp_dir())) -- 2.30.2 From c5b73128df64c9de36ead2ebe4d1e96d50bbb1e0 Mon Sep 17 00:00:00 2001 From: Georgiy Markelov <42409851+DagerD@users.noreply.github.com> Date: Wed, 26 Oct 2022 19:48:37 +0300 Subject: [PATCH 14/28] BLEN-245: Fix assign materials: blender shader, materiax (#12) --- materialx/material/properties.py | 2 +- materialx/utils.py | 32 ++++++++++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/materialx/material/properties.py b/materialx/material/properties.py index 68905da86..f16392040 100644 --- a/materialx/material/properties.py +++ b/materialx/material/properties.py @@ -84,7 +84,6 @@ class MaterialProperties(MaterialXProperties): return mtlx_file, doc - def convert_to_materialx(self, obj: bpy.types.Object = None): mat = self.id_data output_node = self.output_node @@ -109,6 +108,7 @@ class MaterialProperties(MaterialXProperties): mtlx_file = get_temp_file(".mtlx", f'{mat.name}_{self.mx_node_tree.name if self.mx_node_tree else ""}') + mx.writeToXmlFile(doc, str(mtlx_file)) search_path = mx.FileSearchPath(str(mtlx_file.parent)) search_path.append(str(MX_LIBS_DIR)) diff --git a/materialx/utils.py b/materialx/utils.py index 6f6b39b23..7c8a20ba9 100644 --- a/materialx/utils.py +++ b/materialx/utils.py @@ -14,7 +14,6 @@ from . import ADDON_ALIAS from . import logging log = logging.Log('utils') - ADDON_ROOT_DIR = Path(__file__).parent ADDON_DATA_DIR = Path(bpy.utils.user_resource('SCRIPTS', path=f"addons/{ADDON_ALIAS}_data", create=True)) BL_DATA_DIR = Path(bpy.utils.resource_path('LOCAL')) / "datafiles/materialx" @@ -378,7 +377,7 @@ def cache_image_file(image: bpy.types.Image, cache_check=True): image_suffix = image_path.suffix.lower() - if image_suffix in SUPPORTED_FORMATS and\ + if image_suffix in SUPPORTED_FORMATS and \ f".{image.file_format.lower()}" in SUPPORTED_FORMATS and not image.is_dirty: return image_path @@ -444,3 +443,32 @@ def update_ui(area_type='PROPERTIES', region_type='WINDOW'): for region in area.regions: if region.type == region_type: region.tag_redraw() + + +def update_materialx_data(depsgraph, materialx_data): + from .node_tree import MxNodeTree + + if not depsgraph.updates: + return + + for mx_node_tree in (upd.id for upd in depsgraph.updates if isinstance(upd.id, MxNodeTree)): + for material in bpy.data.materials: + if material.materialx.mx_node_tree and material.materialx.mx_node_tree.name == mx_node_tree.name: + doc = material.materialx.export(None) + if not doc: + # log.warn("MX export failed", mat) + continue + + matx_data = next((mat for mat in materialx_data if mat[0] == material.name), None) + + if not matx_data: + mx_file = get_temp_file(".mtlx", + f'{material.name}{material.materialx.mx_node_tree.name if material.materialx.mx_node_tree else ""}', + False) + + mx.writeToXmlFile(doc, str(mx_file)) + surfacematerial = next((node for node in doc.getNodes() + if node.getCategory() == 'surfacematerial')) + materialx_data.append((material.name, str(mx_file), surfacematerial.getName())) + else: + mx.writeToXmlFile(doc, str(matx_data[1])) -- 2.30.2 From e9826b3008cffead88b78982f62bf099f2a5e575 Mon Sep 17 00:00:00 2001 From: Georgiy Markelov <42409851+DagerD@users.noreply.github.com> Date: Thu, 1 Dec 2022 16:33:45 +0300 Subject: [PATCH 15/28] BLEN-264: Basic integration MaterialX nodes into Blender shader nodetree (#14) All MaterialX nodes moved to Blender shader node tree. MaterialX nodes and Blender nodes now work between each other. It is possible to have MaterialX surfacematerial node or Blender Material Output node for material (both works). Moved functions import, export, print to console to Blender shader node tree. Removed: online MatX library, unused code, MatX properties Moved materialx/ui.py -> ui.py. deleted folder "material". small improvements Co-authored-by: markyandex@gmail.com --- materialx/__init__.py | 11 +- materialx/bl_nodes/node_parser.py | 7 +- materialx/bl_nodes/output.py | 17 +- materialx/bl_nodes/shader.py | 4 + materialx/material/__init__.py | 41 -- materialx/material/properties.py | 130 ------ materialx/material/ui.py | 542 ----------------------- materialx/matlib/__init__.py | 34 -- materialx/matlib/manager.py | 433 ------------------ materialx/matlib/properties.py | 130 ------ materialx/matlib/ui.py | 189 -------- materialx/node_tree.py | 268 ----------- materialx/nodes/__init__.py | 12 +- materialx/nodes/categories.py | 4 +- materialx/nodes/generate_node_classes.py | 2 - materialx/nodes/node.py | 151 +++---- materialx/{nodes => }/ui.py | 108 ++--- materialx/utils.py | 266 +++++++++-- 18 files changed, 366 insertions(+), 1983 deletions(-) delete mode 100644 materialx/material/__init__.py delete mode 100644 materialx/material/properties.py delete mode 100644 materialx/material/ui.py delete mode 100644 materialx/matlib/__init__.py delete mode 100644 materialx/matlib/manager.py delete mode 100644 materialx/matlib/properties.py delete mode 100644 materialx/matlib/ui.py delete mode 100644 materialx/node_tree.py rename materialx/{nodes => }/ui.py (56%) diff --git a/materialx/__init__.py b/materialx/__init__.py index 93a8d544a..466690a2e 100644 --- a/materialx/__init__.py +++ b/materialx/__init__.py @@ -25,10 +25,8 @@ import bpy from . import ( preferences, - node_tree, nodes, - matlib, - material, + ui, utils, ) @@ -37,7 +35,6 @@ log = logging.Log("__init__") register_classes, unregister_classes = bpy.utils.register_classes_factory([ - node_tree.MxNodeTree, preferences.AddonPreferences, ]) @@ -47,8 +44,7 @@ def register(): register_classes() nodes.register() - material.register() - matlib.register() + ui.register() def unregister(): @@ -56,7 +52,6 @@ def unregister(): utils.clear_temp_dir() - matlib.unregister() - material.unregister() + ui.unregister() nodes.unregister() unregister_classes() diff --git a/materialx/bl_nodes/node_parser.py b/materialx/bl_nodes/node_parser.py index d6ecfbfd0..1f7513759 100644 --- a/materialx/bl_nodes/node_parser.py +++ b/materialx/bl_nodes/node_parser.py @@ -9,6 +9,7 @@ import MaterialX as mx from .. import utils from ..utils import pass_node_reroute from ..nodes import get_mx_node_cls +from ..nodes.node import MxNode from .. import logging log = logging.Log("bl_nodes.node_parser") @@ -354,7 +355,11 @@ class NodeParser: if not link: return None - return self._export_node(link.from_node, link.from_socket.identifier, link.to_socket) + if isinstance(link.from_node, MxNode): + mx_node = link.from_node.compute(link.from_socket.name, doc=self.doc) + return mx_node + + return self._export_node(link.from_node, link.from_socket.name, link.to_socket) def get_input_value(self, in_key): """ Returns linked node or default socket value """ diff --git a/materialx/bl_nodes/output.py b/materialx/bl_nodes/output.py index 2af4fb633..fc43a3daa 100644 --- a/materialx/bl_nodes/output.py +++ b/materialx/bl_nodes/output.py @@ -1,7 +1,8 @@ # SPDX-License-Identifier: GPL-2.0-or-later # Copyright 2022, AMD +import MaterialX as mx -from .node_parser import NodeParser, Id +from .node_parser import NodeParser, Id, log class ShaderNodeOutputMaterial(NodeParser): @@ -15,14 +16,12 @@ class ShaderNodeOutputMaterial(NodeParser): if surface is None: return None - if surface.type == 'BSDF': - surface = self.create_node('surface', 'surfaceshader', { - 'bsdf': surface, - }) - elif surface.type == 'EDF': - surface = self.create_node('surface', 'surfaceshader', { - 'edf': surface, - }) + linked_input_type = surface.getType() if isinstance(surface, mx.Node) else surface.type + + if linked_input_type != 'surfaceshader': + log.warn("Incorrect node tree to export: output node doesn't have correct input") + + return None result = self.create_node('surfacematerial', 'material', { 'surfaceshader': surface, diff --git a/materialx/bl_nodes/shader.py b/materialx/bl_nodes/shader.py index a780a6e5e..1214a2847 100644 --- a/materialx/bl_nodes/shader.py +++ b/materialx/bl_nodes/shader.py @@ -2,6 +2,7 @@ # Copyright 2022, AMD import math +import MaterialX as mx from .node_parser import NodeParser from . import log @@ -15,6 +16,9 @@ def enabled(val): if val is None: return False + if isinstance(val, mx.Node): + return True + if isinstance(val.data, float) and math.isclose(val.data, 0.0): return False diff --git a/materialx/material/__init__.py b/materialx/material/__init__.py deleted file mode 100644 index b9ee175ba..000000000 --- a/materialx/material/__init__.py +++ /dev/null @@ -1,41 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-or-later -# Copyright 2022, AMD - -import bpy - -from . import ( - ui, - properties -) - -register_classes, unregister_classes = bpy.utils.register_classes_factory([ - ui.MATERIAL_OP_new_mx_node_tree, - ui.MATERIAL_OP_duplicate_mx_node_tree, - ui.MATERIAL_OP_convert_to_materialx, - ui.MATERIAL_OP_duplicate_mat_mx_node_tree, - ui.MATERIAL_OP_link_mx_node_tree, - ui.MATERIAL_OP_unlink_mx_node_tree, - ui.MATERIAL_MT_mx_node_tree, - ui.MATERIAL_PT_materialx, - ui.MATERIAL_PT_materialx_surfaceshader, - ui.MATERIAL_PT_materialx_displacementshader, - ui.MATERIAL_OP_link_mx_node, - ui.MATERIAL_OP_invoke_popup_input_nodes, - ui.MATERIAL_OP_invoke_popup_shader_nodes, - ui.MATERIAL_OP_remove_node, - ui.MATERIAL_OP_disconnect_node, - ui.MATERIAL_OP_export_file, - ui.MATERIAL_OP_export_console, - ui.MATERIAL_PT_tools, - ui.MATERIAL_PT_dev, -]) - - -def register(): - properties.register() - register_classes() - - -def unregister(): - properties.unregister() - unregister_classes() diff --git a/materialx/material/properties.py b/materialx/material/properties.py deleted file mode 100644 index f16392040..000000000 --- a/materialx/material/properties.py +++ /dev/null @@ -1,130 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-or-later -# Copyright 2022, AMD - -import traceback - -import bpy -import MaterialX as mx - -from ..node_tree import MxNodeTree -from ..bl_nodes.output import ShaderNodeOutputMaterial -from ..utils import MX_LIBS_DIR, mx_properties, get_temp_file, MaterialXProperties, with_prefix - -from .. import logging -log = logging.Log('material.properties') - - -class MaterialProperties(MaterialXProperties): - bl_type = bpy.types.Material - - def update_mx_node_tree(self, context): - # trying to show MaterialX area with node tree or Shader area - - material = self.id_data - mx_node_tree = mx_properties(material).mx_node_tree - - if not mx_node_tree: - return - - screen = context.screen - if not hasattr(screen, 'areas'): - return - - for window in context.window_manager.windows: - for area in window.screen.areas: - if area.ui_type not in (MxNodeTree.bl_idname, 'ShaderNodeTree'): - continue - - space = next(s for s in area.spaces if s.type == 'NODE_EDITOR') - if space.pin or space.shader_type != 'OBJECT': - continue - - area.ui_type = MxNodeTree.bl_idname - space.node_tree = mx_node_tree - - mx_node_tree: bpy.props.PointerProperty(type=MxNodeTree, update=update_mx_node_tree) - - @property - def output_node(self): - material = self.id_data - - if not material.node_tree: - return None - - return next((node for node in material.node_tree.nodes if - node.bl_idname == ShaderNodeOutputMaterial.__name__ and - node.is_active_output), None) - - def export(self, obj: bpy.types.Object, check_mx_node_tree=True) -> [mx.Document, None]: - if check_mx_node_tree and self.mx_node_tree: - return self.mx_node_tree.export() - - material = self.id_data - output_node = self.output_node - - if not output_node: - return None - - doc = mx.createDocument() - - node_parser = ShaderNodeOutputMaterial(doc, material, output_node, obj) - if not node_parser.export(): - return None - - return doc - - def get_materialx_data(self, obj: bpy.types.Object): - doc = self.export(obj) - if not doc: - return None, None - - mat = self.id_data - mtlx_file = get_temp_file(".mtlx", f'{mat.name}_{self.mx_node_tree.name if self.mx_node_tree else ""}') - mx.writeToXmlFile(doc, str(mtlx_file)) - - return mtlx_file, doc - - def convert_to_materialx(self, obj: bpy.types.Object = None): - mat = self.id_data - output_node = self.output_node - if not output_node: - log.warn("Incorrect node tree to export: output node doesn't exist") - return False - - mx_node_tree = bpy.data.node_groups.new(f"MX_{mat.name}", type=MxNodeTree.bl_idname) - - if obj: - doc = self.export(obj) - else: - doc = mx.createDocument() - - node_parser = ShaderNodeOutputMaterial(doc, mat, output_node, obj) - if not node_parser.export(): - return False - - if not doc: - log.warn("Incorrect node tree to export", mx_node_tree) - return False - - mtlx_file = get_temp_file(".mtlx", - f'{mat.name}_{self.mx_node_tree.name if self.mx_node_tree else ""}') - - mx.writeToXmlFile(doc, str(mtlx_file)) - search_path = mx.FileSearchPath(str(mtlx_file.parent)) - search_path.append(str(MX_LIBS_DIR)) - - try: - mx.readFromXmlFile(doc, str(mtlx_file), searchPath=search_path) - mx_node_tree.import_(doc, mtlx_file) - self.mx_node_tree = mx_node_tree - - except Exception as e: - log.error(traceback.format_exc(), mtlx_file) - return False - - return True - - -register, unregister = bpy.utils.register_classes_factory(( - MaterialProperties, -)) diff --git a/materialx/material/ui.py b/materialx/material/ui.py deleted file mode 100644 index 4ef344c97..000000000 --- a/materialx/material/ui.py +++ /dev/null @@ -1,542 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-or-later -# Copyright 2022, AMD - -from pathlib import Path - -import MaterialX as mx - -import bpy -from bpy_extras.io_utils import ExportHelper - -from ..node_tree import MxNodeTree, NODE_LAYER_SEPARATION_WIDTH -from ..nodes.node import is_mx_node_valid -from .. import utils -from ..utils import pass_node_reroute, title_str, mx_properties -from ..preferences import addon_preferences - -from ..utils import logging -log = logging.Log(tag='material.ui') - - -class MATERIAL_OP_new_mx_node_tree(bpy.types.Operator): - """Create new MaterialX node tree for selected material""" - bl_idname = utils.with_prefix('material_new_mx_node_tree') - bl_label = "New" - - def execute(self, context): - mat = context.material - mx_node_tree = bpy.data.node_groups.new(f"MX_{mat.name}", type=MxNodeTree.bl_idname) - mx_node_tree.create_basic_nodes() - - mx_properties(mat).mx_node_tree = mx_node_tree - return {"FINISHED"} - - -class MATERIAL_OP_duplicate_mat_mx_node_tree(bpy.types.Operator): - """Create duplicates of Material and MaterialX node tree for selected material""" - bl_idname = utils.with_prefix('material_duplicate_mat_mx_node_tree') - bl_label = "" - - def execute(self, context): - bpy.ops.material.new() - bpy.ops.materialx.material_duplicate_mx_node_tree() - return {"FINISHED"} - - -class MATERIAL_OP_duplicate_mx_node_tree(bpy.types.Operator): - """Create duplicate of MaterialX node tree for selected material""" - bl_idname = utils.with_prefix('material_duplicate_mx_node_tree') - bl_label = "" - - def execute(self, context): - mat = context.object.active_material - mx_node_tree = mx_properties(mat).mx_node_tree - - if mx_node_tree: - mx_properties(mat).mx_node_tree = mx_node_tree.copy() - - return {"FINISHED"} - - -class MATERIAL_OP_convert_to_materialx(bpy.types.Operator): - """Converts standard shader node tree to MaterialX node tree for selected material""" - bl_idname = utils.with_prefix('material_convert_to_materialx') - bl_label = "Convert to MaterialX" - - def execute(self, context): - if not mx_properties(context.material).convert_to_materialx(context.object): - return {'CANCELLED'} - - return {"FINISHED"} - - -class MATERIAL_OP_link_mx_node_tree(bpy.types.Operator): - """Link MaterialX node tree to selected material""" - bl_idname = utils.with_prefix('material_link_mx_node_tree') - bl_label = "" - - mx_node_tree_name: bpy.props.StringProperty(default="") - - def execute(self, context): - mx_properties(context.material).mx_node_tree = bpy.data.node_groups[self.mx_node_tree_name] - return {"FINISHED"} - - -class MATERIAL_OP_unlink_mx_node_tree(bpy.types.Operator): - """Unlink MaterialX node tree from selected material""" - bl_idname = utils.with_prefix('material_unlink_mx_node_tree') - bl_label = "" - - def execute(self, context): - mx_properties(context.material).mx_node_tree = None - return {"FINISHED"} - - -class MATERIAL_MT_mx_node_tree(bpy.types.Menu): - bl_idname = utils.with_prefix('MATERIAL_MT_mx_node_tree', '_', True) - bl_label = "MX Nodetree" - - def draw(self, context): - layout = self.layout - node_groups = bpy.data.node_groups - - for ng in node_groups: - if ng.bl_idname != utils.with_prefix('MxNodeTree'): - continue - - row = layout.row() - row.enabled = bool(ng.output_node) - op = row.operator(MATERIAL_OP_link_mx_node_tree.bl_idname, - text=ng.name, icon='MATERIAL') - op.mx_node_tree_name = ng.name - - -class MATERIAL_PT_materialx(bpy.types.Panel): - bl_idname = utils.with_prefix("MATERIAL_PT_materialx", '_', True) - bl_label = "MaterialX" - bl_space_type = 'PROPERTIES' - bl_region_type = 'WINDOW' - bl_context = "material" - - @classmethod - def poll(cls, context): - return context.material - - def draw(self, context): - mat_materialx = mx_properties(context.material) - layout = self.layout - - row = layout.row(align=True) - row.menu(MATERIAL_MT_mx_node_tree.bl_idname, text="", icon='MATERIAL') - - if mat_materialx.mx_node_tree: - row.prop(mat_materialx.mx_node_tree, 'name', text="") - row.operator(MATERIAL_OP_convert_to_materialx.bl_idname, icon='FILE_TICK', text="") - row.operator(MATERIAL_OP_duplicate_mx_node_tree.bl_idname, icon='DUPLICATE') - row.operator(MATERIAL_OP_unlink_mx_node_tree.bl_idname, icon='X') - - else: - row.operator(MATERIAL_OP_convert_to_materialx.bl_idname, icon='FILE_TICK', text="Convert") - row.operator(MATERIAL_OP_new_mx_node_tree.bl_idname, icon='ADD', text="") - - -class MATERIAL_OP_link_mx_node(bpy.types.Operator): - """Link MaterialX node""" - bl_idname = utils.with_prefix('material_link_mx_node') - bl_label = "" - - new_node_name: bpy.props.StringProperty() - input_num: bpy.props.IntProperty() - current_node_name: bpy.props.StringProperty() - - def execute(self, context): - layout = self.layout - - node_tree = mx_properties(context.material).mx_node_tree - current_node = mx_properties(context.material).mx_node_tree.nodes[self.current_node_name] - - input = current_node.inputs[self.input_num] - link = next((link for link in input.links), None) if input.is_linked else None - linked_node_name = link.from_node.bl_idname if link else None - - if linked_node_name: - if linked_node_name != self.new_node_name: - bpy.ops.materialx.material_remove_node(input_node_name=link.from_node.name) - else: - return {"FINISHED"} - - new_node = node_tree.nodes.new(self.new_node_name) - new_node.location = (current_node.location[0] - NODE_LAYER_SEPARATION_WIDTH, - current_node.location[1]) - node_tree.links.new(new_node.outputs[0], current_node.inputs[self.input_num]) - - return {"FINISHED"} - - -class MATERIAL_OP_invoke_popup_input_nodes(bpy.types.Operator): - """Open panel with nodes to link""" - bl_idname = utils.with_prefix('material_invoke_popup_input_nodes') - bl_label = "" - - input_num: bpy.props.IntProperty() - current_node_name: bpy.props.StringProperty() - - def execute(self, context): - return {'FINISHED'} - - def invoke(self, context, event): - return context.window_manager.invoke_popup(self, width=600) - - def draw(self, context): - from ..nodes import mx_node_classes - - MAX_COLUMN_ITEMS = 34 - - split = self.layout.split() - cat = "" - i = 0 - col = None - for cls in mx_node_classes: - if cls.category in ("PBR", "material"): - continue - - if not col or i >= MAX_COLUMN_ITEMS: - i = 0 - col = split.column() - col.emboss = 'PULLDOWN_MENU' - - if cat != cls.category: - cat = cls.category - col.label(text=title_str(cat), icon='NODE') - i += 1 - - row = col.row() - row.alignment = 'LEFT' - op = row.operator(MATERIAL_OP_link_mx_node.bl_idname, text=cls.bl_label) - op.new_node_name = cls.bl_idname - op.input_num = self.input_num - op.current_node_name = self.current_node_name - i += 1 - - input = mx_properties(context.material).mx_node_tree.nodes[self.current_node_name].inputs[self.input_num] - if input.is_linked: - link = input.links[0] - - col = split.column() - col.emboss = 'PULLDOWN_MENU' - col.label(text="Link") - - row = col.row() - row.alignment = 'LEFT' - op = row.operator(MATERIAL_OP_remove_node.bl_idname) - op.input_node_name = link.from_node.name - - row = col.row() - row.alignment = 'LEFT' - op = row.operator(MATERIAL_OP_disconnect_node.bl_idname) - op.output_node_name = link.to_node.name - op.input_num = self.input_num - - -class MATERIAL_OP_invoke_popup_shader_nodes(bpy.types.Operator): - """Open panel with shader nodes to link""" - bl_idname = utils.with_prefix('material_invoke_popup_shader_nodes') - bl_label = "" - - input_num: bpy.props.IntProperty() - new_node_name: bpy.props.StringProperty() - - def execute(self, context): - return {'FINISHED'} - - def invoke(self, context, event): - return context.window_manager.invoke_popup(self, width=300) - - def draw(self, context): - from ..nodes import mx_node_classes - - split = self.layout.split() - col = split.column() - col.emboss = 'PULLDOWN_MENU' - col.label(text="PBR", icon='NODE') - - output_node = mx_properties(context.material).mx_node_tree.output_node - for cls in mx_node_classes: - if cls.category != "PBR": - continue - - row = col.row() - row.alignment = 'LEFT' - op = row.operator(MATERIAL_OP_link_mx_node.bl_idname, text=cls.bl_label) - op.new_node_name = cls.bl_idname - op.input_num = self.input_num - op.current_node_name = output_node.name - - input = output_node.inputs[self.input_num] - if input.is_linked: - link = input.links[0] - - col = split.column() - col.emboss = 'PULLDOWN_MENU' - col.label(text="Link") - - row = col.row() - row.alignment = 'LEFT' - op = row.operator(MATERIAL_OP_remove_node.bl_idname) - op.input_node_name = link.from_node.name - - row = col.row() - row.alignment = 'LEFT' - op = row.operator(MATERIAL_OP_disconnect_node.bl_idname) - op.output_node_name = link.to_node.name - op.input_num = self.input_num - - -class MATERIAL_OP_remove_node(bpy.types.Operator): - """Remove linked node""" - bl_idname = utils.with_prefix('material_remove_node') - bl_label = "Remove" - - input_node_name: bpy.props.StringProperty() - - def remove_nodes(self, context, node): - for input in node.inputs: - if input.is_linked: - for link in input.links: - self.remove_nodes(context, link.from_node) - - mx_properties(context.material).mx_node_tree.nodes.remove(node) - - def execute(self, context): - node_tree = mx_properties(context.material).mx_node_tree - input_node = node_tree.nodes[self.input_node_name] - - self.remove_nodes(context, input_node) - - return {'FINISHED'} - - -class MATERIAL_OP_disconnect_node(bpy.types.Operator): - """Disconnect linked node""" - bl_idname = utils.with_prefix('material_disconnect_node') - bl_label = "Disconnect" - - output_node_name: bpy.props.StringProperty() - input_num: bpy.props.IntProperty() - - def execute(self, context): - node_tree = mx_properties(context.material).mx_node_tree - output_node = node_tree.nodes[self.output_node_name] - - links = output_node.inputs[self.input_num].links - link = next((link for link in links), None) - if link: - node_tree.links.remove(link) - - return {'FINISHED'} - - -class MATERIAL_PT_materialx_output(bpy.types.Panel): - bl_label = "" - bl_parent_id = MATERIAL_PT_materialx.bl_idname - bl_space_type = 'PROPERTIES' - bl_region_type = 'WINDOW' - - out_key = "" - - @classmethod - def poll(cls, context): - return bool(mx_properties(context.material).mx_node_tree) - - def draw(self, context): - layout = self.layout - - node_tree = mx_properties(context.material).mx_node_tree - output_node = node_tree.output_node - if not output_node: - layout.label(text="No output node") - return - - input = output_node.inputs[self.out_key] - link = next((link for link in input.links if link.is_valid), None) - - split = layout.split(factor=0.4) - row = split.row(align=True) - row.alignment = 'RIGHT' - row.label(text='Surface') - - row = split.row(align=True) - box = row.box() - box.scale_x = 0.7 - box.scale_y = 0.5 - op = box.operator(MATERIAL_OP_invoke_popup_shader_nodes.bl_idname, icon='HANDLETYPE_AUTO_CLAMP_VEC') - op.input_num = output_node.inputs.find(self.out_key) - - if link and is_mx_node_valid(link.from_node): - row.prop(link.from_node, 'name', text="") - else: - box = row.box() - box.scale_y = 0.5 - box.label(text='None') - - row.label(icon='BLANK1') - - if not link: - return - - if not is_mx_node_valid(link.from_node): - layout.label(text="Unsupported node") - return - - link = pass_node_reroute(link) - if not link: - return - - layout.separator() - link.from_node.draw_node_view(context, layout) - - -class MATERIAL_PT_materialx_surfaceshader(MATERIAL_PT_materialx_output): - bl_idname = utils.with_prefix('MATERIAL_PT_materialx_surfaceshader', '_', True) - bl_label = "Surface Shader" - - out_key = 'surfaceshader' - - -class MATERIAL_PT_materialx_displacementshader(MATERIAL_PT_materialx_output): - bl_idname = utils.with_prefix('MATERIAL_PT_materialx_displacementshader', '_', True) - bl_label = "Displacement Shader" - bl_options = {'DEFAULT_CLOSED'} - - out_key = 'displacementshader' - - -class MATERIAL_OP_export_file(bpy.types.Operator, ExportHelper): - bl_idname = utils.with_prefix('material_export_file') - bl_label = "Export to File" - bl_description = "Export material as MaterialX node tree to .mtlx file" - - # region properties - filename_ext = ".mtlx" - - filepath: bpy.props.StringProperty( - name="File Path", - description="File path used for exporting material as MaterialX node tree to .mtlx file", - maxlen=1024, - subtype="FILE_PATH" - ) - filter_glob: bpy.props.StringProperty( - default="*.mtlx", - options={'HIDDEN'}, - ) - is_export_deps: bpy.props.BoolProperty( - name="Include dependencies", - description="Export used MaterialX dependencies", - default=False - ) - is_export_textures: bpy.props.BoolProperty( - name="Export textures", - description="Export bound textures to corresponded folder", - default=True - ) - is_clean_texture_folder: bpy.props.BoolProperty( - name="Сlean texture folder", - description="Сlean texture folder before export", - default=False - ) - texture_dir_name: bpy.props.StringProperty( - name="Folder name", - description="Texture folder name used for exporting files", - default='textures', - maxlen=1024, - ) - # endregion - - def execute(self, context): - materialx_prop = mx_properties(context.material) - - doc = materialx_prop.export(None, False) - if not doc: - return {'CANCELLED'} - - utils.export_mx_to_file(doc, self.filepath, - mx_node_tree=None, - # is_export_deps=self.is_export_deps, - is_export_textures=self.is_export_textures, - texture_dir_name=self.texture_dir_name) - - return {'FINISHED'} - - def draw(self, context): - # self.layout.prop(self, 'is_export_deps') - - col = self.layout.column(align=False) - col.prop(self, 'is_export_textures') - - row = col.row() - row.enabled = self.is_export_textures - row.prop(self, 'texture_dir_name', text='') - - -class MATERIAL_OP_export_console(bpy.types.Operator): - bl_idname = utils.with_prefix('material_export_console') - bl_label = "Export to Console" - bl_description = "Export material as MaterialX node tree to console" - - def execute(self, context): - doc = mx_properties(context.material).export(context.object, False) - if not doc: - return {'CANCELLED'} - - print(mx.writeToXmlString(doc)) - return {'FINISHED'} - - -class MATERIAL_PT_tools(bpy.types.Panel): - bl_idname = utils.with_prefix('MATERIAL_PT_tools', '_', True) - bl_label = "MaterialX Tools" - bl_space_type = "NODE_EDITOR" - bl_region_type = "UI" - bl_category = "Tool" - - @classmethod - def poll(cls, context): - tree = context.space_data.edit_tree - - return tree and tree.bl_idname == bpy.types.ShaderNodeTree.__name__ - - def draw(self, context): - mat_materialx = mx_properties(context.material) - layout = self.layout - - row = layout.row(align=True) - row.menu(MATERIAL_MT_mx_node_tree.bl_idname, text="", icon='MATERIAL') - - if mat_materialx.mx_node_tree: - row.prop(mat_materialx.mx_node_tree, 'name', text="") - row.operator(MATERIAL_OP_convert_to_materialx.bl_idname, icon='FILE_TICK', text="") - row.operator(MATERIAL_OP_duplicate_mx_node_tree.bl_idname, icon='DUPLICATE') - row.operator(MATERIAL_OP_unlink_mx_node_tree.bl_idname, icon='X') - - else: - row.operator(MATERIAL_OP_convert_to_materialx.bl_idname, icon='FILE_TICK', text="Convert") - row.operator(MATERIAL_OP_new_mx_node_tree.bl_idname, icon='ADD', text="") - - layout.operator(MATERIAL_OP_export_file.bl_idname, icon='EXPORT') - - -class MATERIAL_PT_dev(bpy.types.Panel): - bl_idname = utils.with_prefix('MATERIAL_PT_dev', '_', True) - bl_label = "Dev" - bl_parent_id = MATERIAL_PT_tools.bl_idname - bl_space_type = "NODE_EDITOR" - bl_region_type = "UI" - - @classmethod - def poll(cls, context): - preferences = addon_preferences() - return preferences.dev_tools if preferences else True - - def draw(self, context): - layout = self.layout - layout.operator(MATERIAL_OP_export_console.bl_idname) diff --git a/materialx/matlib/__init__.py b/materialx/matlib/__init__.py deleted file mode 100644 index 21f8d16b9..000000000 --- a/materialx/matlib/__init__.py +++ /dev/null @@ -1,34 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-or-later -# Copyright 2022, AMD - -import bpy - -from . import ui, properties - - -register_properties, unregister_properties = bpy.utils.register_classes_factory( - [ - properties.MatlibProperties, - properties.WindowManagerProperties, - ] -) -register_ui, unregister_ui = bpy.utils.register_classes_factory( - [ - ui.MATLIB_PT_matlib, - ui.MATLIB_PT_matlib_tools, - ui.MATLIB_OP_load_materials, - ui.MATLIB_OP_load_package, - ui.MATLIB_OP_import_material, - ui.MATERIAL_OP_matlib_clear_search, - ] -) - - -def register(): - register_properties() - register_ui() - - -def unregister(): - unregister_ui() - unregister_properties() diff --git a/materialx/matlib/manager.py b/materialx/matlib/manager.py deleted file mode 100644 index 761f46d6d..000000000 --- a/materialx/matlib/manager.py +++ /dev/null @@ -1,433 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-or-later -# Copyright 2022, AMD - -import requests -import weakref -from dataclasses import dataclass, field -import shutil -from pathlib import Path -import zipfile -import json -import threading -from concurrent import futures - -import bpy.utils.previews - -from ..utils import logging, update_ui, MATLIB_DIR, MATLIB_URL -log = logging.Log('matlib.manager') - - -def download_file(url, path, cache_check=True): - if cache_check and path.is_file(): - return path - - log("download_file", f"{url=}, {path=}") - - path.parent.mkdir(parents=True, exist_ok=True) - with requests.get(url, stream=True) as response: - with open(path, 'wb') as f: - shutil.copyfileobj(response.raw, f) - - log("download_file", "done") - return path - - -def download_file_callback(url, path, update_callback, cache_check=True): - if cache_check and path.is_file(): - return None - - log("download_file_callback", f"{url=}, {path=}") - - path.parent.mkdir(parents=True, exist_ok=True) - path_raw = path.with_suffix(".raw") - - size = 0 - with requests.get(url, stream=True) as response: - with open(path_raw, 'wb') as f: - if update_callback: - for chunk in response.iter_content(chunk_size=8192): - size += len(chunk) - update_callback(size) - f.write(chunk) - - path_raw.rename(path) - log("download_file_callback", "done") - return path - - -def request_json(url, params, path, cache_check=True): - if cache_check and path and path.is_file(): - with open(path) as json_file: - return json.load(json_file) - - log("request_json", f"{url=}, {params=}, {path=}") - - response = requests.get(url, params=params) - res_json = response.json() - - if path: - save_json(res_json, path) - - log("request_json", "done") - return res_json - - -def save_json(json_obj, path): - path.parent.mkdir(parents=True, exist_ok=True) - with open(path, 'w') as outfile: - json.dump(json_obj, outfile) - - -@dataclass(init=False) -class Render: - id: str - author: str = field(init=False, default=None) - image: str = field(init=False, default=None) - image_url: str = field(init=False, default=None) - image_path: Path = field(init=False, default=None) - thumbnail: str = field(init=False, default=None) - thumbnail_url: str = field(init=False, default=None) - thumbnail_path: Path = field(init=False, default=None) - thumbnail_icon_id: int = field(init=False, default=None) - - def __init__(self, id, material): - self.id = id - self.material = weakref.ref(material) - - @property - def cache_dir(self): - return self.material().cache_dir - - def get_info(self, cache_chek=True): - json_data = request_json(f"{MATLIB_URL}/renders/{self.id}", None, - self.cache_dir / f"R-{self.id[:8]}.json", cache_chek) - - self.author = json_data['author'] - self.image = json_data['image'] - self.image_url = json_data['image_url'] - self.thumbnail = json_data['thumbnail'] - self.thumbnail_url = json_data['thumbnail_url'] - - def get_image(self, cache_check=True): - self.image_path = download_file(self.image_url, - self.cache_dir / self.image, cache_check) - - def get_thumbnail(self, cache_check=True): - self.thumbnail_path = download_file(self.thumbnail_url, - self.cache_dir / self.thumbnail, cache_check) - - def thumbnail_load(self, pcoll): - thumb = pcoll.get(self.thumbnail) - if not thumb: - thumb = pcoll.load(self.thumbnail, str(self.thumbnail_path), 'IMAGE') - self.thumbnail_icon_id = thumb.icon_id - - -@dataclass(init=False) -class Package: - id: str - author: str = field(init=False, default=None) - label: str = field(init=False, default=None) - file: str = field(init=False, default=None) - file_url: str = field(init=False, default=None) - size_str: str = field(init=False, default=None) - - def __init__(self, id, material): - self.id = id - self.material = weakref.ref(material) - self.size_load = None - - @property - def cache_dir(self): - return self.material().cache_dir / f"P-{self.id[:8]}" - - @property - def file_path(self): - return self.cache_dir / self.file - - @property - def has_file(self): - return self.file_path.is_file() - - def get_info(self, cache_check=True): - json_data = request_json(f"{MATLIB_URL}/packages/{self.id}", None, - self.cache_dir / "info.json", cache_check) - - self.author = json_data['author'] - self.file = json_data['file'] - self.file_url = json_data['file_url'] - self.label = json_data['label'] - self.size_str = json_data['size'] - - def download(self, cache_check=True): - def callback(size): - self.size_load = size - update_ui() - - download_file_callback(self.file_url, self.file_path, callback, cache_check) - - def unzip(self, path=None, cache_check=True): - if not path: - path = self.cache_dir / "package" - - if path.is_dir() and not cache_check: - shutil.rmtree(path, ignore_errors=True) - - if not path.is_dir(): - with zipfile.ZipFile(self.file_path) as z: - z.extractall(path=path) - - mtlx_file = next(path.glob("**/*.mtlx")) - return mtlx_file - - @property - def size(self): - n, b = self.size_str.split(" ") - size = float(n) - if b == "MB": - size *= 1048576 # 2 ** 20 - elif b == "KB": - size *= 1024 # 2 ** 10 - elif b == "GB": - size *= 2 ** 30 - - return int(size) - - def __lt__(self, other): - return self.size < other.size - - -@dataclass -class Category: - id: str - title: str = field(init=False, default=None) - - @property - def cache_dir(self): - return MATLIB_DIR - - def get_info(self, use_cache=True): - if not self.id: - return - - json_data = request_json(f"{MATLIB_URL}/categories/{self.id}", None, - self.cache_dir / f"C-{self.id[:8]}.json", use_cache) - - self.title = json_data['title'] - - def __lt__(self, other): - return self.title < other.title - - -@dataclass(init=False) -class Material: - id: str - author: str - title: str - description: str - category: Category - status: str - renders: list[Render] - packages: list[Package] - - def __init__(self, mat_json): - self.id = mat_json['id'] - self.author = mat_json['author'] - self.title = mat_json['title'] - self.description = mat_json['description'] - self.category = Category(mat_json['category']) - self.status = mat_json['status'] - - self.renders = [] - for id in mat_json['renders_order']: - self.renders.append(Render(id, self)) - - self.packages = [] - for id in mat_json['packages']: - self.packages.append(Package(id, self)) - - save_json(mat_json, self.cache_dir / "info.json") - - def __lt__(self, other): - return self.title.lower() < other.title.lower() - - @property - def cache_dir(self): - return MATLIB_DIR / f"M-{self.id[:8]}" - - @classmethod - def get_materials(cls): - offset = 0 - limit = 500 - - while True: - res_json = request_json(f"{MATLIB_URL}/materials", {'limit': limit, 'offset': offset}, None) - - count = res_json['count'] - - for mat_json in res_json['results']: - mat = Material(mat_json) - if not mat.packages or not mat.category.id: - continue - - yield mat - - offset += limit - if offset >= count: - break - - @classmethod - def get_materials_cache(cls): - for f in MATLIB_DIR.glob("M-*/info.json"): - with open(f) as json_file: - mat_json = json.load(json_file) - - yield Material(mat_json) - - -class Manager: - def __init__(self): - self.materials = None - self.categories = None - self.pcoll = None - self.load_thread = None - self.package_executor = None - self.status = "" - self.is_synced = None - - def __del__(self): - # bpy.utils.previews.remove(self.pcoll) - pass - - def set_status(self, msg): - self.status = msg - update_ui() - - @property - def materials_list(self): - # required for thread safe purposes - return list(manager.materials.values()) - - @property - def categories_list(self): - # required for thread safe purposes - return list(manager.categories.values()) - - def check_load_materials(self, reset=False): - # required is not None condition to prevent further update if no material is found at first time. - if self.materials is not None and not reset: - return True - - if reset and self.pcoll: - bpy.utils.previews.remove(self.pcoll) - - self.materials = {} - self.categories = {} - self.pcoll = bpy.utils.previews.new() - - def category_load(cat): - cat.get_info() - self.categories[cat.id] = cat - - def material_load(mat, is_cached): - for render in mat.renders: - render.get_info() - render.get_thumbnail() - render.thumbnail_load(self.pcoll) - - for package in mat.packages: - package.get_info() - - self.materials[mat.id] = mat - - self.set_status(f"Syncing {len(self.materials)} {'cached' if is_cached else 'online'} materials...") - - def load(): - self.is_synced = False - self.set_status("Start syncing...") - with futures.ThreadPoolExecutor() as executor: - try: - # - # getting cached materials - # - materials = {mat.id: mat for mat in Material.get_materials_cache()} - categories = {mat.category.id: mat.category for mat in materials.values()} - - # loading categories - category_loaders = [executor.submit(category_load, cat) - for cat in categories.values()] - for future in futures.as_completed(category_loaders): - future.result() - - # updating category for cached materials - for mat in materials.values(): - mat.category.get_info() - - # loading cached materials - material_loaders = [executor.submit(material_load, mat, True) - for mat in materials.values()] - for future in futures.as_completed(material_loaders): - future.result() - - # - # getting and syncing with online materials - # - online_materials = {mat.id: mat for mat in Material.get_materials()} - - # loading new categories - new_categories = {} - for mat in online_materials.values(): - cat = mat.category - if cat.id not in categories and cat.id not in new_categories: - new_categories[cat.id] = cat - - category_loaders = [executor.submit(category_load, cat) - for cat in new_categories.values()] - for future in futures.as_completed(category_loaders): - future.result() - - # updating categories for online materials - for mat in online_materials.values(): - mat.category.get_info() - - # loading online materials - material_loaders = [executor.submit(material_load, mat, False) - for mat in online_materials.values()] - for future in futures.as_completed(material_loaders): - future.result() - - self.set_status(f"Syncing {len(self.materials)} materials completed") - - except requests.exceptions.RequestException as err: - executor.shutdown(wait=True, cancel_futures=True) - self.set_status(f"Connection error. Synced {len(self.materials)} materials") - log.error(err) - - finally: - self.is_synced = True - - self.load_thread = threading.Thread(target=load, daemon=True) - self.load_thread.start() - - return False - - def load_package(self, package): - package.size_load = 0 - - def package_load(): - try: - package.download() - - except requests.exceptions.RequestException as err: - log.error(err) - package.size_load = None - - update_ui() - - if not self.package_executor: - self.package_executor = futures.ThreadPoolExecutor() - - self.package_executor.submit(package_load) - - -manager = Manager() diff --git a/materialx/matlib/properties.py b/materialx/matlib/properties.py deleted file mode 100644 index 2fe57d604..000000000 --- a/materialx/matlib/properties.py +++ /dev/null @@ -1,130 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-or-later -# Copyright 2022, AMD - -import bpy - -from ..matlib.manager import manager -from ..utils import MaterialXProperties - - -class MatlibProperties(bpy.types.PropertyGroup): - def get_materials(self) -> dict: - materials = {} - search_str = self.search.strip().lower() - - materials_list = manager.materials_list - for mat in materials_list: - if search_str not in mat.title.lower(): - continue - - if not (mat.category.id == self.category_id or self.category_id == 'ALL'): - continue - - materials[mat.id] = mat - - return materials - - def get_materials_prop(self, context): - materials = [] - for i, mat in enumerate(sorted(self.get_materials().values())): - description = mat.title - if mat.description: - description += f"\n{mat.description}" - description += f"\nCategory: {mat.category.title}\nAuthor: {mat.author}" - - icon_id = mat.renders[0].thumbnail_icon_id if mat.renders else 'MATERIAL' - materials.append((mat.id, mat.title, description, icon_id, i)) - - return materials - - def get_categories_prop(self, context): - categories = [] - if manager.categories is None: - return categories - - categories += [('ALL', "All Categories", "Show materials for all categories")] - - categories_list = manager.categories_list - categories += ((cat.id, cat.title, f"Show materials with category {cat.title}") - for cat in sorted(categories_list)) - return categories - - def get_packages_prop(self, context): - packages = [] - mat = self.material - if not mat: - return packages - - for i, p in enumerate(sorted(mat.packages)): - description = f"Package: {p.label} ({p.size_str})\nAuthor: {p.author}" - if p.has_file: - description += "\nReady to import" - icon_id = 'RADIOBUT_ON' if p.has_file else 'RADIOBUT_OFF' - - packages.append((p.id, f"{p.label} ({p.size_str})", description, icon_id, i)) - - return packages - - def update_material(self, context): - mat = self.material - if mat: - self.package_id = min(mat.packages).id - - def update_category(self, context): - materials = self.get_materials() - if not materials: - return - - mat = min(materials.values()) - self.material_id = mat.id - self.package_id = min(mat.packages).id - - def update_search(self, context): - materials = self.get_materials() - if not materials or self.material_id in materials: - return - - mat = min(materials.values()) - self.material_id = mat.id - self.package_id = min(mat.packages).id - - material_id: bpy.props.EnumProperty( - name="Material", - description="Select material", - items=get_materials_prop, - update=update_material, - ) - category_id: bpy.props.EnumProperty( - name="Category", - description="Select materials category", - items=get_categories_prop, - update=update_category, - ) - search: bpy.props.StringProperty( - name="Search", - description="Search materials by title", - update=update_search, - ) - package_id: bpy.props.EnumProperty( - name="Package", - description="Selected material package", - items=get_packages_prop, - ) - - @property - def material(self): - return manager.materials.get(self.material_id) - - @property - def package(self): - mat = self.material - if not mat: - return None - - return next((p for p in mat.packages if p.id == self.package_id), None) - - -class WindowManagerProperties(MaterialXProperties): - bl_type = bpy.types.WindowManager - - matlib: bpy.props.PointerProperty(type=MatlibProperties) diff --git a/materialx/matlib/ui.py b/materialx/matlib/ui.py deleted file mode 100644 index 4cbac19ec..000000000 --- a/materialx/matlib/ui.py +++ /dev/null @@ -1,189 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-or-later -# Copyright 2022, AMD - -import traceback -import textwrap - -import MaterialX as mx - -import bpy - -from .. import utils -from ..node_tree import MxNodeTree -from .manager import manager - -from ..utils import logging -log = logging.Log('matlib.ui') - - -class MATERIAL_OP_matlib_clear_search(bpy.types.Operator): - """Create new MaterialX node tree for selected material""" - bl_idname = utils.with_prefix("matlib_clear_search") - bl_label = "" - - def execute(self, context): - utils.mx_properties(context.window_manager).matlib.search = '' - return {"FINISHED"} - - -class MATLIB_OP_load_materials(bpy.types.Operator): - """Load materials""" - bl_idname = utils.with_prefix("matlib_load") - bl_label = "Reload Library" - - def execute(self, context): - manager.check_load_materials(reset=True) - return {"FINISHED"} - - -class MATLIB_OP_import_material(bpy.types.Operator): - """Import Material Package to material""" - bl_idname = utils.with_prefix("matlib_import_material") - bl_label = "Import Material Package" - - def execute(self, context): - matlib_prop = utils.mx_properties(context.window_manager).matlib - package = matlib_prop.package - - mtlx_file = package.unzip() - - # getting/creating MxNodeTree - bl_material = context.material - mx_node_tree = utils.mx_properties(bl_material).mx_node_tree - if not mx_node_tree: - mx_node_tree = bpy.data.node_groups.new(f"MX_{bl_material.name}", - type=MxNodeTree.bl_idname) - utils.mx_properties(bl_material).mx_node_tree = mx_node_tree - - log(f"Reading: {mtlx_file}") - doc = mx.createDocument() - search_path = mx.FileSearchPath(str(mtlx_file.parent)) - search_path.append(str(utils.MX_LIBS_DIR)) - try: - mx.readFromXmlFile(doc, str(mtlx_file), searchPath=search_path) - mx_node_tree.import_(doc, mtlx_file) - - except Exception as e: - log.error(traceback.format_exc(), mtlx_file) - return {'CANCELLED'} - - return {"FINISHED"} - - -class MATLIB_OP_load_package(bpy.types.Operator): - """Download material package""" - bl_idname = utils.with_prefix("matlib_load_package") - bl_label = "Download Package" - - def execute(self, context): - matlib_prop = utils.mx_properties(context.window_manager).matlib - manager.load_package(matlib_prop.package) - - return {"FINISHED"} - - -class MATLIB_PT_matlib(bpy.types.Panel): - bl_idname = utils.with_prefix("MATLIB_PT_matlib", '_', True) - bl_label = "MaterialX Library" - bl_context = "material" - bl_region_type = 'WINDOW' - bl_space_type = 'PROPERTIES' - bl_options = {'DEFAULT_CLOSED'} - - @classmethod - def poll(cls, context): - return context.material - - def draw(self, context): - layout = self.layout - matlib_prop = utils.mx_properties(context.window_manager).matlib - - manager.check_load_materials() - - # category - layout.prop(matlib_prop, 'category_id') - - # search - row = layout.row(align=True) - row.prop(matlib_prop, 'search', text="", icon='VIEWZOOM') - if matlib_prop.search: - row.operator(MATERIAL_OP_matlib_clear_search.bl_idname, icon='X') - - # materials - col = layout.column(align=True) - materials = matlib_prop.get_materials() - if not materials: - col.label(text="Start syncing..." if not manager.materials else "No materials found") - return - - row = col.row() - row.alignment = 'RIGHT' - row.label(text=f"{len(materials)} materials") - - col.template_icon_view(matlib_prop, 'material_id', show_labels=True) - - mat = matlib_prop.material - if not mat: - return - - # other material renders - if len(mat.renders) > 1: - grid = col.grid_flow(align=True) - for i, render in enumerate(mat.renders): - if i % 6 == 0: - row = grid.row() - row.alignment = 'CENTER' - - row.template_icon(render.thumbnail_icon_id, scale=5) - - # material title - row = col.row() - row.alignment = 'CENTER' - row.label(text=mat.title) - - # material description - col = layout.column(align=True) - if mat.description: - for line in textwrap.wrap(mat.description, 60): - col.label(text=line) - - col = layout.column(align=True) - col.label(text=f"Category: {mat.category.title}") - col.label(text=f"Author: {mat.author}") - - # packages - package = matlib_prop.package - if not package: - return - - layout.prop(matlib_prop, 'package_id', icon='DOCUMENTS') - - row = layout.row() - if package.has_file: - row.operator(MATLIB_OP_import_material.bl_idname, icon='IMPORT') - else: - if package.size_load is None: - row.operator(MATLIB_OP_load_package.bl_idname, icon='IMPORT') - else: - percent = min(100, int(package.size_load * 100 / package.size)) - row.operator(MATLIB_OP_load_package.bl_idname, icon='IMPORT', - text=f"Downloading Package...{percent}%") - row.enabled = False - - -class MATLIB_PT_matlib_tools(bpy.types.Panel): - bl_label = "Tools" - bl_context = "material" - bl_region_type = 'WINDOW' - bl_space_type = 'PROPERTIES' - bl_parent_id = utils.with_prefix('MATLIB_PT_matlib', '_', True) - bl_options = {'DEFAULT_CLOSED'} - - def draw(self, context): - layout = self.layout - col = layout.column() - col.label(text=manager.status) - - row = col.row() - row.enabled = bool(manager.is_synced) - row.operator(MATLIB_OP_load_materials.bl_idname, icon='FILE_REFRESH') diff --git a/materialx/node_tree.py b/materialx/node_tree.py deleted file mode 100644 index 64346a76b..000000000 --- a/materialx/node_tree.py +++ /dev/null @@ -1,268 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-or-later -# Copyright 2022, AMD - -import MaterialX as mx - -import bpy - -from . import utils - -from . import logging -log = logging.Log('node_tree') - - -NODE_LAYER_SEPARATION_WIDTH = 280 -NODE_LAYER_SHIFT_X = 30 -NODE_LAYER_SHIFT_Y = 100 - - -class MxNodeTree(bpy.types.ShaderNodeTree): - """ - MaterialX NodeTree - """ - bl_label = "MaterialX" - bl_icon = "NODE_MATERIAL" - bl_idname = utils.with_prefix("MxNodeTree") - - _do_update = True - - @property - def output_node(self): - return next((node for node in self.nodes - if node.bl_idname == utils.with_prefix('MxNode_STD_surfacematerial')), None) - - @property - def output_node_volume(self): - return next((node for node in self.nodes - if node.bl_idname == utils.with_prefix('MxNode_STD_volumematerial')), None) - - def no_update_call(self, op, *args, **kwargs): - """This function prevents call of self.update() during calling our function""" - if not self._do_update: - return op(*args, **kwargs) - - self._do_update = False - try: - return op(*args, **kwargs) - finally: - self._do_update = True - - def export(self) -> mx.Document: - output_node = self.output_node - if not output_node: - return None - - doc = mx.createDocument() - - surfacematerial = output_node.compute(0, doc=doc) - if not surfacematerial: - return None - - return doc - - def import_(self, doc: mx.Document, file_path): - def prepare_for_import(): - surfacematerial = next( - (n for n in doc.getNodes() if n.getCategory() == 'surfacematerial'), None) - if surfacematerial: - return - - mat = doc.getMaterials()[0] - sr = mat.getShaderRefs()[0] - - doc.removeMaterial(mat.getName()) - - node_name = sr.getName() - if not node_name.startswith("SR_"): - node_name = f"SR_{node_name}" - node = doc.addNode(sr.getNodeString(), node_name, 'surfaceshader') - for sr_input in sr.getBindInputs(): - input = node.addInput(sr_input.getName(), sr_input.getType()) - ng_name = sr_input.getNodeGraphString() - if ng_name: - input.setAttribute('nodegraph', ng_name) - input.setAttribute('output', sr_input.getOutputString()) - else: - input.setValue(sr_input.getValue()) - - surfacematerial = doc.addNode('surfacematerial', mat.getName(), 'material') - input = surfacematerial.addInput('surfaceshader', node.getType()) - input.setNodeName(node.getName()) - - def do_import(): - from .nodes import get_mx_node_cls - - self.nodes.clear() - - def import_node(mx_node, mx_output_name=None, look_nodedef=True): - mx_nodegraph = mx_node.getParent() - node_path = mx_node.getNamePath() - file_prefix = utils.get_file_prefix(mx_node, file_path) - - if node_path in self.nodes: - return self.nodes[node_path] - - try: - MxNode_cls, data_type = get_mx_node_cls(mx_node) - - except KeyError as e: - if not look_nodedef: - log.warn(e) - return None - - # looking for nodedef and switching to another nodegraph defined in doc - nodedef = next(nd for nd in doc.getNodeDefs() - if nd.getNodeString() == mx_node.getCategory() and - nd.getType() == mx_node.getType()) - new_mx_nodegraph = next(ng for ng in doc.getNodeGraphs() - if ng.getNodeDefString() == nodedef.getName()) - - mx_output = new_mx_nodegraph.getOutput(mx_output_name) - node_name = mx_output.getNodeName() - new_mx_node = new_mx_nodegraph.getNode(node_name) - - return import_node(new_mx_node, None, False) - - node = self.nodes.new(MxNode_cls.bl_idname) - node.name = node_path - node.data_type = data_type - nodedef = node.nodedef - - for mx_input in mx_node.getInputs(): - input_name = mx_input.getName() - nd_input = nodedef.getInput(input_name) - if nd_input.getAttribute('uniform') == 'true': - node.set_param_value(input_name, utils.parse_value( - node, mx_input.getValue(), mx_input.getType(), file_prefix)) - continue - - if input_name not in node.inputs: - log.error(f"Incorrect input name '{input_name}' for node {node}") - continue - - val = mx_input.getValue() - if val is not None: - node.set_input_value(input_name, utils.parse_value( - node, val, mx_input.getType(), file_prefix)) - continue - - node_name = mx_input.getNodeName() - - if node_name: - new_mx_node = mx_nodegraph.getNode(node_name) - if not new_mx_node: - log.error(f"Couldn't find node '{node_name}' in nodegraph '{mx_nodegraph.getNamePath()}'") - continue - - new_node = import_node(new_mx_node) - - out_name = mx_input.getAttribute('output') - if len(new_node.nodedef.getOutputs()) > 1 and out_name: - new_node_output = new_node.outputs[out_name] - else: - new_node_output = new_node.outputs[0] - - self.links.new(new_node_output, node.inputs[input_name]) - continue - - new_nodegraph_name = mx_input.getAttribute('nodegraph') - if new_nodegraph_name: - mx_output_name = mx_input.getAttribute('output') - new_mx_nodegraph = mx_nodegraph.getNodeGraph(new_nodegraph_name) - mx_output = new_mx_nodegraph.getOutput(mx_output_name) - node_name = mx_output.getNodeName() - new_mx_node = new_mx_nodegraph.getNode(node_name) - new_node = import_node(new_mx_node, mx_output_name) - if not new_node: - continue - - out_name = mx_output.getAttribute('output') - if len(new_node.nodedef.getOutputs()) > 1 and out_name: - new_node_output = new_node.outputs[out_name] - else: - new_node_output = new_node.outputs[0] - - self.links.new(new_node_output, node.inputs[input_name]) - continue - - node.check_ui_folders() - return node - - mx_node = next(n for n in doc.getNodes() if n.getCategory() == 'surfacematerial') - output_node = import_node(mx_node, 0) - - if not output_node: - return - - # arranging nodes by layers - layer = {output_node} - layer_index = 0 - layers = {} - while layer: - new_layer = set() - for node in layer: - layers[node] = layer_index - for inp in node.inputs: - for link in inp.links: - new_layer.add(link.from_node) - layer = new_layer - layer_index += 1 - - node_layers = [[] for _ in range(max(layers.values()) + 1)] - for node in self.nodes: - node_layers[layers[node]].append(node) - - # placing nodes by layers - loc_x = 0 - for i, nodes in enumerate(node_layers): - loc_y = 0 - for node in nodes: - node.location = (loc_x, loc_y) - loc_y -= NODE_LAYER_SHIFT_Y - loc_x -= NODE_LAYER_SHIFT_X - - loc_x -= NODE_LAYER_SEPARATION_WIDTH - - prepare_for_import() - self.no_update_call(do_import) - self.update_() - - def create_basic_nodes(self, node_name='PBR_standard_surface'): - """ Reset basic node tree structure using scene or USD file as an input """ - def create_nodes(): - self.nodes.clear() - - mat_node = self.nodes.new(utils.with_prefix('MxNode_STD_surfacematerial')) - node = self.nodes.new(utils.with_prefix(f'MxNode_{node_name}')) - node.location = (mat_node.location[0] - NODE_LAYER_SEPARATION_WIDTH, - mat_node.location[1]) - self.links.new(node.outputs[0], mat_node.inputs[0]) - - self.no_update_call(create_nodes) - self.update_() - - # this is called from Blender - def update(self): - if not self._do_update: - return - - self.update_() - - def update_(self): - utils.update_ui() - - # We have to call self.update_links via bpy.app.timers.register - # to have slight delay after self.update(). It'll be called once - bpy.app.timers.register(self.update_links) - - # this is called from Blender - def update_links(self): - for link in self.links: - socket_from_type = link.from_socket.node.nodedef.getOutput(link.from_socket.name).getType() - socket_to_type = link.to_socket.node.nodedef.getInput(link.to_socket.name).getType() - - if socket_to_type != socket_from_type: - link.is_valid = False - continue - - link.is_valid = True diff --git a/materialx/nodes/__init__.py b/materialx/nodes/__init__.py index 816ba1051..9249ad75c 100644 --- a/materialx/nodes/__init__.py +++ b/materialx/nodes/__init__.py @@ -7,7 +7,7 @@ import bpy import nodeitems_utils import sys -from . import node, categories, generate_node_classes, ui +from . import node, categories, generate_node_classes from .. import utils @@ -29,21 +29,12 @@ register_sockets, unregister_sockets = bpy.utils.register_classes_factory([ node.MxNodeInputSocket, node.MxNodeOutputSocket, ]) -register_ui, unregister_ui = bpy.utils.register_classes_factory([ - ui.NODES_OP_import_file, - ui.NODES_OP_export_file, - ui.NODES_OP_export_console, - ui.NODES_OP_create_basic_nodes, - ui.NODES_PT_tools, - ui.NODES_PT_dev, -]) register_nodes, unregister_nodes = bpy.utils.register_classes_factory(mx_node_classes) def register(): register_sockets() - register_ui() register_nodes() nodeitems_utils.register_node_categories(utils.with_prefix("MX_NODES"), categories.get_node_categories()) @@ -53,7 +44,6 @@ def unregister(): nodeitems_utils.unregister_node_categories(utils.with_prefix("MX_NODES")) unregister_nodes() - unregister_ui() unregister_sockets() diff --git a/materialx/nodes/categories.py b/materialx/nodes/categories.py index 14467ee08..66a19b377 100644 --- a/materialx/nodes/categories.py +++ b/materialx/nodes/categories.py @@ -1,6 +1,8 @@ # SPDX-License-Identifier: GPL-2.0-or-later # Copyright 2022, AMD +import bpy + from collections import defaultdict from nodeitems_utils import NodeCategory, NodeItem @@ -11,7 +13,7 @@ from ..utils import title_str, code_str, with_prefix class MxNodeCategory(NodeCategory): @classmethod def poll(cls, context): - return context.space_data.tree_type == with_prefix('MxNodeTree') + return context.space_data.tree_type == 'ShaderNodeTree' def get_node_categories(): diff --git a/materialx/nodes/generate_node_classes.py b/materialx/nodes/generate_node_classes.py index 535d8b124..99d052792 100644 --- a/materialx/nodes/generate_node_classes.py +++ b/materialx/nodes/generate_node_classes.py @@ -130,8 +130,6 @@ def generate_property_code(mx_param, category): val_str = f'"{val}"' if isinstance(val, str) else str(val) prop_attr_strings.append(f"{name}={val_str}") - prop_attr_strings.append("update=MxNode.update_prop") - if mx_type == 'filename' and category in ("texture2d", "texture3d"): prop_attr_strings.insert(0, "type=bpy.types.Image") diff --git a/materialx/nodes/node.py b/materialx/nodes/node.py index 9f8cb0c28..c481da005 100644 --- a/materialx/nodes/node.py +++ b/materialx/nodes/node.py @@ -111,9 +111,29 @@ class MxNode(bpy.types.ShaderNode): def _input_prop_name(self, name): return f"nd_{self.data_type}_in_{name}" - def update_prop(self, context): + def update(self): + bpy.app.timers.register(self.mark_invalid_links) + + def mark_invalid_links(self): + if not is_mx_node_valid(self): + return + nodetree = self.id_data - nodetree.update_() + + if not (hasattr(nodetree, 'links')): + return + + for link in nodetree.links: + if hasattr(link.from_socket.node, 'nodedef') and hasattr(link.to_socket.node, 'nodedef'): + + socket_from_type = link.from_socket.node.nodedef.getOutput(link.from_socket.name).getType() + socket_to_type = link.to_socket.node.nodedef.getInput(link.to_socket.name).getType() + + if socket_to_type != socket_from_type: + link.is_valid = False + continue + + link.is_valid = True def update_data_type(self, context): # updating names for inputs and outputs @@ -124,23 +144,20 @@ class MxNode(bpy.types.ShaderNode): self.outputs[i].name = nd_output.getName() def init(self, context): - def init_(): - nodedef = self.nodedef + nodedef = self.nodedef - for nd_input in utils.get_nodedef_inputs(nodedef, False): - self.create_input(nd_input) + for nd_input in utils.get_nodedef_inputs(nodedef, False): + self.create_input(nd_input) - for nd_output in nodedef.getOutputs(): - self.create_output(nd_output) + for nd_output in nodedef.getOutputs(): + self.create_output(nd_output) - if self._ui_folders: - self.update_ui_folders(context) - - nodetree = self.id_data - nodetree.no_update_call(init_) + if self._ui_folders: + self.update_ui_folders(context) def draw_buttons(self, context, layout): is_prop_area = context.area.type == 'PROPERTIES' + if len(self._data_types) > 1: layout1 = layout if is_prop_area: @@ -163,6 +180,7 @@ class MxNode(bpy.types.ShaderNode): for nd_input in utils.get_nodedef_inputs(nodedef, True): f = nd_input.getAttribute('uifolder') + if f and not getattr(self, self._folder_prop_name(f)): continue @@ -185,84 +203,10 @@ class MxNode(bpy.types.ShaderNode): layout1 = layout1.column() layout1.prop(self, self._input_prop_name(name)) - def draw_node_view(self, context, layout): - from ..material.ui import MATERIAL_OP_invoke_popup_input_nodes - layout.use_property_split = True - layout.use_property_decorate = True - self.draw_buttons(context, layout) - - for i, socket_in in enumerate(self.inputs): - nd = self.nodedef - uiname = utils.get_attr(nd.getInput(socket_in.name), 'uiname', - utils.title_str(nd.getInput(socket_in.name).getName())) - if socket_in.is_linked: - link = next((link for link in socket_in.links if link.is_valid), None) - if not link: - continue - - link = utils.pass_node_reroute(link) - if not link or isinstance(link.from_node, bpy.types.NodeReroute): - continue - - split = layout.split(factor=0.4) - split_1 = split.split(factor=0.4) - - row = split_1.row() - row.use_property_split = False - row.use_property_decorate = False - row.alignment = 'LEFT' - row.prop(socket_in, "show_expanded", - icon="DISCLOSURE_TRI_DOWN" if socket_in.show_expanded else "DISCLOSURE_TRI_RIGHT", - icon_only=True, emboss=False) - row = split_1.row() - row.alignment = 'RIGHT' - row.label(text=uiname) - row = split.row(align=True) - row.use_property_decorate = False - - box = row.box() - box.scale_x = 0.7 - box.scale_y = 0.5 - box.emboss = 'NONE_OR_STATUS' - - op = box.operator(MATERIAL_OP_invoke_popup_input_nodes.bl_idname, icon='HANDLETYPE_AUTO_CLAMP_VEC') - op.input_num = i - op.current_node_name = self.name - - row.prop(link.from_node, 'name', text='') - row.label(icon='BLANK1') - - if socket_in.show_expanded: - link.from_node.draw_node_view(context, layout) - - else: - mx_input = self.nodedef.getInput(socket_in.name) - f = mx_input.getAttribute('uifolder') - is_draw = True - if f: - if not getattr(self, self._folder_prop_name(f)): - is_draw = False - - if is_draw: - split = layout.split(factor=0.4) - - row = split.row(align=True) - row.alignment = 'RIGHT' - row.label(text=uiname) - row = split.row(align=True) - box = row.box() - box.scale_x = 0.7 - box.scale_y = 0.5 - - op = box.operator(MATERIAL_OP_invoke_popup_input_nodes.bl_idname, - icon='HANDLETYPE_AUTO_CLAMP_VEC') - op.input_num = i - op.current_node_name = self.name - - socket_in.draw(context, row, self, '') - # COMPUTE FUNCTION def compute(self, out_key, **kwargs): + from ..bl_nodes.node_parser import NodeItem + log("compute", self, out_key) doc = kwargs['doc'] @@ -287,7 +231,7 @@ class MxNode(bpy.types.ShaderNode): nd_input = self.get_nodedef_input(in_key) nd_type = nd_input.getType() - if isinstance(val, mx.Node): + if isinstance(val, (mx.Node, NodeItem)): mx_input = mx_node.addInput(nd_input.getName(), nd_type) utils.set_param_value(mx_input, val, nd_type) continue @@ -346,6 +290,7 @@ class MxNode(bpy.types.ShaderNode): def get_input_link(self, in_key: [str, int], **kwargs): """Returns linked parsed node or None if nothing is linked or not link is not valid""" + from ..bl_nodes import node_parser socket_in = self.inputs[in_key] if not socket_in.links: @@ -360,11 +305,26 @@ class MxNode(bpy.types.ShaderNode): if not link: return None - if not is_mx_node_valid(link.from_node): - log.warn(f"Ignoring unsupported node {link.from_node.bl_idname}", link.from_node, link.from_node.id_data) + if isinstance(link.from_node, MxNode): + if not is_mx_node_valid(link.from_node): + log.warn(f"Ignoring unsupported node {link.from_node.bl_idname}", link.from_node, + link.from_node.id_data) + return None + + return self._compute_node(link.from_node, link.from_socket.name, **kwargs) + + NodeParser_cls = node_parser.NodeParser.get_node_parser_cls(link.from_node.bl_idname) + if not NodeParser_cls: + log.warn(f"Ignoring unsupported node {link.from_node.bl_idname}", link.from_node, self.material) return None - return self._compute_node(link.from_node, link.from_socket.name, **kwargs) + output_type = NodeParser_cls.get_output_type(link.to_socket) + + node_parser_cls = NodeParser_cls(node_parser.Id(), kwargs['doc'], None, link.from_node, None, + link.from_socket.name, output_type, {}) + node_item = node_parser_cls.export() + + return node_item def get_input_value(self, in_key: [str, int], **kwargs): node = self.get_input_link(in_key, **kwargs) @@ -393,7 +353,7 @@ class MxNode(bpy.types.ShaderNode): @classmethod def poll(cls, tree): - return tree.bl_idname == utils.with_prefix('MxNodeTree') + return tree.bl_idname == 'ShaderNodeTree' def update_ui_folders(self, context): for i, nd_input in enumerate(utils.get_nodedef_inputs(self.nodedef, False)): @@ -401,9 +361,6 @@ class MxNode(bpy.types.ShaderNode): if f: self.inputs[i].hide = not getattr(self, self._folder_prop_name(f)) - nodetree = self.id_data - nodetree.update_() - def check_ui_folders(self): if not self._ui_folders: return diff --git a/materialx/nodes/ui.py b/materialx/ui.py similarity index 56% rename from materialx/nodes/ui.py rename to materialx/ui.py index 82b87de04..8129ea869 100644 --- a/materialx/nodes/ui.py +++ b/materialx/ui.py @@ -2,23 +2,23 @@ # Copyright 2022, AMD from pathlib import Path -import traceback +import traceback import MaterialX as mx import bpy from bpy_extras.io_utils import ImportHelper, ExportHelper -from ..node_tree import MxNodeTree -from .. import utils -from ..preferences import addon_preferences +from . import utils +from .utils import import_materialx_from_file, export +from .preferences import addon_preferences -from ..utils import logging -log = logging.Log('nodes.ui') +from .utils import logging +log = logging.Log(tag='ui') -class NODES_OP_import_file(bpy.types.Operator, ImportHelper): - bl_idname = utils.with_prefix('nodes_import_file') +class MATERIALX_OP_import_file(bpy.types.Operator, ImportHelper): + bl_idname = utils.with_prefix('materialx_import_file') bl_label = "Import from File" bl_description = "Import MaterialX node tree from .mtlx file" @@ -39,7 +39,7 @@ class NODES_OP_import_file(bpy.types.Operator, ImportHelper): search_path.append(str(utils.MX_LIBS_DIR)) try: mx.readFromXmlFile(doc, str(mtlx_file)) - mx_node_tree.import_(doc, mtlx_file) + import_materialx_from_file(mx_node_tree, doc, mtlx_file) except Exception as e: log.error(traceback.format_exc(), mtlx_file) @@ -48,17 +48,17 @@ class NODES_OP_import_file(bpy.types.Operator, ImportHelper): return {'FINISHED'} -class NODES_OP_export_file(bpy.types.Operator, ExportHelper): - bl_idname = utils.with_prefix('nodes_export_file') +class MATERIALX_OP_export_file(bpy.types.Operator, ExportHelper): + bl_idname = utils.with_prefix('materialx_export_file') bl_label = "Export to File" - bl_description = "Export MaterialX node tree to .mtlx file" + bl_description = "Export material as MaterialX node tree to .mtlx file" # region properties filename_ext = ".mtlx" filepath: bpy.props.StringProperty( name="File Path", - description="File path used for exporting MaterialX node tree to .mtlx file", + description="File path used for exporting material as MaterialX node tree to .mtlx file", maxlen=1024, subtype="FILE_PATH" ) @@ -72,27 +72,30 @@ class NODES_OP_export_file(bpy.types.Operator, ExportHelper): default=False ) is_export_textures: bpy.props.BoolProperty( - name="Export bound textures", + name="Export textures", description="Export bound textures to corresponded folder", default=True ) + is_clean_texture_folder: bpy.props.BoolProperty( + name="Сlean texture folder", + description="Сlean texture folder before export", + default=False + ) texture_dir_name: bpy.props.StringProperty( - name="Texture folder name", + name="Folder name", description="Texture folder name used for exporting files", default='textures', - maxlen=1024 + maxlen=1024, ) # endregion def execute(self, context): - mx_node_tree = context.space_data.edit_tree - doc = mx_node_tree.export() + doc = export(context.material, None) if not doc: - log.warn("Incorrect node tree to export", mx_node_tree) return {'CANCELLED'} utils.export_mx_to_file(doc, self.filepath, - mx_node_tree=mx_node_tree, + mx_node_tree=None, # is_export_deps=self.is_export_deps, is_export_textures=self.is_export_textures, texture_dir_name=self.texture_dir_name) @@ -109,68 +112,47 @@ class NODES_OP_export_file(bpy.types.Operator, ExportHelper): row.enabled = self.is_export_textures row.prop(self, 'texture_dir_name', text='') - @staticmethod - def enabled(context): - return bool(context.space_data.edit_tree.output_node) - -class NODES_OP_export_console(bpy.types.Operator): - bl_idname = utils.with_prefix('nodes_export_console') +class MATERIALX_OP_export_console(bpy.types.Operator): + bl_idname = utils.with_prefix('materialx_export_console') bl_label = "Export to Console" - bl_description = "Export MaterialX node tree to console" + bl_description = "Export material as MaterialX node tree to console" def execute(self, context): - mx_node_tree = context.space_data.edit_tree - doc = mx_node_tree.export() + doc = export(context.material, context.object) if not doc: - log.warn("Incorrect node tree to export", mx_node_tree) return {'CANCELLED'} print(mx.writeToXmlString(doc)) return {'FINISHED'} - @staticmethod - def enabled(context): - return bool(context.space_data.edit_tree.output_node) - -class NODES_OP_create_basic_nodes(bpy.types.Operator): - bl_idname = utils.with_prefix("nodes_create_basic_nodes") - bl_label = "Create Basic Nodes" - bl_description = "Create basic MaterialX nodes" - - def execute(self, context): - mx_node_tree = context.space_data.edit_tree - mx_node_tree.create_basic_nodes() - return {'FINISHED'} - - -class NODES_PT_tools(bpy.types.Panel): - bl_idname = utils.with_prefix('NODES_PT_tools', '_', True) +class MATERIALX_PT_tools(bpy.types.Panel): + bl_idname = utils.with_prefix('MATERIALX_PT_tools', '_', True) bl_label = "MaterialX Tools" - bl_space_type = 'NODE_EDITOR' - bl_region_type = 'UI' + bl_space_type = "NODE_EDITOR" + bl_region_type = "UI" bl_category = "Tool" @classmethod def poll(cls, context): tree = context.space_data.edit_tree - return tree and tree.bl_idname == MxNodeTree.bl_idname + + return tree and tree.bl_idname == 'ShaderNodeTree' def draw(self, context): layout = self.layout - layout.operator(NODES_OP_create_basic_nodes.bl_idname, icon='ADD') - layout.operator(NODES_OP_import_file.bl_idname, icon='IMPORT') - layout.operator(NODES_OP_export_file.bl_idname, icon='EXPORT') + layout.operator(MATERIALX_OP_import_file.bl_idname, icon='IMPORT') + layout.operator(MATERIALX_OP_export_file.bl_idname, icon='EXPORT') -class NODES_PT_dev(bpy.types.Panel): - bl_idname = utils.with_prefix('NODES_PT_dev', '_', True) - bl_parent_id = NODES_PT_tools.bl_idname +class MATERIALX_PT_dev(bpy.types.Panel): + bl_idname = utils.with_prefix('MATERIALX_PT_dev', '_', True) bl_label = "Dev" - bl_space_type = 'NODE_EDITOR' - bl_region_type = 'UI' + bl_parent_id = MATERIALX_PT_tools.bl_idname + bl_space_type = "NODE_EDITOR" + bl_region_type = "UI" @classmethod def poll(cls, context): @@ -179,5 +161,13 @@ class NODES_PT_dev(bpy.types.Panel): def draw(self, context): layout = self.layout + layout.operator(MATERIALX_OP_export_console.bl_idname) - layout.operator(NODES_OP_export_console.bl_idname) \ No newline at end of file + +register, unregister = bpy.utils.register_classes_factory([ + MATERIALX_OP_import_file, + MATERIALX_OP_export_file, + MATERIALX_OP_export_console, + MATERIALX_PT_tools, + MATERIALX_PT_dev, +]) diff --git a/materialx/utils.py b/materialx/utils.py index 7c8a20ba9..4ea474335 100644 --- a/materialx/utils.py +++ b/materialx/utils.py @@ -31,25 +31,9 @@ MATLIB_URL = "https://api.matlib.gpuopen.com/api" TEMP_FOLDER = "bl-materialx" - -class MaterialXProperties(bpy.types.PropertyGroup): - bl_type = None - - @classmethod - def register(cls): - setattr(cls.bl_type, ADDON_ALIAS, bpy.props.PointerProperty( - name="MaterialX properties", - description="MaterialX properties", - type=cls, - )) - - @classmethod - def unregister(cls): - delattr(cls.bl_type, ADDON_ALIAS) - - -def mx_properties(obj): - return getattr(obj, ADDON_ALIAS) +NODE_LAYER_SEPARATION_WIDTH = 280 +NODE_LAYER_SHIFT_X = 30 +NODE_LAYER_SHIFT_Y = 100 def with_prefix(name, separator='.', upper=False): @@ -66,6 +50,8 @@ def code_str(val): def set_param_value(mx_param, val, nd_type, nd_output=None): + from .bl_nodes.node_parser import NodeItem + if isinstance(val, mx.Node): param_nodegraph = mx_param.getParent().getParent() val_nodegraph = val.getParent() @@ -107,12 +93,20 @@ def set_param_value(mx_param, val, nd_type, nd_output=None): else: mx_param.setValueString(str(val)) + elif hasattr(val, 'data') and isinstance(val.data, mx.Node): + set_param_value(mx_param, val.data, nd_type, nd_output) + else: mx_type = getattr(mx, title_str(nd_type), None) if mx_type: - val = mx_type(val) - elif nd_type == 'float' and isinstance(val, tuple): - val = val[0] + val = mx_type(val.data) if isinstance(val, NodeItem) else mx_type(val) + + elif nd_type == 'float': + if isinstance(val, NodeItem): + val = val.data + + if isinstance(val, tuple): + val = val[0] mx_param.setValue(val) @@ -446,15 +440,13 @@ def update_ui(area_type='PROPERTIES', region_type='WINDOW'): def update_materialx_data(depsgraph, materialx_data): - from .node_tree import MxNodeTree - if not depsgraph.updates: return - for mx_node_tree in (upd.id for upd in depsgraph.updates if isinstance(upd.id, MxNodeTree)): + for node_tree in (upd.id for upd in depsgraph.updates if isinstance(upd.id, bpy.types.ShaderNodeTree)): for material in bpy.data.materials: - if material.materialx.mx_node_tree and material.materialx.mx_node_tree.name == mx_node_tree.name: - doc = material.materialx.export(None) + if material.node_tree and material.node_tree.name == node_tree.name: + doc = export(material, None) if not doc: # log.warn("MX export failed", mat) continue @@ -463,7 +455,7 @@ def update_materialx_data(depsgraph, materialx_data): if not matx_data: mx_file = get_temp_file(".mtlx", - f'{material.name}{material.materialx.mx_node_tree.name if material.materialx.mx_node_tree else ""}', + f'{material.name}{material.node_tree.name if material.node_tree else ""}', False) mx.writeToXmlFile(doc, str(mx_file)) @@ -472,3 +464,221 @@ def update_materialx_data(depsgraph, materialx_data): materialx_data.append((material.name, str(mx_file), surfacematerial.getName())) else: mx.writeToXmlFile(doc, str(matx_data[1])) + + +def import_materialx_from_file(node_tree, doc: mx.Document, file_path): + def prepare_for_import(): + surfacematerial = next( + (n for n in doc.getNodes() if n.getCategory() == 'surfacematerial'), None) + if surfacematerial: + return + + mat = doc.getMaterials()[0] + sr = mat.getShaderRefs()[0] + + doc.removeMaterial(mat.getName()) + + node_name = sr.getName() + if not node_name.startswith("SR_"): + node_name = f"SR_{node_name}" + node = doc.addNode(sr.getNodeString(), node_name, 'surfaceshader') + for sr_input in sr.getBindInputs(): + input = node.addInput(sr_input.getName(), sr_input.getType()) + ng_name = sr_input.getNodeGraphString() + if ng_name: + input.setAttribute('nodegraph', ng_name) + input.setAttribute('output', sr_input.getOutputString()) + else: + input.setValue(sr_input.getValue()) + + surfacematerial = doc.addNode('surfacematerial', mat.getName(), 'material') + input = surfacematerial.addInput('surfaceshader', node.getType()) + input.setNodeName(node.getName()) + + def do_import(): + from .nodes import get_mx_node_cls + + node_tree.nodes.clear() + + def import_node(mx_node, mx_output_name=None, look_nodedef=True): + mx_nodegraph = mx_node.getParent() + node_path = mx_node.getNamePath() + file_prefix = get_file_prefix(mx_node, file_path) + + if node_path in node_tree.nodes: + return node_tree.nodes[node_path] + + try: + MxNode_cls, data_type = get_mx_node_cls(mx_node) + + except KeyError as e: + if not look_nodedef: + log.warn(e) + return None + + # looking for nodedef and switching to another nodegraph defined in doc + nodedef = next(nd for nd in doc.getNodeDefs() + if nd.getNodeString() == mx_node.getCategory() and + nd.getType() == mx_node.getType()) + new_mx_nodegraph = next(ng for ng in doc.getNodeGraphs() + if ng.getNodeDefString() == nodedef.getName()) + + mx_output = new_mx_nodegraph.getOutput(mx_output_name) + node_name = mx_output.getNodeName() + new_mx_node = new_mx_nodegraph.getNode(node_name) + + return import_node(new_mx_node, None, False) + + node = node_tree.nodes.new(MxNode_cls.bl_idname) + node.name = node_path + node.data_type = data_type + nodedef = node.nodedef + + for mx_input in mx_node.getInputs(): + input_name = mx_input.getName() + nd_input = nodedef.getInput(input_name) + if nd_input.getAttribute('uniform') == 'true': + node.set_param_value(input_name, parse_value( + node, mx_input.getValue(), mx_input.getType(), file_prefix)) + continue + + if input_name not in node.inputs: + log.error(f"Incorrect input name '{input_name}' for node {node}") + continue + + val = mx_input.getValue() + if val is not None: + node.set_input_value(input_name, parse_value( + node, val, mx_input.getType(), file_prefix)) + continue + + node_name = mx_input.getNodeName() + + if node_name: + new_mx_node = mx_nodegraph.getNode(node_name) + if not new_mx_node: + log.error(f"Couldn't find node '{node_name}' in nodegraph '{mx_nodegraph.getNamePath()}'") + continue + + new_node = import_node(new_mx_node) + + out_name = mx_input.getAttribute('output') + if len(new_node.nodedef.getOutputs()) > 1 and out_name: + new_node_output = new_node.outputs[out_name] + else: + new_node_output = new_node.outputs[0] + + node_tree.links.new(new_node_output, node.inputs[input_name]) + continue + + new_nodegraph_name = mx_input.getAttribute('nodegraph') + if new_nodegraph_name: + mx_output_name = mx_input.getAttribute('output') + new_mx_nodegraph = mx_nodegraph.getNodeGraph(new_nodegraph_name) + mx_output = new_mx_nodegraph.getOutput(mx_output_name) + node_name = mx_output.getNodeName() + new_mx_node = new_mx_nodegraph.getNode(node_name) + new_node = import_node(new_mx_node, mx_output_name) + if not new_node: + continue + + out_name = mx_output.getAttribute('output') + if len(new_node.nodedef.getOutputs()) > 1 and out_name: + new_node_output = new_node.outputs[out_name] + else: + new_node_output = new_node.outputs[0] + + node_tree.links.new(new_node_output, node.inputs[input_name]) + continue + + node.check_ui_folders() + return node + + mx_node = next(n for n in doc.getNodes() if n.getCategory() == 'surfacematerial') + output_node = import_node(mx_node, 0) + + if not output_node: + return + + # arranging nodes by layers + layer = {output_node} + layer_index = 0 + layers = {} + while layer: + new_layer = set() + for node in layer: + layers[node] = layer_index + for inp in node.inputs: + for link in inp.links: + new_layer.add(link.from_node) + layer = new_layer + layer_index += 1 + + node_layers = [[] for _ in range(max(layers.values()) + 1)] + for node in node_tree.nodes: + node_layers[layers[node]].append(node) + + # placing nodes by layers + loc_x = 0 + for i, nodes in enumerate(node_layers): + loc_y = 0 + for node in nodes: + node.location = (loc_x, loc_y) + loc_y -= NODE_LAYER_SHIFT_Y + loc_x -= NODE_LAYER_SHIFT_X + + loc_x -= NODE_LAYER_SEPARATION_WIDTH + + prepare_for_import() + do_import() + + +def export(material, obj: bpy.types.Object) -> [mx.Document, None]: + from .bl_nodes.output import ShaderNodeOutputMaterial + from .nodes.node import MxNode + + output_node = get_output_node(material) + + if not output_node: + return None + + doc = mx.createDocument() + + if isinstance(output_node, MxNode): + mx_node = output_node.compute('out', doc=doc) + return doc + + node_parser = ShaderNodeOutputMaterial(doc, material, output_node, obj) + if not node_parser.export(): + return None + + return doc + + +def get_materialx_data(material, obj: bpy.types.Object): + doc = export(obj) + if not doc: + return None, None + + mtlx_file = get_temp_file(".mtlx", f'{material.name}_{material.node_tree.name if material.node_tree else ""}') + mx.writeToXmlFile(doc, str(mtlx_file)) + + return mtlx_file, doc + + +def get_output_node(material): + if not material.node_tree: + return None + + bl_output_node = next((node for node in material.node_tree.nodes if + node.bl_idname == 'ShaderNodeOutputMaterial' and + node.is_active_output and node.inputs['Surface'].links), None) + + if bl_output_node: + return bl_output_node + + mx_output_node = next((node for node in material.node_tree.nodes if + node.bl_idname == with_prefix('MxNode_STD_surfacematerial') and + node.inputs['surfaceshader'].links), None) + + return mx_output_node -- 2.30.2 From dfa1db9e31737f555eb39a1924a512cb3c7d1235 Mon Sep 17 00:00:00 2001 From: Georgiy Markelov <42409851+DagerD@users.noreply.github.com> Date: Fri, 2 Dec 2022 02:22:10 +0300 Subject: [PATCH 16/28] BLEN-233: Support MaterialX 1.38.5 (#15) Added caching of MaterialX Document Changes: getOutput -> getActiveOutput getOutputs-> getActiveOutputs getInput -> getActiveInput getInputs-> getActiveInputs Co-authored-by: markyandex@gmail.com --- materialx/nodes/__init__.py | 4 +-- materialx/nodes/generate_node_classes.py | 14 ++++----- materialx/nodes/node.py | 39 ++++++++++++++---------- materialx/utils.py | 16 +++++----- 4 files changed, 40 insertions(+), 33 deletions(-) diff --git a/materialx/nodes/__init__.py b/materialx/nodes/__init__.py index 9249ad75c..23e8c7a8e 100644 --- a/materialx/nodes/__init__.py +++ b/materialx/nodes/__init__.py @@ -56,14 +56,14 @@ def get_mx_node_cls(mx_node): raise KeyError(f"Unable to find MxNode class for {mx_node}") def params_set(node, out_type): - return {f"in_{p.getName()}:{p.getType()}" for p in node.getInputs()} | \ + return {f"in_{p.getName()}:{p.getType()}" for p in node.getActiveInputs()} | \ {out_type} node_params_set = params_set(mx_node, mx_node.getType()) for cls in classes: for nodedef, data_type in cls.get_nodedefs(): - nd_outputs = nodedef.getOutputs() + nd_outputs = nodedef.getActiveOutputs() nd_params_set = params_set(nodedef, 'multioutput' if len(nd_outputs) > 1 else nd_outputs[0].getType()) if node_params_set.issubset(nd_params_set): diff --git a/materialx/nodes/generate_node_classes.py b/materialx/nodes/generate_node_classes.py index 99d052792..01fe613f2 100644 --- a/materialx/nodes/generate_node_classes.py +++ b/materialx/nodes/generate_node_classes.py @@ -145,21 +145,21 @@ def nodedef_data_type(nodedef): node_name = nodedef.getNodeString() if nd_name.startswith('rpr_'): - return nodedef.getOutputs()[0].getType() + return nodedef.getActiveOutputs()[0].getType() m = re.fullmatch(rf'ND_{node_name}_(.+)', nd_name) if m: return m[1] - return nodedef.getOutputs()[0].getType() + return nodedef.getActiveOutputs()[0].getType() def generate_data_type(nodedef): - outputs = nodedef.getOutputs() + outputs = nodedef.getActiveOutputs() if len(outputs) != 1: return f"{{'multitypes': {{'{nodedef.getName()}': None, 'nodedef_name': '{nodedef.getName()}'}}}}" - return f"{{'{nodedef.getOutputs()[0].getType()}': {{'{nodedef.getName()}': None, 'nodedef_name': '{nodedef.getName()}'}}}}" + return f"{{'{nodedef.getActiveOutputs()[0].getType()}': {{'{nodedef.getName()}': None, 'nodedef_name': '{nodedef.getName()}'}}}}" def input_prop_name(nd_type, name): @@ -204,7 +204,7 @@ class {class_name}(MxNode): """) ui_folders = [] - for mx_param in [*nodedef.getParameters(), *nodedef.getInputs()]: + for mx_param in [*nodedef.getParameters(), *nodedef.getActiveInputs()]: f = mx_param.getAttribute("uifolder") if f and f not in ui_folders: ui_folders.append(f) @@ -242,11 +242,11 @@ class {class_name}(MxNode): nd_type = nodedef_data_type(nd) code_strings.append("") - for input in nd.getInputs(): + for input in nd.getActiveInputs(): prop_code = generate_property_code(input, category) code_strings.append(f" {input_prop_name(nd_type, input.getName())}: {prop_code}") - for output in nd.getOutputs(): + for output in nd.getActiveOutputs(): prop_code = generate_property_code(output, category) code_strings.append(f" {output_prop_name(nd_type, output.getName())}: {prop_code}") diff --git a/materialx/nodes/node.py b/materialx/nodes/node.py index c481da005..7c612844b 100644 --- a/materialx/nodes/node.py +++ b/materialx/nodes/node.py @@ -10,6 +10,8 @@ from .. import utils from .. import logging log = logging.Log("nodes.node") +mtlx_documents = {} + class MxNodeInputSocket(bpy.types.NodeSocket): bl_idname = utils.with_prefix('MxNodeInputSocket') @@ -20,7 +22,7 @@ class MxNodeInputSocket(bpy.types.NodeSocket): return nd = node.nodedef - nd_input = nd.getInput(self.name) + nd_input = nd.getActiveInput(self.name) nd_type = nd_input.getType() uiname = utils.get_attr(nd_input, 'uiname', utils.title_str(nd_input.getName())) @@ -36,7 +38,7 @@ class MxNodeInputSocket(bpy.types.NodeSocket): def draw_color(self, context, node): - return utils.get_socket_color(node.nodedef.getInput(self.name).getType() + return utils.get_socket_color(node.nodedef.getActiveInput(self.name).getType() if is_mx_node_valid(node) else 'undefined') @@ -49,16 +51,16 @@ class MxNodeOutputSocket(bpy.types.NodeSocket): return nd = node.nodedef - mx_output = nd.getOutput(self.name) + mx_output = nd.getActiveOutput(self.name) uiname = utils.get_attr(mx_output, 'uiname', utils.title_str(mx_output.getName())) uitype = utils.title_str(mx_output.getType()) - if uiname.lower() == uitype.lower() or len(nd.getOutputs()) == 1: + if uiname.lower() == uitype.lower() or len(nd.getActiveOutputs()) == 1: layout.label(text=uitype) else: layout.label(text=f"{uiname}: {uitype}") def draw_color(self, context, node): - return utils.get_socket_color(node.nodedef.getOutput(self.name).getType() + return utils.get_socket_color(node.nodedef.getActiveOutput(self.name).getType() if is_mx_node_valid(node) else 'undefined') @@ -80,9 +82,14 @@ class MxNode(bpy.types.ShaderNode): def get_nodedef(cls, data_type): if not cls._data_types[data_type]['nd']: # loading nodedefs - doc = mx.createDocument() - search_path = mx.FileSearchPath(str(utils.MX_LIBS_DIR)) - mx.readFromXmlFile(doc, str(utils.ADDON_ROOT_DIR / cls._file_path), searchPath=search_path) + if cls._file_path not in mtlx_documents: + doc = mx.createDocument() + search_path = mx.FileSearchPath(str(utils.MX_LIBS_DIR)) + mx.readFromXmlFile(doc, str(utils.MX_LIBS_DIR / cls._file_path), searchPath=search_path) + mtlx_documents[cls._file_path] = doc + + doc = mtlx_documents[cls._file_path] + for val in cls._data_types.values(): val['nd'] = doc.getNodeDef(val['nd_name']) @@ -100,7 +107,7 @@ class MxNode(bpy.types.ShaderNode): @property def mx_node_path(self): nd = self.nodedef - if '/' in self.name or utils.is_shader_type(nd.getOutputs()[0].getType()): + if '/' in self.name or utils.is_shader_type(nd.getActiveOutputs()[0].getType()): return self.name return f"NG/{self.name}" @@ -126,8 +133,8 @@ class MxNode(bpy.types.ShaderNode): for link in nodetree.links: if hasattr(link.from_socket.node, 'nodedef') and hasattr(link.to_socket.node, 'nodedef'): - socket_from_type = link.from_socket.node.nodedef.getOutput(link.from_socket.name).getType() - socket_to_type = link.to_socket.node.nodedef.getInput(link.to_socket.name).getType() + socket_from_type = link.from_socket.node.nodedef.getActiveOutput(link.from_socket.name).getType() + socket_to_type = link.to_socket.node.nodedef.getActiveInput(link.to_socket.name).getType() if socket_to_type != socket_from_type: link.is_valid = False @@ -140,7 +147,7 @@ class MxNode(bpy.types.ShaderNode): nodedef = self.nodedef for i, nd_input in enumerate(utils.get_nodedef_inputs(nodedef, False)): self.inputs[i].name = nd_input.getName() - for i, nd_output in enumerate(nodedef.getOutputs()): + for i, nd_output in enumerate(nodedef.getActiveOutputs()): self.outputs[i].name = nd_output.getName() def init(self, context): @@ -149,7 +156,7 @@ class MxNode(bpy.types.ShaderNode): for nd_input in utils.get_nodedef_inputs(nodedef, False): self.create_input(nd_input) - for nd_output in nodedef.getOutputs(): + for nd_output in nodedef.getActiveOutputs(): self.create_output(nd_output) if self._ui_folders: @@ -264,7 +271,7 @@ class MxNode(bpy.types.ShaderNode): mx_param = mx_node.addInput(nd_input.getName(), nd_type) utils.set_param_value(mx_param, val, nd_type) - if len(nodedef.getOutputs()) > 1: + if len(nodedef.getActiveOutputs()) > 1: mx_node.setType('multioutput') return mx_node, nd_output @@ -340,10 +347,10 @@ class MxNode(bpy.types.ShaderNode): return getattr(self, self._input_prop_name(name)) def get_nodedef_input(self, in_key: [str, int]): - return self.nodedef.getInput(self.inputs[in_key].name) + return self.nodedef.getActiveInput(self.inputs[in_key].name) def get_nodedef_output(self, out_key: [str, int]): - return self.nodedef.getOutput(self.outputs[out_key].name) + return self.nodedef.getActiveOutput(self.outputs[out_key].name) def set_input_value(self, in_key, value): setattr(self, self._input_prop_name(self.inputs[in_key].name), value) diff --git a/materialx/utils.py b/materialx/utils.py index 4ea474335..84c80877d 100644 --- a/materialx/utils.py +++ b/materialx/utils.py @@ -74,7 +74,7 @@ def set_param_value(mx_param, val, nd_type, nd_output=None): if nd_output: mx_output_name += f'_{nd_output.getName()}' - mx_output = val_nodegraph.getOutput(mx_output_name) + mx_output = val_nodegraph.getActiveOutput(mx_output_name) if not mx_output: mx_output = val_nodegraph.addOutput(mx_output_name, val.getType()) mx_output.setNodeName(node_name) @@ -182,7 +182,7 @@ def parse_value_str(val_str, mx_type, *, first_only=False, is_enum=False): def get_nodedef_inputs(nodedef, uniform=None): - for nd_input in nodedef.getInputs(): + for nd_input in nodedef.getActiveInputs(): if (uniform is True and nd_input.getAttribute('uniform') != 'true') or \ (uniform is False and nd_input.getAttribute('uniform') == 'true'): continue @@ -523,7 +523,7 @@ def import_materialx_from_file(node_tree, doc: mx.Document, file_path): new_mx_nodegraph = next(ng for ng in doc.getNodeGraphs() if ng.getNodeDefString() == nodedef.getName()) - mx_output = new_mx_nodegraph.getOutput(mx_output_name) + mx_output = new_mx_nodegraph.getActiveOutput(mx_output_name) node_name = mx_output.getNodeName() new_mx_node = new_mx_nodegraph.getNode(node_name) @@ -534,9 +534,9 @@ def import_materialx_from_file(node_tree, doc: mx.Document, file_path): node.data_type = data_type nodedef = node.nodedef - for mx_input in mx_node.getInputs(): + for mx_input in mx_node.getActiveInputs(): input_name = mx_input.getName() - nd_input = nodedef.getInput(input_name) + nd_input = nodedef.getActiveInput(input_name) if nd_input.getAttribute('uniform') == 'true': node.set_param_value(input_name, parse_value( node, mx_input.getValue(), mx_input.getType(), file_prefix)) @@ -563,7 +563,7 @@ def import_materialx_from_file(node_tree, doc: mx.Document, file_path): new_node = import_node(new_mx_node) out_name = mx_input.getAttribute('output') - if len(new_node.nodedef.getOutputs()) > 1 and out_name: + if len(new_node.nodedef.getActiveOutputs()) > 1 and out_name: new_node_output = new_node.outputs[out_name] else: new_node_output = new_node.outputs[0] @@ -575,7 +575,7 @@ def import_materialx_from_file(node_tree, doc: mx.Document, file_path): if new_nodegraph_name: mx_output_name = mx_input.getAttribute('output') new_mx_nodegraph = mx_nodegraph.getNodeGraph(new_nodegraph_name) - mx_output = new_mx_nodegraph.getOutput(mx_output_name) + mx_output = new_mx_nodegraph.getActiveOutput(mx_output_name) node_name = mx_output.getNodeName() new_mx_node = new_mx_nodegraph.getNode(node_name) new_node = import_node(new_mx_node, mx_output_name) @@ -583,7 +583,7 @@ def import_materialx_from_file(node_tree, doc: mx.Document, file_path): continue out_name = mx_output.getAttribute('output') - if len(new_node.nodedef.getOutputs()) > 1 and out_name: + if len(new_node.nodedef.getActiveOutputs()) > 1 and out_name: new_node_output = new_node.outputs[out_name] else: new_node_output = new_node.outputs[0] -- 2.30.2 From 7913e6fbaeb3ba3bbb99015ce13ab2af80437c38 Mon Sep 17 00:00:00 2001 From: Georgiy Markelov <42409851+DagerD@users.noreply.github.com> Date: Fri, 2 Dec 2022 02:24:57 +0300 Subject: [PATCH 17/28] Refactoring (#16) Changed description of addon and moved preference's register/unregister functions to preferences.py Co-authored-by: markyandex@gmail.com --- materialx/__init__.py | 19 ++++++------------- materialx/preferences.py | 4 ++++ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/materialx/__init__.py b/materialx/__init__.py index 466690a2e..b62a68378 100644 --- a/materialx/__init__.py +++ b/materialx/__init__.py @@ -2,16 +2,16 @@ # Copyright 2022, AMD """ -MaterialX NodeTree addon + MaterialX online library +MaterialX nodes addon """ bl_info = { - "name": "MaterialX NodeTree", - "description": "MaterialX NodeTree addon + MaterialX online library", + "name": "MaterialX nodes", + "description": "MaterialX nodes addon", "author": "AMD", "version": (1, 0, 0), "blender": (3, 4, 0), - "location": "Editor Type -> MaterialX", + "location": "Editor Type -> Shader Editor", "doc_url": "{BLENDER_MANUAL_URL}/addons/materials/materialx.html", "warning": "Alpha", "support": "TESTING", @@ -21,8 +21,6 @@ bl_info = { ADDON_ALIAS = "materialx" -import bpy - from . import ( preferences, nodes, @@ -34,15 +32,10 @@ from . import logging log = logging.Log("__init__") -register_classes, unregister_classes = bpy.utils.register_classes_factory([ - preferences.AddonPreferences, -]) - - def register(): log("register") - register_classes() + preferences.register() nodes.register() ui.register() @@ -54,4 +47,4 @@ def unregister(): ui.unregister() nodes.unregister() - unregister_classes() + preferences.unregister() diff --git a/materialx/preferences.py b/materialx/preferences.py index 47eeb106e..24d42a78e 100644 --- a/materialx/preferences.py +++ b/materialx/preferences.py @@ -42,3 +42,7 @@ def addon_preferences(): return bpy.context.preferences.addons[ADDON_ALIAS].preferences + +register, unregister = bpy.utils.register_classes_factory([ + AddonPreferences, +]) -- 2.30.2 From 641fdcd5d4d01df6697f2708e5d331c809ab525a Mon Sep 17 00:00:00 2001 From: Bogdan Nagirniak <33626169+bnagirniak@users.noreply.github.com> Date: Mon, 23 Jan 2023 17:47:28 +0200 Subject: [PATCH 18/28] BLEN-294: Assign MaterialX materials (#17) BLEN-321: Fix export to mtlx with dependencies Fixed code in utils.export_to_file() (renamed from export_mx_to_file()). Made code cleanups/improvements. --- materialx/ui.py | 49 +++++++++++------------- materialx/utils.py | 92 ++++++++++++++++++---------------------------- 2 files changed, 57 insertions(+), 84 deletions(-) diff --git a/materialx/ui.py b/materialx/ui.py index 8129ea869..d1a27cf8b 100644 --- a/materialx/ui.py +++ b/materialx/ui.py @@ -10,7 +10,6 @@ import bpy from bpy_extras.io_utils import ImportHelper, ExportHelper from . import utils -from .utils import import_materialx_from_file, export from .preferences import addon_preferences from .utils import logging @@ -39,7 +38,7 @@ class MATERIALX_OP_import_file(bpy.types.Operator, ImportHelper): search_path.append(str(utils.MX_LIBS_DIR)) try: mx.readFromXmlFile(doc, str(mtlx_file)) - import_materialx_from_file(mx_node_tree, doc, mtlx_file) + utils.import_materialx_from_file(mx_node_tree, doc, mtlx_file) except Exception as e: log.error(traceback.format_exc(), mtlx_file) @@ -53,7 +52,6 @@ class MATERIALX_OP_export_file(bpy.types.Operator, ExportHelper): bl_label = "Export to File" bl_description = "Export material as MaterialX node tree to .mtlx file" - # region properties filename_ext = ".mtlx" filepath: bpy.props.StringProperty( @@ -66,52 +64,47 @@ class MATERIALX_OP_export_file(bpy.types.Operator, ExportHelper): default="*.mtlx", options={'HIDDEN'}, ) - is_export_deps: bpy.props.BoolProperty( - name="Include dependencies", - description="Export used MaterialX dependencies", - default=False - ) - is_export_textures: bpy.props.BoolProperty( - name="Export textures", + export_textures: bpy.props.BoolProperty( + name="Export Textures", description="Export bound textures to corresponded folder", default=True ) - is_clean_texture_folder: bpy.props.BoolProperty( - name="Сlean texture folder", - description="Сlean texture folder before export", - default=False - ) texture_dir_name: bpy.props.StringProperty( - name="Folder name", + name="Folder Name", description="Texture folder name used for exporting files", default='textures', maxlen=1024, ) - # endregion + export_deps: bpy.props.BoolProperty( + name="Export Dependencies", + description="Export MaterialX library dependencies", + default=True + ) def execute(self, context): - doc = export(context.material, None) + doc = utils.export(context.material, None) if not doc: return {'CANCELLED'} - utils.export_mx_to_file(doc, self.filepath, - mx_node_tree=None, - # is_export_deps=self.is_export_deps, - is_export_textures=self.is_export_textures, - texture_dir_name=self.texture_dir_name) + utils.export_to_file(doc, self.filepath, + export_textures=self.export_textures, + texture_dir_name=self.texture_dir_name, + export_deps=self.export_deps, + copy_deps=self.export_deps) + log.info(f"Succesfully exported material '{context.material.name}' into {self.filepath}") return {'FINISHED'} def draw(self, context): - # self.layout.prop(self, 'is_export_deps') - col = self.layout.column(align=False) - col.prop(self, 'is_export_textures') + col.prop(self, 'export_textures') row = col.row() - row.enabled = self.is_export_textures + row.enabled = self.export_textures row.prop(self, 'texture_dir_name', text='') + self.layout.prop(self, 'export_deps') + class MATERIALX_OP_export_console(bpy.types.Operator): bl_idname = utils.with_prefix('materialx_export_console') @@ -119,7 +112,7 @@ class MATERIALX_OP_export_console(bpy.types.Operator): bl_description = "Export material as MaterialX node tree to console" def execute(self, context): - doc = export(context.material, context.object) + doc = utils.export(context.material, context.object) if not doc: return {'CANCELLED'} diff --git a/materialx/utils.py b/materialx/utils.py index 84c80877d..ce80a22c1 100644 --- a/materialx/utils.py +++ b/materialx/utils.py @@ -25,10 +25,6 @@ MX_ADDON_LIBS_DIR = ADDON_ROOT_DIR / MX_LIBS_FOLDER NODE_CLASSES_FOLDER = "materialx_nodes" NODE_CLASSES_DIR = ADDON_DATA_DIR / NODE_CLASSES_FOLDER -MATLIB_FOLDER = "matlib" -MATLIB_DIR = ADDON_DATA_DIR / MATLIB_FOLDER -MATLIB_URL = "https://api.matlib.gpuopen.com/api" - TEMP_FOLDER = "bl-materialx" NODE_LAYER_SEPARATION_WIDTH = 280 @@ -246,76 +242,60 @@ def get_socket_color(mx_type): return (0.63, 0.63, 0.63, 1.0) -def export_mx_to_file(doc, filepath, *, mx_node_tree=None, is_export_deps=False, - is_export_textures=False, texture_dir_name='textures', - is_clean_texture_folder=True, is_clean_deps_folders=True): +def export_to_file(doc, filepath, *, export_textures=False, texture_dir_name='textures', + export_deps=False, copy_deps=False): root_dir = Path(filepath).parent + root_dir.mkdir(parents=True, exist_ok=True) - if not os.path.isdir(root_dir): - Path(root_dir).mkdir(parents=True, exist_ok=True) - - if is_export_deps and mx_node_tree: - mx_libs_dir = root_dir / MX_LIBS_FOLDER - if os.path.isdir(mx_libs_dir) and is_clean_deps_folders: - shutil.rmtree(mx_libs_dir) - - # we need to export every deps only once - unique_paths = set(node._file_path for node in mx_node_tree.nodes) - - for mtlx_path in unique_paths: - # defining paths - source_path = MX_LIBS_DIR.parent / mtlx_path - full_dest_path = root_dir / mtlx_path - rel_dest_path = full_dest_path.relative_to(root_dir / MX_LIBS_FOLDER) - dest_path = root_dir / rel_dest_path - - Path(dest_path.parent).mkdir(parents=True, exist_ok=True) - shutil.copy(source_path, dest_path) - - mx.prependXInclude(doc, str(rel_dest_path)) - - if is_export_textures: + if export_textures: texture_dir = root_dir / texture_dir_name - if os.path.isdir(texture_dir) and is_clean_texture_folder: - shutil.rmtree(texture_dir) - image_paths = set() + mx_input_files = (v for v in doc.traverseTree() if isinstance(v, mx.Input) and v.getType() == 'filename') + for mx_input in mx_input_files: + texture_dir.mkdir(parents=True, exist_ok=True) - i = 0 - - input_files = (v for v in doc.traverseTree() if isinstance(v, mx.Input) and v.getType() == 'filename') - for mx_input in input_files: - if not os.path.isdir(texture_dir): - Path(texture_dir).mkdir(parents=True, exist_ok=True) - - mx_value = mx_input.getValue() - if not mx_value: - log.warn(f"Skipping wrong {mx_input.getType()} input value. Expected: path, got {mx_value}") + val = mx_input.getValue() + if not val: + log.warn(f"Skipping wrong {mx_input.getType()} input value. Expected: path, got {val}") continue - source_path = Path(mx_value) - if not os.path.isfile(source_path): + source_path = Path(val) + if not source_path.is_file(): log.warn("Image is missing", source_path) continue + if source_path in image_paths: + continue + dest_path = texture_dir / source_path.name if source_path not in image_paths: - image_paths.update([source_path]) - - if os.path.isfile(dest_path): - i += 1 - dest_path = texture_dir / f"{source_path.stem}_{i}{source_path.suffix}" - else: - dest_path = texture_dir / f"{source_path.stem}{source_path.suffix}" - + image_paths.add(source_path) + dest_path = texture_dir / source_path.name shutil.copy(source_path, dest_path) log(f"Export file {source_path} to {dest_path}: completed successfully") rel_dest_path = dest_path.relative_to(root_dir) - mx_input.setValue(str(rel_dest_path), mx_input.getType()) + mx_input.setValue(rel_dest_path.as_posix(), mx_input.getType()) - mx.writeToXmlFile(doc, filepath) + if export_deps: + from .nodes import get_mx_node_cls + + deps_files = {get_mx_node_cls(mx_node)[0]._file_path + for mx_node in (it for it in doc.traverseTree() if isinstance(it, mx.Node))} + + for deps_file in deps_files: + deps_file = Path(deps_file) + if copy_deps: + rel_path = deps_file.relative_to(deps_file.parent.parent) + dest_path = root_dir / rel_path + dest_path.parent.mkdir(parents=True, exist_ok=True) + shutil.copy(deps_file, dest_path) + deps_file = rel_path + + mx.prependXInclude(doc, str(deps_file)) + + mx.writeToXmlFile(doc, str(filepath)) log(f"Export MaterialX to {filepath}: completed successfully") -- 2.30.2 From ba72037bb57bbd0b1fed01557226e0083bd2f2e1 Mon Sep 17 00:00:00 2001 From: Bogdan Nagirniak <33626169+bnagirniak@users.noreply.github.com> Date: Mon, 6 Feb 2023 17:04:13 +0200 Subject: [PATCH 19/28] Fixed to use materialx folder in blender (#18) --- materialx/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/materialx/utils.py b/materialx/utils.py index ce80a22c1..fbb1bb21d 100644 --- a/materialx/utils.py +++ b/materialx/utils.py @@ -16,7 +16,7 @@ log = logging.Log('utils') ADDON_ROOT_DIR = Path(__file__).parent ADDON_DATA_DIR = Path(bpy.utils.user_resource('SCRIPTS', path=f"addons/{ADDON_ALIAS}_data", create=True)) -BL_DATA_DIR = Path(bpy.utils.resource_path('LOCAL')) / "datafiles/materialx" +BL_DATA_DIR = Path(bpy.utils.resource_path('LOCAL')).parent / "materialx" MX_LIBS_FOLDER = "libraries" MX_LIBS_DIR = BL_DATA_DIR / MX_LIBS_FOLDER -- 2.30.2 From 61dd62cb6d41c3fe1886bbee109bc0faa1165a69 Mon Sep 17 00:00:00 2001 From: "georgiy.m.markelov@gmail.com" Date: Fri, 17 Mar 2023 14:45:33 +0100 Subject: [PATCH 20/28] BLEN-350: Fix error with Add shader node * Fixed generation of MaterialX nodes * Fixed nodes `add` and `mix` * Adjust code for other nodes to fit new requirements **NOTE FOR REVIEWERS** You need to regenerate MaterialX nodes for this PR Pull Request #3 --- materialx/bl_nodes/node_parser.py | 12 ++- materialx/bl_nodes/output.py | 2 +- materialx/bl_nodes/shader.py | 94 ++++++++++++++++++------ materialx/bl_nodes/texture.py | 4 +- materialx/bl_nodes/vector.py | 2 +- materialx/nodes/__init__.py | 8 +- materialx/nodes/generate_node_classes.py | 2 +- 7 files changed, 89 insertions(+), 35 deletions(-) diff --git a/materialx/bl_nodes/node_parser.py b/materialx/bl_nodes/node_parser.py index 1f7513759..c8ab2a0d2 100644 --- a/materialx/bl_nodes/node_parser.py +++ b/materialx/bl_nodes/node_parser.py @@ -32,13 +32,13 @@ class Id: class NodeItem: """This class is a wrapper used for doing operations on MaterialX nodes, floats, and tuples""" - def __init__(self, id: Id, ng: [mx.Document, mx.NodeGraph], data: [tuple, float, mx.Node]): + def __init__(self, id: Id, ng: [mx.Document, mx.NodeGraph], data: [tuple, float, mx.Node], prefix=''): self.id = id self.nodegraph = ng self.data = data self.nodedef = None if isinstance(data, mx.Node): - MxNode_cls, _ = get_mx_node_cls(data) + MxNode_cls, _ = get_mx_node_cls(data, prefix) self.nodedef = MxNode_cls.get_nodedef(self.type) def node_item(self, value): @@ -370,10 +370,14 @@ class NodeParser: return self.get_input_default(in_key) - def create_node(self, node_name, nd_type, inputs=None): + def create_node(self, node_name, nd_type, *, prefix='', inputs=None): nodegraph = utils.get_nodegraph_by_path(self.doc, self.nodegraph_path, True) node = nodegraph.addNode(node_name, f"{node_name}_{self.id()}", nd_type) - node_item = NodeItem(self.id, nodegraph, node) + node_item = NodeItem(self.id, nodegraph, node, prefix) + + mx_type = node_item.nodedef.getType() + if mx_type != nd_type: + node.setType(mx_type) if inputs: node_item.set_inputs(inputs) diff --git a/materialx/bl_nodes/output.py b/materialx/bl_nodes/output.py index fc43a3daa..dead86320 100644 --- a/materialx/bl_nodes/output.py +++ b/materialx/bl_nodes/output.py @@ -23,7 +23,7 @@ class ShaderNodeOutputMaterial(NodeParser): return None - result = self.create_node('surfacematerial', 'material', { + result = self.create_node('surfacematerial', 'material', inputs={ 'surfaceshader': surface, }) diff --git a/materialx/bl_nodes/shader.py b/materialx/bl_nodes/shader.py index 1214a2847..219d32135 100644 --- a/materialx/bl_nodes/shader.py +++ b/materialx/bl_nodes/shader.py @@ -31,6 +31,10 @@ def enabled(val): return True +def get_node_type(node): + return node.getType() if isinstance(node, mx.Node) else node.nodedef.getType() + + class ShaderNodeBsdfPrincipled(NodeParser): nodegraph_path = "" @@ -89,7 +93,7 @@ class ShaderNodeBsdfPrincipled(NodeParser): tangent = self.get_input_link('Tangent') # CREATING STANDARD SURFACE - result = self.create_node('standard_surface', 'surfaceshader', { + result = self.create_node('standard_surface', 'surfaceshader', prefix='BXDF', inputs={ 'base': 1.0, 'base_color': base_color, 'diffuse_roughness': roughness, @@ -162,7 +166,7 @@ class ShaderNodeBsdfDiffuse(NodeParser): # Also tried burley_diffuse_bsdf and oren_nayar_diffuse_bsdf here, but Blender crashes with them # CREATING STANDARD SURFACE - result = self.create_node('standard_surface', 'surfaceshader', { + result = self.create_node('standard_surface', 'surfaceshader', prefix='BXDF', inputs={ 'base_color': color, 'diffuse_roughness': 1.0 - roughness, 'normal': normal, @@ -179,7 +183,7 @@ class ShaderNodeBsdfGlass(NodeParser): normal = self.get_input_link('Normal') # CREATING STANDARD SURFACE - result = self.create_node('standard_surface', 'surfaceshader', { + result = self.create_node('standard_surface', 'surfaceshader', prefix='BXDF', inputs={ 'base': 0.0, 'normal': normal, 'specular': 1.0, @@ -200,7 +204,7 @@ class ShaderNodeEmission(NodeParser): nodegraph_path = "" def export(self): - result = self.create_node('standard_surface', 'surfaceshader') + result = self.create_node('standard_surface', 'surfaceshader', prefix='BXDF') color = self.get_input_value('Color') strength = self.get_input_value('Strength') @@ -222,23 +226,46 @@ class ShaderNodeMixShader(NodeParser): shader1 = self.get_input_link(1) shader2 = self.get_input_link(2) + mix = None + if shader1 is None and shader2 is None: return None - if shader1 is None: - return shader2 - if shader2 is None: - return shader1 + mix = self.create_node('mix', get_node_type(shader1).lower(), prefix='PBR', inputs={ + 'fg': shader1, + 'mix': factor + }) - result = self.create_node('STD_mix', 'surfaceshader', { - 'fg': shader1, - 'bg': shader2, - 'mix': factor + if shader1 is None: + mix = self.create_node('mix', get_node_type(shader2).lower(), prefix='PBR', inputs={ + 'bg': shader2, + 'mix': factor + }) + + if shader1 is not None and shader2 is not None: + shader1_type = get_node_type(shader1) + shader2_type = get_node_type(shader2) + if shader1_type != shader2_type: + log.warn(f'Types of input shaders must be the same.' + f' First shader type: {shader1_type}, second shader type: {shader2_type}') + + return None + + mix = self.create_node('mix', shader1_type.lower(), prefix='PBR', inputs={ + 'fg': shader1, + 'bg': shader2, + 'mix': factor + }) + + if not mix: + return None + + result = self.create_node('surface', 'surfaceshader', prefix='PBR', inputs={ + mix.nodedef.getType().lower(): mix, + 'opacity': 1.0 }) - log.warn(f"Known issue: node doesn't work correctly with {result.nodedef.getName()}", self.material, self.node) - return result @@ -249,20 +276,41 @@ class ShaderNodeAddShader(NodeParser): shader1 = self.get_input_link(0) shader2 = self.get_input_link(1) + add = None + if shader1 is None and shader2 is None: return None - if shader1 is None: - return shader2 - if shader2 is None: - return shader1 + add = self.create_node('add', get_node_type(shader1).lower(), prefix='PBR', inputs={ + 'in1': shader1 + }) - result = self.create_node('STD_add', 'surfaceshader', { - 'in1': shader1, - 'in2': shader2 + if shader1 is None: + add = self.create_node('add', get_node_type(shader2).lower(), prefix='PBR', inputs={ + 'in2': shader2 + }) + + if shader1 is not None and shader2 is not None: + shader1_type = get_node_type(shader1) + shader2_type = get_node_type(shader2) + if shader1_type != shader2_type: + log.warn(f'Types of input shaders must be the same.' + f' First shader type: {shader1_type}, second shader type: {shader2_type}') + + return None + + add = self.create_node('add', shader1_type.lower(), prefix='PBR', inputs={ + 'in1': shader1, + 'in2': shader2 + }) + + if not add: + return None + + result = self.create_node('surface', 'surfaceshader', prefix='PBR', inputs={ + add.nodedef.getType().lower(): add, + 'opacity': 1.0 }) - log.warn(f"Known issue: node doesn't work correctly with {result.nodedef.getName()}", self.material, self.node) - return result diff --git a/materialx/bl_nodes/texture.py b/materialx/bl_nodes/texture.py index eeda9d524..46e607178 100644 --- a/materialx/bl_nodes/texture.py +++ b/materialx/bl_nodes/texture.py @@ -22,9 +22,9 @@ class ShaderNodeTexImage(NodeParser): return image_error_result # TODO use Vector input for UV - uv = self.create_node('texcoord', 'vector2', {}) + uv = self.create_node('texcoord', 'vector2') - result = self.create_node('image', self.out_type, { + result = self.create_node('image', self.out_type, inputs={ 'file': img_path, 'texcoord': uv, }) diff --git a/materialx/bl_nodes/vector.py b/materialx/bl_nodes/vector.py index 3c2e125f3..0ceac5aed 100644 --- a/materialx/bl_nodes/vector.py +++ b/materialx/bl_nodes/vector.py @@ -23,7 +23,7 @@ class ShaderNodeNormalMap(NodeParser): log.warn("Ignoring unsupported UV Map", space, self.node, self.material, "No UV Map will be used") - result = self.create_node('normalmap', 'vector3', { + result = self.create_node('normalmap', 'vector3', inputs={ 'in': color , 'scale': strength, 'space': space.lower(), diff --git a/materialx/nodes/__init__.py b/materialx/nodes/__init__.py index 23e8c7a8e..1c7deb95c 100644 --- a/materialx/nodes/__init__.py +++ b/materialx/nodes/__init__.py @@ -47,17 +47,19 @@ def unregister(): unregister_sockets() -def get_mx_node_cls(mx_node): +def get_mx_node_cls(mx_node, prefix=''): node_name = mx_node.getCategory() - suffix = f'_{node_name}' + if prefix: + suffix = prefix + suffix classes = tuple(cls for cls in mx_node_classes if cls.__name__.endswith(suffix)) + if not classes: raise KeyError(f"Unable to find MxNode class for {mx_node}") def params_set(node, out_type): return {f"in_{p.getName()}:{p.getType()}" for p in node.getActiveInputs()} | \ - {out_type} + {out_type.lower()} node_params_set = params_set(mx_node, mx_node.getType()) diff --git a/materialx/nodes/generate_node_classes.py b/materialx/nodes/generate_node_classes.py index 01fe613f2..f3e897c3d 100644 --- a/materialx/nodes/generate_node_classes.py +++ b/materialx/nodes/generate_node_classes.py @@ -314,7 +314,7 @@ def generate_basic_classes(): gen_code_dir.mkdir(exist_ok=True) files = [ - ('PBR', "PBR", utils.MX_LIBS_DIR / "bxdf/standard_surface.mtlx"), + ('BXDF', "PBR", utils.MX_LIBS_DIR / "bxdf/standard_surface.mtlx"), ('USD', "USD", utils.MX_LIBS_DIR / "bxdf/usd_preview_surface.mtlx"), ('STD', None, utils.MX_LIBS_DIR / "stdlib/stdlib_defs.mtlx"), ('PBR', "PBR", utils.MX_LIBS_DIR / "pbrlib/pbrlib_defs.mtlx"), -- 2.30.2 From bcc93b04526325d1c146d026d14eaf6be3cee418 Mon Sep 17 00:00:00 2001 From: "georgiy.m.markelov@gmail.com" Date: Tue, 11 Apr 2023 17:16:29 +0200 Subject: [PATCH 21/28] BLEN-358: Error in console after closing Blender **TECHNICAL STEPS** Added check for input types and warnings if input has inappropriate type. This check added for `Mix` and `Add` nodes for now. Pull Request https://projects.blender.org/BogdanNagirniak/blender-addons/pulls/4 --- materialx/bl_nodes/shader.py | 57 +++++++++++++++++++++++++++++------- materialx/utils.py | 16 ++++++++++ 2 files changed, 63 insertions(+), 10 deletions(-) diff --git a/materialx/bl_nodes/shader.py b/materialx/bl_nodes/shader.py index 219d32135..6ab39ce68 100644 --- a/materialx/bl_nodes/shader.py +++ b/materialx/bl_nodes/shader.py @@ -5,6 +5,7 @@ import math import MaterialX as mx from .node_parser import NodeParser +from ..utils import get_mx_node_input_types from . import log @@ -227,18 +228,31 @@ class ShaderNodeMixShader(NodeParser): shader2 = self.get_input_link(2) mix = None + input_types = get_mx_node_input_types('mix', 'PBR') if shader1 is None and shader2 is None: return None if shader2 is None: - mix = self.create_node('mix', get_node_type(shader1).lower(), prefix='PBR', inputs={ + shader1_type = get_node_type(shader1) + if shader1_type not in input_types: + log.warn(f'Node {self.node.bl_idname} ({self.material.name_full}) ignored. ' + f'Input type must be of types {input_types}, actual: {shader1_type}') + return shader1 + + mix = self.create_node('mix', shader1_type.lower(), prefix='PBR', inputs={ 'fg': shader1, 'mix': factor }) if shader1 is None: - mix = self.create_node('mix', get_node_type(shader2).lower(), prefix='PBR', inputs={ + shader2_type = get_node_type(shader2) + if shader2_type not in input_types: + log.warn(f'Node {self.node.bl_idname} ({self.material.name_full}) ignored. ' + f'Input type must be of types {input_types}, actual: {shader2_type}') + return shader2 + + mix = self.create_node('mix', shader2_type.lower(), prefix='PBR', inputs={ 'bg': shader2, 'mix': factor }) @@ -247,10 +261,15 @@ class ShaderNodeMixShader(NodeParser): shader1_type = get_node_type(shader1) shader2_type = get_node_type(shader2) if shader1_type != shader2_type: - log.warn(f'Types of input shaders must be the same.' - f' First shader type: {shader1_type}, second shader type: {shader2_type}') + log.warn(f'Types of input shaders must be the same. ' + f'First shader type: {shader1_type}, second shader type: {shader2_type}') - return None + return shader1 + + if shader1_type not in input_types: + log.warn(f'Node {self.node.bl_idname} ({self.material.name_full}) ignored. ' + f'Input type must be of types {input_types}, actual: {shader1_type}, {shader2_type}') + return shader1 mix = self.create_node('mix', shader1_type.lower(), prefix='PBR', inputs={ 'fg': shader1, @@ -277,17 +296,30 @@ class ShaderNodeAddShader(NodeParser): shader2 = self.get_input_link(1) add = None + input_types = get_mx_node_input_types('add', 'PBR') if shader1 is None and shader2 is None: return None if shader2 is None: - add = self.create_node('add', get_node_type(shader1).lower(), prefix='PBR', inputs={ + shader1_type = get_node_type(shader1) + if shader1_type not in input_types: + log.warn(f'Node {self.node.bl_idname} ({self.material.name_full}) ignored. ' + f'Input type must be of types {input_types}, actual: {shader1_type}') + return shader1 + + add = self.create_node('add', shader1_type.lower(), prefix='PBR', inputs={ 'in1': shader1 }) if shader1 is None: - add = self.create_node('add', get_node_type(shader2).lower(), prefix='PBR', inputs={ + shader2_type = get_node_type(shader2) + if shader2_type not in input_types: + log.warn(f'Node {self.node.bl_idname} ({self.material.name_full}) ignored. ' + f'Input type must be of types {input_types}, actual: {shader2_type}') + return shader2 + + add = self.create_node('add', shader2_type.lower(), prefix='PBR', inputs={ 'in2': shader2 }) @@ -295,10 +327,15 @@ class ShaderNodeAddShader(NodeParser): shader1_type = get_node_type(shader1) shader2_type = get_node_type(shader2) if shader1_type != shader2_type: - log.warn(f'Types of input shaders must be the same.' - f' First shader type: {shader1_type}, second shader type: {shader2_type}') + log.warn(f'Types of input shaders must be the same. ' + f'First shader type: {shader1_type}, second shader type: {shader2_type}') - return None + return shader1 + + if shader1_type not in input_types: + log.warn(f'Node {self.node.bl_idname} ({self.material.name_full}) ignored. ' + f'Input type must be of types {input_types}, actual: {shader1_type}, {shader2_type}') + return shader1 add = self.create_node('add', shader1_type.lower(), prefix='PBR', inputs={ 'in1': shader1, diff --git a/materialx/utils.py b/materialx/utils.py index fbb1bb21d..6964386a4 100644 --- a/materialx/utils.py +++ b/materialx/utils.py @@ -662,3 +662,19 @@ def get_output_node(material): node.inputs['surfaceshader'].links), None) return mx_output_node + + +def get_mx_node_input_types(node_name, prefix=''): + from .nodes import mx_node_classes + + suffix = f'_{node_name}' + if prefix: + suffix = prefix + suffix + + input_types = set() + classes = tuple(cls for cls in mx_node_classes if cls.__name__.endswith(suffix)) + for cls in classes: + for nodedef, data_type in cls.get_nodedefs(): + input_types |= {p.getType() for p in nodedef.getActiveInputs()} + + return input_types -- 2.30.2 From c218b6543d7fc20b12063839d657c7d57cada14d Mon Sep 17 00:00:00 2001 From: Bogdan Nagirniak Date: Tue, 11 Apr 2023 17:50:43 +0200 Subject: [PATCH 22/28] Adjust generating node classes and searching of mtlx files ### Purpose Folder `materialx` with mtlx files moved to blender.shared in Windows. ### Technical steps Make FILE_PATH in generated node classes to be local for MX_LIBS_DIR and MX_ADDON_LIBS_DIR. Added blender.shared to BL_DATA_DIR for Windows. Pull Request https://projects.blender.org/BogdanNagirniak/blender-addons/pulls/7 --- materialx/nodes/generate_node_classes.py | 14 ++++++++++++++ materialx/utils.py | 3 +++ 2 files changed, 17 insertions(+) diff --git a/materialx/nodes/generate_node_classes.py b/materialx/nodes/generate_node_classes.py index f3e897c3d..0c39a4596 100644 --- a/materialx/nodes/generate_node_classes.py +++ b/materialx/nodes/generate_node_classes.py @@ -274,7 +274,21 @@ from bpy.props import ( ) from {ADDON_ALIAS}.nodes.node import MxNode +""") + if file_path.is_relative_to(utils.MX_LIBS_DIR): + code_strings.append( +f"""from {ADDON_ALIAS}.utils import MX_LIBS_DIR +FILE_PATH = MX_LIBS_DIR / "{(file_path.relative_to(utils.MX_LIBS_DIR)).as_posix()}" +""") + elif file_path.is_relative_to(utils.MX_ADDON_LIBS_DIR): + code_strings.append( +f"""from {ADDON_ALIAS}.utils import MX_ADDON_LIBS_DIR +FILE_PATH = MX_ADDON_LIBS_DIR / "{(file_path.relative_to(utils.MX_ADDON_LIBS_DIR)).as_posix()}" +""") + else: + code_strings.append( +f""" FILE_PATH = "{file_path.as_posix()}" """) diff --git a/materialx/utils.py b/materialx/utils.py index 6964386a4..b6d20bfa6 100644 --- a/materialx/utils.py +++ b/materialx/utils.py @@ -5,6 +5,7 @@ import os from pathlib import Path import tempfile import shutil +import platform import MaterialX as mx import bpy @@ -17,6 +18,8 @@ log = logging.Log('utils') ADDON_ROOT_DIR = Path(__file__).parent ADDON_DATA_DIR = Path(bpy.utils.user_resource('SCRIPTS', path=f"addons/{ADDON_ALIAS}_data", create=True)) BL_DATA_DIR = Path(bpy.utils.resource_path('LOCAL')).parent / "materialx" +if platform.system() == 'Windows': + BL_DATA_DIR = BL_DATA_DIR.parent / "blender.shared" / BL_DATA_DIR.name MX_LIBS_FOLDER = "libraries" MX_LIBS_DIR = BL_DATA_DIR / MX_LIBS_FOLDER -- 2.30.2 From 1bfb4ef94f6c10ce9a99fb5ebfe635853059aedf Mon Sep 17 00:00:00 2001 From: "georgiy.m.markelov@gmail.com" Date: Fri, 28 Apr 2023 17:50:42 +0200 Subject: [PATCH 23/28] Extend list of supported formats due to enable OIIO for USD. ### Purpose Extend list of supported formats due to enable OIIO for USD. ### Techical steps Extend SUPPORTED_FORMATS with `".exr", ".open_exr", ".tif", ".tiff", ".zfile", ".tx"` Pull Request https://projects.blender.org/BogdanNagirniak/blender-addons/pulls/8 --- materialx/utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/materialx/utils.py b/materialx/utils.py index b6d20bfa6..6ca461313 100644 --- a/materialx/utils.py +++ b/materialx/utils.py @@ -338,7 +338,8 @@ def get_temp_file(suffix, name=None, is_rand=False): return temp_dir() / name -SUPPORTED_FORMATS = {".png", ".jpeg", ".jpg", ".hdr", ".tga", ".bmp"} +SUPPORTED_FORMATS = {".png", ".jpeg", ".jpg", ".hdr", ".tga", ".bmp", + ".exr", ".open_exr", ".tif", ".tiff", ".zfile", ".tx"} DEFAULT_FORMAT = ".hdr" BLENDER_DEFAULT_FORMAT = "HDR" BLENDER_DEFAULT_COLOR_MODE = "RGB" -- 2.30.2 From 3f7a4984e3ba3e986cf56958a8017c6ee5195e14 Mon Sep 17 00:00:00 2001 From: Bogdan Nagirniak Date: Wed, 10 May 2023 18:14:15 +0200 Subject: [PATCH 24/28] Removed alglib .mtlx as not needed ### Purpose `alglib` .mtlx files are not needed, it can be removed. ### Technical steps - Removed `libraries` folder - Removed `alglib_defs.mtlx` from node code generation. Pull Request https://projects.blender.org/BogdanNagirniak/blender-addons/pulls/9 --- materialx/libraries/alglib/alglib_defs.mtlx | 93 ---- materialx/libraries/alglib/alglib_ng.mtlx | 518 -------------------- materialx/nodes/generate_node_classes.py | 1 - 3 files changed, 612 deletions(-) delete mode 100644 materialx/libraries/alglib/alglib_defs.mtlx delete mode 100644 materialx/libraries/alglib/alglib_ng.mtlx diff --git a/materialx/libraries/alglib/alglib_defs.mtlx b/materialx/libraries/alglib/alglib_defs.mtlx deleted file mode 100644 index c80c785b6..000000000 --- a/materialx/libraries/alglib/alglib_defs.mtlx +++ /dev/null @@ -1,93 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/materialx/libraries/alglib/alglib_ng.mtlx b/materialx/libraries/alglib/alglib_ng.mtlx deleted file mode 100644 index 6fb3910c1..000000000 --- a/materialx/libraries/alglib/alglib_ng.mtlx +++ /dev/null @@ -1,518 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/materialx/nodes/generate_node_classes.py b/materialx/nodes/generate_node_classes.py index 0c39a4596..6f46e2d8e 100644 --- a/materialx/nodes/generate_node_classes.py +++ b/materialx/nodes/generate_node_classes.py @@ -332,7 +332,6 @@ def generate_basic_classes(): ('USD', "USD", utils.MX_LIBS_DIR / "bxdf/usd_preview_surface.mtlx"), ('STD', None, utils.MX_LIBS_DIR / "stdlib/stdlib_defs.mtlx"), ('PBR', "PBR", utils.MX_LIBS_DIR / "pbrlib/pbrlib_defs.mtlx"), - ('ALG', "Algorithm", utils.MX_ADDON_LIBS_DIR / "alglib/alglib_defs.mtlx"), ] for prefix, category, file_path in files: -- 2.30.2 From 5a9ceb92dcd30ad410c75bcf79980e1dd7654239 Mon Sep 17 00:00:00 2001 From: Vasyl-Pidhirskyi Date: Tue, 16 May 2023 20:16:21 +0200 Subject: [PATCH 25/28] Transmission color doesn't affect the render result ### Purpose Transmission color doesn't affect the render result. ### Technical steps Used base_color for specular_color, transmission_color, sheen_color, and coat_color instead of DEFAULT_WHITE_COLOR. The difference between standard_surface and Principled BSDF is that the latter shares `base color` between diffuse reflection and refraction components. Removes redundant code. Pull Request https://projects.blender.org/BogdanNagirniak/blender-addons/pulls/11 --- materialx/bl_nodes/shader.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/materialx/bl_nodes/shader.py b/materialx/bl_nodes/shader.py index 6ab39ce68..da2e62603 100644 --- a/materialx/bl_nodes/shader.py +++ b/materialx/bl_nodes/shader.py @@ -9,10 +9,6 @@ from ..utils import get_mx_node_input_types from . import log -SSS_MIN_RADIUS = 0.0001 -DEFAULT_WHITE_COLOR = (1.0, 1.0, 1.0) - - def enabled(val): if val is None: return False @@ -108,7 +104,7 @@ class ShaderNodeBsdfPrincipled(NodeParser): if enabled(specular): result.set_inputs({ 'specular': specular, - 'specular_color': DEFAULT_WHITE_COLOR, + 'specular_color': base_color, 'specular_roughness': roughness, 'specular_IOR': ior, 'specular_anisotropy': anisotropic, @@ -118,7 +114,7 @@ class ShaderNodeBsdfPrincipled(NodeParser): if enabled(transmission): result.set_inputs({ 'transmission': transmission, - 'transmission_color': DEFAULT_WHITE_COLOR, + 'transmission_color': base_color, 'transmission_extra_roughness': transmission_roughness, }) @@ -133,14 +129,14 @@ class ShaderNodeBsdfPrincipled(NodeParser): if enabled(sheen): result.set_inputs({ 'sheen': sheen, - 'sheen_color': DEFAULT_WHITE_COLOR, + 'sheen_color': base_color, 'sheen_roughness': roughness, }) if enabled(clearcoat): result.set_inputs({ 'coat': clearcoat, - 'coat_color': DEFAULT_WHITE_COLOR, + 'coat_color': base_color, 'coat_roughness': clearcoat_roughness, 'coat_IOR': ior, 'coat_anisotropy': anisotropic, -- 2.30.2 From 24186fe54c4e347959fbca8c804808b6c3605378 Mon Sep 17 00:00:00 2001 From: Vasyl-Pidhirskyi Date: Thu, 18 May 2023 08:22:00 +0200 Subject: [PATCH 26/28] MaterialX Realtime results update in viewport render ### Purpose Update after property changes. ### Technical steps Implemented update_prop using self.socket_value_update (from blender docs: "Update after property changes"). Passed update_prop to "update" argument while generating the node's properties. Made adjustments to generate_node_classes.py. ### NOTE Previously generated nodes should be deleted c:\Users\ ...\AppData\Roaming\Blender Foundation\Blender\3.6\scripts\addons\materialx_data\materialx_nodes\ Pull Request https://projects.blender.org/BogdanNagirniak/blender-addons/pulls/10 --- materialx/nodes/generate_node_classes.py | 2 ++ materialx/nodes/node.py | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/materialx/nodes/generate_node_classes.py b/materialx/nodes/generate_node_classes.py index 6f46e2d8e..a2b899a4c 100644 --- a/materialx/nodes/generate_node_classes.py +++ b/materialx/nodes/generate_node_classes.py @@ -133,6 +133,8 @@ def generate_property_code(mx_param, category): if mx_type == 'filename' and category in ("texture2d", "texture3d"): prop_attr_strings.insert(0, "type=bpy.types.Image") + prop_attr_strings.append('update=MxNode.update_prop') + return f"{prop_type}({', '.join(prop_attr_strings)})" diff --git a/materialx/nodes/node.py b/materialx/nodes/node.py index 7c612844b..38f8c068a 100644 --- a/materialx/nodes/node.py +++ b/materialx/nodes/node.py @@ -78,6 +78,9 @@ class MxNode(bpy.types.ShaderNode): _ui_folders = () # list of ui folders mentioned in nodedef category = "" + def update_prop(self, context): + self.socket_value_update(context) + @classmethod def get_nodedef(cls, data_type): if not cls._data_types[data_type]['nd']: @@ -120,6 +123,7 @@ class MxNode(bpy.types.ShaderNode): def update(self): bpy.app.timers.register(self.mark_invalid_links) + self.socket_value_update(bpy.context) def mark_invalid_links(self): if not is_mx_node_valid(self): @@ -150,6 +154,8 @@ class MxNode(bpy.types.ShaderNode): for i, nd_output in enumerate(nodedef.getActiveOutputs()): self.outputs[i].name = nd_output.getName() + self.update_prop(context) + def init(self, context): nodedef = self.nodedef @@ -368,6 +374,9 @@ class MxNode(bpy.types.ShaderNode): if f: self.inputs[i].hide = not getattr(self, self._folder_prop_name(f)) + if context: + self.update_prop(context) + def check_ui_folders(self): if not self._ui_folders: return -- 2.30.2 From 5103b7f446beed7ef0ba3336a7f2646fdfd7c377 Mon Sep 17 00:00:00 2001 From: "georgiy.m.markelov@gmail.com" Date: Tue, 13 Jun 2023 18:51:39 +0200 Subject: [PATCH 27/28] Caching generated image leads to infinite loop in preview render ### Purpose Fix infinite loop in preview render when generated image cached. ### Technical steps Caching images moved from python to C++ part so caching no more triggers Depsgraph updates; Co-authored-by: Bogdan Nagirniak Pull Request https://projects.blender.org/BogdanNagirniak/blender-addons/pulls/15 --- materialx/utils.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/materialx/utils.py b/materialx/utils.py index 6ca461313..31ad5f168 100644 --- a/materialx/utils.py +++ b/materialx/utils.py @@ -103,7 +103,7 @@ def set_param_value(mx_param, val, nd_type, nd_output=None): elif nd_type == 'float': if isinstance(val, NodeItem): val = val.data - + if isinstance(val, tuple): val = val[0] @@ -347,6 +347,14 @@ READONLY_IMAGE_FORMATS = {".dds"} # blender can read these formats, but can't w def cache_image_file(image: bpy.types.Image, cache_check=True): + try: + import _bpy_hydra + return _bpy_hydra.cache_or_get_image_file(bpy.context.as_pointer(), image.as_pointer()) + + except ImportError: + # without bpy_hydra we are going to cache image through python + pass + image_path = Path(image.filepath_from_user()) if not image.packed_file and image.source != 'GENERATED': if not image_path.is_file(): @@ -380,6 +388,7 @@ def cache_image_file(image: bpy.types.Image, cache_check=True): try: image.save_render(filepath=str(temp_path)) + finally: scene.render.image_settings.file_format = user_format scene.render.image_settings.color_mode = user_color_mode @@ -655,15 +664,15 @@ def get_output_node(material): return None bl_output_node = next((node for node in material.node_tree.nodes if - node.bl_idname == 'ShaderNodeOutputMaterial' and - node.is_active_output and node.inputs['Surface'].links), None) + node.bl_idname == 'ShaderNodeOutputMaterial' and + node.is_active_output and node.inputs['Surface'].links), None) if bl_output_node: return bl_output_node mx_output_node = next((node for node in material.node_tree.nodes if - node.bl_idname == with_prefix('MxNode_STD_surfacematerial') and - node.inputs['surfaceshader'].links), None) + node.bl_idname == with_prefix('MxNode_STD_surfacematerial') and + node.inputs['surfaceshader'].links), None) return mx_output_node -- 2.30.2 From 37f156349b691bf3faa47df0bcb63ce67f21045d Mon Sep 17 00:00:00 2001 From: "georgiy.m.markelov@gmail.com" Date: Fri, 28 Jul 2023 16:24:30 +0200 Subject: [PATCH 28/28] Need to improve Normal Maps Quality ### Purpose Need to improve Normal Maps Quality ### Technical steps Improved warning message (as it turned out it's `HdStorm` issue) Pull Request https://projects.blender.org/BogdanNagirniak/blender-addons/pulls/25 --- materialx/bl_nodes/vector.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/materialx/bl_nodes/vector.py b/materialx/bl_nodes/vector.py index 0ceac5aed..7cbf5ba81 100644 --- a/materialx/bl_nodes/vector.py +++ b/materialx/bl_nodes/vector.py @@ -1,6 +1,8 @@ # SPDX-License-Identifier: GPL-2.0-or-later # Copyright 2022, AMD +import bpy + from .node_parser import NodeParser from . import log @@ -19,9 +21,9 @@ class ShaderNodeNormalMap(NodeParser): f"{DEFAULT_SPACE} will be used") space = DEFAULT_SPACE - if space == 'TANGENT': - log.warn("Ignoring unsupported UV Map", space, self.node, self.material, - "No UV Map will be used") + if space == 'TANGENT' and bpy.context.scene.render.engine == 'HYDRA_STORM': + log.warn("Known issue: HdStorm doesn't work good with tangent space. Consider changing to object space", + space, self.node, self.material) result = self.create_node('normalmap', 'vector3', inputs={ 'in': color , -- 2.30.2