Ajout du projet Depths sur Git
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
# MaterialX Data Libraries
|
||||
|
||||
This folder contains the standard data libraries for MaterialX, providing declarations and graph definitions for the MaterialX nodes, and source code for all supported shader generators.
|
||||
|
||||
## Standard Pattern Library
|
||||
- [stdlib](stdlib)
|
||||
- [stdlib_defs.mtlx](stdlib/stdlib_defs.mtlx) : Nodedef declarations.
|
||||
- [stdlib_ng.mtlx](stdlib/stdlib_ng.mtlx) : Nodegraph definitions.
|
||||
- [genglsl](stdlib/genglsl): GLSL language support.
|
||||
- [lib](stdlib/genglsl/lib) : Shader utility files.
|
||||
- [stdlib_genglsl_impl.mtlx](stdlib/genglsl/stdlib_genglsl_impl.mtlx) : Mapping from declarations to implementations.
|
||||
- [genosl](stdlib/genosl): OSL language support.
|
||||
- [lib](stdlib/genosl/lib) : Shader utility files.
|
||||
- [stdlib_genosl_impl.mtlx](stdlib/genosl/stdlib_genosl_impl.mtlx) : Mapping from declarations to implementations.
|
||||
- [genmdl](stdlib/genmdl): MDL language support.
|
||||
- [stdlib_genmdl_impl.mtlx](stdlib/genmdl/stdlib_genmdl_impl.mtlx) : Mapping from declarations to implementations.
|
||||
- Additional MaterialX support libraries for MDL are located in the [source/MaterialXGenMdl/mdl/materialx](../source/MaterialXGenMdl/mdl/materialx) package folder
|
||||
- [genmsl](stdlib/genmsl): MSL language support.
|
||||
- [lib](stdlib/genmsl/lib) : Shader utility files.
|
||||
- [stdlib_genmsl_impl.mtlx](stdlib/genmsl/stdlib_genmsl_impl.mtlx) : Mapping from declarations to implementations.
|
||||
|
||||
## Physically Based Shading Library
|
||||
- [pbrlib](pbrlib)
|
||||
- [pbrlib_defs.mtlx](pbrlib/pbrlib_defs.mtlx) : Nodedef declarations.
|
||||
- [pbrlib_ng.mtlx](pbrlib/pbrlib_ng.mtlx) : Nodegraph definitions.
|
||||
- [genglsl](pbrlib/genglsl) : GLSL language support
|
||||
- [lib](pbrlib/genglsl/lib) : Shader utility files.
|
||||
- [pbrlib_genglsl_impl.mtlx](pbrlib/genglsl/pbrlib_genglsl_impl.mtlx) : Mapping from declarations to implementations.
|
||||
- [genosl](pbrlib/genosl) : OSL language support
|
||||
- [lib](pbrlib/genosl/lib) : Shader utility files.
|
||||
- [pbrlib_genosl_impl.mtlx](pbrlib/genosl/pbrlib_genosl_impl.mtlx) : Mapping from declarations to implementations.
|
||||
- [genmdl](pbrlib/genmdl) : MDL language support
|
||||
- [pbrlib_genmdl_impl.mtlx](pbrlib/genmdl/pbrlib_genmdl_impl.mtlx) : Mapping from declarations to implementations.
|
||||
- [genmsl](pbrlib/genmsl) : MSL language support
|
||||
- [pbrlib_genmsl_impl.mtlx](pbrlib/genmsl/pbrlib_genmsl_impl.mtlx) : Mapping from declarations to implementations.
|
||||
|
||||
## BxDF Graph Library
|
||||
- [bxdf](bxdf)
|
||||
- [standard_surface.mtlx](bxdf/standard_surface.mtlx) : Graph definition of the [Autodesk Standard Surface](https://autodesk.github.io/standard-surface/) shading model.
|
||||
- [gltf_pbr.mtlx](bxdf/gltf_pbr.mtlx) : Graph definition of the [glTF PBR](https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#appendix-b-brdf-implementation) shading model.
|
||||
- [usd_preview_surface.mtlx](bxdf/usd_preview_surface.mtlx) : Graph definition of the [UsdPreviewSurface](https://openusd.org/release/spec_usdpreviewsurface.html) shading model.
|
||||
- [lama](bxdf/lama) : Graph definitions of the [MaterialX Lama](https://rmanwiki.pixar.com/display/REN24/MaterialX+Lama) node set.
|
||||
|
||||
## Color Management Library
|
||||
- MaterialX shader generation natively supports a small set of common spaces for input colors, with all color transforms implemented as language-independent MaterialX graphs.The canonical definitions of these color transforms may be found in the OpenColorIO configuration for [ACES 1.2](https://github.com/colour-science/OpenColorIO-Configs/tree/feature/aces-1.2-config/aces_1.2).
|
||||
- lin_rec709
|
||||
- g18_rec709
|
||||
- g22_rec709
|
||||
- rec709_display
|
||||
- acescg (lin_ap1)
|
||||
- g22_ap1
|
||||
- srgb_texture
|
||||
- lin_adobergb
|
||||
- adobergb
|
||||
- srgb_displayp3
|
||||
- lin_displayp3
|
||||
- [cmlib](cmlib)
|
||||
- [cmlib_defs.mtlx](cmlib/cmlib_defs.mtlx) : Nodedef declarations.
|
||||
- [cmlib_ng.mtlx](cmlib/cmlib_ng.mtlx) : Nodegraph definitions.
|
||||
|
||||
## Target Definitions
|
||||
- Each target implementation requires a target definition for declaration / implementation correspondence to work.
|
||||
- The [targets](targets) folder contains definition files for the following core targets:
|
||||
- GLSL : `genglsl`
|
||||
- OSL : `genosl`
|
||||
- MDL : `genmdl`
|
||||
- MSL : `genmsl`
|
||||
- Any additional target files should be added under this folder and loaded in as required.
|
||||
|
||||
### Target Support
|
||||
- GLSL target support is for version 4.0 or higher.
|
||||
- OSL target support is for version 1.9.10 or higher.
|
||||
- MDL target support is for version 1.7.
|
||||
- Basic GLSL and MSL `lightshader` node definitions and implementations are provided for the following light types:
|
||||
- point, directional, spot
|
||||
- Shader generation does not currently support:
|
||||
- `ambientocclusion` node.
|
||||
- `arrayappend` node.
|
||||
- `curveadjust` node.
|
||||
- `displacementshader` and `volumeshader` nodes for hardware shading targets (GLSL, MSL).
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0"?>
|
||||
<materialx version="1.38" colorspace="lin_rec709">
|
||||
<nodedef name="ND_disney_brdf_2012_surface" node="disney_brdf_2012" nodegroup="pbr">
|
||||
<input name="baseColor" type="color3" value="0.16, 0.16, 0.16" />
|
||||
<input name="metallic" type="float" value="0" />
|
||||
<input name="subsurface" type="float" value="0" />
|
||||
<input name="specular" type="float" value="0.5" />
|
||||
<input name="roughness" type="float" value="0.5" />
|
||||
<input name="specularTint" type="float" value="0" />
|
||||
<input name="anisotropic" type="float" value="0" />
|
||||
<input name="sheen" type="float" value="0" />
|
||||
<input name="sheenTint" type="float" value="0.5" />
|
||||
<input name="clearcoat" type="float" value="0" />
|
||||
<input name="clearcoatGloss" type="float" value="1" />
|
||||
<output name="out" type="surfaceshader" />
|
||||
</nodedef>
|
||||
<implementation name="IM_disney_brdf_2012_surface_brdf_explorer" nodedef="ND_disney_brdf_2012_surface" target="brdf_explorer" file="https://github.com/wdas/brdf/blob/master/src/brdfs/disney.brdf" />
|
||||
</materialx>
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0"?>
|
||||
<materialx version="1.38" colorspace="lin_rec709">
|
||||
<nodedef name="ND_disney_bsdf_2015_surface" node="disney_bsdf_2015" nodegroup="pbr">
|
||||
<input name="baseColor" type="color3" value="0.16, 0.16, 0.16" />
|
||||
<input name="metallic" type="float" value="0" />
|
||||
<input name="roughness" type="float" value="0.5" />
|
||||
<input name="anisotropic" type="float" value="0" />
|
||||
<input name="specularTint" type="float" value="0" />
|
||||
<input name="sheen" type="float" value="0" />
|
||||
<input name="sheenTint" type="float" value="0.5" />
|
||||
<input name="clearcoat" type="float" value="0" />
|
||||
<input name="clearcoatGloss" type="float" value="1" />
|
||||
<input name="specTrans" type="float" value="0" />
|
||||
<input name="ior" type="float" value="1.5" />
|
||||
<input name="scatterDistance" type="vector3" value="0, 0, 0" />
|
||||
<input name="flatness" type="float" value="0" />
|
||||
<input name="diffTrans" type="float" value="0" />
|
||||
<input name="thin" type="boolean" value="false" uniform="true" />
|
||||
<output name="out" type="surfaceshader" />
|
||||
</nodedef>
|
||||
<implementation name="IM_disney_bsdf_2015_surface_pbrt" nodedef="ND_disney_bsdf_2015_surface" target="pbrt" file="https://github.com/mmp/pbrt-v3/blob/master/src/materials/disney.cpp" function="DisneyMaterial::DisneyMaterial">
|
||||
<input name="baseColor" type="color3" implname="color" />
|
||||
<input name="ior" type="float" implname="eta" />
|
||||
</implementation>
|
||||
</materialx>
|
||||
+726
@@ -0,0 +1,726 @@
|
||||
<?xml version="1.0"?>
|
||||
<materialx version="1.38">
|
||||
<nodedef name="ND_gltf_pbr_surfaceshader" node="gltf_pbr" nodegroup="pbr" doc="glTF PBR" version="2.0.1" isdefaultversion="true">
|
||||
<input name="base_color" type="color3" value="1, 1, 1" uimin="0, 0, 0" uimax="1, 1, 1" uiname="Base Color" uifolder="Base" />
|
||||
<input name="metallic" type="float" value="1" uimin="0" uimax="1" uiname="Metallic" uifolder="Base" />
|
||||
<input name="roughness" type="float" value="1" uimin="0" uimax="1" uiname="Roughness" uifolder="Base" />
|
||||
<input name="normal" type="vector3" defaultgeomprop="Nworld" uiname="Normal" uifolder="Base" />
|
||||
<input name="tangent" type="vector3" defaultgeomprop="Tworld" uiname="Tangent" uifolder="Base" />
|
||||
<input name="occlusion" type="float" value="1" uimin="0" uimax="1" uiname="Occlusion" uifolder="Base" />
|
||||
<input name="transmission" type="float" value="0" uimin="0" uimax="1" uiname="Transmission" uifolder="Base" />
|
||||
<input name="specular" type="float" value="1" uimin="0" uimax="1" uiname="Specular" uifolder="Base" />
|
||||
<input name="specular_color" type="color3" value="1, 1, 1" uimin="0, 0, 0" uisoftmax="1, 1, 1" uiname="Specular Color" uifolder="Base" />
|
||||
<input name="ior" uniform="true" type="float" value="1.5" uimin="1" uisoftmax="3" uiname="Index of Refraction" uifolder="Base" />
|
||||
<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" />
|
||||
<input name="clearcoat_roughness" type="float" value="0" uimin="0" uimax="1" uiname="Clearcoat Roughness" uifolder="Clearcoat" />
|
||||
<input name="clearcoat_normal" type="vector3" defaultgeomprop="Nworld" uiname="Clearcoat Normal" uifolder="Clearcoat" />
|
||||
<input name="emissive" type="color3" value="0, 0, 0" uimin="0, 0, 0" uimax="1, 1, 1" uiname="Emissive" uifolder="Emission" />
|
||||
<input name="emissive_strength" uniform="true" type="float" value="1" uimin="0" uiname="Emissive Strength" uifolder="Emission" />
|
||||
<input name="thickness" uniform="false" type="float" value="0" uimin="0" uiname="Thickness" uifolder="Volume" />
|
||||
<input name="attenuation_distance" uniform="true" type="float" uimin="0" uiname="Attenuation Distance" uifolder="Volume" />
|
||||
<input name="attenuation_color" uniform="true" type="color3" value="1, 1, 1" uimin="0, 0, 0" uimax="1, 1, 1" uiname="Attenuation Color" uifolder="Volume" />
|
||||
<output name="out" type="surfaceshader" />
|
||||
</nodedef>
|
||||
|
||||
<nodegraph name="IMPL_gltf_pbr_surfaceshader" nodedef="ND_gltf_pbr_surfaceshader">
|
||||
|
||||
<!-- Volume -->
|
||||
|
||||
<convert name="attenuation_color_vec" type="vector3">
|
||||
<input name="in" type="color3" interfacename="attenuation_color" />
|
||||
</convert>
|
||||
|
||||
<ln name="ln_attenuation_color_vec" type="vector3">
|
||||
<input name="in" type="vector3" nodename="attenuation_color_vec" />
|
||||
</ln>
|
||||
|
||||
<divide name="ln_attenuation_color_vec_over_distance" type="vector3">
|
||||
<input name="in1" type="vector3" nodename="ln_attenuation_color_vec" />
|
||||
<input name="in2" type="float" interfacename="attenuation_distance" />
|
||||
</divide>
|
||||
|
||||
<multiply name="attenuation_coeff" type="vector3">
|
||||
<input name="in1" type="vector3" nodename="ln_attenuation_color_vec_over_distance" />
|
||||
<input name="in2" type="float" value="-1" />
|
||||
</multiply>
|
||||
|
||||
<anisotropic_vdf name="isotropic_volume" type="VDF">
|
||||
<!-- No scattering yet, so absorption_coeff == attenuation_coeff -->
|
||||
<input name="absorption" type="vector3" nodename="attenuation_coeff" />
|
||||
<input name="scattering" type="vector3" value="0, 0, 0" />
|
||||
<input name="anisotropy" type="float" value="0" />
|
||||
</anisotropic_vdf>
|
||||
|
||||
<!-- Base layer -->
|
||||
|
||||
<!-- Compute F0 and F90 of dielectric component -->
|
||||
<subtract name="one_minus_ior" type="float">
|
||||
<input name="in1" type="float" value="1" />
|
||||
<input name="in2" type="float" interfacename="ior" />
|
||||
</subtract>
|
||||
|
||||
<add name="one_plus_ior" type="float">
|
||||
<input name="in1" type="float" value="1" />
|
||||
<input name="in2" type="float" interfacename="ior" />
|
||||
</add>
|
||||
|
||||
<divide name="ior_div" type="float">
|
||||
<input name="in1" type="float" nodename="one_minus_ior" />
|
||||
<input name="in2" type="float" nodename="one_plus_ior" />
|
||||
</divide>
|
||||
|
||||
<multiply name="dielectric_f0_from_ior" type="float">
|
||||
<input name="in1" type="float" nodename="ior_div" />
|
||||
<input name="in2" type="float" nodename="ior_div" />
|
||||
</multiply>
|
||||
|
||||
<multiply name="dielectric_f0_from_ior_specular_color" type="color3">
|
||||
<input name="in1" type="color3" interfacename="specular_color" />
|
||||
<input name="in2" type="float" nodename="dielectric_f0_from_ior" />
|
||||
</multiply>
|
||||
|
||||
<min name="clamped_dielectric_f0_from_ior_specular_color" type="color3">
|
||||
<input name="in1" type="color3" nodename="dielectric_f0_from_ior_specular_color" />
|
||||
<input name="in2" type="float" value="1" />
|
||||
</min>
|
||||
|
||||
<multiply name="dielectric_f0" type="color3">
|
||||
<input name="in1" type="color3" nodename="clamped_dielectric_f0_from_ior_specular_color" />
|
||||
<input name="in2" type="float" interfacename="specular" />
|
||||
</multiply>
|
||||
|
||||
<multiply name="dielectric_f90" type="color3">
|
||||
<input name="in1" type="color3" value="1, 1, 1" />
|
||||
<input name="in2" type="float" interfacename="specular" />
|
||||
</multiply>
|
||||
|
||||
<!-- Roughness -->
|
||||
|
||||
<roughness_anisotropy name="roughness_uv" type="vector2">
|
||||
<input name="roughness" type="float" interfacename="roughness" />
|
||||
</roughness_anisotropy>
|
||||
|
||||
<!-- Dielectric -->
|
||||
|
||||
<oren_nayar_diffuse_bsdf name="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="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="tangent" type="vector3" interfacename="tangent" />
|
||||
<input name="scatter_mode" type="string" value="T" />
|
||||
</dielectric_bsdf>
|
||||
|
||||
<generalized_schlick_bsdf name="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="tangent" type="vector3" interfacename="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). -->
|
||||
|
||||
<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="tangent" type="vector3" interfacename="tangent" />
|
||||
<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="tangent" type="vector3" interfacename="tangent" />
|
||||
<input name="scatter_mode" type="string" value="R" />
|
||||
</generalized_schlick_bsdf>
|
||||
|
||||
<mix name="tf_transmission_mix" type="BSDF">
|
||||
<input name="bg" type="BSDF" nodename="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">
|
||||
<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" interfacename="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">
|
||||
<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" interfacename="tangent" />
|
||||
</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="mix_iridescent_dielectric_bsdf" />
|
||||
<input name="fg" type="BSDF" nodename="mix_iridescent_metal_bsdf" />
|
||||
<input name="mix" type="float" interfacename="metallic" />
|
||||
</mix>
|
||||
|
||||
<!-- Sheen layer -->
|
||||
|
||||
<!-- Compute sheen intensity = max(sheen_color.r, sheen_color.g, sheen_color.b) -->
|
||||
<extract name="sheen_color_r" type="float">
|
||||
<input name="in" type="color3" interfacename="sheen_color" />
|
||||
<input name="index" type="integer" value="0" />
|
||||
</extract>
|
||||
|
||||
<extract name="sheen_color_g" type="float">
|
||||
<input name="in" type="color3" interfacename="sheen_color" />
|
||||
<input name="index" type="integer" value="1" />
|
||||
</extract>
|
||||
|
||||
<extract name="sheen_color_b" type="float">
|
||||
<input name="in" type="color3" interfacename="sheen_color" />
|
||||
<input name="index" type="integer" value="2" />
|
||||
</extract>
|
||||
|
||||
<max name="sheen_color_max_rg" type="float">
|
||||
<input name="in1" type="float" nodename="sheen_color_r" />
|
||||
<input name="in2" type="float" nodename="sheen_color_g" />
|
||||
</max>
|
||||
|
||||
<max name="sheen_intensity" type="float">
|
||||
<input name="in1" type="float" nodename="sheen_color_max_rg" />
|
||||
<input name="in2" type="float" nodename="sheen_color_b" />
|
||||
</max>
|
||||
|
||||
<multiply name="sheen_roughness_sq" type="float">
|
||||
<input name="in1" type="float" interfacename="sheen_roughness" />
|
||||
<input name="in2" type="float" interfacename="sheen_roughness" />
|
||||
</multiply>
|
||||
|
||||
<divide name="sheen_color_normalized" type="color3">
|
||||
<input name="in1" type="color3" interfacename="sheen_color" />
|
||||
<input name="in2" type="float" nodename="sheen_intensity" />
|
||||
</divide>
|
||||
|
||||
<sheen_bsdf name="sheen_bsdf" type="BSDF">
|
||||
<input name="weight" type="float" nodename="sheen_intensity" />
|
||||
<input name="color" type="color3" nodename="sheen_color_normalized" />
|
||||
<input name="roughness" type="float" nodename="sheen_roughness_sq" />
|
||||
<input name="normal" type="vector3" interfacename="normal" />
|
||||
</sheen_bsdf>
|
||||
|
||||
<layer name="sheen_layer" type="BSDF">
|
||||
<input name="top" type="BSDF" nodename="sheen_bsdf" />
|
||||
<input name="base" type="BSDF" nodename="base_mix" />
|
||||
</layer>
|
||||
|
||||
<!-- Clearcoat -->
|
||||
|
||||
<roughness_anisotropy name="clearcoat_roughness_uv" type="vector2">
|
||||
<input name="roughness" type="float" interfacename="clearcoat_roughness" />
|
||||
</roughness_anisotropy>
|
||||
|
||||
<dielectric_bsdf name="clearcoat_bsdf" type="BSDF">
|
||||
<input name="weight" type="float" interfacename="clearcoat" />
|
||||
<input name="roughness" type="vector2" nodename="clearcoat_roughness_uv" />
|
||||
<input name="ior" type="float" value="1.5" />
|
||||
<input name="normal" type="vector3" interfacename="clearcoat_normal" />
|
||||
<input name="tangent" type="vector3" interfacename="tangent" />
|
||||
</dielectric_bsdf>
|
||||
|
||||
<layer name="clearcoat_layer" type="BSDF">
|
||||
<input name="top" type="BSDF" nodename="clearcoat_bsdf" />
|
||||
<input name="base" type="BSDF" nodename="sheen_layer" />
|
||||
</layer>
|
||||
|
||||
<!-- Emission -->
|
||||
|
||||
<multiply name="emission_color" type="color3">
|
||||
<input name="in1" type="color3" interfacename="emissive" />
|
||||
<input name="in2" type="float" interfacename="emissive_strength" />
|
||||
</multiply>
|
||||
|
||||
<uniform_edf name="emission" type="EDF">
|
||||
<input name="color" type="color3" nodename="emission_color" />
|
||||
</uniform_edf>
|
||||
|
||||
<!-- Alpha -->
|
||||
|
||||
<ifgreatereq name="opacity_mask_cutoff" type="float">
|
||||
<input name="value1" type="float" interfacename="alpha" />
|
||||
<input name="value2" type="float" interfacename="alpha_cutoff" />
|
||||
<input name="in1" type="float" value="1" />
|
||||
<input name="in2" type="float" value="0" />
|
||||
</ifgreatereq>
|
||||
|
||||
<ifequal name="opacity_mask" type="float">
|
||||
<input name="value1" type="integer" interfacename="alpha_mode" />
|
||||
<input name="value2" type="integer" value="1" />
|
||||
<input name="in1" type="float" nodename="opacity_mask_cutoff" />
|
||||
<input name="in2" type="float" interfacename="alpha" />
|
||||
</ifequal>
|
||||
|
||||
<ifequal name="opacity" type="float">
|
||||
<input name="value1" type="integer" interfacename="alpha_mode" />
|
||||
<input name="value2" type="integer" value="0" />
|
||||
<input name="in1" type="float" value="1" />
|
||||
<input name="in2" type="float" nodename="opacity_mask" />
|
||||
</ifequal>
|
||||
|
||||
<!-- Surface -->
|
||||
|
||||
<surface name="shader_constructor" type="surfaceshader">
|
||||
<input name="bsdf" type="BSDF" nodename="clearcoat_layer" />
|
||||
<input name="edf" type="EDF" nodename="emission" />
|
||||
<input name="opacity" type="float" nodename="opacity" />
|
||||
</surface>
|
||||
<output name="out" type="surfaceshader" nodename="shader_constructor" />
|
||||
</nodegraph>
|
||||
|
||||
<!--
|
||||
Node: <gltf_colorimage> Supplemental Node
|
||||
Multiply a color4 image modulated by uniform color and geometry color. Default uniform and geometry colors are 1,1,1,1 which results in no change to the image.
|
||||
-->
|
||||
<nodedef name="ND_gltf_colorimage" node="gltf_colorimage" version="1.0" isdefaultversion="true" nodegroup="texture2d">
|
||||
<input name="file" type="filename" uniform="true" value="" uifolder="Image" />
|
||||
<input name="default" type="color4" value="0, 0, 0, 0" uifolder="Image" />
|
||||
<input name="texcoord" type="vector2" defaultgeomprop="UV0" uifolder="Image" />
|
||||
<input name="pivot" type="vector2" value="0, 1" uifolder="Image" />
|
||||
<input name="scale" type="vector2" value="1, 1" uifolder="Image" />
|
||||
<input name="rotate" type="float" value="0" unit="degree" unittype="angle" uimin="0" uimax="360" uifolder="Image" />
|
||||
<input name="offset" type="vector2" value="0, 0" uifolder="Image" />
|
||||
<input name="operationorder" type="integer" value="1" uifolder="Image" />
|
||||
<input name="uaddressmode" type="string" uniform="true" value="periodic" enum="constant,clamp,periodic,mirror" uifolder="Image" />
|
||||
<input name="vaddressmode" type="string" uniform="true" value="periodic" enum="constant,clamp,periodic,mirror" uifolder="Image" />
|
||||
<input name="filtertype" type="string" uniform="true" value="linear" enum="closest,linear,cubic" uifolder="Image" />
|
||||
<input name="color" type="color4" value="1, 1, 1, 1" uifolder="Color" />
|
||||
<input name="geomcolor" type="color4" value="1, 1, 1, 1" uifolder="Color" uiname="Geometry Color" />
|
||||
<output name="outcolor" type="color3" value="0, 0, 0" />
|
||||
<output name="outa" type="float" value="0" />
|
||||
</nodedef>
|
||||
|
||||
<nodegraph name="NG_gltf_colorimage" nodedef="ND_gltf_colorimage">
|
||||
<gltf_image name="image" type="color4">
|
||||
<input name="file" type="filename" uniform="true" interfacename="file" />
|
||||
<input name="default" type="color4" interfacename="default" />
|
||||
<input name="texcoord" type="vector2" interfacename="texcoord" />
|
||||
<input name="pivot" type="vector2" interfacename="pivot" />
|
||||
<input name="scale" type="vector2" interfacename="scale" />
|
||||
<input name="rotate" type="float" interfacename="rotate" />
|
||||
<input name="offset" type="vector2" interfacename="offset" />
|
||||
<input name="operationorder" type="integer" value="0" />
|
||||
<input name="uaddressmode" type="string" uniform="true" value="periodic" />
|
||||
<input name="vaddressmode" type="string" uniform="true" value="periodic" />
|
||||
<input name="filtertype" type="string" uniform="true" interfacename="filtertype" />
|
||||
</gltf_image>
|
||||
<multiply name="modulate_color" type="color4">
|
||||
<input name="in1" type="color4" interfacename="color" />
|
||||
<input name="in2" type="color4" nodename="image" />
|
||||
</multiply>
|
||||
<multiply name="modulate_geomcolor" type="color4">
|
||||
<input name="in1" type="color4" nodename="modulate_color" />
|
||||
<input name="in2" type="color4" interfacename="geomcolor" />
|
||||
</multiply>
|
||||
<separate4 name="separate_color" type="multioutput">
|
||||
<input name="in" type="color4" nodename="modulate_geomcolor" />
|
||||
</separate4>
|
||||
<combine3 name="combine_color" type="color3">
|
||||
<input name="in1" type="float" nodename="separate_color" output="outr" />
|
||||
<input name="in2" type="float" nodename="separate_color" output="outg" />
|
||||
<input name="in3" type="float" nodename="separate_color" output="outb" />
|
||||
</combine3>
|
||||
<dot name="separate_alpha" type="float">
|
||||
<input name="in" type="float" nodename="separate_color" output="outa" />
|
||||
</dot>
|
||||
<output name="outcolor" type="color3" nodename="combine_color" />
|
||||
<output name="outa" type="float" nodename="separate_alpha" />
|
||||
</nodegraph>
|
||||
|
||||
<!---
|
||||
Node: <gltf_image>
|
||||
color3 image lookup which matches glTF
|
||||
-->
|
||||
<nodedef name="ND_gltf_image_color3_color3_1_0" node="gltf_image" version="1.0" isdefaultversion="true" nodegroup="texture2d">
|
||||
<input name="file" type="filename" uniform="true" value="" />
|
||||
<input name="factor" type="color3" value="1,1,1" />
|
||||
<input name="default" type="color3" value="0, 0, 0" />
|
||||
<input name="texcoord" type="vector2" defaultgeomprop="UV0" />
|
||||
<input name="pivot" type="vector2" value="0, 1" />
|
||||
<input name="scale" type="vector2" value="1, 1" />
|
||||
<input name="rotate" type="float" value="0" unit="degree" unittype="angle" uimin="0" uimax="360" />
|
||||
<input name="offset" type="vector2" value="0, 0" />
|
||||
<input name="operationorder" type="integer" value="0" />
|
||||
<input name="uaddressmode" type="string" uniform="true" value="periodic" enum="constant,clamp,periodic,mirror" />
|
||||
<input name="vaddressmode" type="string" uniform="true" value="periodic" enum="constant,clamp,periodic,mirror" />
|
||||
<input name="filtertype" type="string" uniform="true" value="linear" enum="closest,linear,cubic" />
|
||||
<output name="out" type="color3" value="0, 0, 0" />
|
||||
</nodedef>
|
||||
<nodegraph name="NG_NG_gltf_image_color3_color3_1_0" nodedef="ND_gltf_image_color3_color3_1_0">
|
||||
<image name="image" type="color3">
|
||||
<input name="file" type="filename" uniform="true" interfacename="file" />
|
||||
<input name="default" type="color3" interfacename="default" />
|
||||
<input name="texcoord" type="vector2" nodename="place2d" />
|
||||
<input name="uaddressmode" type="string" uniform="true" interfacename="uaddressmode" />
|
||||
<input name="vaddressmode" type="string" uniform="true" interfacename="vaddressmode" />
|
||||
<input name="filtertype" type="string" uniform="true" interfacename="filtertype" />
|
||||
</image>
|
||||
<divide name="invert_scale" type="vector2">
|
||||
<input name="in1" type="vector2" value="1.0, 1.0" />
|
||||
<input name="in2" type="vector2" interfacename="scale" />
|
||||
</divide>
|
||||
<multiply name="negate_rotate" type="float">
|
||||
<input name="in1" type="float" interfacename="rotate" />
|
||||
<input name="in2" type="float" value="-1.0" />
|
||||
</multiply>
|
||||
<multiply name="negate_offset" type="vector2">
|
||||
<input name="in1" type="vector2" interfacename="offset" />
|
||||
<input name="in2" type="vector2" value="-1.0, 1.0" />
|
||||
</multiply>
|
||||
<place2d name="place2d" type="vector2">
|
||||
<input name="texcoord" type="vector2" interfacename="texcoord" />
|
||||
<input name="pivot" type="vector2" interfacename="pivot" />
|
||||
<input name="scale" type="vector2" nodename="invert_scale" />
|
||||
<input name="rotate" type="float" nodename="negate_rotate" />
|
||||
<input name="offset" type="vector2" nodename="negate_offset" />
|
||||
<input name="operationorder" type="integer" interfacename="operationorder" />
|
||||
</place2d>
|
||||
<multiply name="scale_image" type="color3">
|
||||
<input name="in1" type="color3" interfacename="factor" />
|
||||
<input name="in2" type="color3" nodename="image" />
|
||||
</multiply>
|
||||
<output name="out" type="color3" nodename="scale_image" />
|
||||
</nodegraph>
|
||||
|
||||
<!---
|
||||
Node: <gltf_image>
|
||||
color4 image lookup which matches glTF
|
||||
-->
|
||||
<nodedef name="ND_gltf_image_color4_color4_1_0" node="gltf_image" version="1.0" isdefaultversion="true" nodegroup="texture2d">
|
||||
<input name="file" type="filename" uniform="true" value="" />
|
||||
<input name="factor" type="color4" value="1,1,1,1" />
|
||||
<input name="default" type="color4" value="0, 0, 0, 0" />
|
||||
<input name="texcoord" type="vector2" defaultgeomprop="UV0" />
|
||||
<input name="pivot" type="vector2" value="0, 1" />
|
||||
<input name="scale" type="vector2" value="1, 1" />
|
||||
<input name="rotate" type="float" value="0" unit="degree" unittype="angle" uimin="0" uimax="360" />
|
||||
<input name="offset" type="vector2" value="0, 0" />
|
||||
<input name="operationorder" type="integer" value="1" />
|
||||
<input name="uaddressmode" type="string" uniform="true" value="periodic" enum="constant,clamp,periodic,mirror" />
|
||||
<input name="vaddressmode" type="string" uniform="true" value="periodic" enum="constant,clamp,periodic,mirror" />
|
||||
<input name="filtertype" type="string" uniform="true" value="linear" enum="closest,linear,cubic" />
|
||||
<output name="out" type="color4" value="0, 0, 0, 0" />
|
||||
</nodedef>
|
||||
<nodegraph name="NG_gltf_image_color4_color4_1_0" nodedef="ND_gltf_image_color4_color4_1_0">
|
||||
<image name="image" type="color4">
|
||||
<input name="file" type="filename" uniform="true" interfacename="file" />
|
||||
<input name="default" type="color4" interfacename="default" />
|
||||
<input name="texcoord" type="vector2" nodename="place2d" />
|
||||
<input name="uaddressmode" type="string" uniform="true" interfacename="uaddressmode" />
|
||||
<input name="vaddressmode" type="string" uniform="true" interfacename="vaddressmode" />
|
||||
<input name="filtertype" type="string" uniform="true" interfacename="filtertype" />
|
||||
</image>
|
||||
<divide name="invert_scale" type="vector2">
|
||||
<input name="in1" type="vector2" value="1.0, 1.0" />
|
||||
<input name="in2" type="vector2" interfacename="scale" />
|
||||
</divide>
|
||||
<multiply name="negate_rotate" type="float">
|
||||
<input name="in1" type="float" interfacename="rotate" />
|
||||
<input name="in2" type="float" value="-1.0" />
|
||||
</multiply>
|
||||
<multiply name="negate_offset" type="vector2">
|
||||
<input name="in1" type="vector2" interfacename="offset" />
|
||||
<input name="in2" type="vector2" value="-1.0, 1.0" />
|
||||
</multiply>
|
||||
<place2d name="place2d" type="vector2">
|
||||
<input name="texcoord" type="vector2" interfacename="texcoord" />
|
||||
<input name="pivot" type="vector2" interfacename="pivot" />
|
||||
<input name="scale" type="vector2" nodename="invert_scale" />
|
||||
<input name="rotate" type="float" nodename="negate_rotate" />
|
||||
<input name="offset" type="vector2" nodename="negate_offset" />
|
||||
<input name="operationorder" type="integer" interfacename="operationorder" />
|
||||
</place2d>
|
||||
<multiply name="scale_image" type="color4">
|
||||
<input name="in1" type="color4" interfacename="factor" />
|
||||
<input name="in2" type="color4" nodename="image" />
|
||||
</multiply>
|
||||
<output name="out" type="color4" nodename="scale_image" />
|
||||
</nodegraph>
|
||||
|
||||
<!---
|
||||
Node: <gltf_image>
|
||||
float image lookup which matches glTF
|
||||
-->
|
||||
<nodedef name="ND_gltf_image_float_float_1_0" node="gltf_image" version="1.0" isdefaultversion="true" nodegroup="texture2d">
|
||||
<input name="file" type="filename" uniform="true" value="" />
|
||||
<input name="factor" type="float" value="1" />
|
||||
<input name="default" type="float" value="0" />
|
||||
<input name="texcoord" type="vector2" defaultgeomprop="UV0" />
|
||||
<input name="pivot" type="vector2" value="0, 1" />
|
||||
<input name="scale" type="vector2" value="1, 1" />
|
||||
<input name="rotate" type="float" value="0" unit="degree" unittype="angle" uimin="0" uimax="360" />
|
||||
<input name="offset" type="vector2" value="0, 0" />
|
||||
<input name="operationorder" type="integer" value="0" />
|
||||
<input name="uaddressmode" type="string" uniform="true" value="periodic" enum="constant,clamp,periodic,mirror" />
|
||||
<input name="vaddressmode" type="string" uniform="true" value="periodic" enum="constant,clamp,periodic,mirror" />
|
||||
<input name="filtertype" type="string" uniform="true" value="linear" enum="closest,linear,cubic" />
|
||||
<output name="out" type="float" value="0" />
|
||||
</nodedef>
|
||||
<nodegraph name="NG_gltf_image_float_float_1_0" nodedef="ND_gltf_image_float_float_1_0">
|
||||
<image name="image" type="float">
|
||||
<input name="file" type="filename" uniform="true" interfacename="file" />
|
||||
<input name="default" type="float" interfacename="default" />
|
||||
<input name="texcoord" type="vector2" nodename="place2d" />
|
||||
<input name="uaddressmode" type="string" uniform="true" interfacename="uaddressmode" />
|
||||
<input name="vaddressmode" type="string" uniform="true" interfacename="vaddressmode" />
|
||||
<input name="filtertype" type="string" uniform="true" interfacename="filtertype" />
|
||||
</image>
|
||||
<divide name="invert_scale" type="vector2">
|
||||
<input name="in1" type="vector2" value="1.0, 1.0" />
|
||||
<input name="in2" type="vector2" interfacename="scale" />
|
||||
</divide>
|
||||
<multiply name="negate_rotate" type="float">
|
||||
<input name="in1" type="float" interfacename="rotate" />
|
||||
<input name="in2" type="float" value="-1.0" />
|
||||
</multiply>
|
||||
<multiply name="negate_offset" type="vector2">
|
||||
<input name="in1" type="vector2" interfacename="offset" />
|
||||
<input name="in2" type="vector2" value="-1.0, 1.0" />
|
||||
</multiply>
|
||||
<place2d name="place2d" type="vector2">
|
||||
<input name="texcoord" type="vector2" interfacename="texcoord" />
|
||||
<input name="pivot" type="vector2" interfacename="pivot" />
|
||||
<input name="scale" type="vector2" nodename="invert_scale" />
|
||||
<input name="rotate" type="float" nodename="negate_rotate" />
|
||||
<input name="offset" type="vector2" nodename="negate_offset" />
|
||||
<input name="operationorder" type="integer" interfacename="operationorder" />
|
||||
</place2d>
|
||||
<multiply name="scale_image" type="float">
|
||||
<input name="in1" type="float" interfacename="factor" />
|
||||
<input name="in2" type="float" nodename="image" />
|
||||
</multiply>
|
||||
<output name="out" type="float" nodename="scale_image" />
|
||||
</nodegraph>
|
||||
|
||||
<!---
|
||||
Node: <gltf_image>
|
||||
vector3 image lookup which matches glTF
|
||||
-->
|
||||
<nodedef name="ND_gltf_image_vector3_vector3_1_0" node="gltf_image" version="1.0" isdefaultversion="true" nodegroup="texture2d">
|
||||
<input name="file" type="filename" uniform="true" value="" />
|
||||
<input name="default" type="vector3" value="0, 0, 0" />
|
||||
<input name="texcoord" type="vector2" defaultgeomprop="UV0" />
|
||||
<input name="pivot" type="vector2" value="0, 1" />
|
||||
<input name="scale" type="vector2" value="1, 1" />
|
||||
<input name="rotate" type="float" value="0" unit="degree" unittype="angle" uimin="0" uimax="360" />
|
||||
<input name="offset" type="vector2" value="0, 0" />
|
||||
<input name="operationorder" type="integer" value="0" />
|
||||
<input name="uaddressmode" type="string" uniform="true" value="periodic" enum="constant,clamp,periodic,mirror" />
|
||||
<input name="vaddressmode" type="string" uniform="true" value="periodic" enum="constant,clamp,periodic,mirror" />
|
||||
<input name="filtertype" type="string" uniform="true" value="linear" enum="closest,linear,cubic" />
|
||||
<output name="out" type="vector3" value="0, 0, 0" />
|
||||
</nodedef>
|
||||
<nodegraph name="NG_gltf_image_vector3_vector3_1_0" nodedef="ND_gltf_image_vector3_vector3_1_0">
|
||||
<image name="image" type="vector3">
|
||||
<input name="file" type="filename" uniform="true" interfacename="file" />
|
||||
<input name="default" type="vector3" interfacename="default" />
|
||||
<input name="texcoord" type="vector2" nodename="place2d" />
|
||||
<input name="uaddressmode" type="string" uniform="true" interfacename="uaddressmode" />
|
||||
<input name="vaddressmode" type="string" uniform="true" interfacename="vaddressmode" />
|
||||
<input name="filtertype" type="string" uniform="true" interfacename="filtertype" />
|
||||
</image>
|
||||
<divide name="invert_scale" type="vector2">
|
||||
<input name="in1" type="vector2" value="1.0, 1.0" />
|
||||
<input name="in2" type="vector2" interfacename="scale" />
|
||||
</divide>
|
||||
<multiply name="negate_rotate" type="float">
|
||||
<input name="in1" type="float" interfacename="rotate" />
|
||||
<input name="in2" type="float" value="-1.0" />
|
||||
</multiply>
|
||||
<multiply name="negate_offset" type="vector2">
|
||||
<input name="in1" type="vector2" interfacename="offset" />
|
||||
<input name="in2" type="vector2" value="-1.0, 1.0" />
|
||||
</multiply>
|
||||
<place2d name="place2d" type="vector2">
|
||||
<input name="texcoord" type="vector2" interfacename="texcoord" />
|
||||
<input name="pivot" type="vector2" interfacename="pivot" />
|
||||
<input name="scale" type="vector2" nodename="invert_scale" />
|
||||
<input name="rotate" type="float" nodename="negate_rotate" />
|
||||
<input name="offset" type="vector2" nodename="negate_offset" />
|
||||
<input name="operationorder" type="integer" interfacename="operationorder" />
|
||||
</place2d>
|
||||
<output name="out" type="vector3" nodename="image" />
|
||||
</nodegraph>
|
||||
|
||||
<!---
|
||||
Node: <gltf_normalmap>
|
||||
normalmap image lookup which matches glTF
|
||||
-->
|
||||
<nodedef name="ND_gltf_normalmap_vector3_1_0" node="gltf_normalmap" version="1.0" isdefaultversion="true" nodegroup="texture2d">
|
||||
<input name="file" type="filename" uniform="true" value="" />
|
||||
<input name="default" type="vector3" value="0.5, 0.5, 1" />
|
||||
<input name="texcoord" type="vector2" defaultgeomprop="UV0" />
|
||||
<input name="pivot" type="vector2" value="0, 1" />
|
||||
<input name="scale" type="vector2" value="1, 1" />
|
||||
<input name="rotate" type="float" value="0" unit="degree" unittype="angle" uimin="0" uimax="360" />
|
||||
<input name="offset" type="vector2" value="0, 0" />
|
||||
<input name="operationorder" type="integer" value="0" />
|
||||
<input name="uaddressmode" type="string" uniform="true" value="periodic" enum="constant,clamp,periodic,mirror" />
|
||||
<input name="vaddressmode" type="string" uniform="true" value="periodic" enum="constant,clamp,periodic,mirror" />
|
||||
<input name="filtertype" type="string" uniform="true" value="linear" enum="closest,linear,cubic" />
|
||||
<output name="out" type="vector3" value="0, 0, 0" />
|
||||
</nodedef>
|
||||
<nodegraph name="NG_gltf_normalmap_vector3_1_0" nodedef="ND_gltf_normalmap_vector3_1_0">
|
||||
<image name="image" type="vector3">
|
||||
<input name="file" type="filename" uniform="true" interfacename="file" />
|
||||
<input name="default" type="vector3" interfacename="default" />
|
||||
<input name="texcoord" type="vector2" nodename="place2d" />
|
||||
<input name="uaddressmode" type="string" uniform="true" interfacename="uaddressmode" />
|
||||
<input name="vaddressmode" type="string" uniform="true" interfacename="vaddressmode" />
|
||||
<input name="filtertype" type="string" uniform="true" interfacename="filtertype" />
|
||||
</image>
|
||||
<normalmap name="normalmap" type="vector3">
|
||||
<input name="in" type="vector3" nodename="image" />
|
||||
</normalmap>
|
||||
<divide name="invert_scale" type="vector2">
|
||||
<input name="in1" type="vector2" value="1.0, 1.0" />
|
||||
<input name="in2" type="vector2" interfacename="scale" />
|
||||
</divide>
|
||||
<multiply name="negate_rotate" type="float">
|
||||
<input name="in1" type="float" interfacename="rotate" />
|
||||
<input name="in2" type="float" value="-1.0" />
|
||||
</multiply>
|
||||
<multiply name="negate_offset" type="vector2">
|
||||
<input name="in1" type="vector2" interfacename="offset" />
|
||||
<input name="in2" type="vector2" value="-1.0, 1.0" />
|
||||
</multiply>
|
||||
<place2d name="place2d" type="vector2" nodedef="ND_place2d_vector2">
|
||||
<input name="texcoord" type="vector2" interfacename="texcoord" />
|
||||
<input name="pivot" type="vector2" interfacename="pivot" />
|
||||
<input name="scale" type="vector2" nodename="invert_scale" />
|
||||
<input name="rotate" type="float" nodename="negate_rotate" />
|
||||
<input name="offset" type="vector2" nodename="negate_offset" />
|
||||
<input name="operationorder" type="integer" interfacename="operationorder" />
|
||||
</place2d>
|
||||
<output name="out" type="vector3" nodename="normalmap" />
|
||||
</nodegraph>
|
||||
|
||||
<!--
|
||||
Node: <gltf_iridescence>
|
||||
normalmap image lookup which matches glTF
|
||||
-->
|
||||
<nodedef name="ND_gltf_iridescence_thickness_float_1_0" node="gltf_iridescence_thickness" version="1.0" isdefaultversion="true" nodegroup="texture2d">
|
||||
<input name="file" type="filename" uniform="true" value="" uifolder="Image" />
|
||||
<input name="default" type="vector3" value="0, 0, 0" uifolder="Image" />
|
||||
<input name="texcoord" type="vector2" defaultgeomprop="UV0" uifolder="Image" />
|
||||
<input name="pivot" type="vector2" value="0, 0" uifolder="Image" />
|
||||
<input name="scale" type="vector2" value="1, 1" uifolder="Image" />
|
||||
<input name="rotate" type="float" value="0" uifolder="Image" />
|
||||
<input name="offset" type="vector2" value="0, 0" uifolder="Image" />
|
||||
<input name="uaddressmode" type="string" uniform="true" value="periodic" uifolder="Image" enum="constant,clamp,periodic,mirror" />
|
||||
<input name="vaddressmode" type="string" uniform="true" value="periodic" uifolder="Image" enum="constant,clamp,periodic,mirror" />
|
||||
<input name="filtertype" type="string" uniform="true" value="linear" enum="closest,linear,cubic" uifolder="Image" />
|
||||
<input name="thicknessMin" type="float" value="100" uifolder="Thickness" />
|
||||
<input name="thicknessMax" type="float" value="400" uifolder="Thickness" />
|
||||
<output name="out" type="float" value="0" />
|
||||
</nodedef>
|
||||
<nodegraph name="NG_gltf_iridescence_thickness_float_1_0" nodedef="ND_gltf_iridescence_thickness_float_1_0">
|
||||
<mix name="mixThickness" type="float" nodedef="ND_mix_float">
|
||||
<input name="fg" type="float" interfacename="thicknessMin" />
|
||||
<input name="bg" type="float" interfacename="thicknessMax" />
|
||||
<input name="mix" type="float" nodename="extract" />
|
||||
</mix>
|
||||
<gltf_image name="thickness_image" type="vector3">
|
||||
<input name="file" type="filename" uniform="true" interfacename="file" />
|
||||
<input name="default" type="vector3" interfacename="default" />
|
||||
<input name="texcoord" type="vector2" interfacename="texcoord" />
|
||||
<input name="pivot" type="vector2" interfacename="pivot" />
|
||||
<input name="scale" type="vector2" interfacename="scale" />
|
||||
<input name="rotate" type="float" interfacename="rotate" />
|
||||
<input name="offset" type="vector2" interfacename="offset" />
|
||||
<input name="uaddressmode" type="string" uniform="true" interfacename="uaddressmode" />
|
||||
<input name="vaddressmode" type="string" uniform="true" interfacename="vaddressmode" />
|
||||
<input name="filtertype" type="string" uniform="true" interfacename="filtertype" />
|
||||
</gltf_image>
|
||||
<extract name="extract" type="float">
|
||||
<input name="in" type="vector3" nodename="thickness_image" />
|
||||
<input name="index" type="integer" uniform="true" value="1" />
|
||||
</extract>
|
||||
<output name="out" type="float" nodename="mixThickness" />
|
||||
</nodegraph>
|
||||
|
||||
</materialx>
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
<?xml version="1.0"?>
|
||||
<materialx version="1.38" colorspace="acescg">
|
||||
|
||||
<!-- LamaAdd for BSDFs -->
|
||||
<nodedef name="ND_lama_add_bsdf" node="LamaAdd" nodegroup="pbr" version="1.0" isdefaultversion="true">
|
||||
<input name="material1" uiname="Material 1" type="BSDF" doc="First material to add." />
|
||||
<input name="material2" uiname="Material 2" type="BSDF" doc="Second material to add." />
|
||||
<input name="weight1" uiname="Weight 1" type="float" uimin="0.0" uimax="1.0" value="1.0" doc="Weight of the first material." />
|
||||
<input name="weight2" uiname="Weight 2" type="float" uimin="0.0" uimax="1.0" value="0.0" doc="Weight of the second material." />
|
||||
<output name="out" type="BSDF" />
|
||||
</nodedef>
|
||||
<nodegraph name="NG_lama_add_bsdf" nodedef="ND_lama_add_bsdf">
|
||||
<multiply name="mul1" type="BSDF">
|
||||
<input name="in1" type="BSDF" interfacename="material1" />
|
||||
<input name="in2" type="float" interfacename="weight1" />
|
||||
</multiply>
|
||||
<multiply name="mul2" type="BSDF">
|
||||
<input name="in1" type="BSDF" interfacename="material2" />
|
||||
<input name="in2" type="float" interfacename="weight2" />
|
||||
</multiply>
|
||||
<add name="add1" type="BSDF">
|
||||
<input name="in1" type="BSDF" nodename="mul1" />
|
||||
<input name="in2" type="BSDF" nodename="mul2" />
|
||||
</add>
|
||||
<output name="out" type="BSDF" nodename="add1" />
|
||||
</nodegraph>
|
||||
|
||||
<!-- LamaAdd for EDFs -->
|
||||
<nodedef name="ND_lama_add_edf" node="LamaAdd" nodegroup="pbr" version="1.0" isdefaultversion="true">
|
||||
<input name="material1" uiname="Material 1" type="EDF" doc="First material to add." />
|
||||
<input name="material2" uiname="Material 2" type="EDF" doc="Second material to add." />
|
||||
<input name="weight1" uiname="Weight 1" type="float" uimin="0.0" uimax="1.0" value="1.0" doc="Weight of the first material." />
|
||||
<input name="weight2" uiname="Weight 2" type="float" uimin="0.0" uimax="1.0" value="0.0" doc="Weight of the second material." />
|
||||
<output name="out" type="EDF" />
|
||||
</nodedef>
|
||||
<nodegraph name="NG_lama_add_edf" nodedef="ND_lama_add_edf">
|
||||
<multiply name="mul1" type="EDF">
|
||||
<input name="in1" type="EDF" interfacename="material1" />
|
||||
<input name="in2" type="float" interfacename="weight1" />
|
||||
</multiply>
|
||||
<multiply name="mul2" type="EDF">
|
||||
<input name="in1" type="EDF" interfacename="material2" />
|
||||
<input name="in2" type="float" interfacename="weight2" />
|
||||
</multiply>
|
||||
<add name="add1" type="EDF">
|
||||
<input name="in1" type="EDF" nodename="mul1" />
|
||||
<input name="in2" type="EDF" nodename="mul2" />
|
||||
</add>
|
||||
<output name="out" type="EDF" nodename="add1" />
|
||||
</nodegraph>
|
||||
|
||||
</materialx>
|
||||
Vendored
+159
@@ -0,0 +1,159 @@
|
||||
<?xml version="1.0"?>
|
||||
<materialx version="1.38" colorspace="acescg">
|
||||
<nodedef name="ND_lama_conductor" node="LamaConductor" nodegroup="pbr" doc="Lama conductor" version="1.0" isdefaultversion="true">
|
||||
<input name="tint" type="color3" value="1, 1, 1" uiname="Tint" uifolder="Main"
|
||||
doc="Overall color multiplier. It should be used with parcimony, as a non-white value breaks physicality. The prefered way to define the color of a conductor is through the Fresnel 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="0.180000007153,0.419999986887,1.37000000477" 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="extinction" type="vector3" value="3.42000007629,2.34999990463,1.76999998093" uiname="Extinction" uifolder="Main"
|
||||
doc="Extinction coefficient (often denoted by kappa), influencing how the reflected color curve evolves between its value in the normal direction (or 0 degree), and 1 when reaching 90 degrees. A null value does not deviate the curve at all." />
|
||||
<input name="reflectivity" type="color3" value="0.9450, 0.7772, 0.3737" uiname="Reflectivity" uifolder="Main"
|
||||
doc="Color reflected by the surface in the normal direction." />
|
||||
<input name="edgeColor" type="color3" value="0.9979, 0.9813, 0.7523" uiname="Edge Color" uifolder="Main"
|
||||
doc="Indicates how the reflected color curve evolves between its value in the normal direction (or 0 degree), and 1 when reaching 90 degrees. Note that this color is unlikely to be reached, and just bends the curve towards it when reaching grazing angles. A null value does not deviate the curve at all." />
|
||||
<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="iridescenceThickness" type="float" value="0.0" uimin="0.0" uisoftmax="200.0" uiname="Thickness" uifolder="Iridescence"
|
||||
doc="Thin film thickness in nanometers, driving the iridescent effect." />
|
||||
<input name="iridescenceIOR" type="float" value="1.5" uimin="1.0" uimax="3.0" uiname="IOR" uifolder="Iridescence"
|
||||
doc="Thin film index of refraction, driving the iridescent effect." />
|
||||
<input name="exteriorIOR" type="float" value="1.0" uimin="1.0" uimax="3.0" uiname="Exterior IOR" uifolder="Advanced"
|
||||
doc="Defines what the IOR of the exterior medium is (can be either the outside medium, eg. air or water, or in case of a layered material, the top layer medium, like plexiglass or varnish)." />
|
||||
<output name="out" type="BSDF" />
|
||||
</nodedef>
|
||||
|
||||
<nodegraph name="IMPL_lama_conductor" nodedef="ND_lama_conductor">
|
||||
|
||||
<!-- IOR -->
|
||||
<ifgreater name="exterior_ior_switch" type="float">
|
||||
<input name="in1" type="float" interfacename="iridescenceIOR" />
|
||||
<input name="in2" type="float" interfacename="exteriorIOR" />
|
||||
<input name="value1" type="float" interfacename="iridescenceThickness" />
|
||||
<input name="value2" type="float" value="0" />
|
||||
</ifgreater>
|
||||
<artistic_ior name="artistic_ior" type="multioutput">
|
||||
<input name="reflectivity" type="color3" interfacename="reflectivity" />
|
||||
<input name="edge_color" type="color3" interfacename="edgeColor" />
|
||||
</artistic_ior>
|
||||
<convert name="convert_ior" type="color3">
|
||||
<input name="in" type="vector3" interfacename="IOR" />
|
||||
</convert>
|
||||
<convert name="convert_extinction" type="color3">
|
||||
<input name="in" type="vector3" interfacename="extinction" />
|
||||
</convert>
|
||||
<switch name="eta_switch" type="color3">
|
||||
<input name="in1" type="color3" nodename="convert_ior" />
|
||||
<input name="in2" type="color3" nodename="artistic_ior" output="ior" />
|
||||
<input name="which" type="integer" interfacename="fresnelMode" />
|
||||
</switch>
|
||||
<switch name="kappa_switch" type="color3">
|
||||
<input name="in1" type="color3" nodename="convert_extinction" />
|
||||
<input name="in2" type="color3" nodename="artistic_ior" output="extinction" />
|
||||
<input name="which" type="integer" interfacename="fresnelMode" />
|
||||
</switch>
|
||||
<divide name="relative_eta" type="color3">
|
||||
<input name="in1" type="color3" nodename="eta_switch" />
|
||||
<input name="in2" type="float" nodename="exterior_ior_switch" />
|
||||
</divide>
|
||||
<divide name="relative_kappa" type="color3">
|
||||
<input name="in1" type="color3" nodename="kappa_switch" />
|
||||
<input name="in2" type="float" nodename="exterior_ior_switch" />
|
||||
</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>
|
||||
|
||||
<!-- BRDF -->
|
||||
<conductor_bsdf name="conductor_bsdf" type="BSDF">
|
||||
<input name="weight" type="float" value="1.0" />
|
||||
<input name="ior" type="color3" nodename="relative_eta" />
|
||||
<input name="extinction" type="color3" nodename="relative_kappa" />
|
||||
<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" />
|
||||
</conductor_bsdf>
|
||||
|
||||
<!-- BRDF + Thin film -->
|
||||
<divide name="iridescence_relative_ior" type="float">
|
||||
<input name="in1" type="float" interfacename="iridescenceIOR" />
|
||||
<input name="in2" type="float" interfacename="exteriorIOR" />
|
||||
</divide>
|
||||
<thin_film_bsdf name="thin_film_bsdf" type="BSDF">
|
||||
<input name="thickness" type="float" interfacename="iridescenceThickness" />
|
||||
<input name="ior" type="float" nodename="iridescence_relative_ior" />
|
||||
</thin_film_bsdf>
|
||||
|
||||
<!-- Layered BRDF -->
|
||||
<layer name="thin_film_conductor_bsdf" type="BSDF">
|
||||
<input name="top" type="BSDF" nodename="thin_film_bsdf" />
|
||||
<input name="base" type="BSDF" nodename="conductor_bsdf" />
|
||||
</layer>
|
||||
|
||||
<!-- Tinted BRDF -->
|
||||
<multiply name="tinted_bsdf" type="BSDF">
|
||||
<input name="in1" type="BSDF" nodename="thin_film_conductor_bsdf" />
|
||||
<input name="in2" type="color3" interfacename="tint" />
|
||||
</multiply>
|
||||
|
||||
<!-- Output -->
|
||||
<output name="out" type="BSDF" nodename="tinted_bsdf" />
|
||||
|
||||
</nodegraph>
|
||||
</materialx>
|
||||
Vendored
+165
@@ -0,0 +1,165 @@
|
||||
<?xml version="1.0"?>
|
||||
<materialx version="1.38" colorspace="acescg">
|
||||
<nodedef name="ND_lama_dielectric" node="LamaDielectric" nodegroup="pbr" doc="Lama dielectric" 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="float" value="1.5" uimin="1.0" uimax="3.0" uiname="IOR" uifolder="Main"
|
||||
doc="Index of refraction (often denoted by eta), defining the amount reflected by the surface in the normal direction, and how the rays are bent by refraction." />
|
||||
<input name="reflectivity" type="float" value="0.04" uiname="Reflectivity" uifolder="Main"
|
||||
doc="Reflectivity" />
|
||||
<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="direction" type="vector3" defaultgeomprop="Tworld" uiname="Direction" uifolder="Anisotropy"
|
||||
doc="Overrides the surface tangent as the anisotropy direction." />
|
||||
<input name="rotation" 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="exteriorIOR" type="float" value="1.0" uimin="1.0" uimax="3.0" uiname="Exterior IOR" uifolder="Advanced"
|
||||
doc="Defines what the IOR of the exterior medium is (can be either the outside medium, eg. air or water, or in case of a layered material, the top layer medium, like plexiglass or varnish)." />
|
||||
<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_dielectric" nodedef="ND_lama_dielectric">
|
||||
|
||||
<!-- IOR -->
|
||||
<convert name="reflectivity_color" type="color3">
|
||||
<input name="in" type="float" interfacename="reflectivity" uivisible="false" />
|
||||
</convert>
|
||||
<artistic_ior name="artistic_ior" type="multioutput">
|
||||
<input name="reflectivity" type="color3" nodename="reflectivity_color" />
|
||||
<input name="edge_color" type="color3" value="0.0, 0.0, 0.0" />
|
||||
</artistic_ior>
|
||||
<switch name="fresnel_mode_switch" type="float">
|
||||
<input name="in1" type="float" interfacename="IOR" />
|
||||
<input name="in2" type="float" nodename="artistic_ior" output="ior" channels="r" />
|
||||
<input name="which" type="integer" interfacename="fresnelMode" />
|
||||
</switch>
|
||||
<divide name="relative_ior" type="float">
|
||||
<input name="in1" type="float" nodename="fresnel_mode_switch" />
|
||||
<input name="in2" type="float" interfacename="exteriorIOR" />
|
||||
</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="rotation" />
|
||||
<input name="in2" type="float" value="-360" />
|
||||
</multiply>
|
||||
<subtract name="tangent_rotate_degree_offset" type="float">
|
||||
<input name="in1" type="float" nodename="tangent_rotate_degree" />
|
||||
<input name="in2" type="float" value="0" />
|
||||
</subtract>
|
||||
<rotate3d name="tangent_rotate" type="vector3">
|
||||
<input name="in" type="vector3" interfacename="direction" />
|
||||
<input name="amount" type="float" nodename="tangent_rotate_degree_offset" />
|
||||
<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="relative_ior" />
|
||||
<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 -->
|
||||
<dielectric_bsdf name="reflection_bsdf" type="BSDF">
|
||||
<input name="weight" type="float" value="1.0" />
|
||||
<input name="tint" type="color3" interfacename="reflectionTint" />
|
||||
<input name="ior" type="float" nodename="relative_ior" />
|
||||
<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" />
|
||||
</dielectric_bsdf>
|
||||
|
||||
<!-- BSDF -->
|
||||
<layer name="dielectric_bsdf" type="BSDF">
|
||||
<input name="top" type="BSDF" nodename="reflection_bsdf" />
|
||||
<input name="base" type="BSDF" nodename="transmission_layer" />
|
||||
</layer>
|
||||
|
||||
<!-- Output -->
|
||||
<output name="out" type="BSDF" nodename="dielectric_bsdf" />
|
||||
|
||||
</nodegraph>
|
||||
</materialx>
|
||||
Vendored
+35
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0"?>
|
||||
<materialx version="1.38" colorspace="acescg">
|
||||
<nodedef name="ND_lama_diffuse" node="LamaDiffuse" nodegroup="pbr" version="1.0" isdefaultversion="true">
|
||||
<input name="color" uiname="Color" type="color3" value="0.18, 0.18, 0.18"
|
||||
doc="Diffuse color (aka albedo), defining what ratio of light is reflected for each color channel." />
|
||||
<input name="roughness" uiname="Roughness" type="float" uimin="0.0" uimax="1.0" value="0.0" doc="Micro-facet distribution (Oren-Nayar) roughness." />
|
||||
<input name="normal" uiname="Normal" type="vector3" defaultgeomprop="Nworld"
|
||||
doc="Shading normal, typically defined by bump or normal mapping. Defaults to the smooth surface normal if not set." />
|
||||
<input name="energyCompensation" uiname="Energy Compensation" uifolder="Advanced" type="float" uniform="true" uimin="0.0" uimax="1.0" value="1.0"
|
||||
doc="Indicates how much energy should be added to compensate for the loss inherent to the Oren-Nayar model, ranging from no compensation at all, to the expected energy from multiple scattering between the micro-facets. This prevents overly dark results when roughness is high." />
|
||||
<input name="lobeName" uiname="Lobe Name" uifolder="Advanced" type="string" uniform="true" value="diffuse"
|
||||
doc="Defines the name that can be used in LPE AOVs for this lobe." />
|
||||
<input name="matte" uiname="Matte" uifolder="Advanced" type="string" uniform="true" value=""
|
||||
doc="Defines the name that can be used by the matte system, to output the weight of this lobe in the final material as an AOV." />
|
||||
<output name="out" type="BSDF" />
|
||||
</nodedef>
|
||||
|
||||
<nodegraph name="NG_lama_diffuse" nodedef="ND_lama_diffuse">
|
||||
<multiply name="roughness_squared" type="float">
|
||||
<input name="in1" type="float" interfacename="roughness" />
|
||||
<input name="in2" type="float" interfacename="roughness" />
|
||||
</multiply>
|
||||
<multiply name="half_roughness_squared" type="float">
|
||||
<input name="in1" type="float" nodename="roughness_squared" />
|
||||
<input name="in2" type="float" value="0.5" />
|
||||
</multiply>
|
||||
<oren_nayar_diffuse_bsdf name="oren_nayar" type="BSDF">
|
||||
<input name="weight" type="float" value="1.0" />
|
||||
<input name="color" type="color3" interfacename="color" />
|
||||
<input name="roughness" type="float" nodename="half_roughness_squared" />
|
||||
<input name="normal" type="vector3" interfacename="normal" />
|
||||
</oren_nayar_diffuse_bsdf>
|
||||
<output name="out" type="BSDF" nodename="oren_nayar" />
|
||||
</nodegraph>
|
||||
</materialx>
|
||||
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0"?>
|
||||
<materialx version="1.38" colorspace="acescg">
|
||||
<nodedef name="ND_lama_emission" node="LamaEmission" nodegroup="pbr" doc="Lama emission" version="1.0" isdefaultversion="true">
|
||||
<input name="color" type="color3" value="1.0, 1.0, 1.0" uiname="Color" uifolder="Main"
|
||||
doc="Color being uniformly emitted in all directions above the surface." />
|
||||
<output name="out" type="EDF" />
|
||||
</nodedef>
|
||||
|
||||
<nodegraph name="IMPL_lama_emission" nodedef="ND_lama_emission">
|
||||
|
||||
<!-- EDF -->
|
||||
<uniform_edf name="emission" type="EDF">
|
||||
<input name="color" type="color3" interfacename="color" />
|
||||
</uniform_edf>
|
||||
|
||||
<!-- Output -->
|
||||
<output name="out" type="EDF" nodename="emission" />
|
||||
|
||||
</nodegraph>
|
||||
</materialx>
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0"?>
|
||||
<materialx version="1.38" colorspace="acescg">
|
||||
<!-- LamaLayer for BSDFs -->
|
||||
<nodedef name="ND_lama_layer_bsdf" node="LamaLayer" nodegroup="pbr" version="1.0" isdefaultversion="true">
|
||||
<input name="materialTop" uiname="Material Top" type="BSDF"
|
||||
doc="Material used for the top slab. If not set, the base material will be used by itself." />
|
||||
<input name="materialBase" uiname="Material Base" type="BSDF"
|
||||
doc="Base material, right under the top one." />
|
||||
<input name="topMix" uiname="Top Mix" type="float" uimin="0.0" uimax="1.0" value="1.0"
|
||||
doc="Defines how visible the top material is." />
|
||||
<!-- NOTE: The topThickness feature isn't supported by the MaterialX definitions of the nodes right now. -->
|
||||
<input name="topThickness" uiname="Top Thickness" type="float" uimin="0.0" value="0.0"
|
||||
doc="Thickness of the top slab. It is only relevant for interior effects associated with the top material, such as absorption. If the top material is itself a layer node, this value is passed on to its base component. And if the top material is a mix or add, this value is passed on to both child materials." />
|
||||
<output name="out" type="BSDF" />
|
||||
</nodedef>
|
||||
<nodegraph name="NG_lama_layer_bsdf" nodedef="ND_lama_layer_bsdf">
|
||||
<multiply name="mul" type="BSDF">
|
||||
<input name="in1" type="BSDF" interfacename="materialTop" />
|
||||
<input name="in2" type="float" interfacename="topMix" />
|
||||
</multiply>
|
||||
<layer name="layer" type="BSDF">
|
||||
<input name="top" type="BSDF" nodename="mul" />
|
||||
<input name="base" type="BSDF" interfacename="materialBase" />
|
||||
</layer>
|
||||
<output name="out" type="BSDF" nodename="layer" />
|
||||
</nodegraph>
|
||||
</materialx>
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
<?xml version="1.0"?>
|
||||
<materialx version="1.38" colorspace="acescg">
|
||||
|
||||
<!-- LamaMix for BSDFs -->
|
||||
<nodedef name="ND_lama_mix_bsdf" node="LamaMix" nodegroup="pbr" version="1.0" isdefaultversion="true">
|
||||
<input name="material1" uiname="Material 1" type="BSDF"
|
||||
doc="First material to mix." />
|
||||
<input name="material2" uiname="Material 2" type="BSDF"
|
||||
doc="Second material to mix." />
|
||||
<input name="mix" type="float" uimin="0.0" uimax="1.0" value="0.0"
|
||||
doc="Defines the balance between the two materials, ranging from 0 (Material 1 only) to 1 (Material 2 only). Can also be seen as a Material 2 over Material 1 mask." />
|
||||
<output name="out" type="BSDF" />
|
||||
</nodedef>
|
||||
<nodegraph name="NG_lama_mix_bsdf" nodedef="ND_lama_mix_bsdf">
|
||||
<mix name="mix" type="BSDF">
|
||||
<input name="fg" type="BSDF" interfacename="material2" />
|
||||
<input name="bg" type="BSDF" interfacename="material1" />
|
||||
<input name="mix" type="float" interfacename="mix" />
|
||||
</mix>
|
||||
<output name="out" type="BSDF" nodename="mix" />
|
||||
</nodegraph>
|
||||
|
||||
<!-- LamaMix for EDFs -->
|
||||
<nodedef name="ND_lama_mix_edf" node="LamaMix" nodegroup="pbr" version="1.0" isdefaultversion="true">
|
||||
<input name="material1" uiname="Material 1" type="EDF"
|
||||
doc="First material to mix." />
|
||||
<input name="material2" uiname="Material 2" type="EDF"
|
||||
doc="Second material to mix." />
|
||||
<input name="mix" type="float" uimin="0.0" uimax="1.0" value="0.0"
|
||||
doc="Defines the balance between the two materials, ranging from 0 (Material 1 only) to 1 (Material 2 only). Can also be seen as a Material 2 over Material 1 mask." />
|
||||
<output name="out" type="EDF" />
|
||||
</nodedef>
|
||||
<nodegraph name="NG_lama_mix_edf" nodedef="ND_lama_mix_edf">
|
||||
<mix name="mix" type="EDF">
|
||||
<input name="fg" type="EDF" interfacename="material2" />
|
||||
<input name="bg" type="EDF" interfacename="material1" />
|
||||
<input name="mix" type="float" interfacename="mix" />
|
||||
</mix>
|
||||
<output name="out" type="EDF" nodename="mix" />
|
||||
</nodegraph>
|
||||
</materialx>
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
<?xml version="1.0"?>
|
||||
<materialx version="1.38" colorspace="acescg">
|
||||
<nodedef name="ND_lama_sheen" node="LamaSheen" nodegroup="pbr" doc="Lama sheen" version="1.0" isdefaultversion="true">
|
||||
<input name="color" type="color3" value="1, 1, 1" uiname="Color" uifolder="Main"
|
||||
doc="Amount of sheen to add, per channel. When this node is used as top material in a stack, the more sheen is added, the less energy will be transmitted to the base material." />
|
||||
<input name="roughness" type="float" value="0.1" uimin="0.0" uimax="1.0" uiname="Roughness" uifolder="Main"
|
||||
doc="Roughness of the sheen effect. Very rough sheen can be used to create a rough diffuse look (when combined with a diffuse node by a stack or mix)." />
|
||||
<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." />
|
||||
<output name="out" type="BSDF" />
|
||||
</nodedef>
|
||||
|
||||
<nodegraph name="IMPL_lama_sheen" nodedef="ND_lama_sheen">
|
||||
|
||||
<!-- Roughness -->
|
||||
<multiply name="roughness_compressed" type="float">
|
||||
<input name="in1" type="float" interfacename="roughness" />
|
||||
<input name="in2" type="float" value="0.9" />
|
||||
</multiply>
|
||||
<add name="roughness_remapped" type="float">
|
||||
<input name="in1" type="float" nodename="roughness_compressed" />
|
||||
<input name="in2" type="float" value="0.1" />
|
||||
</add>
|
||||
<power name="roughness_squared" type="float">
|
||||
<input name="in1" type="float" nodename="roughness_remapped" />
|
||||
<input name="in2" type="float" value="2" />
|
||||
</power>
|
||||
|
||||
<!-- BRDF -->
|
||||
<sheen_bsdf name="sheen_bsdf" type="BSDF">
|
||||
<input name="weight" type="float" value="1.0" />
|
||||
<input name="color" type="color3" interfacename="color" />
|
||||
<input name="roughness" type="float" nodename="roughness_squared" />
|
||||
<input name="normal" type="vector3" interfacename="normal" />
|
||||
</sheen_bsdf>
|
||||
|
||||
<!-- Output -->
|
||||
<output name="out" type="BSDF" nodename="sheen_bsdf" />
|
||||
|
||||
</nodegraph>
|
||||
</materialx>
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
<?xml version="1.0"?>
|
||||
<materialx version="1.38" colorspace="acescg">
|
||||
<nodedef name="ND_lama_sss" node="LamaSSS" nodegroup="pbr" doc="Lama SSS" version="1.0" isdefaultversion="true">
|
||||
<input name="color" type="color3" value="0.18, 0.18, 0.18" uiname="Color" uifolder="Main"
|
||||
doc="Diffuse color (aka albedo), defining what ratio of light is reflected -- or transmitted -- for each color channel." />
|
||||
<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="sssRadius" type="color3" value="0.0, 0.0, 0.0" uiname="Radius" uifolder="SSS"
|
||||
doc="Diffuse Mean Free Path, expressed for each color channel in mm. Indicates on average how much the light travels under the surface before being scattered. The higher the value, the softer the result will be. If null, the computation simplifies to a Lambertian lobe." />
|
||||
<input name="sssScale" type="float" value="1.0" uiname="Scale" uifolder="SSS"
|
||||
doc="Multiplies the radius, to adjust its scale to the scene at hand. If null, the computation simplifies to a Lambertian lobe." />
|
||||
<input name="sssMode" type="integer" uniform="true" enum="Path-traced Davis,Path-traced exponential,Diffusion Burley,Diffusion Burley (mean free path)" enumvalues="0,1,2,3" value="0" uiname="Mode" uifolder="Main"
|
||||
doc="Selects what method should be used to compute sub-surface scattering. Proposes two path-traced variants, and a more traditional approximate diffusion model." />
|
||||
<input name="sssIOR" type="float" value="1.0" uimin="1.0" uimax="2.0" uiname="IOR" uifolder="SSS"
|
||||
doc="Index of refraction use to trigger cases of total internal reflections, when the paths are reaching the surface after having travelled under it. Can be used to avoid excessive glow in highly curved regions (corners, creases, ...)." />
|
||||
<input name="sssAnisotropy" type="float" value="0.0" uimin="-1.0" uimax="1.0" uiname="Anisotropy" uifolder="SSS"
|
||||
doc="Higher values makes light scatter predominantly forward under the surface, making the object look less diffuse and more transparent." />
|
||||
<input name="sssBleed" type="float" value="0.0" uimin="0.0" uimax="1.0" uiname="Bleed" uifolder="SSS"
|
||||
doc="Controls the depth of light bleed in the subsurface medium. Has the effect of increasing the distance light travels in the medium while preserving fine detail, compared to increasing the Mean Free Path." />
|
||||
<input name="sssFollowTopology" type="float" value="0.0" uimin="0.0" uimax="1.0" uiname="Follow Topology" uifolder="SSS"
|
||||
doc="Controls how strongly normals are considered in the subsurface computation." />
|
||||
<input name="sssSubset" type="string" uniform="true" value="" uiname="Subset" uifolder="SSS"
|
||||
doc="Specifies trace subset for inclusion/exclusion when struck by a ray indirectly." />
|
||||
<input name="sssContinuationRays" type="integer" value="0" uiname="Continuation Rays" uifolder="SSS"
|
||||
doc="When enabled, ignores internal geometry and jumps to the last surface." />
|
||||
<input name="sssUnitLength" type="float" value="0.00328" uiname="Unit Length" uifolder="SSS"
|
||||
doc="Specifies what unit length the scene is using. It is a multiplier on the mean free path or diffuse mean free path which is expressed in mm. The default value of 0.00328 converts between feet and mm." />
|
||||
<input name="mode" type="integer" uniform="true" enum="Reflection,Transmission,Reflection(with direct illumination)" enumvalues="0,1,2" value="0" uiname="Mode" uifolder="Advanced"
|
||||
doc="If the subsurface is enabled, Reflection: should be used when both the camera and the light are outside of the object. Reflection(with direct illumination): should be used when both the camera and the light are outside of the object. This mode also computes the direct illumination at the sss ray exit point. Transmission: should be used when the light is inside the object while the camera is outside. " />
|
||||
<input name="albedoInversionMethod" type="integer" enum="Pixar,Chiang" enumvalues="0,1" value="0" uiname="Albedo Inversion Method" uifolder="Advanced"
|
||||
doc="Decides which albedo inversion methods is used. Pixar: Does the Pixar Path Traced SSS default albedo inversion. Chiang: Does Chiang's albedo inversion (with no dmfp remapping). The look is closer to Arnold Standard Surface randomwalk." />
|
||||
<input name="diffuseLobeName" type="string" uniform="true" value="diffuse" uiname="Diffuse Lobe Name" uifolder="Advanced"
|
||||
doc="Defines the name that can be used in LPE AOVs for the diffuse lobe (when the SSS radius is null)." />
|
||||
<input name="sssEntryLobeName" type="string" uniform="true" value="irradiance" uiname="SSS Entry Lobe Name" uifolder="Advanced"
|
||||
doc="Defines the name that can be used in LPE AOVs for the SSS Entry lobe." />
|
||||
<input name="sssExitLobeName" type="string" uniform="true" value="" uiname="SSS Exit Lobe Name" uifolder="Advanced"
|
||||
doc="Defines the name that can be used in LPE AOVs for the SSS Exit lobe." />
|
||||
<input name="sssId" type="integer" uniform="true" value="0" enum="0, 1" enumvalues="0, 1" uiname="SSS Id" uifolder="Advanced"
|
||||
doc="SSS ID" />
|
||||
<input name="matte" type="string" uniform="true" value="" uiname="Matte" uifolder="Advanced"
|
||||
doc="Defines the name that can be used by the matte system, to output the weight of this lobe in the final material as an AOV." />
|
||||
<output name="out" type="BSDF" />
|
||||
</nodedef>
|
||||
|
||||
<nodegraph name="IMPL_lama_sss" nodedef="ND_lama_sss">
|
||||
|
||||
<!-- DMFP -->
|
||||
<convert name="subsurface_radius_vector" type="vector3">
|
||||
<input name="in" type="color3" interfacename="sssRadius" />
|
||||
</convert>
|
||||
<multiply name="subsurface_radius_scaled" type="vector3">
|
||||
<input name="in1" type="vector3" nodename="subsurface_radius_vector" />
|
||||
<input name="in2" type="float" interfacename="sssScale" />
|
||||
</multiply>
|
||||
<multiply name="subsurface_multiply_unitlength" type="vector3">
|
||||
<input name="in1" type="vector3" nodename="subsurface_radius_scaled" />
|
||||
<input name="in2" type="float" interfacename="sssUnitLength" />
|
||||
</multiply>
|
||||
|
||||
<!-- BRDF -->
|
||||
<subsurface_bsdf name="subsurface_bsdf" type="BSDF">
|
||||
<input name="weight" type="float" value="1.0" />
|
||||
<input name="color" type="color3" interfacename="color" />
|
||||
<input name="radius" type="vector3" nodename="subsurface_multiply_unitlength" />
|
||||
<input name="anisotropy" type="float" interfacename="sssAnisotropy" />
|
||||
<input name="normal" type="vector3" interfacename="normal" />
|
||||
</subsurface_bsdf>
|
||||
|
||||
<!-- Output -->
|
||||
<output name="out" type="BSDF" nodename="subsurface_bsdf" />
|
||||
|
||||
</nodegraph>
|
||||
</materialx>
|
||||
Vendored
+26
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0"?>
|
||||
<materialx version="1.38" colorspace="acescg">
|
||||
<nodedef name="ND_lama_translucent" node="LamaTranslucent" nodegroup="pbr" version="1.0" isdefaultversion="true">
|
||||
<input name="color" uiname="Color" type="color3" value="0.18, 0.18, 0.18"
|
||||
doc="Translucent color (aka albedo), defining what ratio of light is transmitted for each color channel." />
|
||||
<input name="roughness" uiname="Roughness" type="float" uimin="0.0" uimax="1.0" value="0.0"
|
||||
doc="Micro-facet distribution (Oren-Nayar) roughness." />
|
||||
<input name="normal" uiname="Normal" type="vector3" defaultgeomprop="Nworld"
|
||||
doc="Shading normal, typically defined by bump or normal mapping. Defaults to the smooth surface normal if not set." />
|
||||
<input name="energyCompensation" uiname="Energy Compensation" uifolder="Advanced" type="float" uniform="true" uimin="0.0" uimax="1.0" value="1.0"
|
||||
doc="Indicates how much energy should be added to compensate for the loss inherent to the Oren-Nayar model, ranging from no compensation at all, to the expected energy from multiple scattering between the micro-facets. This prevents overly dark results when roughness is high." />
|
||||
<input name="lobeName" uiname="Lobe Name" uifolder="Advanced" type="string" uniform="true" value="diffuse"
|
||||
doc="Defines the name that can be used in LPE AOVs for this lobe." />
|
||||
<input name="matte" uiname="Matte" uifolder="Advanced" type="string" uniform="true" value=""
|
||||
doc="Defines the name that can be used by the matte system, to output the weight of this lobe in the final material as an AOV." />
|
||||
<output name="out" type="BSDF" />
|
||||
</nodedef>
|
||||
|
||||
<nodegraph name="NG_lama_translucent" nodedef="ND_lama_translucent">
|
||||
<translucent_bsdf name="translucent_bsdf1" type="BSDF">
|
||||
<input name="color" type="color3" interfacename="color" />
|
||||
<input name="normal" type="vector3" interfacename="normal" />
|
||||
</translucent_bsdf>
|
||||
<output name="out" type="BSDF" nodename="translucent_bsdf1" />
|
||||
</nodegraph>
|
||||
</materialx>
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
<?xml version="1.0"?>
|
||||
<materialx version="1.38">
|
||||
<!--
|
||||
OpenPBR Surface node definition
|
||||
-->
|
||||
<nodedef name="ND_open_pbr_surface_surfaceshader" node="open_pbr_surface" nodegroup="pbr" version="1.1" isdefaultversion="true"
|
||||
doc="OpenPBR Surface Shading Model" uiname="OpenPBR Surface">
|
||||
<input name="base_weight" type="float" value="1.0" uimin="0.0" uimax="1.0" uiname="Base Weight" uifolder="Base"
|
||||
doc="Multiplier on the intensity of the reflection from the diffuse and metallic base." />
|
||||
<input name="base_color" type="color3" value="0.8, 0.8, 0.8" uimin="0,0,0" uimax="1,1,1" uiname="Base Color" uifolder="Base"
|
||||
doc="Color of the reflection from the diffuse and metallic base." />
|
||||
<input name="base_diffuse_roughness" type="float" value="0.0" uimin="0.0" uimax="1.0" uiname="Base Diffuse Roughness" uifolder="Base" uiadvanced="true"
|
||||
doc="Roughness of the diffuse reflection. Higher values cause the surface to appear flatter." />
|
||||
<input name="base_metalness" type="float" value="0.0" uimin="0.0" uimax="1.0" uiname="Base Metalness" uifolder="Base"
|
||||
doc="Specifies how metallic the base material appears (dials the base from pure dielectric to pure metal)." />
|
||||
<input name="specular_weight" type="float" value="1.0" uimin="0.0" uisoftmax="1.0" uiname="Specular Weight" uifolder="Specular"
|
||||
doc="Multiplies the specular reflectivity." />
|
||||
<input name="specular_color" type="color3" value="1, 1, 1" uimin="0,0,0" uimax="1,1,1" uiname="Specular Color" uifolder="Specular"
|
||||
doc="Color of the specular reflection (controls the physical edge-tint for metals, and a non-physical overall tint for dielectrics)." />
|
||||
<input name="specular_roughness" type="float" value="0.3" uimin="0.0" uimax="1.0" uiname="Specular Roughness" uifolder="Specular"
|
||||
doc="The roughness of the specular reflection. Lower numbers produce sharper reflections, higher numbers produce blurrier reflections." />
|
||||
<input name="specular_ior" type="float" value="1.5" uimin="0.0" uisoftmin="1.0" uisoftmax="3.0" uiname="Specular Index of Refraction" uifolder="Specular"
|
||||
doc="Index of refraction of the dielectric base." />
|
||||
<input name="specular_roughness_anisotropy" type="float" value="0.0" uimin="0.0" uimax="1.0" uiname="Specular Anisotropy" uifolder="Specular" uiadvanced="true"
|
||||
doc="The directional bias of the roughness of the metal/dielectric base, resulting in increasingly stretched highlights along the tangent direction." />
|
||||
<input name="transmission_weight" type="float" value="0.0" uimin="0.0" uimax="1.0" uiname="Transmission Weight" uifolder="Transmission" uiadvanced="true"
|
||||
doc="Mixture weight between the transparent and opaque dielectric base. The greater the value the more transparent the material." />
|
||||
<input name="transmission_color" type="color3" value="1, 1, 1" uimin="0,0,0" uimax="1,1,1" uiname="Transmission Color" uifolder="Transmission" uiadvanced="true"
|
||||
doc="Controls color of the transparent base due to Beer's law volumetric absorption under the surface (reverts to a non-physical tint when transmission_depth is zero)." />
|
||||
<input name="transmission_depth" type="float" value="0.0" uimin="0.0" uisoftmax="1.0" uiname="Transmission Depth" uifolder="Transmission" uiadvanced="true"
|
||||
doc="Specifies the distance light travels inside the transparent base before it becomes exactly the transmission_color according to Beer's law." />
|
||||
<input name="transmission_scatter" type="color3" value="0, 0, 0" uimin="0,0,0" uimax="1,1,1" uiname="Transmission Scatter" uifolder="Transmission" uiadvanced="true"
|
||||
doc="Controls the color of light volumetrically scattered inside the transparent base. Suitable for materials with visually significant scattering such as honey, fruit juice, murky water, opalescent glass, or milky glass." />
|
||||
<input name="transmission_scatter_anisotropy" type="float" value="0.0" uimin="-1.0" uimax="1.0" uiname="Transmission Anisotropy" uifolder="Transmission" uiadvanced="true"
|
||||
doc="The amount of directional bias, or anisotropy, of the volumetric scattering in the transparent base." />
|
||||
<input name="transmission_dispersion_scale" type="float" value="0.0" uimin="0.0" uimax="1.0" uiname="Transmission Dispersion Scale" uifolder="Transmission" uiadvanced="true"
|
||||
doc="Linearly scales the amount of dispersion." />
|
||||
<input name="transmission_dispersion_abbe_number" type="float" value="20.0" uimin="0.0" uisoftmin="9.0" uisoftmax="91.0" uiname="Transmission Dispersion Abbe Number" uifolder="Transmission" uiadvanced="true"
|
||||
doc="Physical Abbe number of the dielectric medium, describing how much the dielectric index of refraction varies across wavelengths." />
|
||||
<input name="subsurface_weight" type="float" value="0" uimin="0.0" uimax="1.0" uiname="Subsurface Weight" uifolder="Subsurface" uiadvanced="true"
|
||||
doc="Mixture weight which dials the opaque dielectric base between diffuse reflection and subsurface scattering. A value of 1.0 indicates full subsurface scattering and a value 0 for diffuse reflection only." />
|
||||
<input name="subsurface_color" type="color3" value="0.8, 0.8, 0.8" uimin="0,0,0" uimax="1,1,1" uiname="Subsurface Color" uifolder="Subsurface" uiadvanced="true"
|
||||
doc="The observed reflection color of the subsurface scattering medium." />
|
||||
<input name="subsurface_radius" type="float" value="1.0" uimin="0.0" uisoftmax="1.0" uiname="Subsurface Radius" uifolder="Subsurface" uiadvanced="true"
|
||||
doc="Length scale of the subsurface scattering mean free path." />
|
||||
<input name="subsurface_radius_scale" type="color3" value="1.0, 0.5, 0.25" uimin="0,0,0" uimax="1,1,1" uiname="Subsurface Radius Scale" uifolder="Subsurface" uiadvanced="true"
|
||||
doc="RGB multiplier to subsurface_radius, giving the per-channel scattering mean-free-paths." />
|
||||
<input name="subsurface_scatter_anisotropy" type="float" value="0.0" uimin="-1.0" uimax="1.0" uiname="Subsurface Anisotropy" uifolder="Subsurface" uiadvanced="true"
|
||||
doc="Controls the phase-function of subsurface scattering, where zero scatters light evenly, positive values scatter forwards, and negative values scatter backwards." />
|
||||
<input name="fuzz_weight" type="float" value="0.0" uimin="0.0" uimax="1.0" uiname="Fuzz Weight" uifolder="Fuzz" uiadvanced="true"
|
||||
doc="The presence weight of a fuzz layer that can be used to approximate microfibers, for fabrics such as velvet and satin as well as dust grains." />
|
||||
<input name="fuzz_color" type="color3" value="1, 1, 1" uimin="0,0,0" uimax="1,1,1" uiname="Fuzz Color" uifolder="Fuzz" uiadvanced="true"
|
||||
doc="The color of the fuzz layer." />
|
||||
<input name="fuzz_roughness" type="float" value="0.5" uimin="0.0" uimax="1.0" uiname="Fuzz Roughness" uifolder="Fuzz" uiadvanced="true"
|
||||
doc="The roughness of the fuzz layer." />
|
||||
<input name="coat_weight" type="float" value="0.0" uimin="0.0" uimax="1.0" uiname="Coat Weight" uifolder="Coat"
|
||||
doc="The presence weight of a reflective clear-coat layer on top of the material. Use for materials such as car paint or an oily layer." />
|
||||
<input name="coat_color" type="color3" value="1, 1, 1" uimin="0,0,0" uimax="1,1,1" uiname="Coat Color" uifolder="Coat"
|
||||
doc="The color of the clear-coat layer's transparency, due to absorption in the coat." />
|
||||
<input name="coat_roughness" type="float" value="0.0" uimin="0.0" uimax="1.0" uiname="Coat Roughness" uifolder="Coat"
|
||||
doc="The roughness of the clear-coat reflections. The lower the value, the sharper the reflection." />
|
||||
<input name="coat_roughness_anisotropy" type="float" value="0.0" uimin="0.0" uimax="1.0" uiname="Coat Anisotropy" uifolder="Coat" uiadvanced="true"
|
||||
doc="The directional bias of the roughness of the clear-coat layer, resulting in increasingly stretched highlights along the coat tangent direction." />
|
||||
<input name="coat_ior" type="float" value="1.6" uimin="0.0" uisoftmin="1.0" uisoftmax="3.0" uiname="Coat Index of Refraction" uifolder="Coat"
|
||||
doc="The index of refraction of the clear-coat layer." />
|
||||
<input name="coat_darkening" type="float" value="1.0" uimin="0.0" uimax="1.0" uiname="Coat Darkening" uifolder="Coat"
|
||||
doc="Modulates the physical coat darkening effect." />
|
||||
<input name="thin_film_weight" type="float" value="0" uimin="0.0" uimax="1.0" uiname="Thin Film Weight" uifolder="Thin Film" uiadvanced="true"
|
||||
doc="Coverage weight of the thin-film. Use for materials such as multi-tone car paint or soap bubbles." />
|
||||
<input name="thin_film_thickness" type="float" value="0.5" uimin="0.0" uisoftmax="1.0" uiname="Thin Film Thickness" uifolder="Thin Film" uiadvanced="true"
|
||||
doc="The thickness of the thin-film layer on the base (in micrometers)." />
|
||||
<input name="thin_film_ior" type="float" value="1.4" uimin="0.0" uisoftmin="1.0" uisoftmax="3.0" uiname="Thin Film Index of Refraction" uifolder="Thin Film" uiadvanced="true"
|
||||
doc="The index of refraction of the thin-film." />
|
||||
<input name="emission_luminance" type="float" value="0.0" uimin="0.0" uisoftmax="1000.0" uiname="Emission Luminance" uifolder="Emission"
|
||||
doc="The amount of emitted light, as a luminance in nits." />
|
||||
<input name="emission_color" type="color3" value="1, 1, 1" uimin="0,0,0" uimax="1,1,1" uiname="Emission Color" uifolder="Emission"
|
||||
doc="The color of the emitted light." />
|
||||
<input name="geometry_opacity" type="float" value="1" uimin="0" uimax="1" uiname="Opacity" uifolder="Geometry"
|
||||
doc="The opacity of the entire material." />
|
||||
<input name="geometry_thin_walled" type="boolean" value="false" uiname="Thin Walled" uifolder="Geometry" uiadvanced="true"
|
||||
doc="If true the surface is double-sided and represents an infinitesimally thin shell. Suitable for extremely geometrically thin objects such as leaves or paper." />
|
||||
<input name="geometry_normal" type="vector3" defaultgeomprop="Nworld" uiname="Normal" uifolder="Geometry"
|
||||
doc="Input geometric normal" />
|
||||
<input name="geometry_coat_normal" type="vector3" defaultgeomprop="Nworld" uiname="Coat Normal" uifolder="Geometry"
|
||||
doc="Input normal for coat layer" />
|
||||
<input name="geometry_tangent" type="vector3" defaultgeomprop="Tworld" uiname="Tangent" uifolder="Geometry"
|
||||
doc="Input geometric tangent" />
|
||||
<input name="geometry_coat_tangent" type="vector3" defaultgeomprop="Tworld" uiname="Coat Tangent" uifolder="Geometry"
|
||||
doc="Input geometric tangent for coat layer" />
|
||||
<output name="out" type="surfaceshader" />
|
||||
</nodedef>
|
||||
</materialx>
|
||||
+432
@@ -0,0 +1,432 @@
|
||||
<?xml version="1.0"?>
|
||||
<materialx version="1.38">
|
||||
<!--
|
||||
Autodesk Standard Surface node definition.
|
||||
-->
|
||||
<nodedef name="ND_standard_surface_surfaceshader" node="standard_surface" nodegroup="pbr" version="1.0.1" isdefaultversion="true" inherit="ND_standard_surface_surfaceshader_100"
|
||||
doc="Autodesk standard surface shader">
|
||||
<input name="base" type="float" value="1.0" uimin="0.0" uimax="1.0" uiname="Base" uifolder="Base"
|
||||
doc="Multiplier on the intensity of the diffuse reflection." />
|
||||
<input name="base_color" type="color3" value="0.8, 0.8, 0.8" uimin="0,0,0" uimax="1,1,1" uiname="Base Color" uifolder="Base"
|
||||
doc="Color of the diffuse reflection." />
|
||||
</nodedef>
|
||||
|
||||
<nodedef name="ND_standard_surface_surfaceshader_100" node="standard_surface" nodegroup="pbr" version="1.0.0" doc="Autodesk standard surface shader">
|
||||
<input name="base" type="float" value="0.8" uimin="0.0" uimax="1.0" uiname="Base" uifolder="Base"
|
||||
doc="Multiplier on the intensity of the diffuse reflection." />
|
||||
<input name="base_color" type="color3" value="1.0, 1.0, 1.0" uimin="0,0,0" uimax="1,1,1" uiname="Base Color" uifolder="Base"
|
||||
doc="Color of the diffuse reflection." />
|
||||
<input name="diffuse_roughness" type="float" value="0" uimin="0.0" uimax="1.0" uiname="Diffuse Roughness" uifolder="Base" uiadvanced="true"
|
||||
doc="Roughness of the diffuse reflection. Higher values cause the surface to appear flatter and darker." />
|
||||
<input name="metalness" type="float" value="0" uimin="0.0" uimax="1.0" uiname="Metalness" uifolder="Base"
|
||||
doc="Specifies how metallic the material appears. At its maximum, the surface behaves like a metal, using fully specular reflection and complex fresnel." />
|
||||
<input name="specular" type="float" value="1" uimin="0.0" uimax="1.0" uiname="Specular" uifolder="Specular"
|
||||
doc="Multiplier on the intensity of the specular reflection." />
|
||||
<input name="specular_color" type="color3" value="1, 1, 1" uimin="0,0,0" uimax="1,1,1" uiname="Specular Color" uifolder="Specular"
|
||||
doc="Color tint on the specular reflection." />
|
||||
<input name="specular_roughness" type="float" value="0.2" uimin="0.0" uimax="1.0" uiname="Specular Roughness" uifolder="Specular"
|
||||
doc="The roughness of the specular reflection. Lower numbers produce sharper reflections, higher numbers produce blurrier reflections." />
|
||||
<input name="specular_IOR" type="float" value="1.5" uimin="0.0" uisoftmin="1.0" uisoftmax="3.0" uiname="Index of Refraction" uifolder="Specular"
|
||||
doc="Index of refraction for specular reflection." />
|
||||
<input name="specular_anisotropy" type="float" value="0" uimin="0.0" uimax="1.0" uiname="Specular Anisotropy" uifolder="Specular" uiadvanced="true"
|
||||
doc="The directional bias of reflected and transmitted light resulting in materials appearing rougher or glossier in certain directions." />
|
||||
<input name="specular_rotation" type="float" value="0" uimin="0.0" uimax="1.0" uiname="Specular Rotation" uifolder="Specular" uiadvanced="true"
|
||||
doc="Rotation of the axis of specular anisotropy around the surface normal." />
|
||||
<input name="transmission" type="float" value="0" uimin="0.0" uimax="1.0" uiname="Transmission" uifolder="Transmission" uiadvanced="true"
|
||||
doc="Transmission of light through the surface for materials such as glass or water. The greater the value the more transparent the material." />
|
||||
<input name="transmission_color" type="color3" value="1, 1, 1" uimin="0,0,0" uimax="1,1,1" uiname="Transmission Color" uifolder="Transmission" uiadvanced="true"
|
||||
doc="Color tint on the transmitted light." />
|
||||
<input name="transmission_depth" type="float" value="0" uimin="0.0" uisoftmax="100.0" uiname="Transmission Depth" uifolder="Transmission" uiadvanced="true"
|
||||
doc="Specifies the distance light travels inside the material before its becomes exactly the transmission color according to Beer's law." />
|
||||
<input name="transmission_scatter" type="color3" value="0, 0, 0" uimin="0,0,0" uimax="1,1,1" uiname="Transmission Scatter" uifolder="Transmission" uiadvanced="true"
|
||||
doc="Scattering coefficient of the interior medium. Suitable for a large body of liquid or one that is fairly thick, such as an ocean, honey, ice, or frosted glass." />
|
||||
<input name="transmission_scatter_anisotropy" type="float" value="0" uimin="0.0" uimax="1.0" uiname="Transmission Anisotropy" uifolder="Transmission" uiadvanced="true"
|
||||
doc="The amount of directional bias, or anisotropy, of the scattering." />
|
||||
<input name="transmission_dispersion" type="float" value="0" uimin="0.0" uisoftmax="100.0" uiname="Transmission Dispersion" uifolder="Transmission" uiadvanced="true"
|
||||
doc="Dispersion amount, describing how much the index of refraction varies across wavelengths." />
|
||||
<input name="transmission_extra_roughness" type="float" value="0" uimin="-1.0" uisoftmin="0.0" uimax="1.0" uiname="Transmission Roughness" uifolder="Transmission" uiadvanced="true"
|
||||
doc="Additional roughness on top of specular roughness. Positive values blur refractions more than reflections, and negative values blur refractions less." />
|
||||
<input name="subsurface" type="float" value="0" uimin="0.0" uimax="1.0" uiname="Subsurface" uifolder="Subsurface" uiadvanced="true"
|
||||
doc="The blend between diffuse reflection and subsurface scattering. A value of 1.0 indicates full subsurface scattering and a value 0 for diffuse reflection only." />
|
||||
<input name="subsurface_color" type="color3" value="1, 1, 1" uimin="0,0,0" uimax="1,1,1" uiname="Subsurface Color" uifolder="Subsurface" uiadvanced="true"
|
||||
doc="The color of the subsurface scattering effect." />
|
||||
<input name="subsurface_radius" type="color3" value="1, 1, 1" uimin="0,0,0" uimax="1,1,1" uiname="Subsurface Radius" uifolder="Subsurface" uiadvanced="true"
|
||||
doc="The mean free path. The distance which light can travel before being scattered inside the surface." />
|
||||
<input name="subsurface_scale" type="float" value="1" uimin="0.0" uisoftmax="10.0" uiname="Subsurface Scale" uifolder="Subsurface" uiadvanced="true"
|
||||
doc="Scalar weight for the subsurface radius value." />
|
||||
<input name="subsurface_anisotropy" type="float" value="0" uimin="-1.0" uimax="1.0" uiname="Subsurface Anisotropy" uifolder="Subsurface" uiadvanced="true"
|
||||
doc="The direction of subsurface scattering. 0 scatters light evenly, positive values scatter forward and negative values scatter backward." />
|
||||
<input name="sheen" type="float" value="0" uimin="0.0" uimax="1.0" uiname="Sheen" uifolder="Sheen" uiadvanced="true"
|
||||
doc="The weight of a sheen layer that can be used to approximate microfibers or fabrics such as velvet and satin." />
|
||||
<input name="sheen_color" type="color3" value="1, 1, 1" uimin="0,0,0" uimax="1,1,1" uiname="Sheen Color" uifolder="Sheen" uiadvanced="true"
|
||||
doc="The color of the sheen layer." />
|
||||
<input name="sheen_roughness" type="float" value="0.3" uimin="0.0" uimax="1.0" uiname="Sheen Roughness" uifolder="Sheen" uiadvanced="true"
|
||||
doc="The roughness of the sheen layer." />
|
||||
<input name="coat" type="float" value="0" uimin="0.0" uimax="1.0" uiname="Coat" uifolder="Coat"
|
||||
doc="The weight of a reflective clear-coat layer on top of the material. Use for materials such as car paint or an oily layer." />
|
||||
<input name="coat_color" type="color3" value="1, 1, 1" uimin="0,0,0" uimax="1,1,1" uiname="Coat Color" uifolder="Coat"
|
||||
doc="The color of the clear-coat layer's transparency." />
|
||||
<input name="coat_roughness" type="float" value="0.1" uimin="0.0" uimax="1.0" uiname="Coat Roughness" uifolder="Coat"
|
||||
doc="The roughness of the clear-coat reflections. The lower the value, the sharper the reflection." />
|
||||
<input name="coat_anisotropy" type="float" value="0.0" uimin="0.0" uimax="1.0" uiname="Coat Anisotropy" uifolder="Coat" uiadvanced="true"
|
||||
doc="The amount of directional bias, or anisotropy, of the clear-coat layer." />
|
||||
<input name="coat_rotation" type="float" value="0.0" uimin="0.0" uimax="1.0" uiname="Coat Rotation" uifolder="Coat" uiadvanced="true"
|
||||
doc="The rotation of the anisotropic effect of the clear-coat layer." />
|
||||
<input name="coat_IOR" type="float" value="1.5" uimin="0.0" uisoftmin="1.0" uisoftmax="3.0" uiname="Coat Index of Refraction" uifolder="Coat"
|
||||
doc="The index of refraction of the clear-coat layer." />
|
||||
<input name="coat_normal" type="vector3" defaultgeomprop="Nworld" uiname="Coat normal" uifolder="Coat"
|
||||
doc="Input normal for clear-coat layer" />
|
||||
<input name="coat_affect_color" type="float" value="0" uimin="0" uimax="1" uiname="Coat Affect Color" uifolder="Coat" uiadvanced="true"
|
||||
doc="Controls the saturation of diffuse reflection and subsurface scattering below the clear-coat." />
|
||||
<input name="coat_affect_roughness" type="float" value="0" uimin="0" uimax="1" uiname="Coat Affect Roughness" uifolder="Coat" uiadvanced="true"
|
||||
doc="Controls the roughness of the specular reflection in the layers below the clear-coat." />
|
||||
<input name="thin_film_thickness" type="float" value="0" uimin="0.0" uisoftmax="2000.0" uiname="Thin Film Thickness" uifolder="Thin Film" uiadvanced="true"
|
||||
doc="The thickness of the thin film layer on a surface. Use for materials such as multitone car paint or soap bubbles." />
|
||||
<input name="thin_film_IOR" type="float" value="1.5" uimin="0.0" uisoftmin="1.0" uisoftmax="3.0" uiname="Thin Film Index of Refraction" uifolder="Thin Film" uiadvanced="true"
|
||||
doc="The index of refraction of the medium surrounding the material." />
|
||||
<input name="emission" type="float" value="0" uimin="0.0" uisoftmax="1.0" uiname="Emission" uifolder="Emission"
|
||||
doc="The amount of emitted incandescent light." />
|
||||
<input name="emission_color" type="color3" value="1, 1, 1" uimin="0,0,0" uimax="1,1,1" uiname="Emission Color" uifolder="Emission"
|
||||
doc="The color of the emitted light." />
|
||||
<input name="opacity" type="color3" value="1, 1, 1" uimin="0,0,0" uimax="1,1,1" uiname="Opacity" uifolder="Geometry"
|
||||
doc="The opacity of the entire material." />
|
||||
<input name="thin_walled" type="boolean" value="false" uiname="Thin Walled" uifolder="Geometry" uiadvanced="true"
|
||||
doc="If true the surface is double-sided and represents an infinitely thin shell. Suitable for thin objects such as tree leaves or paper." />
|
||||
<input name="normal" type="vector3" defaultgeomprop="Nworld" uiname="Normal" uifolder="Geometry"
|
||||
doc="Input geometric normal" />
|
||||
<input name="tangent" type="vector3" defaultgeomprop="Tworld" uiname="Tangent Input" uifolder="Geometry"
|
||||
doc="Input geometric tangent" />
|
||||
<output name="out" type="surfaceshader" />
|
||||
</nodedef>
|
||||
|
||||
<!--
|
||||
Association between implementation and definition.
|
||||
Note that version 1.0.1 only changes default values and thus reuses the same 1.0.0 nodegraph implementation.
|
||||
-->
|
||||
<implementation name="IMPL_standard_surface_surfaceshader_101" nodedef="ND_standard_surface_surfaceshader" nodegraph="NG_standard_surface_surfaceshader_100" />
|
||||
<implementation name="IMPL_standard_surface_surfaceshader_100" nodedef="ND_standard_surface_surfaceshader_100" nodegraph="NG_standard_surface_surfaceshader_100" />
|
||||
|
||||
<!--
|
||||
Autodesk Standard Surface nodegraph implementation.
|
||||
-->
|
||||
<nodegraph name="NG_standard_surface_surfaceshader_100">
|
||||
|
||||
<!-- Roughness influence by coat-->
|
||||
<!-- Calculate main specular roughness -->
|
||||
<multiply name="coat_affect_roughness_multiply1" type="float">
|
||||
<input name="in1" type="float" interfacename="coat_affect_roughness" />
|
||||
<input name="in2" type="float" interfacename="coat" />
|
||||
</multiply>
|
||||
<multiply name="coat_affect_roughness_multiply2" type="float">
|
||||
<input name="in1" type="float" nodename="coat_affect_roughness_multiply1" />
|
||||
<input name="in2" type="float" interfacename="coat_roughness" />
|
||||
</multiply>
|
||||
<mix name="coat_affected_roughness" type="float">
|
||||
<input name="fg" type="float" value="1.0" />
|
||||
<input name="bg" type="float" interfacename="specular_roughness" />
|
||||
<input name="mix" type="float" nodename="coat_affect_roughness_multiply2" />
|
||||
</mix>
|
||||
<roughness_anisotropy name="main_roughness" type="vector2">
|
||||
<input name="roughness" type="float" nodename="coat_affected_roughness" />
|
||||
<input name="anisotropy" type="float" interfacename="specular_anisotropy" />
|
||||
</roughness_anisotropy>
|
||||
<!-- Calculate transmission roughness -->
|
||||
<add name="transmission_roughness_add" type="float">
|
||||
<input name="in1" type="float" interfacename="specular_roughness" />
|
||||
<input name="in2" type="float" interfacename="transmission_extra_roughness" />
|
||||
</add>
|
||||
<clamp name="transmission_roughness_clamped" type="float">
|
||||
<input name="in" type="float" nodename="transmission_roughness_add" />
|
||||
</clamp>
|
||||
<mix name="coat_affected_transmission_roughness" type="float">
|
||||
<input name="fg" type="float" value="1.0" />
|
||||
<input name="bg" type="float" nodename="transmission_roughness_clamped" />
|
||||
<input name="mix" type="float" nodename="coat_affect_roughness_multiply2" />
|
||||
</mix>
|
||||
<roughness_anisotropy name="transmission_roughness" type="vector2">
|
||||
<input name="roughness" type="float" nodename="coat_affected_transmission_roughness" />
|
||||
<input name="anisotropy" type="float" interfacename="specular_anisotropy" />
|
||||
</roughness_anisotropy>
|
||||
|
||||
<!-- Tangent rotation -->
|
||||
<multiply name="tangent_rotate_degree" type="float">
|
||||
<input name="in1" type="float" interfacename="specular_rotation" />
|
||||
<input name="in2" type="float" value="360" />
|
||||
</multiply>
|
||||
<rotate3d name="tangent_rotate" type="vector3">
|
||||
<input name="in" type="vector3" interfacename="tangent" />
|
||||
<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>
|
||||
<ifgreater name="main_tangent" type="vector3">
|
||||
<input name="value1" type="float" interfacename="specular_anisotropy" />
|
||||
<input name="value2" type="float" value="0.0" />
|
||||
<input name="in1" type="vector3" nodename="tangent_rotate_normalize" />
|
||||
<input name="in2" type="vector3" interfacename="tangent" />
|
||||
</ifgreater>
|
||||
|
||||
<!-- Coat tangent rotation -->
|
||||
<multiply name="coat_tangent_rotate_degree" type="float">
|
||||
<input name="in1" type="float" interfacename="coat_rotation" />
|
||||
<input name="in2" type="float" value="360" />
|
||||
</multiply>
|
||||
<rotate3d name="coat_tangent_rotate" type="vector3">
|
||||
<input name="in" type="vector3" interfacename="tangent" />
|
||||
<input name="amount" type="float" nodename="coat_tangent_rotate_degree" />
|
||||
<input name="axis" type="vector3" interfacename="coat_normal" />
|
||||
</rotate3d>
|
||||
<normalize name="coat_tangent_rotate_normalize" type="vector3">
|
||||
<input name="in" type="vector3" nodename="coat_tangent_rotate" />
|
||||
</normalize>
|
||||
<ifgreater name="coat_tangent" type="vector3">
|
||||
<input name="value1" type="float" interfacename="coat_anisotropy" />
|
||||
<input name="value2" type="float" value="0.0" />
|
||||
<input name="in1" type="vector3" nodename="coat_tangent_rotate_normalize" />
|
||||
<input name="in2" type="vector3" interfacename="tangent" />
|
||||
</ifgreater>
|
||||
|
||||
<!-- Colors influenced by coat ("coat gamma") -->
|
||||
<clamp name="coat_clamped" type="float">
|
||||
<input name="in" type="float" interfacename="coat" />
|
||||
</clamp>
|
||||
<multiply name="coat_gamma_multiply" type="float">
|
||||
<input name="in1" type="float" nodename="coat_clamped" />
|
||||
<input name="in2" type="float" interfacename="coat_affect_color" />
|
||||
</multiply>
|
||||
<add name="coat_gamma" type="float">
|
||||
<input name="in1" type="float" nodename="coat_gamma_multiply" />
|
||||
<input name="in2" type="float" value="1.0" />
|
||||
</add>
|
||||
<max name="base_color_nonnegative" type="color3">
|
||||
<input name="in1" type="color3" interfacename="base_color" />
|
||||
<input name="in2" type="float" value="0.0" />
|
||||
</max>
|
||||
<power name="coat_affected_diffuse_color" type="color3">
|
||||
<input name="in1" type="color3" nodename="base_color_nonnegative" />
|
||||
<input name="in2" type="float" nodename="coat_gamma" />
|
||||
</power>
|
||||
<max name="subsurface_color_nonnegative" type="color3">
|
||||
<input name="in1" type="color3" interfacename="subsurface_color" />
|
||||
<input name="in2" type="float" value="0.0" />
|
||||
</max>
|
||||
<power name="coat_affected_subsurface_color" type="color3">
|
||||
<input name="in1" type="color3" nodename="subsurface_color_nonnegative" />
|
||||
<input name="in2" type="float" nodename="coat_gamma" />
|
||||
</power>
|
||||
|
||||
<!-- Diffuse/Subsurface Layer -->
|
||||
<oren_nayar_diffuse_bsdf name="diffuse_bsdf" type="BSDF">
|
||||
<input name="weight" type="float" interfacename="base" />
|
||||
<input name="color" type="color3" nodename="coat_affected_diffuse_color" />
|
||||
<input name="roughness" type="float" interfacename="diffuse_roughness" />
|
||||
<input name="normal" type="vector3" interfacename="normal" />
|
||||
</oren_nayar_diffuse_bsdf>
|
||||
<translucent_bsdf name="translucent_bsdf" type="BSDF">
|
||||
<input name="weight" type="float" value="1.0" />
|
||||
<input name="color" type="color3" nodename="coat_affected_subsurface_color" />
|
||||
<input name="normal" type="vector3" interfacename="normal" />
|
||||
</translucent_bsdf>
|
||||
<convert name="subsurface_radius_vector" type="vector3">
|
||||
<input name="in" type="color3" interfacename="subsurface_radius" />
|
||||
</convert>
|
||||
<multiply name="subsurface_radius_scaled" type="vector3">
|
||||
<input name="in1" type="vector3" nodename="subsurface_radius_vector" />
|
||||
<input name="in2" type="float" interfacename="subsurface_scale" />
|
||||
</multiply>
|
||||
<subsurface_bsdf name="subsurface_bsdf" type="BSDF">
|
||||
<input name="weight" type="float" value="1.0" />
|
||||
<input name="color" type="color3" nodename="coat_affected_subsurface_color" />
|
||||
<input name="radius" type="vector3" nodename="subsurface_radius_scaled" />
|
||||
<input name="anisotropy" type="float" interfacename="subsurface_anisotropy" />
|
||||
<input name="normal" type="vector3" interfacename="normal" />
|
||||
</subsurface_bsdf>
|
||||
<convert name="subsurface_selector" type="float">
|
||||
<input name="in" type="boolean" interfacename="thin_walled" />
|
||||
</convert>
|
||||
<mix name="selected_subsurface_bsdf" type="BSDF">
|
||||
<input name="fg" type="BSDF" nodename="translucent_bsdf" />
|
||||
<input name="bg" type="BSDF" nodename="subsurface_bsdf" />
|
||||
<input name="mix" type="float" nodename="subsurface_selector" />
|
||||
</mix>
|
||||
<mix name="subsurface_mix" type="BSDF">
|
||||
<input name="fg" type="BSDF" nodename="selected_subsurface_bsdf" />
|
||||
<input name="bg" type="BSDF" nodename="diffuse_bsdf" />
|
||||
<input name="mix" type="float" interfacename="subsurface" />
|
||||
</mix>
|
||||
|
||||
<!-- Sheen Layer -->
|
||||
<sheen_bsdf name="sheen_bsdf" type="BSDF">
|
||||
<input name="weight" type="float" interfacename="sheen" />
|
||||
<input name="color" type="color3" interfacename="sheen_color" />
|
||||
<input name="roughness" type="float" interfacename="sheen_roughness" />
|
||||
<input name="normal" type="vector3" interfacename="normal" />
|
||||
</sheen_bsdf>
|
||||
<layer name="sheen_layer" type="BSDF">
|
||||
<input name="top" type="BSDF" nodename="sheen_bsdf" />
|
||||
<input name="base" type="BSDF" nodename="subsurface_mix" />
|
||||
</layer>
|
||||
|
||||
<!-- Transmission Layer -->
|
||||
<dielectric_bsdf name="transmission_bsdf" type="BSDF">
|
||||
<input name="weight" type="float" value="1.0" />
|
||||
<input name="tint" type="color3" interfacename="transmission_color" />
|
||||
<input name="ior" type="float" interfacename="specular_IOR" />
|
||||
<input name="roughness" type="vector2" nodename="transmission_roughness" />
|
||||
<input name="normal" type="vector3" interfacename="normal" />
|
||||
<input name="tangent" type="vector3" nodename="main_tangent" />
|
||||
<input name="distribution" type="string" value="ggx" />
|
||||
<input name="scatter_mode" type="string" value="T" />
|
||||
</dielectric_bsdf>
|
||||
<mix name="transmission_mix" type="BSDF">
|
||||
<input name="fg" type="BSDF" nodename="transmission_bsdf" />
|
||||
<input name="bg" type="BSDF" nodename="sheen_layer" />
|
||||
<input name="mix" type="float" interfacename="transmission" />
|
||||
</mix>
|
||||
|
||||
<!-- Specular Layer -->
|
||||
<dielectric_bsdf name="specular_bsdf" type="BSDF">
|
||||
<input name="weight" type="float" interfacename="specular" />
|
||||
<input name="tint" type="color3" interfacename="specular_color" />
|
||||
<input name="ior" type="float" interfacename="specular_IOR" />
|
||||
<input name="roughness" type="vector2" nodename="main_roughness" />
|
||||
<input name="normal" type="vector3" interfacename="normal" />
|
||||
<input name="tangent" type="vector3" nodename="main_tangent" />
|
||||
<input name="distribution" type="string" value="ggx" />
|
||||
<input name="scatter_mode" type="string" value="R" />
|
||||
</dielectric_bsdf>
|
||||
<layer name="specular_layer" type="BSDF">
|
||||
<input name="top" type="BSDF" nodename="specular_bsdf" />
|
||||
<input name="base" type="BSDF" nodename="transmission_mix" />
|
||||
</layer>
|
||||
|
||||
<!-- Metal Layer -->
|
||||
<multiply name="metal_reflectivity" type="color3">
|
||||
<input name="in1" type="color3" interfacename="base_color" />
|
||||
<input name="in2" type="float" interfacename="base" />
|
||||
</multiply>
|
||||
<multiply name="metal_edgecolor" type="color3">
|
||||
<input name="in1" type="color3" interfacename="specular_color" />
|
||||
<input name="in2" type="float" interfacename="specular" />
|
||||
</multiply>
|
||||
<artistic_ior name="artistic_ior" type="multioutput">
|
||||
<input name="reflectivity" type="color3" nodename="metal_reflectivity" />
|
||||
<input name="edge_color" type="color3" nodename="metal_edgecolor" />
|
||||
</artistic_ior>
|
||||
<conductor_bsdf name="metal_bsdf" type="BSDF">
|
||||
<input name="weight" type="float" value="1.0" />
|
||||
<input name="ior" type="color3" nodename="artistic_ior" output="ior" />
|
||||
<input name="extinction" type="color3" nodename="artistic_ior" output="extinction" />
|
||||
<input name="roughness" type="vector2" nodename="main_roughness" />
|
||||
<input name="normal" type="vector3" interfacename="normal" />
|
||||
<input name="tangent" type="vector3" nodename="main_tangent" />
|
||||
<input name="distribution" type="string" value="ggx" />
|
||||
</conductor_bsdf>
|
||||
<mix name="metalness_mix" type="BSDF">
|
||||
<input name="fg" type="BSDF" nodename="metal_bsdf" />
|
||||
<input name="bg" type="BSDF" nodename="specular_layer" />
|
||||
<input name="mix" type="float" interfacename="metalness" />
|
||||
</mix>
|
||||
|
||||
<!-- Thin-film Layer -->
|
||||
<thin_film_bsdf name="thin_film_bsdf" type="BSDF">
|
||||
<input name="thickness" type="float" interfacename="thin_film_thickness" />
|
||||
<input name="ior" type="float" interfacename="thin_film_IOR" />
|
||||
</thin_film_bsdf>
|
||||
<layer name="thin_film_layer" type="BSDF">
|
||||
<input name="top" type="BSDF" nodename="thin_film_bsdf" />
|
||||
<input name="base" type="BSDF" nodename="metalness_mix" />
|
||||
</layer>
|
||||
|
||||
<!-- Coat Layer -->
|
||||
<mix name="coat_attenuation" type="color3">
|
||||
<input name="fg" type="color3" interfacename="coat_color" />
|
||||
<input name="bg" type="color3" value="1.0, 1.0, 1.0" />
|
||||
<input name="mix" type="float" interfacename="coat" />
|
||||
</mix>
|
||||
<multiply name="thin_film_layer_attenuated" type="BSDF">
|
||||
<input name="in1" type="BSDF" nodename="thin_film_layer" />
|
||||
<input name="in2" type="color3" nodename="coat_attenuation" />
|
||||
</multiply>
|
||||
<roughness_anisotropy name="coat_roughness_vector" type="vector2">
|
||||
<input name="roughness" type="float" interfacename="coat_roughness" />
|
||||
<input name="anisotropy" type="float" interfacename="coat_anisotropy" />
|
||||
</roughness_anisotropy>
|
||||
<dielectric_bsdf name="coat_bsdf" type="BSDF">
|
||||
<input name="weight" type="float" interfacename="coat" />
|
||||
<input name="tint" type="color3" value="1.0, 1.0, 1.0" />
|
||||
<input name="ior" type="float" interfacename="coat_IOR" />
|
||||
<input name="roughness" type="vector2" nodename="coat_roughness_vector" />
|
||||
<input name="normal" type="vector3" interfacename="coat_normal" />
|
||||
<input name="tangent" type="vector3" nodename="coat_tangent" />
|
||||
<input name="distribution" type="string" value="ggx" />
|
||||
<input name="scatter_mode" type="string" value="R" />
|
||||
</dielectric_bsdf>
|
||||
<layer name="coat_layer" type="BSDF">
|
||||
<input name="top" type="BSDF" nodename="coat_bsdf" />
|
||||
<input name="base" type="BSDF" nodename="thin_film_layer_attenuated" />
|
||||
</layer>
|
||||
|
||||
<!-- Emission Layer -->
|
||||
<subtract name="one_minus_coat_ior" type="float">
|
||||
<input name="in1" type="float" value="1.0" />
|
||||
<input name="in2" type="float" interfacename="coat_IOR" />
|
||||
</subtract>
|
||||
<add name="one_plus_coat_ior" type="float">
|
||||
<input name="in1" type="float" value="1.0" />
|
||||
<input name="in2" type="float" interfacename="coat_IOR" />
|
||||
</add>
|
||||
<divide name="coat_ior_to_F0_sqrt" type="float">
|
||||
<input name="in1" type="float" nodename="one_minus_coat_ior" />
|
||||
<input name="in2" type="float" nodename="one_plus_coat_ior" />
|
||||
</divide>
|
||||
<multiply name="coat_ior_to_F0" type="float">
|
||||
<input name="in1" type="float" nodename="coat_ior_to_F0_sqrt" />
|
||||
<input name="in2" type="float" nodename="coat_ior_to_F0_sqrt" />
|
||||
</multiply>
|
||||
<subtract name="one_minus_coat_ior_to_F0" type="float">
|
||||
<input name="in1" type="float" value="1.0" />
|
||||
<input name="in2" type="float" nodename="coat_ior_to_F0" />
|
||||
</subtract>
|
||||
<multiply name="emission_weight" type="color3">
|
||||
<input name="in1" type="color3" interfacename="emission_color" />
|
||||
<input name="in2" type="float" interfacename="emission" />
|
||||
</multiply>
|
||||
<uniform_edf name="emission_edf" type="EDF">
|
||||
<input name="color" type="color3" nodename="emission_weight" />
|
||||
</uniform_edf>
|
||||
<multiply name="coat_tinted_emission_edf" type="EDF">
|
||||
<input name="in1" type="EDF" nodename="emission_edf" />
|
||||
<input name="in2" type="color3" interfacename="coat_color" />
|
||||
</multiply>
|
||||
<generalized_schlick_edf name="coat_emission_edf" type="EDF">
|
||||
<input name="color0" type="color3" nodename="one_minus_coat_ior_to_F0" channels="rrr" />
|
||||
<input name="color90" type="color3" value="0.0, 0.0, 0.0" />
|
||||
<input name="exponent" type="float" value="5.0" />
|
||||
<input name="base" type="EDF" nodename="coat_tinted_emission_edf" />
|
||||
</generalized_schlick_edf>
|
||||
<mix name="blended_coat_emission_edf" type="EDF">
|
||||
<input name="fg" type="EDF" nodename="coat_emission_edf" />
|
||||
<input name="bg" type="EDF" nodename="emission_edf" />
|
||||
<input name="mix" type="float" interfacename="coat" />
|
||||
</mix>
|
||||
|
||||
<!-- Surface construction with opacity -->
|
||||
<!-- Node <surface> only supports monochromatic opacity so use the luminance of input opacity color -->
|
||||
<luminance name="opacity_luminance" type="color3">
|
||||
<input name="in" type="color3" interfacename="opacity" />
|
||||
</luminance>
|
||||
<surface name="shader_constructor" type="surfaceshader">
|
||||
<input name="bsdf" type="BSDF" nodename="coat_layer" />
|
||||
<input name="edf" type="EDF" nodename="blended_coat_emission_edf" />
|
||||
<input name="opacity" type="float" nodename="opacity_luminance" channels="r" />
|
||||
</surface>
|
||||
|
||||
<!-- Output -->
|
||||
<output name="out" type="surfaceshader" nodename="shader_constructor" />
|
||||
|
||||
</nodegraph>
|
||||
|
||||
</materialx>
|
||||
+134
@@ -0,0 +1,134 @@
|
||||
<?xml version="1.0"?>
|
||||
<materialx version="1.38">
|
||||
|
||||
<nodedef name="ND_standard_surface_to_gltf_pbr" node="standard_surface_to_gltf_pbr" nodegroup="translation">
|
||||
<input name="base" type="float" value="1" />
|
||||
<input name="base_color" type="color3" value="0.8, 0.8, 0.8" />
|
||||
<input name="metalness" type="float" value="0" />
|
||||
<input name="specular_roughness" type="float" value="0.2" />
|
||||
<input name="transmission" type="float" value="0" />
|
||||
<input name="transmission_color" type="color3" value="1, 1, 1" />
|
||||
<input name="transmission_depth" type="float" value="0" />
|
||||
<input name="sheen" type="float" value="0" />
|
||||
<input name="sheen_color" type="color3" value="1, 1, 1" />
|
||||
<input name="sheen_roughness" type="float" value="0.3" />
|
||||
<input name="coat" type="float" value="0" />
|
||||
<input name="coat_color" type="color3" value="0, 0, 0" />
|
||||
<input name="coat_roughness" type="float" value="0.1" />
|
||||
<input name="emission" type="float" value="0" />
|
||||
<input name="emission_color" type="color3" value="1, 1, 1" />
|
||||
|
||||
<output name="base_color_out" type="color3" />
|
||||
<output name="metallic_out" type="float" />
|
||||
<output name="roughness_out" type="float" />
|
||||
<output name="transmission_out" type="float" />
|
||||
<output name="thickness_out" type="float" />
|
||||
<output name="attenuation_color_out" type="color3" />
|
||||
<output name="sheen_color_out" type="color3" />
|
||||
<output name="sheen_roughness_out" type="float" />
|
||||
<output name="clearcoat_out" type="float" />
|
||||
<output name="clearcoat_roughness_out" type="float" />
|
||||
<output name="emissive_out" type="color3" />
|
||||
</nodedef>
|
||||
|
||||
<nodegraph name="NG_standard_surface_to_gltf_pbr" nodedef="ND_standard_surface_to_gltf_pbr">
|
||||
|
||||
<!-- Coat attenuation -->
|
||||
<dotproduct name="has_coat_color" type="float">
|
||||
<input name="in1" type="vector3" interfacename="coat_color" channels="rgb" />
|
||||
<input name="in2" type="vector3" value="1,1,1" />
|
||||
</dotproduct>
|
||||
<multiply name="scaledBaseColor" type="color3">
|
||||
<input name="in1" type="color3" interfacename="base_color" />
|
||||
<input name="in2" type="float" interfacename="base" />
|
||||
</multiply>
|
||||
<mix name="coatAttenuation" type="color3">
|
||||
<input name="fg" type="color3" interfacename="coat_color" />
|
||||
<input name="bg" type="color3" value="1.0, 1.0, 1.0" />
|
||||
<input name="mix" type="float" interfacename="coat" />
|
||||
</mix>
|
||||
<multiply name="mixedBaseColor" type="color3">
|
||||
<input name="in1" type="color3" nodename="scaledBaseColor" />
|
||||
<input name="in2" type="color3" nodename="coatAttenuation" />
|
||||
</multiply>
|
||||
<divide name="constantOneThird" type="float">
|
||||
<input name="in1" type="float" value="1" />
|
||||
<input name="in2" type="float" value="3" />
|
||||
</divide>
|
||||
<multiply name="coatColor" type="color3">
|
||||
<input name="in1" type="color3" interfacename="coat_color" />
|
||||
<input name="in2" type="float" interfacename="coat" />
|
||||
</multiply>
|
||||
<dotproduct name="weightedCoat" type="float">
|
||||
<input name="in1" type="vector3" nodename="coatColor" channels="rgb" />
|
||||
<input name="in2" type="vector3" nodename="constantOneThird" channels="xxx" />
|
||||
</dotproduct>
|
||||
|
||||
<!-- Metallic roughness -->
|
||||
<ifequal name="base_color" type="color3">
|
||||
<input name="value1" type="float" nodename="has_coat_color" />
|
||||
<input name="value2" type="float" value="0" />
|
||||
<input name="in1" type="color3" nodename="scaledBaseColor" />
|
||||
<input name="in2" type="color3" nodename="mixedBaseColor" />
|
||||
</ifequal>
|
||||
<dot name="metallic" type="float">
|
||||
<input name="in" type="float" interfacename="metalness" />
|
||||
</dot>
|
||||
<dot name="roughness" type="float">
|
||||
<input name="in" type="float" interfacename="specular_roughness" />
|
||||
</dot>
|
||||
|
||||
<!-- Transmission -->
|
||||
<dot name="transmission" type="float">
|
||||
<input name="in" type="float" interfacename="transmission" />
|
||||
</dot>
|
||||
<dot name="thickness" type="float">
|
||||
<input name="in" type="float" interfacename="transmission_depth" />
|
||||
</dot>
|
||||
<dot name="attenuation_color" type="color3">
|
||||
<input name="in" type="color3" interfacename="transmission_color" />
|
||||
</dot>
|
||||
|
||||
<!-- Sheen -->
|
||||
<multiply name="sheen_color" type="color3">
|
||||
<input name="in1" type="color3" interfacename="sheen_color" />
|
||||
<input name="in2" type="float" interfacename="sheen" />
|
||||
</multiply>
|
||||
<ifgreater name="sheen_roughness" type="float">
|
||||
<input name="value1" type="float" interfacename="sheen" />
|
||||
<input name="value2" type="float" value="0" />
|
||||
<input name="in1" type="float" interfacename="sheen_roughness" />
|
||||
<input name="in2" type="float" value="0" />
|
||||
</ifgreater>
|
||||
|
||||
<!-- Clearcoat -->
|
||||
<ifequal name="clearcoat" type="float">
|
||||
<input name="value1" type="float" nodename="has_coat_color" />
|
||||
<input name="value2" type="float" value="0" />
|
||||
<input name="in1" type="float" interfacename="coat" />
|
||||
<input name="in2" type="float" nodename="weightedCoat" />
|
||||
</ifequal>
|
||||
<dot name="clearcoat_roughness" type="float">
|
||||
<input name="in" type="float" interfacename="coat_roughness" />
|
||||
</dot>
|
||||
|
||||
<!-- Emission -->
|
||||
<multiply name="emissive" type="color3">
|
||||
<input name="in1" type="color3" interfacename="emission_color" />
|
||||
<input name="in2" type="float" interfacename="emission" />
|
||||
</multiply>
|
||||
|
||||
<output name="base_color_out" type="color3" nodename="base_color" />
|
||||
<output name="metallic_out" type="float" nodename="metallic" />
|
||||
<output name="roughness_out" type="float" nodename="roughness" />
|
||||
<output name="transmission_out" type="float" nodename="transmission" />
|
||||
<output name="thickness_out" type="float" nodename="thickness" />
|
||||
<output name="attenuation_color_out" type="color3" nodename="attenuation_color" />
|
||||
<output name="sheen_color_out" type="color3" nodename="sheen_color" />
|
||||
<output name="sheen_roughness_out" type="float" nodename="sheen_roughness" />
|
||||
<output name="clearcoat_out" type="float" nodename="clearcoat" />
|
||||
<output name="clearcoat_roughness_out" type="float" nodename="clearcoat_roughness" />
|
||||
<output name="emissive_out" type="color3" nodename="emissive" />
|
||||
|
||||
</nodegraph>
|
||||
</materialx>
|
||||
+108
@@ -0,0 +1,108 @@
|
||||
<?xml version="1.0"?>
|
||||
<materialx version="1.38">
|
||||
|
||||
<nodedef name="ND_standard_surface_to_UsdPreviewSurface" node="standard_surface_to_UsdPreviewSurface" nodegroup="translation">
|
||||
<input name="metalness" type="float" value="0" />
|
||||
<input name="base" type="float" value="1" />
|
||||
<input name="base_color" type="color3" value="0.8, 0.8, 0.8" />
|
||||
<input name="specular" type="float" value="1" />
|
||||
<input name="specular_color" type="color3" value="1, 1, 1" />
|
||||
<input name="specular_IOR" type="float" value="1.5" />
|
||||
<input name="specular_roughness" type="float" value="0.2" />
|
||||
<input name="coat" type="float" value="0" />
|
||||
<input name="coat_color" type="color3" value="1, 1, 1" />
|
||||
<input name="coat_roughness" type="float" value="0.1" />
|
||||
<input name="emission" type="float" value="0" />
|
||||
<input name="emission_color" type="color3" value="1, 1, 1" />
|
||||
<input name="opacity" type="color3" value="1, 1, 1" />
|
||||
<input name="normal" type="vector3" value="0.5, 0.5, 1.0" />
|
||||
|
||||
<output name="diffuseColor_out" type="color3" />
|
||||
<output name="emissiveColor_out" type="color3" />
|
||||
<output name="metallic_out" type="float" />
|
||||
<output name="roughness_out" type="float" />
|
||||
<output name="clearcoat_out" type="float" />
|
||||
<output name="clearcoatRoughness_out" type="float" />
|
||||
<output name="opacity_out" type="float" />
|
||||
<output name="ior_out" type="float" />
|
||||
<output name="normal_out" type="vector3" />
|
||||
</nodedef>
|
||||
|
||||
<nodegraph name="NG_standard_surface_to_UsdPreviewSurface" nodedef="ND_standard_surface_to_UsdPreviewSurface">
|
||||
|
||||
<!-- Constants -->
|
||||
<divide name="constantOneThird" type="float">
|
||||
<input name="in1" type="float" value="1" />
|
||||
<input name="in2" type="float" value="3" />
|
||||
</divide>
|
||||
|
||||
<!-- Diffuse/Specular -->
|
||||
<dot name="metallic" type="float">
|
||||
<input name="in" type="float" interfacename="metalness" />
|
||||
</dot>
|
||||
<multiply name="scaledBaseColor" type="color3">
|
||||
<input name="in1" type="color3" interfacename="base_color" />
|
||||
<input name="in2" type="float" interfacename="base" />
|
||||
</multiply>
|
||||
<mix name="coatAttenuation" type="color3">
|
||||
<input name="fg" type="color3" interfacename="coat_color" />
|
||||
<input name="bg" type="color3" value="1.0, 1.0, 1.0" />
|
||||
<input name="mix" type="float" interfacename="coat" />
|
||||
</mix>
|
||||
<multiply name="diffuseColor" type="color3">
|
||||
<input name="in1" type="color3" nodename="scaledBaseColor" />
|
||||
<input name="in2" type="color3" nodename="coatAttenuation" />
|
||||
</multiply>
|
||||
<dot name="roughness" type="float">
|
||||
<input name="in" type="float" interfacename="specular_roughness" />
|
||||
</dot>
|
||||
<dot name="ior" type="float">
|
||||
<input name="in" type="float" interfacename="specular_IOR" />
|
||||
</dot>
|
||||
|
||||
<!-- Clearcoat -->
|
||||
<multiply name="coatColor" type="color3">
|
||||
<input name="in1" type="color3" interfacename="coat_color" />
|
||||
<input name="in2" type="float" interfacename="coat" />
|
||||
</multiply>
|
||||
<dotproduct name="clearcoat" type="float">
|
||||
<input name="in1" type="vector3" nodename="coatColor" channels="rgb" />
|
||||
<input name="in2" type="vector3" nodename="constantOneThird" channels="xxx" />
|
||||
</dotproduct>
|
||||
<dot name="clearcoatRoughness" type="float">
|
||||
<input name="in" type="float" interfacename="coat_roughness" />
|
||||
</dot>
|
||||
|
||||
<!-- Emissive -->
|
||||
<multiply name="emissiveColor" type="color3">
|
||||
<input name="in1" type="color3" interfacename="emission_color" />
|
||||
<input name="in2" type="float" interfacename="emission" />
|
||||
</multiply>
|
||||
|
||||
<!-- Opacity -->
|
||||
<dotproduct name="opacity" type="float">
|
||||
<input name="in1" type="vector3" interfacename="opacity" channels="rgb" />
|
||||
<input name="in2" type="vector3" nodename="constantOneThird" channels="xxx" />
|
||||
</dotproduct>
|
||||
|
||||
<!-- Normal Map -->
|
||||
<subtract name="biasNormal" type="vector3">
|
||||
<input name="in1" type="vector3" interfacename="normal" />
|
||||
<input name="in2" type="float" value="0.5" />
|
||||
</subtract>
|
||||
<multiply name="normal" type="vector3">
|
||||
<input name="in1" type="vector3" nodename="biasNormal" />
|
||||
<input name="in2" type="float" value="2" />
|
||||
</multiply>
|
||||
|
||||
<output name="diffuseColor_out" type="color3" nodename="diffuseColor" />
|
||||
<output name="emissiveColor_out" type="color3" nodename="emissiveColor" />
|
||||
<output name="metallic_out" type="float" nodename="metallic" />
|
||||
<output name="roughness_out" type="float" nodename="roughness" />
|
||||
<output name="clearcoat_out" type="float" nodename="clearcoat" />
|
||||
<output name="clearcoatRoughness_out" type="float" nodename="clearcoatRoughness" />
|
||||
<output name="opacity_out" type="float" nodename="opacity" />
|
||||
<output name="ior_out" type="float" nodename="ior" />
|
||||
<output name="normal_out" type="vector3" nodename="normal" />
|
||||
</nodegraph>
|
||||
</materialx>
|
||||
Vendored
+396
@@ -0,0 +1,396 @@
|
||||
<?xml version="1.0"?>
|
||||
<materialx version="1.38">
|
||||
|
||||
<!-- ======================================================================== -->
|
||||
<!-- USD Preview Surface node definitions -->
|
||||
<!-- ======================================================================== -->
|
||||
|
||||
<!-- Node: UsdPreviewSurface -->
|
||||
<nodedef name="ND_UsdPreviewSurface_surfaceshader" node="UsdPreviewSurface" nodegroup="pbr" doc="USD preview surface shader" version="2.3" isdefaultversion="true">
|
||||
<input name="diffuseColor" type="color3" value="0.18, 0.18, 0.18" uimin="0,0,0" uimax="1,1,1" />
|
||||
<input name="emissiveColor" type="color3" value="0, 0, 0" uimin="0,0,0" uisoftmax="1,1,1" />
|
||||
<input name="useSpecularWorkflow" type="integer" value="0" uimin="0" uimax="1" uistep="1" />
|
||||
<input name="specularColor" type="color3" value="0, 0, 0" uimin="0,0,0" uimax="1,1,1" />
|
||||
<input name="metallic" type="float" value="0" uimin="0.0" uimax="1.0" />
|
||||
<input name="roughness" type="float" value="0.5" uimin="0.0" uimax="1.0" />
|
||||
<input name="clearcoat" type="float" value="0" uimin="0.0" uimax="1.0" />
|
||||
<input name="clearcoatRoughness" type="float" value="0.01" uimin="0.0" uimax="1.0" />
|
||||
<input name="opacity" type="float" value="1" uimin="0.0" uimax="1.0" />
|
||||
<input name="opacityThreshold" type="float" value="0" uimin="0.0" uimax="1.0" />
|
||||
<input name="ior" type="float" value="1.5" uimin="0.0" uisoftmin="1.0" uisoftmax="3.0" />
|
||||
<input name="normal" type="vector3" value="0, 0, 1" uimin="-1.0,-1.0,-1.0" uimax="1.0,1.0,1.0" uistep="0.01" />
|
||||
<input name="displacement" type="float" value="0" />
|
||||
<input name="occlusion" type="float" value="1" uimin="0.0" uimax="1.0" />
|
||||
<output name="out" type="surfaceshader" />
|
||||
</nodedef>
|
||||
|
||||
<!-- Node: UsdUVTexture -->
|
||||
<nodedef name="ND_UsdUVTexture" node="UsdUVTexture" nodegroup="texture2d" version="2.2" inherit="ND_UsdUVTexture_23">
|
||||
<output name="r" type="float" />
|
||||
<output name="g" type="float" />
|
||||
<output name="b" type="float" />
|
||||
<output name="a" type="float" />
|
||||
<output name="rgb" type="color3" />
|
||||
<output name="rgba" type="color4" />
|
||||
</nodedef>
|
||||
|
||||
<nodedef name="ND_UsdUVTexture_23" node="UsdUVTexture" nodegroup="texture2d" version="2.3" isdefaultversion="true">
|
||||
<input name="file" type="filename" value="" uniform="true" />
|
||||
<input name="st" type="vector2" defaultgeomprop="UV0" />
|
||||
<input name="wrapS" type="string" value="periodic" enum="black,clamp,periodic,mirror" uniform="true" />
|
||||
<input name="wrapT" type="string" value="periodic" enum="black,clamp,periodic,mirror" uniform="true" />
|
||||
<input name="fallback" type="color4" value="0, 0, 0, 1" />
|
||||
<input name="scale" type="color4" value="1, 1, 1, 1" uniform="true" />
|
||||
<input name="bias" type="color4" value="0, 0, 0, 0" uniform="true" />
|
||||
<output name="r" type="float" />
|
||||
<output name="g" type="float" />
|
||||
<output name="b" type="float" />
|
||||
<output name="a" type="float" />
|
||||
<output name="rgb" type="color3" />
|
||||
</nodedef>
|
||||
|
||||
<!-- Node: UsdPrimvarReader -->
|
||||
<nodedef name="ND_UsdPrimvarReader_integer" nodegroup="geometric" node="UsdPrimvarReader">
|
||||
<input name="varname" type="string" value="" uniform="true" />
|
||||
<input name="fallback" type="integer" value="0" />
|
||||
<output name="out" type="integer" />
|
||||
</nodedef>
|
||||
<nodedef name="ND_UsdPrimvarReader_boolean" nodegroup="geometric" node="UsdPrimvarReader">
|
||||
<input name="varname" type="string" value="" uniform="true" />
|
||||
<input name="fallback" type="boolean" value="false" />
|
||||
<output name="out" type="boolean" />
|
||||
</nodedef>
|
||||
<nodedef name="ND_UsdPrimvarReader_string" nodegroup="geometric" node="UsdPrimvarReader">
|
||||
<input name="varname" type="string" value="" uniform="true" />
|
||||
<input name="fallback" type="string" value="" />
|
||||
<output name="out" type="string" />
|
||||
</nodedef>
|
||||
<nodedef name="ND_UsdPrimvarReader_float" nodegroup="geometric" node="UsdPrimvarReader">
|
||||
<input name="varname" type="string" value="" uniform="true" />
|
||||
<input name="fallback" type="float" value="0" />
|
||||
<output name="out" type="float" />
|
||||
</nodedef>
|
||||
<nodedef name="ND_UsdPrimvarReader_vector2" nodegroup="geometric" node="UsdPrimvarReader">
|
||||
<input name="varname" type="string" value="" uniform="true" />
|
||||
<input name="fallback" type="vector2" value="0, 0" />
|
||||
<output name="out" type="vector2" />
|
||||
</nodedef>
|
||||
<nodedef name="ND_UsdPrimvarReader_vector3" nodegroup="geometric" node="UsdPrimvarReader">
|
||||
<input name="varname" type="string" value="" uniform="true" />
|
||||
<input name="fallback" type="vector3" value="0, 0, 0" />
|
||||
<output name="out" type="vector3" />
|
||||
</nodedef>
|
||||
<nodedef name="ND_UsdPrimvarReader_vector4" nodegroup="geometric" node="UsdPrimvarReader">
|
||||
<input name="varname" type="string" value="" uniform="true" />
|
||||
<input name="fallback" type="vector4" value="0, 0, 0, 0" />
|
||||
<output name="out" type="vector4" />
|
||||
</nodedef>
|
||||
<!-- TODO: Getting primvar of matrix type is not supported in MaterialX standard library.
|
||||
<nodedef name="ND_UsdPrimvarReader_matrix44" node="UsdPrimvarReader">
|
||||
<input name="varname" type="string" />
|
||||
<input name="fallback" type="matrix44" value="1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1" />
|
||||
<output name="out" type="matrix44" />
|
||||
</nodedef>
|
||||
-->
|
||||
|
||||
<!-- Node: UsdTransform2d -->
|
||||
<nodedef name="ND_UsdTransform2d" nodegroup="math" node="UsdTransform2d">
|
||||
<input name="in" type="vector2" value="0, 0" />
|
||||
<input name="rotation" type="float" value="0" />
|
||||
<input name="scale" type="vector2" value="1, 1" />
|
||||
<input name="translation" type="vector2" value="0, 0" />
|
||||
<output name="out" type="vector2" />
|
||||
</nodedef>
|
||||
|
||||
<!-- ======================================================================== -->
|
||||
<!-- USD Preview Surface nodegraph implementations -->
|
||||
<!-- ======================================================================== -->
|
||||
|
||||
<!-- Node: UsdPreviewSurface -->
|
||||
<nodegraph name="IMP_UsdPreviewSurface_surfaceshader" nodedef="ND_UsdPreviewSurface_surfaceshader">
|
||||
|
||||
<convert name="use_specular_workflow_float" type="float">
|
||||
<input name="in" type="integer" interfacename="useSpecularWorkflow" />
|
||||
</convert>
|
||||
|
||||
<!-- Compute the surface normal -->
|
||||
<multiply name="scale_normal" type="vector3">
|
||||
<input name="in1" type="vector3" interfacename="normal" />
|
||||
<input name="in2" type="float" value="0.5" />
|
||||
</multiply>
|
||||
<add name="bias_normal" type="vector3">
|
||||
<input name="in1" type="vector3" nodename="scale_normal" />
|
||||
<input name="in2" type="float" value="0.5" />
|
||||
</add>
|
||||
<normalmap name="surface_normal" type="vector3">
|
||||
<input name="in" type="vector3" nodename="bias_normal" />
|
||||
</normalmap>
|
||||
|
||||
<!-- Diffuse Layer -->
|
||||
<subtract name="inverse_metalness" type="float">
|
||||
<input name="in1" type="float" value="1" />
|
||||
<input name="in2" type="float" interfacename="metallic" />
|
||||
</subtract>
|
||||
<mix name="diffuse_bsdf_weight" type="float">
|
||||
<input name="fg" type="float" value="1.0" />
|
||||
<input name="bg" type="float" nodename="inverse_metalness" />
|
||||
<input name="mix" type="float" nodename="use_specular_workflow_float" />
|
||||
</mix>
|
||||
<oren_nayar_diffuse_bsdf name="diffuse_bsdf" type="BSDF">
|
||||
<input name="weight" type="float" nodename="diffuse_bsdf_weight" />
|
||||
<input name="color" type="color3" interfacename="diffuseColor" />
|
||||
<input name="roughness" type="float" value="0" />
|
||||
<input name="normal" type="vector3" nodename="surface_normal" />
|
||||
</oren_nayar_diffuse_bsdf>
|
||||
|
||||
<!-- Transmission Layer -->
|
||||
<dielectric_bsdf name="transmission_bsdf" type="BSDF">
|
||||
<input name="weight" type="float" value="1" />
|
||||
<input name="tint" type="color3" value="1, 1, 1" />
|
||||
<input name="ior" type="float" interfacename="ior" />
|
||||
<input name="roughness" type="vector2" value="0.0, 0.0" />
|
||||
<input name="normal" type="vector3" nodename="surface_normal" />
|
||||
<input name="scatter_mode" type="string" value="T" />
|
||||
</dielectric_bsdf>
|
||||
<mix name="transmission_mix" type="BSDF">
|
||||
<input name="fg" type="BSDF" nodename="diffuse_bsdf" />
|
||||
<input name="bg" type="BSDF" nodename="transmission_bsdf" />
|
||||
<input name="mix" type="float" interfacename="opacity" />
|
||||
</mix>
|
||||
|
||||
<!-- Specular Workflow -->
|
||||
<roughness_anisotropy name="specular_roughness" type="vector2">
|
||||
<input name="roughness" type="float" interfacename="roughness" />
|
||||
<input name="anisotropy" type="float" value="0" />
|
||||
</roughness_anisotropy>
|
||||
<generalized_schlick_bsdf name="specular_bsdf1" type="BSDF">
|
||||
<input name="weight" type="float" value="1" />
|
||||
<input name="color0" type="color3" interfacename="specularColor" />
|
||||
<input name="color90" type="color3" value="1, 1, 1" />
|
||||
<input name="roughness" type="vector2" nodename="specular_roughness" />
|
||||
<input name="normal" type="vector3" nodename="surface_normal" />
|
||||
</generalized_schlick_bsdf>
|
||||
<layer name="specular_workflow_bsdf" type="BSDF">
|
||||
<input name="top" type="BSDF" nodename="specular_bsdf1" />
|
||||
<input name="base" type="BSDF" nodename="transmission_mix" />
|
||||
</layer>
|
||||
|
||||
<!-- Metalness Workflow -->
|
||||
<subtract name="one_minus_ior" type="float">
|
||||
<input name="in1" type="float" value="1" />
|
||||
<input name="in2" type="float" interfacename="ior" />
|
||||
</subtract>
|
||||
<add name="one_plus_ior" type="float">
|
||||
<input name="in1" type="float" value="1" />
|
||||
<input name="in2" type="float" interfacename="ior" />
|
||||
</add>
|
||||
<divide name="R" type="float">
|
||||
<input name="in1" type="float" nodename="one_minus_ior" />
|
||||
<input name="in2" type="float" nodename="one_plus_ior" />
|
||||
</divide>
|
||||
<multiply name="R_sq" type="float">
|
||||
<input name="in1" type="float" nodename="R" />
|
||||
<input name="in2" type="float" nodename="R" />
|
||||
</multiply>
|
||||
<mix name="specular_color_metallic" type="color3">
|
||||
<input name="fg" type="color3" interfacename="diffuseColor" />
|
||||
<input name="bg" type="color3" value="1, 1, 1" />
|
||||
<input name="mix" type="float" interfacename="metallic" />
|
||||
</mix>
|
||||
<multiply name="specular_color_metallic_R_sq" type="color3">
|
||||
<input name="in1" type="color3" nodename="specular_color_metallic" />
|
||||
<input name="in2" type="float" nodename="R_sq" />
|
||||
</multiply>
|
||||
<mix name="F0" type="color3">
|
||||
<input name="fg" type="color3" nodename="specular_color_metallic" />
|
||||
<input name="bg" type="color3" nodename="specular_color_metallic_R_sq" />
|
||||
<input name="mix" type="float" interfacename="metallic" />
|
||||
</mix>
|
||||
<generalized_schlick_bsdf name="specular_bsdf2" type="BSDF">
|
||||
<input name="weight" type="float" value="1" />
|
||||
<input name="color0" type="color3" nodename="F0" />
|
||||
<input name="color90" type="color3" nodename="specular_color_metallic" />
|
||||
<input name="roughness" type="vector2" nodename="specular_roughness" />
|
||||
<input name="normal" type="vector3" nodename="surface_normal" />
|
||||
</generalized_schlick_bsdf>
|
||||
<layer name="metalness_specular_bsdf" type="BSDF">
|
||||
<input name="top" type="BSDF" nodename="specular_bsdf2" />
|
||||
<input name="base" type="BSDF" nodename="transmission_mix" />
|
||||
</layer>
|
||||
<artistic_ior name="artistic_ior" type="multioutput">
|
||||
<input name="reflectivity" type="color3" interfacename="diffuseColor" />
|
||||
<input name="edge_color" type="color3" interfacename="diffuseColor" />
|
||||
</artistic_ior>
|
||||
<conductor_bsdf name="metalness_metal_bsdf" type="BSDF">
|
||||
<input name="weight" type="float" value="1" />
|
||||
<input name="ior" type="color3" nodename="artistic_ior" output="ior" />
|
||||
<input name="extinction" type="color3" nodename="artistic_ior" output="extinction" />
|
||||
<input name="roughness" type="vector2" nodename="specular_roughness" />
|
||||
<input name="normal" type="vector3" nodename="surface_normal" />
|
||||
</conductor_bsdf>
|
||||
<mix name="metalness_workflow_bsdf" type="BSDF">
|
||||
<input name="fg" type="BSDF" nodename="metalness_metal_bsdf" />
|
||||
<input name="bg" type="BSDF" nodename="metalness_specular_bsdf" />
|
||||
<input name="mix" type="float" interfacename="metallic" />
|
||||
</mix>
|
||||
|
||||
<!-- Select Specular/Metalness workflow -->
|
||||
<mix name="workflow_selector_bsdf" type="BSDF">
|
||||
<input name="fg" type="BSDF" nodename="specular_workflow_bsdf" />
|
||||
<input name="bg" type="BSDF" nodename="metalness_workflow_bsdf" />
|
||||
<input name="mix" type="float" nodename="use_specular_workflow_float" />
|
||||
</mix>
|
||||
|
||||
<!-- Clearcoat Layer -->
|
||||
<roughness_anisotropy name="coat_roughness" type="vector2">
|
||||
<input name="roughness" type="float" interfacename="clearcoatRoughness" />
|
||||
<input name="anisotropy" type="float" value="0" />
|
||||
</roughness_anisotropy>
|
||||
<convert name="coat_F0" type="color3">
|
||||
<input name="in" type="float" nodename="R_sq" />
|
||||
</convert>
|
||||
<generalized_schlick_bsdf name="coat_dielectric_bsdf" type="BSDF">
|
||||
<input name="weight" type="float" interfacename="clearcoat" />
|
||||
<input name="color0" type="color3" nodename="coat_F0" />
|
||||
<input name="color90" type="color3" value="1, 1, 1" />
|
||||
<input name="roughness" type="vector2" nodename="coat_roughness" />
|
||||
<input name="normal" type="vector3" nodename="surface_normal" />
|
||||
</generalized_schlick_bsdf>
|
||||
<layer name="coat_bsdf" type="BSDF">
|
||||
<input name="top" type="BSDF" nodename="coat_dielectric_bsdf" />
|
||||
<input name="base" type="BSDF" nodename="workflow_selector_bsdf" />
|
||||
</layer>
|
||||
|
||||
<!-- Emission Layer -->
|
||||
<uniform_edf name="emission_edf" type="EDF">
|
||||
<input name="color" type="color3" interfacename="emissiveColor" />
|
||||
</uniform_edf>
|
||||
|
||||
<!-- Surface Shader Constructor -->
|
||||
<ifgreatereq name="cutout_opacity" type="float">
|
||||
<input name="value1" type="float" interfacename="opacity" />
|
||||
<input name="value2" type="float" interfacename="opacityThreshold" />
|
||||
<input name="in1" type="float" value="1" />
|
||||
<input name="in2" type="float" value="0" />
|
||||
</ifgreatereq>
|
||||
<surface name="surface_constructor" type="surfaceshader">
|
||||
<input name="bsdf" type="BSDF" nodename="coat_bsdf" />
|
||||
<input name="edf" type="EDF" nodename="emission_edf" />
|
||||
<input name="opacity" type="float" nodename="cutout_opacity" />
|
||||
</surface>
|
||||
|
||||
<!-- Output -->
|
||||
<output name="out" type="surfaceshader" nodename="surface_constructor" />
|
||||
</nodegraph>
|
||||
|
||||
<!-- Node: UsdUVTexture -->
|
||||
<nodegraph name="IMP_UsdUVTexture_22" nodedef="ND_UsdUVTexture">
|
||||
<image name="image_reader" type="color4">
|
||||
<input name="file" type="filename" interfacename="file" />
|
||||
<input name="default" type="color4" interfacename="fallback" />
|
||||
<input name="texcoord" type="vector2" interfacename="st" />
|
||||
<input name="uaddressmode" type="string" interfacename="wrapS" />
|
||||
<input name="vaddressmode" type="string" interfacename="wrapT" />
|
||||
</image>
|
||||
<multiply name="image_scale" type="color4">
|
||||
<input name="in1" type="color4" nodename="image_reader" />
|
||||
<input name="in2" type="color4" interfacename="scale" />
|
||||
</multiply>
|
||||
<add name="image_bias" type="color4">
|
||||
<input name="in1" type="color4" nodename="image_scale" />
|
||||
<input name="in2" type="color4" interfacename="bias" />
|
||||
</add>
|
||||
<output name="r" type="float" nodename="image_bias" channels="r" />
|
||||
<output name="g" type="float" nodename="image_bias" channels="g" />
|
||||
<output name="b" type="float" nodename="image_bias" channels="b" />
|
||||
<output name="a" type="float" nodename="image_bias" channels="a" />
|
||||
<output name="rgb" type="color3" nodename="image_bias" channels="rgb" />
|
||||
<output name="rgba" type="color4" nodename="image_bias" />
|
||||
</nodegraph>
|
||||
|
||||
<nodegraph name="IMP_UsdUVTexture_23" nodedef="ND_UsdUVTexture_23">
|
||||
<image name="image_reader" type="color4">
|
||||
<input name="file" type="filename" interfacename="file" />
|
||||
<input name="default" type="color4" interfacename="fallback" />
|
||||
<input name="texcoord" type="vector2" interfacename="st" />
|
||||
<input name="uaddressmode" type="string" interfacename="wrapS" />
|
||||
<input name="vaddressmode" type="string" interfacename="wrapT" />
|
||||
</image>
|
||||
<multiply name="image_scale" type="color4">
|
||||
<input name="in1" type="color4" nodename="image_reader" />
|
||||
<input name="in2" type="color4" interfacename="scale" />
|
||||
</multiply>
|
||||
<add name="image_bias" type="color4">
|
||||
<input name="in1" type="color4" nodename="image_scale" />
|
||||
<input name="in2" type="color4" interfacename="bias" />
|
||||
</add>
|
||||
<output name="r" type="float" nodename="image_bias" channels="r" />
|
||||
<output name="g" type="float" nodename="image_bias" channels="g" />
|
||||
<output name="b" type="float" nodename="image_bias" channels="b" />
|
||||
<output name="a" type="float" nodename="image_bias" channels="a" />
|
||||
<output name="rgb" type="color3" nodename="image_bias" channels="rgb" />
|
||||
</nodegraph>
|
||||
|
||||
<!-- Node: UsdPrimvarReader -->
|
||||
<nodegraph name="IMP_UsdPrimvarReader_integer" nodedef="ND_UsdPrimvarReader_integer">
|
||||
<geompropvalue name="primvar" type="integer">
|
||||
<input name="geomprop" type="string" interfacename="varname" />
|
||||
<input name="default" type="integer" interfacename="fallback" />
|
||||
</geompropvalue>
|
||||
<output name="out" type="integer" nodename="primvar" />
|
||||
</nodegraph>
|
||||
<nodegraph name="IMP_UsdPrimvarReader_boolean" nodedef="ND_UsdPrimvarReader_boolean">
|
||||
<geompropvalue name="primvar" type="boolean">
|
||||
<input name="geomprop" type="string" interfacename="varname" />
|
||||
<input name="default" type="boolean" interfacename="fallback" />
|
||||
</geompropvalue>
|
||||
<output name="out" type="boolean" nodename="primvar" />
|
||||
</nodegraph>
|
||||
<nodegraph name="IMP_UsdPrimvarReader_string" nodedef="ND_UsdPrimvarReader_string">
|
||||
<geompropvalue name="primvar" type="string">
|
||||
<input name="geomprop" type="string" interfacename="varname" />
|
||||
<input name="default" type="string" interfacename="fallback" />
|
||||
</geompropvalue>
|
||||
<output name="out" type="string" nodename="primvar" />
|
||||
</nodegraph>
|
||||
<nodegraph name="IMP_UsdPrimvarReader_float" nodedef="ND_UsdPrimvarReader_float">
|
||||
<geompropvalue name="primvar" type="float">
|
||||
<input name="geomprop" type="string" interfacename="varname" />
|
||||
<input name="default" type="float" interfacename="fallback" />
|
||||
</geompropvalue>
|
||||
<output name="out" type="float" nodename="primvar" />
|
||||
</nodegraph>
|
||||
<nodegraph name="IMP_UsdPrimvarReader_vector2" nodedef="ND_UsdPrimvarReader_vector2">
|
||||
<geompropvalue name="primvar" type="vector2">
|
||||
<input name="geomprop" type="string" interfacename="varname" />
|
||||
<input name="default" type="vector2" interfacename="fallback" />
|
||||
</geompropvalue>
|
||||
<output name="out" type="vector2" nodename="primvar" />
|
||||
</nodegraph>
|
||||
<nodegraph name="IMP_UsdPrimvarReader_vector3" nodedef="ND_UsdPrimvarReader_vector3">
|
||||
<geompropvalue name="primvar" type="vector3">
|
||||
<input name="geomprop" type="string" interfacename="varname" />
|
||||
<input name="default" type="vector3" interfacename="fallback" />
|
||||
</geompropvalue>
|
||||
<output name="out" type="vector3" nodename="primvar" />
|
||||
</nodegraph>
|
||||
<nodegraph name="IMP_UsdPrimvarReader_vector4" nodedef="ND_UsdPrimvarReader_vector4">
|
||||
<geompropvalue name="primvar" type="vector4">
|
||||
<input name="geomprop" type="string" interfacename="varname" />
|
||||
<input name="default" type="vector4" interfacename="fallback" />
|
||||
</geompropvalue>
|
||||
<output name="out" type="vector4" nodename="primvar" />
|
||||
</nodegraph>
|
||||
|
||||
<!-- Node: UsdTransform2d -->
|
||||
<nodegraph name="IMP_UsdTransform2d" nodedef="ND_UsdTransform2d">
|
||||
<place2d name="placement" type="vector2">
|
||||
<input name="texcoord" type="vector2" interfacename="in" />
|
||||
<input name="scale" type="vector2" interfacename="scale" />
|
||||
<input name="rotate" type="float" interfacename="rotation" />
|
||||
<input name="offset" type="vector2" interfacename="translation" />
|
||||
</place2d>
|
||||
<output name="out" type="vector2" nodename="placement" />
|
||||
</nodegraph>
|
||||
|
||||
</materialx>
|
||||
+110
@@ -0,0 +1,110 @@
|
||||
<?xml version="1.0"?>
|
||||
<materialx version="1.38">
|
||||
<!--
|
||||
Copyright Contributors to the MaterialX Project
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
Declarations of the default color transforms in MaterialX.
|
||||
-->
|
||||
|
||||
<nodedef name="ND_g18_rec709_to_lin_rec709_color3" node="g18_rec709_to_lin_rec709" nodegroup="colortransform">
|
||||
<input name="in" type="color3" value="0.0, 0.0, 0.0" />
|
||||
<output name="out" type="color3" />
|
||||
</nodedef>
|
||||
|
||||
<nodedef name="ND_g18_rec709_to_lin_rec709_color4" node="g18_rec709_to_lin_rec709" nodegroup="colortransform">
|
||||
<input name="in" type="color4" value="0.0, 0.0, 0.0, 1.0" />
|
||||
<output name="out" type="color4" />
|
||||
</nodedef>
|
||||
|
||||
<nodedef name="ND_g22_rec709_to_lin_rec709_color3" node="g22_rec709_to_lin_rec709" nodegroup="colortransform">
|
||||
<input name="in" type="color3" value="0.0, 0.0, 0.0" />
|
||||
<output name="out" type="color3" />
|
||||
</nodedef>
|
||||
|
||||
<nodedef name="ND_g22_rec709_to_lin_rec709_color4" node="g22_rec709_to_lin_rec709" nodegroup="colortransform">
|
||||
<input name="in" type="color4" value="0.0, 0.0, 0.0, 1.0" />
|
||||
<output name="out" type="color4" />
|
||||
</nodedef>
|
||||
|
||||
<nodedef name="ND_rec709_display_to_lin_rec709_color3" node="rec709_display_to_lin_rec709" nodegroup="colortransform">
|
||||
<input name="in" type="color3" value="0.0, 0.0, 0.0" />
|
||||
<output name="out" type="color3" />
|
||||
</nodedef>
|
||||
|
||||
<nodedef name="ND_rec709_display_to_lin_rec709_color4" node="rec709_display_to_lin_rec709" nodegroup="colortransform">
|
||||
<input name="in" type="color4" value="0.0, 0.0, 0.0, 1.0" />
|
||||
<output name="out" type="color4" />
|
||||
</nodedef>
|
||||
|
||||
<nodedef name="ND_acescg_to_lin_rec709_color3" node="acescg_to_lin_rec709" nodegroup="colortransform">
|
||||
<input name="in" type="color3" value="0.0, 0.0, 0.0" />
|
||||
<output name="out" type="color3" />
|
||||
</nodedef>
|
||||
|
||||
<nodedef name="ND_acescg_to_lin_rec709_color4" node="acescg_to_lin_rec709" nodegroup="colortransform">
|
||||
<input name="in" type="color4" value="0.0, 0.0, 0.0, 1.0" />
|
||||
<output name="out" type="color4" />
|
||||
</nodedef>
|
||||
|
||||
<nodedef name="ND_g22_ap1_to_lin_rec709_color3" node="g22_ap1_to_lin_rec709" nodegroup="colortransform">
|
||||
<input name="in" type="color3" value="0.0, 0.0, 0.0" />
|
||||
<output name="out" type="color3" />
|
||||
</nodedef>
|
||||
|
||||
<nodedef name="ND_g22_ap1_to_lin_rec709_color4" node="g22_ap1_to_lin_rec709" nodegroup="colortransform">
|
||||
<input name="in" type="color4" value="0.0, 0.0, 0.0, 1.0" />
|
||||
<output name="out" type="color4" />
|
||||
</nodedef>
|
||||
|
||||
<nodedef name="ND_srgb_texture_to_lin_rec709_color3" node="srgb_texture_to_lin_rec709" nodegroup="colortransform">
|
||||
<input name="in" type="color3" value="0.0, 0.0, 0.0" />
|
||||
<output name="out" type="color3" />
|
||||
</nodedef>
|
||||
|
||||
<nodedef name="ND_srgb_texture_to_lin_rec709_color4" node="srgb_texture_to_lin_rec709" nodegroup="colortransform">
|
||||
<input name="in" type="color4" value="0.0, 0.0, 0.0, 1.0" />
|
||||
<output name="out" type="color4" />
|
||||
</nodedef>
|
||||
|
||||
<nodedef name="ND_lin_adobergb_to_lin_rec709_color3" node="lin_adobergb_to_lin_rec709" nodegroup="colortransform">
|
||||
<input name="in" type="color3" value="0.0, 0.0, 0.0" />
|
||||
<output name="out" type="color3" />
|
||||
</nodedef>
|
||||
|
||||
<nodedef name="ND_lin_adobergb_to_lin_rec709_color4" node="lin_adobergb_to_lin_rec709" nodegroup="colortransform">
|
||||
<input name="in" type="color4" value="0.0, 0.0, 0.0, 1.0" />
|
||||
<output name="out" type="color4" />
|
||||
</nodedef>
|
||||
|
||||
<nodedef name="ND_adobergb_to_lin_rec709_color3" node="adobergb_to_lin_rec709" nodegroup="colortransform">
|
||||
<input name="in" type="color3" value="0.0, 0.0, 0.0" />
|
||||
<output name="out" type="color3" />
|
||||
</nodedef>
|
||||
|
||||
<nodedef name="ND_adobergb_to_lin_rec709_color4" node="adobergb_to_lin_rec709" nodegroup="colortransform">
|
||||
<input name="in" type="color4" value="0.0, 0.0, 0.0, 1.0" />
|
||||
<output name="out" type="color4" />
|
||||
</nodedef>
|
||||
|
||||
<nodedef name="ND_srgb_displayp3_to_lin_rec709_color3" node="srgb_displayp3_to_lin_rec709" nodegroup="colortransform">
|
||||
<input name="in" type="color3" value="0.0, 0.0, 0.0" />
|
||||
<output name="out" type="color3" />
|
||||
</nodedef>
|
||||
|
||||
<nodedef name="ND_srgb_displayp3_to_lin_rec709_color4" node="srgb_displayp3_to_lin_rec709" nodegroup="colortransform">
|
||||
<input name="in" type="color4" value="0.0, 0.0, 0.0, 1.0" />
|
||||
<output name="out" type="color4" />
|
||||
</nodedef>
|
||||
|
||||
<nodedef name="ND_lin_displayp3_to_lin_rec709_color3" node="lin_displayp3_to_lin_rec709" nodegroup="colortransform">
|
||||
<input name="in" type="color3" value="0.0, 0.0, 0.0" />
|
||||
<output name="out" type="color3" />
|
||||
</nodedef>
|
||||
|
||||
<nodedef name="ND_lin_displayp3_to_lin_rec709_color4" node="lin_displayp3_to_lin_rec709" nodegroup="colortransform">
|
||||
<input name="in" type="color4" value="0.0, 0.0, 0.0, 1.0" />
|
||||
<output name="out" type="color4" />
|
||||
</nodedef>
|
||||
|
||||
</materialx>
|
||||
+367
@@ -0,0 +1,367 @@
|
||||
<?xml version="1.0"?>
|
||||
<materialx version="1.38">
|
||||
<!--
|
||||
Copyright Contributors to the MaterialX Project
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
Nodegraph implementations for the default color transforms in MaterialX.
|
||||
-->
|
||||
|
||||
<nodegraph name="NG_g18_rec709_to_lin_rec709_color3" nodedef="ND_g18_rec709_to_lin_rec709_color3">
|
||||
<max name="max" type="color3">
|
||||
<input name="in1" type="color3" interfacename="in" />
|
||||
<input name="in2" type="float" value="0" />
|
||||
</max>
|
||||
<power name="gamma" type="color3">
|
||||
<input name="in1" type="color3" nodename="max" />
|
||||
<input name="in2" type="float" value="1.8" />
|
||||
</power>
|
||||
<output name="out" type="color3" nodename="gamma" />
|
||||
</nodegraph>
|
||||
|
||||
<nodegraph name="NG_g18_rec709_to_lin_rec709_color4" nodedef="ND_g18_rec709_to_lin_rec709_color4">
|
||||
<convert name="asColor3" type="color3">
|
||||
<input name="in" type="color4" interfacename="in" />
|
||||
</convert>
|
||||
<g18_rec709_to_lin_rec709 name="transform" type="color3">
|
||||
<input name="in" type="color3" nodename="asColor3" />
|
||||
</g18_rec709_to_lin_rec709>
|
||||
<combine4 name="asColor4" type="color4">
|
||||
<input name="in1" type="float" nodename="transform" channels="r" />
|
||||
<input name="in2" type="float" nodename="transform" channels="g" />
|
||||
<input name="in3" type="float" nodename="transform" channels="b" />
|
||||
<input name="in4" type="float" interfacename="in" channels="a" />
|
||||
</combine4>
|
||||
<output name="out" type="color4" nodename="asColor4" />
|
||||
</nodegraph>
|
||||
|
||||
<nodegraph name="NG_g22_rec709_to_lin_rec709_color3" nodedef="ND_g22_rec709_to_lin_rec709_color3">
|
||||
<max name="max" type="color3">
|
||||
<input name="in1" type="color3" interfacename="in" />
|
||||
<input name="in2" type="float" value="0" />
|
||||
</max>
|
||||
<power name="gamma" type="color3">
|
||||
<input name="in1" type="color3" nodename="max" />
|
||||
<input name="in2" type="float" value="2.2" />
|
||||
</power>
|
||||
<output name="out" type="color3" nodename="gamma" />
|
||||
</nodegraph>
|
||||
|
||||
<nodegraph name="NG_g22_rec709_to_lin_rec709_color4" nodedef="ND_g22_rec709_to_lin_rec709_color4">
|
||||
<convert name="asColor3" type="color3">
|
||||
<input name="in" type="color4" interfacename="in" />
|
||||
</convert>
|
||||
<g22_rec709_to_lin_rec709 name="transform" type="color3">
|
||||
<input name="in" type="color3" nodename="asColor3" />
|
||||
</g22_rec709_to_lin_rec709>
|
||||
<combine4 name="asColor4" type="color4">
|
||||
<input name="in1" type="float" nodename="transform" channels="r" />
|
||||
<input name="in2" type="float" nodename="transform" channels="g" />
|
||||
<input name="in3" type="float" nodename="transform" channels="b" />
|
||||
<input name="in4" type="float" interfacename="in" channels="a" />
|
||||
</combine4>
|
||||
<output name="out" type="color4" nodename="asColor4" />
|
||||
</nodegraph>
|
||||
|
||||
<nodegraph name="NG_rec709_display_to_lin_rec709_color3" nodedef="ND_rec709_display_to_lin_rec709_color3">
|
||||
<max name="max" type="color3">
|
||||
<input name="in1" type="color3" interfacename="in" />
|
||||
<input name="in2" type="float" value="0" />
|
||||
</max>
|
||||
<power name="gamma" type="color3">
|
||||
<input name="in1" type="color3" nodename="max" />
|
||||
<input name="in2" type="float" value="2.4" />
|
||||
</power>
|
||||
<output name="out" type="color3" nodename="gamma" />
|
||||
</nodegraph>
|
||||
|
||||
<nodegraph name="NG_rec709_display_to_lin_rec709_color4" nodedef="ND_rec709_display_to_lin_rec709_color4">
|
||||
<convert name="asColor3" type="color3">
|
||||
<input name="in" type="color4" interfacename="in" />
|
||||
</convert>
|
||||
<rec709_display_to_lin_rec709 name="transform" type="color3">
|
||||
<input name="in" type="color3" nodename="asColor3" />
|
||||
</rec709_display_to_lin_rec709>
|
||||
<combine4 name="asColor4" type="color4">
|
||||
<input name="in1" type="float" nodename="transform" channels="r" />
|
||||
<input name="in2" type="float" nodename="transform" channels="g" />
|
||||
<input name="in3" type="float" nodename="transform" channels="b" />
|
||||
<input name="in4" type="float" interfacename="in" channels="a" />
|
||||
</combine4>
|
||||
<output name="out" type="color4" nodename="asColor4" />
|
||||
</nodegraph>
|
||||
|
||||
<nodegraph name="NG_acescg_to_lin_rec709_color3" nodedef="ND_acescg_to_lin_rec709_color3">
|
||||
<constant name="mat" type="matrix33">
|
||||
<input name="value" type="matrix33" value="1.705050992658, -0.130256417507, -0.024003356805, -0.621792120657, 1.140804736575, -0.128968976065, -0.083258872001, -0.010548319068, 1.15297233287" />
|
||||
</constant>
|
||||
<convert name="asVec" type="vector3">
|
||||
<input name="in" type="color3" interfacename="in" />
|
||||
</convert>
|
||||
<transformmatrix name="transform" type="vector3">
|
||||
<input name="in" type="vector3" nodename="asVec" />
|
||||
<input name="mat" type="matrix33" nodename="mat" />
|
||||
</transformmatrix>
|
||||
<convert name="asColor" type="color3">
|
||||
<input name="in" type="vector3" nodename="transform" />
|
||||
</convert>
|
||||
<output name="out" type="color3" nodename="asColor" />
|
||||
</nodegraph>
|
||||
|
||||
<nodegraph name="NG_acescg_to_lin_rec709_color4" nodedef="ND_acescg_to_lin_rec709_color4">
|
||||
<convert name="asColor3" type="color3">
|
||||
<input name="in" type="color4" interfacename="in" />
|
||||
</convert>
|
||||
<acescg_to_lin_rec709 name="transform" type="color3">
|
||||
<input name="in" type="color3" nodename="asColor3" />
|
||||
</acescg_to_lin_rec709>
|
||||
<combine4 name="asColor4" type="color4">
|
||||
<input name="in1" type="float" nodename="transform" channels="r" />
|
||||
<input name="in2" type="float" nodename="transform" channels="g" />
|
||||
<input name="in3" type="float" nodename="transform" channels="b" />
|
||||
<input name="in4" type="float" interfacename="in" channels="a" />
|
||||
</combine4>
|
||||
<output name="out" type="color4" nodename="asColor4" />
|
||||
</nodegraph>
|
||||
|
||||
<nodegraph name="NG_g22_ap1_to_lin_rec709_color3" nodedef="ND_g22_ap1_to_lin_rec709_color3">
|
||||
<max name="max" type="color3">
|
||||
<input name="in1" type="color3" interfacename="in" />
|
||||
<input name="in2" type="float" value="0" />
|
||||
</max>
|
||||
<power name="gamma" type="color3">
|
||||
<input name="in1" type="color3" nodename="max" />
|
||||
<input name="in2" type="float" value="2.2" />
|
||||
</power>
|
||||
<acescg_to_lin_rec709 name="rec709" type="color3">
|
||||
<input name="in" type="color3" nodename="gamma" />
|
||||
</acescg_to_lin_rec709>
|
||||
<output name="out" type="color3" nodename="rec709" />
|
||||
</nodegraph>
|
||||
|
||||
<nodegraph name="NG_g22_ap1_to_lin_rec709_color4" nodedef="ND_g22_ap1_to_lin_rec709_color4">
|
||||
<convert name="asColor3" type="color3">
|
||||
<input name="in" type="color4" interfacename="in" />
|
||||
</convert>
|
||||
<g22_ap1_to_lin_rec709 name="transform" type="color3">
|
||||
<input name="in" type="color3" nodename="asColor3" />
|
||||
</g22_ap1_to_lin_rec709>
|
||||
<combine4 name="asColor4" type="color4">
|
||||
<input name="in1" type="float" nodename="transform" channels="r" />
|
||||
<input name="in2" type="float" nodename="transform" channels="g" />
|
||||
<input name="in3" type="float" nodename="transform" channels="b" />
|
||||
<input name="in4" type="float" interfacename="in" channels="a" />
|
||||
</combine4>
|
||||
<output name="out" type="color4" nodename="asColor4" />
|
||||
</nodegraph>
|
||||
|
||||
<nodegraph name="NG_srgb_texture_to_lin_rec709_color3" nodedef="ND_srgb_texture_to_lin_rec709_color3">
|
||||
<constant name="threshhold" type="float">
|
||||
<input name="value" type="float" value="0.04045" />
|
||||
</constant>
|
||||
<ifgreater name="isAboveR" type="float">
|
||||
<input name="value1" type="float" interfacename="in" channels="r" />
|
||||
<input name="value2" type="float" nodename="threshhold" />
|
||||
<input name="in1" type="float" value="1" />
|
||||
<input name="in2" type="float" value="0" />
|
||||
</ifgreater>
|
||||
<ifgreater name="isAboveG" type="float">
|
||||
<input name="value1" type="float" interfacename="in" channels="g" />
|
||||
<input name="value2" type="float" nodename="threshhold" />
|
||||
<input name="in1" type="float" value="1" />
|
||||
<input name="in2" type="float" value="0" />
|
||||
</ifgreater>
|
||||
<ifgreater name="isAboveB" type="float">
|
||||
<input name="value1" type="float" interfacename="in" channels="b" />
|
||||
<input name="value2" type="float" nodename="threshhold" />
|
||||
<input name="in1" type="float" value="1" />
|
||||
<input name="in2" type="float" value="0" />
|
||||
</ifgreater>
|
||||
<combine3 name="isAbove" type="color3">
|
||||
<input name="in1" type="float" nodename="isAboveR" />
|
||||
<input name="in2" type="float" nodename="isAboveG" />
|
||||
<input name="in3" type="float" nodename="isAboveB" />
|
||||
</combine3>
|
||||
<divide name="linSeg" type="color3">
|
||||
<input name="in1" type="color3" interfacename="in" />
|
||||
<input name="in2" type="float" value="12.92" />
|
||||
</divide>
|
||||
<add name="bias" type="color3">
|
||||
<input name="in1" type="color3" interfacename="in" />
|
||||
<input name="in2" type="float" value="0.055" />
|
||||
</add>
|
||||
<max name="max" type="color3">
|
||||
<input name="in1" type="color3" nodename="bias" />
|
||||
<input name="in2" type="float" value="0" />
|
||||
</max>
|
||||
<divide name="scale" type="color3">
|
||||
<input name="in1" type="color3" nodename="max" />
|
||||
<input name="in2" type="float" value="1.055" />
|
||||
</divide>
|
||||
<power name="powSeg" type="color3">
|
||||
<input name="in1" type="color3" nodename="scale" />
|
||||
<input name="in2" type="float" value="2.4" />
|
||||
</power>
|
||||
<mix name="mix" type="color3">
|
||||
<input name="bg" type="color3" nodename="linSeg" />
|
||||
<input name="fg" type="color3" nodename="powSeg" />
|
||||
<input name="mix" type="color3" nodename="isAbove" />
|
||||
</mix>
|
||||
<output name="out" type="color3" nodename="mix" />
|
||||
</nodegraph>
|
||||
|
||||
<nodegraph name="NG_srgb_texture_to_lin_rec709_color4" nodedef="ND_srgb_texture_to_lin_rec709_color4">
|
||||
<convert name="asColor3" type="color3">
|
||||
<input name="in" type="color4" interfacename="in" />
|
||||
</convert>
|
||||
<srgb_texture_to_lin_rec709 name="transform" type="color3">
|
||||
<input name="in" type="color3" nodename="asColor3" />
|
||||
</srgb_texture_to_lin_rec709>
|
||||
<combine4 name="asColor4" type="color4">
|
||||
<input name="in1" type="float" nodename="transform" channels="r" />
|
||||
<input name="in2" type="float" nodename="transform" channels="g" />
|
||||
<input name="in3" type="float" nodename="transform" channels="b" />
|
||||
<input name="in4" type="float" interfacename="in" channels="a" />
|
||||
</combine4>
|
||||
<output name="out" type="color4" nodename="asColor4" />
|
||||
</nodegraph>
|
||||
|
||||
<nodegraph name="NG_lin_adobergb_to_lin_rec709_color3" nodedef="ND_lin_adobergb_to_lin_rec709_color3">
|
||||
<constant name="mat" type="matrix33">
|
||||
<input name="value" type="matrix33" value="1.39835574e+00, -2.50233861e-16, 2.77555756e-17, -3.98355744e-01, 1.00000000e+00, -4.29289893e-02, 0.00000000e+00, 0.00000000e+00, 1.04292899e+00" />
|
||||
</constant>
|
||||
<convert name="asVec" type="vector3">
|
||||
<input name="in" type="color3" interfacename="in" />
|
||||
</convert>
|
||||
<transformmatrix name="transform" type="vector3">
|
||||
<input name="in" type="vector3" nodename="asVec" />
|
||||
<input name="mat" type="matrix33" nodename="mat" />
|
||||
</transformmatrix>
|
||||
<convert name="asColor" type="color3">
|
||||
<input name="in" type="vector3" nodename="transform" />
|
||||
</convert>
|
||||
<output name="out" type="color3" nodename="asColor" />
|
||||
</nodegraph>
|
||||
|
||||
<nodegraph name="NG_lin_adobergb_to_lin_rec709_color4" nodedef="ND_lin_adobergb_to_lin_rec709_color4">
|
||||
<convert name="asColor3" type="color3">
|
||||
<input name="in" type="color4" interfacename="in" />
|
||||
</convert>
|
||||
<lin_adobergb_to_lin_rec709 name="transform" type="color3">
|
||||
<input name="in" type="color3" nodename="asColor3" />
|
||||
</lin_adobergb_to_lin_rec709>
|
||||
<combine4 name="asColor4" type="color4">
|
||||
<input name="in1" type="float" nodename="transform" channels="r" />
|
||||
<input name="in2" type="float" nodename="transform" channels="g" />
|
||||
<input name="in3" type="float" nodename="transform" channels="b" />
|
||||
<input name="in4" type="float" interfacename="in" channels="a" />
|
||||
</combine4>
|
||||
<output name="out" type="color4" nodename="asColor4" />
|
||||
</nodegraph>
|
||||
|
||||
<nodegraph name="NG_adobergb_to_lin_rec709_color3" nodedef="ND_adobergb_to_lin_rec709_color3">
|
||||
<divide name="constant" type="float">
|
||||
<input name="in1" type="float" value="563.0" />
|
||||
<input name="in2" type="float" value="256.0" />
|
||||
</divide>
|
||||
<max name="max" type="color3">
|
||||
<input name="in1" type="color3" interfacename="in" />
|
||||
<input name="in2" type="float" value="0" />
|
||||
</max>
|
||||
<power name="gamma" type="color3">
|
||||
<input name="in1" type="color3" nodename="max" />
|
||||
<input name="in2" type="float" nodename="constant" />
|
||||
</power>
|
||||
<lin_adobergb_to_lin_rec709 name="rec709" type="color3">
|
||||
<input name="in" type="color3" nodename="gamma" />
|
||||
</lin_adobergb_to_lin_rec709>
|
||||
<output name="out" type="color3" nodename="rec709" />
|
||||
</nodegraph>
|
||||
|
||||
<nodegraph name="NG_adobergb_to_lin_rec709_color4" nodedef="ND_adobergb_to_lin_rec709_color4">
|
||||
<convert name="asColor3" type="color3">
|
||||
<input name="in" type="color4" interfacename="in" />
|
||||
</convert>
|
||||
<adobergb_to_lin_rec709 name="transform" type="color3">
|
||||
<input name="in" type="color3" nodename="asColor3" />
|
||||
</adobergb_to_lin_rec709>
|
||||
<combine4 name="asColor4" type="color4">
|
||||
<input name="in1" type="float" nodename="transform" channels="r" />
|
||||
<input name="in2" type="float" nodename="transform" channels="g" />
|
||||
<input name="in3" type="float" nodename="transform" channels="b" />
|
||||
<input name="in4" type="float" interfacename="in" channels="a" />
|
||||
</combine4>
|
||||
<output name="out" type="color4" nodename="asColor4" />
|
||||
</nodegraph>
|
||||
|
||||
<nodegraph name="NG_srgb_displayp3_to_lin_rec709_color3" nodedef="ND_srgb_displayp3_to_lin_rec709_color3">
|
||||
<constant name="mat" type="matrix33">
|
||||
<input name="value" type="matrix33" value="1.22493029, -0.22492968, 0.00000006, -0.04205868, 1.04205894, -0.00000001, -0.01964128, -0.07864794, 1.09828925" />
|
||||
</constant>
|
||||
<!-- Use srgb_texture_to_lin_rec709 to convert from sRGB to Lin before passing to the mat conversion -->
|
||||
<srgb_texture_to_lin_rec709 name="srgb_transform" type="color3">
|
||||
<input name="in" type="color3" interfacename="in" />
|
||||
</srgb_texture_to_lin_rec709>
|
||||
<convert name="asVec" type="vector3">
|
||||
<input name="in" type="color3" nodename="srgb_transform" />
|
||||
</convert>
|
||||
<transformmatrix name="transform" type="vector3">
|
||||
<input name="in" type="vector3" nodename="asVec" />
|
||||
<input name="mat" type="matrix33" nodename="mat" />
|
||||
</transformmatrix>
|
||||
<convert name="asColor" type="color3">
|
||||
<input name="in" type="vector3" nodename="transform" />
|
||||
</convert>
|
||||
<output name="out" type="color3" nodename="asColor" />
|
||||
</nodegraph>
|
||||
|
||||
<nodegraph name="NG_srgb_displayp3_to_lin_rec709_color4" nodedef="ND_srgb_displayp3_to_lin_rec709_color4">
|
||||
<convert name="asColor3" type="color3">
|
||||
<input name="in" type="color4" interfacename="in" />
|
||||
</convert>
|
||||
<srgb_displayp3_to_lin_rec709 name="transform" type="color3">
|
||||
<input name="in" type="color3" nodename="asColor3" />
|
||||
</srgb_displayp3_to_lin_rec709>
|
||||
<combine4 name="asColor4" type="color4">
|
||||
<input name="in1" type="float" nodename="transform" channels="r" />
|
||||
<input name="in2" type="float" nodename="transform" channels="g" />
|
||||
<input name="in3" type="float" nodename="transform" channels="b" />
|
||||
<input name="in4" type="float" interfacename="in" channels="a" />
|
||||
</combine4>
|
||||
<output name="out" type="color4" nodename="asColor4" />
|
||||
</nodegraph>
|
||||
|
||||
<nodegraph name="NG_lin_displayp3_to_lin_rec709_color3" nodedef="ND_lin_displayp3_to_lin_rec709_color3">
|
||||
<constant name="mat" type="matrix33">
|
||||
<input name="value" type="matrix33" value="1.22493029, -0.22492968, 0.00000006, -0.04205868, 1.04205894, -0.00000001, -0.01964128, -0.07864794, 1.09828925" />
|
||||
</constant>
|
||||
<convert name="asVec" type="vector3">
|
||||
<input name="in" type="color3" interfacename="in" />
|
||||
</convert>
|
||||
<transformmatrix name="transform" type="vector3">
|
||||
<input name="in" type="vector3" nodename="asVec" />
|
||||
<input name="mat" type="matrix33" nodename="mat" />
|
||||
</transformmatrix>
|
||||
<convert name="asColor" type="color3">
|
||||
<input name="in" type="vector3" nodename="transform" />
|
||||
</convert>
|
||||
<output name="out" type="color3" nodename="asColor" />
|
||||
</nodegraph>
|
||||
|
||||
<nodegraph name="NG_lin_displayp3_to_lin_rec709_color4" nodedef="ND_lin_displayp3_to_lin_rec709_color4">
|
||||
<convert name="asColor3" type="color3">
|
||||
<input name="in" type="color4" interfacename="in" />
|
||||
</convert>
|
||||
<lin_displayp3_to_lin_rec709 name="transform" type="color3">
|
||||
<input name="in" type="color3" nodename="asColor3" />
|
||||
</lin_displayp3_to_lin_rec709>
|
||||
<combine4 name="asColor4" type="color4">
|
||||
<input name="in1" type="float" nodename="transform" channels="r" />
|
||||
<input name="in2" type="float" nodename="transform" channels="g" />
|
||||
<input name="in3" type="float" nodename="transform" channels="b" />
|
||||
<input name="in4" type="float" interfacename="in" channels="a" />
|
||||
</combine4>
|
||||
<output name="out" type="color4" nodename="asColor4" />
|
||||
</nodegraph>
|
||||
|
||||
</materialx>
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0"?>
|
||||
<materialx version="1.38">
|
||||
|
||||
<!-- <point_light> -->
|
||||
<implementation name="IM_point_light_genglsl" nodedef="ND_point_light" file="mx_point_light.glsl" function="mx_point_light" target="genglsl" />
|
||||
|
||||
<!-- <directional_light> -->
|
||||
<implementation name="IM_directional_light_genglsl" nodedef="ND_directional_light" file="mx_directional_light.glsl" function="mx_directional_light" target="genglsl" />
|
||||
|
||||
<!-- <spot_light> -->
|
||||
<implementation name="IM_spot_light_genglsl" nodedef="ND_spot_light" file="mx_spot_light.glsl" function="mx_spot_light" target="genglsl" />
|
||||
|
||||
</materialx>
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
void mx_directional_light(LightData light, vec3 position, out lightshader result)
|
||||
{
|
||||
result.direction = -light.direction;
|
||||
result.intensity = light.color * light.intensity;
|
||||
}
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
void mx_point_light(LightData light, vec3 position, out lightshader result)
|
||||
{
|
||||
result.direction = light.position - position;
|
||||
float distance = length(result.direction) + M_FLOAT_EPS;
|
||||
float attenuation = pow(distance + 1.0, light.decay_rate + M_FLOAT_EPS);
|
||||
result.intensity = light.color * light.intensity / attenuation;
|
||||
result.direction /= distance;
|
||||
}
|
||||
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
void mx_spot_light(LightData light, vec3 position, out lightshader result)
|
||||
{
|
||||
result.direction = light.position - position;
|
||||
float distance = length(result.direction) + M_FLOAT_EPS;
|
||||
float attenuation = pow(distance + 1.0, light.decay_rate + M_FLOAT_EPS);
|
||||
result.intensity = light.color * light.intensity / attenuation;
|
||||
result.direction /= distance;
|
||||
float low = min(light.inner_angle, light.outer_angle);
|
||||
float high = light.inner_angle;
|
||||
float cosDir = dot(result.direction, -light.direction);
|
||||
float spotAttenuation = smoothstep(low, high, cosDir);
|
||||
result.intensity *= spotAttenuation;
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0"?>
|
||||
<materialx version="1.38">
|
||||
|
||||
<!-- <point_light> -->
|
||||
<implementation name="IM_point_light_genmsl" nodedef="ND_point_light" file="mx_point_light.metal" function="mx_point_light" target="genmsl" />
|
||||
|
||||
<!-- <directional_light> -->
|
||||
<implementation name="IM_directional_light_genmsl" nodedef="ND_directional_light" file="mx_directional_light.metal" function="mx_directional_light" target="genmsl" />
|
||||
|
||||
<!-- <spot_light> -->
|
||||
<implementation name="IM_spot_light_genmsl" nodedef="ND_spot_light" file="mx_spot_light.metal" function="mx_spot_light" target="genmsl" />
|
||||
|
||||
</materialx>
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
void mx_directional_light(LightData light, float3 position, thread lightshader& result)
|
||||
{
|
||||
result.direction = -light.direction;
|
||||
result.intensity = light.color * light.intensity;
|
||||
}
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
void mx_point_light(LightData light, float3 position, thread lightshader& result)
|
||||
{
|
||||
result.direction = light.position - position;
|
||||
float distance = length(result.direction) + M_FLOAT_EPS;
|
||||
float attenuation = pow(distance + 1.0, light.decay_rate + M_FLOAT_EPS);
|
||||
result.intensity = light.color * light.intensity / attenuation;
|
||||
result.direction /= distance;
|
||||
}
|
||||
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
void mx_spot_light(LightData light, float3 position, thread lightshader& result)
|
||||
{
|
||||
result.direction = light.position - position;
|
||||
float distance = length(result.direction) + M_FLOAT_EPS;
|
||||
float attenuation = pow(distance + 1.0, light.decay_rate + M_FLOAT_EPS);
|
||||
result.intensity = light.color * light.intensity / attenuation;
|
||||
result.direction /= distance;
|
||||
float low = min(light.inner_angle, light.outer_angle);
|
||||
float high = light.inner_angle;
|
||||
float cosDir = dot(result.direction, -light.direction);
|
||||
float spotAttenuation = smoothstep(low, high, cosDir);
|
||||
result.intensity *= spotAttenuation;
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
<?xml version="1.0"?>
|
||||
<materialx version="1.38">
|
||||
<!--
|
||||
Copyright Contributors to the MaterialX Project
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
Declarations of common light nodes, used in code generation for hardware
|
||||
shading languages that require explicit light loops.
|
||||
|
||||
These nodes are a required implementation detail for hardware shader
|
||||
generation, and are not themselves part of the MaterialX standard.
|
||||
-->
|
||||
|
||||
<!-- ======================================================================== -->
|
||||
<!-- Light shader nodes -->
|
||||
<!-- ======================================================================== -->
|
||||
|
||||
<!--
|
||||
Node: <point_light>
|
||||
-->
|
||||
<nodedef name="ND_point_light" node="point_light" nodegroup="light" doc="A light shader node of 'point' type.">
|
||||
<input name="position" type="vector3" doc="Light source position." />
|
||||
<input name="color" type="color3" doc="Light color." />
|
||||
<input name="intensity" type="float" doc="Light intensity." />
|
||||
<input name="decay_rate" type="float" value="2.0" doc="Light decay exponent. Defaults to 2 for quadratic decay." />
|
||||
<output name="out" type="lightshader" />
|
||||
</nodedef>
|
||||
|
||||
<!--
|
||||
Node: <directional_light>
|
||||
-->
|
||||
<nodedef name="ND_directional_light" node="directional_light" nodegroup="light" doc="A light shader node of 'directional' type.">
|
||||
<input name="direction" type="vector3" doc="Light source direction." />
|
||||
<input name="color" type="color3" doc="Light color." />
|
||||
<input name="intensity" type="float" doc="Light intensity." />
|
||||
<output name="out" type="lightshader" />
|
||||
</nodedef>
|
||||
|
||||
<!--
|
||||
Node: <spot_light>
|
||||
-->
|
||||
<nodedef name="ND_spot_light" node="spot_light" nodegroup="light" doc="A light shader node of 'spot' type.">
|
||||
<input name="position" type="vector3" doc="Light source position." />
|
||||
<input name="direction" type="vector3" doc="Light source direction." />
|
||||
<input name="color" type="color3" doc="Light color." />
|
||||
<input name="intensity" type="float" doc="Light intensity." />
|
||||
<input name="decay_rate" type="float" value="2.0" doc="Light decay exponent. Defaults to 2 for quadratic decay." />
|
||||
<input name="inner_angle" type="float" doc="Inner cone angle." />
|
||||
<input name="outer_angle" type="float" doc="Outer cone angle." />
|
||||
<output name="out" type="lightshader" />
|
||||
</nodedef>
|
||||
|
||||
</materialx>
|
||||
+199
@@ -0,0 +1,199 @@
|
||||
/*
|
||||
* Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// MDL implementation of core types and supporting functions from
|
||||
// MaterialX: An Open Standard for Network-Based CG Object Looks
|
||||
// Document v1.37 REV2, January 19, 2020
|
||||
// and
|
||||
// MaterialX: An Open Standard for Network-Based CG Object Looks
|
||||
// Document v1.37 REV2, January 19, 2020
|
||||
// www.materialx.org
|
||||
// in
|
||||
// NVIDIA Material Definition Language 1.7
|
||||
// Language Specification
|
||||
// Document version 1.7.2, January 17, 2022
|
||||
// www.nvidia.com/mdl
|
||||
|
||||
mdl 1.6;
|
||||
|
||||
import ::math::*;
|
||||
import ::state::*;
|
||||
import ::tex::*;
|
||||
|
||||
// Epsilon value used in float calculations.
|
||||
export const float FLOAT_EPS = 0.000001;
|
||||
|
||||
// MaterialX Data Types
|
||||
// NOTE: We use native MDL types where possible and rely on the translator
|
||||
// to map MaterialX types to MDL types according to this table:
|
||||
//
|
||||
// MaterialX --> MDL
|
||||
// ------------------
|
||||
// integer --> int
|
||||
// boolean --> bool
|
||||
// float --> float
|
||||
// color3 --> color
|
||||
// color4 --> struct color4 (see below)
|
||||
// vector2 --> float2
|
||||
// vector3 --> float3
|
||||
// vector4 --> float4
|
||||
// matrix33 --> float3x3
|
||||
// matrix44 --> float4x4
|
||||
// string --> string, or context specific enums (see below)
|
||||
// filename --> texture_2d, or other repective resource type
|
||||
// geomname --> (N.A.)
|
||||
// <T>array --> T[<N>] (deferred-size arrays)
|
||||
//
|
||||
// NOTE: The type mapping is not bijective, multiple types in MaterialX
|
||||
// map to the same type in MDL, which can impact the translation
|
||||
// of overloaded nodes to not generate mutliple identical definitions.
|
||||
|
||||
// Special struct type for color4
|
||||
export struct color4 {
|
||||
color rgb = color(0.0);
|
||||
float a = 1.0;
|
||||
};
|
||||
|
||||
// NOTE: MDL does not support operator overloading nor custom constructors,
|
||||
// we use constructor-like functions defined here to help the generator
|
||||
// to work with the vector and color types, as well as operator-like
|
||||
// functions for the color4 type.
|
||||
export color4 mk_color4( float v) { return color4( color(v), v);}
|
||||
export color4 mk_color4( float r, float g, float b, float a) { return color4(color(r,g,b), a); }
|
||||
export color4 mk_color4( float3 v) { return color4(color(v.x, v.y, v.z), 1.0); }
|
||||
export color4 mk_color4( float4 v) { return color4(color(v.x, v.y, v.z), v.w); }
|
||||
export color4 mk_color4( color v) { return color4(v, 1.0); }
|
||||
export color4 mk_color4( color v, float a) { return color4(v, a); }
|
||||
export color mk_color3( float r, float g, float b) { return color(r, g, b); }
|
||||
export color mk_color3( float v) { return color(v); }
|
||||
export color mk_color3( float2 v) { return color(v.x, v.y, 0.0); }
|
||||
export color mk_color3( float3 v) { return color(v.x, v.y, v.z); }
|
||||
export color mk_color3( float4 v) { return color(v.x, v.y, v.z); }
|
||||
export color mk_color3( color v) { return v; }
|
||||
export color mk_color3( color4 v) { return v.rgb; }
|
||||
export float3 mk_float3( color4 v) { return float3(v.rgb); }
|
||||
export float4 mk_float4( color4 v) {
|
||||
float3 rgb = float3(v.rgb);
|
||||
return float4(rgb.x, rgb.y, rgb.z, v.a);
|
||||
}
|
||||
|
||||
export color4 mx_add( color4 v1, color4 v2) { return color4(v1.rgb + v2.rgb, v1.a + v2.a); }
|
||||
export color4 mx_add( color4 v1, float v2) { return color4(v1.rgb + v2 , v1.a + v2 ); }
|
||||
export color4 mx_subtract( color4 v1, color4 v2) { return color4(v1.rgb - v2.rgb, v1.a - v2.a); }
|
||||
export color4 mx_subtract( color4 v1, float v2) { return color4(v1.rgb - v2 , v1.a - v2 ); }
|
||||
export color4 mx_multiply( color4 v1, color4 v2) { return color4(v1.rgb * v2.rgb, v1.a * v2.a); }
|
||||
export color4 mx_multiply( color4 v1, float v2) { return color4(v1.rgb * v2 , v1.a * v2 ); }
|
||||
export color4 mx_divide( color4 v1, color4 v2) { return color4(v1.rgb / v2.rgb, v1.a / v2.a); }
|
||||
export color4 mx_divide( color4 v1, float v2) { return color4(v1.rgb / v2 , v1.a / v2 ); }
|
||||
export float mx_mod( float x, float y) { return x - y * math::floor(x/y); }
|
||||
export float2 mx_mod( float2 x, float2 y) { return x - y * math::floor(x/y); }
|
||||
export float3 mx_mod( float3 x, float3 y) { return x - y * math::floor(x/y); }
|
||||
export float4 mx_mod( float4 x, float4 y) { return x - y * math::floor(x/y); }
|
||||
export float2 mx_mod( float2 x, float y) { return mx_mod(x, float2(y,y)); }
|
||||
export float3 mx_mod( float3 x, float y) { return mx_mod(x, float3(y,y,y)); }
|
||||
export float4 mx_mod( float4 x, float y) { return mx_mod(x, float4(y,y,y,y)); }
|
||||
|
||||
// Parameter Expressions and Function Curves
|
||||
// Idea: attach an auxiliary lookup function if an array of frame values is
|
||||
// given in a <valuecurve> attribute
|
||||
export int curve_lookup( int index, int[<N>] values, int min, int max) {
|
||||
return values[::math::clamp( index, min, max) - min];
|
||||
}
|
||||
export float curve_lookup( int index, float[<N>] values, int min, int max) {
|
||||
return values[::math::clamp( index, min, max) - min];
|
||||
}
|
||||
export float2 curve_lookup( int index, float2[<N>] values, int min, int max) {
|
||||
return values[::math::clamp( index, min, max) - min];
|
||||
}
|
||||
export float3 curve_lookup( int index, float3[<N>] values, int min, int max) {
|
||||
return values[::math::clamp( index, min, max) - min];
|
||||
}
|
||||
export float4 curve_lookup( int index, float4[<N>] values, int min, int max) {
|
||||
return values[::math::clamp( index, min, max) - min];
|
||||
}
|
||||
export color curve_lookup( int index, color[<N>] values, int min, int max) {
|
||||
return values[::math::clamp( index, min, max) - min];
|
||||
}
|
||||
|
||||
// Enum selecting address modes for texture nodes, instead of string
|
||||
export enum mx_addressmode_type {
|
||||
mx_addressmode_type_constant,
|
||||
mx_addressmode_type_clamp,
|
||||
mx_addressmode_type_periodic,
|
||||
mx_addressmode_type_mirror
|
||||
};
|
||||
|
||||
// Enum selecting filter modes for texture nodes, instead of string
|
||||
export enum mx_filterlookup_type {
|
||||
mx_filterlookup_type_closest,
|
||||
mx_filterlookup_type_linear,
|
||||
mx_filterlookup_type_cubic
|
||||
};
|
||||
|
||||
// Enum selecting coordinate spaces, instead of string
|
||||
export enum mx_coordinatespace_type {
|
||||
mx_coordinatespace_type_model,
|
||||
mx_coordinatespace_type_object,
|
||||
mx_coordinatespace_type_world
|
||||
};
|
||||
|
||||
// Helper function mapping MaterialX coordinate spaces to MDL coordinate spaces
|
||||
export state::coordinate_space mx_map_space( mx_coordinatespace_type space) {
|
||||
switch (space) {
|
||||
case mx_coordinatespace_type_world:
|
||||
return state::coordinate_world;
|
||||
case mx_coordinatespace_type_object:
|
||||
return state::coordinate_object;
|
||||
default:
|
||||
return state::coordinate_internal;
|
||||
}
|
||||
}
|
||||
|
||||
// Helper function mapping MaterialX coordinate space strings to MDL coordinate spaces
|
||||
export state::coordinate_space mx_map_space( string space) {
|
||||
if (space == "world") {
|
||||
return state::coordinate_world;
|
||||
}
|
||||
else if (space == "object") {
|
||||
return state::coordinate_object;
|
||||
}
|
||||
else {
|
||||
return state::coordinate_internal;
|
||||
}
|
||||
}
|
||||
|
||||
// Support return type structures for the separate[234] types
|
||||
export struct mx_separate2_vector2_type { float outx = 0.0; float outy = 0.0; };
|
||||
export struct mx_separate3_color3_type { float outr = 0.0; float outg = 0.0; float outb = 0.0; };
|
||||
export struct mx_separate3_vector3_type { float outx = 0.0; float outy = 0.0; float outz = 0.0; };
|
||||
export struct mx_separate4_color4_type { float outr = 0.0; float outg = 0.0; float outb = 0.0; float outa = 0.0; };
|
||||
export struct mx_separate4_vector4_type { float outx = 0.0; float outy = 0.0; float outz = 0.0; float outw = 0.0; };
|
||||
|
||||
// Enum for blur filter type, instead of string
|
||||
export enum mx_filter_type {
|
||||
mx_filter_type_box,
|
||||
mx_filter_type_gaussian
|
||||
};
|
||||
|
||||
// Enum selecting microfacet models, instead of string
|
||||
export enum mx_distribution_type {
|
||||
mx_distribution_type_ggx
|
||||
};
|
||||
|
||||
// Custom annotation for MDL function parameters to map between MDL and the original MaterialX graph.
|
||||
// * When added to a paramater, the "name" will contain the path in the MaterialX graph starting
|
||||
// from the root up to the input using `/` as separator.
|
||||
export annotation origin(string name);
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// Support functions for HSV <--> RGB color conversions
|
||||
|
||||
mdl 1.6;
|
||||
|
||||
import ::limits::*;
|
||||
import ::math::*;
|
||||
|
||||
// Convert from the HSV color model to the RGB color model
|
||||
export float3 mx_hsvtorgb(float3 hsv) {
|
||||
// from "Color Imaging, Fundamentals and Applications", Reinhard et al., p. 442
|
||||
|
||||
float h = 6.0 * (hsv.x - math::floor(hsv.x));
|
||||
int hi = int(h); // truncate
|
||||
float f = h - float(hi);
|
||||
|
||||
float zy = hsv.z*hsv.y;
|
||||
float a = hsv.z - zy;
|
||||
float b = hsv.z - zy*f;
|
||||
float c = a + zy*f;
|
||||
|
||||
switch(hi) {
|
||||
default:
|
||||
// hue out of [0,1] range...
|
||||
// fall through...
|
||||
case 0:
|
||||
return float3(hsv.z, c, a);
|
||||
case 1:
|
||||
return float3(b, hsv.z, a);
|
||||
case 2:
|
||||
return float3(a, hsv.z, c);
|
||||
case 3:
|
||||
return float3(a, b, hsv.z);
|
||||
case 4:
|
||||
return float3(c, a, hsv.z);
|
||||
case 5:
|
||||
return float3(hsv.z, a, b);
|
||||
}
|
||||
}
|
||||
|
||||
// Convert from the RGB color model to the HSV color model
|
||||
export float3 mx_rgbtohsv(float3 rgb) {
|
||||
// from "Color Imaging, Fundamentals and Applications", Reinhard et al., p. 442
|
||||
// H =
|
||||
// 60*(G-B)/(max-min) if R is max
|
||||
// 60*(2+((B-R)/(max-min))) if G is max
|
||||
// 60*(4+((R-G)/(max-min))) if B if max
|
||||
// and normalize the result by dividing by 360deg
|
||||
// S = (max-min)/max
|
||||
// V = max
|
||||
|
||||
float max = math::max(rgb.x, math::max(rgb.y, rgb.z));
|
||||
float min = math::min(rgb.x, math::min(rgb.y, rgb.z));
|
||||
float range = max - min;
|
||||
float inv_range = (1.0f/6.0f)/range;
|
||||
|
||||
float saturation = (max > limits::FLOAT_MIN) ? (range / max) : 0.0f;
|
||||
float hue = (saturation != 0.0f) ?
|
||||
((max == rgb.x) ? ((rgb.y-rgb.z)*inv_range) // R is max
|
||||
: (max == rgb.y) ? ((2.0f/6.0f) + (rgb.z-rgb.x)*inv_range) // G is max
|
||||
: ((4.0f/6.0f) + (rgb.x-rgb.y)*inv_range)) // B is max
|
||||
: 0.0f; // hue is undefined (assume 0)
|
||||
|
||||
return float3((hue >= 0.0f) ? hue : (hue + 1.0f), saturation, max);
|
||||
}
|
||||
+760
@@ -0,0 +1,760 @@
|
||||
//
|
||||
// Copyright Contributors to the MaterialX Project
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
/********************************************************************************
|
||||
MaterialX Noise Library.
|
||||
|
||||
This library is a modified version of the noise library found in
|
||||
Open Shading Language:
|
||||
github.com/imageworks/OpenShadingLanguage/blob/master/src/include/OSL/oslnoise.h
|
||||
|
||||
It contains the subset of noise types needed to implement the MaterialX
|
||||
standard library. The modifications are mainly conversions from C++ to MDL.
|
||||
Produced results should be identical to the OSL noise functions.
|
||||
|
||||
Original copyright notice:
|
||||
------------------------------------------------------------------------
|
||||
Copyright (c) 2009-2010 Sony Pictures Imageworks Inc., et al.
|
||||
All Rights Reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of Sony Pictures Imageworks nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
------------------------------------------------------------------------
|
||||
********************************************************************************/
|
||||
|
||||
mdl 1.6;
|
||||
|
||||
import ::anno::*;
|
||||
import ::math::*;
|
||||
import ::state::*;
|
||||
|
||||
import .::core::*;
|
||||
import .::swizzle::*;
|
||||
|
||||
float mx_bilerp_float(float v0, float v1, float v2, float v3, float s, float t)
|
||||
{
|
||||
float s1 = 1.0 - s;
|
||||
return (1.0 - t) * (v0*s1 + v1*s) + t * (v2*s1 + v3*s);
|
||||
}
|
||||
float3 mx_bilerp_float3(float3 v0, float3 v1, float3 v2, float3 v3, float s, float t)
|
||||
{
|
||||
float s1 = 1.0 - s;
|
||||
return (1.0 - t) * (v0*s1 + v1*s) + t * (v2*s1 + v3*s);
|
||||
}
|
||||
float mx_trilerp_float(float v0, float v1, float v2, float v3, float v4, float v5, float v6, float v7, float s, float t, float r)
|
||||
{
|
||||
float s1 = 1.0 - s;
|
||||
float t1 = 1.0 - t;
|
||||
float r1 = 1.0 - r;
|
||||
return (r1*(t1*(v0*s1 + v1*s) + t*(v2*s1 + v3*s)) +
|
||||
r*(t1*(v4*s1 + v5*s) + t*(v6*s1 + v7*s)));
|
||||
}
|
||||
float3 mx_trilerp_float3(float3 v0, float3 v1, float3 v2, float3 v3, float3 v4, float3 v5, float3 v6, float3 v7, float s, float t, float r)
|
||||
{
|
||||
float s1 = 1.0 - s;
|
||||
float t1 = 1.0 - t;
|
||||
float r1 = 1.0 - r;
|
||||
return (r1*(t1*(v0*s1 + v1*s) + t*(v2*s1 + v3*s)) +
|
||||
r*(t1*(v4*s1 + v5*s) + t*(v6*s1 + v7*s)));
|
||||
}
|
||||
|
||||
// 2 and 3 dimensional gradient functions - perform a dot product against a
|
||||
// randomly chosen vector. Note that the gradient vector is not normalized, but
|
||||
// this only affects the overal "scale" of the result, so we simply account for
|
||||
// the scale by multiplying in the corresponding "perlin" function.
|
||||
float mx_gradient_float(int mxp_hash, float mxp_x, float mxp_y)
|
||||
{
|
||||
// 8 possible directions (+-1,+-2) and (+-2,+-1)
|
||||
int h = mxp_hash & 7;
|
||||
float u = h<4 ? mxp_x : mxp_y;
|
||||
float v = 2.0 * (h<4 ? mxp_y : mxp_x);
|
||||
// compute the dot product with (x,y).
|
||||
return (((h&1)!=0) ? -u : u) + (((h&2) != 0) ? -v : v);
|
||||
}
|
||||
float mx_gradient_float(int mxp_hash, float mxp_x, float mxp_y, float mxp_z)
|
||||
{
|
||||
// use vectors pointing to the edges of the cube
|
||||
int h = mxp_hash & 15;
|
||||
float u = h<8 ? mxp_x : mxp_y;
|
||||
float v = h<4 ? mxp_y : ((h==12)||(h==14)) ? mxp_x : mxp_z;
|
||||
return (((h&1)!=0)?-u:u) + (((h&2)!=0)?-v:v);
|
||||
}
|
||||
float3 mx_gradient_float3(int3 mxp_hash, float mxp_x, float mxp_y)
|
||||
{
|
||||
return float3(mx_gradient_float(mxp_hash.x, mxp_x, mxp_y),
|
||||
mx_gradient_float(mxp_hash.y, mxp_x, mxp_y),
|
||||
mx_gradient_float(mxp_hash.z, mxp_x, mxp_y));
|
||||
}
|
||||
float3 mx_gradient_float3(int3 mxp_hash, float mxp_x, float mxp_y, float mxp_z)
|
||||
{
|
||||
return float3(mx_gradient_float(mxp_hash.x, mxp_x, mxp_y, mxp_z),
|
||||
mx_gradient_float(mxp_hash.y, mxp_x, mxp_y, mxp_z),
|
||||
mx_gradient_float(mxp_hash.z, mxp_x, mxp_y, mxp_z));
|
||||
}
|
||||
// Scaling factors to normalize the result of gradients above.
|
||||
// These factors were experimentally calculated to be:
|
||||
// 2D: 0.6616
|
||||
// 3D: 0.9820
|
||||
//JAN: why do those differ from osl sourcecode?
|
||||
float mx_gradient_scale2d_float(float mxp_v) { return 0.6616 * mxp_v; }
|
||||
float mx_gradient_scale3d_float(float mxp_v) { return 0.9820 * mxp_v; }
|
||||
float3 mx_gradient_scale2d_float3(float3 mxp_v) { return 0.6616 * mxp_v; }
|
||||
float3 mx_gradient_scale3d_float3(float3 mxp_v) { return 0.9820 * mxp_v; }
|
||||
|
||||
/// Bitwise circular rotation left by k bits (for 32 bit unsigned integers)
|
||||
int mx_rotl32(int mxp_x, int mxp_k)
|
||||
{
|
||||
return (mxp_x<<mxp_k) | (mxp_x>>>(32-mxp_k)); //note the unsigned right shift
|
||||
}
|
||||
|
||||
int3 mx_bjmix(int a, int b, int c)
|
||||
{
|
||||
a -= c; a ^= mx_rotl32(c, 4); c += b;
|
||||
b -= a; b ^= mx_rotl32(a, 6); a += c;
|
||||
c -= b; c ^= mx_rotl32(b, 8); b += a;
|
||||
a -= c; a ^= mx_rotl32(c,16); c += b;
|
||||
b -= a; b ^= mx_rotl32(a,19); a += c;
|
||||
c -= b; c ^= mx_rotl32(b, 4); b += a;
|
||||
return int3(a, b, c);
|
||||
}
|
||||
|
||||
// Mix up and combine the bits of a, b, and c (doesn't change them, but
|
||||
// returns a hash of those three original values).
|
||||
int mx_bjfinal(int mxp_a, int mxp_b, int mxp_c)
|
||||
{
|
||||
mxp_c ^= mxp_b; mxp_c -= mx_rotl32(mxp_b,14);
|
||||
mxp_a ^= mxp_c; mxp_a -= mx_rotl32(mxp_c,11);
|
||||
mxp_b ^= mxp_a; mxp_b -= mx_rotl32(mxp_a,25);
|
||||
mxp_c ^= mxp_b; mxp_c -= mx_rotl32(mxp_b,16);
|
||||
mxp_a ^= mxp_c; mxp_a -= mx_rotl32(mxp_c,4);
|
||||
mxp_b ^= mxp_a; mxp_b -= mx_rotl32(mxp_a,14);
|
||||
mxp_c ^= mxp_b; mxp_c -= mx_rotl32(mxp_b,24);
|
||||
return mxp_c;
|
||||
}
|
||||
|
||||
// Convert a 32 bit integer into a floating point number in [0,1]
|
||||
float mx_bits_to_01(int mxp_bits)
|
||||
{
|
||||
return mxp_bits >=0 ? float(mxp_bits) / 4294967295.:
|
||||
float(mxp_bits>>>1)/ 2147483647.;
|
||||
}
|
||||
|
||||
float mx_fade(float mxp_t)
|
||||
{
|
||||
return mxp_t * mxp_t * mxp_t * (mxp_t * (mxp_t * 6.0 - 15.0) + 10.0);
|
||||
}
|
||||
|
||||
int mx_hash_int(int mxp_x)
|
||||
{
|
||||
int len = 1;
|
||||
int seed = int(0xdeadbeef) + (len << 2) + 13;
|
||||
return mx_bjfinal(seed + mxp_x, seed, seed);
|
||||
}
|
||||
|
||||
int mx_hash_int(int mxp_x, int mxp_y)
|
||||
{
|
||||
int len = 2;
|
||||
int a, b, c;
|
||||
a = b = c = int(0xdeadbeef) + (len << 2) + 13;
|
||||
a += mxp_x;
|
||||
b += mxp_y;
|
||||
return mx_bjfinal(a, b, c);
|
||||
}
|
||||
|
||||
int mx_hash_int(int mxp_x, int mxp_y, int mxp_z)
|
||||
{
|
||||
int len = 3;
|
||||
int a, b, c;
|
||||
a = b = c = int(0xdeadbeef) + (len << 2) + 13;
|
||||
a += mxp_x;
|
||||
b += mxp_y;
|
||||
c += mxp_z;
|
||||
return mx_bjfinal(a, b, c);
|
||||
}
|
||||
|
||||
int mx_hash_int(int x, int y, int z, int xx)
|
||||
{
|
||||
int len = 4;
|
||||
int a, b, c;
|
||||
a = b = c = int(0xdeadbeef) + (len << 2) + 13;
|
||||
a += x;
|
||||
b += y;
|
||||
c += z;
|
||||
int3 abc = mx_bjmix(a, b, c);
|
||||
a = abc.x;
|
||||
b = abc.y;
|
||||
c = abc.z;
|
||||
a += xx;
|
||||
return mx_bjfinal(a, b, c);
|
||||
}
|
||||
|
||||
int mx_hash_int(int x, int y, int z, int xx, int yy)
|
||||
{
|
||||
int len = 5;
|
||||
int a, b, c;
|
||||
a = b = c = int(0xdeadbeef) + (len << 2) + 13;
|
||||
a += x;
|
||||
b += y;
|
||||
c += z;
|
||||
int3 abc = mx_bjmix(a, b, c);
|
||||
a = abc.x;
|
||||
b = abc.y;
|
||||
c = abc.z;
|
||||
a += xx;
|
||||
b += yy;
|
||||
return mx_bjfinal(a, b, c);
|
||||
}
|
||||
|
||||
int3 mx_hash_int3(int mxp_x, int mxp_y)
|
||||
{
|
||||
int h = mx_hash_int(mxp_x, mxp_y);
|
||||
// we only need the low-order bits to be random, so split out
|
||||
// the 32 bit result into 3 parts for each channel
|
||||
int3 result;
|
||||
result.x = (h ) & 0xFF;
|
||||
result.y = (h >>> 8 ) & 0xFF;
|
||||
result.z = (h >>> 16) & 0xFF;
|
||||
return result;
|
||||
}
|
||||
|
||||
int3 mx_hash_int3(int mxp_x, int mxp_y, int mxp_z)
|
||||
{
|
||||
int h = mx_hash_int(mxp_x, mxp_y, mxp_z);
|
||||
// we only need the low-order bits to be random, so split out
|
||||
// the 32 bit result into 3 parts for each channel
|
||||
int3 result;
|
||||
result.x = (h ) & 0xFF;
|
||||
result.y = (h >>> 8 ) & 0xFF;
|
||||
result.z = (h >>> 16) & 0xFF;
|
||||
return result;
|
||||
}
|
||||
|
||||
export float mx_perlin_noise_float(
|
||||
float2 mxp_p = swizzle::xy( ::state::texture_coordinate(0)))
|
||||
[[
|
||||
anno::noinline()
|
||||
]]
|
||||
{
|
||||
float ix=math::floor(mxp_p.x);
|
||||
float iy=math::floor(mxp_p.y);
|
||||
int X = int(ix);
|
||||
int Y = int(iy);
|
||||
float fx = mxp_p.x-ix;
|
||||
float fy = mxp_p.y-iy;
|
||||
float u = mx_fade(fx);
|
||||
float v = mx_fade(fy);
|
||||
float result = mx_bilerp_float(
|
||||
mx_gradient_float(mx_hash_int(X , Y ), fx , fy ),
|
||||
mx_gradient_float(mx_hash_int(X+1, Y ), fx-1.0, fy ),
|
||||
mx_gradient_float(mx_hash_int(X , Y+1), fx , fy-1.0),
|
||||
mx_gradient_float(mx_hash_int(X+1, Y+1), fx-1.0, fy-1.0),
|
||||
u, v);
|
||||
return mx_gradient_scale2d_float(result);
|
||||
}
|
||||
|
||||
export float3 mx_perlin_noise_float3(
|
||||
float2 mxp_p = swizzle::xy( ::state::texture_coordinate(0)))
|
||||
[[
|
||||
anno::noinline()
|
||||
]]
|
||||
{
|
||||
float ix=math::floor(mxp_p.x);
|
||||
float iy=math::floor(mxp_p.y);
|
||||
int X = int(ix);
|
||||
int Y = int(iy);
|
||||
float fx = mxp_p.x-ix;
|
||||
float fy = mxp_p.y-iy;
|
||||
float u = mx_fade(fx);
|
||||
float v = mx_fade(fy);
|
||||
float3 result = mx_bilerp_float3(
|
||||
mx_gradient_float3(mx_hash_int3(X , Y ), fx , fy ),
|
||||
mx_gradient_float3(mx_hash_int3(X+1, Y ), fx-1.0, fy ),
|
||||
mx_gradient_float3(mx_hash_int3(X , Y+1), fx , fy-1.0),
|
||||
mx_gradient_float3(mx_hash_int3(X+1, Y+1), fx-1.0, fy-1.0),
|
||||
u, v);
|
||||
return mx_gradient_scale2d_float3(result);
|
||||
}
|
||||
|
||||
export float mx_perlin_noise_float(
|
||||
float3 mxp_p = state::transform_point(state::coordinate_internal, state::coordinate_object, state::position()))
|
||||
[[
|
||||
anno::noinline()
|
||||
]]
|
||||
{
|
||||
float ix=math::floor(mxp_p.x);
|
||||
float iy=math::floor(mxp_p.y);
|
||||
float iz=math::floor(mxp_p.z);
|
||||
int X = int(ix);
|
||||
int Y = int(iy);
|
||||
int Z = int(iz);
|
||||
float fx = mxp_p.x-ix;
|
||||
float fy = mxp_p.y-iy;
|
||||
float fz = mxp_p.z-iz;
|
||||
float u = mx_fade(fx);
|
||||
float v = mx_fade(fy);
|
||||
float w = mx_fade(fz);
|
||||
float result = mx_trilerp_float(
|
||||
mx_gradient_float(mx_hash_int(X , Y , Z ), fx , fy , fz ),
|
||||
mx_gradient_float(mx_hash_int(X+1, Y , Z ), fx-1.0, fy , fz ),
|
||||
mx_gradient_float(mx_hash_int(X , Y+1, Z ), fx , fy-1.0, fz ),
|
||||
mx_gradient_float(mx_hash_int(X+1, Y+1, Z ), fx-1.0, fy-1.0, fz ),
|
||||
mx_gradient_float(mx_hash_int(X , Y , Z+1), fx , fy , fz-1.0),
|
||||
mx_gradient_float(mx_hash_int(X+1, Y , Z+1), fx-1.0, fy , fz-1.0),
|
||||
mx_gradient_float(mx_hash_int(X , Y+1, Z+1), fx , fy-1.0, fz-1.0),
|
||||
mx_gradient_float(mx_hash_int(X+1, Y+1, Z+1), fx-1.0, fy-1.0, fz-1.0),
|
||||
u, v, w);
|
||||
return mx_gradient_scale3d_float(result);
|
||||
}
|
||||
|
||||
export float3 mx_perlin_noise_float3(
|
||||
float3 mxp_p = state::transform_point(state::coordinate_internal, state::coordinate_object, state::position()))
|
||||
[[
|
||||
anno::noinline()
|
||||
]]
|
||||
{
|
||||
float ix=math::floor(mxp_p.x);
|
||||
float iy=math::floor(mxp_p.y);
|
||||
float iz=math::floor(mxp_p.z);
|
||||
int X = int(ix);
|
||||
int Y = int(iy);
|
||||
int Z = int(iz);
|
||||
float fx = mxp_p.x-ix;
|
||||
float fy = mxp_p.y-iy;
|
||||
float fz = mxp_p.z-iz;
|
||||
float u = mx_fade(fx);
|
||||
float v = mx_fade(fy);
|
||||
float w = mx_fade(fz);
|
||||
float3 result = mx_trilerp_float3(
|
||||
mx_gradient_float3(mx_hash_int3(X , Y , Z ), fx , fy , fz ),
|
||||
mx_gradient_float3(mx_hash_int3(X+1, Y , Z ), fx-1.0, fy , fz ),
|
||||
mx_gradient_float3(mx_hash_int3(X , Y+1, Z ), fx , fy-1.0, fz ),
|
||||
mx_gradient_float3(mx_hash_int3(X+1, Y+1, Z ), fx-1.0, fy-1.0, fz ),
|
||||
mx_gradient_float3(mx_hash_int3(X , Y , Z+1), fx , fy , fz-1.0),
|
||||
mx_gradient_float3(mx_hash_int3(X+1, Y , Z+1), fx-1.0, fy , fz-1.0),
|
||||
mx_gradient_float3(mx_hash_int3(X , Y+1, Z+1), fx , fy-1.0, fz-1.0),
|
||||
mx_gradient_float3(mx_hash_int3(X+1, Y+1, Z+1), fx-1.0, fy-1.0, fz-1.0),
|
||||
u, v, w);
|
||||
return mx_gradient_scale3d_float3(result);
|
||||
}
|
||||
|
||||
export float mx_cell_noise_float(float mxp_p)
|
||||
[[
|
||||
anno::noinline()
|
||||
]]
|
||||
{
|
||||
int ix = math::floor(mxp_p);
|
||||
return mx_bits_to_01(mx_hash_int(ix));
|
||||
}
|
||||
|
||||
export float mx_cell_noise_float(
|
||||
float2 mxp_p = swizzle::xy( ::state::texture_coordinate(0)))
|
||||
[[
|
||||
anno::noinline()
|
||||
]]
|
||||
{
|
||||
int ix = math::floor(mxp_p.x);
|
||||
int iy = math::floor(mxp_p.y);
|
||||
return mx_bits_to_01(mx_hash_int(ix, iy));
|
||||
}
|
||||
|
||||
export float mx_cell_noise_float(
|
||||
float3 mxp_p = state::transform_point(state::coordinate_internal, state::coordinate_object, state::position()))
|
||||
[[
|
||||
anno::noinline()
|
||||
]]
|
||||
{
|
||||
int ix = math::floor(mxp_p.x);
|
||||
int iy = math::floor(mxp_p.y);
|
||||
int iz = math::floor(mxp_p.z);
|
||||
return mx_bits_to_01(mx_hash_int(ix, iy, iz));
|
||||
}
|
||||
|
||||
export float mx_cell_noise_float(float4 mxp_p)
|
||||
[[
|
||||
anno::noinline()
|
||||
]]
|
||||
{
|
||||
int ix = math::floor(mxp_p.x);
|
||||
int iy = math::floor(mxp_p.y);
|
||||
int iz = math::floor(mxp_p.z);
|
||||
int iw = math::floor(mxp_p.w);
|
||||
return mx_bits_to_01(mx_hash_int(ix, iy, iz, iw));
|
||||
}
|
||||
|
||||
export float3 mx_cell_noise_float3(float mxp_p)
|
||||
[[
|
||||
anno::noinline()
|
||||
]]
|
||||
{
|
||||
int ix = math::floor(mxp_p);
|
||||
return float3(
|
||||
mx_bits_to_01(mx_hash_int(ix, 0)),
|
||||
mx_bits_to_01(mx_hash_int(ix, 1)),
|
||||
mx_bits_to_01(mx_hash_int(ix, 2))
|
||||
);
|
||||
}
|
||||
|
||||
export float3 mx_cell_noise_float3(
|
||||
float2 mxp_p = swizzle::xy( ::state::texture_coordinate(0)))
|
||||
[[
|
||||
anno::noinline()
|
||||
]]
|
||||
{
|
||||
int ix = math::floor(mxp_p.x);
|
||||
int iy = math::floor(mxp_p.y);
|
||||
return float3(
|
||||
mx_bits_to_01(mx_hash_int(ix, iy, 0)),
|
||||
mx_bits_to_01(mx_hash_int(ix, iy, 1)),
|
||||
mx_bits_to_01(mx_hash_int(ix, iy, 2))
|
||||
);
|
||||
}
|
||||
|
||||
export float3 mx_cell_noise_float3(
|
||||
float3 mxp_p = state::transform_point(state::coordinate_internal, state::coordinate_object, state::position()))
|
||||
[[
|
||||
anno::noinline()
|
||||
]]
|
||||
{
|
||||
int ix = math::floor(mxp_p.x);
|
||||
int iy = math::floor(mxp_p.y);
|
||||
int iz = math::floor(mxp_p.z);
|
||||
return float3(
|
||||
mx_bits_to_01(mx_hash_int(ix, iy, iz, 0)),
|
||||
mx_bits_to_01(mx_hash_int(ix, iy, iz, 1)),
|
||||
mx_bits_to_01(mx_hash_int(ix, iy, iz, 2))
|
||||
);
|
||||
}
|
||||
|
||||
export float3 mx_cell_noise_float3(float4 mxp_p)
|
||||
[[
|
||||
anno::noinline()
|
||||
]]
|
||||
{
|
||||
int ix = math::floor(mxp_p.x);
|
||||
int iy = math::floor(mxp_p.y);
|
||||
int iz = math::floor(mxp_p.z);
|
||||
int iw = math::floor(mxp_p.w);
|
||||
return float3(
|
||||
mx_bits_to_01(mx_hash_int(ix, iy, iz, iw, 0)),
|
||||
mx_bits_to_01(mx_hash_int(ix, iy, iz, iw, 1)),
|
||||
mx_bits_to_01(mx_hash_int(ix, iy, iz, iw, 2))
|
||||
);
|
||||
}
|
||||
|
||||
export float mx_fractal_noise_float(
|
||||
float3 mxp_p = state::transform_point(state::coordinate_internal, state::coordinate_object, state::position()),
|
||||
int mxp_octaves = 3,
|
||||
float mxp_lacunarity = 2.0,
|
||||
float mxp_diminish= 0.5)
|
||||
[[
|
||||
anno::noinline()
|
||||
]]
|
||||
{
|
||||
float result = 0.0;
|
||||
float amplitude = 1.0;
|
||||
for (int i = 0; i < mxp_octaves; ++i)
|
||||
{
|
||||
result += amplitude * mx_perlin_noise_float(mxp_p);
|
||||
amplitude *= mxp_diminish;
|
||||
mxp_p *= mxp_lacunarity;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export float3 mx_fractal_noise_float3(
|
||||
float3 mxp_p = state::transform_point(state::coordinate_internal, state::coordinate_object, state::position()),
|
||||
int mxp_octaves = 3,
|
||||
float mxp_lacunarity = 2.0,
|
||||
float mxp_diminish= 0.5)
|
||||
[[
|
||||
anno::noinline()
|
||||
]]
|
||||
{
|
||||
float3 result = float3(0.0);
|
||||
float amplitude = 1.0;
|
||||
for (int i = 0; i < mxp_octaves; ++i)
|
||||
{
|
||||
result += amplitude * mx_perlin_noise_float3(mxp_p);
|
||||
amplitude *= mxp_diminish;
|
||||
mxp_p *= mxp_lacunarity;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export float2 mx_fractal_noise_float2(
|
||||
float3 mxp_p = state::transform_point(state::coordinate_internal, state::coordinate_object, state::position()),
|
||||
int mxp_octaves = 3,
|
||||
float mxp_lacunarity = 2.0,
|
||||
float mxp_diminish= 0.5)
|
||||
[[
|
||||
anno::noinline()
|
||||
]]
|
||||
{
|
||||
return float2(mx_fractal_noise_float(mxp_p, mxp_octaves, mxp_lacunarity, mxp_diminish),
|
||||
mx_fractal_noise_float(mxp_p+float3(19, 193, 17), mxp_octaves, mxp_lacunarity, mxp_diminish));
|
||||
}
|
||||
|
||||
export float4 mx_fractal_noise_float4(
|
||||
float3 mxp_p = state::transform_point(state::coordinate_internal, state::coordinate_object, state::position()),
|
||||
int mxp_octaves = 3,
|
||||
float mxp_lacunarity = 2.0,
|
||||
float mxp_diminish= 0.5)
|
||||
[[
|
||||
anno::noinline()
|
||||
]]
|
||||
{
|
||||
|
||||
float3 c = mx_fractal_noise_float3(mxp_p, mxp_octaves, mxp_lacunarity, mxp_diminish);
|
||||
float a = mx_fractal_noise_float(mxp_p+float3(19, 193, 17), mxp_octaves, mxp_lacunarity, mxp_diminish);
|
||||
return float4(c.x, c.y, c.z, a);
|
||||
}
|
||||
|
||||
float mx_worley_distance2(float2 p, int x, int y, int xoff, int yoff, float jitter, int metric)
|
||||
{
|
||||
float3 tmp = mx_cell_noise_float3(float2(x+xoff, y+yoff));
|
||||
float2 off = float2(tmp.x, tmp.y);
|
||||
|
||||
off -= 0.5f;
|
||||
off *= jitter;
|
||||
off += 0.5f;
|
||||
|
||||
float2 cellpos = float2(float(x), float(y)) + off;
|
||||
float2 diff = cellpos - p;
|
||||
if (metric == 2)
|
||||
return math::abs(diff.x) + math::abs(diff.y); // Manhattan distance
|
||||
if (metric == 3)
|
||||
return math::max(math::abs(diff.x), math::abs(diff.y)); // Chebyshev distance
|
||||
// Either Euclidian or Distance^2
|
||||
return math::dot(diff, diff);
|
||||
}
|
||||
|
||||
float mx_worley_distance3(float3 p, int x, int y, int z, int xoff, int yoff, int zoff, float jitter, int metric)
|
||||
{
|
||||
float3 off = mx_cell_noise_float3(float3(x+xoff, y+yoff, z+zoff));
|
||||
|
||||
off -= 0.5f;
|
||||
off *= jitter;
|
||||
off += 0.5f;
|
||||
|
||||
float3 cellpos = float3(float(x), float(y), float(z)) + off;
|
||||
float3 diff = cellpos - p;
|
||||
if (metric == 2)
|
||||
return math::abs(diff.x) + math::abs(diff.y) + math::abs(diff.z); // Manhattan distance
|
||||
if (metric == 3)
|
||||
return math::max(math::max(math::abs(diff.x), math::abs(diff.y)), math::abs(diff.z)); // Chebyshev distance
|
||||
// Either Euclidian or Distance^2
|
||||
return math::dot(diff, diff);
|
||||
}
|
||||
|
||||
export float mx_worley_noise_float(float2 p, float jitter, int metric)
|
||||
{
|
||||
float ix = math::floor(p.x);
|
||||
float iy = math::floor(p.y);
|
||||
int X = int(ix);
|
||||
int Y = int(iy);
|
||||
float2 localpos = float2(p.x-ix, p.y-iy);
|
||||
|
||||
float sqdist = 1e6f; // Some big number for jitter > 1 (not all GPUs may be IEEE)
|
||||
for (int x = -1; x <= 1; ++x)
|
||||
{
|
||||
for (int y = -1; y <= 1; ++y)
|
||||
{
|
||||
float dist = mx_worley_distance2(localpos, x, y, X, Y, jitter, metric);
|
||||
sqdist = math::min(sqdist, dist);
|
||||
}
|
||||
}
|
||||
if (metric == 0)
|
||||
sqdist = math::sqrt(sqdist);
|
||||
return sqdist;
|
||||
}
|
||||
|
||||
export float2 mx_worley_noise_float2(float2 p, float jitter, int metric)
|
||||
{
|
||||
float ix = math::floor(p.x);
|
||||
float iy = math::floor(p.y);
|
||||
int X = int(ix);
|
||||
int Y = int(iy);
|
||||
float2 localpos = float2(p.x-ix, p.y-iy);
|
||||
|
||||
float2 sqdist = float2(1e6f, 1e6f);
|
||||
for (int x = -1; x <= 1; ++x)
|
||||
{
|
||||
for (int y = -1; y <= 1; ++y)
|
||||
{
|
||||
float dist = mx_worley_distance2(localpos, x, y, X, Y, jitter, metric);
|
||||
if (dist < sqdist.x)
|
||||
{
|
||||
sqdist.y = sqdist.x;
|
||||
sqdist.x = dist;
|
||||
}
|
||||
else if (dist < sqdist.y)
|
||||
{
|
||||
sqdist.y = dist;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (metric == 0)
|
||||
sqdist = math::sqrt(sqdist);
|
||||
return sqdist;
|
||||
}
|
||||
|
||||
export float3 mx_worley_noise_float3(float2 p, float jitter, int metric)
|
||||
{
|
||||
float ix = math::floor(p.x);
|
||||
float iy = math::floor(p.y);
|
||||
int X = int(ix);
|
||||
int Y = int(iy);
|
||||
float2 localpos = float2(p.x-ix, p.y-iy);
|
||||
|
||||
float3 sqdist = float3(1e6f, 1e6f, 1e6f);
|
||||
for (int x = -1; x <= 1; ++x)
|
||||
{
|
||||
for (int y = -1; y <= 1; ++y)
|
||||
{
|
||||
float dist = mx_worley_distance2(localpos, x, y, X, Y, jitter, metric);
|
||||
if (dist < sqdist.x)
|
||||
{
|
||||
sqdist.z = sqdist.y;
|
||||
sqdist.y = sqdist.x;
|
||||
sqdist.x = dist;
|
||||
}
|
||||
else if (dist < sqdist.y)
|
||||
{
|
||||
sqdist.z = sqdist.y;
|
||||
sqdist.y = dist;
|
||||
}
|
||||
else if (dist < sqdist.z)
|
||||
{
|
||||
sqdist.z = dist;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (metric == 0)
|
||||
sqdist = math::sqrt(sqdist);
|
||||
return sqdist;
|
||||
}
|
||||
|
||||
export float mx_worley_noise_float(float3 p, float jitter, int metric)
|
||||
{
|
||||
float ix = math::floor(p.x);
|
||||
float iy = math::floor(p.y);
|
||||
float iz = math::floor(p.z);
|
||||
int X = int(ix);
|
||||
int Y = int(iy);
|
||||
int Z = int(iz);
|
||||
float3 localpos = float3(p.x-ix, p.y-iy, p.z-iz);
|
||||
|
||||
float sqdist = 1e6f;
|
||||
for (int x = -1; x <= 1; ++x)
|
||||
{
|
||||
for (int y = -1; y <= 1; ++y)
|
||||
{
|
||||
for (int z = -1; z <= 1; ++z)
|
||||
{
|
||||
float dist = mx_worley_distance3(localpos, x, y, z, X, Y, Z, jitter, metric);
|
||||
sqdist = math::min(sqdist, dist);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (metric == 0)
|
||||
sqdist = math::sqrt(sqdist);
|
||||
return sqdist;
|
||||
}
|
||||
|
||||
export float2 mx_worley_noise_float2(float3 p, float jitter, int metric)
|
||||
{
|
||||
float ix = math::floor(p.x);
|
||||
float iy = math::floor(p.y);
|
||||
float iz = math::floor(p.z);
|
||||
int X = int(ix);
|
||||
int Y = int(iy);
|
||||
int Z = int(iz);
|
||||
float3 localpos = float3(p.x-ix, p.y-iy, p.z-iz);
|
||||
|
||||
float2 sqdist = float2(1e6f, 1e6f);
|
||||
for (int x = -1; x <= 1; ++x)
|
||||
{
|
||||
for (int y = -1; y <= 1; ++y)
|
||||
{
|
||||
for (int z = -1; z <= 1; ++z)
|
||||
{
|
||||
float dist = mx_worley_distance3(localpos, x, y, z, X, Y, Z, jitter, metric);
|
||||
if (dist < sqdist.x)
|
||||
{
|
||||
sqdist.y = sqdist.x;
|
||||
sqdist.x = dist;
|
||||
}
|
||||
else if (dist < sqdist.y)
|
||||
{
|
||||
sqdist.y = dist;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (metric == 0)
|
||||
sqdist = math::sqrt(sqdist);
|
||||
return sqdist;
|
||||
}
|
||||
|
||||
export float3 mx_worley_noise_float3(float3 p, float jitter, int metric)
|
||||
{
|
||||
float ix = math::floor(p.x);
|
||||
float iy = math::floor(p.y);
|
||||
float iz = math::floor(p.z);
|
||||
int X = int(ix);
|
||||
int Y = int(iy);
|
||||
int Z = int(iz);
|
||||
float3 localpos = float3(p.x-ix, p.y-iy, p.z-iz);
|
||||
|
||||
float3 sqdist = float3(1e6f, 1e6f, 1e6f);
|
||||
for (int x = -1; x <= 1; ++x)
|
||||
{
|
||||
for (int y = -1; y <= 1; ++y)
|
||||
{
|
||||
for (int z = -1; z <= 1; ++z)
|
||||
{
|
||||
float dist = mx_worley_distance3(localpos, x, y, z, X, Y, Z, jitter, metric);
|
||||
if (dist < sqdist.x)
|
||||
{
|
||||
sqdist.z = sqdist.y;
|
||||
sqdist.y = sqdist.x;
|
||||
sqdist.x = dist;
|
||||
}
|
||||
else if (dist < sqdist.y)
|
||||
{
|
||||
sqdist.z = sqdist.y;
|
||||
sqdist.y = dist;
|
||||
}
|
||||
else if (dist < sqdist.z)
|
||||
{
|
||||
sqdist.z = dist;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (metric == 0)
|
||||
sqdist = math::sqrt(sqdist);
|
||||
return sqdist;
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// MDL implementation of all types and nodes of
|
||||
// MaterialX Physically-Based Shading Nodes
|
||||
// Document v1.37 REV2, July 16, 2019 (Revised October 17, 2019)
|
||||
// see www.materialx.org
|
||||
// in
|
||||
// NVIDIA Material Definition Language 1.8
|
||||
// Language Specification
|
||||
// Document version 1.8.2, May 24, 2023
|
||||
// www.nvidia.com/mdl
|
||||
|
||||
mdl 1.8;
|
||||
|
||||
// forward the latest version
|
||||
export using .::pbrlib_1_8 import *;
|
||||
Vendored
+1009
File diff suppressed because it is too large
Load Diff
Vendored
+259
@@ -0,0 +1,259 @@
|
||||
/*
|
||||
* Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// MDL implementation of all types and nodes of
|
||||
// MaterialX Physically-Based Shading Nodes
|
||||
// Document v1.37 REV2, July 16, 2019 (Revised October 17, 2019)
|
||||
// see www.materialx.org
|
||||
// in
|
||||
// NVIDIA Material Definition Language 1.7
|
||||
// Language Specification
|
||||
// Document version 1.7.2, January 17, 2022
|
||||
// www.nvidia.com/mdl
|
||||
|
||||
mdl 1.7;
|
||||
|
||||
// Changes since MDL 1.6
|
||||
// - Support for unbounded_mix to implement add_bsdf, add_edf, and add_vdf
|
||||
// - Support for df::sheen_bsdf with a custom base BSDF
|
||||
// - Support for df::directional_factor on EDFs to implement generalized_schlick_edf
|
||||
// - Support for emission on VDFs
|
||||
|
||||
import ::anno::*;
|
||||
import ::df::*;
|
||||
import ::math::*;
|
||||
import ::state::*;
|
||||
|
||||
// forward all unchanged definitions from the previous version
|
||||
export using .::pbrlib_1_6 import mx_scatter_mode;
|
||||
export using .::pbrlib_1_6 import mx_map_scatter_mode;
|
||||
export using .::pbrlib_1_6 import mx_oren_nayar_diffuse_bsdf;
|
||||
export using .::pbrlib_1_6 import mx_burley_diffuse_bsdf;
|
||||
export using .::pbrlib_1_6 import mx_translucent_bsdf;
|
||||
export using .::pbrlib_1_6 import mx_dielectric_bsdf;
|
||||
export using .::pbrlib_1_6 import mx_conductor_bsdf;
|
||||
export using .::pbrlib_1_6 import mx_generalized_schlick_bsdf;
|
||||
export using .::pbrlib_1_6 import mx_subsurface_bsdf;
|
||||
export using .::pbrlib_1_6 import mx_thin_film_bsdf;
|
||||
export using .::pbrlib_1_6 import mx_uniform_edf;
|
||||
export using .::pbrlib_1_6 import mx_conical_edf;
|
||||
export using .::pbrlib_1_6 import mx_measured_edf;
|
||||
export using .::pbrlib_1_6 import mx_absorption_vdf;
|
||||
export using .::pbrlib_1_6 import mx_anisotropic_vdf;
|
||||
export using .::pbrlib_1_6 import mx_surface;
|
||||
export using .::pbrlib_1_6 import mx_thin_surface;
|
||||
export using .::pbrlib_1_6 import mx_light;
|
||||
export using .::pbrlib_1_6 import mx_displacement_float;
|
||||
export using .::pbrlib_1_6 import mx_displacement_vector3;
|
||||
export using .::pbrlib_1_6 import volume_mix_return;
|
||||
export using .::pbrlib_1_6 import volume_mix;
|
||||
export using .::pbrlib_1_6 import mx_mix_bsdf;
|
||||
export using .::pbrlib_1_6 import mx_mix_vdf;
|
||||
export using .::pbrlib_1_6 import mx_multiply_bsdf_color3;
|
||||
export using .::pbrlib_1_6 import mx_multiply_bsdf_float;
|
||||
export using .::pbrlib_1_6 import mx_multiply_edf_color3;
|
||||
export using .::pbrlib_1_6 import mx_multiply_edf_float;
|
||||
export using .::pbrlib_1_6 import mx_multiply_vdf_color3;
|
||||
export using .::pbrlib_1_6 import mx_multiply_vdf_float;
|
||||
export using .::pbrlib_1_6 import mx_roughness_anisotropy;
|
||||
export using .::pbrlib_1_6 import mx_roughness_dual;
|
||||
export using .::pbrlib_1_6 import mx_blackbody;
|
||||
export using .::pbrlib_1_6 import mx_artistic_ior__result ;
|
||||
export using .::pbrlib_1_6 import mx_artistic_ior;
|
||||
|
||||
|
||||
|
||||
// To match with OSL, the sheen weight is scaled with average color as approximation of albedo.
|
||||
// OSL uses the layer operator which mixes based on albedo.
|
||||
export material mx_sheen_bsdf(
|
||||
float mxp_weight = 1.0,
|
||||
color mxp_color = color(1.0),
|
||||
float mxp_roughness = 0.2,
|
||||
float3 mxp_normal = state::normal(),
|
||||
material mxp_base = material(
|
||||
surface: material_surface(
|
||||
scattering: df::diffuse_reflection_bsdf(
|
||||
))) [[ anno::usage( "materialx:bsdf") ]]
|
||||
) [[
|
||||
anno::usage( "materialx:bsdf")
|
||||
]]
|
||||
= material(
|
||||
surface: material_surface(
|
||||
// using the mix seems to fit OSL best, at least in the test cases
|
||||
scattering: df::weighted_layer(
|
||||
weight: math::average(mxp_color) * mxp_weight,
|
||||
layer: df::sheen_bsdf(
|
||||
roughness: mxp_roughness,
|
||||
tint: mxp_color,
|
||||
multiscatter_tint: color(1.0),
|
||||
multiscatter: mxp_base.surface.scattering
|
||||
),
|
||||
base: mxp_base.surface.scattering,
|
||||
normal: mxp_normal)),
|
||||
// we need to carry volume properties along for SSS
|
||||
ior: mxp_base.ior,
|
||||
volume: mxp_base.volume
|
||||
);
|
||||
|
||||
|
||||
// NOTE: Adding two BSDFs is not supported in MDL, the generator would best
|
||||
// analyze the context for mixing weights and replace the add with a mix.
|
||||
// The provided implementation just mixes the BSDFs with equal weight.
|
||||
export material mx_add_bsdf(
|
||||
material mxp_in1 = material() [[ anno::usage( "materialx:bsdf") ]],
|
||||
material mxp_in2 = material() [[ anno::usage( "materialx:bsdf") ]]
|
||||
) [[
|
||||
anno::usage( "materialx:bsdf")
|
||||
]]
|
||||
= let {
|
||||
volume_mix_return v = volume_mix(
|
||||
mxp_in1.volume.scattering_coefficient, 1.0f,
|
||||
mxp_in2.volume.scattering_coefficient, 1.0f);
|
||||
} in material(
|
||||
surface: material_surface(
|
||||
scattering: df::unbounded_mix(
|
||||
df::bsdf_component[](
|
||||
df::bsdf_component( 1.0, mxp_in1.surface.scattering),
|
||||
df::bsdf_component( 1.0, mxp_in2.surface.scattering)
|
||||
)
|
||||
)
|
||||
),
|
||||
// we need to carry volume properties along for SSS
|
||||
volume: material_volume(
|
||||
scattering: df::unbounded_mix(
|
||||
df::vdf_component[](
|
||||
df::vdf_component( v.mix_weight1, mxp_in1.volume.scattering),
|
||||
df::vdf_component( 1.0 - v.mix_weight1, mxp_in2.volume.scattering))
|
||||
),
|
||||
absorption_coefficient: mxp_in1.volume.absorption_coefficient +
|
||||
mxp_in2.volume.absorption_coefficient,
|
||||
scattering_coefficient: v.scattering_coefficient
|
||||
)
|
||||
);
|
||||
|
||||
// NOTE: Adding two EDFs is not supported in MDL, the generator would best
|
||||
// analyze the context for mixing weights and replace the add with a mix.
|
||||
// The provided implementation just mixes the EDFs with equal weight
|
||||
// and adds the intensities.
|
||||
export material mx_add_edf(
|
||||
material mxp_in1 = material() [[ anno::usage( "materialx:edf") ]],
|
||||
material mxp_in2 = material() [[ anno::usage( "materialx:edf") ]]
|
||||
) [[
|
||||
anno::usage( "materialx:edf")
|
||||
]]
|
||||
= material(
|
||||
surface: material_surface(
|
||||
emission: material_emission(
|
||||
emission: df::unbounded_mix(
|
||||
df::edf_component[](
|
||||
df::edf_component( 1.0, mxp_in1.surface.emission.emission),
|
||||
df::edf_component( 1.0, mxp_in2.surface.emission.emission))
|
||||
),
|
||||
intensity: mxp_in1.surface.emission.intensity + mxp_in2.surface.emission.intensity
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
export material mx_mix_edf(
|
||||
material mxp_fg = material() [[ anno::usage( "materialx:edf") ]],
|
||||
material mxp_bg = material() [[ anno::usage( "materialx:edf") ]],
|
||||
float mxp_mix = 0.0
|
||||
) [[
|
||||
anno::usage( "materialx:edf")
|
||||
]]
|
||||
= let {
|
||||
float mix = math::saturate(mxp_mix);
|
||||
} in material(
|
||||
surface: material_surface(
|
||||
emission: material_emission(
|
||||
emission: df::unbounded_mix(
|
||||
df::edf_component[](
|
||||
df::edf_component( mix, mxp_fg.surface.emission.emission),
|
||||
df::edf_component( 1.0 - mix, mxp_bg.surface.emission.emission))
|
||||
),
|
||||
intensity: mix * mxp_fg.surface.emission.intensity +
|
||||
(1.0 - mix) * mxp_bg.surface.emission.intensity
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// NOTE: Adding two VDFs is not supported in MDL, the generator would best
|
||||
// analyze the context for mixing weights and replace the add with a mix.
|
||||
// The provided implementation just mixes the VDFs with equal weight.
|
||||
export material mx_add_vdf(
|
||||
material mxp_in1 = material() [[ anno::usage( "materialx:vdf") ]],
|
||||
material mxp_in2 = material() [[ anno::usage( "materialx:vdf") ]]
|
||||
) [[
|
||||
anno::usage( "materialx:vdf")
|
||||
]]
|
||||
= let {
|
||||
volume_mix_return v = volume_mix(
|
||||
mxp_in1.volume.scattering_coefficient, 1.0f,
|
||||
mxp_in2.volume.scattering_coefficient, 1.0f);
|
||||
} in material(
|
||||
// assuming mixing the IOR is the best we can do here
|
||||
ior: 0.5 * mxp_in1.ior + 0.5 * mxp_in2.ior,
|
||||
volume: material_volume(
|
||||
scattering: df::unbounded_mix(
|
||||
df::vdf_component[](
|
||||
df::vdf_component( v.mix_weight1, mxp_in1.volume.scattering),
|
||||
df::vdf_component( 1.0 - v.mix_weight1, mxp_in2.volume.scattering))
|
||||
),
|
||||
absorption_coefficient: mxp_in1.volume.absorption_coefficient +
|
||||
mxp_in2.volume.absorption_coefficient,
|
||||
scattering_coefficient: v.scattering_coefficient
|
||||
)
|
||||
);
|
||||
|
||||
export material mx_generalized_schlick_edf(
|
||||
color mxp_color0 = color(1.0),
|
||||
color mxp_color90 = color(1.0),
|
||||
float mxp_exponent = 5.0,
|
||||
material mxp_base = material() [[ anno::usage( "materialx:bsdf") ]]
|
||||
) [[
|
||||
anno::usage( "materialx:edf")
|
||||
]]
|
||||
= material(
|
||||
thin_walled: mxp_base.thin_walled,
|
||||
surface: material_surface(
|
||||
scattering: mxp_base.surface.scattering,
|
||||
emission: material_emission(
|
||||
emission: df::directional_factor(mxp_color0, mxp_color90, mxp_exponent, mxp_base.surface.emission.emission),
|
||||
intensity: mxp_base.surface.emission.intensity,
|
||||
mode: mxp_base.surface.emission.mode)
|
||||
),
|
||||
backface: mxp_base.backface,
|
||||
ior: mxp_base.ior,
|
||||
volume: mxp_base.volume,
|
||||
geometry: mxp_base.geometry,
|
||||
hair: mxp_base.hair
|
||||
);
|
||||
|
||||
// MDL 1.7, Volumes do support emission, but not as EDF, just emission intensity.
|
||||
// A uniform emission DF is the only practical DF here.
|
||||
export material mx_volume(
|
||||
material mxp_vdf = material() [[ anno::usage( "materialx:vdf") ]],
|
||||
material mxp_edf = material() [[ anno::usage( "materialx:edf") ]]
|
||||
) [[
|
||||
anno::usage( "materialx:volumeshader")
|
||||
]]
|
||||
= material(
|
||||
volume: material_volume(
|
||||
absorption_coefficient: mxp_vdf.volume.absorption_coefficient,
|
||||
scattering_coefficient: mxp_vdf.volume.scattering_coefficient,
|
||||
emission_intensity: mxp_edf.surface.emission.intensity
|
||||
)
|
||||
);
|
||||
Vendored
+36
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// MDL implementation of all types and nodes of
|
||||
// MaterialX Physically-Based Shading Nodes
|
||||
// Document v1.37 REV2, July 16, 2019 (Revised October 17, 2019)
|
||||
// see www.materialx.org
|
||||
// in
|
||||
// NVIDIA Material Definition Language 1.8
|
||||
// Language Specification
|
||||
// Document version 1.8.2, May 24, 2023
|
||||
// www.nvidia.com/mdl
|
||||
|
||||
mdl 1.8;
|
||||
|
||||
// Changes since MDL 1.7
|
||||
// - Support thin-film on custom curve layer to improve generalized_schlick_bsdf,
|
||||
// no new implementation required
|
||||
|
||||
// forward all unchanged definitions from the previous version
|
||||
export using .::pbrlib_1_7 import *;
|
||||
|
||||
// without changing any source code
|
||||
+181
@@ -0,0 +1,181 @@
|
||||
//
|
||||
// Copyright Contributors to the MaterialX Project
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
mdl 1.6;
|
||||
|
||||
import ::math::*;
|
||||
|
||||
import .::core::*;
|
||||
|
||||
// Restrict to 7x7 kernel size for performance reasons
|
||||
export const int MX_MAX_SAMPLE_COUNT = 49;
|
||||
// Size of all weights for all levels (including level 1)
|
||||
export const int MX_WEIGHT_ARRAY_SIZE = 84;
|
||||
|
||||
// This is not available in MDL so just use a "small" number
|
||||
float2 dFdx(float2 uv)
|
||||
{
|
||||
return uv+0.0001;
|
||||
}
|
||||
|
||||
float2 dFdy(float2 uv)
|
||||
{
|
||||
return uv+0.0001;
|
||||
}
|
||||
|
||||
//
|
||||
// Function to compute the sample size relative to a texture coordinate
|
||||
//
|
||||
export float2 mx_compute_sample_size_uv(float2 uv, float filterSize, float filterOffset)
|
||||
{
|
||||
float2 derivUVx = dFdx(uv) * 0.5f;
|
||||
float2 derivUVy = dFdy(uv) * 0.5f;
|
||||
float derivX = ::math::abs(derivUVx.x) + ::math::abs(derivUVy.x);
|
||||
float derivY = ::math::abs(derivUVx.y) + ::math::abs(derivUVy.y);
|
||||
float sampleSizeU = 2.0f * filterSize * derivX + filterOffset;
|
||||
if (sampleSizeU < 1.0E-05f)
|
||||
sampleSizeU = 1.0E-05f;
|
||||
float sampleSizeV = 2.0f * filterSize * derivY + filterOffset;
|
||||
if (sampleSizeV < 1.0E-05f)
|
||||
sampleSizeV = 1.0E-05f;
|
||||
return float2(sampleSizeU, sampleSizeV);
|
||||
}
|
||||
|
||||
//
|
||||
// Compute a normal mapped to 0..1 space based on a set of input
|
||||
// samples using a Sobel filter.
|
||||
//
|
||||
export float3 mx_normal_from_samples_sobel(float[9] S, float scale)
|
||||
{
|
||||
float nx = S[0] - S[2] + (2.0*S[3]) - (2.0*S[5]) + S[6] - S[8];
|
||||
float ny = S[0] + (2.0*S[1]) + S[2] - S[6] - (2.0*S[7]) - S[8];
|
||||
float nz = scale * ::math::sqrt(1.0 - nx*nx - ny*ny);
|
||||
float3 norm = ::math::normalize(float3(nx, ny, nz));
|
||||
return (norm + 1.0) * 0.5;
|
||||
}
|
||||
|
||||
// Kernel weights for box filter
|
||||
export float[MX_MAX_SAMPLE_COUNT] mx_get_box_weights(int filterSize)
|
||||
{
|
||||
float[MX_MAX_SAMPLE_COUNT] W;
|
||||
int sampleCount = filterSize*filterSize;
|
||||
float value = 1.0 / float(sampleCount);
|
||||
for (int i=0; i<sampleCount; i++)
|
||||
{
|
||||
W[i] = value;
|
||||
}
|
||||
return W;
|
||||
}
|
||||
|
||||
// Kernel weights for Gaussian filter. Sigma is assumed to be 1.
|
||||
export float[MX_MAX_SAMPLE_COUNT] mx_get_gaussian_weights(int filterSize)
|
||||
{
|
||||
float[MX_MAX_SAMPLE_COUNT] W;
|
||||
if (filterSize >= 7)
|
||||
{
|
||||
W[0] = 0.000036; W[1] = 0.000363; W[2] = 0.001446; W[3] = 0.002291; W[4] = 0.001446; W[5] = 0.000363; W[6] = 0.000036;
|
||||
W[7] = 0.000363; W[8] = 0.003676; W[9] = 0.014662; W[10] = 0.023226; W[11] = 0.014662; W[12] = 0.003676; W[13] = 0.000363;
|
||||
W[14] = 0.001446; W[15] = 0.014662; W[16] = 0.058488; W[17] = 0.092651; W[18] = 0.058488; W[19] = 0.014662; W[20] = 0.001446;
|
||||
W[21] = 0.002291; W[22] = 0.023226; W[23] = 0.092651; W[24] = 0.146768; W[25] = 0.092651; W[26] = 0.023226; W[27] = 0.002291;
|
||||
W[28] = 0.001446; W[29] = 0.014662; W[30] = 0.058488; W[31] = 0.092651; W[32] = 0.058488; W[33] = 0.014662; W[34] = 0.001446;
|
||||
W[35] = 0.000363; W[36] = 0.003676; W[37] = 0.014662; W[38] = 0.023226; W[39] = 0.014662; W[40] = 0.003676; W[41] = 0.000363;
|
||||
W[42] = 0.000036; W[43] = 0.000363; W[44] = 0.001446; W[45] = 0.002291; W[46] = 0.001446; W[47] = 0.000363; W[48] = 0.000036;
|
||||
}
|
||||
else if (filterSize >= 5)
|
||||
{
|
||||
W[0] = 0.003765; W[1] = 0.015019; W[2] = 0.023792; W[3] = 0.015019; W[4] = 0.003765;
|
||||
W[5] = 0.015019; W[6] = 0.059912; W[7] = 0.094907; W[8] = 0.059912; W[9] = 0.015019;
|
||||
W[10] = 0.023792; W[11] = 0.094907; W[12] = 0.150342; W[13] = 0.094907; W[14] = 0.023792;
|
||||
W[15] = 0.015019; W[16] = 0.059912; W[17] = 0.094907; W[18] = 0.059912; W[19] = 0.015019;
|
||||
W[20] = 0.003765; W[21] = 0.015019; W[22] = 0.023792; W[23] = 0.015019; W[24] = 0.003765;
|
||||
}
|
||||
else if (filterSize >= 3)
|
||||
{
|
||||
W[0] = 0.0625; W[1] = 0.125; W[2] = 0.0625;
|
||||
W[3] = 0.125; W[4] = 0.25; W[5] = 0.125;
|
||||
W[6] = 0.0625; W[7] = 0.125; W[8] = 0.0625;
|
||||
}
|
||||
else
|
||||
{
|
||||
W[0] = 1.0;
|
||||
}
|
||||
return W;
|
||||
}
|
||||
|
||||
//
|
||||
// Apply filter for float samples S, using weights W.
|
||||
// sampleCount should be a square of a odd number in the range { 1, 3, 5, 7 }
|
||||
//
|
||||
export float mx_convolution_float(float[MX_MAX_SAMPLE_COUNT] S, float[MX_WEIGHT_ARRAY_SIZE] W, int offset, int sampleCount)
|
||||
{
|
||||
float result = 0.0;
|
||||
for (int i = 0; i < sampleCount; i++)
|
||||
{
|
||||
result += S[i]*W[i+offset];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Apply filter for float2 samples S, using weights W.
|
||||
// sampleCount should be a square of a odd number in the range { 1, 3, 5, 7 }
|
||||
//
|
||||
export float2 mx_convolution_float2(float2[MX_MAX_SAMPLE_COUNT] S, float[MX_WEIGHT_ARRAY_SIZE] W, int offset, int sampleCount)
|
||||
{
|
||||
float2 result = float2(0.0);
|
||||
for (int i=0; i<sampleCount; i++)
|
||||
{
|
||||
result += S[i]*W[i+offset];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Apply filter for float3 samples S, using weights W.
|
||||
// sampleCount should be a square of a odd number in the range { 1, 3, 5, 7 }
|
||||
//
|
||||
export float3 mx_convolution_float3(float3[MX_MAX_SAMPLE_COUNT] S, float[MX_WEIGHT_ARRAY_SIZE] W, int offset, int sampleCount)
|
||||
{
|
||||
float3 result = float3(0.0);
|
||||
for (int i=0; i<sampleCount; i++)
|
||||
{
|
||||
result += S[i]*W[i+offset];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Apply filter for float4 samples S, using weights W.
|
||||
// sampleCount should be a square of a odd number { 1, 3, 5, 7 }
|
||||
//
|
||||
export float4 mx_convolution_float4(float4[MX_MAX_SAMPLE_COUNT] S, float[MX_WEIGHT_ARRAY_SIZE] W, int offset, int sampleCount)
|
||||
{
|
||||
float4 result = float4(0.0);
|
||||
for (int i=0; i<sampleCount; i++)
|
||||
{
|
||||
result += S[i]*W[i+offset];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export color mx_convolution_color(color[MX_MAX_SAMPLE_COUNT] S, float[MX_WEIGHT_ARRAY_SIZE] W, int offset, int sampleCount)
|
||||
{
|
||||
color result = color(0.0);
|
||||
for (int i=0; i<sampleCount; i++)
|
||||
{
|
||||
result += S[i]*W[i+offset];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export core::color4 mx_convolution_color4(core::color4[MX_MAX_SAMPLE_COUNT] S, float[MX_WEIGHT_ARRAY_SIZE] W, int offset, int sampleCount)
|
||||
{
|
||||
core::color4 result = core::mk_color4(0.0, 0.0, 0.0, 0.0);
|
||||
for (int i=0; i<sampleCount; i++)
|
||||
{
|
||||
core::mx_add(result, core::mx_multiply(S[i], W[i+offset]));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// Copyright Contributors to the MaterialX Project
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
// MDL implementation of all Standard Source Nodes of
|
||||
// MaterialX: An Open Standard for Network-Based CG Object Looks
|
||||
// Document v1.37 REV2, January 19, 2020
|
||||
// www.materialx.org
|
||||
// in
|
||||
// NVIDIA Material Definition Language 1.7
|
||||
// Language Specification
|
||||
// Document version 1.7.2, January 17, 2022
|
||||
// www.nvidia.com/mdl
|
||||
|
||||
mdl 1.8;
|
||||
|
||||
// forward the latest version
|
||||
export using .::stdlib_1_8 import *;
|
||||
Vendored
+4578
File diff suppressed because it is too large
Load Diff
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// Copyright Contributors to the MaterialX Project
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
// MDL implementation of all Standard Source Nodes of
|
||||
// MaterialX: An Open Standard for Network-Based CG Object Looks
|
||||
// Document v1.37 REV2, January 19, 2020
|
||||
// www.materialx.org
|
||||
// in
|
||||
// NVIDIA Material Definition Language 1.7
|
||||
// Language Specification
|
||||
// Document version 1.7.2, January 17, 2022
|
||||
// www.nvidia.com/mdl
|
||||
|
||||
mdl 1.7;
|
||||
|
||||
// forward all unchanged definitions from the previous version
|
||||
export using .::stdlib_1_6 import *;
|
||||
Vendored
+449
@@ -0,0 +1,449 @@
|
||||
//
|
||||
// Copyright Contributors to the MaterialX Project
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
// MDL implementation of all Standard Source Nodes of
|
||||
// MaterialX: An Open Standard for Network-Based CG Object Looks
|
||||
// Document v1.37 REV2, January 19, 2020
|
||||
// www.materialx.org
|
||||
// in
|
||||
// NVIDIA Material Definition Language 1.8
|
||||
// Language Specification
|
||||
// Document version 1.8.2, May 24, 2023
|
||||
// www.nvidia.com/mdl
|
||||
|
||||
mdl 1.8;
|
||||
|
||||
import ::anno::*;
|
||||
import ::math::*;
|
||||
import ::scene::*;
|
||||
import ::state::*;
|
||||
|
||||
import .::core::*;
|
||||
import .::noise::*;
|
||||
import .::swizzle::*;
|
||||
import .::hsv::*;
|
||||
|
||||
// Changes since MDL 1.7
|
||||
// - Scene data lookups used for PrimVar readers allow non-literal string names
|
||||
|
||||
// forward all unchanged definitions from the previous version
|
||||
export using .::stdlib_1_7 import mx_surfacematerial;
|
||||
export using .::stdlib_1_7 import mx_surface_unlit;
|
||||
export using .::stdlib_1_7 import mx_image_float;
|
||||
export using .::stdlib_1_7 import mx_image_color3;
|
||||
export using .::stdlib_1_7 import mx_image_color4;
|
||||
export using .::stdlib_1_7 import mx_image_vector2;
|
||||
export using .::stdlib_1_7 import mx_image_vector3;
|
||||
export using .::stdlib_1_7 import mx_image_vector4;
|
||||
export using .::stdlib_1_7 import mx_constant_float;
|
||||
export using .::stdlib_1_7 import mx_constant_color3;
|
||||
export using .::stdlib_1_7 import mx_constant_color4;
|
||||
export using .::stdlib_1_7 import mx_constant_vector2;
|
||||
export using .::stdlib_1_7 import mx_constant_vector3;
|
||||
export using .::stdlib_1_7 import mx_constant_vector4;
|
||||
export using .::stdlib_1_7 import mx_constant_boolean;
|
||||
export using .::stdlib_1_7 import mx_constant_integer;
|
||||
export using .::stdlib_1_7 import mx_constant_matrix33;
|
||||
export using .::stdlib_1_7 import mx_constant_matrix44;
|
||||
export using .::stdlib_1_7 import mx_constant_string;
|
||||
export using .::stdlib_1_7 import mx_constant_filename;
|
||||
export using .::stdlib_1_7 import mx_ramplr_float;
|
||||
export using .::stdlib_1_7 import mx_ramplr_color3;
|
||||
export using .::stdlib_1_7 import mx_ramplr_color4;
|
||||
export using .::stdlib_1_7 import mx_ramplr_vector2;
|
||||
export using .::stdlib_1_7 import mx_ramplr_vector3;
|
||||
export using .::stdlib_1_7 import mx_ramplr_vector4;
|
||||
export using .::stdlib_1_7 import mx_ramptb_float;
|
||||
export using .::stdlib_1_7 import mx_ramptb_color3;
|
||||
export using .::stdlib_1_7 import mx_ramptb_color4;
|
||||
export using .::stdlib_1_7 import mx_ramptb_vector2;
|
||||
export using .::stdlib_1_7 import mx_ramptb_vector3;
|
||||
export using .::stdlib_1_7 import mx_ramptb_vector4;
|
||||
export using .::stdlib_1_7 import mx_splitlr_float;
|
||||
export using .::stdlib_1_7 import mx_splitlr_color3;
|
||||
export using .::stdlib_1_7 import mx_splitlr_color4;
|
||||
export using .::stdlib_1_7 import mx_splitlr_vector2;
|
||||
export using .::stdlib_1_7 import mx_splitlr_vector3;
|
||||
export using .::stdlib_1_7 import mx_splitlr_vector4;
|
||||
export using .::stdlib_1_7 import mx_splittb_float;
|
||||
export using .::stdlib_1_7 import mx_splittb_color3;
|
||||
export using .::stdlib_1_7 import mx_splittb_color4;
|
||||
export using .::stdlib_1_7 import mx_splittb_vector2;
|
||||
export using .::stdlib_1_7 import mx_splittb_vector3;
|
||||
export using .::stdlib_1_7 import mx_splittb_vector4;
|
||||
export using .::stdlib_1_7 import mx_position_vector3;
|
||||
export using .::stdlib_1_7 import mx_normal_vector3;
|
||||
export using .::stdlib_1_7 import mx_tangent_vector3;
|
||||
export using .::stdlib_1_7 import mx_bitangent_vector3;
|
||||
export using .::stdlib_1_7 import mx_texcoord_vector2;
|
||||
export using .::stdlib_1_7 import mx_texcoord_vector3;
|
||||
export using .::stdlib_1_7 import mx_geomcolor_float;
|
||||
export using .::stdlib_1_7 import mx_geomcolor_color3;
|
||||
export using .::stdlib_1_7 import mx_geomcolor_color4;
|
||||
export using .::stdlib_1_7 import mx_ambientocclusion_float;
|
||||
export using .::stdlib_1_7 import mx_frame_float;
|
||||
export using .::stdlib_1_7 import mx_time_float;
|
||||
export using .::stdlib_1_7 import mx_modulo_color3;
|
||||
export using .::stdlib_1_7 import mx_modulo_color4;
|
||||
export using .::stdlib_1_7 import mx_modulo_color3FA;
|
||||
export using .::stdlib_1_7 import mx_modulo_color4FA;
|
||||
export using .::stdlib_1_7 import mx_invert_color4;
|
||||
export using .::stdlib_1_7 import mx_invert_color4FA;
|
||||
export using .::stdlib_1_7 import mx_absval_color4;
|
||||
export using .::stdlib_1_7 import mx_floor_color3;
|
||||
export using .::stdlib_1_7 import mx_floor_color4;
|
||||
export using .::stdlib_1_7 import mx_ceil_color3;
|
||||
export using .::stdlib_1_7 import mx_ceil_color4;
|
||||
export using .::stdlib_1_7 import mx_round_color3;
|
||||
export using .::stdlib_1_7 import mx_round_color4;
|
||||
export using .::stdlib_1_7 import mx_power_color4;
|
||||
export using .::stdlib_1_7 import mx_power_color4FA;
|
||||
export using .::stdlib_1_7 import mx_sin_float;
|
||||
export using .::stdlib_1_7 import mx_cos_float;
|
||||
export using .::stdlib_1_7 import mx_tan_float;
|
||||
export using .::stdlib_1_7 import mx_asin_float;
|
||||
export using .::stdlib_1_7 import mx_acos_float;
|
||||
export using .::stdlib_1_7 import mx_atan2_float;
|
||||
export using .::stdlib_1_7 import mx_sin_vector2;
|
||||
export using .::stdlib_1_7 import mx_cos_vector2;
|
||||
export using .::stdlib_1_7 import mx_tan_vector2;
|
||||
export using .::stdlib_1_7 import mx_asin_vector2;
|
||||
export using .::stdlib_1_7 import mx_acos_vector2;
|
||||
export using .::stdlib_1_7 import mx_atan2_vector2;
|
||||
export using .::stdlib_1_7 import mx_sin_vector3;
|
||||
export using .::stdlib_1_7 import mx_cos_vector3;
|
||||
export using .::stdlib_1_7 import mx_tan_vector3;
|
||||
export using .::stdlib_1_7 import mx_asin_vector3;
|
||||
export using .::stdlib_1_7 import mx_acos_vector3;
|
||||
export using .::stdlib_1_7 import mx_atan2_vector3;
|
||||
export using .::stdlib_1_7 import mx_sin_vector4;
|
||||
export using .::stdlib_1_7 import mx_cos_vector4;
|
||||
export using .::stdlib_1_7 import mx_tan_vector4;
|
||||
export using .::stdlib_1_7 import mx_asin_vector4;
|
||||
export using .::stdlib_1_7 import mx_acos_vector4;
|
||||
export using .::stdlib_1_7 import mx_atan2_vector4;
|
||||
export using .::stdlib_1_7 import mx_sqrt_float;
|
||||
export using .::stdlib_1_7 import mx_ln_float;
|
||||
export using .::stdlib_1_7 import mx_exp_float;
|
||||
export using .::stdlib_1_7 import mx_sqrt_vector2;
|
||||
export using .::stdlib_1_7 import mx_ln_vector2;
|
||||
export using .::stdlib_1_7 import mx_exp_vector2;
|
||||
export using .::stdlib_1_7 import mx_sqrt_vector3;
|
||||
export using .::stdlib_1_7 import mx_ln_vector3;
|
||||
export using .::stdlib_1_7 import mx_exp_vector3;
|
||||
export using .::stdlib_1_7 import mx_sqrt_vector4;
|
||||
export using .::stdlib_1_7 import mx_ln_vector4;
|
||||
export using .::stdlib_1_7 import mx_exp_vector4;
|
||||
export using .::stdlib_1_7 import mx_sign_color3;
|
||||
export using .::stdlib_1_7 import mx_sign_color4;
|
||||
export using .::stdlib_1_7 import mx_clamp_color4;
|
||||
export using .::stdlib_1_7 import mx_clamp_color4FA;
|
||||
export using .::stdlib_1_7 import mx_min_color4;
|
||||
export using .::stdlib_1_7 import mx_min_color4;
|
||||
export using .::stdlib_1_7 import mx_max_color4;
|
||||
export using .::stdlib_1_7 import mx_max_color4;
|
||||
export using .::stdlib_1_7 import mx_transformpoint_vector3;
|
||||
export using .::stdlib_1_7 import mx_transformvector_vector3;
|
||||
export using .::stdlib_1_7 import mx_transformnormal_vector3;
|
||||
export using .::stdlib_1_7 import mx_transformmatrix_vector2M3;
|
||||
export using .::stdlib_1_7 import mx_transformmatrix_vector3;
|
||||
export using .::stdlib_1_7 import mx_transformmatrix_vector3M4;
|
||||
export using .::stdlib_1_7 import mx_transformmatrix_vector4;
|
||||
export using .::stdlib_1_7 import mx_normalmap_float;
|
||||
export using .::stdlib_1_7 import mx_normalmap_vector2;
|
||||
export using .::stdlib_1_7 import mx_transpose_matrix33;
|
||||
export using .::stdlib_1_7 import mx_transpose_matrix44;
|
||||
export using .::stdlib_1_7 import mx_determinant_matrix33;
|
||||
export using .::stdlib_1_7 import mx_determinant_matrix44;
|
||||
export using .::stdlib_1_7 import mx_invertmatrix_matrix33;
|
||||
export using .::stdlib_1_7 import mx_invertmatrix_matrix44;
|
||||
export using .::stdlib_1_7 import mx_rotate2d_vector2;
|
||||
export using .::stdlib_1_7 import mx_rotate3d_vector3;
|
||||
export using .::stdlib_1_7 import mx_remap_float;
|
||||
export using .::stdlib_1_7 import mx_remap_color3;
|
||||
export using .::stdlib_1_7 import mx_remap_color4;
|
||||
export using .::stdlib_1_7 import mx_remap_vector2;
|
||||
export using .::stdlib_1_7 import mx_remap_vector3;
|
||||
export using .::stdlib_1_7 import mx_remap_vector4;
|
||||
export using .::stdlib_1_7 import mx_remap_color3FA;
|
||||
export using .::stdlib_1_7 import mx_remap_color4FA;
|
||||
export using .::stdlib_1_7 import mx_remap_vector2FA;
|
||||
export using .::stdlib_1_7 import mx_remap_vector3FA;
|
||||
export using .::stdlib_1_7 import mx_remap_vector4FA;
|
||||
export using .::stdlib_1_7 import mx_smoothstep_float;
|
||||
export using .::stdlib_1_7 import mx_smoothstep_color3;
|
||||
export using .::stdlib_1_7 import mx_smoothstep_color4;
|
||||
export using .::stdlib_1_7 import mx_smoothstep_vector2;
|
||||
export using .::stdlib_1_7 import mx_smoothstep_vector3;
|
||||
export using .::stdlib_1_7 import mx_smoothstep_vector4;
|
||||
export using .::stdlib_1_7 import mx_smoothstep_color3FA;
|
||||
export using .::stdlib_1_7 import mx_smoothstep_color4FA;
|
||||
export using .::stdlib_1_7 import mx_smoothstep_vector2FA;
|
||||
export using .::stdlib_1_7 import mx_smoothstep_vector3FA;
|
||||
export using .::stdlib_1_7 import mx_smoothstep_vector4FA;
|
||||
export using .::stdlib_1_7 import mx_curveadjust_float;
|
||||
export using .::stdlib_1_7 import mx_curveadjust_color3;
|
||||
export using .::stdlib_1_7 import mx_curveadjust_color4;
|
||||
export using .::stdlib_1_7 import mx_curveadjust_vector2;
|
||||
export using .::stdlib_1_7 import mx_curveadjust_vector3;
|
||||
export using .::stdlib_1_7 import mx_curveadjust_vector4;
|
||||
export using .::stdlib_1_7 import mx_luminance_color3;
|
||||
export using .::stdlib_1_7 import mx_luminance_color4;
|
||||
export using .::stdlib_1_7 import mx_rgbtohsv_color3;
|
||||
export using .::stdlib_1_7 import mx_rgbtohsv_color4;
|
||||
export using .::stdlib_1_7 import mx_hsvtorgb_color3;
|
||||
export using .::stdlib_1_7 import mx_hsvtorgb_color4;
|
||||
export using .::stdlib_1_7 import mx_premult_color4;
|
||||
export using .::stdlib_1_7 import mx_unpremult_color4;
|
||||
export using .::stdlib_1_7 import mx_plus_color4;
|
||||
export using .::stdlib_1_7 import mx_minus_color4;
|
||||
export using .::stdlib_1_7 import mx_difference_color4;
|
||||
export using .::stdlib_1_7 import mx_burn_float;
|
||||
export using .::stdlib_1_7 import mx_burn_color3;
|
||||
export using .::stdlib_1_7 import mx_burn_color4;
|
||||
export using .::stdlib_1_7 import mx_dodge_float;
|
||||
export using .::stdlib_1_7 import mx_dodge_color3;
|
||||
export using .::stdlib_1_7 import mx_dodge_color4;
|
||||
export using .::stdlib_1_7 import mx_screen_color4;
|
||||
export using .::stdlib_1_7 import mx_disjointover_color4;
|
||||
export using .::stdlib_1_7 import mx_in_color4;
|
||||
export using .::stdlib_1_7 import mx_mask_color4;
|
||||
export using .::stdlib_1_7 import mx_matte_color4;
|
||||
export using .::stdlib_1_7 import mx_out_color4;
|
||||
export using .::stdlib_1_7 import mx_over_color4;
|
||||
export using .::stdlib_1_7 import mx_mix_color4;
|
||||
export using .::stdlib_1_7 import mx_mix_color4_color4;
|
||||
export using .::stdlib_1_7 import mx_mix_surfaceshader;
|
||||
export using .::stdlib_1_7 import mx_mix_volumeshader;
|
||||
export using .::stdlib_1_7 import mx_mix_displacementshader;
|
||||
export using .::stdlib_1_7 import mx_ifgreater_float;
|
||||
export using .::stdlib_1_7 import mx_ifgreater_color3;
|
||||
export using .::stdlib_1_7 import mx_ifgreater_color4;
|
||||
export using .::stdlib_1_7 import mx_ifgreater_vector2;
|
||||
export using .::stdlib_1_7 import mx_ifgreater_vector3;
|
||||
export using .::stdlib_1_7 import mx_ifgreater_vector4;
|
||||
export using .::stdlib_1_7 import mx_ifgreater_floatI;
|
||||
export using .::stdlib_1_7 import mx_ifgreater_color3I;
|
||||
export using .::stdlib_1_7 import mx_ifgreater_color4I;
|
||||
export using .::stdlib_1_7 import mx_ifgreater_vector2I;
|
||||
export using .::stdlib_1_7 import mx_ifgreater_vector3I;
|
||||
export using .::stdlib_1_7 import mx_ifgreater_vector4I;
|
||||
export using .::stdlib_1_7 import mx_ifgreatereq_float;
|
||||
export using .::stdlib_1_7 import mx_ifgreatereq_color3;
|
||||
export using .::stdlib_1_7 import mx_ifgreatereq_color4;
|
||||
export using .::stdlib_1_7 import mx_ifgreatereq_vector2;
|
||||
export using .::stdlib_1_7 import mx_ifgreatereq_vector3;
|
||||
export using .::stdlib_1_7 import mx_ifgreatereq_vector4;
|
||||
export using .::stdlib_1_7 import mx_ifgreatereq_floatI;
|
||||
export using .::stdlib_1_7 import mx_ifgreatereq_color3I;
|
||||
export using .::stdlib_1_7 import mx_ifgreatereq_color4I;
|
||||
export using .::stdlib_1_7 import mx_ifgreatereq_vector2I;
|
||||
export using .::stdlib_1_7 import mx_ifgreatereq_vector3I;
|
||||
export using .::stdlib_1_7 import mx_ifgreatereq_vector4I;
|
||||
export using .::stdlib_1_7 import mx_ifequal_float;
|
||||
export using .::stdlib_1_7 import mx_ifequal_color3;
|
||||
export using .::stdlib_1_7 import mx_ifequal_color4;
|
||||
export using .::stdlib_1_7 import mx_ifequal_vector2;
|
||||
export using .::stdlib_1_7 import mx_ifequal_vector3;
|
||||
export using .::stdlib_1_7 import mx_ifequal_vector4;
|
||||
export using .::stdlib_1_7 import mx_ifequal_floatI;
|
||||
export using .::stdlib_1_7 import mx_ifequal_color3I;
|
||||
export using .::stdlib_1_7 import mx_ifequal_color4I;
|
||||
export using .::stdlib_1_7 import mx_ifequal_vector2I;
|
||||
export using .::stdlib_1_7 import mx_ifequal_vector3I;
|
||||
export using .::stdlib_1_7 import mx_ifequal_vector4I;
|
||||
export using .::stdlib_1_7 import mx_ifequal_floatB;
|
||||
export using .::stdlib_1_7 import mx_ifequal_color3B;
|
||||
export using .::stdlib_1_7 import mx_ifequal_color4B;
|
||||
export using .::stdlib_1_7 import mx_ifequal_vector2B;
|
||||
export using .::stdlib_1_7 import mx_ifequal_vector3B;
|
||||
export using .::stdlib_1_7 import mx_ifequal_vector4B;
|
||||
export using .::stdlib_1_7 import mx_switch_float;
|
||||
export using .::stdlib_1_7 import mx_switch_color3;
|
||||
export using .::stdlib_1_7 import mx_switch_color4;
|
||||
export using .::stdlib_1_7 import mx_switch_vector2;
|
||||
export using .::stdlib_1_7 import mx_switch_vector3;
|
||||
export using .::stdlib_1_7 import mx_switch_vector4;
|
||||
export using .::stdlib_1_7 import mx_switch_floatI;
|
||||
export using .::stdlib_1_7 import mx_switch_color3I;
|
||||
export using .::stdlib_1_7 import mx_switch_color4I;
|
||||
export using .::stdlib_1_7 import mx_switch_vector2I;
|
||||
export using .::stdlib_1_7 import mx_switch_vector3I;
|
||||
export using .::stdlib_1_7 import mx_switch_vector4I;
|
||||
export using .::stdlib_1_7 import mx_convert_float_color3;
|
||||
export using .::stdlib_1_7 import mx_convert_float_color4;
|
||||
export using .::stdlib_1_7 import mx_convert_float_vector2;
|
||||
export using .::stdlib_1_7 import mx_convert_float_vector3;
|
||||
export using .::stdlib_1_7 import mx_convert_float_vector4;
|
||||
export using .::stdlib_1_7 import mx_convert_vector2_vector3;
|
||||
export using .::stdlib_1_7 import mx_convert_vector3_color3;
|
||||
export using .::stdlib_1_7 import mx_convert_vector3_vector2;
|
||||
export using .::stdlib_1_7 import mx_convert_vector3_vector4;
|
||||
export using .::stdlib_1_7 import mx_convert_vector4_color4;
|
||||
export using .::stdlib_1_7 import mx_convert_vector4_vector3;
|
||||
export using .::stdlib_1_7 import mx_convert_color3_vector3;
|
||||
export using .::stdlib_1_7 import mx_convert_color4_vector4;
|
||||
export using .::stdlib_1_7 import mx_convert_color3_color4;
|
||||
export using .::stdlib_1_7 import mx_convert_color4_color3;
|
||||
export using .::stdlib_1_7 import mx_convert_boolean_float;
|
||||
export using .::stdlib_1_7 import mx_convert_integer_float;
|
||||
export using .::stdlib_1_7 import mx_combine2_vector2;
|
||||
export using .::stdlib_1_7 import mx_combine2_color4CF;
|
||||
export using .::stdlib_1_7 import mx_combine2_vector4VF;
|
||||
export using .::stdlib_1_7 import mx_combine2_color4CC;
|
||||
export using .::stdlib_1_7 import mx_combine2_vector4VV;
|
||||
export using .::stdlib_1_7 import mx_combine3_color3;
|
||||
export using .::stdlib_1_7 import mx_combine3_vector3;
|
||||
export using .::stdlib_1_7 import mx_combine4_color4;
|
||||
export using .::stdlib_1_7 import mx_combine4_vector4;
|
||||
export using .::stdlib_1_7 import mx_creatematrix_vector3_matrix33;
|
||||
export using .::stdlib_1_7 import mx_creatematrix_vector3_matrix44;
|
||||
export using .::stdlib_1_7 import mx_creatematrix_vector4_matrix44;
|
||||
export using .::stdlib_1_7 import mx_blur_float;
|
||||
export using .::stdlib_1_7 import mx_blur_color3;
|
||||
export using .::stdlib_1_7 import mx_blur_color4;
|
||||
export using .::stdlib_1_7 import mx_blur_vector2;
|
||||
export using .::stdlib_1_7 import mx_blur_vector3;
|
||||
export using .::stdlib_1_7 import mx_blur_vector4;
|
||||
export using .::stdlib_1_7 import mx_heighttonormal_vector3;
|
||||
export using .::stdlib_1_7 import mx_noise2d_float;
|
||||
export using .::stdlib_1_7 import mx_noise2d_float2;
|
||||
export using .::stdlib_1_7 import mx_noise2d_float3;
|
||||
export using .::stdlib_1_7 import mx_noise2d_float4;
|
||||
export using .::stdlib_1_7 import mx_noise3d_float;
|
||||
export using .::stdlib_1_7 import mx_noise3d_float2;
|
||||
export using .::stdlib_1_7 import mx_noise3d_float3;
|
||||
export using .::stdlib_1_7 import mx_noise3d_float4;
|
||||
export using .::stdlib_1_7 import mx_fractal3d_float;
|
||||
export using .::stdlib_1_7 import mx_fractal3d_float2;
|
||||
export using .::stdlib_1_7 import mx_fractal3d_float3;
|
||||
export using .::stdlib_1_7 import mx_fractal3d_float4;
|
||||
export using .::stdlib_1_7 import mx_cellnoise2d_float;
|
||||
export using .::stdlib_1_7 import mx_cellnoise3d_float;
|
||||
export using .::stdlib_1_7 import mx_worleynoise2d_float;
|
||||
export using .::stdlib_1_7 import mx_worleynoise2d_float2;
|
||||
export using .::stdlib_1_7 import mx_worleynoise2d_float3;
|
||||
export using .::stdlib_1_7 import mx_worleynoise3d_float;
|
||||
export using .::stdlib_1_7 import mx_worleynoise3d_float2;
|
||||
export using .::stdlib_1_7 import mx_worleynoise3d_float3;
|
||||
|
||||
// NOTE: Not planned to be implemented.
|
||||
export using .::stdlib_1_7 import mx_geompropvalue_string;
|
||||
|
||||
// NOTE: No boolean scene data in MDL so it's mapped to integer.
|
||||
// Returns false if the scene data is zero, true otherwise.
|
||||
export bool mx_geompropvalue_boolean(
|
||||
uniform string mxp_geomprop = string(""),
|
||||
bool mxp_default = bool(false)
|
||||
)
|
||||
[[
|
||||
anno::description("Node Group: geometric")
|
||||
]]
|
||||
{
|
||||
int defaultValue = mxp_default ? 1 : 0;
|
||||
return scene::data_lookup_int(mxp_geomprop, defaultValue) == 0 ? false : true;
|
||||
}
|
||||
|
||||
export int mx_geompropvalue_integer(
|
||||
uniform string mxp_geomprop = string(""),
|
||||
int mxp_default = int(0)
|
||||
)
|
||||
[[
|
||||
anno::description("Node Group: geometric")
|
||||
]]
|
||||
{
|
||||
return scene::data_lookup_int(mxp_geomprop, mxp_default);
|
||||
}
|
||||
|
||||
export float mx_geompropvalue_float(
|
||||
uniform string mxp_geomprop = string(""),
|
||||
float mxp_default = float(0.0)
|
||||
)
|
||||
[[
|
||||
anno::description("Node Group: geometric")
|
||||
]]
|
||||
{
|
||||
return scene::data_lookup_float(mxp_geomprop, mxp_default);
|
||||
}
|
||||
|
||||
export color mx_geompropvalue_color3(
|
||||
uniform string mxp_geomprop = string(""),
|
||||
color mxp_default = color(0.0, 0.0, 0.0)
|
||||
)
|
||||
[[
|
||||
anno::description("Node Group: geometric")
|
||||
]]
|
||||
{
|
||||
return scene::data_lookup_color(mxp_geomprop, mxp_default);
|
||||
}
|
||||
|
||||
export core::color4 mx_geompropvalue_color4(
|
||||
uniform string mxp_geomprop = string(""),
|
||||
core::color4 mxp_default = core::mk_color4(0.0, 0.0, 0.0, 0.0)
|
||||
)
|
||||
[[
|
||||
anno::description("Node Group: geometric")
|
||||
]]
|
||||
{
|
||||
float3 rgbValue = float3(mxp_default.rgb);
|
||||
float4 defaultValue = float4(rgbValue.x, rgbValue.y, rgbValue.z, mxp_default.a);
|
||||
float4 value = scene::data_lookup_float4(mxp_geomprop, defaultValue);
|
||||
return core::mk_color4(value.x, value.y, value.z, value.w);
|
||||
}
|
||||
|
||||
export float2 mx_geompropvalue_vector2(
|
||||
uniform string mxp_geomprop = string(""),
|
||||
float2 mxp_default = float2(0.0, 0.0)
|
||||
)
|
||||
[[
|
||||
anno::description("Node Group: geometric")
|
||||
]]
|
||||
{
|
||||
return scene::data_lookup_float2(mxp_geomprop, mxp_default);
|
||||
}
|
||||
|
||||
export float3 mx_geompropvalue_vector3(
|
||||
uniform string mxp_geomprop = string(""),
|
||||
float3 mxp_default = float3(0.0, 0.0, 0.0)
|
||||
)
|
||||
[[
|
||||
anno::description("Node Group: geometric")
|
||||
]]
|
||||
{
|
||||
return scene::data_lookup_float3(mxp_geomprop, mxp_default);
|
||||
}
|
||||
|
||||
export float4 mx_geompropvalue_vector4(
|
||||
uniform string mxp_geomprop = string(""),
|
||||
float4 mxp_default = float4(0.0, 0.0, 0.0, 0.0)
|
||||
)
|
||||
{
|
||||
return scene::data_lookup_float4(mxp_geomprop, mxp_default);
|
||||
}
|
||||
|
||||
export float3 mx_viewdirection_vector3(
|
||||
uniform core::mx_coordinatespace_type mxp_space = core::mx_coordinatespace_type_world
|
||||
[[
|
||||
anno::description("Enumeration {model,object,world}."),
|
||||
anno::unused()
|
||||
]]
|
||||
)
|
||||
[[
|
||||
anno::description("Node Group: nprlib")
|
||||
]]
|
||||
{
|
||||
float3 internal_space_direction =
|
||||
state::position() - scene::data_lookup_float3("CAMERA_POSITION", float3(0.0, 0.0, 0.0));
|
||||
|
||||
if (mxp_space == core::mx_coordinatespace_type_world)
|
||||
return math::normalize(state::transform_vector(
|
||||
::state::coordinate_internal,
|
||||
::state::coordinate_world,
|
||||
internal_space_direction));
|
||||
else
|
||||
return math::normalize(state::transform_vector(
|
||||
::state::coordinate_internal,
|
||||
::state::coordinate_object,
|
||||
internal_space_direction));
|
||||
}
|
||||
+1007
File diff suppressed because it is too large
Load Diff
+17
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0"?>
|
||||
<materialx version="1.38">
|
||||
<!--
|
||||
Copyright Contributors to the MaterialX Project
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
Declarations for GLSL implementations of standard nodes included in the MaterialX specification.
|
||||
-->
|
||||
|
||||
<!-- ======================================================================== -->
|
||||
<!-- View-dependent nodes -->
|
||||
<!-- ======================================================================== -->
|
||||
|
||||
<!-- <viewdirection> -->
|
||||
<implementation name="IM_viewdirection_vector3_genglsl" nodedef="ND_viewdirection_vector3" target="genglsl" />
|
||||
|
||||
</materialx>
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0"?>
|
||||
<materialx version="1.38">
|
||||
<!--
|
||||
Copyright Contributors to the MaterialX Project
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
Declarations for MDL implementations of standard nodes included in the MaterialX specification.
|
||||
-->
|
||||
|
||||
<!-- ======================================================================== -->
|
||||
<!-- View-dependent nodes -->
|
||||
<!-- ======================================================================== -->
|
||||
|
||||
<!-- <viewdirection> -->
|
||||
<implementation name="IM_viewdirection_vector3_genmdl" nodedef="ND_viewdirection_vector3" sourcecode="materialx::stdlib_{{MDL_VERSION_SUFFIX}}::mx_viewdirection_vector3(mxp_space:{{space}})" target="genmdl" />
|
||||
|
||||
</materialx>
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0"?>
|
||||
<materialx version="1.38">
|
||||
<!--
|
||||
Copyright Contributors to the MaterialX Project
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
Declarations for MSL implementations of standard nodes included in the MaterialX specification.
|
||||
-->
|
||||
|
||||
<!-- ======================================================================== -->
|
||||
<!-- View-dependent nodes -->
|
||||
<!-- ======================================================================== -->
|
||||
|
||||
<!-- <viewdirection> -->
|
||||
<implementation name="IM_viewdirection_vector3_genmsl" nodedef="ND_viewdirection_vector3" target="genmsl" />
|
||||
|
||||
</materialx>
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0"?>
|
||||
<materialx version="1.38">
|
||||
<!--
|
||||
Copyright Contributors to the MaterialX Project
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
Declarations for OSL implementations of standard nodes included in the MaterialX specification.
|
||||
-->
|
||||
|
||||
<!-- ======================================================================== -->
|
||||
<!-- View-dependent nodes -->
|
||||
<!-- ======================================================================== -->
|
||||
|
||||
<!-- <viewdirection> -->
|
||||
<implementation name="IM_viewdirection_vector3_genosl" nodedef="ND_viewdirection_vector3" sourcecode="transform({{space}}, I)" target="genosl" />
|
||||
|
||||
</materialx>
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
<?xml version="1.0"?>
|
||||
<materialx version="1.38">
|
||||
<!--
|
||||
Copyright Contributors to the MaterialX Project
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
Declarations of standard data types and nodes included in the MaterialX specification.
|
||||
-->
|
||||
|
||||
<!-- ======================================================================== -->
|
||||
<!-- View-dependent properties -->
|
||||
<!-- ======================================================================== -->
|
||||
|
||||
<geompropdef name="Vworld" type="vector3" geomprop="viewdirection" space="world" />
|
||||
|
||||
<!-- ======================================================================== -->
|
||||
<!-- View-dependent nodes -->
|
||||
<!-- ======================================================================== -->
|
||||
|
||||
<!--
|
||||
Node: <viewdirection>
|
||||
The current scene view direction, as defined by the shading environment.
|
||||
-->
|
||||
<nodedef name="ND_viewdirection_vector3" node="viewdirection" nodegroup="npr">
|
||||
<input name="space" type="string" value="world" enum="model,object,world" uniform="true" />
|
||||
<output name="out" type="vector3" default="0.0, 0.0, 1.0" />
|
||||
</nodedef>
|
||||
|
||||
<!--
|
||||
Node: <facingratio>
|
||||
Return the geometric facing ratio, computed as the dot product between the
|
||||
view direction and geometric normal.
|
||||
-->
|
||||
<nodedef name="ND_facingratio_float" node="facingratio" nodegroup="npr">
|
||||
<input name="viewdirection" type="vector3" defaultgeomprop="Vworld" />
|
||||
<input name="normal" type="vector3" defaultgeomprop="Nworld" />
|
||||
<input name="faceforward" type="boolean" value="true" />
|
||||
<input name="invert" type="boolean" value="false" />
|
||||
<output name="out" type="float" default="0.0" />
|
||||
</nodedef>
|
||||
|
||||
<!--
|
||||
Node: <gooch_shade>
|
||||
Compute Gooch Shading.
|
||||
-->
|
||||
<nodedef name="ND_gooch_shade" node="gooch_shade" nodegroup="npr" doc="Compute Gooch shading">
|
||||
<input name="warm_color" type="color3" value="0.8, 0.8, 0.7" uiname="Warm Color" doc="Warm color" />
|
||||
<input name="cool_color" type="color3" value="0.3, 0.3, 0.8" uiname="Cool Color" doc="Cool color" />
|
||||
<input name="specular_intensity" type="float" value="1" uimin="0" uimax="1" uiname="Specular Intensity" doc="Specular Intensity" />
|
||||
<input name="shininess" type="float" value="64" uimin="1" uisoftmax="256" uiname="Shininess" doc="Specular Power" />
|
||||
<input name="light_direction" type="vector3" value="1, -0.5, -0.5" uimin="-1, -1, -1" uimax="1, 1, 1" uiname="Light Direction" doc="Light vector in world space" />
|
||||
<output name="out" type="color3" />
|
||||
</nodedef>
|
||||
|
||||
</materialx>
|
||||
+114
@@ -0,0 +1,114 @@
|
||||
<?xml version="1.0"?>
|
||||
<materialx version="1.38">
|
||||
<!--
|
||||
Copyright Contributors to the MaterialX Project
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
Graph definitions of standard nodes included in the MaterialX specification.
|
||||
-->
|
||||
|
||||
<!-- ======================================================================== -->
|
||||
<!-- View-dependent nodes -->
|
||||
<!-- ======================================================================== -->
|
||||
|
||||
<!--
|
||||
Node: <facingratio>
|
||||
-->
|
||||
<nodegraph name="NG_facingratio_float" nodedef="ND_facingratio_float">
|
||||
<dotproduct name="N_dotproduct" type="float">
|
||||
<input name="in1" type="vector3" interfacename="viewdirection" />
|
||||
<input name="in2" type="vector3" interfacename="normal" />
|
||||
</dotproduct>
|
||||
<multiply name="N_scale" type="float">
|
||||
<input name="in1" type="float" nodename="N_dotproduct" />
|
||||
<input name="in2" type="float" value="-1" />
|
||||
</multiply>
|
||||
<absval name="N_absval" type="float">
|
||||
<input name="in" type="float" nodename="N_dotproduct" />
|
||||
</absval>
|
||||
<ifequal name="N_facing" type="float">
|
||||
<input name="value1" type="boolean" interfacename="faceforward" />
|
||||
<input name="value2" type="boolean" value="true" />
|
||||
<input name="in1" type="float" nodename="N_absval" />
|
||||
<input name="in2" type="float" nodename="N_scale" />
|
||||
</ifequal>
|
||||
<invert name="N_invert" type="float">
|
||||
<input name="in" type="float" nodename="N_facing" />
|
||||
</invert>
|
||||
<ifequal name="N_result" type="float">
|
||||
<input name="value1" type="boolean" interfacename="invert" />
|
||||
<input name="value2" type="boolean" value="true" />
|
||||
<input name="in1" type="float" nodename="N_invert" />
|
||||
<input name="in2" type="float" nodename="N_facing" />
|
||||
</ifequal>
|
||||
<output name="out" type="float" nodename="N_result" />
|
||||
</nodegraph>
|
||||
|
||||
<!--
|
||||
Node: <gooch_shade>
|
||||
-->
|
||||
<nodegraph name="NG_gooch_shade" type="color3" nodedef="ND_gooch_shade">
|
||||
<normal name="normal" type="vector3" >
|
||||
<input name="space" type="string" value="world" />
|
||||
</normal>
|
||||
<viewdirection name="viewdir" type="vector3" >
|
||||
<input name="space" type="string" value="world" />
|
||||
</viewdirection>
|
||||
<normalize name="unit_normal" type="vector3">
|
||||
<input name="in" type="vector3" nodename="normal" />
|
||||
</normalize>
|
||||
<normalize name="unit_viewdir" type="vector3">
|
||||
<input name="in" type="vector3" nodename="viewdir" />
|
||||
</normalize>
|
||||
<normalize name="unit_lightdir" type="vector3">
|
||||
<input name="in" type="vector3" interfacename="light_direction" />
|
||||
</normalize>
|
||||
<dotproduct name="NdotL" type="float">
|
||||
<input name="in1" type="vector3" nodename="unit_normal" />
|
||||
<input name="in2" type="vector3" nodename="unit_lightdir" />
|
||||
</dotproduct>
|
||||
<add name="one_plus_NdotL" type="float">
|
||||
<input name="in2" type="float" nodename="NdotL" />
|
||||
<input name="in1" type="float" value="1" />
|
||||
</add>
|
||||
<divide name="cool_intensity" type="float">
|
||||
<input name="in1" type="float" nodename="one_plus_NdotL" />
|
||||
<input name="in2" type="float" value="2" />
|
||||
</divide>
|
||||
<mix name="diffuse" type="color3">
|
||||
<input name="bg" type="color3" interfacename="warm_color" />
|
||||
<input name="fg" type="color3" interfacename="cool_color" />
|
||||
<input name="mix" type="float" nodename="cool_intensity" />
|
||||
</mix>
|
||||
<reflect name="view_reflect" type="vector3">
|
||||
<input name="in" type="vector3" nodename="unit_viewdir" />
|
||||
<input name="normal" type="vector3" nodename="unit_normal" />
|
||||
</reflect>
|
||||
<multiply name="invert_lightdir" type="vector3">
|
||||
<input name="in1" type="vector3" nodename="unit_lightdir" />
|
||||
<input name="in2" type="float" value="-1" />
|
||||
</multiply>
|
||||
<dotproduct name="VdotR" type="float">
|
||||
<input name="in1" type="vector3" nodename="invert_lightdir" />
|
||||
<input name="in2" type="vector3" nodename="view_reflect" />
|
||||
</dotproduct>
|
||||
<max name="VdotR_nonnegative" type="float">
|
||||
<input name="in1" type="float" nodename="VdotR" />
|
||||
<input name="in2" type="float" value="0" />
|
||||
</max>
|
||||
<power name="specular_highlight" type="float">
|
||||
<input name="in1" type="float" nodename="VdotR_nonnegative" />
|
||||
<input name="in2" type="float" interfacename="shininess" />
|
||||
</power>
|
||||
<multiply name="specular" type="float">
|
||||
<input name="in1" type="float" nodename="specular_highlight" />
|
||||
<input name="in2" type="float" interfacename="specular_intensity" />
|
||||
</multiply>
|
||||
<add name="final_color" type="color3">
|
||||
<input name="in1" type="color3" nodename="diffuse" />
|
||||
<input name="in2" type="float" nodename="specular" />
|
||||
</add>
|
||||
<output name="out" type="color3" nodename="final_color" />
|
||||
</nodegraph>
|
||||
|
||||
</materialx>
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
#include "mx_microfacet_specular.glsl"
|
||||
|
||||
vec3 mx_environment_radiance(vec3 N, vec3 V, vec3 X, vec2 alpha, int distribution, FresnelData fd)
|
||||
{
|
||||
// Generate tangent frame.
|
||||
X = normalize(X - dot(X, N) * N);
|
||||
vec3 Y = cross(N, X);
|
||||
mat3 tangentToWorld = mat3(X, Y, N);
|
||||
|
||||
// Transform the view vector to tangent space.
|
||||
V = vec3(dot(V, X), dot(V, Y), dot(V, N));
|
||||
|
||||
// Compute derived properties.
|
||||
float NdotV = clamp(V.z, M_FLOAT_EPS, 1.0);
|
||||
float avgAlpha = mx_average_alpha(alpha);
|
||||
float G1V = mx_ggx_smith_G1(NdotV, avgAlpha);
|
||||
|
||||
// Integrate outgoing radiance using filtered importance sampling.
|
||||
// http://cgg.mff.cuni.cz/~jaroslav/papers/2008-egsr-fis/2008-egsr-fis-final-embedded.pdf
|
||||
vec3 radiance = vec3(0.0);
|
||||
int envRadianceSamples = $envRadianceSamples;
|
||||
for (int i = 0; i < envRadianceSamples; i++)
|
||||
{
|
||||
vec2 Xi = mx_spherical_fibonacci(i, envRadianceSamples);
|
||||
|
||||
// Compute the half vector and incoming light direction.
|
||||
vec3 H = mx_ggx_importance_sample_VNDF(Xi, V, alpha);
|
||||
vec3 L = fd.refraction ? mx_refraction_solid_sphere(-V, H, fd.ior.x) : -reflect(V, H);
|
||||
|
||||
// Compute dot products for this sample.
|
||||
float NdotL = clamp(L.z, M_FLOAT_EPS, 1.0);
|
||||
float VdotH = clamp(dot(V, H), M_FLOAT_EPS, 1.0);
|
||||
|
||||
// Sample the environment light from the given direction.
|
||||
vec3 Lw = tangentToWorld * L;
|
||||
float pdf = mx_ggx_NDF(H, alpha) * G1V / (4.0 * NdotV);
|
||||
float lod = mx_latlong_compute_lod(Lw, pdf, float($envRadianceMips - 1), envRadianceSamples);
|
||||
vec3 sampleColor = mx_latlong_map_lookup(Lw, $envMatrix, lod, $envRadiance);
|
||||
|
||||
// Compute the Fresnel term.
|
||||
vec3 F = mx_compute_fresnel(VdotH, fd);
|
||||
|
||||
// Compute the geometric term.
|
||||
float G = mx_ggx_smith_G2(NdotL, NdotV, avgAlpha);
|
||||
|
||||
// Compute the combined FG term, which is inverted for refraction.
|
||||
vec3 FG = fd.refraction ? vec3(1.0) - (F * G) : F * G;
|
||||
|
||||
// Add the radiance contribution of this sample.
|
||||
// From https://cdn2.unrealengine.com/Resources/files/2013SiggraphPresentationsNotes-26915738.pdf
|
||||
// incidentLight = sampleColor * NdotL
|
||||
// microfacetSpecular = D * F * G / (4 * NdotL * NdotV)
|
||||
// pdf = D * G1V / (4 * NdotV);
|
||||
// radiance = incidentLight * microfacetSpecular / pdf
|
||||
radiance += sampleColor * FG;
|
||||
}
|
||||
|
||||
// Apply the global component of the geometric term and normalize.
|
||||
radiance /= G1V * float(envRadianceSamples);
|
||||
|
||||
// Return the final radiance.
|
||||
return radiance * $envLightIntensity;
|
||||
}
|
||||
|
||||
vec3 mx_environment_irradiance(vec3 N)
|
||||
{
|
||||
vec3 Li = mx_latlong_map_lookup(N, $envMatrix, 0.0, $envIrradiance);
|
||||
return Li * $envLightIntensity;
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
#include "mx_microfacet_specular.glsl"
|
||||
|
||||
vec3 mx_environment_radiance(vec3 N, vec3 V, vec3 X, vec2 roughness, int distribution, FresnelData fd)
|
||||
{
|
||||
return vec3(0.0);
|
||||
}
|
||||
|
||||
vec3 mx_environment_irradiance(vec3 N)
|
||||
{
|
||||
return vec3(0.0);
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
#include "mx_microfacet_specular.glsl"
|
||||
|
||||
// Return the mip level associated with the given alpha in a prefiltered environment.
|
||||
float mx_latlong_alpha_to_lod(float alpha)
|
||||
{
|
||||
float lodBias = (alpha < 0.25) ? sqrt(alpha) : 0.5 * alpha + 0.375;
|
||||
return lodBias * float($envRadianceMips - 1);
|
||||
}
|
||||
|
||||
vec3 mx_environment_radiance(vec3 N, vec3 V, vec3 X, vec2 alpha, int distribution, FresnelData fd)
|
||||
{
|
||||
N = mx_forward_facing_normal(N, V);
|
||||
vec3 L = fd.refraction ? mx_refraction_solid_sphere(-V, N, fd.ior.x) : -reflect(V, N);
|
||||
|
||||
float NdotV = clamp(dot(N, V), M_FLOAT_EPS, 1.0);
|
||||
|
||||
float avgAlpha = mx_average_alpha(alpha);
|
||||
vec3 F = mx_compute_fresnel(NdotV, fd);
|
||||
float G = mx_ggx_smith_G2(NdotV, NdotV, avgAlpha);
|
||||
vec3 FG = fd.refraction ? vec3(1.0) - (F * G) : F * G;
|
||||
|
||||
vec3 Li = mx_latlong_map_lookup(L, $envMatrix, mx_latlong_alpha_to_lod(avgAlpha), $envRadiance);
|
||||
return Li * FG * $envLightIntensity;
|
||||
}
|
||||
|
||||
vec3 mx_environment_irradiance(vec3 N)
|
||||
{
|
||||
vec3 Li = mx_latlong_map_lookup(N, $envMatrix, 0.0, $envIrradiance);
|
||||
return Li * $envLightIntensity;
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
#include "mx_microfacet_sheen.glsl"
|
||||
#include "mx_microfacet_specular.glsl"
|
||||
|
||||
vec3 mx_generate_dir_albedo_table()
|
||||
{
|
||||
vec2 uv = gl_FragCoord.xy / $albedoTableSize;
|
||||
vec2 ggxDirAlbedo = mx_ggx_dir_albedo(uv.x, uv.y, vec3(1, 0, 0), vec3(0, 1, 0)).xy;
|
||||
float sheenDirAlbedo = mx_imageworks_sheen_dir_albedo(uv.x, uv.y);
|
||||
return vec3(ggxDirAlbedo, sheenDirAlbedo);
|
||||
}
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
#include "mx_microfacet_specular.glsl"
|
||||
|
||||
// Construct an orthonormal basis from a unit vector.
|
||||
// https://graphics.pixar.com/library/OrthonormalB/paper.pdf
|
||||
mat3 mx_orthonormal_basis(vec3 N)
|
||||
{
|
||||
float sign = (N.z < 0.0) ? -1.0 : 1.0;
|
||||
float a = -1.0 / (sign + N.z);
|
||||
float b = N.x * N.y * a;
|
||||
vec3 X = vec3(1.0 + sign * N.x * N.x * a, sign * b, -sign * N.x);
|
||||
vec3 Y = vec3(b, sign + N.y * N.y * a, -N.y);
|
||||
return mat3(X, Y, N);
|
||||
}
|
||||
|
||||
// Return the alpha associated with the given mip level in a prefiltered environment.
|
||||
float mx_latlong_lod_to_alpha(float lod)
|
||||
{
|
||||
float lodBias = lod / float($envRadianceMips - 1);
|
||||
return (lodBias < 0.5) ? mx_square(lodBias) : 2.0 * (lodBias - 0.375);
|
||||
}
|
||||
|
||||
// The inverse of mx_latlong_projection.
|
||||
vec3 mx_latlong_map_projection_inverse(vec2 uv)
|
||||
{
|
||||
float latitude = (uv.y - 0.5) * M_PI;
|
||||
float longitude = (uv.x - 0.5) * M_PI * 2.0;
|
||||
|
||||
float x = -cos(latitude) * sin(longitude);
|
||||
float y = -sin(latitude);
|
||||
float z = cos(latitude) * cos(longitude);
|
||||
|
||||
return vec3(x, y, z);
|
||||
}
|
||||
|
||||
vec3 mx_generate_prefilter_env()
|
||||
{
|
||||
// The tangent view vector is aligned with the normal.
|
||||
vec3 V = vec3(0.0, 0.0, 1.0);
|
||||
float NdotV = 1.0;
|
||||
|
||||
// Compute derived properties.
|
||||
vec2 uv = gl_FragCoord.xy * pow(2.0, $envPrefilterMip) / vec2(textureSize($envRadiance, 0));
|
||||
vec3 worldN = mx_latlong_map_projection_inverse(uv);
|
||||
mat3 tangentToWorld = mx_orthonormal_basis(worldN);
|
||||
float alpha = mx_latlong_lod_to_alpha(float($envPrefilterMip));
|
||||
float G1V = mx_ggx_smith_G1(NdotV, alpha);
|
||||
|
||||
// Integrate the LD term for the given environment and alpha.
|
||||
vec3 radiance = vec3(0.0, 0.0, 0.0);
|
||||
float weight = 0.0;
|
||||
int envRadianceSamples = 1024;
|
||||
for (int i = 0; i < envRadianceSamples; i++)
|
||||
{
|
||||
vec2 Xi = mx_spherical_fibonacci(i, envRadianceSamples);
|
||||
|
||||
// Compute the half vector and incoming light direction.
|
||||
vec3 H = mx_ggx_importance_sample_VNDF(Xi, V, vec2(alpha));
|
||||
vec3 L = -V + 2.0 * H.z * H;
|
||||
|
||||
// Compute dot products for this sample.
|
||||
float NdotL = clamp(L.z, M_FLOAT_EPS, 1.0);
|
||||
|
||||
// Compute the geometric term.
|
||||
float G = mx_ggx_smith_G2(NdotL, NdotV, alpha);
|
||||
|
||||
// Sample the environment light from the given direction.
|
||||
vec3 Lw = tangentToWorld * L;
|
||||
float pdf = mx_ggx_NDF(H, vec2(alpha)) * G1V / (4.0 * NdotV);
|
||||
float lod = mx_latlong_compute_lod(Lw, pdf, float($envRadianceMips - 1), envRadianceSamples);
|
||||
vec3 sampleColor = mx_latlong_map_lookup(Lw, $envMatrix, lod, $envRadiance);
|
||||
|
||||
// Add the radiance contribution of this sample.
|
||||
radiance += G * sampleColor;
|
||||
weight += G;
|
||||
}
|
||||
|
||||
return radiance / weight;
|
||||
}
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
#define M_PI 3.1415926535897932
|
||||
#define M_PI_INV (1.0 / M_PI)
|
||||
|
||||
float mx_pow5(float x)
|
||||
{
|
||||
return mx_square(mx_square(x)) * x;
|
||||
}
|
||||
|
||||
// Standard Schlick Fresnel
|
||||
float mx_fresnel_schlick(float cosTheta, float F0)
|
||||
{
|
||||
float x = clamp(1.0 - cosTheta, 0.0, 1.0);
|
||||
float x5 = mx_pow5(x);
|
||||
return F0 + (1.0 - F0) * x5;
|
||||
}
|
||||
vec3 mx_fresnel_schlick(float cosTheta, vec3 F0)
|
||||
{
|
||||
float x = clamp(1.0 - cosTheta, 0.0, 1.0);
|
||||
float x5 = mx_pow5(x);
|
||||
return F0 + (1.0 - F0) * x5;
|
||||
}
|
||||
|
||||
// Generalized Schlick Fresnel
|
||||
float mx_fresnel_schlick(float cosTheta, float F0, float F90)
|
||||
{
|
||||
float x = clamp(1.0 - cosTheta, 0.0, 1.0);
|
||||
float x5 = mx_pow5(x);
|
||||
return mix(F0, F90, x5);
|
||||
}
|
||||
vec3 mx_fresnel_schlick(float cosTheta, vec3 F0, vec3 F90)
|
||||
{
|
||||
float x = clamp(1.0 - cosTheta, 0.0, 1.0);
|
||||
float x5 = mx_pow5(x);
|
||||
return mix(F0, F90, x5);
|
||||
}
|
||||
|
||||
// Generalized Schlick Fresnel with a variable exponent
|
||||
float mx_fresnel_schlick(float cosTheta, float F0, float F90, float exponent)
|
||||
{
|
||||
float x = clamp(1.0 - cosTheta, 0.0, 1.0);
|
||||
return mix(F0, F90, pow(x, exponent));
|
||||
}
|
||||
vec3 mx_fresnel_schlick(float cosTheta, vec3 F0, vec3 F90, float exponent)
|
||||
{
|
||||
float x = clamp(1.0 - cosTheta, 0.0, 1.0);
|
||||
return mix(F0, F90, pow(x, exponent));
|
||||
}
|
||||
|
||||
// Enforce that the given normal is forward-facing from the specified view direction.
|
||||
vec3 mx_forward_facing_normal(vec3 N, vec3 V)
|
||||
{
|
||||
return (dot(N, V) < 0.0) ? -N : N;
|
||||
}
|
||||
|
||||
// https://www.graphics.rwth-aachen.de/publication/2/jgt.pdf
|
||||
float mx_golden_ratio_sequence(int i)
|
||||
{
|
||||
const float GOLDEN_RATIO = 1.6180339887498948;
|
||||
return fract((float(i) + 1.0) * GOLDEN_RATIO);
|
||||
}
|
||||
|
||||
// https://people.irisa.fr/Ricardo.Marques/articles/2013/SF_CGF.pdf
|
||||
vec2 mx_spherical_fibonacci(int i, int numSamples)
|
||||
{
|
||||
return vec2((float(i) + 0.5) / float(numSamples), mx_golden_ratio_sequence(i));
|
||||
}
|
||||
|
||||
// Generate a uniform-weighted sample in the unit hemisphere.
|
||||
vec3 mx_uniform_sample_hemisphere(vec2 Xi)
|
||||
{
|
||||
float phi = 2.0 * M_PI * Xi.x;
|
||||
float cosTheta = 1.0 - Xi.y;
|
||||
float sinTheta = sqrt(1.0 - mx_square(cosTheta));
|
||||
return vec3(cos(phi) * sinTheta,
|
||||
sin(phi) * sinTheta,
|
||||
cosTheta);
|
||||
}
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
#include "mx_microfacet.glsl"
|
||||
|
||||
// Based on the OSL implementation of Oren-Nayar diffuse, which is in turn
|
||||
// based on https://mimosa-pudica.net/improved-oren-nayar.html.
|
||||
float mx_oren_nayar_diffuse(vec3 L, vec3 V, vec3 N, float NdotL, float roughness)
|
||||
{
|
||||
float LdotV = clamp(dot(L, V), M_FLOAT_EPS, 1.0);
|
||||
float NdotV = clamp(dot(N, V), M_FLOAT_EPS, 1.0);
|
||||
float s = LdotV - NdotL * NdotV;
|
||||
float stinv = (s > 0.0f) ? s / max(NdotL, NdotV) : 0.0;
|
||||
|
||||
float sigma2 = mx_square(roughness * M_PI);
|
||||
float A = 1.0 - 0.5 * (sigma2 / (sigma2 + 0.33));
|
||||
float B = 0.45 * sigma2 / (sigma2 + 0.09);
|
||||
|
||||
return A + B * stinv;
|
||||
}
|
||||
|
||||
// https://media.disneyanimation.com/uploads/production/publication_asset/48/asset/s2012_pbs_disney_brdf_notes_v3.pdf
|
||||
// Section 5.3
|
||||
float mx_burley_diffuse(vec3 L, vec3 V, vec3 N, float NdotL, float roughness)
|
||||
{
|
||||
vec3 H = normalize(L + V);
|
||||
float LdotH = clamp(dot(L, H), M_FLOAT_EPS, 1.0);
|
||||
float NdotV = clamp(dot(N, V), M_FLOAT_EPS, 1.0);
|
||||
|
||||
float F90 = 0.5 + (2.0 * roughness * mx_square(LdotH));
|
||||
float refL = mx_fresnel_schlick(NdotL, 1.0, F90);
|
||||
float refV = mx_fresnel_schlick(NdotV, 1.0, F90);
|
||||
return refL * refV;
|
||||
}
|
||||
|
||||
// Compute the directional albedo component of Burley diffuse for the given
|
||||
// view angle and roughness. Curve fit provided by Stephen Hill.
|
||||
float mx_burley_diffuse_dir_albedo(float NdotV, float roughness)
|
||||
{
|
||||
float x = NdotV;
|
||||
float fit0 = 0.97619 - 0.488095 * mx_pow5(1.0 - x);
|
||||
float fit1 = 1.55754 + (-2.02221 + (2.56283 - 1.06244 * x) * x) * x;
|
||||
return mix(fit0, fit1, roughness);
|
||||
}
|
||||
|
||||
// Evaluate the Burley diffusion profile for the given distance and diffusion shape.
|
||||
// Based on https://graphics.pixar.com/library/ApproxBSSRDF/
|
||||
vec3 mx_burley_diffusion_profile(float dist, vec3 shape)
|
||||
{
|
||||
vec3 num1 = exp(-shape * dist);
|
||||
vec3 num2 = exp(-shape * dist / 3.0);
|
||||
float denom = max(dist, M_FLOAT_EPS);
|
||||
return (num1 + num2) / denom;
|
||||
}
|
||||
|
||||
// Integrate the Burley diffusion profile over a sphere of the given radius.
|
||||
// Inspired by Eric Penner's presentation in http://advances.realtimerendering.com/s2011/
|
||||
vec3 mx_integrate_burley_diffusion(vec3 N, vec3 L, float radius, vec3 mfp)
|
||||
{
|
||||
float theta = acos(dot(N, L));
|
||||
|
||||
// Estimate the Burley diffusion shape from mean free path.
|
||||
vec3 shape = vec3(1.0) / max(mfp, 0.1);
|
||||
|
||||
// Integrate the profile over the sphere.
|
||||
vec3 sumD = vec3(0.0);
|
||||
vec3 sumR = vec3(0.0);
|
||||
const int SAMPLE_COUNT = 32;
|
||||
const float SAMPLE_WIDTH = (2.0 * M_PI) / float(SAMPLE_COUNT);
|
||||
for (int i = 0; i < SAMPLE_COUNT; i++)
|
||||
{
|
||||
float x = -M_PI + (float(i) + 0.5) * SAMPLE_WIDTH;
|
||||
float dist = radius * abs(2.0 * sin(x * 0.5));
|
||||
vec3 R = mx_burley_diffusion_profile(dist, shape);
|
||||
sumD += R * max(cos(theta + x), 0.0);
|
||||
sumR += R;
|
||||
}
|
||||
|
||||
return sumD / sumR;
|
||||
}
|
||||
|
||||
vec3 mx_subsurface_scattering_approx(vec3 N, vec3 L, vec3 P, vec3 albedo, vec3 mfp)
|
||||
{
|
||||
float curvature = length(fwidth(N)) / length(fwidth(P));
|
||||
float radius = 1.0 / max(curvature, 0.01);
|
||||
return albedo * mx_integrate_burley_diffusion(N, L, radius, mfp) / vec3(M_PI);
|
||||
}
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
#include "mx_microfacet.glsl"
|
||||
|
||||
// http://www.aconty.com/pdf/s2017_pbs_imageworks_sheen.pdf
|
||||
// Equation 2
|
||||
float mx_imageworks_sheen_NDF(float NdotH, float roughness)
|
||||
{
|
||||
float invRoughness = 1.0 / max(roughness, 0.005);
|
||||
float cos2 = NdotH * NdotH;
|
||||
float sin2 = 1.0 - cos2;
|
||||
return (2.0 + invRoughness) * pow(sin2, invRoughness * 0.5) / (2.0 * M_PI);
|
||||
}
|
||||
|
||||
float mx_imageworks_sheen_brdf(float NdotL, float NdotV, float NdotH, float roughness)
|
||||
{
|
||||
// Microfacet distribution.
|
||||
float D = mx_imageworks_sheen_NDF(NdotH, roughness);
|
||||
|
||||
// Fresnel and geometry terms are ignored.
|
||||
float F = 1.0;
|
||||
float G = 1.0;
|
||||
|
||||
// We use a smoother denominator, as in:
|
||||
// https://blog.selfshadow.com/publications/s2013-shading-course/rad/s2013_pbs_rad_notes.pdf
|
||||
return D * F * G / (4.0 * (NdotL + NdotV - NdotL*NdotV));
|
||||
}
|
||||
|
||||
// Rational quadratic fit to Monte Carlo data for Imageworks sheen directional albedo.
|
||||
float mx_imageworks_sheen_dir_albedo_analytic(float NdotV, float roughness)
|
||||
{
|
||||
vec2 r = vec2(13.67300, 1.0) +
|
||||
vec2(-68.78018, 61.57746) * NdotV +
|
||||
vec2(799.08825, 442.78211) * roughness +
|
||||
vec2(-905.00061, 2597.49308) * NdotV * roughness +
|
||||
vec2(60.28956, 121.81241) * mx_square(NdotV) +
|
||||
vec2(1086.96473, 3045.55075) * mx_square(roughness);
|
||||
return r.x / r.y;
|
||||
}
|
||||
|
||||
float mx_imageworks_sheen_dir_albedo_table_lookup(float NdotV, float roughness)
|
||||
{
|
||||
#if DIRECTIONAL_ALBEDO_METHOD == 1
|
||||
if (textureSize($albedoTable, 0).x > 1)
|
||||
{
|
||||
return texture($albedoTable, vec2(NdotV, roughness)).b;
|
||||
}
|
||||
#endif
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
float mx_imageworks_sheen_dir_albedo_monte_carlo(float NdotV, float roughness)
|
||||
{
|
||||
NdotV = clamp(NdotV, M_FLOAT_EPS, 1.0);
|
||||
vec3 V = vec3(sqrt(1.0f - mx_square(NdotV)), 0, NdotV);
|
||||
|
||||
float radiance = 0.0;
|
||||
const int SAMPLE_COUNT = 64;
|
||||
for (int i = 0; i < SAMPLE_COUNT; i++)
|
||||
{
|
||||
vec2 Xi = mx_spherical_fibonacci(i, SAMPLE_COUNT);
|
||||
|
||||
// Compute the incoming light direction and half vector.
|
||||
vec3 L = mx_uniform_sample_hemisphere(Xi);
|
||||
vec3 H = normalize(L + V);
|
||||
|
||||
// Compute dot products for this sample.
|
||||
float NdotL = clamp(L.z, M_FLOAT_EPS, 1.0);
|
||||
float NdotH = clamp(H.z, M_FLOAT_EPS, 1.0);
|
||||
|
||||
// Compute sheen reflectance.
|
||||
float reflectance = mx_imageworks_sheen_brdf(NdotL, NdotV, NdotH, roughness);
|
||||
|
||||
// Add the radiance contribution of this sample.
|
||||
// uniform_pdf = 1 / (2 * PI)
|
||||
// radiance = reflectance * NdotL / uniform_pdf;
|
||||
radiance += reflectance * NdotL * 2.0 * M_PI;
|
||||
}
|
||||
|
||||
// Return the final directional albedo.
|
||||
return radiance / float(SAMPLE_COUNT);
|
||||
}
|
||||
|
||||
float mx_imageworks_sheen_dir_albedo(float NdotV, float roughness)
|
||||
{
|
||||
#if DIRECTIONAL_ALBEDO_METHOD == 0
|
||||
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
|
||||
float dirAlbedo = mx_imageworks_sheen_dir_albedo_monte_carlo(NdotV, roughness);
|
||||
#endif
|
||||
return clamp(dirAlbedo, 0.0, 1.0);
|
||||
}
|
||||
+606
@@ -0,0 +1,606 @@
|
||||
#include "mx_microfacet.glsl"
|
||||
|
||||
// Fresnel model options.
|
||||
const int FRESNEL_MODEL_DIELECTRIC = 0;
|
||||
const int FRESNEL_MODEL_CONDUCTOR = 1;
|
||||
const int FRESNEL_MODEL_SCHLICK = 2;
|
||||
const int FRESNEL_MODEL_AIRY = 3;
|
||||
const int FRESNEL_MODEL_SCHLICK_AIRY = 4;
|
||||
|
||||
// XYZ to CIE 1931 RGB color space (using neutral E illuminant)
|
||||
const mat3 XYZ_TO_RGB = mat3(2.3706743, -0.5138850, 0.0052982, -0.9000405, 1.4253036, -0.0146949, -0.4706338, 0.0885814, 1.0093968);
|
||||
|
||||
// Parameters for Fresnel calculations.
|
||||
struct FresnelData
|
||||
{
|
||||
int model;
|
||||
|
||||
// Physical Fresnel
|
||||
vec3 ior;
|
||||
vec3 extinction;
|
||||
|
||||
// Generalized Schlick Fresnel
|
||||
vec3 F0;
|
||||
vec3 F90;
|
||||
float exponent;
|
||||
|
||||
// Thin film
|
||||
float tf_thickness;
|
||||
float tf_ior;
|
||||
|
||||
// Refraction
|
||||
bool refraction;
|
||||
|
||||
#ifdef __METAL__
|
||||
FresnelData(int _model = 0,
|
||||
vec3 _ior = vec3(0.0f),
|
||||
vec3 _extinction = vec3(0.0f),
|
||||
vec3 _F0 = vec3(0.0f),
|
||||
vec3 _F90 = vec3(0.0f),
|
||||
float _exponent = 0.0f,
|
||||
float _tf_thickness = 0.0f,
|
||||
float _tf_ior = 0.0f,
|
||||
bool _refraction = false) :
|
||||
model(_model),
|
||||
ior(_ior),
|
||||
extinction(_extinction),
|
||||
F0(_F0), F90(_F90), exponent(_exponent),
|
||||
tf_thickness(_tf_thickness),
|
||||
tf_ior(_tf_ior),
|
||||
refraction(_refraction) {}
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
// https://media.disneyanimation.com/uploads/production/publication_asset/48/asset/s2012_pbs_disney_brdf_notes_v3.pdf
|
||||
// Appendix B.2 Equation 13
|
||||
float mx_ggx_NDF(vec3 H, vec2 alpha)
|
||||
{
|
||||
vec2 He = H.xy / alpha;
|
||||
float denom = dot(He, He) + mx_square(H.z);
|
||||
return 1.0 / (M_PI * alpha.x * alpha.y * mx_square(denom));
|
||||
}
|
||||
|
||||
// https://ggx-research.github.io/publication/2023/06/09/publication-ggx.html
|
||||
vec3 mx_ggx_importance_sample_VNDF(vec2 Xi, vec3 V, vec2 alpha)
|
||||
{
|
||||
// Transform the view direction to the hemisphere configuration.
|
||||
V = normalize(vec3(V.xy * alpha, V.z));
|
||||
|
||||
// Sample a spherical cap in (-V.z, 1].
|
||||
float phi = 2.0 * M_PI * Xi.x;
|
||||
float z = (1.0 - Xi.y) * (1.0 + V.z) - V.z;
|
||||
float sinTheta = sqrt(clamp(1.0 - z * z, 0.0, 1.0));
|
||||
float x = sinTheta * cos(phi);
|
||||
float y = sinTheta * sin(phi);
|
||||
vec3 c = vec3(x, y, z);
|
||||
|
||||
// Compute the microfacet normal.
|
||||
vec3 H = c + V;
|
||||
|
||||
// Transform the microfacet normal back to the ellipsoid configuration.
|
||||
H = normalize(vec3(H.xy * alpha, max(H.z, 0.0)));
|
||||
|
||||
return H;
|
||||
}
|
||||
|
||||
// https://www.cs.cornell.edu/~srm/publications/EGSR07-btdf.pdf
|
||||
// Equation 34
|
||||
float mx_ggx_smith_G1(float cosTheta, float alpha)
|
||||
{
|
||||
float cosTheta2 = mx_square(cosTheta);
|
||||
float tanTheta2 = (1.0 - cosTheta2) / cosTheta2;
|
||||
return 2.0 / (1.0 + sqrt(1.0 + mx_square(alpha) * tanTheta2));
|
||||
}
|
||||
|
||||
// Height-correlated Smith masking-shadowing
|
||||
// http://jcgt.org/published/0003/02/03/paper.pdf
|
||||
// Equations 72 and 99
|
||||
float mx_ggx_smith_G2(float NdotL, float NdotV, float alpha)
|
||||
{
|
||||
float alpha2 = mx_square(alpha);
|
||||
float lambdaL = sqrt(alpha2 + (1.0 - alpha2) * mx_square(NdotL));
|
||||
float lambdaV = sqrt(alpha2 + (1.0 - alpha2) * mx_square(NdotV));
|
||||
return 2.0 / (lambdaL / NdotL + lambdaV / NdotV);
|
||||
}
|
||||
|
||||
// Rational quadratic fit to Monte Carlo data for GGX directional albedo.
|
||||
vec3 mx_ggx_dir_albedo_analytic(float NdotV, float alpha, vec3 F0, vec3 F90)
|
||||
{
|
||||
float x = NdotV;
|
||||
float y = alpha;
|
||||
float x2 = mx_square(x);
|
||||
float y2 = mx_square(y);
|
||||
vec4 r = vec4(0.1003, 0.9345, 1.0, 1.0) +
|
||||
vec4(-0.6303, -2.323, -1.765, 0.2281) * x +
|
||||
vec4(9.748, 2.229, 8.263, 15.94) * y +
|
||||
vec4(-2.038, -3.748, 11.53, -55.83) * x * y +
|
||||
vec4(29.34, 1.424, 28.96, 13.08) * x2 +
|
||||
vec4(-8.245, -0.7684, -7.507, 41.26) * y2 +
|
||||
vec4(-26.44, 1.436, -36.11, 54.9) * x2 * y +
|
||||
vec4(19.99, 0.2913, 15.86, 300.2) * x * y2 +
|
||||
vec4(-5.448, 0.6286, 33.37, -285.1) * x2 * y2;
|
||||
vec2 AB = clamp(r.xy / r.zw, 0.0, 1.0);
|
||||
return F0 * AB.x + F90 * AB.y;
|
||||
}
|
||||
|
||||
vec3 mx_ggx_dir_albedo_table_lookup(float NdotV, float alpha, vec3 F0, vec3 F90)
|
||||
{
|
||||
#if DIRECTIONAL_ALBEDO_METHOD == 1
|
||||
if (textureSize($albedoTable, 0).x > 1)
|
||||
{
|
||||
vec2 AB = texture($albedoTable, vec2(NdotV, alpha)).rg;
|
||||
return F0 * AB.x + F90 * AB.y;
|
||||
}
|
||||
#endif
|
||||
return vec3(0.0);
|
||||
}
|
||||
|
||||
// https://cdn2.unrealengine.com/Resources/files/2013SiggraphPresentationsNotes-26915738.pdf
|
||||
vec3 mx_ggx_dir_albedo_monte_carlo(float NdotV, float alpha, vec3 F0, vec3 F90)
|
||||
{
|
||||
NdotV = clamp(NdotV, M_FLOAT_EPS, 1.0);
|
||||
vec3 V = vec3(sqrt(1.0 - mx_square(NdotV)), 0, NdotV);
|
||||
|
||||
vec2 AB = vec2(0.0);
|
||||
const int SAMPLE_COUNT = 64;
|
||||
for (int i = 0; i < SAMPLE_COUNT; i++)
|
||||
{
|
||||
vec2 Xi = mx_spherical_fibonacci(i, SAMPLE_COUNT);
|
||||
|
||||
// Compute the half vector and incoming light direction.
|
||||
vec3 H = mx_ggx_importance_sample_VNDF(Xi, V, vec2(alpha));
|
||||
vec3 L = -reflect(V, H);
|
||||
|
||||
// Compute dot products for this sample.
|
||||
float NdotL = clamp(L.z, M_FLOAT_EPS, 1.0);
|
||||
float VdotH = clamp(dot(V, H), M_FLOAT_EPS, 1.0);
|
||||
|
||||
// Compute the Fresnel term.
|
||||
float Fc = mx_fresnel_schlick(VdotH, 0.0, 1.0);
|
||||
|
||||
// Compute the per-sample geometric term.
|
||||
// https://hal.inria.fr/hal-00996995v2/document, Algorithm 2
|
||||
float G2 = mx_ggx_smith_G2(NdotL, NdotV, alpha);
|
||||
|
||||
// Add the contribution of this sample.
|
||||
AB += vec2(G2 * (1.0 - Fc), G2 * Fc);
|
||||
}
|
||||
|
||||
// Apply the global component of the geometric term and normalize.
|
||||
AB /= mx_ggx_smith_G1(NdotV, alpha) * float(SAMPLE_COUNT);
|
||||
|
||||
// Return the final directional albedo.
|
||||
return F0 * AB.x + F90 * AB.y;
|
||||
}
|
||||
|
||||
vec3 mx_ggx_dir_albedo(float NdotV, float alpha, vec3 F0, vec3 F90)
|
||||
{
|
||||
#if DIRECTIONAL_ALBEDO_METHOD == 0
|
||||
return mx_ggx_dir_albedo_analytic(NdotV, alpha, F0, F90);
|
||||
#elif DIRECTIONAL_ALBEDO_METHOD == 1
|
||||
return mx_ggx_dir_albedo_table_lookup(NdotV, alpha, F0, F90);
|
||||
#else
|
||||
return mx_ggx_dir_albedo_monte_carlo(NdotV, alpha, F0, F90);
|
||||
#endif
|
||||
}
|
||||
|
||||
float mx_ggx_dir_albedo(float NdotV, float alpha, float F0, float F90)
|
||||
{
|
||||
return mx_ggx_dir_albedo(NdotV, alpha, vec3(F0), vec3(F90)).x;
|
||||
}
|
||||
|
||||
// https://blog.selfshadow.com/publications/turquin/ms_comp_final.pdf
|
||||
// Equations 14 and 16
|
||||
vec3 mx_ggx_energy_compensation(float NdotV, float alpha, vec3 Fss)
|
||||
{
|
||||
float Ess = mx_ggx_dir_albedo(NdotV, alpha, 1.0, 1.0);
|
||||
return 1.0 + Fss * (1.0 - Ess) / Ess;
|
||||
}
|
||||
|
||||
float mx_ggx_energy_compensation(float NdotV, float alpha, float Fss)
|
||||
{
|
||||
return mx_ggx_energy_compensation(NdotV, alpha, vec3(Fss)).x;
|
||||
}
|
||||
|
||||
// Compute the average of an anisotropic alpha pair.
|
||||
float mx_average_alpha(vec2 alpha)
|
||||
{
|
||||
return sqrt(alpha.x * alpha.y);
|
||||
}
|
||||
|
||||
// Convert a real-valued index of refraction to normal-incidence reflectivity.
|
||||
float mx_ior_to_f0(float ior)
|
||||
{
|
||||
return mx_square((ior - 1.0) / (ior + 1.0));
|
||||
}
|
||||
|
||||
// Convert normal-incidence reflectivity to real-valued index of refraction.
|
||||
float mx_f0_to_ior(float F0)
|
||||
{
|
||||
float sqrtF0 = sqrt(clamp(F0, 0.01, 0.99));
|
||||
return (1.0 + sqrtF0) / (1.0 - sqrtF0);
|
||||
}
|
||||
|
||||
vec3 mx_f0_to_ior_colored(vec3 F0)
|
||||
{
|
||||
vec3 sqrtF0 = sqrt(clamp(F0, 0.01, 0.99));
|
||||
return (vec3(1.0) + sqrtF0) / (vec3(1.0) - sqrtF0);
|
||||
}
|
||||
|
||||
// https://seblagarde.wordpress.com/2013/04/29/memo-on-fresnel-equations/
|
||||
float mx_fresnel_dielectric(float cosTheta, float ior)
|
||||
{
|
||||
if (cosTheta < 0.0)
|
||||
return 1.0;
|
||||
|
||||
float g = ior*ior + cosTheta*cosTheta - 1.0;
|
||||
// Check for total internal reflection
|
||||
if (g < 0.0)
|
||||
return 1.0;
|
||||
|
||||
g = sqrt(g);
|
||||
float gmc = g - cosTheta;
|
||||
float gpc = g + cosTheta;
|
||||
float x = gmc / gpc;
|
||||
float y = (gpc * cosTheta - 1.0) / (gmc * cosTheta + 1.0);
|
||||
return 0.5 * x * x * (1.0 + y * y);
|
||||
}
|
||||
|
||||
void mx_fresnel_dielectric_polarized(float cosTheta, float n, out float Rp, out float Rs)
|
||||
{
|
||||
if (cosTheta < 0.0) {
|
||||
Rp = 1.0;
|
||||
Rs = 1.0;
|
||||
return;
|
||||
}
|
||||
|
||||
float cosTheta2 = cosTheta * cosTheta;
|
||||
float sinTheta2 = 1.0 - cosTheta2;
|
||||
float n2 = n * n;
|
||||
|
||||
float t0 = n2 - sinTheta2;
|
||||
float a2plusb2 = sqrt(t0 * t0);
|
||||
float t1 = a2plusb2 + cosTheta2;
|
||||
float a = sqrt(max(0.5 * (a2plusb2 + t0), 0.0));
|
||||
float t2 = 2.0 * a * cosTheta;
|
||||
Rs = (t1 - t2) / (t1 + t2);
|
||||
|
||||
float t3 = cosTheta2 * a2plusb2 + sinTheta2 * sinTheta2;
|
||||
float t4 = t2 * sinTheta2;
|
||||
Rp = Rs * (t3 - t4) / (t3 + t4);
|
||||
}
|
||||
|
||||
void mx_fresnel_dielectric_polarized(float cosTheta, float eta1, float eta2, out float Rp, out float Rs)
|
||||
{
|
||||
float n = eta2 / eta1;
|
||||
mx_fresnel_dielectric_polarized(cosTheta, n, Rp, Rs);
|
||||
}
|
||||
|
||||
void mx_fresnel_conductor_polarized(float cosTheta, vec3 n, vec3 k, out vec3 Rp, out vec3 Rs)
|
||||
{
|
||||
cosTheta = clamp(cosTheta, 0.0, 1.0);
|
||||
float cosTheta2 = cosTheta * cosTheta;
|
||||
float sinTheta2 = 1.0 - cosTheta2;
|
||||
vec3 n2 = n * n;
|
||||
vec3 k2 = k * k;
|
||||
|
||||
vec3 t0 = n2 - k2 - vec3(sinTheta2);
|
||||
vec3 a2plusb2 = sqrt(t0 * t0 + 4.0 * n2 * k2);
|
||||
vec3 t1 = a2plusb2 + vec3(cosTheta2);
|
||||
vec3 a = sqrt(max(0.5 * (a2plusb2 + t0), 0.0));
|
||||
vec3 t2 = 2.0 * a * cosTheta;
|
||||
Rs = (t1 - t2) / (t1 + t2);
|
||||
|
||||
vec3 t3 = cosTheta2 * a2plusb2 + vec3(sinTheta2 * sinTheta2);
|
||||
vec3 t4 = t2 * sinTheta2;
|
||||
Rp = Rs * (t3 - t4) / (t3 + t4);
|
||||
}
|
||||
|
||||
void mx_fresnel_conductor_polarized(float cosTheta, float eta1, vec3 eta2, vec3 kappa2, out vec3 Rp, out vec3 Rs)
|
||||
{
|
||||
vec3 n = eta2 / eta1;
|
||||
vec3 k = kappa2 / eta1;
|
||||
mx_fresnel_conductor_polarized(cosTheta, n, k, Rp, Rs);
|
||||
}
|
||||
|
||||
vec3 mx_fresnel_conductor(float cosTheta, vec3 n, vec3 k)
|
||||
{
|
||||
vec3 Rp, Rs;
|
||||
mx_fresnel_conductor_polarized(cosTheta, n, k, Rp, Rs);
|
||||
return 0.5 * (Rp + Rs);
|
||||
}
|
||||
|
||||
// Phase shift due to a dielectric material
|
||||
void mx_fresnel_dielectric_phase_polarized(float cosTheta, float eta1, float eta2, out float phiP, out float phiS)
|
||||
{
|
||||
float cosB = cos(atan(eta2 / eta1)); // Brewster's angle
|
||||
if (eta2 > eta1) {
|
||||
phiP = cosTheta < cosB ? M_PI : 0.0f;
|
||||
phiS = 0.0f;
|
||||
} else {
|
||||
phiP = cosTheta < cosB ? 0.0f : M_PI;
|
||||
phiS = M_PI;
|
||||
}
|
||||
}
|
||||
|
||||
// Phase shift due to a conducting material
|
||||
void mx_fresnel_conductor_phase_polarized(float cosTheta, float eta1, vec3 eta2, vec3 kappa2, out vec3 phiP, out vec3 phiS)
|
||||
{
|
||||
if (dot(kappa2, kappa2) == 0.0 && eta2.x == eta2.y && eta2.y == eta2.z) {
|
||||
// Use dielectric formula to increase performance
|
||||
float phiPx, phiSx;
|
||||
mx_fresnel_dielectric_phase_polarized(cosTheta, eta1, eta2.x, phiPx, phiSx);
|
||||
phiP = vec3(phiPx, phiPx, phiPx);
|
||||
phiS = vec3(phiSx, phiSx, phiSx);
|
||||
return;
|
||||
}
|
||||
vec3 k2 = kappa2 / eta2;
|
||||
vec3 sinThetaSqr = vec3(1.0) - cosTheta * cosTheta;
|
||||
vec3 A = eta2*eta2*(vec3(1.0)-k2*k2) - eta1*eta1*sinThetaSqr;
|
||||
vec3 B = sqrt(A*A + mx_square(2.0*eta2*eta2*k2));
|
||||
vec3 U = sqrt((A+B)/2.0);
|
||||
vec3 V = max(vec3(0.0), sqrt((B-A)/2.0));
|
||||
|
||||
phiS = atan(2.0*eta1*V*cosTheta, U*U + V*V - mx_square(eta1*cosTheta));
|
||||
phiP = atan(2.0*eta1*eta2*eta2*cosTheta * (2.0*k2*U - (vec3(1.0)-k2*k2) * V),
|
||||
mx_square(eta2*eta2*(vec3(1.0)+k2*k2)*cosTheta) - eta1*eta1*(U*U+V*V));
|
||||
}
|
||||
|
||||
// Evaluation XYZ sensitivity curves in Fourier space
|
||||
vec3 mx_eval_sensitivity(float opd, vec3 shift)
|
||||
{
|
||||
// Use Gaussian fits, given by 3 parameters: val, pos and var
|
||||
float phase = 2.0*M_PI * opd;
|
||||
vec3 val = vec3(5.4856e-13, 4.4201e-13, 5.2481e-13);
|
||||
vec3 pos = vec3(1.6810e+06, 1.7953e+06, 2.2084e+06);
|
||||
vec3 var = vec3(4.3278e+09, 9.3046e+09, 6.6121e+09);
|
||||
vec3 xyz = val * sqrt(2.0*M_PI * var) * cos(pos * phase + shift) * exp(- var * phase*phase);
|
||||
xyz.x += 9.7470e-14 * sqrt(2.0*M_PI * 4.5282e+09) * cos(2.2399e+06 * phase + shift[0]) * exp(- 4.5282e+09 * phase*phase);
|
||||
return xyz / 1.0685e-7;
|
||||
}
|
||||
|
||||
// A Practical Extension to Microfacet Theory for the Modeling of Varying Iridescence
|
||||
// https://belcour.github.io/blog/research/publication/2017/05/01/brdf-thin-film.html
|
||||
vec3 mx_fresnel_airy(float cosTheta, vec3 ior, vec3 extinction, float tf_thickness, float tf_ior,
|
||||
vec3 f0, vec3 f90, float exponent, bool use_schlick)
|
||||
{
|
||||
// Convert nm -> m
|
||||
float d = tf_thickness * 1.0e-9;
|
||||
|
||||
// Assume vacuum on the outside
|
||||
float eta1 = 1.0;
|
||||
float eta2 = max(tf_ior, eta1);
|
||||
vec3 eta3 = use_schlick ? mx_f0_to_ior_colored(f0) : ior;
|
||||
vec3 kappa3 = use_schlick ? vec3(0.0) : extinction;
|
||||
|
||||
// Compute the Spectral versions of the Fresnel reflectance and
|
||||
// transmitance for each interface.
|
||||
float R12p, T121p, R12s, T121s;
|
||||
vec3 R23p, R23s;
|
||||
|
||||
// Reflected and transmitted parts in the thin film
|
||||
mx_fresnel_dielectric_polarized(cosTheta, eta1, eta2, R12p, R12s);
|
||||
|
||||
// Reflected part by the base
|
||||
float scale = eta1 / eta2;
|
||||
float cosThetaTSqr = 1.0 - (1.0-cosTheta*cosTheta) * scale*scale;
|
||||
float cosTheta2 = sqrt(cosThetaTSqr);
|
||||
if (use_schlick)
|
||||
{
|
||||
vec3 f = mx_fresnel_schlick(cosTheta2, f0, f90, exponent);
|
||||
R23p = 0.5 * f;
|
||||
R23s = 0.5 * f;
|
||||
}
|
||||
else
|
||||
{
|
||||
mx_fresnel_conductor_polarized(cosTheta2, eta2, eta3, kappa3, R23p, R23s);
|
||||
}
|
||||
|
||||
// Check for total internal reflection
|
||||
if (cosThetaTSqr <= 0.0f)
|
||||
{
|
||||
R12s = 1.0;
|
||||
R12p = 1.0;
|
||||
}
|
||||
|
||||
// Compute the transmission coefficients
|
||||
T121p = 1.0 - R12p;
|
||||
T121s = 1.0 - R12s;
|
||||
|
||||
// Optical path difference
|
||||
float D = 2.0 * eta2 * d * cosTheta2;
|
||||
|
||||
float phi21p, phi21s;
|
||||
vec3 phi23p, phi23s, r123s, r123p;
|
||||
|
||||
// Evaluate the phase shift
|
||||
mx_fresnel_dielectric_phase_polarized(cosTheta, eta1, eta2, phi21p, phi21s);
|
||||
if (use_schlick)
|
||||
{
|
||||
phi23p = vec3(
|
||||
(eta3[0] < eta2) ? M_PI : 0.0,
|
||||
(eta3[1] < eta2) ? M_PI : 0.0,
|
||||
(eta3[2] < eta2) ? M_PI : 0.0);
|
||||
phi23s = phi23p;
|
||||
}
|
||||
else
|
||||
{
|
||||
mx_fresnel_conductor_phase_polarized(cosTheta2, eta2, eta3, kappa3, phi23p, phi23s);
|
||||
}
|
||||
|
||||
phi21p = M_PI - phi21p;
|
||||
phi21s = M_PI - phi21s;
|
||||
|
||||
r123p = max(vec3(0.0), sqrt(R12p*R23p));
|
||||
r123s = max(vec3(0.0), sqrt(R12s*R23s));
|
||||
|
||||
// Evaluate iridescence term
|
||||
vec3 I = vec3(0.0);
|
||||
vec3 C0, Cm, Sm;
|
||||
|
||||
// Iridescence term using spectral antialiasing for Parallel polarization
|
||||
|
||||
vec3 S0 = vec3(1.0);
|
||||
|
||||
// Reflectance term for m=0 (DC term amplitude)
|
||||
vec3 Rs = (T121p*T121p*R23p) / (vec3(1.0) - R12p*R23p);
|
||||
C0 = R12p + Rs;
|
||||
I += C0 * S0;
|
||||
|
||||
// Reflectance term for m>0 (pairs of diracs)
|
||||
Cm = Rs - T121p;
|
||||
for (int m=1; m<=2; ++m)
|
||||
{
|
||||
Cm *= r123p;
|
||||
Sm = 2.0 * mx_eval_sensitivity(float(m)*D, float(m)*(phi23p+vec3(phi21p)));
|
||||
I += Cm*Sm;
|
||||
}
|
||||
|
||||
// Iridescence term using spectral antialiasing for Perpendicular polarization
|
||||
|
||||
// Reflectance term for m=0 (DC term amplitude)
|
||||
vec3 Rp = (T121s*T121s*R23s) / (vec3(1.0) - R12s*R23s);
|
||||
C0 = R12s + Rp;
|
||||
I += C0 * S0;
|
||||
|
||||
// Reflectance term for m>0 (pairs of diracs)
|
||||
Cm = Rp - T121s ;
|
||||
for (int m=1; m<=2; ++m)
|
||||
{
|
||||
Cm *= r123s;
|
||||
Sm = 2.0 * mx_eval_sensitivity(float(m)*D, float(m)*(phi23s+vec3(phi21s)));
|
||||
I += Cm*Sm;
|
||||
}
|
||||
|
||||
// Average parallel and perpendicular polarization
|
||||
I *= 0.5;
|
||||
|
||||
// Convert back to RGB reflectance
|
||||
I = clamp(XYZ_TO_RGB * I, vec3(0.0), vec3(1.0));
|
||||
|
||||
return I;
|
||||
}
|
||||
|
||||
FresnelData mx_init_fresnel_data(int model)
|
||||
{
|
||||
return FresnelData(model, vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0), 0.0, 0.0, 0.0, false);
|
||||
}
|
||||
|
||||
FresnelData mx_init_fresnel_dielectric(float ior)
|
||||
{
|
||||
FresnelData fd = mx_init_fresnel_data(FRESNEL_MODEL_DIELECTRIC);
|
||||
fd.ior = vec3(ior);
|
||||
return fd;
|
||||
}
|
||||
|
||||
FresnelData mx_init_fresnel_conductor(vec3 ior, vec3 extinction)
|
||||
{
|
||||
FresnelData fd = mx_init_fresnel_data(FRESNEL_MODEL_CONDUCTOR);
|
||||
fd.ior = ior;
|
||||
fd.extinction = extinction;
|
||||
return fd;
|
||||
}
|
||||
|
||||
FresnelData mx_init_fresnel_schlick(vec3 F0)
|
||||
{
|
||||
FresnelData fd = mx_init_fresnel_data(FRESNEL_MODEL_SCHLICK);
|
||||
fd.F0 = F0;
|
||||
fd.F90 = vec3(1.0);
|
||||
fd.exponent = 5.0f;
|
||||
return fd;
|
||||
}
|
||||
|
||||
FresnelData mx_init_fresnel_schlick(vec3 F0, vec3 F90, float exponent)
|
||||
{
|
||||
FresnelData fd = mx_init_fresnel_data(FRESNEL_MODEL_SCHLICK);
|
||||
fd.F0 = F0;
|
||||
fd.F90 = F90;
|
||||
fd.exponent = exponent;
|
||||
return fd;
|
||||
}
|
||||
|
||||
FresnelData mx_init_fresnel_schlick_airy(vec3 F0, vec3 F90, float exponent, float tf_thickness, float tf_ior)
|
||||
{
|
||||
FresnelData fd = mx_init_fresnel_data(FRESNEL_MODEL_SCHLICK_AIRY);
|
||||
fd.F0 = F0;
|
||||
fd.F90 = F90;
|
||||
fd.exponent = exponent;
|
||||
fd.tf_thickness = tf_thickness;
|
||||
fd.tf_ior = tf_ior;
|
||||
return fd;
|
||||
}
|
||||
|
||||
FresnelData mx_init_fresnel_dielectric_airy(float ior, float tf_thickness, float tf_ior)
|
||||
{
|
||||
FresnelData fd = mx_init_fresnel_data(FRESNEL_MODEL_AIRY);
|
||||
fd.ior = vec3(ior);
|
||||
fd.tf_thickness = tf_thickness;
|
||||
fd.tf_ior = tf_ior;
|
||||
return fd;
|
||||
}
|
||||
|
||||
FresnelData mx_init_fresnel_conductor_airy(vec3 ior, vec3 extinction, float tf_thickness, float tf_ior)
|
||||
{
|
||||
FresnelData fd = mx_init_fresnel_data(FRESNEL_MODEL_AIRY);
|
||||
fd.ior = ior;
|
||||
fd.extinction = extinction;
|
||||
fd.tf_thickness = tf_thickness;
|
||||
fd.tf_ior = tf_ior;
|
||||
return fd;
|
||||
}
|
||||
|
||||
vec3 mx_compute_fresnel(float cosTheta, FresnelData fd)
|
||||
{
|
||||
if (fd.model == FRESNEL_MODEL_DIELECTRIC)
|
||||
{
|
||||
return vec3(mx_fresnel_dielectric(cosTheta, fd.ior.x));
|
||||
}
|
||||
else if (fd.model == FRESNEL_MODEL_CONDUCTOR)
|
||||
{
|
||||
return mx_fresnel_conductor(cosTheta, fd.ior, fd.extinction);
|
||||
}
|
||||
else if (fd.model == FRESNEL_MODEL_SCHLICK)
|
||||
{
|
||||
return mx_fresnel_schlick(cosTheta, fd.F0, fd.F90, fd.exponent);
|
||||
}
|
||||
else
|
||||
{
|
||||
return mx_fresnel_airy(cosTheta, fd.ior, fd.extinction, fd.tf_thickness, fd.tf_ior,
|
||||
fd.F0, fd.F90, fd.exponent,
|
||||
fd.model == FRESNEL_MODEL_SCHLICK_AIRY);
|
||||
}
|
||||
}
|
||||
|
||||
// Compute the refraction of a ray through a solid sphere.
|
||||
vec3 mx_refraction_solid_sphere(vec3 R, vec3 N, float ior)
|
||||
{
|
||||
R = refract(R, N, 1.0 / ior);
|
||||
vec3 N1 = normalize(R * dot(R, N) - N * 0.5);
|
||||
return refract(R, N1, ior);
|
||||
}
|
||||
|
||||
vec2 mx_latlong_projection(vec3 dir)
|
||||
{
|
||||
float latitude = -asin(dir.y) * M_PI_INV + 0.5;
|
||||
float longitude = atan(dir.x, -dir.z) * M_PI_INV * 0.5 + 0.5;
|
||||
return vec2(longitude, latitude);
|
||||
}
|
||||
|
||||
vec3 mx_latlong_map_lookup(vec3 dir, mat4 transform, float lod, sampler2D envSampler)
|
||||
{
|
||||
vec3 envDir = normalize((transform * vec4(dir,0.0)).xyz);
|
||||
vec2 uv = mx_latlong_projection(envDir);
|
||||
return textureLod(envSampler, uv, lod).rgb;
|
||||
}
|
||||
|
||||
// Return the mip level with the appropriate coverage for a filtered importance sample.
|
||||
// https://developer.nvidia.com/gpugems/GPUGems3/gpugems3_ch20.html
|
||||
// Section 20.4 Equation 13
|
||||
float mx_latlong_compute_lod(vec3 dir, float pdf, float maxMipLevel, int envSamples)
|
||||
{
|
||||
const float MIP_LEVEL_OFFSET = 1.5;
|
||||
float effectiveMaxMipLevel = maxMipLevel - MIP_LEVEL_OFFSET;
|
||||
float distortion = sqrt(1.0 - mx_square(dir.y));
|
||||
return max(effectiveMaxMipLevel - 0.5 * log2(float(envSamples) * pdf * distortion), 0.0);
|
||||
}
|
||||
Vendored
+23
@@ -0,0 +1,23 @@
|
||||
// https://developer.nvidia.com/gpugems/gpugems3/part-ii-light-and-shadows/chapter-8-summed-area-variance-shadow-maps
|
||||
float mx_variance_shadow_occlusion(vec2 moments, float fragmentDepth)
|
||||
{
|
||||
const float MIN_VARIANCE = 0.00001;
|
||||
|
||||
// One-tailed inequality valid if fragmentDepth > moments.x.
|
||||
float p = (fragmentDepth <= moments.x) ? 1.0 : 0.0;
|
||||
|
||||
// Compute variance.
|
||||
float variance = moments.y - mx_square(moments.x);
|
||||
variance = max(variance, MIN_VARIANCE);
|
||||
|
||||
// Compute probabilistic upper bound.
|
||||
float d = fragmentDepth - moments.x;
|
||||
float pMax = variance / (variance + mx_square(d));
|
||||
return max(p, pMax);
|
||||
}
|
||||
|
||||
vec2 mx_compute_depth_moments()
|
||||
{
|
||||
float depth = gl_FragCoord.z;
|
||||
return vec2(depth, mx_square(depth));
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
#include "mx_microfacet_specular.glsl"
|
||||
|
||||
vec3 mx_surface_transmission(vec3 N, vec3 V, vec3 X, vec2 alpha, int distribution, FresnelData fd, vec3 tint)
|
||||
{
|
||||
return tint;
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
#include "mx_microfacet_specular.glsl"
|
||||
|
||||
vec3 mx_surface_transmission(vec3 N, vec3 V, vec3 X, vec2 alpha, int distribution, FresnelData fd, vec3 tint)
|
||||
{
|
||||
// Approximate the appearance of surface transmission as glossy
|
||||
// environment map refraction, ignoring any scene geometry that might
|
||||
// be visible through the surface.
|
||||
fd.refraction = true;
|
||||
if ($refractionTwoSided)
|
||||
{
|
||||
tint = mx_square(tint);
|
||||
}
|
||||
return mx_environment_radiance(N, V, X, alpha, distribution, fd) * tint;
|
||||
}
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
void mx_add_edf(vec3 N, vec3 L, EDF in1, EDF in2, out EDF result)
|
||||
{
|
||||
result = in1 + in2;
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
void mx_anisotropic_vdf(vec3 absorption, vec3 scattering, float anisotropy, inout BSDF bsdf)
|
||||
{
|
||||
// TODO: Add some approximation for volumetric light absorption.
|
||||
}
|
||||
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
void mx_artistic_ior(vec3 reflectivity, vec3 edge_color, out vec3 ior, out vec3 extinction)
|
||||
{
|
||||
// "Artist Friendly Metallic Fresnel", Ole Gulbrandsen, 2014
|
||||
// http://jcgt.org/published/0003/04/03/paper.pdf
|
||||
|
||||
vec3 r = clamp(reflectivity, 0.0, 0.99);
|
||||
vec3 r_sqrt = sqrt(r);
|
||||
vec3 n_min = (1.0 - r) / (1.0 + r);
|
||||
vec3 n_max = (1.0 + r_sqrt) / (1.0 - r_sqrt);
|
||||
ior = mix(n_max, n_min, edge_color);
|
||||
|
||||
vec3 np1 = ior + 1.0;
|
||||
vec3 nm1 = ior - 1.0;
|
||||
vec3 k2 = (np1*np1 * r - nm1*nm1) / (1.0 - r);
|
||||
k2 = max(k2, 0.0);
|
||||
extinction = sqrt(k2);
|
||||
}
|
||||
Vendored
+48
@@ -0,0 +1,48 @@
|
||||
/// XYZ to Rec.709 RGB colorspace conversion
|
||||
const mat3 XYZ_to_RGB = mat3( 3.2406, -0.9689, 0.0557,
|
||||
-1.5372, 1.8758, -0.2040,
|
||||
-0.4986, 0.0415, 1.0570);
|
||||
|
||||
void mx_blackbody(float temperatureKelvin, out vec3 colorValue)
|
||||
{
|
||||
float xc, yc;
|
||||
float t, t2, t3, xc2, xc3;
|
||||
|
||||
// if value outside valid range of approximation clamp to accepted temperature range
|
||||
temperatureKelvin = clamp(temperatureKelvin, 1667.0, 25000.0);
|
||||
|
||||
t = 1000.0 / temperatureKelvin;
|
||||
t2 = t * t;
|
||||
t3 = t * t * t;
|
||||
|
||||
// Cubic spline approximation for Kelvin temperature to sRGB conversion
|
||||
// (https://en.wikipedia.org/wiki/Planckian_locus#Approximation)
|
||||
if (temperatureKelvin < 4000.0) { // 1667K <= temperatureKelvin < 4000K
|
||||
xc = -0.2661239 * t3 - 0.2343580 * t2 + 0.8776956 * t + 0.179910;
|
||||
}
|
||||
else { // 4000K <= temperatureKelvin <= 25000K
|
||||
xc = -3.0258469 * t3 + 2.1070379 * t2 + 0.2226347 * t + 0.240390;
|
||||
}
|
||||
xc2 = xc * xc;
|
||||
xc3 = xc * xc * xc;
|
||||
|
||||
if (temperatureKelvin < 2222.0) { // 1667K <= temperatureKelvin < 2222K
|
||||
yc = -1.1063814 * xc3 - 1.34811020 * xc2 + 2.18555832 * xc - 0.20219683;
|
||||
}
|
||||
else if (temperatureKelvin < 4000.0) { // 2222K <= temperatureKelvin < 4000K
|
||||
yc = -0.9549476 * xc3 - 1.37418593 * xc2 + 2.09137015 * xc - 0.16748867;
|
||||
}
|
||||
else { // 4000K <= temperatureKelvin <= 25000K
|
||||
yc = 3.0817580 * xc3 - 5.87338670 * xc2 + 3.75112997 * xc - 0.37001483;
|
||||
}
|
||||
|
||||
if (yc <= 0.0) { // avoid division by zero
|
||||
colorValue = vec3(1.0);
|
||||
return;
|
||||
}
|
||||
|
||||
vec3 XYZ = vec3(xc / yc, 1.0, (1.0 - xc - yc) / yc);
|
||||
|
||||
colorValue = XYZ_to_RGB * XYZ;
|
||||
colorValue = max(colorValue, vec3(0.0));
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
#include "lib/mx_microfacet_diffuse.glsl"
|
||||
|
||||
void mx_burley_diffuse_bsdf_reflection(vec3 L, vec3 V, vec3 P, float occlusion, float weight, vec3 color, float roughness, vec3 normal, inout BSDF bsdf)
|
||||
{
|
||||
bsdf.throughput = vec3(0.0);
|
||||
|
||||
if (weight < M_FLOAT_EPS)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
normal = mx_forward_facing_normal(normal, V);
|
||||
|
||||
float NdotL = clamp(dot(normal, L), M_FLOAT_EPS, 1.0);
|
||||
|
||||
bsdf.response = color * occlusion * weight * NdotL * M_PI_INV;
|
||||
bsdf.response *= mx_burley_diffuse(L, V, normal, NdotL, roughness);
|
||||
}
|
||||
|
||||
void mx_burley_diffuse_bsdf_indirect(vec3 V, float weight, vec3 color, float roughness, vec3 normal, inout BSDF bsdf)
|
||||
{
|
||||
bsdf.throughput = vec3(0.0);
|
||||
|
||||
if (weight < M_FLOAT_EPS)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
normal = mx_forward_facing_normal(normal, V);
|
||||
|
||||
float NdotV = clamp(dot(normal, V), M_FLOAT_EPS, 1.0);
|
||||
|
||||
vec3 Li = mx_environment_irradiance(normal) *
|
||||
mx_burley_diffuse_dir_albedo(NdotV, roughness);
|
||||
bsdf.response = Li * color * weight;
|
||||
}
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
#include "lib/mx_microfacet_specular.glsl"
|
||||
|
||||
void mx_conductor_bsdf_reflection(vec3 L, vec3 V, vec3 P, float occlusion, float weight, vec3 ior_n, vec3 ior_k, vec2 roughness, vec3 N, vec3 X, int distribution, inout BSDF bsdf)
|
||||
{
|
||||
bsdf.throughput = vec3(0.0);
|
||||
|
||||
if (weight < M_FLOAT_EPS)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
N = mx_forward_facing_normal(N, V);
|
||||
|
||||
X = normalize(X - dot(X, N) * N);
|
||||
vec3 Y = cross(N, X);
|
||||
vec3 H = normalize(L + V);
|
||||
|
||||
float NdotL = clamp(dot(N, L), M_FLOAT_EPS, 1.0);
|
||||
float NdotV = clamp(dot(N, V), M_FLOAT_EPS, 1.0);
|
||||
float VdotH = clamp(dot(V, H), M_FLOAT_EPS, 1.0);
|
||||
|
||||
vec2 safeAlpha = clamp(roughness, M_FLOAT_EPS, 1.0);
|
||||
float avgAlpha = mx_average_alpha(safeAlpha);
|
||||
vec3 Ht = vec3(dot(H, X), dot(H, Y), dot(H, N));
|
||||
|
||||
FresnelData fd;
|
||||
if (bsdf.thickness > 0.0)
|
||||
fd = mx_init_fresnel_conductor_airy(ior_n, ior_k, bsdf.thickness, bsdf.ior);
|
||||
else
|
||||
fd = mx_init_fresnel_conductor(ior_n, ior_k);
|
||||
|
||||
vec3 F = mx_compute_fresnel(VdotH, fd);
|
||||
float D = mx_ggx_NDF(Ht, safeAlpha);
|
||||
float G = mx_ggx_smith_G2(NdotL, NdotV, avgAlpha);
|
||||
|
||||
vec3 comp = mx_ggx_energy_compensation(NdotV, avgAlpha, F);
|
||||
|
||||
// Note: NdotL is cancelled out
|
||||
bsdf.response = D * F * G * comp * occlusion * weight / (4.0 * NdotV);
|
||||
}
|
||||
|
||||
void mx_conductor_bsdf_indirect(vec3 V, float weight, vec3 ior_n, vec3 ior_k, vec2 roughness, vec3 N, vec3 X, int distribution, inout BSDF bsdf)
|
||||
{
|
||||
bsdf.throughput = vec3(0.0);
|
||||
|
||||
if (weight < M_FLOAT_EPS)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
N = mx_forward_facing_normal(N, V);
|
||||
|
||||
float NdotV = clamp(dot(N, V), M_FLOAT_EPS, 1.0);
|
||||
|
||||
FresnelData fd;
|
||||
if (bsdf.thickness > 0.0)
|
||||
fd = mx_init_fresnel_conductor_airy(ior_n, ior_k, bsdf.thickness, bsdf.ior);
|
||||
else
|
||||
fd = mx_init_fresnel_conductor(ior_n, ior_k);
|
||||
|
||||
vec3 F = mx_compute_fresnel(NdotV, fd);
|
||||
|
||||
vec2 safeAlpha = clamp(roughness, M_FLOAT_EPS, 1.0);
|
||||
float avgAlpha = mx_average_alpha(safeAlpha);
|
||||
vec3 comp = mx_ggx_energy_compensation(NdotV, avgAlpha, F);
|
||||
|
||||
vec3 Li = mx_environment_radiance(N, V, X, safeAlpha, distribution, fd);
|
||||
|
||||
bsdf.response = Li * comp * weight;
|
||||
}
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
#include "lib/mx_microfacet_specular.glsl"
|
||||
|
||||
void mx_dielectric_bsdf_reflection(vec3 L, vec3 V, vec3 P, float occlusion, float weight, vec3 tint, float ior, vec2 roughness, vec3 N, vec3 X, int distribution, int scatter_mode, inout BSDF bsdf)
|
||||
{
|
||||
if (weight < M_FLOAT_EPS)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
N = mx_forward_facing_normal(N, V);
|
||||
|
||||
X = normalize(X - dot(X, N) * N);
|
||||
vec3 Y = cross(N, X);
|
||||
vec3 H = normalize(L + V);
|
||||
|
||||
float NdotL = clamp(dot(N, L), M_FLOAT_EPS, 1.0);
|
||||
float NdotV = clamp(dot(N, V), M_FLOAT_EPS, 1.0);
|
||||
float VdotH = clamp(dot(V, H), M_FLOAT_EPS, 1.0);
|
||||
|
||||
vec2 safeAlpha = clamp(roughness, M_FLOAT_EPS, 1.0);
|
||||
float avgAlpha = mx_average_alpha(safeAlpha);
|
||||
vec3 Ht = vec3(dot(H, X), dot(H, Y), dot(H, N));
|
||||
|
||||
FresnelData fd;
|
||||
vec3 safeTint = max(tint, 0.0);
|
||||
if (bsdf.thickness > 0.0)
|
||||
{
|
||||
fd = mx_init_fresnel_dielectric_airy(ior, bsdf.thickness, bsdf.ior);
|
||||
}
|
||||
else
|
||||
{
|
||||
fd = mx_init_fresnel_dielectric(ior);
|
||||
}
|
||||
vec3 F = mx_compute_fresnel(VdotH, fd);
|
||||
float D = mx_ggx_NDF(Ht, safeAlpha);
|
||||
float G = mx_ggx_smith_G2(NdotL, NdotV, avgAlpha);
|
||||
|
||||
float F0 = mx_ior_to_f0(ior);
|
||||
vec3 comp = mx_ggx_energy_compensation(NdotV, avgAlpha, F);
|
||||
vec3 dirAlbedo = mx_ggx_dir_albedo(NdotV, avgAlpha, F0, 1.0) * comp;
|
||||
bsdf.throughput = 1.0 - dirAlbedo * weight;
|
||||
|
||||
// Note: NdotL is cancelled out
|
||||
bsdf.response = D * F * G * comp * safeTint * occlusion * weight / (4.0 * NdotV);
|
||||
}
|
||||
|
||||
void mx_dielectric_bsdf_transmission(vec3 V, float weight, vec3 tint, float ior, vec2 roughness, vec3 N, vec3 X, int distribution, int scatter_mode, inout BSDF bsdf)
|
||||
{
|
||||
if (weight < M_FLOAT_EPS)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
N = mx_forward_facing_normal(N, V);
|
||||
float NdotV = clamp(dot(N, V), M_FLOAT_EPS, 1.0);
|
||||
|
||||
FresnelData fd;
|
||||
vec3 safeTint = max(tint, 0.0);
|
||||
if (bsdf.thickness > 0.0)
|
||||
{
|
||||
fd = mx_init_fresnel_dielectric_airy(ior, bsdf.thickness, bsdf.ior);
|
||||
}
|
||||
else
|
||||
{
|
||||
fd = mx_init_fresnel_dielectric(ior);
|
||||
}
|
||||
vec3 F = mx_compute_fresnel(NdotV, fd);
|
||||
|
||||
vec2 safeAlpha = clamp(roughness, M_FLOAT_EPS, 1.0);
|
||||
float avgAlpha = mx_average_alpha(safeAlpha);
|
||||
|
||||
float F0 = mx_ior_to_f0(ior);
|
||||
vec3 comp = mx_ggx_energy_compensation(NdotV, avgAlpha, F);
|
||||
vec3 dirAlbedo = mx_ggx_dir_albedo(NdotV, avgAlpha, F0, 1.0) * comp;
|
||||
bsdf.throughput = 1.0 - dirAlbedo * weight;
|
||||
|
||||
if (scatter_mode != 0)
|
||||
{
|
||||
bsdf.response = mx_surface_transmission(N, V, X, safeAlpha, distribution, fd, safeTint) * weight;
|
||||
}
|
||||
}
|
||||
|
||||
void mx_dielectric_bsdf_indirect(vec3 V, float weight, vec3 tint, float ior, vec2 roughness, vec3 N, vec3 X, int distribution, int scatter_mode, inout BSDF bsdf)
|
||||
{
|
||||
if (weight < M_FLOAT_EPS)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
N = mx_forward_facing_normal(N, V);
|
||||
|
||||
float NdotV = clamp(dot(N, V), M_FLOAT_EPS, 1.0);
|
||||
|
||||
FresnelData fd;
|
||||
vec3 safeTint = max(tint, 0.0);
|
||||
if (bsdf.thickness > 0.0)
|
||||
{
|
||||
fd = mx_init_fresnel_dielectric_airy(ior, bsdf.thickness, bsdf.ior);
|
||||
}
|
||||
else
|
||||
{
|
||||
fd = mx_init_fresnel_dielectric(ior);
|
||||
}
|
||||
vec3 F = mx_compute_fresnel(NdotV, fd);
|
||||
|
||||
vec2 safeAlpha = clamp(roughness, M_FLOAT_EPS, 1.0);
|
||||
float avgAlpha = mx_average_alpha(safeAlpha);
|
||||
|
||||
float F0 = mx_ior_to_f0(ior);
|
||||
vec3 comp = mx_ggx_energy_compensation(NdotV, avgAlpha, F);
|
||||
vec3 dirAlbedo = mx_ggx_dir_albedo(NdotV, avgAlpha, F0, 1.0) * comp;
|
||||
bsdf.throughput = 1.0 - dirAlbedo * weight;
|
||||
|
||||
vec3 Li = mx_environment_radiance(N, V, X, safeAlpha, distribution, fd);
|
||||
bsdf.response = Li * safeTint * comp * weight;
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
void mx_displacement_float(float disp, float scale, out displacementshader result)
|
||||
{
|
||||
result.offset = vec3(disp);
|
||||
result.scale = scale;
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
void mx_displacement_vector3(vec3 disp, float scale, out displacementshader result)
|
||||
{
|
||||
result.offset = disp;
|
||||
result.scale = scale;
|
||||
}
|
||||
+119
@@ -0,0 +1,119 @@
|
||||
#include "lib/mx_microfacet_specular.glsl"
|
||||
|
||||
void mx_generalized_schlick_bsdf_reflection(vec3 L, vec3 V, vec3 P, float occlusion, float weight, vec3 color0, vec3 color90, float exponent, vec2 roughness, vec3 N, vec3 X, int distribution, int scatter_mode, inout BSDF bsdf)
|
||||
{
|
||||
if (weight < M_FLOAT_EPS)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
N = mx_forward_facing_normal(N, V);
|
||||
|
||||
X = normalize(X - dot(X, N) * N);
|
||||
vec3 Y = cross(N, X);
|
||||
vec3 H = normalize(L + V);
|
||||
|
||||
float NdotL = clamp(dot(N, L), M_FLOAT_EPS, 1.0);
|
||||
float NdotV = clamp(dot(N, V), M_FLOAT_EPS, 1.0);
|
||||
float VdotH = clamp(dot(V, H), M_FLOAT_EPS, 1.0);
|
||||
|
||||
vec2 safeAlpha = clamp(roughness, M_FLOAT_EPS, 1.0);
|
||||
float avgAlpha = mx_average_alpha(safeAlpha);
|
||||
vec3 Ht = vec3(dot(H, X), dot(H, Y), dot(H, N));
|
||||
|
||||
FresnelData fd;
|
||||
vec3 safeColor0 = max(color0, 0.0);
|
||||
vec3 safeColor90 = max(color90, 0.0);
|
||||
if (bsdf.thickness > 0.0)
|
||||
{
|
||||
fd = mx_init_fresnel_schlick_airy(safeColor0, safeColor90, exponent, bsdf.thickness, bsdf.ior);
|
||||
}
|
||||
else
|
||||
{
|
||||
fd = mx_init_fresnel_schlick(safeColor0, safeColor90, exponent);
|
||||
}
|
||||
vec3 F = mx_compute_fresnel(VdotH, fd);
|
||||
float D = mx_ggx_NDF(Ht, safeAlpha);
|
||||
float G = mx_ggx_smith_G2(NdotL, NdotV, avgAlpha);
|
||||
|
||||
vec3 comp = mx_ggx_energy_compensation(NdotV, avgAlpha, F);
|
||||
vec3 dirAlbedo = mx_ggx_dir_albedo(NdotV, avgAlpha, safeColor0, safeColor90) * comp;
|
||||
float avgDirAlbedo = dot(dirAlbedo, vec3(1.0 / 3.0));
|
||||
bsdf.throughput = vec3(1.0 - avgDirAlbedo * weight);
|
||||
|
||||
// Note: NdotL is cancelled out
|
||||
bsdf.response = D * F * G * comp * occlusion * weight / (4.0 * NdotV);
|
||||
}
|
||||
|
||||
void mx_generalized_schlick_bsdf_transmission(vec3 V, float weight, vec3 color0, vec3 color90, float exponent, vec2 roughness, vec3 N, vec3 X, int distribution, int scatter_mode, inout BSDF bsdf)
|
||||
{
|
||||
if (weight < M_FLOAT_EPS)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
N = mx_forward_facing_normal(N, V);
|
||||
float NdotV = clamp(dot(N, V), M_FLOAT_EPS, 1.0);
|
||||
|
||||
FresnelData fd;
|
||||
vec3 safeColor0 = max(color0, 0.0);
|
||||
vec3 safeColor90 = max(color90, 0.0);
|
||||
if (bsdf.thickness > 0.0)
|
||||
{
|
||||
fd = mx_init_fresnel_schlick_airy(safeColor0, safeColor90, exponent, bsdf.thickness, bsdf.ior);
|
||||
}
|
||||
else
|
||||
{
|
||||
fd = mx_init_fresnel_schlick(safeColor0, safeColor90, exponent);
|
||||
}
|
||||
vec3 F = mx_compute_fresnel(NdotV, fd);
|
||||
|
||||
vec2 safeAlpha = clamp(roughness, M_FLOAT_EPS, 1.0);
|
||||
float avgAlpha = mx_average_alpha(safeAlpha);
|
||||
|
||||
vec3 comp = mx_ggx_energy_compensation(NdotV, avgAlpha, F);
|
||||
vec3 dirAlbedo = mx_ggx_dir_albedo(NdotV, avgAlpha, safeColor0, safeColor90) * comp;
|
||||
float avgDirAlbedo = dot(dirAlbedo, vec3(1.0 / 3.0));
|
||||
bsdf.throughput = vec3(1.0 - avgDirAlbedo * weight);
|
||||
|
||||
if (scatter_mode != 0)
|
||||
{
|
||||
float avgF0 = dot(safeColor0, vec3(1.0 / 3.0));
|
||||
fd.ior = vec3(mx_f0_to_ior(avgF0));
|
||||
bsdf.response = mx_surface_transmission(N, V, X, safeAlpha, distribution, fd, safeColor0) * weight;
|
||||
}
|
||||
}
|
||||
|
||||
void mx_generalized_schlick_bsdf_indirect(vec3 V, float weight, vec3 color0, vec3 color90, float exponent, vec2 roughness, vec3 N, vec3 X, int distribution, int scatter_mode, inout BSDF bsdf)
|
||||
{
|
||||
if (weight < M_FLOAT_EPS)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
N = mx_forward_facing_normal(N, V);
|
||||
float NdotV = clamp(dot(N, V), M_FLOAT_EPS, 1.0);
|
||||
|
||||
FresnelData fd;
|
||||
vec3 safeColor0 = max(color0, 0.0);
|
||||
vec3 safeColor90 = max(color90, 0.0);
|
||||
if (bsdf.thickness > 0.0)
|
||||
{
|
||||
fd = mx_init_fresnel_schlick_airy(safeColor0, safeColor90, exponent, bsdf.thickness, bsdf.ior);
|
||||
}
|
||||
else
|
||||
{
|
||||
fd = mx_init_fresnel_schlick(safeColor0, safeColor90, exponent);
|
||||
}
|
||||
vec3 F = mx_compute_fresnel(NdotV, fd);
|
||||
|
||||
vec2 safeAlpha = clamp(roughness, M_FLOAT_EPS, 1.0);
|
||||
float avgAlpha = mx_average_alpha(safeAlpha);
|
||||
vec3 comp = mx_ggx_energy_compensation(NdotV, avgAlpha, F);
|
||||
vec3 dirAlbedo = mx_ggx_dir_albedo(NdotV, avgAlpha, safeColor0, safeColor90) * comp;
|
||||
float avgDirAlbedo = dot(dirAlbedo, vec3(1.0 / 3.0));
|
||||
bsdf.throughput = vec3(1.0 - avgDirAlbedo * weight);
|
||||
|
||||
vec3 Li = mx_environment_radiance(N, V, X, safeAlpha, distribution, fd);
|
||||
bsdf.response = Li * comp * weight;
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
#include "lib/mx_microfacet.glsl"
|
||||
|
||||
void mx_generalized_schlick_edf(vec3 N, vec3 V, vec3 color0, vec3 color90, float exponent, EDF base, out EDF result)
|
||||
{
|
||||
N = mx_forward_facing_normal(N, V);
|
||||
float NdotV = clamp(dot(N, V), M_FLOAT_EPS, 1.0);
|
||||
vec3 f = mx_fresnel_schlick(NdotV, color0, color90, exponent);
|
||||
result = base * f;
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
#include "lib/mx_microfacet_diffuse.glsl"
|
||||
|
||||
void mx_oren_nayar_diffuse_bsdf_reflection(vec3 L, vec3 V, vec3 P, float occlusion, float weight, vec3 color, float roughness, vec3 normal, inout BSDF bsdf)
|
||||
{
|
||||
bsdf.throughput = vec3(0.0);
|
||||
|
||||
if (weight < M_FLOAT_EPS)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
normal = mx_forward_facing_normal(normal, V);
|
||||
|
||||
float NdotL = clamp(dot(normal, L), M_FLOAT_EPS, 1.0);
|
||||
|
||||
bsdf.response = color * occlusion * weight * NdotL * M_PI_INV;
|
||||
if (roughness > 0.0)
|
||||
{
|
||||
bsdf.response *= mx_oren_nayar_diffuse(L, V, normal, NdotL, roughness);
|
||||
}
|
||||
}
|
||||
|
||||
void mx_oren_nayar_diffuse_bsdf_indirect(vec3 V, float weight, vec3 color, float roughness, vec3 normal, inout BSDF bsdf)
|
||||
{
|
||||
bsdf.throughput = vec3(0.0);
|
||||
|
||||
if (weight < M_FLOAT_EPS)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
normal = mx_forward_facing_normal(normal, V);
|
||||
|
||||
vec3 Li = mx_environment_irradiance(normal);
|
||||
bsdf.response = Li * color * weight;
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
void mx_roughness_anisotropy(float roughness, float anisotropy, out vec2 result)
|
||||
{
|
||||
float roughness_sqr = clamp(roughness*roughness, M_FLOAT_EPS, 1.0);
|
||||
if (anisotropy > 0.0)
|
||||
{
|
||||
float aspect = sqrt(1.0 - clamp(anisotropy, 0.0, 0.98));
|
||||
result.x = min(roughness_sqr / aspect, 1.0);
|
||||
result.y = roughness_sqr * aspect;
|
||||
}
|
||||
else
|
||||
{
|
||||
result.x = roughness_sqr;
|
||||
result.y = roughness_sqr;
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
void mx_roughness_dual(vec2 roughness, out vec2 result)
|
||||
{
|
||||
if (roughness.y < 0.0)
|
||||
{
|
||||
roughness.y = roughness.x;
|
||||
}
|
||||
result.x = clamp(roughness.x * roughness.x, M_FLOAT_EPS, 1.0);
|
||||
result.y = clamp(roughness.y * roughness.y, M_FLOAT_EPS, 1.0);
|
||||
}
|
||||
Vendored
+43
@@ -0,0 +1,43 @@
|
||||
#include "lib/mx_microfacet_sheen.glsl"
|
||||
|
||||
void mx_sheen_bsdf_reflection(vec3 L, vec3 V, vec3 P, float occlusion, float weight, vec3 color, float roughness, vec3 N, inout BSDF bsdf)
|
||||
{
|
||||
if (weight < M_FLOAT_EPS)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
N = mx_forward_facing_normal(N, V);
|
||||
|
||||
vec3 H = normalize(L + V);
|
||||
|
||||
float NdotL = clamp(dot(N, L), M_FLOAT_EPS, 1.0);
|
||||
float NdotV = clamp(dot(N, V), M_FLOAT_EPS, 1.0);
|
||||
float NdotH = clamp(dot(N, H), M_FLOAT_EPS, 1.0);
|
||||
|
||||
vec3 fr = color * mx_imageworks_sheen_brdf(NdotL, NdotV, NdotH, roughness);
|
||||
float dirAlbedo = mx_imageworks_sheen_dir_albedo(NdotV, roughness);
|
||||
bsdf.throughput = vec3(1.0 - dirAlbedo * weight);
|
||||
|
||||
// We need to include NdotL from the light integral here
|
||||
// as in this case it's not cancelled out by the BRDF denominator.
|
||||
bsdf.response = fr * NdotL * occlusion * weight;
|
||||
}
|
||||
|
||||
void mx_sheen_bsdf_indirect(vec3 V, float weight, vec3 color, float roughness, vec3 N, inout BSDF bsdf)
|
||||
{
|
||||
if (weight < M_FLOAT_EPS)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
N = mx_forward_facing_normal(N, V);
|
||||
|
||||
float NdotV = clamp(dot(N, V), M_FLOAT_EPS, 1.0);
|
||||
|
||||
float dirAlbedo = mx_imageworks_sheen_dir_albedo(NdotV, roughness);
|
||||
bsdf.throughput = vec3(1.0 - dirAlbedo * weight);
|
||||
|
||||
vec3 Li = mx_environment_irradiance(N);
|
||||
bsdf.response = Li * color * dirAlbedo * weight;
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
#include "lib/mx_microfacet_diffuse.glsl"
|
||||
|
||||
void mx_subsurface_bsdf_reflection(vec3 L, vec3 V, vec3 P, float occlusion, float weight, vec3 color, vec3 radius, float anisotropy, vec3 normal, inout BSDF bsdf)
|
||||
{
|
||||
bsdf.throughput = vec3(0.0);
|
||||
|
||||
if (weight < M_FLOAT_EPS)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
normal = mx_forward_facing_normal(normal, V);
|
||||
|
||||
vec3 sss = mx_subsurface_scattering_approx(normal, L, P, color, radius);
|
||||
float NdotL = clamp(dot(normal, L), M_FLOAT_EPS, 1.0);
|
||||
float visibleOcclusion = 1.0 - NdotL * (1.0 - occlusion);
|
||||
bsdf.response = sss * visibleOcclusion * weight;
|
||||
}
|
||||
|
||||
void mx_subsurface_bsdf_indirect(vec3 V, float weight, vec3 color, vec3 radius, float anisotropy, vec3 normal, inout BSDF bsdf)
|
||||
{
|
||||
bsdf.throughput = vec3(0.0);
|
||||
|
||||
if (weight < M_FLOAT_EPS)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
normal = mx_forward_facing_normal(normal, V);
|
||||
|
||||
// For now, we render indirect subsurface as simple indirect diffuse.
|
||||
vec3 Li = mx_environment_irradiance(normal);
|
||||
bsdf.response = Li * color * weight;
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
// We fake diffuse transmission by using diffuse reflection from the opposite side.
|
||||
// So this BTDF is really a BRDF.
|
||||
void mx_translucent_bsdf_reflection(vec3 L, vec3 V, vec3 P, float occlusion, float weight, vec3 color, vec3 normal, inout BSDF bsdf)
|
||||
{
|
||||
bsdf.throughput = vec3(0.0);
|
||||
|
||||
// Invert normal since we're transmitting light from the other side
|
||||
float NdotL = dot(L, -normal);
|
||||
if (NdotL <= 0.0 || weight < M_FLOAT_EPS)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
bsdf.response = color * weight * NdotL * M_PI_INV;
|
||||
}
|
||||
|
||||
void mx_translucent_bsdf_indirect(vec3 V, float weight, vec3 color, vec3 normal, inout BSDF bsdf)
|
||||
{
|
||||
bsdf.throughput = vec3(0.0);
|
||||
|
||||
if (weight < M_FLOAT_EPS)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Invert normal since we're transmitting light from the other side
|
||||
vec3 Li = mx_environment_irradiance(-normal);
|
||||
bsdf.response = Li * color * weight;
|
||||
}
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
void mx_uniform_edf(vec3 N, vec3 L, vec3 color, out EDF result)
|
||||
{
|
||||
result = color;
|
||||
}
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
<?xml version="1.0"?>
|
||||
<materialx version="1.38">
|
||||
|
||||
<!-- <oren_nayar_diffuse_bsdf> -->
|
||||
<implementation name="IM_oren_nayar_diffuse_bsdf_genglsl" nodedef="ND_oren_nayar_diffuse_bsdf" file="mx_oren_nayar_diffuse_bsdf.glsl" function="mx_oren_nayar_diffuse_bsdf" target="genglsl" />
|
||||
|
||||
<!-- <burley_diffuse_bsdf> -->
|
||||
<implementation name="IM_burley_diffuse_bsdf_genglsl" nodedef="ND_burley_diffuse_bsdf" file="mx_burley_diffuse_bsdf.glsl" function="mx_burley_diffuse_bsdf" target="genglsl" />
|
||||
|
||||
<!-- <translucent_bsdf> -->
|
||||
<implementation name="IM_translucent_bsdf_genglsl" nodedef="ND_translucent_bsdf" file="mx_translucent_bsdf.glsl" function="mx_translucent_bsdf" target="genglsl" />
|
||||
|
||||
<!-- <dielectric_bsdf> -->
|
||||
<implementation name="IM_dielectric_bsdf_genglsl" nodedef="ND_dielectric_bsdf" file="mx_dielectric_bsdf.glsl" function="mx_dielectric_bsdf" target="genglsl" />
|
||||
|
||||
<!-- <conductor_bsdf> -->
|
||||
<implementation name="IM_conductor_bsdf_genglsl" nodedef="ND_conductor_bsdf" file="mx_conductor_bsdf.glsl" function="mx_conductor_bsdf" target="genglsl" />
|
||||
|
||||
<!-- <generalized_schlick_bsdf> -->
|
||||
<implementation name="IM_generalized_schlick_bsdf_genglsl" nodedef="ND_generalized_schlick_bsdf" file="mx_generalized_schlick_bsdf.glsl" function="mx_generalized_schlick_bsdf" target="genglsl" />
|
||||
|
||||
<!-- <subsurface_bsdf> -->
|
||||
<implementation name="IM_subsurface_bsdf_genglsl" nodedef="ND_subsurface_bsdf" file="mx_subsurface_bsdf.glsl" function="mx_subsurface_bsdf" target="genglsl" />
|
||||
|
||||
<!-- <sheen_bsdf> -->
|
||||
<implementation name="IM_sheen_bsdf_genglsl" nodedef="ND_sheen_bsdf" file="mx_sheen_bsdf.glsl" function="mx_sheen_bsdf" target="genglsl" />
|
||||
|
||||
<!-- <anisotropic_vdf> -->
|
||||
<implementation name="IM_anisotropic_vdf_genglsl" nodedef="ND_anisotropic_vdf" file="mx_anisotropic_vdf.glsl" function="mx_anisotropic_vdf" target="genglsl" />
|
||||
|
||||
<!-- <thin_film_bsdf> -->
|
||||
<implementation name="IM_thin_film_bsdf_genglsl" nodedef="ND_thin_film_bsdf" target="genglsl" />
|
||||
|
||||
<!-- <layer> -->
|
||||
<implementation name="IM_layer_bsdf_genglsl" nodedef="ND_layer_bsdf" target="genglsl" />
|
||||
<implementation name="IM_layer_vdf_genglsl" nodedef="ND_layer_vdf" target="genglsl" />
|
||||
|
||||
<!-- <mix> -->
|
||||
<implementation name="IM_mix_bsdf_genglsl" nodedef="ND_mix_bsdf" target="genglsl" />
|
||||
<implementation name="IM_mix_edf_genglsl" nodedef="ND_mix_edf" target="genglsl" />
|
||||
|
||||
<!-- <add> -->
|
||||
<implementation name="IM_add_bsdf_genglsl" nodedef="ND_add_bsdf" target="genglsl" />
|
||||
<implementation name="IM_add_edf_genglsl" nodedef="ND_add_edf" target="genglsl" />
|
||||
|
||||
<!-- <multiply> -->
|
||||
<implementation name="IM_multiply_bsdfC_genglsl" nodedef="ND_multiply_bsdfC" target="genglsl" />
|
||||
<implementation name="IM_multiply_bsdfF_genglsl" nodedef="ND_multiply_bsdfF" target="genglsl" />
|
||||
<implementation name="IM_multiply_edfC_genglsl" nodedef="ND_multiply_edfC" target="genglsl" />
|
||||
<implementation name="IM_multiply_edfF_genglsl" nodedef="ND_multiply_edfF" target="genglsl" />
|
||||
|
||||
<!-- <uniform_edf> -->
|
||||
<implementation name="IM_uniform_edf_genglsl" nodedef="ND_uniform_edf" file="mx_uniform_edf.glsl" function="mx_uniform_edf" target="genglsl" />
|
||||
|
||||
<!-- <generalized_schlick_edf> -->
|
||||
<implementation name="IM_generalized_schlick_edf_genglsl" nodedef="ND_generalized_schlick_edf" file="mx_generalized_schlick_edf.glsl" function="mx_generalized_schlick_edf" target="genglsl" />
|
||||
|
||||
<!-- <surface> -->
|
||||
<implementation name="IM_surface_genglsl" nodedef="ND_surface" target="genglsl" />
|
||||
|
||||
<!-- <displacement> -->
|
||||
<implementation name="IM_displacement_float_genglsl" nodedef="ND_displacement_float" file="mx_displacement_float.glsl" function="mx_displacement_float" target="genglsl" />
|
||||
<implementation name="IM_displacement_vector3_genglsl" nodedef="ND_displacement_vector3" file="mx_displacement_vector3.glsl" function="mx_displacement_vector3" target="genglsl" />
|
||||
|
||||
<!-- <light> -->
|
||||
<implementation name="IM_light_genglsl" nodedef="ND_light" target="genglsl" />
|
||||
|
||||
<!-- <roughness_anisotropy> -->
|
||||
<implementation name="IM_roughness_anisotropy_genglsl" nodedef="ND_roughness_anisotropy" file="mx_roughness_anisotropy.glsl" function="mx_roughness_anisotropy" target="genglsl" />
|
||||
|
||||
<!-- <roughness_dual> -->
|
||||
<implementation name="IM_roughness_dual_genglsl" nodedef="ND_roughness_dual" file="mx_roughness_dual.glsl" function="mx_roughness_dual" target="genglsl" />
|
||||
|
||||
<!-- <artistic_ior> -->
|
||||
<implementation name="IM_artistic_ior_genglsl" nodedef="ND_artistic_ior" file="mx_artistic_ior.glsl" function="mx_artistic_ior" target="genglsl" />
|
||||
|
||||
<!-- <blackbody> -->
|
||||
<implementation name="IM_blackbody_genglsl" nodedef="ND_blackbody" file="mx_blackbody.glsl" function="mx_blackbody" target="genglsl" />
|
||||
|
||||
</materialx>
|
||||
+99
@@ -0,0 +1,99 @@
|
||||
<?xml version="1.0"?>
|
||||
<materialx version="1.38">
|
||||
|
||||
<!-- <oren_nayar_diffuse_bsdf> -->
|
||||
<implementation name="IM_oren_nayar_diffuse_bsdf_genmdl" nodedef="ND_oren_nayar_diffuse_bsdf" sourcecode="materialx::pbrlib_{{MDL_VERSION_SUFFIX}}::mx_oren_nayar_diffuse_bsdf(mxp_weight:{{weight}}, mxp_color:{{color}}, mxp_roughness:{{roughness}}, mxp_normal:{{normal}})" target="genmdl" />
|
||||
|
||||
<!-- <burley_diffuse_bsdf> -->
|
||||
<implementation name="IM_burley_diffuse_bsdf_genmdl" nodedef="ND_burley_diffuse_bsdf" sourcecode="materialx::pbrlib_{{MDL_VERSION_SUFFIX}}::mx_burley_diffuse_bsdf(mxp_weight:{{weight}}, mxp_color:{{color}}, mxp_roughness:{{roughness}}, mxp_normal:{{normal}})" target="genmdl" />
|
||||
|
||||
<!-- <translucent_bsdf> -->
|
||||
<implementation name="IM_translucent_bsdf_genmdl" nodedef="ND_translucent_bsdf" sourcecode="materialx::pbrlib_{{MDL_VERSION_SUFFIX}}::mx_translucent_bsdf(mxp_weight:{{weight}}, mxp_color:{{color}}, mxp_normal:{{normal}})" target="genmdl" />
|
||||
|
||||
<!-- <dielectric_bsdf> -->
|
||||
<implementation name="IM_dielectric_bsdf_genmdl" nodedef="ND_dielectric_bsdf" sourcecode="materialx::pbrlib_{{MDL_VERSION_SUFFIX}}::mx_dielectric_bsdf(mxp_weight:{{weight}}, mxp_tint:{{tint}}, mxp_ior:{{ior}}, mxp_roughness:{{roughness}}, mxp_normal:{{normal}}, mxp_tangent:{{tangent}}, mxp_distribution:{{distribution}}, mxp_scatter_mode:{{scatter_mode}}, mxp_base:{{base}}, mxp_thinfilm_thickness:{{thinfilm_thickness}}, mxp_thinfilm_ior:{{thinfilm_ior}})" target="genmdl" />
|
||||
|
||||
<!-- <conductor_bsdf> -->
|
||||
<implementation name="IM_conductor_bsdf_genmdl" nodedef="ND_conductor_bsdf" sourcecode="materialx::pbrlib_{{MDL_VERSION_SUFFIX}}::mx_conductor_bsdf(mxp_weight:{{weight}}, mxp_ior:{{ior}}, mxp_extinction:{{extinction}}, mxp_roughness:{{roughness}}, mxp_normal:{{normal}}, mxp_tangent:{{tangent}}, mxp_distribution:{{distribution}}, mxp_thinfilm_thickness:{{thinfilm_thickness}}, mxp_thinfilm_ior:{{thinfilm_ior}})" target="genmdl" />
|
||||
|
||||
<!-- <generalized_schlick_bsdf> -->
|
||||
<implementation name="IM_generalized_schlick_bsdf_genmdl" nodedef="ND_generalized_schlick_bsdf" sourcecode="materialx::pbrlib_{{MDL_VERSION_SUFFIX}}::mx_generalized_schlick_bsdf(mxp_weight:{{weight}}, mxp_color0:{{color0}}, mxp_color90:{{color90}}, mxp_exponent:{{exponent}},mxp_roughness:{{roughness}}, mxp_normal:{{normal}}, mxp_tangent:{{tangent}}, mxp_distribution:{{distribution}}, mxp_scatter_mode:{{scatter_mode}}, mxp_base:{{base}}, mxp_thinfilm_thickness:{{thinfilm_thickness}}, mxp_thinfilm_ior:{{thinfilm_ior}})" target="genmdl" />
|
||||
|
||||
<!-- <subsurface_bsdf> -->
|
||||
<implementation name="IM_subsurface_bsdf_genmdl" nodedef="ND_subsurface_bsdf" sourcecode="materialx::pbrlib_{{MDL_VERSION_SUFFIX}}::mx_subsurface_bsdf(mxp_weight:{{weight}}, mxp_color:{{color}}, mxp_radius:{{radius}}, mxp_anisotropy:{{anisotropy}}, mxp_normal:{{normal}})" target="genmdl" />
|
||||
|
||||
<!-- <sheen_bsdf> -->
|
||||
<implementation name="IM_sheen_bsdf_genmdl" nodedef="ND_sheen_bsdf" sourcecode="materialx::pbrlib_{{MDL_VERSION_SUFFIX}}::mx_sheen_bsdf(mxp_weight:{{weight}}, mxp_color:{{color}}, mxp_roughness:{{roughness}}, mxp_normal:{{normal}}, mxp_base:{{base}})" target="genmdl" />
|
||||
|
||||
<!-- <thin_film_bsdf> -->
|
||||
<implementation name="IM_thin_film_bsdf_genmdl" nodedef="ND_thin_film_bsdf" sourcecode="materialx::pbrlib_{{MDL_VERSION_SUFFIX}}::mx_thin_film_bsdf(mxp_thickness:{{thickness}}, mxp_ior:{{ior}}, mxp_base:{{base}})" target="genmdl" />
|
||||
|
||||
<!-- <uniform_edf> -->
|
||||
<implementation name="IM_uniform_edf_genmdl" nodedef="ND_uniform_edf" sourcecode="materialx::pbrlib_{{MDL_VERSION_SUFFIX}}::mx_uniform_edf(mxp_color:{{color}})" target="genmdl" />
|
||||
|
||||
<!-- <conical_edf> -->
|
||||
<implementation name="IM_conical_edf_genmdl" nodedef="ND_conical_edf" sourcecode="materialx::pbrlib_{{MDL_VERSION_SUFFIX}}::mx_conical_edf(mxp_color:{{color}}, mxp_normal:{{normal}}, mxp_inner_angle:{{inner_angle}}, mxp_outer_angle:{{outer_angle}})" target="genmdl" />
|
||||
|
||||
<!-- <measured_edf> -->
|
||||
<implementation name="IM_measured_edf_genmdl" nodedef="ND_measured_edf" sourcecode="materialx::pbrlib_{{MDL_VERSION_SUFFIX}}::mx_measured_edf(mxp_color:{{color}}, mxp_normal:{{normal}}, mxp_file:{{file}}" target="genmdl" />
|
||||
|
||||
<!-- <generalized_schlick_edf> -->
|
||||
<implementation name="IM_generalized_schlick_edf_genmdl" nodedef="ND_generalized_schlick_edf" sourcecode="materialx::pbrlib_{{MDL_VERSION_SUFFIX}}::mx_generalized_schlick_edf(mxp_color0:{{color0}}, mxp_color90:{{color90}}, mxp_exponent:{{exponent}}, mxp_base:{{base}})" target="genmdl" />
|
||||
|
||||
<!-- <absorption_vdf> -->
|
||||
<implementation name="IM_absorption_vdf_genmdl" nodedef="ND_absorption_vdf" sourcecode="materialx::pbrlib_{{MDL_VERSION_SUFFIX}}::mx_absorption_vdf(mxp_absorption:{{absorption}})" target="genmdl" />
|
||||
|
||||
<!-- <anisotropic_vdf> -->
|
||||
<implementation name="IM_anisotropic_vdf_genmdl" nodedef="ND_anisotropic_vdf" sourcecode="materialx::pbrlib_{{MDL_VERSION_SUFFIX}}::mx_anisotropic_vdf(mxp_absorption:{{absorption}}, mxp_scattering:{{scattering}}, mxp_anisotropy:{{anisotropy}})" target="genmdl" />
|
||||
|
||||
<!-- <surface> -->
|
||||
<implementation name="IM_surface_genmdl" nodedef="ND_surface" target="genmdl" />
|
||||
|
||||
<!-- <thin_surface> -->
|
||||
<implementation name="IM_thin_surface_genmdl" nodedef="ND_thin_surface" sourcecode="materialx::pbrlib_{{MDL_VERSION_SUFFIX}}::mx_thin_surface(mxp_front_bsdf:{{front_bsdf}}, mxp_front_edf:{{front_edf}}, mxp_back_bsdf:{{back_bsdf}}, mxp_back_edf:{{back_edf}}, mxp_opacity:{{opacity}})" target="genmdl" />
|
||||
|
||||
<!-- <volume> -->
|
||||
<implementation name="IM_volume_genmdl" nodedef="ND_volume" sourcecode="materialx::pbrlib_{{MDL_VERSION_SUFFIX}}::mx_volume(mxp_vdf:{{vdf}}, mxp_edf:{{edf}})" target="genmdl" />
|
||||
|
||||
<!-- <light> -->
|
||||
<implementation name="IM_light_genmdl" nodedef="ND_light" sourcecode="materialx::pbrlib_{{MDL_VERSION_SUFFIX}}::mx_light(mxp_edf:{{edf}}, mxp_intensity:{{intensity}}, mxp_exposure:{{exposure}})" target="genmdl" />
|
||||
|
||||
<!-- <displacement> -->
|
||||
<implementation name="IM_displacement_float_genmdl" nodedef="ND_displacement_float" sourcecode="materialx::pbrlib_{{MDL_VERSION_SUFFIX}}::mx_displacement_float(mxp_displacement:{{displacement}}, mxp_scale:{{scale}})" target="genmdl" />
|
||||
<implementation name="IM_displacement_vector3_genmdl" nodedef="ND_displacement_vector3" sourcecode="materialx::pbrlib_{{MDL_VERSION_SUFFIX}}::mx_displacement_vector3(mxp_displacement:{{displacement}}, mxp_scale:{{scale}})" target="genmdl" />
|
||||
|
||||
<!-- <layer> -->
|
||||
<implementation name="IM_layer_bsdf_genmdl" nodedef="ND_layer_bsdf" target="genmdl" />
|
||||
<implementation name="IM_layer_vdf_genmdl" nodedef="ND_layer_vdf" target="genmdl" />
|
||||
|
||||
<!-- <mix> -->
|
||||
<implementation name="IM_mix_bsdf_genmdl" nodedef="ND_mix_bsdf" sourcecode="materialx::pbrlib_{{MDL_VERSION_SUFFIX}}::mx_mix_bsdf(mxp_fg:{{fg}}, mxp_bg:{{bg}}, mxp_mix:{{mix}})" target="genmdl" />
|
||||
<implementation name="IM_mix_edf_genmdl" nodedef="ND_mix_edf" sourcecode="materialx::pbrlib_{{MDL_VERSION_SUFFIX}}::mx_mix_edf(mxp_fg:{{fg}}, mxp_bg:{{bg}}, mxp_mix:{{mix}})" target="genmdl" />
|
||||
<implementation name="IM_mix_vdf_genmdl" nodedef="ND_mix_vdf" sourcecode="materialx::pbrlib_{{MDL_VERSION_SUFFIX}}::mx_mix_vdf(mxp_fg:{{fg}}, mxp_bg:{{bg}}, mxp_mix:{{mix}})" target="genmdl" />
|
||||
|
||||
<!-- <add> -->
|
||||
<implementation name="IM_add_bsdf_genmdl" nodedef="ND_add_bsdf" sourcecode="materialx::pbrlib_{{MDL_VERSION_SUFFIX}}::mx_add_bsdf(mxp_in1:{{in1}}, mxp_in2:{{in2}})" target="genmdl" />
|
||||
<implementation name="IM_add_edf_genmdl" nodedef="ND_add_edf" sourcecode="materialx::pbrlib_{{MDL_VERSION_SUFFIX}}::mx_add_edf(mxp_in1:{{in1}}, mxp_in2:{{in2}})" target="genmdl" />
|
||||
<implementation name="IM_add_vdf_genmdl" nodedef="ND_add_vdf" sourcecode="materialx::pbrlib_{{MDL_VERSION_SUFFIX}}::mx_add_vdf(mxp_in1:{{in1}}, mxp_in2:{{in2}})" target="genmdl" />
|
||||
|
||||
<!-- <multiply> -->
|
||||
<implementation name="IM_multiply_bsdfC_genmdl" nodedef="ND_multiply_bsdfC" sourcecode="materialx::pbrlib_{{MDL_VERSION_SUFFIX}}::mx_multiply_bsdf_color3(mxp_in1:{{in1}}, mxp_in2:{{in2}})" target="genmdl" />
|
||||
<implementation name="IM_multiply_bsdfF_genmdl" nodedef="ND_multiply_bsdfF" sourcecode="materialx::pbrlib_{{MDL_VERSION_SUFFIX}}::mx_multiply_bsdf_float(mxp_in1:{{in1}}, mxp_in2:{{in2}})" target="genmdl" />
|
||||
<implementation name="IM_multiply_edfC_genmdl" nodedef="ND_multiply_edfC" sourcecode="materialx::pbrlib_{{MDL_VERSION_SUFFIX}}::mx_multiply_edf_color3(mxp_in1:{{in1}}, mxp_in2:{{in2}})" target="genmdl" />
|
||||
<implementation name="IM_multiply_edfF_genmdl" nodedef="ND_multiply_edfF" sourcecode="materialx::pbrlib_{{MDL_VERSION_SUFFIX}}::mx_multiply_edf_float(mxp_in1:{{in1}}, mxp_in2:{{in2}})" target="genmdl" />
|
||||
<implementation name="IM_multiply_vdfC_genmdl" nodedef="ND_multiply_vdfC" sourcecode="materialx::pbrlib_{{MDL_VERSION_SUFFIX}}::mx_multiply_vdf_color3(mxp_in1:{{in1}}, mxp_in2:{{in2}})" target="genmdl" />
|
||||
<implementation name="IM_multiply_vdfF_genmdl" nodedef="ND_multiply_vdfF" sourcecode="materialx::pbrlib_{{MDL_VERSION_SUFFIX}}::mx_multiply_vdf_float(mxp_in1:{{in1}}, mxp_in2:{{in2}})" target="genmdl" />
|
||||
|
||||
<!-- <roughness_anisotropy> -->
|
||||
<implementation name="IM_roughness_anisotropy_genmdl" nodedef="ND_roughness_anisotropy" sourcecode="materialx::pbrlib_{{MDL_VERSION_SUFFIX}}::mx_roughness_anisotropy(mxp_roughness:{{roughness}}, mxp_anisotropy:{{anisotropy}})" target="genmdl" />
|
||||
|
||||
<!-- <roughness_dual> -->
|
||||
<implementation name="IM_roughness_dual_genmdl" nodedef="ND_roughness_dual" sourcecode="materialx::pbrlib_{{MDL_VERSION_SUFFIX}}::mx_roughness_dual(mxp_roughness:{{roughness}})" target="genmdl" />
|
||||
|
||||
<!-- <artistic_ior> -->
|
||||
<implementation name="IM_artistic_ior_genmdl" nodedef="ND_artistic_ior" sourcecode="materialx::pbrlib_{{MDL_VERSION_SUFFIX}}::mx_artistic_ior(mxp_reflectivity:{{reflectivity}}, mxp_edge_color:{{edge_color}})" target="genmdl" />
|
||||
|
||||
<!-- <blackbody> -->
|
||||
<implementation name="IM_blackbody_genmdl" nodedef="ND_blackbody" sourcecode="materialx::pbrlib_{{MDL_VERSION_SUFFIX}}::mx_blackbody(mxp_temperature:{{temperature}})" target="genmdl" />
|
||||
|
||||
</materialx>
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
<?xml version="1.0"?>
|
||||
<materialx version="1.38">
|
||||
|
||||
<!-- <oren_nayar_diffuse_bsdf> -->
|
||||
<implementation name="IM_oren_nayar_diffuse_bsdf_genmsl" nodedef="ND_oren_nayar_diffuse_bsdf" file="../genglsl/mx_oren_nayar_diffuse_bsdf.glsl" function="mx_oren_nayar_diffuse_bsdf" target="genmsl" />
|
||||
|
||||
<!-- <burley_diffuse_bsdf> -->
|
||||
<implementation name="IM_burley_diffuse_bsdf_genmsl" nodedef="ND_burley_diffuse_bsdf" file="../genglsl/mx_burley_diffuse_bsdf.glsl" function="mx_burley_diffuse_bsdf" target="genmsl" />
|
||||
|
||||
<!-- <translucent_bsdf> -->
|
||||
<implementation name="IM_translucent_bsdf_genmsl" nodedef="ND_translucent_bsdf" file="../genglsl/mx_translucent_bsdf.glsl" function="mx_translucent_bsdf" target="genmsl" />
|
||||
|
||||
<!-- <dielectric_bsdf> -->
|
||||
<implementation name="IM_dielectric_bsdf_genmsl" nodedef="ND_dielectric_bsdf" file="../genglsl/mx_dielectric_bsdf.glsl" function="mx_dielectric_bsdf" target="genmsl" />
|
||||
|
||||
<!-- <conductor_bsdf> -->
|
||||
<implementation name="IM_conductor_bsdf_genmsl" nodedef="ND_conductor_bsdf" file="../genglsl/mx_conductor_bsdf.glsl" function="mx_conductor_bsdf" target="genmsl" />
|
||||
|
||||
<!-- <generalized_schlick_bsdf> -->
|
||||
<implementation name="IM_generalized_schlick_bsdf_genmsl" nodedef="ND_generalized_schlick_bsdf" file="../genglsl/mx_generalized_schlick_bsdf.glsl" function="mx_generalized_schlick_bsdf" target="genmsl" />
|
||||
|
||||
<!-- <subsurface_bsdf> -->
|
||||
<implementation name="IM_subsurface_bsdf_genmsl" nodedef="ND_subsurface_bsdf" file="../genglsl/mx_subsurface_bsdf.glsl" function="mx_subsurface_bsdf" target="genmsl" />
|
||||
|
||||
<!-- <sheen_bsdf> -->
|
||||
<implementation name="IM_sheen_bsdf_genmsl" nodedef="ND_sheen_bsdf" file="../genglsl/mx_sheen_bsdf.glsl" function="mx_sheen_bsdf" target="genmsl" />
|
||||
|
||||
<!-- <anisotropic_vdf> -->
|
||||
<implementation name="IM_anisotropic_vdf_genmsl" nodedef="ND_anisotropic_vdf" file="../genglsl/mx_anisotropic_vdf.glsl" function="mx_anisotropic_vdf" target="genmsl" />
|
||||
|
||||
<!-- <thin_film_bsdf> -->
|
||||
<implementation name="IM_thin_film_bsdf_genmsl" nodedef="ND_thin_film_bsdf" target="genmsl" />
|
||||
|
||||
<!-- <layer> -->
|
||||
<implementation name="IM_layer_bsdf_genmsl" nodedef="ND_layer_bsdf" target="genmsl" />
|
||||
<implementation name="IM_layer_vdf_genmsl" nodedef="ND_layer_vdf" target="genmsl" />
|
||||
|
||||
<!-- <mix> -->
|
||||
<implementation name="IM_mix_bsdf_genmsl" nodedef="ND_mix_bsdf" target="genmsl" />
|
||||
<implementation name="IM_mix_edf_genmsl" nodedef="ND_mix_edf" target="genmsl" />
|
||||
|
||||
<!-- <add> -->
|
||||
<implementation name="IM_add_bsdf_genmsl" nodedef="ND_add_bsdf" target="genmsl" />
|
||||
<implementation name="IM_add_edf_genmsl" nodedef="ND_add_edf" target="genmsl" />
|
||||
|
||||
<!-- <multiply> -->
|
||||
<implementation name="IM_multiply_bsdfC_genmsl" nodedef="ND_multiply_bsdfC" target="genmsl" />
|
||||
<implementation name="IM_multiply_bsdfF_genmsl" nodedef="ND_multiply_bsdfF" target="genmsl" />
|
||||
<implementation name="IM_multiply_edfC_genmsl" nodedef="ND_multiply_edfC" target="genmsl" />
|
||||
<implementation name="IM_multiply_edfF_genmsl" nodedef="ND_multiply_edfF" target="genmsl" />
|
||||
|
||||
<!-- <uniform_edf> -->
|
||||
<implementation name="IM_uniform_edf_genmsl" nodedef="ND_uniform_edf" file="../genglsl/mx_uniform_edf.glsl" function="mx_uniform_edf" target="genmsl" />
|
||||
|
||||
<!-- <surface> -->
|
||||
<implementation name="IM_surface_genmsl" nodedef="ND_surface" target="genmsl" />
|
||||
|
||||
<!-- <displacement> -->
|
||||
<implementation name="IM_displacement_float_genmsl" nodedef="ND_displacement_float" file="../genglsl/mx_displacement_float.glsl" function="mx_displacement_float" target="genmsl" />
|
||||
<implementation name="IM_displacement_vector3_genmsl" nodedef="ND_displacement_vector3" file="../genglsl/mx_displacement_vector3.glsl" function="mx_displacement_vector3" target="genmsl" />
|
||||
|
||||
<!-- <light> -->
|
||||
<implementation name="IM_light_genmsl" nodedef="ND_light" target="genmsl" />
|
||||
|
||||
<!-- <roughness_anisotropy> -->
|
||||
<implementation name="IM_roughness_anisotropy_genmsl" nodedef="ND_roughness_anisotropy" file="../genglsl/mx_roughness_anisotropy.glsl" function="mx_roughness_anisotropy" target="genmsl" />
|
||||
|
||||
<!-- <roughness_dual> -->
|
||||
<implementation name="IM_roughness_dual_genmsl" nodedef="ND_roughness_dual" file="../genglsl/mx_roughness_dual.glsl" function="mx_roughness_dual" target="genmsl" />
|
||||
|
||||
<!-- <artistic_ior> -->
|
||||
<implementation name="IM_artistic_ior_genmsl" nodedef="ND_artistic_ior" file="../genglsl/mx_artistic_ior.glsl" function="mx_artistic_ior" target="genmsl" />
|
||||
|
||||
<!-- <blackbody> -->
|
||||
<implementation name="IM_blackbody_genmsl" nodedef="ND_blackbody" file="../genglsl/mx_blackbody.glsl" function="mx_blackbody" target="genmsl" />
|
||||
|
||||
</materialx>
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
void mx_anisotropic_vdf(vector absorption, vector scattering, float anisotropy, output VDF vdf)
|
||||
{
|
||||
// Not implemented in vanilla OSL
|
||||
vdf = 0; // volume_henyey_greenstein(color(absorption), color(scattering), color(0.0), anisotropy);
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
void mx_burley_diffuse_bsdf(float weight, color reflectance, float roughness, normal N, output BSDF bsdf)
|
||||
{
|
||||
// TODO: Implement properly.
|
||||
bsdf.response = reflectance * weight * oren_nayar(N, roughness);
|
||||
bsdf.throughput = color(0.0);
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
#include "../lib/mx_microfacet_specular.osl"
|
||||
|
||||
void mx_conductor_bsdf(float weight, color ior_n, color ior_k, vector2 roughness, normal N, vector U, string distribution, output BSDF bsdf)
|
||||
{
|
||||
bsdf.throughput = color(0.0);
|
||||
|
||||
if (weight < M_FLOAT_EPS)
|
||||
{
|
||||
bsdf.response = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
// Calculate conductor fresnel
|
||||
//
|
||||
// Fresnel should be based on microfacet normal
|
||||
// but we have no access to that from here, so just use
|
||||
// view direction and surface normal instead
|
||||
//
|
||||
float NdotV = fabs(dot(N,-I));
|
||||
color F = mx_fresnel_conductor(NdotV, ior_n, ior_k);
|
||||
|
||||
// Calculate compensation for multiple scattering.
|
||||
// This should normally be done inside the closure
|
||||
// but since vanilla OSL doesen't support this we
|
||||
// add it here in shader code instead.
|
||||
vector2 safeAlpha = clamp(roughness, M_FLOAT_EPS, 1.0);
|
||||
float avgAlpha = mx_average_alpha(safeAlpha);
|
||||
color comp = mx_ggx_energy_compensation(NdotV, avgAlpha, F);
|
||||
|
||||
// Set ior to 0.0 to disable the internal dielectric fresnel
|
||||
bsdf.response = F * comp * weight * microfacet(distribution, N, U, safeAlpha.x, safeAlpha.y, 0.0, false);
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
#include "../lib/mx_microfacet_specular.osl"
|
||||
|
||||
void mx_dielectric_bsdf(float weight, color tint, float ior, vector2 roughness, normal N, vector U, string distribution, string scatter_mode, output BSDF bsdf)
|
||||
{
|
||||
if (scatter_mode == "T")
|
||||
{
|
||||
bsdf.response = tint * weight * microfacet(distribution, N, U, roughness.x, roughness.y, ior, 1);
|
||||
bsdf.throughput = tint * weight;
|
||||
return;
|
||||
}
|
||||
|
||||
float NdotV = clamp(dot(N,-I), M_FLOAT_EPS, 1.0);
|
||||
float F0 = mx_ior_to_f0(ior);
|
||||
float F = mx_fresnel_schlick(NdotV, F0);
|
||||
|
||||
// Calculate compensation for multiple scattering.
|
||||
// This should normally be done inside the closure
|
||||
// but since vanilla OSL doesen't support this we
|
||||
// add it here in shader code instead.
|
||||
vector2 safeAlpha = clamp(roughness, M_FLOAT_EPS, 1.0);
|
||||
float avgAlpha = mx_average_alpha(safeAlpha);
|
||||
float comp = mx_ggx_energy_compensation(NdotV, avgAlpha, F);
|
||||
|
||||
// Calculate throughput from directional albedo.
|
||||
float dirAlbedo = mx_ggx_dir_albedo(NdotV, avgAlpha, ior) * comp;
|
||||
bsdf.throughput = 1.0 - dirAlbedo * weight;
|
||||
|
||||
if (scatter_mode == "R")
|
||||
{
|
||||
bsdf.response = tint * weight * comp * microfacet(distribution, N, U, safeAlpha.x, safeAlpha.y, ior, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
bsdf.response = tint * weight * comp * microfacet(distribution, N, U, safeAlpha.x, safeAlpha.y, ior, 2);
|
||||
}
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
#include "../lib/mx_microfacet_specular.osl"
|
||||
|
||||
void mx_generalized_schlick_bsdf(float weight, color color0, color color90, float exponent, vector2 roughness, normal N, vector U, string distribution, string scatter_mode, output BSDF bsdf)
|
||||
{
|
||||
float avgF0 = dot(color0, color(1.0 / 3.0));
|
||||
float ior = mx_f0_to_ior(avgF0);
|
||||
|
||||
if (scatter_mode == "T")
|
||||
{
|
||||
bsdf.response = weight * microfacet(distribution, N, U, roughness.x, roughness.y, ior, 1);
|
||||
bsdf.throughput = weight;
|
||||
return;
|
||||
}
|
||||
|
||||
float NdotV = fabs(dot(N,-I));
|
||||
color F = mx_fresnel_schlick(NdotV, color0, color90, exponent);
|
||||
|
||||
// Calculate compensation for multiple scattering.
|
||||
// This should normally be done inside the closure
|
||||
// but since vanilla OSL doesen't support this we
|
||||
// add it here in shader code instead.
|
||||
vector2 safeAlpha = clamp(roughness, M_FLOAT_EPS, 1.0);
|
||||
float avgAlpha = mx_average_alpha(safeAlpha);
|
||||
color comp = mx_ggx_energy_compensation(NdotV, avgAlpha, F);
|
||||
|
||||
// Calculate throughput from directional albedo.
|
||||
color dirAlbedo = mx_ggx_dir_albedo(NdotV, avgAlpha, color0, color90) * comp;
|
||||
float avgDirAlbedo = dot(dirAlbedo, color(1.0 / 3.0));
|
||||
bsdf.throughput = 1.0 - avgDirAlbedo * weight;
|
||||
|
||||
// Calculate the reflection response, setting IOR to zero to disable internal Fresnel.
|
||||
bsdf.response = F * comp * weight * microfacet(distribution, N, U, safeAlpha.x, safeAlpha.y, 0.0, 0);
|
||||
|
||||
if (scatter_mode == "RT")
|
||||
{
|
||||
bsdf.response += bsdf.throughput * microfacet(distribution, N, U, safeAlpha.x, safeAlpha.y, ior, 1);
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
void mx_oren_nayar_diffuse_bsdf(float weight, color _color, float roughness, normal N, output BSDF bsdf)
|
||||
{
|
||||
bsdf.response = _color * weight * oren_nayar(N, roughness);
|
||||
bsdf.throughput = color(0.0);
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
#include "../lib/mx_microfacet_sheen.osl"
|
||||
|
||||
// TODO: Vanilla OSL doesn't have a proper sheen closure,
|
||||
// so use 'diffuse' scaled by sheen directional albedo for now.
|
||||
void mx_sheen_bsdf(float weight, color Ks, float roughness, vector N, output BSDF bsdf)
|
||||
{
|
||||
if (weight < M_FLOAT_EPS)
|
||||
{
|
||||
bsdf.response = 0;
|
||||
bsdf.throughput = color(1.0);
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: Normalization should not be needed. My suspicion is that
|
||||
// BSDF sampling of new outgoing direction in 'testrender' needs
|
||||
// to be fixed.
|
||||
vector V = normalize(-I);
|
||||
|
||||
float NdotV = fabs(dot(N,V));
|
||||
float alpha = clamp(roughness, M_FLOAT_EPS, 1.0);
|
||||
float albedo = weight * mx_imageworks_sheen_dir_albedo(NdotV, alpha);
|
||||
bsdf.response = albedo * Ks * diffuse(N);
|
||||
bsdf.throughput = 1.0 - albedo;
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
void mx_subsurface_bsdf(float weight, color _color, vector radius, float anisotropy, normal N, output BSDF bsdf)
|
||||
{
|
||||
// TODO: Subsurface closure is not supported by vanilla OSL.
|
||||
bsdf.response = _color * weight * diffuse(N);
|
||||
bsdf.throughput = color(0.0);
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
void mx_surface(BSDF bsdf, EDF edf, float opacity, output surfaceshader result)
|
||||
{
|
||||
result.bsdf = bsdf.response;
|
||||
result.edf = edf;
|
||||
result.opacity = clamp(opacity, 0.0, 1.0);
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
void mx_translucent_bsdf(float weight, color _color, normal N, output BSDF bsdf)
|
||||
{
|
||||
bsdf.response = _color * weight * translucent(N);
|
||||
bsdf.throughput = color(0.0);
|
||||
}
|
||||
Vendored
+78
@@ -0,0 +1,78 @@
|
||||
float mx_square(float x)
|
||||
{
|
||||
return x*x;
|
||||
}
|
||||
|
||||
vector2 mx_square(vector2 x)
|
||||
{
|
||||
return x*x;
|
||||
}
|
||||
|
||||
vector mx_square(vector x)
|
||||
{
|
||||
return x*x;
|
||||
}
|
||||
|
||||
vector4 mx_square(vector4 x)
|
||||
{
|
||||
return x*x;
|
||||
}
|
||||
|
||||
float mx_pow5(float x)
|
||||
{
|
||||
return mx_square(mx_square(x)) * x;
|
||||
}
|
||||
|
||||
color mx_fresnel_conductor(float cosTheta, vector n, vector k)
|
||||
{
|
||||
float c2 = cosTheta*cosTheta;
|
||||
vector n2_k2 = n*n + k*k;
|
||||
vector nc2 = 2.0 * n * cosTheta;
|
||||
|
||||
vector rs_a = n2_k2 + c2;
|
||||
vector rp_a = n2_k2 * c2 + 1.0;
|
||||
vector rs = (rs_a - nc2) / (rs_a + nc2);
|
||||
vector rp = (rp_a - nc2) / (rp_a + nc2);
|
||||
|
||||
return 0.5 * (rs + rp);
|
||||
}
|
||||
|
||||
// Standard Schlick Fresnel
|
||||
float mx_fresnel_schlick(float cosTheta, float F0)
|
||||
{
|
||||
float x = clamp(1.0 - cosTheta, 0.0, 1.0);
|
||||
float x5 = mx_pow5(x);
|
||||
return F0 + (1.0 - F0) * x5;
|
||||
}
|
||||
color mx_fresnel_schlick(float cosTheta, color F0)
|
||||
{
|
||||
float x = clamp(1.0 - cosTheta, 0.0, 1.0);
|
||||
float x5 = mx_pow5(x);
|
||||
return F0 + (1.0 - F0) * x5;
|
||||
}
|
||||
|
||||
// Generalized Schlick Fresnel
|
||||
float mx_fresnel_schlick(float cosTheta, float F0, float F90)
|
||||
{
|
||||
float x = clamp(1.0 - cosTheta, 0.0, 1.0);
|
||||
float x5 = mx_pow5(x);
|
||||
return mix(F0, F90, x5);
|
||||
}
|
||||
color mx_fresnel_schlick(float cosTheta, color F0, color F90)
|
||||
{
|
||||
float x = clamp(1.0 - cosTheta, 0.0, 1.0);
|
||||
float x5 = mx_pow5(x);
|
||||
return mix(F0, F90, x5);
|
||||
}
|
||||
|
||||
// Generalized Schlick Fresnel with a variable exponent
|
||||
color mx_fresnel_schlick(float cosTheta, float f0, float f90, float exponent)
|
||||
{
|
||||
float x = clamp(1.0 - cosTheta, 0.0, 1.0);
|
||||
return mix(f0, f90, pow(x, exponent));
|
||||
}
|
||||
color mx_fresnel_schlick(float cosTheta, color f0, color f90, float exponent)
|
||||
{
|
||||
float x = clamp(1.0 - cosTheta, 0.0, 1.0);
|
||||
return mix(f0, f90, pow(x, exponent));
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
#include "mx_microfacet.osl"
|
||||
|
||||
// Rational curve fit approximation for the directional albedo of Imageworks sheen.
|
||||
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;
|
||||
return a / b;
|
||||
}
|
||||
|
||||
float mx_imageworks_sheen_dir_albedo(float NdotV, float roughness)
|
||||
{
|
||||
float dirAlbedo = mx_imageworks_sheen_dir_albedo_analytic(NdotV, roughness);
|
||||
return clamp(dirAlbedo, 0.0, 1.0);
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
#include "mx_microfacet.osl"
|
||||
|
||||
// Compute the average of an anisotropic alpha pair.
|
||||
float mx_average_alpha(vector2 alpha)
|
||||
{
|
||||
return sqrt(alpha.x * alpha.y);
|
||||
}
|
||||
|
||||
// Convert a real-valued index of refraction to normal-incidence reflectivity.
|
||||
float mx_ior_to_f0(float ior)
|
||||
{
|
||||
return mx_square((ior - 1.0) / (ior + 1.0));
|
||||
}
|
||||
|
||||
// Convert normal-incidence reflectivity to real-valued index of refraction.
|
||||
float mx_f0_to_ior(float F0)
|
||||
{
|
||||
float sqrtF0 = sqrt(clamp(F0, 0.01, 0.99));
|
||||
return (1.0 + sqrtF0) / (1.0 - sqrtF0);
|
||||
}
|
||||
|
||||
// Rational quadratic fit to Monte Carlo data for GGX directional albedo.
|
||||
color mx_ggx_dir_albedo(float NdotV, float alpha, color F0, color F90)
|
||||
{
|
||||
float x = NdotV;
|
||||
float y = alpha;
|
||||
float x2 = mx_square(x);
|
||||
float y2 = mx_square(y);
|
||||
vector4 r = vector4(0.1003, 0.9345, 1.0, 1.0) +
|
||||
vector4(-0.6303, -2.323, -1.765, 0.2281) * x +
|
||||
vector4(9.748, 2.229, 8.263, 15.94) * y +
|
||||
vector4(-2.038, -3.748, 11.53, -55.83) * x * y +
|
||||
vector4(29.34, 1.424, 28.96, 13.08) * x2 +
|
||||
vector4(-8.245, -0.7684, -7.507, 41.26) * y2 +
|
||||
vector4(-26.44, 1.436, -36.11, 54.9) * x2 * y +
|
||||
vector4(19.99, 0.2913, 15.86, 300.2) * x * y2 +
|
||||
vector4(-5.448, 0.6286, 33.37, -285.1) * x2 * y2;
|
||||
vector2 AB = vector2(r.x, r.y) / vector2(r.z, r.w);
|
||||
AB.x = clamp(AB.x, 0.0, 1.0);
|
||||
AB.y = clamp(AB.y, 0.0, 1.0);
|
||||
return F0 * AB.x + F90 * AB.y;
|
||||
}
|
||||
|
||||
float mx_ggx_dir_albedo(float NdotV, float alpha, float F0, float F90)
|
||||
{
|
||||
color result = mx_ggx_dir_albedo(NdotV, alpha, color(F0), color(F90));
|
||||
return result[0];
|
||||
}
|
||||
|
||||
float mx_ggx_dir_albedo(float NdotV, float alpha, float ior)
|
||||
{
|
||||
color result = mx_ggx_dir_albedo(NdotV, alpha, color(mx_ior_to_f0(ior)), color(1.0));
|
||||
return result[0];
|
||||
}
|
||||
|
||||
// https://blog.selfshadow.com/publications/turquin/ms_comp_final.pdf
|
||||
// Equations 14 and 16
|
||||
color mx_ggx_energy_compensation(float NdotV, float alpha, color Fss)
|
||||
{
|
||||
float Ess = mx_ggx_dir_albedo(NdotV, alpha, 1.0, 1.0);
|
||||
return 1.0 + Fss * (1.0 - Ess) / Ess;
|
||||
}
|
||||
|
||||
float mx_ggx_energy_compensation(float NdotV, float alpha, float Fss)
|
||||
{
|
||||
color result = mx_ggx_energy_compensation(NdotV, alpha, color(Fss));
|
||||
return result[0];
|
||||
}
|
||||
Packaged/Windows/Engine/Binaries/ThirdParty/MaterialX/libraries/pbrlib/genosl/mx_anisotropic_vdf.osl
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
void mx_anisotropic_vdf(vector absorption, vector scattering, float anisotropy, output VDF vdf)
|
||||
{
|
||||
// TODO: Need to remap parameters to match the new closure,
|
||||
// or change the MaterialX spec to OSL parameterization.
|
||||
vdf = 0;
|
||||
}
|
||||
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
void mx_artistic_ior(color reflectivity, color edge_color, output vector ior, output vector extinction)
|
||||
{
|
||||
// "Artist Friendly Metallic Fresnel", Ole Gulbrandsen, 2014
|
||||
// http://jcgt.org/published/0003/04/03/paper.pdf
|
||||
|
||||
color r = clamp(reflectivity, 0.0, 0.99);
|
||||
color r_sqrt = sqrt(r);
|
||||
color n_min = (1.0 - r) / (1.0 + r);
|
||||
color n_max = (1.0 + r_sqrt) / (1.0 - r_sqrt);
|
||||
ior = mix(n_max, n_min, edge_color);
|
||||
|
||||
color np1 = ior + 1.0;
|
||||
color nm1 = ior - 1.0;
|
||||
color k2 = (np1*np1 * r - nm1*nm1) / (1.0 - r);
|
||||
k2 = max(k2, 0.0);
|
||||
extinction = sqrt(k2);
|
||||
}
|
||||
Vendored
+49
@@ -0,0 +1,49 @@
|
||||
void mx_blackbody(float temp, output color color_value)
|
||||
{
|
||||
float xc, yc;
|
||||
float t, t2, t3, xc2, xc3;
|
||||
|
||||
// if value outside valid range of approximation clamp to accepted temperature range
|
||||
float temperature = clamp(temp, 1667.0, 25000.0);
|
||||
|
||||
t = 1000.0 / temperature;
|
||||
t2 = t * t;
|
||||
t3 = t * t * t;
|
||||
|
||||
// Cubic spline approximation for Kelvin temperature to sRGB conversion
|
||||
// (https://en.wikipedia.org/wiki/Planckian_locus#Approximation)
|
||||
if (temperature < 4000.0) { // 1667K <= temperature < 4000K
|
||||
xc = -0.2661239 * t3 - 0.2343580 * t2 + 0.8776956 * t + 0.179910;
|
||||
}
|
||||
else { // 4000K <= temperature <= 25000K
|
||||
xc = -3.0258469 * t3 + 2.1070379 * t2 + 0.2226347 * t + 0.240390;
|
||||
}
|
||||
xc2 = xc * xc;
|
||||
xc3 = xc * xc * xc;
|
||||
|
||||
if (temperature < 2222.0) { // 1667K <= temperature < 2222K
|
||||
yc = -1.1063814 * xc3 - 1.34811020 * xc2 + 2.18555832 * xc - 0.20219683;
|
||||
}
|
||||
else if (temperature < 4000.0) { // 2222K <= temperature < 4000K
|
||||
yc = -0.9549476 * xc3 - 1.37418593 * xc2 + 2.09137015 * xc - 0.16748867;
|
||||
}
|
||||
else { // 4000K <= temperature <= 25000K
|
||||
yc = 3.0817580 * xc3 - 5.87338670 * xc2 + 3.75112997 * xc - 0.37001483;
|
||||
}
|
||||
|
||||
if (yc <= 0.0) { // avoid division by zero
|
||||
color_value = color(1.0);
|
||||
return;
|
||||
}
|
||||
|
||||
vector XYZ = vector(xc / yc, 1.0, (1 - xc - yc) / yc);
|
||||
|
||||
/// XYZ to Rec.709 RGB colorspace conversion
|
||||
matrix XYZ_to_RGB = matrix( 3.2406, -0.9689, 0.0557, 0.0,
|
||||
-1.5372, 1.8758, -0.2040, 0.0,
|
||||
-0.4986, 0.0415, 1.0570, 0.0,
|
||||
0.0, 0.0, 0.0, 1.0);
|
||||
|
||||
color_value = transform(XYZ_to_RGB, XYZ);
|
||||
color_value = max(color_value, vector(0.0));
|
||||
}
|
||||
Packaged/Windows/Engine/Binaries/ThirdParty/MaterialX/libraries/pbrlib/genosl/mx_dielectric_bsdf.osl
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
void mx_dielectric_bsdf(float weight, color tint, float ior, vector2 roughness, normal N, vector U, string distribution, string scatter_mode, output BSDF bsdf)
|
||||
{
|
||||
if (scatter_mode == "R")
|
||||
{
|
||||
bsdf = weight * dielectric_bsdf(N, U, tint, color(0.0), roughness.x, roughness.y, ior, distribution);
|
||||
}
|
||||
else if (scatter_mode == "T")
|
||||
{
|
||||
bsdf = weight * dielectric_bsdf(N, U, color(0.0), tint, roughness.x, roughness.y, ior, distribution);
|
||||
}
|
||||
else
|
||||
{
|
||||
bsdf = weight * dielectric_bsdf(N, U, tint, tint, roughness.x, roughness.y, ior, distribution);
|
||||
}
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
void mx_displacement_float(float displacement, float scale, output displacementshader result)
|
||||
{
|
||||
result = vector(displacement * scale);
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user