Unify envmap textures and deprecate sphericalEnvMap #5454
Merged
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.
Description:
Follow-up of #5453, also preparation work for #5449. In A-Frame environment maps were handled separately in both the
standardandphongshader. Besides the code-duplication this also meant that there was no texture re-use between them or other textures.This PR moves the envMap logic into
utils/materialandsystems/materialin a similar vein to other textures. The eventual texture loads now also go through the texture cache. The possible values forenvMaphas been broadened to support both cubemaps and equirectangular maps. The latter allows a fallback for the currently incorrect behaviour ofsphericalEnvMap. There is one small breaking change, theenvMapvalue now behaves closer toassetproperty types, meaning it now only supports ID based selectors and would otherwise assume a URL in case it's unwrapped (e.g. breakingenvMap="#someElement > a-cubemap.active").Changes proposed:
envMapto a common implementation inutils/materialandsystems/materialmaking use of existing texture loading and caching.envMapto support both cubemap (six images/<a-cubemap>) as well as Equirectangular images.sphericalEnvMapas Three.js dropped support for them long ago and A-Frame incorrectly uses them as Equirectangular images. Fallback is in place, logging a warning, but otherwise ensuring those expecting the equirectangular behaviour won't notice a regression.utils/src-loaderandshaders/phong