Skip to content

Commit

Permalink
Improvements to thin-film BSDF (#1055)
Browse files Browse the repository at this point in the history
This PR improves several aspects of the thin film BSDF:

- Adds support for wavelength-dependent complex refraction indices (relevant for metallic base layer)
- Adds (limited) support for thin film effects to generalized_schlick_bsdf
- Adds iridescence to glTF PBR
  • Loading branch information
proog128 authored Sep 30, 2022
1 parent 3d9f60b commit c7a0304
Show file tree
Hide file tree
Showing 5 changed files with 345 additions and 90 deletions.
85 changes: 83 additions & 2 deletions libraries/bxdf/gltf_pbr.mtlx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
<input name="alpha" type="float" value="1" uimin="0" uimax="1" uiname="Alpha" uifolder="Alpha" />
<input name="alpha_mode" uniform="true" type="integer" enum="OPAQUE, MASK, BLEND" enumvalues="0, 1, 2" value="0" uiname="Alpha Mode" uifolder="Alpha" />
<input name="alpha_cutoff" uniform="true" type="float" value="0.5" uimin="0" uimax="1" uiname="Alpha Cutoff" uifolder="Alpha" />
<input name="iridescence" type="float" value="0" uimin="0" uimax="1" uiname="Iridescence" uifolder="Iridescence" />
<input name="iridescence_ior" uniform="true" type="float" value="1.3" uimin="1" uisoftmax="3" uiname="Iridescence Index of Refraction" uifolder="Iridescence" />
<input name="iridescence_thickness" type="float" value="100" uimin="0" uisoftmin="100" uisoftmax="400" uiname="Iridescence Thickness" uifolder="Iridescence" />
<input name="sheen_color" type="color3" value="0, 0, 0" uimin="0, 0, 0" uimax="1, 1, 1" uiname="Sheen Color" uifolder="Sheen" />
<input name="sheen_roughness" type="float" value="0" uimin="0" uimax="1" uiname="Sheen Roughness" uifolder="Sheen" />
<input name="clearcoat" type="float" value="0" uimin="0" uimax="1" uiname="Clearcoat" uifolder="Clearcoat" />
Expand Down Expand Up @@ -138,6 +141,58 @@
<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). -->

<oren_nayar_diffuse_bsdf name="tf_diffuse_bsdf" type="BSDF">
<input name="color" type="color3" interfacename="base_color" />
<input name="normal" type="vector3" interfacename="normal" />
</oren_nayar_diffuse_bsdf>

<dielectric_bsdf name="tf_transmission_bsdf" type="BSDF">
<input name="weight" type="float" value="1" />
<input name="tint" type="color3" interfacename="base_color" />
<input name="ior" type="float" interfacename="ior" />
<input name="roughness" type="vector2" nodename="roughness_uv" />
<input name="normal" type="vector3" interfacename="normal" />
<input name="scatter_mode" type="string" value="T" />
</dielectric_bsdf>

<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" />
<input name="roughness" type="vector2" nodename="roughness_uv" />
<input name="normal" type="vector3" interfacename="normal" />
<input name="scatter_mode" type="string" value="R" />
</generalized_schlick_bsdf>

<mix name="tf_transmission_mix" type="BSDF">
<input name="bg" type="BSDF" nodename="tf_diffuse_bsdf" />
<input name="fg" type="BSDF" nodename="tf_transmission_bsdf" />
<input name="mix" type="float" interfacename="transmission" />
</mix>

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

<thin_film_bsdf name="dielectric_thinfilm_bsdf" type="BSDF">
<input name="thickness" type="float" interfacename="iridescence_thickness" />
<input name="ior" type="float" interfacename="iridescence_ior" />
</thin_film_bsdf>

<layer name="iridescent_dielectric_bsdf" type="BSDF">
<input name="top" type="BSDF" nodename="dielectric_thinfilm_bsdf" />
<input name="base" type="BSDF" nodename="tf_dielectric_bsdf" />
</layer>

<mix name="mix_iridescent_dielectric_bsdf" type="BSDF">
<input name="bg" type="BSDF" nodename="dielectric_bsdf" />
<input name="fg" type="BSDF" nodename="iridescent_dielectric_bsdf" />
<input name="mix" type="float" interfacename="iridescence" />
</mix>

<!-- Metal -->

<generalized_schlick_bsdf name="metal_bsdf" type="BSDF">
Expand All @@ -147,11 +202,37 @@
<input name="normal" type="vector3" interfacename="normal" />
</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">
<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" />
</generalized_schlick_bsdf>

<thin_film_bsdf name="metal_thinfilm_bsdf" type="BSDF">
<input name="thickness" type="float" interfacename="iridescence_thickness" />
<input name="ior" type="float" interfacename="iridescence_ior" />
</thin_film_bsdf>

<layer name="iridescent_metal_bsdf" type="BSDF">
<input name="top" type="BSDF" nodename="metal_thinfilm_bsdf" />
<input name="base" type="BSDF" nodename="tf_metal_bsdf" />
</layer>

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

<!-- Dielectric/metal mix -->

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

Expand Down
Loading

0 comments on commit c7a0304

Please sign in to comment.