Skip to content

Commit

Permalink
Merge pull request #1319 from autodesk-forks/adsk_contrib/1382_update_5
Browse files Browse the repository at this point in the history
Final 1.38.2 main merge
  • Loading branch information
kwokcb authored Oct 8, 2021
2 parents 780e2ac + afec59c commit 149a98a
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 26 deletions.
43 changes: 37 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,51 @@
# Change Log

## [1.38.2_adsk] - ADSK Development

- Javascript bindings for MaterialXCore, MaterialXFormat, MaterialXGenShader

## [1.38.2] - Development
## [1.38.3] - Development WIP

- Unlit / modeling material library
- Javascript bindings for MaterialXCore, MaterialXFormat, MaterialXGenShader (completion)
- OCIO v2 support continued (incl OSL testing framework)
- Reference rendering / MDL DXR improvements
- Khronos PBR driven enhancements
- Nodegraph / nodedef implementation association completion
- v1.03 std surface
- Continued asset support
- tokens revised
- metadata
- Real-time / interactive enhancements
- GLslang SPIR-V framework
- Fragment generation
- USD/MTLX driven enhancements

## [1.38.2_adsk] - 2021-10-8

### Autodesk enhancements to merge
- Unlit shader (in progress)
- Std surface v1.01 and v1.02
- Nodegraph / nodedef implementation association (in progress)
- OCIO v2 GLSL initial integration
- Javascript bindings for MaterialXCore, MaterialXFormat, MaterialXGenShader (under review)
- Localization support for values (not strings)
- Enhanced texture baking support (for Fusion) (to merge to main)

### Autodesk only enhancements
- Export API. (may be removed)
- Arnold render test suite
- OGSXML code generator enhancements

## [1.38.2] - 2021-10-07

### Added
- Added an initial shader translation graph from Autodesk Standard Surface to UsdPreviewSurface.
- Added example script translateshader.py with validation in GitHub Actions.
- Added support for filename templates in texture baking.
- Added graph definitions for the MaterialX Lama node set.
- Added UI properties to the interface of UsdPreviewSurface.
- Added an initial ESSL shader generator.
- Added support for GCC 11.
- Added ESSL shader generator

### Changed
- Improved the accuracy of directional albedo computations for GGX specular and Imageworks sheen.
- Updated default color space names to follow ACES 1.2 conventions (e.g. g22_rec709), while maintaining compatibility with legacy names (e.g. gamma22).

### Fixed
Expand Down
6 changes: 3 additions & 3 deletions libraries/pbrlib/genglsl/lib/mx_microfacet_sheen.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ float mx_imageworks_sheen_brdf(float NdotL, float NdotV, float NdotH, float roug
return D * F * G / (4.0 * (NdotL + NdotV - NdotL*NdotV));
}

