Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 18 additions & 37 deletions libraries/bxdf/gltf_pbr.mtlx
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@
<input name="color" type="color3" interfacename="base_color" />
<input name="normal" type="vector3" interfacename="normal" />
</oren_nayar_diffuse_bsdf>

<dielectric_bsdf name="transmission_bsdf" type="BSDF">
<input name="weight" type="float" value="1" />
<input name="tint" type="color3" interfacename="base_color" />
Expand All @@ -150,6 +149,11 @@
<input name="tangent" type="vector3" nodename="selected_tangent" />
<input name="scatter_mode" type="string" value="T" />
</dielectric_bsdf>
<mix name="transmission_blend" type="BSDF">
<input name="bg" type="BSDF" nodename="diffuse_bsdf" />
<input name="fg" type="BSDF" nodename="transmission_bsdf" />
<input name="mix" type="float" interfacename="transmission" />
</mix>

<generalized_schlick_bsdf name="reflection_bsdf" type="BSDF">
<input name="color0" type="color3" nodename="dielectric_f0" />
Expand All @@ -159,21 +163,6 @@
<input name="tangent" type="vector3" nodename="selected_tangent" />
<input name="scatter_mode" type="string" value="R" />
</generalized_schlick_bsdf>

<mix name="transmission_mix" type="BSDF">
<input name="bg" type="BSDF" nodename="diffuse_bsdf" />
<input name="fg" type="BSDF" nodename="transmission_bsdf" />
<input name="mix" type="float" interfacename="transmission" />
</mix>

<layer name="dielectric_bsdf" type="BSDF">
<input name="top" type="BSDF" nodename="reflection_bsdf" />
<input name="base" type="BSDF" nodename="transmission_mix" />
</layer>

<!-- Thin-film + Dielectric
Note: Due to limitations in codegen, the base layer BSDF is duplicated (#1035). -->

<generalized_schlick_bsdf name="tf_reflection_bsdf" type="BSDF">
<input name="color0" type="color3" nodename="dielectric_f0" />
<input name="color90" type="color3" nodename="dielectric_f90" />
Expand All @@ -185,32 +174,26 @@
<input name="thinfilm_ior" type="float" interfacename="iridescence_ior" />
</generalized_schlick_bsdf>


<layer name="tf_dielectric_bsdf" type="BSDF">
<input name="top" type="BSDF" nodename="tf_reflection_bsdf" />
<input name="base" type="BSDF" nodename="transmission_mix" />
</layer>

<mix name="mix_iridescent_dielectric_bsdf" type="BSDF">
<input name="bg" type="BSDF" nodename="dielectric_bsdf" />
<input name="fg" type="BSDF" nodename="tf_dielectric_bsdf" />
<mix name="reflection_blend" type="BSDF">
<input name="bg" type="BSDF" nodename="reflection_bsdf" />
<input name="fg" type="BSDF" nodename="tf_reflection_bsdf" />
<input name="mix" type="float" interfacename="iridescence" />
</mix>

<!-- Metal -->
<layer name="iridescent_dielectric_bsdf" type="BSDF">
<input name="top" type="BSDF" nodename="reflection_blend" />
<input name="base" type="BSDF" nodename="transmission_blend" />
</layer>

<!-- Metal -->
<generalized_schlick_bsdf name="metal_bsdf" type="BSDF">
<input name="color0" type="color3" interfacename="base_color" />
<input name="color90" type="color3" value="1, 1, 1" />
<input name="roughness" type="vector2" nodename="roughness_uv" />
<input name="normal" type="vector3" interfacename="normal" />
<input name="tangent" type="vector3" nodename="selected_tangent" />
</generalized_schlick_bsdf>

<!-- Thin-film + Metal
Note: Due to limitations in codegen, the base layer BSDF is duplicated (#1035). -->

<generalized_schlick_bsdf name="tf_metal_bsdf" type="BSDF">
<generalized_schlick_bsdf name="metal_bsdf_tf" type="BSDF">
<input name="color0" type="color3" interfacename="base_color" />
<input name="color90" type="color3" value="1, 1, 1" />
<input name="roughness" type="vector2" nodename="roughness_uv" />
Expand All @@ -219,18 +202,16 @@
<input name="thinfilm_thickness" type="float" interfacename="iridescence_thickness" />
<input name="thinfilm_ior" type="float" interfacename="iridescence_ior" />
</generalized_schlick_bsdf>

<mix name="mix_iridescent_metal_bsdf" type="BSDF">
<mix name="metal_blend" type="BSDF">
<input name="bg" type="BSDF" nodename="metal_bsdf" />
<input name="fg" type="BSDF" nodename="tf_metal_bsdf" />
<input name="fg" type="BSDF" nodename="metal_bsdf_tf" />
<input name="mix" type="float" interfacename="iridescence" />
</mix>

<!-- Dielectric/metal mix -->

<mix name="base_mix" type="BSDF">
<input name="bg" type="BSDF" nodename="mix_iridescent_dielectric_bsdf" />
<input name="fg" type="BSDF" nodename="mix_iridescent_metal_bsdf" />
<input name="bg" type="BSDF" nodename="iridescent_dielectric_bsdf" />
<input name="fg" type="BSDF" nodename="metal_blend" />
<input name="mix" type="float" interfacename="metallic" />
</mix>

Expand Down
7 changes: 6 additions & 1 deletion source/MaterialXGenShader/GenOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ class MX_GENSHADER_API GenOptions
hwNormalizeUdimTexCoords(false),
hwWriteAlbedoTable(false),
hwWriteEnvPrefilter(false),
hwImplicitBitangents(true)
hwImplicitBitangents(true),
optReplaceBsdfMixWithLinearCombination(false)
{
}
virtual ~GenOptions() { }
Expand Down Expand Up @@ -197,6 +198,10 @@ class MX_GENSHADER_API GenOptions
/// Calculate fallback bitangents from existing normals and tangents
/// inside the bitangent node.
bool hwImplicitBitangents;

/// Analyse the graph of ShaderNodes and replace any ND_mix_bsdf nodes
/// with a linear combination of their weighted inputs
bool optReplaceBsdfMixWithLinearCombination;
};

MATERIALX_NAMESPACE_END
Expand Down
Loading