Fix IOR/refractionIndex being ignored in materials#8311
Merged
Conversation
willeastcott
approved these changes
Dec 23, 2025
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.
Fix IOR/refractionIndex being ignored in materials
Summary
Fixes #6911
This PR fixes an issue where custom
refractionIndexvalues were being ignored in materials, causing all IOR rows to appear identical in transmission tests.Changes
Bug Fix: Inverted
equalishlogicThe
equalishchecks forrefractionTint,refractionIndexTint, andiorTintwere inverted. Theequalishfunction returnstruewhen values are approximately equal, but the logic neededtruewhen values differ from the default (to enable the shader uniform).Before: When
refractionIndexdiffered from the default, the shader used the hardcoded default value, ignoring the user's setting.After: When
refractionIndexdiffers from the default, theSTD_IOR_CONSTANTdefine is set and the user's value is correctly passed to the shader.Safety: Clamp refractionIndex to avoid division by zero
Added clamping to
refractionIndexuniform (minimum 0.001) to prevent infinity when calculatingf0 = 1.0 / litArgs_iorin the shader.New Example
Added
transmission-roughness.example.mjsusing the Khronos TransmissionRoughnessTest.glb model to demonstrate and verify correct IOR/roughness interaction.Reference image

PlayCanvas before (all rows are the same, ior is ignored)

PlayCanvas now
