Skip to content

Commit

Permalink
Updates:
Browse files Browse the repository at this point in the history
- Change specular color to specular intensity with default 1
- Change back to using warm and cool colours to drive diffuse
- Keep the paper's additive color mixing for diffuse.
  • Loading branch information
kwokcb committed Jan 29, 2024
1 parent 5c01aa0 commit 18aeca8
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 68 deletions.
16 changes: 6 additions & 10 deletions libraries/nprlib/nprlib_defs.mtlx
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,12 @@
Compute Gooch Shading.
-->
<nodedef name="ND_gooch_shade" node="gooch_shade" nodegroup="npr" doc="Compute Gooch shading">
<input name="diffuse_color" type="color3" value="0.8, 0.8, 0.8" doc="Diffuse Color" uiname="Diffuse Color" />
<input name="blue_tone" type="float" value="0.55" uimin="0" uimax="1" doc="Blue tone" uiname="Blue Tone" />
<input name="yellow_tone" type="float" value="0.3" uimin="0" uimax="1" doc="Yellow Tone" uiname="Yellow Tone" />
<input name="diffuse_strength" type="float" value="0.25" uimin="0" uimax="1" doc="Diffuse Strength" uiname="Diffuse Strength" />
<input name="luminance_shift" type="float" value="0.5" uimin="0" uimax="1" doc="Luminance Shift" uiname="Luminance Shift" />
<input name="shininess" type="float" value="32" uimin="1" uimax="64" uiname="Shininess" doc="Specular shininess" />
<input name="specular_color" type="color3" value="1, 1, 1" uiname="Specular Color" doc="Specular color" />
<input name="light_direction" type="vector3" value="1, -0.5, -0.5" uiname="Light Direction" doc="Light vector" />
<output name="out" type="color3" />
<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" uimax="64" uiname="Shininess" doc="Specular Power" />
<input name="light_direction" type="vector3" value="1, -0.5, -0.5" uiname="Light Direction" doc="Light vector in world space" />
<output name="out" type="color3"/>
</nodedef>


</materialx>
66 changes: 19 additions & 47 deletions libraries/nprlib/nprlib_ng.mtlx
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@
<input name="in" type="vector3" interfacename="light_direction" />
</normalize>
<dotproduct name="NdotL" type="float">
<input name="in1" type="vector3" nodename="N" />
<input name="in1" type="vector3" nodename="normalize_vector4" />
<input name="in2" type="vector3" nodename="normalized_light_dir" />
</dotproduct>
<power name="specular" type="float">
<power name="specular_power" type="float">
<input name="in1" type="float" nodename="max1" />
<input name="in2" type="float" interfacename="shininess" />
</power>
Expand Down Expand Up @@ -97,26 +97,10 @@
<input name="in1" type="vector3" nodename="normalize_vector3" />
<input name="in2" type="vector3" nodename="NdotI_N_2" />
</subtract>
<multiply name="multiply_color3FA" type="color3">
<input name="in2" type="float" nodename="specular" />
<input name="in1" type="color3" interfacename="specular_color" />
</multiply>
<add name="final_color" type="color3">
<input name="in1" type="color3" nodename="diffuse" />
<input name="in2" type="color3" nodename="multiply_color3FA" />
</add>
<multiply name="invert_light_dir" type="vector3">
<input name="in1" type="vector3" nodename="normalized_light_dir" />
<input name="in2" type="vector3" value="-1, -1, -1" />
</multiply>
<swizzle name="swizzle_float_color3" type="color3">
<input name="in" type="float" interfacename="blue_tone" />
<input name="channels" type="string" value="00b" />
</swizzle>
<swizzle name="swizzle_float_color4" type="color3">
<input name="in" type="float" interfacename="yellow_tone" />
<input name="channels" type="string" value="rg0" />
</swizzle>
<add name="one_plus_NdotL" type="float">
<input name="in2" type="float" nodename="NdotL" />
<input name="in1" type="float" value="1" />
Expand All @@ -125,42 +109,30 @@
<input name="in1" type="float" nodename="one_plus_NdotL" />
<input name="in2" type="float" value="2" />
</divide>
<subtract name="one_minus_NdotL" type="float">
<input name="in2" type="float" nodename="NdotL" />
<add name="diffuse" type="color3">
<input name="in1" type="color3" nodename="cool" />
<input name="in2" type="color3" nodename="warm" />
</add>
<subtract name="subtract_float" type="float">
<input name="in2" type="float" nodename="one_plus_NdotL_div_2" />
<input name="in1" type="float" value="1" />
</subtract>
<divide name="one_minus_NdotL_div_2" type="float">
<input name="in1" type="float" nodename="one_minus_NdotL" />
<input name="in2" type="float" value="2" />
</divide>
<multiply name="multiply_color3" type="color3">
<input name="in1" type="color3" interfacename="diffuse_color" />
<input name="in2" type="float" interfacename="diffuse_strength" />
</multiply>
<add name="k_cool" type="color3">
<input name="in1" type="color3" nodename="multiply_color3" />
<input name="in2" type="color3" nodename="swizzle_float_color3" />
</add>
<add name="k_warm" type="color3">
<input name="in2" type="color3" nodename="swizzle_float_color4" />
<input name="in1" type="color3" nodename="multiply_color4" />
</add>
<multiply name="multiply_color4" type="color3">
<input name="in1" type="color3" interfacename="diffuse_color" />
<input name="in2" type="float" interfacename="luminance_shift" />
<multiply name="warm" type="color3">
<input name="in1" type="color3" interfacename="warm_color" />
<input name="in2" type="float" nodename="subtract_float" />
</multiply>
<multiply name="cool" type="color3">
<input name="in1" type="color3" nodename="k_cool" />
<input name="in2" type="float" nodename="one_plus_NdotL_div_2" />
<input name="in1" type="color3" interfacename="cool_color" />
</multiply>
<multiply name="warm" type="color3">
<input name="in1" type="color3" nodename="k_warm" />
<input name="in2" type="float" nodename="one_minus_NdotL_div_2" />
</multiply>
<add name="diffuse" type="color3">
<input name="in1" type="color3" nodename="cool" />
<input name="in2" type="color3" nodename="warm" />
<add name="final_color" type="color3">
<input name="in2" type="float" nodename="specular" />
<input name="in1" type="color3" nodename="diffuse" />
</add>
<multiply name="specular" type="float">
<input name="in1" type="float" interfacename="specular_intensity" />
<input name="in2" type="float" nodename="specular_power" />
</multiply>
<output name="out" type="color3" nodename="final_color" />
</nodegraph>

