Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding LamaGeneralizedSchlick and LamaIridescence Nodes #1897

Merged
merged 5 commits into from
Jun 24, 2024
Merged
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
198 changes: 198 additions & 0 deletions libraries/bxdf/lama/lama_generalized_schlick.mtlx
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
<?xml version="1.0"?>
<materialx version="1.39" colorspace="acescg">
<nodedef name="ND_lama_generalized_schlick" node="LamaGeneralizedSchlick" nodegroup="pbr" doc="Lama generalized schlick" version="1.0" isdefaultversion="true">
<input name="reflectionTint" type="color3" value="1.0, 1.0, 1.0" uiname="Reflection Tint" uifolder="Main"
doc="Color multiplier for external reflection. It should be used with parcimony, as a non-white value breaks physicality." />
<input name="transmissionTint" type="color3" value="1.0, 1.0, 1.0" uiname="Transmission Tint" uifolder="Main"
doc="Color multiplier for rays going inside the medium (covers external transmission and internal reflection). It should be used with parcimony, as a non-white value breaks physicality. The prefered way to define the color of a dielectric is through the Interior attributes right below." />
<input name="fresnelMode" type="integer" uniform="true" enum="Scientific,Artistic" enumvalues="0,1" value="0" uiname="Fresnel Mode" uifolder="Main"
doc="Fresnel mode" />
<input name="IOR" type="vector3" value="1.5,1.5,1.5" uiname="IOR" uifolder="Main"
doc="Index of refraction (often denoted by eta), defining the color reflected by the surface in the normal direction." />
<input name="reflectivity" type="color3" value="0.04, 0.04, 0.04" uiname="Reflectivity" uifolder="Main"
doc="Color reflected by the surface in the normal direction." />
<input name="reflectivity90" type="color3" value="1.0, 1.0, 1.0" uiname="Reflectivity90" uifolder="Main"
doc="Color reflected by the surface at the grazing angle. Should be kept at 1,1,1 for most materials." />
<input name="reflectivityProfile" type="float" value="0.2" uiname="ReflectivityProfile" uifolder="Main"
doc="The inverse of the exponent to use for Schlick." />
<input name="roughness" type="float" value="0.1" uimin="0.0" uimax="1.0" uiname="Roughness" uifolder="Main"
doc="Micro-facet distribution roughness." />
<input name="normal" type="vector3" defaultgeomprop="Nworld" uiname="Normal" uifolder="Main"
doc="Shading normal, typically defined by bump or normal mapping. Defaults to the smooth surface normal if not set." />
<input name="anisotropy" type="float" value="0.0" uimin="-1.0" uimax="1.0" uiname="Anisotropy" uifolder="Anisotropy"
doc="Defines the amount of anisotropy, changing the co-tangent axis roughness from the original value to 1 (or to 0 with a negative value)." />
<input name="anisotropyDirection" type="vector3" defaultgeomprop="Tworld" uiname="Direction" uifolder="Anisotropy"
doc="Overrides the surface tangent as the anisotropy direction." />
<input name="anisotropyRotation" type="float" value="0.0" uiname="Rotation" uifolder="Anisotropy"
doc="Rotates the anisotropy direction (possibly overriden by the previous attribute) around the normal, from 0 to 360 degrees." />
<input name="absorptionColor" type="color3" value="1.0, 1.0, 1.0" uiname="Absorption Color" uifolder="Interior"
doc="Absorption color" />
<input name="absorptionRadius" type="float" value="1.0" uiname="Absorption Radius" uifolder="Interior"
doc="Absorption radius" />
<input name="scatterColor" type="color3" value="0.0, 0.0, 0.0" uiname="Scatter Color" uifolder="Interior"
doc="Scatter color" />
<input name="scatterAnisotropy" type="float" value="0.0" uimin="-1.0" uimax="1.0" uiname="Scatter Anisotropy" uifolder="Interior"
doc="Scatter anisotropy" />
<output name="out" type="BSDF" />
</nodedef>

<nodegraph name="IMPL_lama_generalized_schlick" nodedef="ND_lama_generalized_schlick">

<!-- Dielectric IOR -->
<extract name="ior_float" type="float">
<input name="in" type="vector3" interfacename="IOR" />
<input name="index" type="integer" value="0" />
</extract>

