Visitar URL original
fix: Correct anisotropic GGX and reflection roughness by drakeo338 · Pull Request #9530 · playcanvas/engine · GitHub
Skip to content

fix: Correct anisotropic GGX and reflection roughness - #9530

Open
drakeo338 wants to merge 2 commits into
playcanvas:mainfrom
drakeo338:claude/9511-fix
Open

drakeo338 wants to merge 2 commits into
playcanvas:mainfrom
drakeo338:claude/9511-fix

Conversation

@drakeo338

@drakeo338 drakeo338 commented Sep 25, 2026 •

Copy link
Copy Markdown

Description

This covers both parts of the issue, in the GLSL and WGSL chunks.

The anisotropic GGX chunk squared (1 - gloss)^2 again, so at and ab came from perceptualRoughness^4. It now uses alphaRoughness = (1 - gloss)^2 directly. reflDirAniso bent the reflection normal with sqrt(1 - gloss); it now uses 1 - gloss, matching the reference getIBLRadianceAnisotropy.

It is a visible change: anisotropic highlights get noticeably wider and less intense, and glossy anisotropic reflections bend more. A new unit test evaluates the roughness lines of all four chunks; it fails on main and passes here. npm test and npm run lint are clean.

#9513 covers the separate isotropic bug (#9510).

Fixes #9511

Checklist

  • I have read the contributing guidelines
  • My code follows the project's coding standards
  • This PR focuses on a single change

calcLightSpecular in the anisotropic GGX chunk took roughness as
(1 - gloss)^2 and then squared it again for alphaRoughness, so at and ab
were built from perceptual roughness to the fourth power. The Khronos
KHR_materials_anisotropy reference derives them from alphaRoughness =
perceptualRoughness^2, so anisotropic highlights came out too narrow.
Compute alphaRoughness directly in both the GLSL and WGSL chunks.

Fixed playcanvas#9511
getReflDir in reflDirAniso computed the bend roughness as
sqrt(1 - gloss), i.e. sqrt(perceptualRoughness). The glTF Sample
Renderer's getIBLRadianceAnisotropy is called with perceptualRoughness
itself, so glossy anisotropic materials were bent less than they should
be. Use 1 - gloss in both the GLSL and WGSL chunks, and cover it in the
anisotropy chunk test alongside the alphaRoughness check.

Fixes playcanvas#9511
@drakeo338 drakeo338 changed the title fix: Square perceptual roughness once in anisotropic GGX fix: Correct anisotropic GGX and reflection roughness Sep 25, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Anisotropic GGX squares roughness twice, making KHR_materials_anisotropy lobes far too tight

1 participant