[FIX] Add Dedicated Isotropic GGX Specular Implementation #8299
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds a dedicated isotropic GGX specular shader path for non-anisotropic materials, improving performance and code clarity. Previously, all GGX specular used the anisotropic implementation even when anisotropy was disabled.
Changes
lightSpecularGGX.jsshader files (GLSL and WGSL) implementing isotropic GGXLIT_ANISOTROPYshader define to control which specular path is useduseAnisotropyoption to material options buildersTechnical Details
New Isotropic GGX Implementation
Shader Path Selection
Anisotropy Detection
useAnisotropyis set totrueonly when:enableGGXSpecularis enabled, ANDanisotropyIntensity > 0ORanisotropyMapis setPerformance Benefits
The isotropic path avoids:
This benefits the common case where materials don't use anisotropy.
Files Changed
src/scene/shader-lib/glsl/chunks/lit/frag/lightSpecularGGX.jssrc/scene/shader-lib/wgsl/chunks/lit/frag/lightSpecularGGX.jssrc/scene/shader-lib/glsl/chunks/lit/frag/pass-forward/litForwardPostCode.jssrc/scene/shader-lib/wgsl/chunks/lit/frag/pass-forward/litForwardPostCode.jssrc/scene/shader-lib/glsl/collections/shader-chunks-glsl.jssrc/scene/shader-lib/wgsl/collections/shader-chunks-wgsl.jssrc/scene/shader-lib/programs/lit-shader.jssrc/scene/materials/standard-material-options-builder.jssrc/scene/materials/lit-material-options-builder.jsAPI Changes
New shader define:
LIT_ANISOTROPY- set when material uses anisotropyNew material option:
useAnisotropy- automatically determined based on material propertiesBreaking Changes
None. Existing materials will automatically use the appropriate path based on their anisotropy settings.
Fixes #2869
Fixes #8295
Checklist