<!-- Color0 -->
<convert name="convert_ior" type="color3">
<input name="in" type="vector3" interfacename="IOR" />
</convert>
<add name="ior_plus_one" type="color3">
<input name="in1" type="color3" nodename="convert_ior" />
<input name="in2" type="float" value="1" />
</add>
<subtract name="ior_sub_one" type="color3">
<input name="in1" type="color3" nodename="convert_ior" />
<input name="in2" type="float" value="1" />
</subtract>
<divide name="ior_divide" type="color3">
<input name="in1" type="color3" nodename="ior_sub_one" />
<input name="in2" type="color3" nodename="ior_plus_one" />
</divide>
<multiply name="ior_multiply" type="color3">
<input name="in1" type="color3" nodename="ior_divide" />
<input name="in2" type="color3" nodename="ior_divide" />
</multiply>
<multiply name="ior_reflection_tint" type="color3">
<input name="in1" type="color3" nodename="ior_multiply" />
<input name="in2" type="color3" interfacename="reflectionTint" />
</multiply>
<multiply name="reflectivity_reflection_tint" type="color3">
<input name="in1" type="color3" interfacename="reflectivity" />
<input name="in2" type="color3" interfacename="reflectionTint" />
</multiply>
<switch name="fresnel_mode_switch_reflection" type="color3">
<input name="in1" type="color3" nodename="ior_reflection_tint" />
<input name="in2" type="color3" nodename="reflectivity_reflection_tint" />
<input name="which" type="integer" interfacename="fresnelMode" />
</switch>

<!-- Color90 -->
<multiply name="reflectivity90_reflection_tint" type="color3">
<input name="in1" type="color3" interfacename="reflectivity90" />
<input name="in2" type="color3" interfacename="reflectionTint" />
</multiply>

<!-- Exponent -->
<divide name="exponent" type="float">
<input name="in1" type="float" value="1" />
<input name="in2" type="float" interfacename="reflectivityProfile" />
</divide>

<!-- Roughness -->
<subtract name="roughness_inverse" type="float">
<input name="in1" type="float" value="1.0" />
<input name="in2" type="float" interfacename="roughness" />
</subtract>
<ifgreatereq name="delta" type="float">
<input name="in1" type="float" nodename="roughness_inverse" />
<input name="in2" type="float" interfacename="roughness" />
<input name="value1" type="float" interfacename="anisotropy" />
<input name="value2" type="float" value="0" />
</ifgreatereq>
<multiply name="roughness_additional" type="float">
<input name="in1" type="float" interfacename="anisotropy" />
<input name="in2" type="float" nodename="delta" />
</multiply>
<add name="roughness_bitangent" type="float">
<input name="in1" type="float" interfacename="roughness" />
<input name="in2" type="float" nodename="roughness_additional" />
</add>
<clamp name="roughness_bitangent_clamped" type="float">
<input name="in" type="float" nodename="roughness_bitangent" />
</clamp>
<combine2 name="roughness_linear" type="vector2">
<input name="in1" type="float" interfacename="roughness" />
<input name="in2" type="float" nodename="roughness_bitangent_clamped" />
</combine2>
<power name="roughness_anisotropic_squared" type="vector2">
<input name="in1" type="vector2" nodename="roughness_linear" />
<input name="in2" type="float" value="2" />
</power>
<max name="roughness_anisotropic_squared_clamped" type="vector2">
<input name="in1" type="vector2" nodename="roughness_anisotropic_squared" />
<input name="in2" type="float" value="0.000001" />
</max>

<!-- Tangent -->
<multiply name="tangent_rotate_degree" type="float">
<input name="in1" type="float" interfacename="anisotropyRotation" />
<input name="in2" type="float" value="-360" />
</multiply>
<rotate3d name="tangent_rotate" type="vector3">
<input name="in" type="vector3" interfacename="anisotropyDirection" />
<input name="amount" type="float" nodename="tangent_rotate_degree" />
<input name="axis" type="vector3" interfacename="normal" />
</rotate3d>
<normalize name="tangent_rotate_normalize" type="vector3">
<input name="in" type="vector3" nodename="tangent_rotate" />
</normalize>

<!-- Interior -->
<divide name="absorption" type="color3">
<input name="in1" type="color3" interfacename="absorptionColor" />
<input name="in2" type="float" interfacename="absorptionRadius" />
</divide>
<convert name="absorption_vector" type="vector3">
<input name="in" type="color3" nodename="absorption" />
</convert>
<convert name="scatter_vector" type="vector3">
<input name="in" type="color3" interfacename="scatterColor" />
</convert>
<anisotropic_vdf name="interior_vdf" type="VDF">
<input name="absorption" type="vector3" nodename="absorption_vector" />
<input name="scattering" type="vector3" nodename="scatter_vector" />
<input name="anisotropy" type="float" interfacename="scatterAnisotropy" />
</anisotropic_vdf>

