Various changes to support material nodes vs material elements
Add in support for units and expose API to set system + target.
Fix to optimization to keep constant images if any colorspace or unit transform is encoded into the graph being baked. New utility added to detect if a graph has certain "attributes" on nodes.
Update flatten interface to be able to perform selective flattening passed on a predicate and update flatten to make sure that unit, unitype and colorspace are transferred during flattening.
Add baking as a unit test (RTS) option via _options.mtlx file. Update test file with color + unit bake.
<?xml version="1.0"?>
<materialx version="1.38">
<nodegraph name="NG_baked" colorspace="srgb_texture">
<image name="normal_baked" type="vector3">
<input name="file" type="filename" uniform="true" value="NormalMapGraph_normal_NormalMappedShader_baked.png" />
</image>
<normalmap name="normal_baked_map" type="vector3">
<input name="in" type="vector3" nodename="normal_baked" />
<input name="scale" type="float" value="1.1" />
<input name="space" type="string" value="tangent" />
</normalmap>
<output name="normal_output" type="vector3" nodename="normal_baked_map" />
</nodegraph>
<standard_surface name="NormalMappedShader_baked" type="surfaceshader">
<input name="base" type="float" value="0.6" />
<input name="metalness" type="float" value="1.0" />
<input name="specular" type="float" value="0.7" />
<input name="coat" type="float" value="1" />
<input name="normal" type="vector3" output="normal_output" nodegraph="NG_baked" />
<input name="base_color" type="color3" value="1, 1, 1" 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="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" 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="0.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_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" uisoftmax="3.0" uiname="Coat Index of Refraction" uifolder="Coat" doc="The index of refraction of the 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" 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. Suiteable for thin objects such as tree leafs or paper" />
</standard_surface>
<surfacematerial name="NormalMappedShaderMaterial_baked" type="material">
<input name="surfaceshader" type="surfaceshader" nodename="NormalMappedShader_baked" />
</surfacematerial>
</materialx>
Update #460 Update #831 Update #920 Update #974
Sample before bake
Sample after bake
Baked Images: Note that the baked images are sampling upstream graphs after flattening is performed.
* Original render
* Baked render
Normal map example
*Flattend normalmap graph**
Unbaked normalmap render
Baked normalmap render
Baked texture, and original