Expand Down
29 changes: 18 additions & 11 deletions resources/Materials/TestSuite/nprlib/gooch_shade.mtlx
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
<?xml version="1.0"?>
<materialx version="1.38">
<gooch_shade name="gooch1" type="color3">
<input name="diffuse_strength" type="float" value="0.269" />
<input name="diffuse_color" type="color3" value="0, 0.535452, 0.068077" />
<input name="luminance_shift" type="float" value="0.374" />
<input name="yellow_tone" type="float" value="0.325" />
<input name="blue_tone" type="float" value="0.491" />
<input name="light_direction" type="vector3" value="-1, -0.5, -0.5" />
<input name="shininess" type="float" value="5" />
</gooch_shade>
<gooch_shade name="default_gooch" type="color3" />
<surface_unlit name="unlit_surface" type="surfaceshader">
<input name="emission_color" type="color3" nodename="gooch1" />
<input name="emission_color" type="color3" nodename="default_gooch" />
<input name="opacity" type="float" value="1.0" />
</surface_unlit>
<surfacematerial name="surfacematerial" type="material">
<surfacematerial name="default_gooch_material" type="material">
<input name="surfaceshader" type="surfaceshader" nodename="unlit_surface" />
<input name="displacementshader" type="displacementshader" value="" />
</surfacematerial>
<gooch_shade name="red_blue_gooch" type="color3">
<input name="warm_color" type="color3" value="1, 0, 0" />
<input name="cool_color" type="color3" value="0, 2.38419e-07, 1" />
<input name="specular_intensity" type="float" value="0.5" />
<input name="shininess" type="float" value="32" />
<input name="light_direction" type="vector3" value="-1, -0.5, -0.5" />
</gooch_shade>
<surface_unlit name="unlit_surface2" type="surfaceshader">
<input name="emission_color" type="color3" nodename="red_blue_gooch" />
<input name="opacity" type="float" value="1.0" />
</surface_unlit>
<surfacematerial name="redblue_gooch_material" type="material">
<input name="surfaceshader" type="surfaceshader" nodename="unlit_surface2" />
<input name="displacementshader" type="displacementshader" value="" />
</surfacematerial>
</materialx>

0 comments on commit 18aeca8

Please sign in to comment.