Autodesk / Autodesk/maya-usd

evaluateDirectDiffuse should not multiply by 1/PI when not integrated

Open
#3,892 7 comments 0 reactions 0 assignees View on GitHub
Dominant language
Wolfram Language
Stars
905
Forks
223
Avg merge
2d 9h
Merged PRs (30d)
17

Description

https://github.com/Autodesk/maya-usd/blob/8391cd9c44b546c1970ef2f7937439d1f338c17c/lib/mayaUsd/render/vp2ShaderFragments/usdPreviewSurfaceLightingAPI1.xml#L124-L129

I work for a studio where we have an issue that the default maya surface shaders look wildly different to the UsdPreviewSurface shaders in Maya. The UsdPreviewSurface shaders look a LOT darker.

The reason is an incorrect application of the hemispherical integral of the diffuse in your implementation.

You should not be multiplying by 1/PI for diffuse, since you are not integrating over the hemisphere like you would be if you were sampling in a raytracer.

Since you are point sampling, the 1/PI multiplication factor introduces an incorrect darkening.

The reason for this is that since you are not using a monte-carlo estimator, the PDF for diffuse is (1/pi) cos(theta), but in order to use this in a raytracer you do the following:

f = diffuseColor * (1/pi) * cos(theta)
pdf = (1/pi) * cos(theta)

E = f / pdf = (diffuseColor * (1/pi) * cos(theta)) / ((1/pi) * cos(theta)) = diffuseColor

See how the (1/pi) factor falls away when used in the form of the estimator (which a monte-carlo renderer uses)?

Since you are only point-sampling in your viewport engine, and you are therefore not using the pdf, you need to pre-divide by it to get an accurate result.

Could you please change this code to remove the (1/PI) factor in all implementations to make your result match a standard ray-tracer and the previous maya viewport shaders?

Thanks.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with lib/mayaUsd/render/vp2ShaderFragments/usdPreviewSurfaceLightingAPI1.xml at lines 124-129 and inspect the other implementations of evaluateDirectDiffuse. Remove the incorrect diffuse factor as described, then verify that UsdPreviewSurface viewport shading matches the standard Maya viewport shaders without the reported darkening.

Written by the indexing model from the issue text.

Assessment

Tech stack
xml
Domain
computer-graphics
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.