From a345d134b865a6cdaf63e10cfc870df49ed841be Mon Sep 17 00:00:00 2001 From: Jonathan Stone Date: Thu, 28 Apr 2022 14:28:47 -0700 Subject: [PATCH] Relative shader includes This changelist adds support for relative includes of shader source files in code generation, and makes all file includes relative within the MaterialX data libraries. This allows clients to use arbitrary naming conventions for the root folder of their MaterialX data libraries, with "libraries" being the default name in the MaterialX distribution. --- .../lights/genglsl/lights_genglsl_impl.mtlx | 6 +- .../genglsl/lib/mx_environment_fis.glsl | 2 +- .../genglsl/lib/mx_environment_none.glsl | 2 +- .../genglsl/lib/mx_environment_prefilter.glsl | 2 +- .../genglsl/lib/mx_microfacet_diffuse.glsl | 2 +- .../genglsl/lib/mx_microfacet_sheen.glsl | 2 +- .../genglsl/lib/mx_microfacet_specular.glsl | 2 +- libraries/pbrlib/genglsl/lib/mx_table.glsl | 4 +- .../genglsl/mx_burley_diffuse_bsdf.glsl | 2 +- .../pbrlib/genglsl/mx_conductor_bsdf.glsl | 2 +- .../pbrlib/genglsl/mx_dielectric_bsdf.glsl | 2 +- .../genglsl/mx_generalized_schlick_bsdf.glsl | 2 +- .../genglsl/mx_oren_nayar_diffuse_bsdf.glsl | 2 +- libraries/pbrlib/genglsl/mx_sheen_bsdf.glsl | 2 +- .../pbrlib/genglsl/mx_subsurface_bsdf.glsl | 2 +- .../pbrlib/genglsl/pbrlib_genglsl_impl.mtlx | 26 +- .../pbrlib/genosl/lib/mx_microfacet_sheen.osl | 2 +- .../genosl/lib/mx_microfacet_specular.osl | 2 +- libraries/pbrlib/genosl/mx_conductor_bsdf.osl | 2 +- .../pbrlib/genosl/mx_dielectric_bsdf.osl | 2 +- .../genosl/mx_generalized_schlick_bsdf.osl | 2 +- libraries/pbrlib/genosl/mx_sheen_bsdf.osl | 2 +- .../pbrlib/genosl/pbrlib_genosl_impl.mtlx | 32 +- .../genglsl/mx_ap1_to_rec709_color3.glsl | 2 +- .../genglsl/mx_ap1_to_rec709_color4.glsl | 2 +- libraries/stdlib/genglsl/mx_burn_color3.glsl | 2 +- libraries/stdlib/genglsl/mx_burn_color4.glsl | 2 +- .../stdlib/genglsl/mx_cellnoise2d_float.glsl | 2 +- .../stdlib/genglsl/mx_cellnoise3d_float.glsl | 2 +- libraries/stdlib/genglsl/mx_dodge_color3.glsl | 2 +- libraries/stdlib/genglsl/mx_dodge_color4.glsl | 2 +- .../genglsl/mx_fractal3d_fa_vector2.glsl | 2 +- .../genglsl/mx_fractal3d_fa_vector3.glsl | 2 +- .../genglsl/mx_fractal3d_fa_vector4.glsl | 2 +- .../stdlib/genglsl/mx_fractal3d_float.glsl | 2 +- .../stdlib/genglsl/mx_fractal3d_vector2.glsl | 2 +- .../stdlib/genglsl/mx_fractal3d_vector3.glsl | 2 +- .../stdlib/genglsl/mx_fractal3d_vector4.glsl | 2 +- .../mx_g22_ap1_to_lin_rec709_color3.glsl | 2 +- .../mx_g22_ap1_to_lin_rec709_color4.glsl | 2 +- .../stdlib/genglsl/mx_hsvtorgb_color3.glsl | 2 +- .../stdlib/genglsl/mx_hsvtorgb_color4.glsl | 2 +- libraries/stdlib/genglsl/mx_image_color3.glsl | 2 +- libraries/stdlib/genglsl/mx_image_color4.glsl | 2 +- libraries/stdlib/genglsl/mx_image_float.glsl | 2 +- .../stdlib/genglsl/mx_image_vector2.glsl | 2 +- .../stdlib/genglsl/mx_image_vector3.glsl | 2 +- .../stdlib/genglsl/mx_image_vector4.glsl | 2 +- .../stdlib/genglsl/mx_noise2d_fa_vector2.glsl | 2 +- .../stdlib/genglsl/mx_noise2d_fa_vector3.glsl | 2 +- .../stdlib/genglsl/mx_noise2d_fa_vector4.glsl | 2 +- .../stdlib/genglsl/mx_noise2d_float.glsl | 2 +- .../stdlib/genglsl/mx_noise2d_vector2.glsl | 2 +- .../stdlib/genglsl/mx_noise2d_vector3.glsl | 2 +- .../stdlib/genglsl/mx_noise2d_vector4.glsl | 2 +- .../stdlib/genglsl/mx_noise3d_fa_vector2.glsl | 2 +- .../stdlib/genglsl/mx_noise3d_fa_vector3.glsl | 2 +- .../stdlib/genglsl/mx_noise3d_fa_vector4.glsl | 2 +- .../stdlib/genglsl/mx_noise3d_float.glsl | 2 +- .../stdlib/genglsl/mx_noise3d_vector2.glsl | 2 +- .../stdlib/genglsl/mx_noise3d_vector3.glsl | 2 +- .../stdlib/genglsl/mx_noise3d_vector4.glsl | 2 +- .../stdlib/genglsl/mx_overlay_color3.glsl | 2 +- .../stdlib/genglsl/mx_overlay_color4.glsl | 2 +- .../stdlib/genglsl/mx_rgbtohsv_color3.glsl | 2 +- .../stdlib/genglsl/mx_rgbtohsv_color4.glsl | 2 +- .../stdlib/genglsl/mx_smoothstep_vec2.glsl | 2 +- .../stdlib/genglsl/mx_smoothstep_vec2FA.glsl | 2 +- .../stdlib/genglsl/mx_smoothstep_vec3.glsl | 2 +- .../stdlib/genglsl/mx_smoothstep_vec3FA.glsl | 2 +- .../stdlib/genglsl/mx_smoothstep_vec4.glsl | 2 +- .../stdlib/genglsl/mx_smoothstep_vec4FA.glsl | 2 +- .../stdlib/genglsl/mx_splitlr_float.glsl | 2 +- .../stdlib/genglsl/mx_splitlr_vector2.glsl | 2 +- .../stdlib/genglsl/mx_splitlr_vector3.glsl | 2 +- .../stdlib/genglsl/mx_splitlr_vector4.glsl | 2 +- .../stdlib/genglsl/mx_splittb_float.glsl | 2 +- .../stdlib/genglsl/mx_splittb_vector2.glsl | 2 +- .../stdlib/genglsl/mx_splittb_vector3.glsl | 2 +- .../stdlib/genglsl/mx_splittb_vector4.glsl | 2 +- .../mx_srgb_texture_to_lin_rec709_color3.glsl | 2 +- .../mx_srgb_texture_to_lin_rec709_color4.glsl | 2 +- .../genglsl/mx_worleynoise2d_float.glsl | 2 +- .../genglsl/mx_worleynoise2d_vector2.glsl | 2 +- .../genglsl/mx_worleynoise2d_vector3.glsl | 2 +- .../genglsl/mx_worleynoise3d_float.glsl | 2 +- .../genglsl/mx_worleynoise3d_vector2.glsl | 2 +- .../genglsl/mx_worleynoise3d_vector3.glsl | 2 +- .../genglsl/stdlib_genglsl_cm_impl.mtlx | 24 +- .../stdlib/genglsl/stdlib_genglsl_impl.mtlx | 754 ++++++++-------- libraries/stdlib/genosl/mx_burn_color3.osl | 2 +- libraries/stdlib/genosl/mx_burn_color4.osl | 2 +- libraries/stdlib/genosl/mx_dodge_color3.osl | 2 +- libraries/stdlib/genosl/mx_dodge_color4.osl | 2 +- libraries/stdlib/genosl/mx_image_color3.osl | 2 +- libraries/stdlib/genosl/mx_image_color4.osl | 2 +- libraries/stdlib/genosl/mx_image_float.osl | 2 +- libraries/stdlib/genosl/mx_image_vector2.osl | 2 +- libraries/stdlib/genosl/mx_image_vector3.osl | 2 +- libraries/stdlib/genosl/mx_image_vector4.osl | 2 +- .../mx_srgb_texture_to_lin_rec709_color3.osl | 2 +- .../mx_srgb_texture_to_lin_rec709_color4.osl | 2 +- .../stdlib/genosl/stdlib_genosl_cm_impl.mtlx | 24 +- .../stdlib/genosl/stdlib_genosl_impl.mtlx | 812 +++++++++--------- .../MaterialXGenGlsl/GlslShaderGenerator.cpp | 20 +- .../MaterialXGenGlsl/Nodes/BlurNodeGlsl.cpp | 2 +- .../Nodes/HeightToNormalNodeGlsl.cpp | 2 +- .../MaterialXGenGlsl/Nodes/LightNodeGlsl.cpp | 2 +- source/MaterialXGenMdl/MdlShaderGenerator.cpp | 4 +- source/MaterialXGenOsl/Nodes/BlurNodeOsl.cpp | 2 +- source/MaterialXGenOsl/OslShaderGenerator.cpp | 10 +- source/MaterialXGenOsl/OslShaderGenerator.h | 2 +- source/MaterialXGenShader/GenContext.h | 33 +- source/MaterialXGenShader/GenOptions.h | 8 + .../Nodes/SourceCodeNode.cpp | 12 +- .../MaterialXGenShader/Nodes/SourceCodeNode.h | 3 + source/MaterialXGenShader/ShaderGenerator.cpp | 11 +- source/MaterialXGenShader/ShaderGenerator.h | 11 +- source/MaterialXGenShader/ShaderStage.cpp | 17 +- source/MaterialXGenShader/ShaderStage.h | 9 +- .../MaterialXGenShader/GenShaderUtil.cpp | 3 +- 121 files changed, 1018 insertions(+), 1007 deletions(-) diff --git a/libraries/lights/genglsl/lights_genglsl_impl.mtlx b/libraries/lights/genglsl/lights_genglsl_impl.mtlx index 61347491bb..b51940d843 100644 --- a/libraries/lights/genglsl/lights_genglsl_impl.mtlx +++ b/libraries/lights/genglsl/lights_genglsl_impl.mtlx @@ -2,12 +2,12 @@ - + - + - + diff --git a/libraries/pbrlib/genglsl/lib/mx_environment_fis.glsl b/libraries/pbrlib/genglsl/lib/mx_environment_fis.glsl index cee193514d..b39697fea4 100644 --- a/libraries/pbrlib/genglsl/lib/mx_environment_fis.glsl +++ b/libraries/pbrlib/genglsl/lib/mx_environment_fis.glsl @@ -1,4 +1,4 @@ -#include "libraries/pbrlib/genglsl/lib/mx_microfacet_specular.glsl" +#include "mx_microfacet_specular.glsl" // https://developer.nvidia.com/gpugems/GPUGems3/gpugems3_ch20.html // Section 20.4 Equation 13 diff --git a/libraries/pbrlib/genglsl/lib/mx_environment_none.glsl b/libraries/pbrlib/genglsl/lib/mx_environment_none.glsl index aeef10d703..f0a1da5989 100644 --- a/libraries/pbrlib/genglsl/lib/mx_environment_none.glsl +++ b/libraries/pbrlib/genglsl/lib/mx_environment_none.glsl @@ -1,4 +1,4 @@ -#include "libraries/pbrlib/genglsl/lib/mx_microfacet_specular.glsl" +#include "mx_microfacet_specular.glsl" vec3 mx_environment_radiance(vec3 N, vec3 V, vec3 X, vec2 roughness, int distribution, FresnelData fd) { diff --git a/libraries/pbrlib/genglsl/lib/mx_environment_prefilter.glsl b/libraries/pbrlib/genglsl/lib/mx_environment_prefilter.glsl index 4a51872a77..b7e0730707 100644 --- a/libraries/pbrlib/genglsl/lib/mx_environment_prefilter.glsl +++ b/libraries/pbrlib/genglsl/lib/mx_environment_prefilter.glsl @@ -1,4 +1,4 @@ -#include "libraries/pbrlib/genglsl/lib/mx_microfacet_specular.glsl" +#include "mx_microfacet_specular.glsl" float mx_latlong_compute_lod(float alpha) { diff --git a/libraries/pbrlib/genglsl/lib/mx_microfacet_diffuse.glsl b/libraries/pbrlib/genglsl/lib/mx_microfacet_diffuse.glsl index e758a179bc..7a0ed28151 100644 --- a/libraries/pbrlib/genglsl/lib/mx_microfacet_diffuse.glsl +++ b/libraries/pbrlib/genglsl/lib/mx_microfacet_diffuse.glsl @@ -1,4 +1,4 @@ -#include "libraries/pbrlib/genglsl/lib/mx_microfacet.glsl" +#include "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. diff --git a/libraries/pbrlib/genglsl/lib/mx_microfacet_sheen.glsl b/libraries/pbrlib/genglsl/lib/mx_microfacet_sheen.glsl index c6adce0fbb..fc32ee05f7 100644 --- a/libraries/pbrlib/genglsl/lib/mx_microfacet_sheen.glsl +++ b/libraries/pbrlib/genglsl/lib/mx_microfacet_sheen.glsl @@ -1,4 +1,4 @@ -#include "libraries/pbrlib/genglsl/lib/mx_microfacet.glsl" +#include "mx_microfacet.glsl" // http://www.aconty.com/pdf/s2017_pbs_imageworks_sheen.pdf // Equation 2 diff --git a/libraries/pbrlib/genglsl/lib/mx_microfacet_specular.glsl b/libraries/pbrlib/genglsl/lib/mx_microfacet_specular.glsl index 4d9fedc77f..9c0dbfcef0 100644 --- a/libraries/pbrlib/genglsl/lib/mx_microfacet_specular.glsl +++ b/libraries/pbrlib/genglsl/lib/mx_microfacet_specular.glsl @@ -1,4 +1,4 @@ -#include "libraries/pbrlib/genglsl/lib/mx_microfacet.glsl" +#include "mx_microfacet.glsl" // Fresnel model options. const int FRESNEL_MODEL_DIELECTRIC = 0; diff --git a/libraries/pbrlib/genglsl/lib/mx_table.glsl b/libraries/pbrlib/genglsl/lib/mx_table.glsl index c0cb6fd793..5d310e90a6 100644 --- a/libraries/pbrlib/genglsl/lib/mx_table.glsl +++ b/libraries/pbrlib/genglsl/lib/mx_table.glsl @@ -1,5 +1,5 @@ -#include "libraries/pbrlib/genglsl/lib/mx_microfacet_sheen.glsl" -#include "libraries/pbrlib/genglsl/lib/mx_microfacet_specular.glsl" +#include "mx_microfacet_sheen.glsl" +#include "mx_microfacet_specular.glsl" vec3 mx_generate_dir_albedo_table() { diff --git a/libraries/pbrlib/genglsl/mx_burley_diffuse_bsdf.glsl b/libraries/pbrlib/genglsl/mx_burley_diffuse_bsdf.glsl index d2ab8af37f..ddf2fe4710 100644 --- a/libraries/pbrlib/genglsl/mx_burley_diffuse_bsdf.glsl +++ b/libraries/pbrlib/genglsl/mx_burley_diffuse_bsdf.glsl @@ -1,4 +1,4 @@ -#include "libraries/pbrlib/genglsl/lib/mx_microfacet_diffuse.glsl" +#include "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, inout BSDF bsdf) { diff --git a/libraries/pbrlib/genglsl/mx_conductor_bsdf.glsl b/libraries/pbrlib/genglsl/mx_conductor_bsdf.glsl index 06f97a9b8b..1b1069298d 100644 --- a/libraries/pbrlib/genglsl/mx_conductor_bsdf.glsl +++ b/libraries/pbrlib/genglsl/mx_conductor_bsdf.glsl @@ -1,4 +1,4 @@ -#include "libraries/pbrlib/genglsl/lib/mx_microfacet_specular.glsl" +#include "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, inout BSDF bsdf) { diff --git a/libraries/pbrlib/genglsl/mx_dielectric_bsdf.glsl b/libraries/pbrlib/genglsl/mx_dielectric_bsdf.glsl index 2b4535066e..456272bd9e 100644 --- a/libraries/pbrlib/genglsl/mx_dielectric_bsdf.glsl +++ b/libraries/pbrlib/genglsl/mx_dielectric_bsdf.glsl @@ -1,4 +1,4 @@ -#include "libraries/pbrlib/genglsl/lib/mx_microfacet_specular.glsl" +#include "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, inout BSDF bsdf) { diff --git a/libraries/pbrlib/genglsl/mx_generalized_schlick_bsdf.glsl b/libraries/pbrlib/genglsl/mx_generalized_schlick_bsdf.glsl index a71ea5adb5..5aab770cbe 100644 --- a/libraries/pbrlib/genglsl/mx_generalized_schlick_bsdf.glsl +++ b/libraries/pbrlib/genglsl/mx_generalized_schlick_bsdf.glsl @@ -1,4 +1,4 @@ -#include "libraries/pbrlib/genglsl/lib/mx_microfacet_specular.glsl" +#include "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, inout BSDF bsdf) { diff --git a/libraries/pbrlib/genglsl/mx_oren_nayar_diffuse_bsdf.glsl b/libraries/pbrlib/genglsl/mx_oren_nayar_diffuse_bsdf.glsl index feb583430b..e32590d1e5 100644 --- a/libraries/pbrlib/genglsl/mx_oren_nayar_diffuse_bsdf.glsl +++ b/libraries/pbrlib/genglsl/mx_oren_nayar_diffuse_bsdf.glsl @@ -1,4 +1,4 @@ -#include "libraries/pbrlib/genglsl/lib/mx_microfacet_diffuse.glsl" +#include "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, inout BSDF bsdf) { diff --git a/libraries/pbrlib/genglsl/mx_sheen_bsdf.glsl b/libraries/pbrlib/genglsl/mx_sheen_bsdf.glsl index 18c46b76ac..7ecd41d8a8 100644 --- a/libraries/pbrlib/genglsl/mx_sheen_bsdf.glsl +++ b/libraries/pbrlib/genglsl/mx_sheen_bsdf.glsl @@ -1,4 +1,4 @@ -#include "libraries/pbrlib/genglsl/lib/mx_microfacet_sheen.glsl" +#include "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, inout BSDF bsdf) { diff --git a/libraries/pbrlib/genglsl/mx_subsurface_bsdf.glsl b/libraries/pbrlib/genglsl/mx_subsurface_bsdf.glsl index 49ac0b6601..5bcf8e2285 100644 --- a/libraries/pbrlib/genglsl/mx_subsurface_bsdf.glsl +++ b/libraries/pbrlib/genglsl/mx_subsurface_bsdf.glsl @@ -1,4 +1,4 @@ -#include "libraries/pbrlib/genglsl/lib/mx_microfacet_diffuse.glsl" +#include "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, inout BSDF bsdf) { diff --git a/libraries/pbrlib/genglsl/pbrlib_genglsl_impl.mtlx b/libraries/pbrlib/genglsl/pbrlib_genglsl_impl.mtlx index c74061455e..8f45114226 100644 --- a/libraries/pbrlib/genglsl/pbrlib_genglsl_impl.mtlx +++ b/libraries/pbrlib/genglsl/pbrlib_genglsl_impl.mtlx @@ -2,31 +2,31 @@ - + - + - + - + - + - + - + - + - + @@ -50,7 +50,7 @@ - + @@ -59,12 +59,12 @@ - + - + - + diff --git a/libraries/pbrlib/genosl/lib/mx_microfacet_sheen.osl b/libraries/pbrlib/genosl/lib/mx_microfacet_sheen.osl index f58866c87d..384c113330 100644 --- a/libraries/pbrlib/genosl/lib/mx_microfacet_sheen.osl +++ b/libraries/pbrlib/genosl/lib/mx_microfacet_sheen.osl @@ -1,4 +1,4 @@ -#include "libraries/pbrlib/genosl/lib/mx_microfacet.osl" +#include "mx_microfacet.osl" // Rational curve fit approximation for the directional albedo of Imageworks sheen. float mx_imageworks_sheen_dir_albedo_analytic(float NdotV, float roughness) diff --git a/libraries/pbrlib/genosl/lib/mx_microfacet_specular.osl b/libraries/pbrlib/genosl/lib/mx_microfacet_specular.osl index 7db4748a5a..1d0e7e1590 100644 --- a/libraries/pbrlib/genosl/lib/mx_microfacet_specular.osl +++ b/libraries/pbrlib/genosl/lib/mx_microfacet_specular.osl @@ -1,4 +1,4 @@ -#include "libraries/pbrlib/genosl/lib/mx_microfacet.osl" +#include "mx_microfacet.osl" // Compute the average of an anisotropic alpha pair. float mx_average_alpha(vector2 alpha) diff --git a/libraries/pbrlib/genosl/mx_conductor_bsdf.osl b/libraries/pbrlib/genosl/mx_conductor_bsdf.osl index 9b74b6386a..e13b38fd7e 100644 --- a/libraries/pbrlib/genosl/mx_conductor_bsdf.osl +++ b/libraries/pbrlib/genosl/mx_conductor_bsdf.osl @@ -1,4 +1,4 @@ -#include "libraries/pbrlib/genosl/lib/mx_microfacet_specular.osl" +#include "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, output BSDF bsdf) { diff --git a/libraries/pbrlib/genosl/mx_dielectric_bsdf.osl b/libraries/pbrlib/genosl/mx_dielectric_bsdf.osl index a2463bf935..fba0199185 100644 --- a/libraries/pbrlib/genosl/mx_dielectric_bsdf.osl +++ b/libraries/pbrlib/genosl/mx_dielectric_bsdf.osl @@ -1,4 +1,4 @@ -#include "libraries/pbrlib/genosl/lib/mx_microfacet_specular.osl" +#include "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, output BSDF bsdf) { diff --git a/libraries/pbrlib/genosl/mx_generalized_schlick_bsdf.osl b/libraries/pbrlib/genosl/mx_generalized_schlick_bsdf.osl index 08aedfe1ce..8650d4eb21 100644 --- a/libraries/pbrlib/genosl/mx_generalized_schlick_bsdf.osl +++ b/libraries/pbrlib/genosl/mx_generalized_schlick_bsdf.osl @@ -1,4 +1,4 @@ -#include "libraries/pbrlib/genosl/lib/mx_microfacet_specular.osl" +#include "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, output BSDF bsdf) { diff --git a/libraries/pbrlib/genosl/mx_sheen_bsdf.osl b/libraries/pbrlib/genosl/mx_sheen_bsdf.osl index 83bfb13185..bf4efe90c4 100644 --- a/libraries/pbrlib/genosl/mx_sheen_bsdf.osl +++ b/libraries/pbrlib/genosl/mx_sheen_bsdf.osl @@ -1,4 +1,4 @@ -#include "libraries/pbrlib/genosl/lib/mx_microfacet_sheen.osl" +#include "lib/mx_microfacet_sheen.osl" // TODO: Vanilla OSL doesn't have a proper sheen closure, // so use 'diffuse' scaled by sheen directional albedo for now. diff --git a/libraries/pbrlib/genosl/pbrlib_genosl_impl.mtlx b/libraries/pbrlib/genosl/pbrlib_genosl_impl.mtlx index 2f553df668..f2748f7cba 100644 --- a/libraries/pbrlib/genosl/pbrlib_genosl_impl.mtlx +++ b/libraries/pbrlib/genosl/pbrlib_genosl_impl.mtlx @@ -2,37 +2,37 @@ - + - + - + - + - + - + - + - + - + - + @@ -53,19 +53,19 @@ - + - - + + - + - + - + diff --git a/libraries/stdlib/genglsl/mx_ap1_to_rec709_color3.glsl b/libraries/stdlib/genglsl/mx_ap1_to_rec709_color3.glsl index c4f282e59d..18b9a088e6 100644 --- a/libraries/stdlib/genglsl/mx_ap1_to_rec709_color3.glsl +++ b/libraries/stdlib/genglsl/mx_ap1_to_rec709_color3.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/lib/mx_transform_color.glsl" +#include "lib/mx_transform_color.glsl" void mx_ap1_to_rec709_color3(vec3 _in, out vec3 result) { diff --git a/libraries/stdlib/genglsl/mx_ap1_to_rec709_color4.glsl b/libraries/stdlib/genglsl/mx_ap1_to_rec709_color4.glsl index 0a4a6824b3..e7c1156194 100644 --- a/libraries/stdlib/genglsl/mx_ap1_to_rec709_color4.glsl +++ b/libraries/stdlib/genglsl/mx_ap1_to_rec709_color4.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/lib/mx_transform_color.glsl" +#include "lib/mx_transform_color.glsl" void mx_ap1_to_rec709_color4(vec4 _in, out vec4 result) { diff --git a/libraries/stdlib/genglsl/mx_burn_color3.glsl b/libraries/stdlib/genglsl/mx_burn_color3.glsl index fc4e11f9eb..10f4008f1a 100644 --- a/libraries/stdlib/genglsl/mx_burn_color3.glsl +++ b/libraries/stdlib/genglsl/mx_burn_color3.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/mx_burn_float.glsl" +#include "mx_burn_float.glsl" void mx_burn_color3(vec3 fg, vec3 bg, float mixval, out vec3 result) { diff --git a/libraries/stdlib/genglsl/mx_burn_color4.glsl b/libraries/stdlib/genglsl/mx_burn_color4.glsl index bc1946475e..df6802a646 100644 --- a/libraries/stdlib/genglsl/mx_burn_color4.glsl +++ b/libraries/stdlib/genglsl/mx_burn_color4.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/mx_burn_float.glsl" +#include "mx_burn_float.glsl" void mx_burn_color4(vec4 fg, vec4 bg, float mixval, out vec4 result) { diff --git a/libraries/stdlib/genglsl/mx_cellnoise2d_float.glsl b/libraries/stdlib/genglsl/mx_cellnoise2d_float.glsl index de0711d599..97d1257e97 100644 --- a/libraries/stdlib/genglsl/mx_cellnoise2d_float.glsl +++ b/libraries/stdlib/genglsl/mx_cellnoise2d_float.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/lib/mx_noise.glsl" +#include "lib/mx_noise.glsl" void mx_cellnoise2d_float(vec2 texcoord, out float result) { diff --git a/libraries/stdlib/genglsl/mx_cellnoise3d_float.glsl b/libraries/stdlib/genglsl/mx_cellnoise3d_float.glsl index 9c7de6e44f..ae4b848fc8 100644 --- a/libraries/stdlib/genglsl/mx_cellnoise3d_float.glsl +++ b/libraries/stdlib/genglsl/mx_cellnoise3d_float.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/lib/mx_noise.glsl" +#include "lib/mx_noise.glsl" void mx_cellnoise3d_float(vec3 position, out float result) { diff --git a/libraries/stdlib/genglsl/mx_dodge_color3.glsl b/libraries/stdlib/genglsl/mx_dodge_color3.glsl index b21f4db432..a8cfd1dff7 100644 --- a/libraries/stdlib/genglsl/mx_dodge_color3.glsl +++ b/libraries/stdlib/genglsl/mx_dodge_color3.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/mx_dodge_float.glsl" +#include "mx_dodge_float.glsl" void mx_dodge_color3(vec3 fg, vec3 bg, float mixval, out vec3 result) { diff --git a/libraries/stdlib/genglsl/mx_dodge_color4.glsl b/libraries/stdlib/genglsl/mx_dodge_color4.glsl index ec9b786de5..c492043ceb 100644 --- a/libraries/stdlib/genglsl/mx_dodge_color4.glsl +++ b/libraries/stdlib/genglsl/mx_dodge_color4.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/mx_dodge_float.glsl" +#include "mx_dodge_float.glsl" void mx_dodge_color4(vec4 fg , vec4 bg , float mixval, out vec4 result) { diff --git a/libraries/stdlib/genglsl/mx_fractal3d_fa_vector2.glsl b/libraries/stdlib/genglsl/mx_fractal3d_fa_vector2.glsl index 3d52d75548..59dbbee127 100644 --- a/libraries/stdlib/genglsl/mx_fractal3d_fa_vector2.glsl +++ b/libraries/stdlib/genglsl/mx_fractal3d_fa_vector2.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/lib/mx_noise.glsl" +#include "lib/mx_noise.glsl" void mx_fractal3d_fa_vector2(float amplitude, int octaves, float lacunarity, float diminish, vec3 position, out vec2 result) { diff --git a/libraries/stdlib/genglsl/mx_fractal3d_fa_vector3.glsl b/libraries/stdlib/genglsl/mx_fractal3d_fa_vector3.glsl index cd445c5e71..d0f30defd4 100644 --- a/libraries/stdlib/genglsl/mx_fractal3d_fa_vector3.glsl +++ b/libraries/stdlib/genglsl/mx_fractal3d_fa_vector3.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/lib/mx_noise.glsl" +#include "lib/mx_noise.glsl" void mx_fractal3d_fa_vector3(float amplitude, int octaves, float lacunarity, float diminish, vec3 position, out vec3 result) { diff --git a/libraries/stdlib/genglsl/mx_fractal3d_fa_vector4.glsl b/libraries/stdlib/genglsl/mx_fractal3d_fa_vector4.glsl index 5c991285f5..b9c66c4465 100644 --- a/libraries/stdlib/genglsl/mx_fractal3d_fa_vector4.glsl +++ b/libraries/stdlib/genglsl/mx_fractal3d_fa_vector4.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/lib/mx_noise.glsl" +#include "lib/mx_noise.glsl" void mx_fractal3d_fa_vector4(float amplitude, int octaves, float lacunarity, float diminish, vec3 position, out vec4 result) { diff --git a/libraries/stdlib/genglsl/mx_fractal3d_float.glsl b/libraries/stdlib/genglsl/mx_fractal3d_float.glsl index 1c3d7e2f82..71d9d0c0a6 100644 --- a/libraries/stdlib/genglsl/mx_fractal3d_float.glsl +++ b/libraries/stdlib/genglsl/mx_fractal3d_float.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/lib/mx_noise.glsl" +#include "lib/mx_noise.glsl" void mx_fractal3d_float(float amplitude, int octaves, float lacunarity, float diminish, vec3 position, out float result) { diff --git a/libraries/stdlib/genglsl/mx_fractal3d_vector2.glsl b/libraries/stdlib/genglsl/mx_fractal3d_vector2.glsl index 1e4ad0e911..6abb247ee7 100644 --- a/libraries/stdlib/genglsl/mx_fractal3d_vector2.glsl +++ b/libraries/stdlib/genglsl/mx_fractal3d_vector2.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/lib/mx_noise.glsl" +#include "lib/mx_noise.glsl" void mx_fractal3d_vector2(vec2 amplitude, int octaves, float lacunarity, float diminish, vec3 position, out vec2 result) { diff --git a/libraries/stdlib/genglsl/mx_fractal3d_vector3.glsl b/libraries/stdlib/genglsl/mx_fractal3d_vector3.glsl index 6eaf79aaad..21843a83e1 100644 --- a/libraries/stdlib/genglsl/mx_fractal3d_vector3.glsl +++ b/libraries/stdlib/genglsl/mx_fractal3d_vector3.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/lib/mx_noise.glsl" +#include "lib/mx_noise.glsl" void mx_fractal3d_vector3(vec3 amplitude, int octaves, float lacunarity, float diminish, vec3 position, out vec3 result) { diff --git a/libraries/stdlib/genglsl/mx_fractal3d_vector4.glsl b/libraries/stdlib/genglsl/mx_fractal3d_vector4.glsl index 7dac32f7b5..16d8db77b2 100644 --- a/libraries/stdlib/genglsl/mx_fractal3d_vector4.glsl +++ b/libraries/stdlib/genglsl/mx_fractal3d_vector4.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/lib/mx_noise.glsl" +#include "lib/mx_noise.glsl" void mx_fractal3d_vector4(vec4 amplitude, int octaves, float lacunarity, float diminish, vec3 position, out vec4 result) { diff --git a/libraries/stdlib/genglsl/mx_g22_ap1_to_lin_rec709_color3.glsl b/libraries/stdlib/genglsl/mx_g22_ap1_to_lin_rec709_color3.glsl index b0efd28a66..62f867cbe8 100644 --- a/libraries/stdlib/genglsl/mx_g22_ap1_to_lin_rec709_color3.glsl +++ b/libraries/stdlib/genglsl/mx_g22_ap1_to_lin_rec709_color3.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/lib/mx_transform_color.glsl" +#include "lib/mx_transform_color.glsl" void mx_g22_ap1_to_lin_rec709_color3(vec3 _in, out vec3 result) { diff --git a/libraries/stdlib/genglsl/mx_g22_ap1_to_lin_rec709_color4.glsl b/libraries/stdlib/genglsl/mx_g22_ap1_to_lin_rec709_color4.glsl index 32991c0916..4e3a9a616b 100644 --- a/libraries/stdlib/genglsl/mx_g22_ap1_to_lin_rec709_color4.glsl +++ b/libraries/stdlib/genglsl/mx_g22_ap1_to_lin_rec709_color4.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/lib/mx_transform_color.glsl" +#include "lib/mx_transform_color.glsl" void mx_g22_ap1_to_lin_rec709_color4(vec4 _in, out vec4 result) { diff --git a/libraries/stdlib/genglsl/mx_hsvtorgb_color3.glsl b/libraries/stdlib/genglsl/mx_hsvtorgb_color3.glsl index 1bc6631b43..535f6529b6 100644 --- a/libraries/stdlib/genglsl/mx_hsvtorgb_color3.glsl +++ b/libraries/stdlib/genglsl/mx_hsvtorgb_color3.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/lib/mx_hsv.glsl" +#include "lib/mx_hsv.glsl" void mx_hsvtorgb_color3(vec3 _in, out vec3 result) { diff --git a/libraries/stdlib/genglsl/mx_hsvtorgb_color4.glsl b/libraries/stdlib/genglsl/mx_hsvtorgb_color4.glsl index 05fc28daf7..6f401bb202 100644 --- a/libraries/stdlib/genglsl/mx_hsvtorgb_color4.glsl +++ b/libraries/stdlib/genglsl/mx_hsvtorgb_color4.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/lib/mx_hsv.glsl" +#include "lib/mx_hsv.glsl" void mx_hsvtorgb_color4(vec4 _in, out vec4 result) { diff --git a/libraries/stdlib/genglsl/mx_image_color3.glsl b/libraries/stdlib/genglsl/mx_image_color3.glsl index 2a5073db9d..802318f475 100644 --- a/libraries/stdlib/genglsl/mx_image_color3.glsl +++ b/libraries/stdlib/genglsl/mx_image_color3.glsl @@ -1,4 +1,4 @@ -#include "$fileTransformUv" +#include "lib/$fileTransformUv" void mx_image_color3(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) { diff --git a/libraries/stdlib/genglsl/mx_image_color4.glsl b/libraries/stdlib/genglsl/mx_image_color4.glsl index 0f5eb1ee9e..e74ad9445f 100644 --- a/libraries/stdlib/genglsl/mx_image_color4.glsl +++ b/libraries/stdlib/genglsl/mx_image_color4.glsl @@ -1,4 +1,4 @@ -#include "$fileTransformUv" +#include "lib/$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) { diff --git a/libraries/stdlib/genglsl/mx_image_float.glsl b/libraries/stdlib/genglsl/mx_image_float.glsl index f1efe5f238..9b831035d2 100644 --- a/libraries/stdlib/genglsl/mx_image_float.glsl +++ b/libraries/stdlib/genglsl/mx_image_float.glsl @@ -1,4 +1,4 @@ -#include "$fileTransformUv" +#include "lib/$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) { diff --git a/libraries/stdlib/genglsl/mx_image_vector2.glsl b/libraries/stdlib/genglsl/mx_image_vector2.glsl index 38739fe8d3..124cb09287 100644 --- a/libraries/stdlib/genglsl/mx_image_vector2.glsl +++ b/libraries/stdlib/genglsl/mx_image_vector2.glsl @@ -1,4 +1,4 @@ -#include "$fileTransformUv" +#include "lib/$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) { diff --git a/libraries/stdlib/genglsl/mx_image_vector3.glsl b/libraries/stdlib/genglsl/mx_image_vector3.glsl index dbb7b26a21..840e60fe6f 100644 --- a/libraries/stdlib/genglsl/mx_image_vector3.glsl +++ b/libraries/stdlib/genglsl/mx_image_vector3.glsl @@ -1,4 +1,4 @@ -#include "$fileTransformUv" +#include "lib/$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) { diff --git a/libraries/stdlib/genglsl/mx_image_vector4.glsl b/libraries/stdlib/genglsl/mx_image_vector4.glsl index a1fc7ffda2..f4b61d83f0 100644 --- a/libraries/stdlib/genglsl/mx_image_vector4.glsl +++ b/libraries/stdlib/genglsl/mx_image_vector4.glsl @@ -1,4 +1,4 @@ -#include "$fileTransformUv" +#include "lib/$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) { diff --git a/libraries/stdlib/genglsl/mx_noise2d_fa_vector2.glsl b/libraries/stdlib/genglsl/mx_noise2d_fa_vector2.glsl index cf20a6ecd5..f5a81565d7 100644 --- a/libraries/stdlib/genglsl/mx_noise2d_fa_vector2.glsl +++ b/libraries/stdlib/genglsl/mx_noise2d_fa_vector2.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/lib/mx_noise.glsl" +#include "lib/mx_noise.glsl" void mx_noise2d_fa_vector2(float amplitude, float pivot, vec2 texcoord, out vec2 result) { diff --git a/libraries/stdlib/genglsl/mx_noise2d_fa_vector3.glsl b/libraries/stdlib/genglsl/mx_noise2d_fa_vector3.glsl index 6b55424bea..0735965ca0 100644 --- a/libraries/stdlib/genglsl/mx_noise2d_fa_vector3.glsl +++ b/libraries/stdlib/genglsl/mx_noise2d_fa_vector3.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/lib/mx_noise.glsl" +#include "lib/mx_noise.glsl" void mx_noise2d_fa_vector3(float amplitude, float pivot, vec2 texcoord, out vec3 result) { diff --git a/libraries/stdlib/genglsl/mx_noise2d_fa_vector4.glsl b/libraries/stdlib/genglsl/mx_noise2d_fa_vector4.glsl index acf1f93bdd..6d51a59e4a 100644 --- a/libraries/stdlib/genglsl/mx_noise2d_fa_vector4.glsl +++ b/libraries/stdlib/genglsl/mx_noise2d_fa_vector4.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/lib/mx_noise.glsl" +#include "lib/mx_noise.glsl" void mx_noise2d_fa_vector4(float amplitude, float pivot, vec2 texcoord, out vec4 result) { diff --git a/libraries/stdlib/genglsl/mx_noise2d_float.glsl b/libraries/stdlib/genglsl/mx_noise2d_float.glsl index 517d493a01..4949083720 100644 --- a/libraries/stdlib/genglsl/mx_noise2d_float.glsl +++ b/libraries/stdlib/genglsl/mx_noise2d_float.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/lib/mx_noise.glsl" +#include "lib/mx_noise.glsl" void mx_noise2d_float(float amplitude, float pivot, vec2 texcoord, out float result) { diff --git a/libraries/stdlib/genglsl/mx_noise2d_vector2.glsl b/libraries/stdlib/genglsl/mx_noise2d_vector2.glsl index adcc3d58af..a6c890f551 100644 --- a/libraries/stdlib/genglsl/mx_noise2d_vector2.glsl +++ b/libraries/stdlib/genglsl/mx_noise2d_vector2.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/lib/mx_noise.glsl" +#include "lib/mx_noise.glsl" void mx_noise2d_vector2(vec2 amplitude, float pivot, vec2 texcoord, out vec2 result) { diff --git a/libraries/stdlib/genglsl/mx_noise2d_vector3.glsl b/libraries/stdlib/genglsl/mx_noise2d_vector3.glsl index 33373ac15b..f965e159a9 100644 --- a/libraries/stdlib/genglsl/mx_noise2d_vector3.glsl +++ b/libraries/stdlib/genglsl/mx_noise2d_vector3.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/lib/mx_noise.glsl" +#include "lib/mx_noise.glsl" void mx_noise2d_vector3(vec3 amplitude, float pivot, vec2 texcoord, out vec3 result) { diff --git a/libraries/stdlib/genglsl/mx_noise2d_vector4.glsl b/libraries/stdlib/genglsl/mx_noise2d_vector4.glsl index 789ebae3d1..3a723962e3 100644 --- a/libraries/stdlib/genglsl/mx_noise2d_vector4.glsl +++ b/libraries/stdlib/genglsl/mx_noise2d_vector4.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/lib/mx_noise.glsl" +#include "lib/mx_noise.glsl" void mx_noise2d_vector4(vec4 amplitude, float pivot, vec2 texcoord, out vec4 result) { diff --git a/libraries/stdlib/genglsl/mx_noise3d_fa_vector2.glsl b/libraries/stdlib/genglsl/mx_noise3d_fa_vector2.glsl index fe049dde26..06d91f9135 100644 --- a/libraries/stdlib/genglsl/mx_noise3d_fa_vector2.glsl +++ b/libraries/stdlib/genglsl/mx_noise3d_fa_vector2.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/lib/mx_noise.glsl" +#include "lib/mx_noise.glsl" void mx_noise3d_fa_vector2(float amplitude, float pivot, vec3 position, out vec2 result) { diff --git a/libraries/stdlib/genglsl/mx_noise3d_fa_vector3.glsl b/libraries/stdlib/genglsl/mx_noise3d_fa_vector3.glsl index ce665e94b4..168bf572f1 100644 --- a/libraries/stdlib/genglsl/mx_noise3d_fa_vector3.glsl +++ b/libraries/stdlib/genglsl/mx_noise3d_fa_vector3.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/lib/mx_noise.glsl" +#include "lib/mx_noise.glsl" void mx_noise3d_fa_vector3(float amplitude, float pivot, vec3 position, out vec3 result) { diff --git a/libraries/stdlib/genglsl/mx_noise3d_fa_vector4.glsl b/libraries/stdlib/genglsl/mx_noise3d_fa_vector4.glsl index 7f9b2bac21..680410f9d3 100644 --- a/libraries/stdlib/genglsl/mx_noise3d_fa_vector4.glsl +++ b/libraries/stdlib/genglsl/mx_noise3d_fa_vector4.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/lib/mx_noise.glsl" +#include "lib/mx_noise.glsl" void mx_noise3d_fa_vector4(float amplitude, float pivot, vec3 position, out vec4 result) { diff --git a/libraries/stdlib/genglsl/mx_noise3d_float.glsl b/libraries/stdlib/genglsl/mx_noise3d_float.glsl index 4f05c70020..f30e3a264c 100644 --- a/libraries/stdlib/genglsl/mx_noise3d_float.glsl +++ b/libraries/stdlib/genglsl/mx_noise3d_float.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/lib/mx_noise.glsl" +#include "lib/mx_noise.glsl" void mx_noise3d_float(float amplitude, float pivot, vec3 position, out float result) { diff --git a/libraries/stdlib/genglsl/mx_noise3d_vector2.glsl b/libraries/stdlib/genglsl/mx_noise3d_vector2.glsl index 1f8b101350..aa22814353 100644 --- a/libraries/stdlib/genglsl/mx_noise3d_vector2.glsl +++ b/libraries/stdlib/genglsl/mx_noise3d_vector2.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/lib/mx_noise.glsl" +#include "lib/mx_noise.glsl" void mx_noise3d_vector2(vec2 amplitude, float pivot, vec3 position, out vec2 result) { diff --git a/libraries/stdlib/genglsl/mx_noise3d_vector3.glsl b/libraries/stdlib/genglsl/mx_noise3d_vector3.glsl index c5ea6105ff..f23313aadf 100644 --- a/libraries/stdlib/genglsl/mx_noise3d_vector3.glsl +++ b/libraries/stdlib/genglsl/mx_noise3d_vector3.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/lib/mx_noise.glsl" +#include "lib/mx_noise.glsl" void mx_noise3d_vector3(vec3 amplitude, float pivot, vec3 position, out vec3 result) { diff --git a/libraries/stdlib/genglsl/mx_noise3d_vector4.glsl b/libraries/stdlib/genglsl/mx_noise3d_vector4.glsl index 7c1552a09e..9c8cfd98dd 100644 --- a/libraries/stdlib/genglsl/mx_noise3d_vector4.glsl +++ b/libraries/stdlib/genglsl/mx_noise3d_vector4.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/lib/mx_noise.glsl" +#include "lib/mx_noise.glsl" void mx_noise3d_vector4(vec4 amplitude, float pivot, vec3 position, out vec4 result) { diff --git a/libraries/stdlib/genglsl/mx_overlay_color3.glsl b/libraries/stdlib/genglsl/mx_overlay_color3.glsl index b62d653740..3b6ae67804 100644 --- a/libraries/stdlib/genglsl/mx_overlay_color3.glsl +++ b/libraries/stdlib/genglsl/mx_overlay_color3.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/mx_overlay.glsl" +#include "mx_overlay.glsl" void mx_overlay_color3(vec3 fg, vec3 bg, float mix, out vec3 result) { diff --git a/libraries/stdlib/genglsl/mx_overlay_color4.glsl b/libraries/stdlib/genglsl/mx_overlay_color4.glsl index 5f129b4188..411e0da372 100644 --- a/libraries/stdlib/genglsl/mx_overlay_color4.glsl +++ b/libraries/stdlib/genglsl/mx_overlay_color4.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/mx_overlay.glsl" +#include "mx_overlay.glsl" void mx_overlay_color4(vec4 fg, vec4 bg, float mix, out vec4 result) { diff --git a/libraries/stdlib/genglsl/mx_rgbtohsv_color3.glsl b/libraries/stdlib/genglsl/mx_rgbtohsv_color3.glsl index 4456e1b8e8..701221c616 100644 --- a/libraries/stdlib/genglsl/mx_rgbtohsv_color3.glsl +++ b/libraries/stdlib/genglsl/mx_rgbtohsv_color3.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/lib/mx_hsv.glsl" +#include "lib/mx_hsv.glsl" void mx_rgbtohsv_color3(vec3 _in, out vec3 result) { diff --git a/libraries/stdlib/genglsl/mx_rgbtohsv_color4.glsl b/libraries/stdlib/genglsl/mx_rgbtohsv_color4.glsl index 7f4ab246b9..e4e6e001b7 100644 --- a/libraries/stdlib/genglsl/mx_rgbtohsv_color4.glsl +++ b/libraries/stdlib/genglsl/mx_rgbtohsv_color4.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/lib/mx_hsv.glsl" +#include "lib/mx_hsv.glsl" void mx_rgbtohsv_color4(vec4 _in, out vec4 result) { diff --git a/libraries/stdlib/genglsl/mx_smoothstep_vec2.glsl b/libraries/stdlib/genglsl/mx_smoothstep_vec2.glsl index b621a9600f..c46152e3fd 100644 --- a/libraries/stdlib/genglsl/mx_smoothstep_vec2.glsl +++ b/libraries/stdlib/genglsl/mx_smoothstep_vec2.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/mx_smoothstep_float.glsl" +#include "mx_smoothstep_float.glsl" void mx_smoothstep_vec2(vec2 val, vec2 low, vec2 high, out vec2 result) { diff --git a/libraries/stdlib/genglsl/mx_smoothstep_vec2FA.glsl b/libraries/stdlib/genglsl/mx_smoothstep_vec2FA.glsl index e419ea09c2..0b16d99e19 100644 --- a/libraries/stdlib/genglsl/mx_smoothstep_vec2FA.glsl +++ b/libraries/stdlib/genglsl/mx_smoothstep_vec2FA.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/mx_smoothstep_float.glsl" +#include "mx_smoothstep_float.glsl" void mx_smoothstep_vec2FA(vec2 val, float low, float high, out vec2 result) { diff --git a/libraries/stdlib/genglsl/mx_smoothstep_vec3.glsl b/libraries/stdlib/genglsl/mx_smoothstep_vec3.glsl index 535fcfa3b0..ce15fcddfd 100644 --- a/libraries/stdlib/genglsl/mx_smoothstep_vec3.glsl +++ b/libraries/stdlib/genglsl/mx_smoothstep_vec3.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/mx_smoothstep_float.glsl" +#include "mx_smoothstep_float.glsl" void mx_smoothstep_vec3(vec3 val, vec3 low, vec3 high, out vec3 result) { diff --git a/libraries/stdlib/genglsl/mx_smoothstep_vec3FA.glsl b/libraries/stdlib/genglsl/mx_smoothstep_vec3FA.glsl index 1b0ee5248a..ffc913e682 100644 --- a/libraries/stdlib/genglsl/mx_smoothstep_vec3FA.glsl +++ b/libraries/stdlib/genglsl/mx_smoothstep_vec3FA.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/mx_smoothstep_float.glsl" +#include "mx_smoothstep_float.glsl" void mx_smoothstep_vec3FA(vec3 val, float low, float high, out vec3 result) { diff --git a/libraries/stdlib/genglsl/mx_smoothstep_vec4.glsl b/libraries/stdlib/genglsl/mx_smoothstep_vec4.glsl index 155d49ebef..04609b6073 100644 --- a/libraries/stdlib/genglsl/mx_smoothstep_vec4.glsl +++ b/libraries/stdlib/genglsl/mx_smoothstep_vec4.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/mx_smoothstep_float.glsl" +#include "mx_smoothstep_float.glsl" void mx_smoothstep_vec4(vec4 val, vec4 low, vec4 high, out vec4 result) { diff --git a/libraries/stdlib/genglsl/mx_smoothstep_vec4FA.glsl b/libraries/stdlib/genglsl/mx_smoothstep_vec4FA.glsl index f9e7dbeea5..e001efd86a 100644 --- a/libraries/stdlib/genglsl/mx_smoothstep_vec4FA.glsl +++ b/libraries/stdlib/genglsl/mx_smoothstep_vec4FA.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/mx_smoothstep_float.glsl" +#include "mx_smoothstep_float.glsl" void mx_smoothstep_vec4FA(vec4 val, float low, float high, out vec4 result) { diff --git a/libraries/stdlib/genglsl/mx_splitlr_float.glsl b/libraries/stdlib/genglsl/mx_splitlr_float.glsl index 11df7449e6..7331c480ca 100644 --- a/libraries/stdlib/genglsl/mx_splitlr_float.glsl +++ b/libraries/stdlib/genglsl/mx_splitlr_float.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/mx_aastep.glsl" +#include "mx_aastep.glsl" void mx_splitlr_float(float valuel, float valuer, float center, vec2 texcoord, out float result) { diff --git a/libraries/stdlib/genglsl/mx_splitlr_vector2.glsl b/libraries/stdlib/genglsl/mx_splitlr_vector2.glsl index 6ba2af0112..820ac09f28 100644 --- a/libraries/stdlib/genglsl/mx_splitlr_vector2.glsl +++ b/libraries/stdlib/genglsl/mx_splitlr_vector2.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/mx_aastep.glsl" +#include "mx_aastep.glsl" void mx_splitlr_vector2(vec2 valuel, vec2 valuer, float center, vec2 texcoord, out vec2 result) { diff --git a/libraries/stdlib/genglsl/mx_splitlr_vector3.glsl b/libraries/stdlib/genglsl/mx_splitlr_vector3.glsl index c37cc074db..7ac28b4477 100644 --- a/libraries/stdlib/genglsl/mx_splitlr_vector3.glsl +++ b/libraries/stdlib/genglsl/mx_splitlr_vector3.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/mx_aastep.glsl" +#include "mx_aastep.glsl" void mx_splitlr_vector3(vec3 valuel, vec3 valuer, float center, vec2 texcoord, out vec3 result) { diff --git a/libraries/stdlib/genglsl/mx_splitlr_vector4.glsl b/libraries/stdlib/genglsl/mx_splitlr_vector4.glsl index 00201ed841..7edc7261ae 100644 --- a/libraries/stdlib/genglsl/mx_splitlr_vector4.glsl +++ b/libraries/stdlib/genglsl/mx_splitlr_vector4.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/mx_aastep.glsl" +#include "mx_aastep.glsl" void mx_splitlr_vector4(vec4 valuel, vec4 valuer, float center, vec2 texcoord, out vec4 result) { diff --git a/libraries/stdlib/genglsl/mx_splittb_float.glsl b/libraries/stdlib/genglsl/mx_splittb_float.glsl index dbe20239a5..31b49927bb 100644 --- a/libraries/stdlib/genglsl/mx_splittb_float.glsl +++ b/libraries/stdlib/genglsl/mx_splittb_float.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/mx_aastep.glsl" +#include "mx_aastep.glsl" void mx_splittb_float(float valuet, float valueb, float center, vec2 texcoord, out float result) { diff --git a/libraries/stdlib/genglsl/mx_splittb_vector2.glsl b/libraries/stdlib/genglsl/mx_splittb_vector2.glsl index a6acb9a24a..12b0bcf3d8 100644 --- a/libraries/stdlib/genglsl/mx_splittb_vector2.glsl +++ b/libraries/stdlib/genglsl/mx_splittb_vector2.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/mx_aastep.glsl" +#include "mx_aastep.glsl" void mx_splittb_vector2(vec2 valuet, vec2 valueb, float center, vec2 texcoord, out vec2 result) { diff --git a/libraries/stdlib/genglsl/mx_splittb_vector3.glsl b/libraries/stdlib/genglsl/mx_splittb_vector3.glsl index 4676694ef7..ff468b3d7e 100644 --- a/libraries/stdlib/genglsl/mx_splittb_vector3.glsl +++ b/libraries/stdlib/genglsl/mx_splittb_vector3.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/mx_aastep.glsl" +#include "mx_aastep.glsl" void mx_splittb_vector3(vec3 valuet, vec3 valueb, float center, vec2 texcoord, out vec3 result) { diff --git a/libraries/stdlib/genglsl/mx_splittb_vector4.glsl b/libraries/stdlib/genglsl/mx_splittb_vector4.glsl index 198744c7b0..97fa787af4 100644 --- a/libraries/stdlib/genglsl/mx_splittb_vector4.glsl +++ b/libraries/stdlib/genglsl/mx_splittb_vector4.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/mx_aastep.glsl" +#include "mx_aastep.glsl" void mx_splittb_vector4(vec4 valuet, vec4 valueb, float center, vec2 texcoord, out vec4 result) { diff --git a/libraries/stdlib/genglsl/mx_srgb_texture_to_lin_rec709_color3.glsl b/libraries/stdlib/genglsl/mx_srgb_texture_to_lin_rec709_color3.glsl index 94446d840e..c9db445b10 100644 --- a/libraries/stdlib/genglsl/mx_srgb_texture_to_lin_rec709_color3.glsl +++ b/libraries/stdlib/genglsl/mx_srgb_texture_to_lin_rec709_color3.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/lib/mx_transform_color.glsl" +#include "lib/mx_transform_color.glsl" void mx_srgb_texture_to_lin_rec709_color3(vec3 _in, out vec3 result) { diff --git a/libraries/stdlib/genglsl/mx_srgb_texture_to_lin_rec709_color4.glsl b/libraries/stdlib/genglsl/mx_srgb_texture_to_lin_rec709_color4.glsl index 5109c21eaa..e79887fac6 100644 --- a/libraries/stdlib/genglsl/mx_srgb_texture_to_lin_rec709_color4.glsl +++ b/libraries/stdlib/genglsl/mx_srgb_texture_to_lin_rec709_color4.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/lib/mx_transform_color.glsl" +#include "lib/mx_transform_color.glsl" void mx_srgb_texture_to_lin_rec709_color4(vec4 _in, out vec4 result) { diff --git a/libraries/stdlib/genglsl/mx_worleynoise2d_float.glsl b/libraries/stdlib/genglsl/mx_worleynoise2d_float.glsl index 5753975c8b..75368e4f38 100644 --- a/libraries/stdlib/genglsl/mx_worleynoise2d_float.glsl +++ b/libraries/stdlib/genglsl/mx_worleynoise2d_float.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/lib/mx_noise.glsl" +#include "lib/mx_noise.glsl" void mx_worleynoise2d_float(vec2 texcoord, float jitter, out float result) { diff --git a/libraries/stdlib/genglsl/mx_worleynoise2d_vector2.glsl b/libraries/stdlib/genglsl/mx_worleynoise2d_vector2.glsl index 6bc8c48412..1a63c0c220 100644 --- a/libraries/stdlib/genglsl/mx_worleynoise2d_vector2.glsl +++ b/libraries/stdlib/genglsl/mx_worleynoise2d_vector2.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/lib/mx_noise.glsl" +#include "lib/mx_noise.glsl" void mx_worleynoise2d_vector2(vec2 texcoord, float jitter, out vec2 result) { diff --git a/libraries/stdlib/genglsl/mx_worleynoise2d_vector3.glsl b/libraries/stdlib/genglsl/mx_worleynoise2d_vector3.glsl index d857dcdd9b..ee4ce42b58 100644 --- a/libraries/stdlib/genglsl/mx_worleynoise2d_vector3.glsl +++ b/libraries/stdlib/genglsl/mx_worleynoise2d_vector3.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/lib/mx_noise.glsl" +#include "lib/mx_noise.glsl" void mx_worleynoise2d_vector3(vec2 texcoord, float jitter, out vec3 result) { diff --git a/libraries/stdlib/genglsl/mx_worleynoise3d_float.glsl b/libraries/stdlib/genglsl/mx_worleynoise3d_float.glsl index 86b3df1d54..738d2f6a77 100644 --- a/libraries/stdlib/genglsl/mx_worleynoise3d_float.glsl +++ b/libraries/stdlib/genglsl/mx_worleynoise3d_float.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/lib/mx_noise.glsl" +#include "lib/mx_noise.glsl" void mx_worleynoise3d_float(vec3 position, float jitter, out float result) { diff --git a/libraries/stdlib/genglsl/mx_worleynoise3d_vector2.glsl b/libraries/stdlib/genglsl/mx_worleynoise3d_vector2.glsl index 064b1b0aae..22bfe8d03d 100644 --- a/libraries/stdlib/genglsl/mx_worleynoise3d_vector2.glsl +++ b/libraries/stdlib/genglsl/mx_worleynoise3d_vector2.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/lib/mx_noise.glsl" +#include "lib/mx_noise.glsl" void mx_worleynoise3d_vector2(vec3 position, float jitter, out vec2 result) { diff --git a/libraries/stdlib/genglsl/mx_worleynoise3d_vector3.glsl b/libraries/stdlib/genglsl/mx_worleynoise3d_vector3.glsl index 16426fd2c1..ac6f7121c6 100644 --- a/libraries/stdlib/genglsl/mx_worleynoise3d_vector3.glsl +++ b/libraries/stdlib/genglsl/mx_worleynoise3d_vector3.glsl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genglsl/lib/mx_noise.glsl" +#include "lib/mx_noise.glsl" void mx_worleynoise3d_vector3(vec3 position, float jitter, out vec3 result) { diff --git a/libraries/stdlib/genglsl/stdlib_genglsl_cm_impl.mtlx b/libraries/stdlib/genglsl/stdlib_genglsl_cm_impl.mtlx index a6ac39201a..da01808929 100644 --- a/libraries/stdlib/genglsl/stdlib_genglsl_cm_impl.mtlx +++ b/libraries/stdlib/genglsl/stdlib_genglsl_cm_impl.mtlx @@ -5,20 +5,20 @@ - - - - - - + + + + + + - - + + - - + + - - + + diff --git a/libraries/stdlib/genglsl/stdlib_genglsl_impl.mtlx b/libraries/stdlib/genglsl/stdlib_genglsl_impl.mtlx index 02e10a03f4..bced025c5e 100644 --- a/libraries/stdlib/genglsl/stdlib_genglsl_impl.mtlx +++ b/libraries/stdlib/genglsl/stdlib_genglsl_impl.mtlx @@ -19,132 +19,132 @@ - + - + - + - + - + - + - + - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + - + - + - - - + + + - - - + + + @@ -204,242 +204,242 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - - - + + + + + + - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + - - - + + + - - - + + + - - - + + + - + @@ -451,28 +451,28 @@ - - - - + + + + - - + + - - + + - - + + - + - + @@ -481,124 +481,124 @@ - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + - - + + - - + + - - + + - + - + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - + - + - + - + - + - + - - - + + + - - - + + + - - - - - - - + + + + + + + @@ -766,21 +766,21 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/libraries/stdlib/genosl/mx_burn_color3.osl b/libraries/stdlib/genosl/mx_burn_color3.osl index 8396ad6f22..5c8d7a3d47 100644 --- a/libraries/stdlib/genosl/mx_burn_color3.osl +++ b/libraries/stdlib/genosl/mx_burn_color3.osl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genosl/mx_burn_float.osl" +#include "mx_burn_float.osl" void mx_burn_color3(color fg, color bg, float mix, output color result) { diff --git a/libraries/stdlib/genosl/mx_burn_color4.osl b/libraries/stdlib/genosl/mx_burn_color4.osl index 13884af543..54f40ec9c7 100644 --- a/libraries/stdlib/genosl/mx_burn_color4.osl +++ b/libraries/stdlib/genosl/mx_burn_color4.osl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genosl/mx_burn_float.osl" +#include "mx_burn_float.osl" void mx_burn_color4(color4 fg, color4 bg, float mix, output color4 result) { diff --git a/libraries/stdlib/genosl/mx_dodge_color3.osl b/libraries/stdlib/genosl/mx_dodge_color3.osl index dd88fa425f..3ebbac0a61 100644 --- a/libraries/stdlib/genosl/mx_dodge_color3.osl +++ b/libraries/stdlib/genosl/mx_dodge_color3.osl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genosl/mx_dodge_float.osl" +#include "mx_dodge_float.osl" void mx_dodge_color3(color fg, color bg, float mix, output color result) { diff --git a/libraries/stdlib/genosl/mx_dodge_color4.osl b/libraries/stdlib/genosl/mx_dodge_color4.osl index 9a34499929..0ad4a2b142 100644 --- a/libraries/stdlib/genosl/mx_dodge_color4.osl +++ b/libraries/stdlib/genosl/mx_dodge_color4.osl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genosl/mx_dodge_float.osl" +#include "mx_dodge_float.osl" void mx_dodge_color4(color4 fg , color4 bg , float mix , output color4 result) { diff --git a/libraries/stdlib/genosl/mx_image_color3.osl b/libraries/stdlib/genosl/mx_image_color3.osl index f2c9fc6bc2..15b594e885 100644 --- a/libraries/stdlib/genosl/mx_image_color3.osl +++ b/libraries/stdlib/genosl/mx_image_color3.osl @@ -1,4 +1,4 @@ -#include "$fileTransformUv" +#include "lib/$fileTransformUv" void mx_image_color3(textureresource file, string layer, color default_value, vector2 texcoord, string uaddressmode, string vaddressmode, string filtertype, string framerange, int frameoffset, string frameendaction, output color out) { diff --git a/libraries/stdlib/genosl/mx_image_color4.osl b/libraries/stdlib/genosl/mx_image_color4.osl index bfc99c292b..3bde1a5047 100644 --- a/libraries/stdlib/genosl/mx_image_color4.osl +++ b/libraries/stdlib/genosl/mx_image_color4.osl @@ -1,4 +1,4 @@ -#include "$fileTransformUv" +#include "lib/$fileTransformUv" void mx_image_color4(textureresource file, string layer, color4 default_value, vector2 texcoord, string uaddressmode, string vaddressmode, string filtertype, string framerange, int frameoffset, string frameendaction, output color4 out) { diff --git a/libraries/stdlib/genosl/mx_image_float.osl b/libraries/stdlib/genosl/mx_image_float.osl index c2d9b97df8..8cbadb35e2 100644 --- a/libraries/stdlib/genosl/mx_image_float.osl +++ b/libraries/stdlib/genosl/mx_image_float.osl @@ -1,4 +1,4 @@ -#include "$fileTransformUv" +#include "lib/$fileTransformUv" void mx_image_float(textureresource file, string layer, float default_value, vector2 texcoord, string uaddressmode, string vaddressmode, string filtertype, string framerange, int frameoffset, string frameendaction, output float out) { diff --git a/libraries/stdlib/genosl/mx_image_vector2.osl b/libraries/stdlib/genosl/mx_image_vector2.osl index de95f82c17..3aadbefc23 100644 --- a/libraries/stdlib/genosl/mx_image_vector2.osl +++ b/libraries/stdlib/genosl/mx_image_vector2.osl @@ -1,4 +1,4 @@ -#include "$fileTransformUv" +#include "lib/$fileTransformUv" void mx_image_vector2(textureresource file, string layer, vector2 default_value, vector2 texcoord, string uaddressmode, string vaddressmode, string filtertype, string framerange, int frameoffset, string frameendaction, output vector2 out) { diff --git a/libraries/stdlib/genosl/mx_image_vector3.osl b/libraries/stdlib/genosl/mx_image_vector3.osl index 754ecb12dc..a180107fcf 100644 --- a/libraries/stdlib/genosl/mx_image_vector3.osl +++ b/libraries/stdlib/genosl/mx_image_vector3.osl @@ -1,4 +1,4 @@ -#include "$fileTransformUv" +#include "lib/$fileTransformUv" void mx_image_vector3(textureresource file, string layer, vector default_value, vector2 texcoord, string uaddressmode, string vaddressmode, string filtertype, string framerange, int frameoffset, string frameendaction, output vector out) { diff --git a/libraries/stdlib/genosl/mx_image_vector4.osl b/libraries/stdlib/genosl/mx_image_vector4.osl index 8b933baf8c..bf5f6d1903 100644 --- a/libraries/stdlib/genosl/mx_image_vector4.osl +++ b/libraries/stdlib/genosl/mx_image_vector4.osl @@ -1,4 +1,4 @@ -#include "$fileTransformUv" +#include "lib/$fileTransformUv" void mx_image_vector4(textureresource file, string layer, vector4 default_value, vector2 texcoord, string uaddressmode, string vaddressmode, string filtertype, string framerange, int frameoffset, string frameendaction, output vector4 out) { diff --git a/libraries/stdlib/genosl/mx_srgb_texture_to_lin_rec709_color3.osl b/libraries/stdlib/genosl/mx_srgb_texture_to_lin_rec709_color3.osl index dbe4384910..b60a0b35ce 100644 --- a/libraries/stdlib/genosl/mx_srgb_texture_to_lin_rec709_color3.osl +++ b/libraries/stdlib/genosl/mx_srgb_texture_to_lin_rec709_color3.osl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genosl/lib/mx_transform_color.osl" +#include "lib/mx_transform_color.osl" void mx_srgb_texture_to_lin_rec709_color3(color _in, output color result) { diff --git a/libraries/stdlib/genosl/mx_srgb_texture_to_lin_rec709_color4.osl b/libraries/stdlib/genosl/mx_srgb_texture_to_lin_rec709_color4.osl index f48c5ee294..88777d89dd 100644 --- a/libraries/stdlib/genosl/mx_srgb_texture_to_lin_rec709_color4.osl +++ b/libraries/stdlib/genosl/mx_srgb_texture_to_lin_rec709_color4.osl @@ -1,4 +1,4 @@ -#include "libraries/stdlib/genosl/lib/mx_transform_color.osl" +#include "lib/mx_transform_color.osl" void mx_srgb_texture_to_lin_rec709_color4(color4 _in, output color4 result) { diff --git a/libraries/stdlib/genosl/stdlib_genosl_cm_impl.mtlx b/libraries/stdlib/genosl/stdlib_genosl_cm_impl.mtlx index 668339d2fb..ff1308741a 100644 --- a/libraries/stdlib/genosl/stdlib_genosl_cm_impl.mtlx +++ b/libraries/stdlib/genosl/stdlib_genosl_cm_impl.mtlx @@ -5,20 +5,20 @@ - - - - - - + + + + + + - - + + - - + + - - + + diff --git a/libraries/stdlib/genosl/stdlib_genosl_impl.mtlx b/libraries/stdlib/genosl/stdlib_genosl_impl.mtlx index c2e0d66695..168299e928 100644 --- a/libraries/stdlib/genosl/stdlib_genosl_impl.mtlx +++ b/libraries/stdlib/genosl/stdlib_genosl_impl.mtlx @@ -12,141 +12,141 @@ - + - + - + - + - + - + - + - + - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + - + - + - - - + + + - - - + + + @@ -154,456 +154,456 @@ - + - + - + - + - + - - + + - - - + + + - - - - - - - - - + + + + + + + + + - + - + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - - - + + + + + + - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + - - - + + + - - - + + + - - - + + + - + - + - + - + - - - - + + + + - - + + - - + + - - + + - + - + - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + - - + + - - + + - - + + - + - + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - + - + - + - + - + - + - - - + + + - - - + + + - - - - - - - + + + + + + + @@ -766,28 +766,28 @@ - + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/source/MaterialXGenGlsl/GlslShaderGenerator.cpp b/source/MaterialXGenGlsl/GlslShaderGenerator.cpp index 1dd59f791a..3d23fd90b2 100644 --- a/source/MaterialXGenGlsl/GlslShaderGenerator.cpp +++ b/source/MaterialXGenGlsl/GlslShaderGenerator.cpp @@ -344,15 +344,15 @@ void GlslShaderGenerator::emitSpecularEnvironment(GenContext& context, ShaderSta int specularMethod = context.getOptions().hwSpecularEnvironmentMethod; if (specularMethod == SPECULAR_ENVIRONMENT_FIS) { - emitInclude("libraries/pbrlib/" + GlslShaderGenerator::TARGET + "/lib/mx_environment_fis.glsl", context, stage); + emitLibraryInclude("pbrlib/genglsl/lib/mx_environment_fis.glsl", context, stage); } else if (specularMethod == SPECULAR_ENVIRONMENT_PREFILTER) { - emitInclude("libraries/pbrlib/" + GlslShaderGenerator::TARGET + "/lib/mx_environment_prefilter.glsl", context, stage); + emitLibraryInclude("pbrlib/genglsl/lib/mx_environment_prefilter.glsl", context, stage); } else if (specularMethod == SPECULAR_ENVIRONMENT_NONE) { - emitInclude("libraries/pbrlib/" + GlslShaderGenerator::TARGET + "/lib/mx_environment_none.glsl", context, stage); + emitLibraryInclude("pbrlib/genglsl/lib/mx_environment_none.glsl", context, stage); } else { @@ -522,7 +522,7 @@ void GlslShaderGenerator::emitPixelStage(const ShaderGraph& graph, GenContext& c emitOutputs(context, stage); // Add common math functions - emitInclude("libraries/stdlib/" + GlslShaderGenerator::TARGET + "/lib/mx_math.glsl", context, stage); + emitLibraryInclude("stdlib/genglsl/lib/mx_math.glsl", context, stage); emitLineBreak(stage); // Determine whether lighting is required @@ -547,7 +547,7 @@ void GlslShaderGenerator::emitPixelStage(const ShaderGraph& graph, GenContext& c if (context.getOptions().hwMaxActiveLightSources > 0) { - emitLightData(context, stage); + emitLightData(context, stage); } } @@ -556,13 +556,13 @@ void GlslShaderGenerator::emitPixelStage(const ShaderGraph& graph, GenContext& c context.getOptions().hwWriteDepthMoments; if (shadowing) { - emitInclude("libraries/pbrlib/" + GlslShaderGenerator::TARGET + "/lib/mx_shadow.glsl", context, stage); + emitLibraryInclude("pbrlib/genglsl/lib/mx_shadow.glsl", context, stage); } // Emit directional albedo table code. if (context.getOptions().hwWriteAlbedoTable) { - emitInclude("libraries/pbrlib/" + GlslShaderGenerator::TARGET + "/lib/mx_table.glsl", context, stage); + emitLibraryInclude("pbrlib/genglsl/lib/mx_table.glsl", context, stage); emitLineBreak(stage); } @@ -570,17 +570,17 @@ void GlslShaderGenerator::emitPixelStage(const ShaderGraph& graph, GenContext& c // depending on the vertical flip flag. if (context.getOptions().fileTextureVerticalFlip) { - _tokenSubstitutions[ShaderGenerator::T_FILE_TRANSFORM_UV] = "libraries/stdlib/" + GlslShaderGenerator::TARGET + "/lib/mx_transform_uv_vflip.glsl"; + _tokenSubstitutions[ShaderGenerator::T_FILE_TRANSFORM_UV] = "mx_transform_uv_vflip.glsl"; } else { - _tokenSubstitutions[ShaderGenerator::T_FILE_TRANSFORM_UV] = "libraries/stdlib/" + GlslShaderGenerator::TARGET + "/lib/mx_transform_uv.glsl"; + _tokenSubstitutions[ShaderGenerator::T_FILE_TRANSFORM_UV] = "mx_transform_uv.glsl"; } // Emit uv transform code globally if needed. if (context.getOptions().hwAmbientOcclusion) { - emitInclude(ShaderGenerator::T_FILE_TRANSFORM_UV, context, stage); + emitLibraryInclude("stdlib/genglsl/lib/" + _tokenSubstitutions[ShaderGenerator::T_FILE_TRANSFORM_UV], context, stage); } emitLightFunctionDefinitions(graph, context, stage); diff --git a/source/MaterialXGenGlsl/Nodes/BlurNodeGlsl.cpp b/source/MaterialXGenGlsl/Nodes/BlurNodeGlsl.cpp index 0b129f39f5..a90e4b0d65 100644 --- a/source/MaterialXGenGlsl/Nodes/BlurNodeGlsl.cpp +++ b/source/MaterialXGenGlsl/Nodes/BlurNodeGlsl.cpp @@ -20,7 +20,7 @@ ShaderNodeImplPtr BlurNodeGlsl::create() void BlurNodeGlsl::emitSamplingFunctionDefinition(const ShaderNode& /*node*/, GenContext& context, ShaderStage& stage) const { const ShaderGenerator& shadergen = context.getShaderGenerator(); - shadergen.emitInclude("libraries/stdlib/genglsl/lib/mx_sampling" + shadergen.getSyntax().getSourceFileExtension(), context, stage); + shadergen.emitLibraryInclude("stdlib/genglsl/lib/mx_sampling.glsl", context, stage); shadergen.emitLineBreak(stage); } diff --git a/source/MaterialXGenGlsl/Nodes/HeightToNormalNodeGlsl.cpp b/source/MaterialXGenGlsl/Nodes/HeightToNormalNodeGlsl.cpp index 79d41d79e1..08baf57126 100644 --- a/source/MaterialXGenGlsl/Nodes/HeightToNormalNodeGlsl.cpp +++ b/source/MaterialXGenGlsl/Nodes/HeightToNormalNodeGlsl.cpp @@ -55,7 +55,7 @@ void HeightToNormalNodeGlsl::emitFunctionDefinition(const ShaderNode&, GenContex BEGIN_SHADER_STAGE(stage, Stage::PIXEL) // Emit sampling functions const ShaderGenerator& shadergen = context.getShaderGenerator(); - shadergen.emitInclude("libraries/stdlib/genglsl/lib/mx_sampling.glsl", context, stage); + shadergen.emitLibraryInclude("stdlib/genglsl/lib/mx_sampling.glsl", context, stage); shadergen.emitLineBreak(stage); END_SHADER_STAGE(shader, Stage::PIXEL) } diff --git a/source/MaterialXGenGlsl/Nodes/LightNodeGlsl.cpp b/source/MaterialXGenGlsl/Nodes/LightNodeGlsl.cpp index bb475e5969..be8eb31b8a 100644 --- a/source/MaterialXGenGlsl/Nodes/LightNodeGlsl.cpp +++ b/source/MaterialXGenGlsl/Nodes/LightNodeGlsl.cpp @@ -50,7 +50,7 @@ void LightNodeGlsl::emitFunctionCall(const ShaderNode& node, GenContext& context BEGIN_SHADER_STAGE(stage, Stage::PIXEL) const GlslShaderGenerator& shadergen = static_cast(context.getShaderGenerator()); - shadergen.emitBlock(LIGHT_DIRECTION_CALCULATION, context, stage); + shadergen.emitBlock(LIGHT_DIRECTION_CALCULATION, FilePath(), context, stage); shadergen.emitLineBreak(stage); context.pushClosureContext(&_callEmission); diff --git a/source/MaterialXGenMdl/MdlShaderGenerator.cpp b/source/MaterialXGenMdl/MdlShaderGenerator.cpp index b4ec026350..db26faaf23 100644 --- a/source/MaterialXGenMdl/MdlShaderGenerator.cpp +++ b/source/MaterialXGenMdl/MdlShaderGenerator.cpp @@ -275,7 +275,7 @@ ShaderPtr MdlShaderGenerator::generate(const string& name, ElementPtr element, G " )\n" " )\n" ");"; - emitBlock(textureMaterial, context, stage); + emitBlock(textureMaterial, FilePath(), context, stage); } else if (graph.hasClassification(ShaderNode::Classification::SHADER)) { @@ -285,7 +285,7 @@ ShaderPtr MdlShaderGenerator::generate(const string& name, ElementPtr element, G emitScopeEnd(stage); static const string shaderMaterial = "in material(finalOutput__);"; - emitBlock(shaderMaterial, context, stage); + emitBlock(shaderMaterial, FilePath(), context, stage); } else { diff --git a/source/MaterialXGenOsl/Nodes/BlurNodeOsl.cpp b/source/MaterialXGenOsl/Nodes/BlurNodeOsl.cpp index 55bab703e9..97e0115399 100644 --- a/source/MaterialXGenOsl/Nodes/BlurNodeOsl.cpp +++ b/source/MaterialXGenOsl/Nodes/BlurNodeOsl.cpp @@ -20,7 +20,7 @@ ShaderNodeImplPtr BlurNodeOsl::create() void BlurNodeOsl::emitSamplingFunctionDefinition(const ShaderNode& /*node*/, GenContext& context, ShaderStage& stage) const { const ShaderGenerator& shadergen = context.getShaderGenerator(); - shadergen.emitInclude("libraries/stdlib/genosl/lib/mx_sampling" + shadergen.getSyntax().getSourceFileExtension(), context, stage); + shadergen.emitLibraryInclude("stdlib/genosl/lib/mx_sampling.osl", context, stage); shadergen.emitLineBreak(stage); } diff --git a/source/MaterialXGenOsl/OslShaderGenerator.cpp b/source/MaterialXGenOsl/OslShaderGenerator.cpp index 1ff1f9c07e..2cc310cfef 100644 --- a/source/MaterialXGenOsl/OslShaderGenerator.cpp +++ b/source/MaterialXGenOsl/OslShaderGenerator.cpp @@ -193,7 +193,7 @@ ShaderPtr OslShaderGenerator::generate(const string& name, ElementPtr element, G ShaderGraph& graph = shader->getGraph(); ShaderStage& stage = shader->getStage(Stage::PIXEL); - emitIncludes(stage, context); + emitLibraryIncludes(stage, context); // Add global constants and type definitions emitTypeDefinitions(context, stage); @@ -204,11 +204,11 @@ ShaderPtr OslShaderGenerator::generate(const string& name, ElementPtr element, G // depending on the vertical flip flag. if (context.getOptions().fileTextureVerticalFlip) { - _tokenSubstitutions[ShaderGenerator::T_FILE_TRANSFORM_UV] = "libraries/stdlib/" + OslShaderGenerator::TARGET + "/lib/mx_transform_uv_vflip.osl"; + _tokenSubstitutions[ShaderGenerator::T_FILE_TRANSFORM_UV] = "mx_transform_uv_vflip.osl"; } else { - _tokenSubstitutions[ShaderGenerator::T_FILE_TRANSFORM_UV] = "libraries/stdlib/" + OslShaderGenerator::TARGET + "/lib/mx_transform_uv.osl"; + _tokenSubstitutions[ShaderGenerator::T_FILE_TRANSFORM_UV] = "mx_transform_uv.osl"; } // Emit function definitions for all nodes @@ -428,7 +428,7 @@ void OslShaderGenerator::emitFunctionBodyBegin(const ShaderNode& node, GenContex } } -void OslShaderGenerator::emitIncludes(ShaderStage& stage, GenContext& context) const +void OslShaderGenerator::emitLibraryIncludes(ShaderStage& stage, GenContext& context) const { static const string INCLUDE_PREFIX = "#include \""; static const string INCLUDE_SUFFIX = "\""; @@ -439,7 +439,7 @@ void OslShaderGenerator::emitIncludes(ShaderStage& stage, GenContext& context) c for (const string& file : INCLUDE_FILES) { - FilePath path = context.resolveSourceFile(file); + FilePath path = context.resolveSourceFile(file, FilePath()); // Force path to use slash since backslash even if escaped // gives problems when saving the source code to file. diff --git a/source/MaterialXGenOsl/OslShaderGenerator.h b/source/MaterialXGenOsl/OslShaderGenerator.h index 1e85acefd3..a6a3bd954a 100644 --- a/source/MaterialXGenOsl/OslShaderGenerator.h +++ b/source/MaterialXGenOsl/OslShaderGenerator.h @@ -55,7 +55,7 @@ class MX_GENOSL_API OslShaderGenerator : public ShaderGenerator virtual ShaderPtr createShader(const string& name, ElementPtr element, GenContext& context) const; /// Emit include headers needed by the generated shader code. - virtual void emitIncludes(ShaderStage& stage, GenContext& context) const; + virtual void emitLibraryIncludes(ShaderStage& stage, GenContext& context) const; /// Emit a block of shader inputs. virtual void emitShaderInputs(const VariableBlock& inputs, ShaderStage& stage) const; diff --git a/source/MaterialXGenShader/GenContext.h b/source/MaterialXGenShader/GenContext.h index 839e8c98ee..1e01fedaf7 100644 --- a/source/MaterialXGenShader/GenContext.h +++ b/source/MaterialXGenShader/GenContext.h @@ -48,22 +48,30 @@ class MX_GENSHADER_API GenContext return _options; } - /// Add to the search path used for finding source code. + /// Register a user search path for finding source code during + /// code generation. void registerSourceCodeSearchPath(const FilePath& path) { _sourceCodeSearchPath.append(path); } - /// Add to the search path used for finding source code. + /// Register a user search path for finding source code during + /// code generation. void registerSourceCodeSearchPath(const FileSearchPath& path) { _sourceCodeSearchPath.append(path); } - /// Resolve a file using the registered search paths. - FilePath resolveSourceFile(const FilePath& filename) const + /// Resolve a source code filename, first checking the given local path + /// then checking any file paths registered by the user. + FilePath resolveSourceFile(const FilePath& filename, const FilePath& localPath) const { - return _sourceCodeSearchPath.find(filename); + FileSearchPath searchPath = _sourceCodeSearchPath; + if (!localPath.isEmpty()) + { + searchPath.prepend(localPath); + } + return searchPath.find(filename); } /// Add reserved words that should not be used as @@ -182,31 +190,16 @@ class MX_GENSHADER_API GenContext protected: GenContext() = delete; - // Shader generator. ShaderGeneratorPtr _sg; - - // Generation options. GenOptions _options; - - // Search path for finding source files. FileSearchPath _sourceCodeSearchPath; - - // Set of globally reserved words. StringSet _reservedWords; - // Cached shader node implementations. std::unordered_map _nodeImpls; - - // User data std::unordered_map> _userData; - - // List of input suffixes std::unordered_map _inputSuffix; - - // List of output suffixes std::unordered_map _outputSuffix; - // Contexts for closure evaluation. vector _closureContexts; }; diff --git a/source/MaterialXGenShader/GenOptions.h b/source/MaterialXGenShader/GenOptions.h index 3ba74968b4..5260845913 100644 --- a/source/MaterialXGenShader/GenOptions.h +++ b/source/MaterialXGenShader/GenOptions.h @@ -11,6 +11,8 @@ #include +#include + MATERIALX_NAMESPACE_BEGIN /// Type of shader interface to be generated @@ -67,6 +69,7 @@ class MX_GENSHADER_API GenOptions shaderInterfaceType(SHADER_INTERFACE_COMPLETE), fileTextureVerticalFlip(false), addUpstreamDependencies(true), + libraryPrefix("libraries"), hwTransparency(false), hwSpecularEnvironmentMethod(SPECULAR_ENVIRONMENT_FIS), hwDirectionalAlbedoMethod(DIRECTIONAL_ALBEDO_ANALYTIC), @@ -108,6 +111,11 @@ class MX_GENSHADER_API GenOptions /// for the element to generate a shader for. bool addUpstreamDependencies; + /// The standard library prefix, which will be applied to + /// calls to emitLibraryInclude during code generation. + /// Defaults to "libraries". + FilePath libraryPrefix; + /// Sets if transparency is needed or not for HW shaders. /// If a surface shader has potential of being transparent /// this must be set to true, otherwise no transparency diff --git a/source/MaterialXGenShader/Nodes/SourceCodeNode.cpp b/source/MaterialXGenShader/Nodes/SourceCodeNode.cpp index bafbc39b08..d248211f75 100644 --- a/source/MaterialXGenShader/Nodes/SourceCodeNode.cpp +++ b/source/MaterialXGenShader/Nodes/SourceCodeNode.cpp @@ -32,13 +32,13 @@ void SourceCodeNode::initialize(const InterfaceElement& element, GenContext& con _functionSource = impl.getAttribute("sourcecode"); if (_functionSource.empty()) { - FilePath file(impl.getAttribute("file")); - file = context.resolveSourceFile(file); - _functionSource = readFile(file); + FilePath localPath = FilePath(impl.getActiveSourceUri()).getParentPath(); + _sourceFilename = context.resolveSourceFile(impl.getAttribute("file"), localPath); + _functionSource = readFile(_sourceFilename); if (_functionSource.empty()) { - throw ExceptionShaderGenError("Failed to get source code from file '" + file.asString() + - "' used by implementation '" + impl.getName() + "'"); + throw ExceptionShaderGenError("Failed to get source code from file '" + _sourceFilename.asString() + + "' used by implementation '" + impl.getName() + "'"); } } @@ -74,7 +74,7 @@ void SourceCodeNode::emitFunctionDefinition(const ShaderNode&, GenContext& conte if (!_inlined && !_functionSource.empty()) { const ShaderGenerator& shadergen = context.getShaderGenerator(); - shadergen.emitBlock(_functionSource, context, stage); + shadergen.emitBlock(_functionSource, _sourceFilename, context, stage); shadergen.emitLineBreak(stage); } END_SHADER_STAGE(stage, Stage::PIXEL) diff --git a/source/MaterialXGenShader/Nodes/SourceCodeNode.h b/source/MaterialXGenShader/Nodes/SourceCodeNode.h index deda1cdd46..fbd9e7e307 100644 --- a/source/MaterialXGenShader/Nodes/SourceCodeNode.h +++ b/source/MaterialXGenShader/Nodes/SourceCodeNode.h @@ -8,6 +8,8 @@ #include +#include + MATERIALX_NAMESPACE_BEGIN /// Node implementation using data-driven static source code. @@ -26,6 +28,7 @@ class MX_GENSHADER_API SourceCodeNode : public ShaderNodeImpl bool _inlined; string _functionName; string _functionSource; + FilePath _sourceFilename; }; MATERIALX_NAMESPACE_END diff --git a/source/MaterialXGenShader/ShaderGenerator.cpp b/source/MaterialXGenShader/ShaderGenerator.cpp index c8791244ff..50db4e4386 100644 --- a/source/MaterialXGenShader/ShaderGenerator.cpp +++ b/source/MaterialXGenShader/ShaderGenerator.cpp @@ -74,14 +74,17 @@ void ShaderGenerator::emitComment(const string& str, ShaderStage& stage) const stage.addComment(str); } -void ShaderGenerator::emitBlock(const string& str, GenContext& context, ShaderStage& stage) const +void ShaderGenerator::emitBlock(const string& str, const FilePath& sourceFilename, GenContext& context, ShaderStage& stage) const { - stage.addBlock(str, context); + stage.addBlock(str, sourceFilename, context); } -void ShaderGenerator::emitInclude(const string& file, GenContext& context, ShaderStage& stage) const +void ShaderGenerator::emitLibraryInclude(const FilePath& filename, GenContext& context, ShaderStage& stage) const { - stage.addInclude(file, context); + FilePath libraryPrefix = context.getOptions().libraryPrefix; + FilePath fullFilename = libraryPrefix.isEmpty() ? filename : libraryPrefix / filename; + FilePath resolvedFilename = context.resolveSourceFile(fullFilename, FilePath()); + stage.addInclude(fullFilename, resolvedFilename, context); } void ShaderGenerator::emitFunctionDefinition(const ShaderNode& node, GenContext& context, ShaderStage& stage) const diff --git a/source/MaterialXGenShader/ShaderGenerator.h b/source/MaterialXGenShader/ShaderGenerator.h index 985c8afe88..c468608a12 100644 --- a/source/MaterialXGenShader/ShaderGenerator.h +++ b/source/MaterialXGenShader/ShaderGenerator.h @@ -16,6 +16,8 @@ #include #include +#include + #include MATERIALX_NAMESPACE_BEGIN @@ -69,11 +71,12 @@ class MX_GENSHADER_API ShaderGenerator virtual void emitComment(const string& str, ShaderStage& stage) const; /// Add a block of code. - virtual void emitBlock(const string& str, GenContext& context, ShaderStage& stage) const; + virtual void emitBlock(const string& str, const FilePath& sourceFilename, GenContext& context, ShaderStage& stage) const; - /// Add the contents of an include file. Making sure it is - /// only included once for the shader stage. - virtual void emitInclude(const string& file, GenContext& context, ShaderStage& stage) const; + /// Add the contents of a standard library include file if not already present. + /// The library file prefix of the given context, if any, will be prepended + /// to the given filename. + virtual void emitLibraryInclude(const FilePath& filename, GenContext& context, ShaderStage& stage) const; /// Add a value. template diff --git a/source/MaterialXGenShader/ShaderStage.cpp b/source/MaterialXGenShader/ShaderStage.cpp index 4cd56db8d1..34e2eb4b09 100644 --- a/source/MaterialXGenShader/ShaderStage.cpp +++ b/source/MaterialXGenShader/ShaderStage.cpp @@ -291,13 +291,12 @@ void ShaderStage::addComment(const string& str) endLine(false); } -void ShaderStage::addBlock(const string& str, GenContext& context) +void ShaderStage::addBlock(const string& str, const FilePath& sourceFilename, GenContext& context) { const string& INCLUDE = _syntax->getIncludeStatement(); const string& QUOTE = _syntax->getStringQuote(); - // Add each line in the block seperatelly - // to get correct indentation + // Add each line in the block seperately to get correct indentation. StringStream stream(str); for (string line; std::getline(stream, line); ) { @@ -312,7 +311,7 @@ void ShaderStage::addBlock(const string& str, GenContext& context) if (length) { const string filename = line.substr(startQuote + 1, length); - addInclude(filename, context); + addInclude(filename, sourceFilename, context); } } } @@ -323,21 +322,21 @@ void ShaderStage::addBlock(const string& str, GenContext& context) } } -void ShaderStage::addInclude(const string& file, GenContext& context) +void ShaderStage::addInclude(const FilePath& includeFilename, const FilePath& sourceFilename, GenContext& context) { - string modifiedFile = file; + string modifiedFile = includeFilename; tokenSubstitution(context.getShaderGenerator().getTokenSubstitutions(), modifiedFile); - FilePath resolvedFile = context.resolveSourceFile(modifiedFile); + FilePath resolvedFile = context.resolveSourceFile(modifiedFile, sourceFilename.getParentPath()); if (!_includes.count(resolvedFile)) { string content = readFile(resolvedFile); if (content.empty()) { - throw ExceptionShaderGenError("Could not find include file: '" + file + "'"); + throw ExceptionShaderGenError("Could not find include file: '" + includeFilename.asString() + "'"); } _includes.insert(resolvedFile); - addBlock(content, context); + addBlock(content, resolvedFile, context); } } diff --git a/source/MaterialXGenShader/ShaderStage.h b/source/MaterialXGenShader/ShaderStage.h index dc95db6426..395f847370 100644 --- a/source/MaterialXGenShader/ShaderStage.h +++ b/source/MaterialXGenShader/ShaderStage.h @@ -15,6 +15,8 @@ #include #include +#include + #include #include @@ -222,11 +224,10 @@ class MX_GENSHADER_API ShaderStage void addComment(const string& str); /// Add a block of code. - void addBlock(const string& str, GenContext& context); + void addBlock(const string& str, const FilePath& sourceFilename, GenContext& context); - /// Add the contents of an include file. Making sure it is - /// only included once for the shader stage. - void addInclude(const string& file, GenContext& context); + /// Add the contents of an include file if not already present. + void addInclude(const FilePath& includeFilename, const FilePath& sourceFilename, GenContext& context); /// Add a value. template diff --git a/source/MaterialXTest/MaterialXGenShader/GenShaderUtil.cpp b/source/MaterialXTest/MaterialXGenShader/GenShaderUtil.cpp index 7c5ccc882a..8d8ee1abb8 100644 --- a/source/MaterialXTest/MaterialXGenShader/GenShaderUtil.cpp +++ b/source/MaterialXTest/MaterialXGenShader/GenShaderUtil.cpp @@ -55,7 +55,8 @@ bool getShaderSource(mx::GenContext& context, return true; } sourcePath = implementation->getFile(); - mx::FilePath resolvedPath = context.resolveSourceFile(sourcePath); + mx::FilePath localPath = mx::FilePath(implementation->getSourceUri()).getParentPath(); + mx::FilePath resolvedPath = context.resolveSourceFile(sourcePath, localPath); sourceContents = mx::readFile(resolvedPath); resolvedSource = resolvedPath.asString(); return !sourceContents.empty();