Skip to content

Commit

Permalink
Merge branch 'main' into node_editor_fonts
Browse files Browse the repository at this point in the history
  • Loading branch information
jstone-lucasfilm authored Oct 21, 2024
2 parents cb6e8c9 + a578d8a commit 64f1219
Show file tree
Hide file tree
Showing 57 changed files with 689 additions and 1,836 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -229,13 +229,14 @@ jobs:
run: |
vcpkg/vcpkg install glslang --triplet=x64-windows
glslangValidator.exe -v
python python/Scripts/generateshader.py resources/Materials/Examples/StandardSurface --target glsl --validator glslangValidator.exe --vulkanGlsl True --validatorArgs="-V --aml"
python python/Scripts/generateshader.py resources/Materials/Examples/StandardSurface --target essl --validator glslangValidator.exe
python python/Scripts/generateshader.py resources/Materials/Examples --target glsl --validator glslangValidator.exe
python python/Scripts/generateshader.py resources/Materials/Examples --target essl --validator glslangValidator.exe
- name: Shader Validation Tests (MacOS)
if: matrix.test_shaders == 'ON' && runner.os == 'macOS'
run: |
python python/Scripts/generateshader.py resources/Materials/Examples/StandardSurface --target msl --validator "xcrun metal --language=metal" --validatorArgs="-w"
python python/Scripts/generateshader.py resources/Materials/Examples --target msl --validator "xcrun metal --language=metal" --validatorArgs="-w"
python python/Scripts/generateshader.py resources/Materials/TestSuite/stdlib --target msl --validator "xcrun metal --language=metal" --validatorArgs="-w"
- name: Coverage Analysis Tests
if: matrix.coverage_analysis == 'ON'
Expand Down
18 changes: 8 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,25 +60,21 @@ option(MATERIALX_DYNAMIC_ANALYSIS "Build MaterialX libraries with dynamic analys
option(MATERIALX_OSL_LEGACY_CLOSURES "Build OSL shader generation supporting the legacy OSL closures." OFF)

option(MATERIALX_BUILD_IOS "Build MaterialX for iOS. (Deprecated. Set CMAKE_SYSTEM_NAME instead)" OFF)
set(MATERIALX_BUILD_APPLE_EMBEDDED OFF)
option(MATERIALX_BUILD_APPLE_FRAMEWORK "Build MaterialX as an Apple Framework" ${__build_apple_framework})
if (MATERIALX_BUILD_IOS)
MESSAGE(WARNING "The MATERIALX_BUILD_IOS is deprecated. Set the CMAKE_SYSTEM_NAME to the platform instead")
set(CMAKE_SYSTEM_NAME iOS)
endif()

# Cross Compilation detection as defined in CMake docs
# Apple ecosystem cross-compilation
# https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html#cross-compiling-for-ios-tvos-visionos-or-watchos
# Note: All these SDKs may not be supported by MaterialX
set(MATERIALX_BUILD_APPLE_EMBEDDED OFF)
set(__build_apple_framework OFF)
if (CMAKE_SYSTEM_NAME MATCHES "iOS"
OR CMAKE_SYSTEM_NAME MATCHES "tvOS"
OR CMAKE_SYSTEM_NAME MATCHES "visionOS"
OR CMAKE_SYSTEM_NAME MATCHES "watchOS")
if (CMAKE_SYSTEM_NAME MATCHES "iOS" OR CMAKE_SYSTEM_NAME MATCHES "tvOS" OR CMAKE_SYSTEM_NAME MATCHES "visionOS" OR CMAKE_SYSTEM_NAME MATCHES "watchOS")
set(MATERIALX_BUILD_APPLE_EMBEDDED ON)
set(__build_apple_framework ${MATERIALX_BUILD_SHARED_LIBS})
# TARGET_OS_IPHONE refers to all IPHONE derived platforms
# https://chaosinmotion.com/2021/08/02/things-to-remember-compiler-conditionals-for-macos-ios-etc/
# This should be auto-defined, but leaving it in here because it was historically defined
add_definitions(-DTARGET_OS_IPHONE=1)
set(MATERIALX_BUILD_MONOLITHIC ON)
set(MATERIALX_BUILD_PYTHON OFF)
Expand All @@ -90,8 +86,10 @@ if (CMAKE_SYSTEM_NAME MATCHES "iOS"
set(MATERIALX_BUILD_TESTS OFF)
endif()

set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "-" CACHE STRING "The Codesigning identity needed to sign compiled objects")
option(MATERIALX_BUILD_APPLE_FRAMEWORK "Build MaterialX as an Apple Framework" ${__build_apple_framework})
# Apple framework handling
if(APPLE)
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "-" CACHE STRING "The Codesigning identity needed to sign compiled objects")
endif()
if (MATERIALX_BUILD_APPLE_FRAMEWORK)
add_definitions(-DBUILD_APPLE_FRAMEWORK)
set(MATERIALX_BUILD_MONOLITHIC ON)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ void mx_chiang_hair_roughness(
float ar = clamp(azimuthal, 0.001, 1.0);

// longitudinal variance
float v = 0.726 * lr + 0.812 * lr * lr + 3.7 * pow(lr, 20);
float v = 0.726 * lr + 0.812 * lr * lr + 3.7 * pow(lr, 20.0);
v = v * v;

float s = 0.265 * ar + 1.194 * ar * ar + 5.372 * pow(ar, 22);
float s = 0.265 * ar + 1.194 * ar * ar + 5.372 * pow(ar, 22.0);

roughness_R = vec2(v, s);
roughness_TT = vec2(v * scale_TT * scale_TT, s);
Expand Down Expand Up @@ -111,7 +111,8 @@ float mx_hair_trimmed_logistic(float x, float s, float a, float b)

float mx_hair_phi(int p, float gammaO, float gammaT)
{
return 2.0 * p * gammaT - 2.0 * gammaO + p * M_PI;
float fP = float(p);
return 2.0 * fP * gammaT - 2.0 * gammaO + fP * M_PI;
}

float mx_hair_longitudinal_scattering( // Mp
Expand Down Expand Up @@ -260,9 +261,7 @@ vec3 mx_chiang_hair_bsdf(
vec3 F = vec3(0.0);
for (int i = 0; i <= 3; ++i)
{
if (all(lessThanEqual(tint[i], vec3(0.0))))
continue;

tint[i] = max(tint[i], vec3(0.0));
float Mp = mx_hair_longitudinal_scattering(angles[i].x, angles[i].y, sinThetaO, cosThetaO, vs[i].x);
float Np = (i == 3) ? (1.0 / 2.0 * M_PI) : mx_hair_azimuthal_scattering(phi, i, vs[i].y, gammaO, gammaT);
F += Mp * Np * tint[i] * Ap[i];
Expand Down
8 changes: 4 additions & 4 deletions libraries/pbrlib/genglsl/pbrlib_genglsl_impl.mtlx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<implementation name="IM_sheen_bsdf_genglsl" nodedef="ND_sheen_bsdf" file="mx_sheen_bsdf.glsl" function="mx_sheen_bsdf" target="genglsl" />

<!-- <chiang_hair_bsdf> -->
<implementation name="IM_chiang_hair_bsdf_genglsl" nodedef="ND_chiang_hair_bsdf" file="mx_hair_bsdf.glsl" function="mx_chiang_hair_bsdf" target="genglsl" />
<implementation name="IM_chiang_hair_bsdf_genglsl" nodedef="ND_chiang_hair_bsdf" file="mx_chiang_hair_bsdf.glsl" function="mx_chiang_hair_bsdf" target="genglsl" />

<!-- <anisotropic_vdf> -->
<implementation name="IM_anisotropic_vdf_genglsl" nodedef="ND_anisotropic_vdf" file="mx_anisotropic_vdf.glsl" function="mx_anisotropic_vdf" target="genglsl" />
Expand Down Expand Up @@ -78,12 +78,12 @@
<implementation name="IM_blackbody_genglsl" nodedef="ND_blackbody" file="mx_blackbody.glsl" function="mx_blackbody" target="genglsl" />

<!-- <deon_hair_absorption_from_melanin -->
<implementation name="IM_deon_hair_absorption_from_melanin_genglsl" nodedef="ND_deon_hair_absorption_from_melanin" file="mx_hair_bsdf.glsl" function="mx_deon_hair_absorption_from_melanin" target="genglsl" />
<implementation name="IM_deon_hair_absorption_from_melanin_genglsl" nodedef="ND_deon_hair_absorption_from_melanin" file="mx_chiang_hair_bsdf.glsl" function="mx_deon_hair_absorption_from_melanin" target="genglsl" />

<!-- <chiang_hair_absorption_from_color -->
<implementation name="IM_chiang_hair_absorption_from_color_genglsl" nodedef="ND_chiang_hair_absorption_from_color" file="mx_hair_bsdf.glsl" function="mx_chiang_hair_absorption_from_color" target="genglsl" />
<implementation name="IM_chiang_hair_absorption_from_color_genglsl" nodedef="ND_chiang_hair_absorption_from_color" file="mx_chiang_hair_bsdf.glsl" function="mx_chiang_hair_absorption_from_color" target="genglsl" />

<!-- <chiang_hair_roughness -->
<implementation name="IM_chiang_hair_roughness_genglsl" nodedef="ND_chiang_hair_roughness" file="mx_hair_bsdf.glsl" function="mx_chiang_hair_roughness" target="genglsl" />
<implementation name="IM_chiang_hair_roughness_genglsl" nodedef="ND_chiang_hair_roughness" file="mx_chiang_hair_bsdf.glsl" function="mx_chiang_hair_roughness" target="genglsl" />

</materialx>
12 changes: 12 additions & 0 deletions libraries/pbrlib/genmdl/pbrlib_genmdl_impl.mtlx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
<!-- <sheen_bsdf> -->
<implementation name="IM_sheen_bsdf_genmdl" nodedef="ND_sheen_bsdf" sourcecode="materialx::pbrlib_{{MDL_VERSION_SUFFIX}}::mx_sheen_bsdf(mxp_weight:{{weight}}, mxp_color:{{color}}, mxp_roughness:{{roughness}}, mxp_normal:{{normal}}, mxp_base:{{base}})" target="genmdl" />

<!-- <chiang_hair_bsdf> -->
<implementation name="IM_chiang_hair_bsdf_genmdl" nodedef="ND_chiang_hair_bsdf" sourcecode="materialx::pbrlib_{{MDL_VERSION_SUFFIX}}::mx_chiang_hairbsdf(mxp_tint_R:{{tint_R}}, mxp_tint_TT:{{tint_TT}}, mxp_tint_TRT:{{tint_TRT}}, mxp_ior:{{ior}}, mxp_roughness_R:{{roughness_R}}, mxp_roughness_TT:{{roughness_TT}}, mxp_roughness_TRT:{{roughness_TRT}}, mxp_cuticle_angle:{{cuticle_angle}}, mxp_absorption_coefficient:{{absorption_coefficient}}, mxp_curve_direction:{{curve_direction}})" target="genmdl" />

<!-- <uniform_edf> -->
<implementation name="IM_uniform_edf_genmdl" nodedef="ND_uniform_edf" sourcecode="materialx::pbrlib_{{MDL_VERSION_SUFFIX}}::mx_uniform_edf(mxp_color:{{color}})" target="genmdl" />

Expand Down Expand Up @@ -90,4 +93,13 @@
<!-- <blackbody> -->
<implementation name="IM_blackbody_genmdl" nodedef="ND_blackbody" sourcecode="materialx::pbrlib_{{MDL_VERSION_SUFFIX}}::mx_blackbody(mxp_temperature:{{temperature}})" target="genmdl" />

<!-- <deon_hair_absorption_from_melanin> -->
<implementation name="IM_deon_hair_absorption_from_melanin_genmdl" nodedef="ND_deon_hair_absorption_from_melanin" sourcecode="materialx::pbrlib_{{MDL_VERSION_SUFFIX}}::mx_deon_hair_absorption_from_melanin(mxp_melanin_concentration:{{melanin_concentration}}, mxp_melanin_redness:{{melanin_redness}}, mxp_eumelanin_color:{{eumelanin_color}}, mxp_pheomelanin_color:{{pheomelanin_color}})" function="mx_deon_hair_absorption_from_melanin" target="genmdl" />

<!-- <chiang_hair_absorption_from_color> -->
<implementation name="IM_chiang_hair_absorption_from_color_genmdl" nodedef="ND_chiang_hair_absorption_from_color" sourcecode="materialx::pbrlib_{{MDL_VERSION_SUFFIX}}::mx_chiang_hair_absorption_from_color(mxp_color:{{color}}, mxp_azimuthal_roughness:{{azimuthal_roughness}})" function="mx_chiang_hair_absorption_from_color" target="genmdl" />

<!-- <chiang_hair_roughness> -->
<implementation name="IM_chiang_hair_roughness_genmdl" nodedef="ND_chiang_hair_roughness" sourcecode="materialx::pbrlib_{{MDL_VERSION_SUFFIX}}::mx_chiang_hair_roughness(mxp_longitudinal:{{longitudinal}}, mxp_azimuthal:{{azimuthal}}, mxp_scale_TT:{{scale_TT}}, mxp_scale_TRT:{{scale_TRT}})" target="genmdl" />

</materialx>
46 changes: 0 additions & 46 deletions libraries/pbrlib/genmsl/pbrlib_genmsl_impl.mtlx
Original file line number Diff line number Diff line change
@@ -1,33 +1,6 @@
<?xml version="1.0"?>
<materialx version="1.39">

<!-- <oren_nayar_diffuse_bsdf> -->
<implementation name="IM_oren_nayar_diffuse_bsdf_genmsl" nodedef="ND_oren_nayar_diffuse_bsdf" file="../genglsl/mx_oren_nayar_diffuse_bsdf.glsl" function="mx_oren_nayar_diffuse_bsdf" target="genmsl" />

<!-- <burley_diffuse_bsdf> -->
<implementation name="IM_burley_diffuse_bsdf_genmsl" nodedef="ND_burley_diffuse_bsdf" file="../genglsl/mx_burley_diffuse_bsdf.glsl" function="mx_burley_diffuse_bsdf" target="genmsl" />

<!-- <translucent_bsdf> -->
<implementation name="IM_translucent_bsdf_genmsl" nodedef="ND_translucent_bsdf" file="../genglsl/mx_translucent_bsdf.glsl" function="mx_translucent_bsdf" target="genmsl" />

<!-- <dielectric_bsdf> -->
<implementation name="IM_dielectric_bsdf_genmsl" nodedef="ND_dielectric_bsdf" file="../genglsl/mx_dielectric_bsdf.glsl" function="mx_dielectric_bsdf" target="genmsl" />

<!-- <conductor_bsdf> -->
<implementation name="IM_conductor_bsdf_genmsl" nodedef="ND_conductor_bsdf" file="../genglsl/mx_conductor_bsdf.glsl" function="mx_conductor_bsdf" target="genmsl" />

<!-- <generalized_schlick_bsdf> -->
<implementation name="IM_generalized_schlick_bsdf_genmsl" nodedef="ND_generalized_schlick_bsdf" file="../genglsl/mx_generalized_schlick_bsdf.glsl" function="mx_generalized_schlick_bsdf" target="genmsl" />

<!-- <subsurface_bsdf> -->
<implementation name="IM_subsurface_bsdf_genmsl" nodedef="ND_subsurface_bsdf" file="../genglsl/mx_subsurface_bsdf.glsl" function="mx_subsurface_bsdf" target="genmsl" />

<!-- <sheen_bsdf> -->
<implementation name="IM_sheen_bsdf_genmsl" nodedef="ND_sheen_bsdf" file="../genglsl/mx_sheen_bsdf.glsl" function="mx_sheen_bsdf" target="genmsl" />

<!-- <anisotropic_vdf> -->
<implementation name="IM_anisotropic_vdf_genmsl" nodedef="ND_anisotropic_vdf" file="../genglsl/mx_anisotropic_vdf.glsl" function="mx_anisotropic_vdf" target="genmsl" />

<!-- <layer> -->
<implementation name="IM_layer_bsdf_genmsl" nodedef="ND_layer_bsdf" target="genmsl" />
<implementation name="IM_layer_vdf_genmsl" nodedef="ND_layer_vdf" target="genmsl" />
Expand All @@ -46,29 +19,10 @@
<implementation name="IM_multiply_edfC_genmsl" nodedef="ND_multiply_edfC" target="genmsl" />
<implementation name="IM_multiply_edfF_genmsl" nodedef="ND_multiply_edfF" target="genmsl" />

<!-- <uniform_edf> -->
<implementation name="IM_uniform_edf_genmsl" nodedef="ND_uniform_edf" file="../genglsl/mx_uniform_edf.glsl" function="mx_uniform_edf" target="genmsl" />

<!-- <surface> -->
<implementation name="IM_surface_genmsl" nodedef="ND_surface" target="genmsl" />

<!-- <displacement> -->
<implementation name="IM_displacement_float_genmsl" nodedef="ND_displacement_float" file="../genglsl/mx_displacement_float.glsl" function="mx_displacement_float" target="genmsl" />
<implementation name="IM_displacement_vector3_genmsl" nodedef="ND_displacement_vector3" file="../genglsl/mx_displacement_vector3.glsl" function="mx_displacement_vector3" target="genmsl" />

<!-- <light> -->
<implementation name="IM_light_genmsl" nodedef="ND_light" target="genmsl" />

<!-- <roughness_anisotropy> -->
<implementation name="IM_roughness_anisotropy_genmsl" nodedef="ND_roughness_anisotropy" file="../genglsl/mx_roughness_anisotropy.glsl" function="mx_roughness_anisotropy" target="genmsl" />

<!-- <roughness_dual> -->
<implementation name="IM_roughness_dual_genmsl" nodedef="ND_roughness_dual" file="../genglsl/mx_roughness_dual.glsl" function="mx_roughness_dual" target="genmsl" />

<!-- <artistic_ior> -->
<implementation name="IM_artistic_ior_genmsl" nodedef="ND_artistic_ior" file="../genglsl/mx_artistic_ior.glsl" function="mx_artistic_ior" target="genmsl" />

<!-- <blackbody> -->
<implementation name="IM_blackbody_genmsl" nodedef="ND_blackbody" file="../genglsl/mx_blackbody.glsl" function="mx_blackbody" target="genmsl" />

</materialx>
2 changes: 2 additions & 0 deletions libraries/stdlib/genglsl/lib/mx_math.glsl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#define M_FLOAT_EPS 1e-8

#define mx_mod mod
#define mx_inverse inverse
#define mx_inversesqrt inversesqrt
#define mx_sin sin
#define mx_cos cos
Expand Down
7 changes: 4 additions & 3 deletions libraries/stdlib/genglsl/mx_burn_color3.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

void mx_burn_color3(vec3 fg, vec3 bg, float mixval, out vec3 result)
{
mx_burn_float(fg.x, bg.x, mixval, result.x);
mx_burn_float(fg.y, bg.y, mixval, result.y);
mx_burn_float(fg.z, bg.z, mixval, result.z);
float f;
mx_burn_float(fg.x, bg.x, mixval, f); result.x = f;
mx_burn_float(fg.y, bg.y, mixval, f); result.y = f;
mx_burn_float(fg.z, bg.z, mixval, f); result.z = f;
}
9 changes: 5 additions & 4 deletions libraries/stdlib/genglsl/mx_burn_color4.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

void mx_burn_color4(vec4 fg, vec4 bg, float mixval, out vec4 result)
{
mx_burn_float(fg.x, bg.x, mixval, result.x);
mx_burn_float(fg.y, bg.y, mixval, result.y);
mx_burn_float(fg.z, bg.z, mixval, result.z);
mx_burn_float(fg.w, bg.w, mixval, result.w);
float f;
mx_burn_float(fg.x, bg.x, mixval, f); result.x = f;
mx_burn_float(fg.y, bg.y, mixval, f); result.y = f;
mx_burn_float(fg.z, bg.z, mixval, f); result.z = f;
mx_burn_float(fg.w, bg.w, mixval, f); result.w = f;
}
7 changes: 4 additions & 3 deletions libraries/stdlib/genglsl/mx_dodge_color3.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

void mx_dodge_color3(vec3 fg, vec3 bg, float mixval, out vec3 result)
{
mx_dodge_float(fg.x, bg.x, mixval, result.x);
mx_dodge_float(fg.y, bg.y, mixval, result.y);
mx_dodge_float(fg.z, bg.z, mixval, result.z);
float f;
mx_dodge_float(fg.x, bg.x, mixval, f); result.x = f;
mx_dodge_float(fg.y, bg.y, mixval, f); result.y = f;
mx_dodge_float(fg.z, bg.z, mixval, f); result.z = f;
}
9 changes: 5 additions & 4 deletions libraries/stdlib/genglsl/mx_dodge_color4.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

void mx_dodge_color4(vec4 fg , vec4 bg , float mixval, out vec4 result)
{
mx_dodge_float(fg.x, bg.x, mixval, result.x);
mx_dodge_float(fg.y, bg.y, mixval, result.y);
mx_dodge_float(fg.z, bg.z, mixval, result.z);
mx_dodge_float(fg.w, bg.w, mixval, result.w);
float f;
mx_dodge_float(fg.x, bg.x, mixval, f); result.x = f;
mx_dodge_float(fg.y, bg.y, mixval, f); result.y = f;
mx_dodge_float(fg.z, bg.z, mixval, f); result.z = f;
mx_dodge_float(fg.w, bg.w, mixval, f); result.w = f;
}
8 changes: 4 additions & 4 deletions libraries/stdlib/genglsl/mx_normalmap.glsl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
void mx_normalmap_vector2(vec3 value, vec2 normal_scale, vec3 N, vec3 T, vec3 B, out vec3 result)
{
value = (value == vec3(0.0)) ? vec3(0.0, 0.0, 1.0) : value * 2.0 - 1.0;

value = T * value.x * normal_scale.x + B * value.y * normal_scale.y + N * value.z;

value = (dot(value, value) == 0.0) ? vec3(0.0, 0.0, 1.0) : value * 2.0 - 1.0;
value = T * value.x * normal_scale.x +
B * value.y * normal_scale.y +
N * value.z;
result = normalize(value);
}

Expand Down
Loading

0 comments on commit 64f1219

Please sign in to comment.