<!-- BTDF -->
<dielectric_bsdf name="transmission_bsdf" type="BSDF">
<input name="weight" type="float" value="1.0" />
<input name="tint" type="color3" interfacename="transmissionTint" />
<input name="ior" type="float" nodename="ior_float" />
<input name="roughness" type="vector2" nodename="roughness_anisotropic_squared_clamped" />
<input name="normal" type="vector3" interfacename="normal" />
<input name="tangent" type="vector3" nodename="tangent_rotate_normalize" />
<input name="distribution" type="string" value="ggx" />
<input name="scatter_mode" type="string" value="T" />
</dielectric_bsdf>
<layer name="transmission_layer" type="BSDF">
<input name="top" type="BSDF" nodename="transmission_bsdf" />
<input name="base" type="VDF" nodename="interior_vdf" />
</layer>

<!-- BRDF -->
<generalized_schlick_bsdf name="reflection_generalized_schlick_bsdf" type="BSDF">
<input name="weight" type="float" value="1.0" />
<input name="color0" type="color3" nodename="fresnel_mode_switch_reflection" />
<input name="color90" type="color3" nodename="reflectivity90_reflection_tint" />
<input name="exponent" type="float" nodename="exponent" />
<input name="roughness" type="vector2" nodename="roughness_anisotropic_squared_clamped" />
<input name="normal" type="vector3" interfacename="normal" />
<input name="tangent" type="vector3" nodename="tangent_rotate_normalize" />
<input name="distribution" type="string" value="ggx" />
<input name="scatter_mode" type="string" value="R" />
</generalized_schlick_bsdf>

<!-- BSDF -->
<layer name="generalized_schlick_bsdf" type="BSDF">
<input name="top" type="BSDF" nodename="reflection_generalized_schlick_bsdf" />
<input name="base" type="BSDF" nodename="transmission_layer" />
</layer>

<!-- Output -->
<output name="out" type="BSDF" nodename="generalized_schlick_bsdf" />

</nodegraph>
</materialx>
77 changes: 77 additions & 0 deletions libraries/bxdf/lama/lama_iridescence.mtlx
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?xml version="1.0"?>
<materialx version="1.39" colorspace="acescg">
<nodedef name="ND_lama_iridescence" node="LamaIridescence" nodegroup="pbr" doc="Lama iridescence" version="1.0" isdefaultversion="true">
<input name="roughness" type="float" value="0.01" uimin="0.0" uimax="1.0" uiname="Roughness" uifolder="Main"
doc="Micro-facet distribution roughness." />
<input name="anisotropy" type="float" value="0.0" uimin="-1.0" uimax="1.0" uiname="Anisotropy" uifolder="Anisotropy"
doc="Defines the amount of anisotropy, changing the co-tangent axis roughness from the original value to 1 (or to 0 with a negative value)." />
<input name="relativeFilmThickness" type="float" value="0.5" uimin="0.0" uimax="1.0" uiname="relativeFilmThickness" uifolder="Main"
doc="Relative thin film thickness in the range from 0 to 1 will be scaled to the minimum and maximum thickness, respectively." />
<input name="minFilmThickness" type="float" value="400.0" uiname="minFilmThickness" uifolder="Main"
doc="Minimum thin film thickness in nanometers, driving the iridescent effect." />
<input name="maxFilmThickness" type="float" value="800.0" uiname="maxFilmThickness" uifolder="Main"
doc="Maximum thin film thickness in nanometers, driving the iridescent effect." />
<input name="filmIOR" type="float" value="1.3" uiname="filmIOR" uifolder="Main"
doc="Thin film index of refraction, driving the iridescent effect." />
<output name="out" type="BSDF" />
</nodedef>

<nodegraph name="IMPL_lama_iridescence" nodedef="ND_lama_iridescence">