// Rational curve fit approximation for the directional albedo of Imageworks sheen.
float mx_imageworks_sheen_dir_albedo_curve_fit(float NdotV, float roughness)
// Rational quadratic fit to Monte Carlo data for Imageworks sheen directional albedo.
float mx_imageworks_sheen_dir_albedo_analytic(float NdotV, float roughness)
{
float a = 5.25248 - 7.66024 * NdotV + 14.26377 * roughness;
float b = 1.0 + 30.66449 * NdotV + 32.53420 * roughness;
Expand Down Expand Up @@ -79,7 +79,7 @@ float mx_imageworks_sheen_dir_albedo_monte_carlo(float NdotV, float roughness)
float mx_imageworks_sheen_dir_albedo(float NdotV, float roughness)
{
#if DIRECTIONAL_ALBEDO_METHOD == 0
float dirAlbedo = mx_imageworks_sheen_dir_albedo_curve_fit(NdotV, roughness);
float dirAlbedo = mx_imageworks_sheen_dir_albedo_analytic(NdotV, roughness);
#elif DIRECTIONAL_ALBEDO_METHOD == 1
float dirAlbedo = mx_imageworks_sheen_dir_albedo_table_lookup(NdotV, roughness);
#else
Expand Down
4 changes: 2 additions & 2 deletions libraries/pbrlib/genglsl/lib/mx_microfacet_specular.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ float mx_ggx_smith_G2(float NdotL, float NdotV, float alpha)
}

// Rational quadratic fit to Monte Carlo data for GGX directional albedo.
vec3 mx_ggx_dir_albedo_curve_fit(float NdotV, float roughness, vec3 F0, vec3 F90)
vec3 mx_ggx_dir_albedo_analytic(float NdotV, float roughness, vec3 F0, vec3 F90)
{
float x = NdotV;
float y = roughness;
Expand Down Expand Up @@ -153,7 +153,7 @@ vec3 mx_ggx_dir_albedo_monte_carlo(float NdotV, float roughness, vec3 F0, vec3 F
vec3 mx_ggx_dir_albedo(float NdotV, float roughness, vec3 F0, vec3 F90)
{
#if DIRECTIONAL_ALBEDO_METHOD == 0
return mx_ggx_dir_albedo_curve_fit(NdotV, roughness, F0, F90);
return mx_ggx_dir_albedo_analytic(NdotV, roughness, F0, F90);
#elif DIRECTIONAL_ALBEDO_METHOD == 1
return mx_ggx_dir_albedo_table_lookup(NdotV, roughness, F0, F90);
#else
Expand Down
4 changes: 2 additions & 2 deletions libraries/pbrlib/genosl/lib/mx_microfacet_sheen.osl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "pbrlib/genosl/lib/mx_microfacet.osl"

// Rational curve fit approximation for the directional albedo of Imageworks sheen.
float mx_imageworks_sheen_dir_albedo_curve_fit(float NdotV, float roughness)
float mx_imageworks_sheen_dir_albedo_analytic(float NdotV, float roughness)
{
float a = 5.25248 - 7.66024 * NdotV + 14.26377 * roughness;
float b = 1.0 + 30.66449 * NdotV + 32.53420 * roughness;
Expand All @@ -10,6 +10,6 @@ float mx_imageworks_sheen_dir_albedo_curve_fit(float NdotV, float roughness)

float mx_imageworks_sheen_dir_albedo(float NdotV, float roughness)
{
float dirAlbedo = mx_imageworks_sheen_dir_albedo_curve_fit(NdotV, roughness);
float dirAlbedo = mx_imageworks_sheen_dir_albedo_analytic(NdotV, roughness);
return clamp(dirAlbedo, 0.0, 1.0);
}
4 changes: 2 additions & 2 deletions libraries/pbrlib/genosl/lib/mx_microfacet_specular.osl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ float mx_ggx_smith_G2(float NdotL, float NdotV, float alpha)
}

// https://www.unrealengine.com/blog/physically-based-shading-on-mobile
color mx_ggx_dir_albedo_curve_fit(float NdotV, float roughness, color F0, color F90)
color mx_ggx_dir_albedo_analytic(float NdotV, float roughness, color F0, color F90)
{
vector4 c0 = vector4(-1, -0.0275, -0.572, 0.022);
vector4 c1 = vector4( 1, 0.0425, 1.04, -0.04 );
Expand Down Expand Up @@ -82,7 +82,7 @@ color mx_ggx_dir_albedo_monte_carlo(float _NdotV, float roughness, color F0, col
color mx_ggx_dir_albedo(float NdotV, float roughness, color F0, color F90)
{
#if GGX_DIRECTIONAL_ALBEDO_METHOD == 0
return mx_ggx_dir_albedo_curve_fit(NdotV, roughness, F0, F90);
return mx_ggx_dir_albedo_analytic(NdotV, roughness, F0, F90);
#elif GGX_DIRECTIONAL_ALBEDO_METHOD == 1
return mx_ggx_dir_albedo_table_lookup(NdotV, roughness, F0, F90);
#else
Expand Down
2 changes: 1 addition & 1 deletion source/JsMaterialX/JsMaterialXGenShader/JsGenContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void initContext(mx::GenContext& context, mx::FileSearchPath searchPath, mx::Doc
context.getOptions().fileTextureVerticalFlip = false;
context.getOptions().hwMaxActiveLightSources = 1;
context.getOptions().hwSpecularEnvironmentMethod = mx::SPECULAR_ENVIRONMENT_FIS;
context.getOptions().hwDirectionalAlbedoMethod = mx::DIRECTIONAL_ALBEDO_CURVE_FIT;
context.getOptions().hwDirectionalAlbedoMethod = mx::DIRECTIONAL_ALBEDO_ANALYTIC;

// Initialize color management.
mx::DefaultColorManagementSystemPtr cms = mx::DefaultColorManagementSystem::create(context.getShaderGenerator().getTarget());
Expand Down
2 changes: 1 addition & 1 deletion source/JsMaterialX/JsMaterialXGenShader/JsGenOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ EMSCRIPTEN_BINDINGS(GenOptions)
;

ems::enum_<mx::HwDirectionalAlbedoMethod>("HwDirectionalAlbedoMethod")
.value("DIRECTIONAL_ALBEDO_CURVE_FIT",mx::HwDirectionalAlbedoMethod::DIRECTIONAL_ALBEDO_CURVE_FIT)
.value("DIRECTIONAL_ALBEDO_ANALYTIC",mx::HwDirectionalAlbedoMethod::DIRECTIONAL_ALBEDO_ANALYTIC)
.value("DIRECTIONAL_ALBEDO_TABLE", mx::HwDirectionalAlbedoMethod::DIRECTIONAL_ALBEDO_TABLE)
.value("DIRECTIONAL_ALBEDO_MONTE_CARLO", mx::HwDirectionalAlbedoMethod::DIRECTIONAL_ALBEDO_MONTE_CARLO)
;
Expand Down
6 changes: 3 additions & 3 deletions source/MaterialXGenShader/GenOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ enum HwSpecularEnvironmentMethod
/// Method to use for directional albedo evaluation
enum HwDirectionalAlbedoMethod
{
/// Use a curve fit approximation for directional albedo.
DIRECTIONAL_ALBEDO_CURVE_FIT,
/// Use an analytic approximation for directional albedo.
DIRECTIONAL_ALBEDO_ANALYTIC,

/// Use a table look-up for directional albedo.
DIRECTIONAL_ALBEDO_TABLE,
Expand All @@ -70,7 +70,7 @@ class MX_GENSHADER_API GenOptions
addUpstreamDependencies(true),
hwTransparency(false),
hwSpecularEnvironmentMethod(SPECULAR_ENVIRONMENT_FIS),
hwDirectionalAlbedoMethod(DIRECTIONAL_ALBEDO_CURVE_FIT),
hwDirectionalAlbedoMethod(DIRECTIONAL_ALBEDO_ANALYTIC),
hwWriteDepthMoments(false),
hwShadowMap(false),
hwAmbientOcclusion(false),
Expand Down
18 changes: 14 additions & 4 deletions source/MaterialXGenShader/ShaderGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,15 @@ void ShaderGraph::addDefaultGeomNode(ShaderInput* input, const GeomPropDef& geom

void ShaderGraph::addColorTransformNode(ShaderInput* input, const ColorSpaceTransform& transform, GenContext& context)
{
if (input->getConnection() && !input->isBindInput())
{
// Ignore connected inputs, which are unaffected by color space bindings.
return;
}

ColorManagementSystemPtr colorManagementSystem = context.getShaderGenerator().getColorManagementSystem();
if (!input->isBindInput() && (!colorManagementSystem || input->getConnection()))
if (!colorManagementSystem)
{
// Ignore unbound inputs with connections as they are not
// allowed to have colorspaces specified.
return;
}

Expand Down Expand Up @@ -297,8 +301,14 @@ void ShaderGraph::addColorTransformNode(ShaderOutput* output, const ColorSpaceTr

void ShaderGraph::addUnitTransformNode(ShaderInput* input, const UnitTransform& transform, GenContext& context)
{
if (input->getConnection() && !input->isBindInput())
{
// Ignore connected inputs, which are unaffected by unit bindings.
return;
}

UnitSystemPtr unitSystem = context.getShaderGenerator().getUnitSystem();
if (!input->isBindInput() && (!unitSystem || input->getConnection()))
if (!unitSystem)
{
return;
}
Expand Down
4 changes: 2 additions & 2 deletions source/MaterialXView/Viewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ Viewer::Viewer(const std::string& materialFilename,
_genContextEssl.getOptions().fileTextureVerticalFlip = false;
_genContextEssl.getOptions().hwMaxActiveLightSources = 1;
_genContextEssl.getOptions().hwSpecularEnvironmentMethod = mx::SPECULAR_ENVIRONMENT_FIS;
_genContextEssl.getOptions().hwDirectionalAlbedoMethod = mx::DIRECTIONAL_ALBEDO_CURVE_FIT;
_genContextEssl.getOptions().hwDirectionalAlbedoMethod = mx::DIRECTIONAL_ALBEDO_ANALYTIC;

#if MATERIALX_BUILD_GEN_OSL
// Set OSL generator options.
Expand Down Expand Up @@ -930,7 +930,7 @@ void Viewer::createAdvancedSettings(Widget* parent)
{
_genContext.getOptions().hwDirectionalAlbedoMethod = enable ? mx::DIRECTIONAL_ALBEDO_MONTE_CARLO : mx::DIRECTIONAL_ALBEDO_TABLE;
// There is no Albedo Table support for Essl currently. Always set to curve fit.
_genContextEssl.getOptions().hwDirectionalAlbedoMethod = mx::DIRECTIONAL_ALBEDO_CURVE_FIT;
_genContextEssl.getOptions().hwDirectionalAlbedoMethod = mx::DIRECTIONAL_ALBEDO_ANALYTIC;
reloadShaders();
});

Expand Down

0 comments on commit 149a98a

Please sign in to comment.