Skip to content

Commit

Permalink
MDL fixes (#1033)
Browse files Browse the repository at this point in the history
* Fix mismatching MDL defaults
* Fix incorrect and add missing MDL annotations
* Normalize tangent and bitangent after space transformation in MDL
  • Loading branch information
pablode authored Jul 24, 2022
1 parent d5fa7a6 commit b07a49b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
26 changes: 14 additions & 12 deletions source/MaterialXGenMdl/mdl/materialx/pbrlib.mdl
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,12 @@ export material mx_dielectric_bsdf(
);

export material mx_conductor_bsdf(
float mxp_weight = 1.0,
color mxp_ior = color(0.271, 0.677, 1.316),
color mxp_extinction = color(3.609, 2.625, 2.292),
float2 mxp_roughness = float2(0.0),
float3 mxp_normal = state::normal(),
float3 mxp_tangent = state::texture_tangent_u(0),
float mxp_weight = 1.0,
color mxp_ior = color(0.18, 0.42, 1.37),
color mxp_extinction = color(3.42, 2.35, 1.77),
float2 mxp_roughness = float2(0.0),
float3 mxp_normal = state::normal(),
float3 mxp_tangent = state::texture_tangent_u(0),
uniform mx_distribution_type mxp_distribution = mx_distribution_type_ggx
[[
anno::unused()
Expand Down Expand Up @@ -312,7 +312,7 @@ export material mx_sheen_bsdf(
);

export material mx_thin_film_bsdf(
float mxp_thickness = 550.0,
float mxp_thickness = 1000.0,
float mxp_ior = 1.5,
material mxp_base = material() [[ anno::usage( "materialx:bsdf") ]]
) [[
Expand Down Expand Up @@ -427,7 +427,9 @@ export material mx_surface(
material mxp_edf = material() [[ anno::usage( "materialx:edf") ]],
float mxp_opacity = 1.0,
uniform float mxp_transmission_ior = 1.0 // extra parameter for setting transmission IOR
)
) [[
anno::usage( "materialx:surfaceshader")
]]
= let {
bsdf bsdf_node = mxp_bsdf.surface.scattering;
material_emission edf_node = mxp_edf.surface.emission;
Expand Down Expand Up @@ -496,8 +498,8 @@ export material mx_light(
material mxp_edf = material() [[ anno::usage( "materialx:edf") ]],
color mxp_intensity = color(1.0),
float mxp_exposure = 0.0
) [[
anno::usage( "materialx:volumeshader")
) [[
anno::usage( "materialx:lightshader")
]]
= let {
edf emission = mxp_edf.surface.emission.emission;
Expand Down Expand Up @@ -830,8 +832,8 @@ export struct mx_artistic_ior__result {
// Converts the artistic parameterization reflectivity and edgecolor
// to complex IOR values; this is the inverse of the ​complex_ior​ node.
export mx_artistic_ior__result mx_artistic_ior(
color mxp_reflectivity = color(0.944, 0.776, 0.373),
color mxp_edge_color = color(0.998, 0.981, 0.751)
color mxp_reflectivity = color(0.947, 0.776, 0.371),
color mxp_edge_color = color(1.0, 0.982, 0.753)
) {
color r = math::clamp( mxp_reflectivity, color(0.0), color(0.99));
color r_sqrt = math::sqrt(r);
Expand Down
4 changes: 2 additions & 2 deletions source/MaterialXGenMdl/mdl/materialx/stdlib.mdl
Original file line number Diff line number Diff line change
Expand Up @@ -1092,7 +1092,7 @@ export float3 mx_tangent_vector3(
{
state::coordinate_space fromSpace = ::mx_map_space(mx_coordinatespace_type_model);
state::coordinate_space toSpace = ::mx_map_space(mxp_space);
return state::transform_vector(fromSpace, toSpace, state::texture_tangent_u(mxp_index));
return ::math::normalize(state::transform_vector(fromSpace, toSpace, state::texture_tangent_u(mxp_index)));
}

export float3 mx_bitangent_vector3(
Expand All @@ -1108,7 +1108,7 @@ export float3 mx_bitangent_vector3(
{
state::coordinate_space fromSpace = ::mx_map_space(mx_coordinatespace_type_model);
state::coordinate_space toSpace = ::mx_map_space(mxp_space);
return state::transform_vector(fromSpace, toSpace, state::texture_tangent_v(mxp_index));
return ::math::normalize(state::transform_vector(fromSpace, toSpace, state::texture_tangent_v(mxp_index)));
}

export float2 mx_texcoord_vector2(
Expand Down

0 comments on commit b07a49b

Please sign in to comment.