<!-- Roughness -->
<subtract name="roughness_inverse" type="float">
<input name="in1" type="float" value="1.0" />
<input name="in2" type="float" interfacename="roughness" />
</subtract>
<ifgreatereq name="delta" type="float">
<input name="in1" type="float" nodename="roughness_inverse" />
<input name="in2" type="float" interfacename="roughness" />
<input name="value1" type="float" interfacename="anisotropy" />
<input name="value2" type="float" value="0" />
</ifgreatereq>
<multiply name="roughness_additional" type="float">
<input name="in1" type="float" interfacename="anisotropy" />
<input name="in2" type="float" nodename="delta" />
</multiply>
<add name="roughness_bitangent" type="float">
<input name="in1" type="float" interfacename="roughness" />
<input name="in2" type="float" nodename="roughness_additional" />
</add>
<clamp name="roughness_bitangent_clamped" type="float">
<input name="in" type="float" nodename="roughness_bitangent" />
</clamp>
<combine2 name="roughness_linear" type="vector2">
<input name="in1" type="float" interfacename="roughness" />
<input name="in2" type="float" nodename="roughness_bitangent_clamped" />
</combine2>
<power name="roughness_anisotropic_squared" type="vector2">
<input name="in1" type="vector2" nodename="roughness_linear" />
<input name="in2" type="float" value="2" />
</power>
<max name="roughness_anisotropic_squared_clamped" type="vector2">
<input name="in1" type="vector2" nodename="roughness_anisotropic_squared" />
<input name="in2" type="float" value="0.000001" />
</max>

<!-- Thinfilm Thickness -->
<mix name="thinfilm_thickness" type="float">
<input name="fg" type="float" interfacename="maxFilmThickness" />
<input name="bg" type="float" interfacename="minFilmThickness" />
<input name="mix" type="float" interfacename="relativeFilmThickness" />
</mix>

<!-- BSDF -->
<dielectric_bsdf name="iridescence_bsdf" type="BSDF">
<input name="roughness" type="vector2" nodename="roughness_anisotropic_squared_clamped" />
<input name="ior" type="float" value="1.0" />
<input name="thinfilm_thickness" type="float" nodename="thinfilm_thickness" />
<input name="thinfilm_ior" type="float" interfacename="filmIOR" />
<input name="distribution" type="string" value="ggx" />
<input name="scatter_mode" type="string" value="RT" />
</dielectric_bsdf>

<!-- Output -->
<output name="out" type="BSDF" nodename="iridescence_bsdf" />

</nodegraph>
</materialx>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0"?>
<materialx version="1.38" colorspace="acescg">

<!-- LamaGeneralizedSchlick -->
<LamaGeneralizedSchlick name="LamaGeneralizedSchlick" type="BSDF">
<input name="reflectionTint" type="color3" value="1.0, 1.0, 1.0" />
<input name="transmissionTint" type="color3" value="1.0, 1.0, 1.0" />
<input name="fresnelMode" type="integer" value="0" />
<input name="IOR" type="vector3" value="1.5,1.5,1.5" />
<input name="reflectivity" type="color3" value="0.04, 0.04, 0.04" />
<input name="reflectivity90" type="color3" value="1.0, 1.0, 1.0" />
<input name="reflectivityProfile" type="float" value="0.2" />
<input name="roughness" type="float" value="0.1" />
<input name="anisotropy" type="float" value="0.0" />
<input name="anisotropyRotation" type="float" value="0.0" />
<input name="absorptionColor" type="color3" value="1.0, 1.0, 1.0" />
<input name="absorptionRadius" type="float" value="1.0" />
<input name="scatterColor" type="color3" value="0.0, 0.0, 0.0" />
<input name="scatterAnisotropy" type="float" value="0.0" />
</LamaGeneralizedSchlick>
<surface name="LamaGeneralizedSchlickSurface" type="surfaceshader">
<input name="bsdf" type="BSDF" nodename="LamaGeneralizedSchlick" />
</surface>
<surfacematerial name="LamaGeneralizedSchlickTest" type="material">
<input name="surfaceshader" type="surfaceshader" nodename="LamaGeneralizedSchlickSurface" />
</surfacematerial>

</materialx>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0"?>
<materialx version="1.38" colorspace="acescg">

<!-- LamaIridescence -->
<LamaIridescence name="LamaIridescence" type="BSDF">
<input name="roughness" type="float" value="0.01" />
<input name="anisotropy" type="float" value="0.0" />
<input name="relativeFilmThickness" type="float" value="0.5" />
<input name="minFilmThickness" type="float" value="400.0" />
<input name="maxFilmThickness" type="float" value="800.0" />
<input name="filmIOR" type="float" value="1.3" />
</LamaIridescence>
<surface name="LamaIridescenceSurface" type="surfaceshader">
<input name="bsdf" type="BSDF" nodename="LamaIridescence" />
</surface>
<surfacematerial name="LamaIridescenceTest" type="material">
<input name="surfaceshader" type="surfaceshader" nodename="LamaIridescenceSurface" />
</surfacematerial>

</materialx>