Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add Gooch Shading node to NPR library #1674

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
febc498
Introduce a Gooch node and implementation.
kwokcb Jan 24, 2024
bb049b5
Update example material
ashwinbhat Jan 24, 2024
b0d3f4c
Update node name gooch_shade
ashwinbhat Jan 25, 2024
52563c5
Add nodegroup for gooch_shade node
ashwinbhat Jan 25, 2024
1df4221
Fix highlight.
ashwinbhat Jan 25, 2024
8e67932
Merge branch 'main' into bhata/npr_gooch
ashwinbhat Jan 25, 2024
068d7ce
Remove unused node.
kwokcb Jan 26, 2024
6a94169
- Fix light direction (should be inverted).
kwokcb Jan 27, 2024
94eb3ac
Change to fit logic from Gooch paper.
kwokcb Jan 27, 2024
942dc1f
Fix gooch shader usage in Example material.
kwokcb Jan 27, 2024
18a99cd
Remove combined PBR/NPR example
jstone-lucasfilm Jan 27, 2024
02c9f25
Rename test suite example
jstone-lucasfilm Jan 27, 2024
79a4c93
Merge branch 'main' into bhata/npr_gooch
jstone-lucasfilm Jan 28, 2024
5c01aa0
Remove extra convert nodes
jstone-lucasfilm Jan 28, 2024
18aeca8
Updates:
kwokcb Jan 29, 2024
17fd1b7
Add an upstream graph to compute warm / cool colours based on math in…
kwokcb Jan 29, 2024
b415638
Remove multiply by one
jstone-lucasfilm Jan 29, 2024
4c9346f
Clarify shading logic
jstone-lucasfilm Jan 29, 2024
8147e60
Simplify example materials
jstone-lucasfilm Jan 29, 2024
17e2cef
Allow shininess to exceed the soft maximum
jstone-lucasfilm Jan 29, 2024
9c1280d
Extend range for shininess
jstone-lucasfilm Jan 29, 2024
7b98391
Merge branch 'main' into bhata/npr_gooch
jstone-lucasfilm Jan 30, 2024
6f8dc12
Simplify shading logic
jstone-lucasfilm Jan 30, 2024
8afc520
Clarify highlight logic
jstone-lucasfilm Jan 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions libraries/nprlib/nprlib_defs.mtlx
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,17 @@
<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" uiname="Light Direction" doc="Light vector in world space" />
<output name="out" type="color3"/>
</nodedef>

</materialx>
75 changes: 75 additions & 0 deletions libraries/nprlib/nprlib_ng.mtlx
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,79 @@
<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" />
<viewdirection name="viewdir" type="vector3" />
<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>
<dotproduct name="NdotV" type="float">
<input name="in1" type="vector3" nodename="unit_normal" />
<input name="in2" type="vector3" nodename="unit_viewdir" />
</dotproduct>
<multiply name="NdotV_2" type="float">
<input name="in1" type="float" nodename="NdotV" />
<input name="in2" type="float" value="2" />
</multiply>
<multiply name="NdotV_N_2" type="vector3">
<input name="in1" type="vector3" nodename="unit_normal" />
<input name="in2" type="float" nodename="NdotV_2" />
</multiply>
<subtract name="view_reflect" type="vector3">
<input name="in1" type="vector3" nodename="unit_viewdir" />
<input name="in2" type="vector3" nodename="NdotV_N_2" />
</subtract>
<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>
30 changes: 30 additions & 0 deletions resources/Materials/TestSuite/nprlib/gooch_shade.mtlx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0"?>
<materialx version="1.38">

<gooch_shade name="default_gooch" type="color3">
<input name="warm_color" type="color3" value="0.8, 0.8, 0.7" />
<input name="cool_color" type="color3" value="0.3, 0.3, 0.8" />
<input name="specular_intensity" type="float" value="1" />
<input name="shininess" type="float" value="64" />
</gooch_shade>
<surface_unlit name="unlit_surface" type="surfaceshader">
<input name="emission_color" type="color3" nodename="default_gooch" />
</surface_unlit>
<surfacematerial name="default_gooch_material" type="material">
<input name="surfaceshader" type="surfaceshader" nodename="unlit_surface" />
</surfacematerial>

<gooch_shade name="red_blue_gooch" type="color3">
<input name="warm_color" type="color3" value="0.9, 0.1, 0.1" />
<input name="cool_color" type="color3" value="0.1, 0.1, 0.9" />
<input name="specular_intensity" type="float" value="1" />
<input name="shininess" type="float" value="64" />
</gooch_shade>
<surface_unlit name="redblue_gooch_surface" type="surfaceshader">
<input name="emission_color" type="color3" nodename="red_blue_gooch" />
</surface_unlit>
<surfacematerial name="redblue_gooch_material" type="material">
<input name="surfaceshader" type="surfaceshader" nodename="redblue_gooch_surface" />
</surfacematerial>

</materialx>
Loading