MeshPhysicalMaterial: Match behavior of attenuationDistance to KHR_materials_volume #24622
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.
Related issue: N/A
Description
This is an alternative approach to #24620 See also #24620 (comment)
The default
attenuationDistance
inMeshPhysicalMaterial
is0.0
, which is functionally equivalent to Infinity (c.f.three.js/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js
Line 74 in f160d03
The KHR_materials_volume spec requires that attenuationDistance be greater than zero if present. It defaults to Infinity if not present. (c.f. https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_volume/README.md#properties )
The current GTLFExporter produces incorrect gltf files for
MeshPhysicalMaterial
iftransmission
is set greater than zero, butattenuationDistance
is set to the default of zero. These incorrect files cannot be read in some popular GLTF software (like Blender 3.3 GLTF Importer)This PR changes the default value of
attenuationDistance
toInfinity
, and the behavior of0
andInfinity
to more closely align with the KHR_materials_volume specification.Note: Only one of #24620 or this PR should be accepted. They are different approaches to the same problem.