Add dispersion support to PrincipledMaterial
A material's index of refraction varies across wavelengths, so light
refracted through its volume separates into colored fringes, the way a
prism splits white light. The new dispersion property follows the glTF
KHR_materials_dispersion extension, which gives the strength as 20
divided by the Abbe number, so 1.0 is about as dispersive as ordinary
materials get. The default of zero leaves the generated shader
unchanged for existing materials.
The implementation is the real-time approach of the extension: one
index of refraction and one refraction per color channel, within the
existing screen space refraction. Attenuation still uses the undispersed
ray length, and punctual light transmission stays monochromatic as in
the reference implementation.
Dispersion needs transmission to have any effect. CustomMaterial can set
it through the new DISPERSION keyword, and a shader that writes it
without setting TRANSMISSION_FACTOR gets a warning, while still
compiling.
[ChangeLog][PrincipledMaterial] Added the dispersion property, which
splits light refracted through a transmissive material into color
fringes the way a prism does.
Task-number: QTBUG-148682
Change-Id: I816c01dae62f7942b4792189de2d3387f9d6a804
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
| commit | 25e5d94ad8c2e99b87b8696652b7d1f382d61d8b |
| parent | cd7598a2be7935dac8da05b428c46b4a844ca739 |
| author | Andy Nichols <andy.nichols@qt.io> |
| committer | Andy Nichols <andy.nichols@qt.io> |
| commit time | Tue, 29 Sep 2026 11:22:31 +0000 |
- M examples/quick3d/principledmaterial/RefractionPane.qml
- M src/quick3d/designer/PrincipledMaterialSection.qml
- M src/quick3d/designer/propertyGroups.json
- M src/quick3d/qquick3dcustommaterial.cpp
- M src/quick3d/qquick3dprincipledmaterial.cpp
- M src/quick3d/qquick3dprincipledmaterial_p.h
- M src/runtimerender/graphobjects/qssgrendercustommaterial_p.h
- M src/runtimerender/graphobjects/qssgrenderdefaultmaterial_p.h
- M src/runtimerender/qssgrenderdefaultmaterialshadergenerator.cpp
- M src/runtimerender/qssgrendershaderkeys_p.h
- M src/runtimerender/qssgrhicontext_p.h
- M src/runtimerender/qssgshadermaterialadapter.cpp
- M src/runtimerender/qssgshadermaterialadapter_p.h
- M src/runtimerender/rendererimpl/qssglayerrenderdata.cpp
- M src/runtimerender/rendererimpl/qssgvertexpipelineimpl.cpp
- M src/runtimerender/res/effectlib/transmission.glsllib
- M src/runtimerender/resourcemanager/qssgrendershaderlibrarymanager_p.h
- M tests/auto/quick3d/qquick3dmaterials/tst_qquick3dmaterials.cpp
- A tests/baseline/data/custommaterial/custom_dispersion.frag
- A tests/baseline/data/custommaterial/custom_dispersion.qml
- A tests/baseline/data/custommaterial/custom_dispersion_notransmission.frag
- A tests/baseline/data/principled/dispersion.qml