Skip to content

Commit

Permalink
Metallic materials should have an F0 equal to their base color in Usd…
Browse files Browse the repository at this point in the history
…PreviewSurface.

Fixes #1174

(Internal change: 2090921)
  • Loading branch information
clach authored and pixar-oss committed Aug 17, 2020
1 parent 8a13d20 commit f11ab36
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ evaluateLight(
if (!useSpecularWorkflow) {
float R = (1.0 - ior) / (1.0 + ior);
vec3 specColor = mix(vec3(1.0), diffuseColor, metallic);
F0 = R * R * specColor;
F0 = mix(R * R * specColor, specColor, metallic);
F90 = specColor;

// For metallic workflows, pure metals have no diffuse
Expand Down Expand Up @@ -297,7 +297,7 @@ evaluateIndirectLighting(
if (!useSpecularWorkflow) {
float R = (1.0 - ior) / (1.0 + ior);
vec3 specColor = mix(vec3(1.0), diffuseColor, metallic);
F0 = R * R * specColor;
F0 = mix(R * R * specColor, specColor, metallic);
F90 = specColor;

// For metallic workflows, pure metals have no diffuse
Expand Down
10 changes: 5 additions & 5 deletions pxr/usdImaging/plugin/usdShaders/shaders/shaderDefs.usda
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ def Shader "UsdPreviewSurface" (
float inputs:metallic = 0.0 (
doc = """Used only in the metalness workflow.
1 for metallic surfaces and 0 for non-metallic.
- If metallic is 1, then F0 (reflectivity at 0 degree incidence)
will be derived from ior ( (1-ior)/(1+ior) )^2, then multiplied by Albedo;
while edge F90 reflectivity will simply be the Albedo.
(As an option, you can put ior to 0 such that F0 comes equal to F90 and thus the Albedo).
- If metallic is 0, then Albedo is ignored; F0 is derived from ior and F90 is white.
- If metallic is 1, then both F0 (reflectivity at 0 degree
incidence) and edge F90 reflectivity will simply be the Albedo.
- If metallic is 0, then Albedo is ignored in the calculation of F0
and F90; F0 is derived from ior via ( (1-ior)/(1+ior) )^2 and F90 is
white.
In between, we interpolate."""
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ shader UsdPreviewSurfaceParameters
float metal = clamp(metallic, 0.0, 1.0);
color spec = mix(color(1.0,1.0,1.0), diffuseColor, metal);
float r = (1.0 - ior) / (1.0 + ior);
specularFaceColorOut = r * r * spec;
specularFaceColorOut = mix(r * r * spec, spec, metal);
specularEdgeColorOut = spec;

diffuseGainOut *= 1.0 - metal;
Expand Down

0 comments on commit f11ab36

Please sign in to comment.