Skip to content

Commit

Permalink
Merge branch 'main' into bhata/document_datalibrary
Browse files Browse the repository at this point in the history
  • Loading branch information
ashwinbhat authored Oct 13, 2024
2 parents 164131e + ede6573 commit fa27416
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 17 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -229,13 +229,13 @@ 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 --vulkanGlsl True --validatorArgs="-V --aml"
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"
- name: Coverage Analysis Tests
if: matrix.coverage_analysis == '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>
2 changes: 1 addition & 1 deletion libraries/pbrlib/genmdl/pbrlib_genmdl_impl.mtlx
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,6 @@
<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" file="mx_hair_bsdf.glsl" 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" />
<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>
6 changes: 3 additions & 3 deletions python/Scripts/generateshader.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
'''
Utility to generate the shader for materials found in a MaterialX document. One file will be generated
for each material / shader found. The currently supported target languages are GLSL, OSL, MDL and ESSL.
Generate shader code for each renderable element in a MaterialX document or folder.
The currently supported target languages are GLSL, ESSL, MSL, OSL, and MDL.
'''

import sys, os, argparse, subprocess
Expand Down Expand Up @@ -43,7 +43,7 @@ def getMaterialXFiles(rootPath):
return filelist

def main():
parser = argparse.ArgumentParser(description='Generate shader code for each material / shader in a document.')
parser = argparse.ArgumentParser(description='Generate shader code for each renderable element in a MaterialX document or folder.')
parser.add_argument('--path', dest='paths', action='append', nargs='+', help='An additional absolute search path location (e.g. "/projects/MaterialX")')
parser.add_argument('--library', dest='libraries', action='append', nargs='+', help='An additional relative path to a custom data library folder (e.g. "libraries/custom")')
parser.add_argument('--target', dest='target', default='glsl', help='Target shader generator to use (e.g. "glsl, osl, mdl, essl, vulkan"). Default is glsl.')
Expand Down

0 comments on commit fa27416

Please sign in to comment.