fix: include fresnelSchlick chunk when refraction is enabled without specular#8595
Merged
willeastcott merged 1 commit intomainfrom Apr 13, 2026
Merged
fix: include fresnelSchlick chunk when refraction is enabled without specular#8595willeastcott merged 1 commit intomainfrom
willeastcott merged 1 commit intomainfrom
Conversation
…specular The fresnelSchlickPS chunk (defining getFresnel) was only included under LIT_SPECULAR_OR_REFLECTION, but refractionDynamicPS calls getFresnel regardless. When a material has refraction enabled with specular disabled (e.g. black specular color, no metalness), the shader fails to compile. Made-with: Cursor
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a forward-lit shader compilation failure where refraction code can call getFresnel() even when the Fresnel implementation chunk wasn’t being included (notably when refraction is enabled while specular/reflection is effectively disabled).
Changes:
- Move
fresnelSchlickPSinclusion out of theLIT_SPECULAR_OR_REFLECTION-only block. - Include
fresnelSchlickPSwhen eitherLIT_SPECULAR_OR_REFLECTIONorLIT_REFRACTIONis defined. - Apply the same change to both GLSL and WGSL forward-pass post code.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/scene/shader-lib/wgsl/chunks/lit/frag/pass-forward/litForwardPostCode.js | Ensures the Fresnel Schlick chunk is available when refraction is enabled in WGSL. |
| src/scene/shader-lib/glsl/chunks/lit/frag/pass-forward/litForwardPostCode.js | Ensures the Fresnel Schlick chunk is available when refraction is enabled in GLSL. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
'getFresnel' : no matching overloaded function found) when a material has refraction enabled but specular is effectively disabled (e.g. black specular color with no metalness)Root Cause
The
fresnelSchlickPSchunk — which defines thegetFresnel()function — was only included inside the#ifdef LIT_SPECULAR_OR_REFLECTIONguard inlitForwardPostCode.js. However, therefractionDynamicPSchunk (included under#ifdef LIT_REFRACTION) callsgetFresnel()regardless. WhenLIT_SPECULAR_OR_REFLECTIONwas false butLIT_REFRACTIONwas true, the function was called but never defined.Fix
Moved the
fresnelSchlickPSinclude so it is also triggered whenLIT_REFRACTIONis defined:Applied to both the GLSL and WGSL versions of
litForwardPostCode.js.Steps to Reproduce
Test Plan