open_pbr_surface` with `specular_weight = 0` gets darker at grazing angles in GLSL

Aperta
#3,128 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva

Direzione di ricerca

Start by reading mx_dielectric_bsdf.glsl, especially the three branches that compute F90 and the throughput to the base layer. Reproduce the reported grazing-angle darkening with the attached material and uniform environment, then compare against oren_nayar_diffuse_bsdf. Done when the cause is understood and the corrected result behaves as expected without regressions for other F0 values.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Hi, and thanks for MaterialX! I noticed something while comparing renderers and wanted to check whether this is expected.

With open_pbr_surface, specular_weight = 0 and a grey base colour (0.18), a sphere under a uniform white environment gets darker toward the silhouette in MaterialXView 1.39.5. I expected it to look flat, like oren_nayar_diffuse_bsdf on its own does.

Material centre 90 % radius 98 % radius
open_pbr_surface, specular_weight = 0 0.178 0.169 0.139 (about −22 %)
oren_nayar_diffuse_bsdf only 0.181 0.181 0.181

I see the same thing in OpenUSD Storm with MaterialX 1.39.4.

What I think might be happening

With specular_weight = 0, OpenPBR sets the dielectric IOR to 1, so F0 is 0 and the specular response is zero. But in mx_dielectric_bsdf.glsl the throughput to the base layer seems to use a fixed F90 of 1.0:

vec3 dirAlbedo = mx_ggx_dir_albedo(NdotV, avgAlpha, F0, 1.0) * comp;
bsdf.throughput = 1.0 - dirAlbedo * weight;

So the base layer still loses some energy at grazing angles, even though nothing is reflected. I might be misreading this, so please correct me if so.

As a quick test, I changed F90 to clamp(50.0 * F0, 0.0, 1.0) (the Filament approximation) in the three branches of that file. The open_pbr_surface render then matched oren_nayar_diffuse_bsdf exactly. I only tested the IOR = 1 case, so I'm not sure this is the right fix in general. It only changes results when F0 is below 0.02.

The same code is still on main (12de4d3).

To reproduce

Material (diffuse18_openpbr.mtlx, attached):

<?xml version="1.0"?>
<materialx version="1.39">
  <open_pbr_surface name="SR_diffuse18" type="surfaceshader">
    <input name="base_color" type="color3" value="0.18, 0.18, 0.18" />
    <input name="specular_weight" type="float" value="0.0" />
  </open_pbr_surface>
  <surfacematerial name="M_diffuse18" type="material">
    <input name="surfaceshader" type="surfaceshader" nodename="SR_diffuse18" />
  </surfacematerial>
</materialx>

white_env.hdr (attached) is a small HDR with every pixel 1.0.

MaterialXView --material diffuse18_openpbr.mtlx --mesh resources/Geometry/sphere.obj --envRad white_env.hdr --envMethod 0 --envSampleCount 1024 --enableDirectLight false --shadowMap false --drawEnvironment false --screenColor 0,0,0 --cameraViewAngle 0 --captureFilename openpbr.png

Environment: MaterialX 1.39.5 official Windows build, NVIDIA RTX 4070 Ti, Windows 10.

Attached: the two .mtlx files, white_env.hdr, a radial profile plot, and a side-by-side comparison image.

Thanks for taking a look!

Lingua principale
C++
Stelle
2.3k
Fork
472
Merge medio
1g 4h
PR unite (30g)
7

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di AcademySoftwareFoundation/MaterialX

Tutte le issue di AcademySoftwareFoundation/MaterialX

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.