bevy/crates/bevy_pbr/src
Patrick Walton df8ccb8735
Implement PBR anisotropy per KHR_materials_anisotropy. (#13450)
This commit implements support for physically-based anisotropy in Bevy's
`StandardMaterial`, following the specification for the
[`KHR_materials_anisotropy`] glTF extension.

[*Anisotropy*] (not to be confused with [anisotropic filtering]) is a
PBR feature that allows roughness to vary along the tangent and
bitangent directions of a mesh. In effect, this causes the specular
light to stretch out into lines instead of a round lobe. This is useful
for modeling brushed metal, hair, and similar surfaces. Support for
anisotropy is a common feature in major game and graphics engines;
Unity, Unreal, Godot, three.js, and Blender all support it to varying
degrees.

Two new parameters have been added to `StandardMaterial`:
`anisotropy_strength` and `anisotropy_rotation`. Anisotropy strength,
which ranges from 0 to 1, represents how much the roughness differs
between the tangent and the bitangent of the mesh. In effect, it
controls how stretched the specular highlight is. Anisotropy rotation
allows the roughness direction to differ from the tangent of the model.

In addition to these two fixed parameters, an *anisotropy texture* can
be supplied. Such a texture should be a 3-channel RGB texture, where the
red and green values specify a direction vector using the same
conventions as a normal map ([0, 1] color values map to [-1, 1] vector
values), and the the blue value represents the strength. This matches
the format that the [`KHR_materials_anisotropy`] specification requires.
Such textures should be loaded as linear and not sRGB. Note that this
texture does consume one additional texture binding in the standard
material shader.

The glTF loader has been updated to properly parse the
`KHR_materials_anisotropy` extension.

A new example, `anisotropy`, has been added. This example loads and
displays the barn lamp example from the [`glTF-Sample-Assets`]
repository. Note that the textures were rather large, so I shrunk them
down and converted them to a mixture of JPEG and KTX2 format, in the
interests of saving space in the Bevy repository.

[*Anisotropy*]:
https://google.github.io/filament/Filament.md.html#materialsystem/anisotropicmodel

[anisotropic filtering]:
https://en.wikipedia.org/wiki/Anisotropic_filtering

[`KHR_materials_anisotropy`]:
https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_anisotropy/README.md

[`glTF-Sample-Assets`]:
https://github.com/KhronosGroup/glTF-Sample-Assets/

## Changelog

### Added

* Physically-based anisotropy is now available for materials, which
enhances the look of surfaces such as brushed metal or hair. glTF scenes
can use the new feature with the `KHR_materials_anisotropy` extension.

## Screenshots

With anisotropy:
![Screenshot 2024-05-20
233414](https://github.com/bevyengine/bevy/assets/157897/379f1e42-24e9-40b6-a430-f7d1479d0335)

Without anisotropy:
![Screenshot 2024-05-20
233420](https://github.com/bevyengine/bevy/assets/157897/aa220f05-b8e7-417c-9671-b242d4bf9fc4)
2024-06-03 23:46:06 +00:00
..
cluster Normalise matrix naming (#13489) 2024-06-03 16:56:53 +00:00
deferred Normalise matrix naming (#13489) 2024-06-03 16:56:53 +00:00
light Normalise matrix naming (#13489) 2024-06-03 16:56:53 +00:00
light_probe Normalise matrix naming (#13489) 2024-06-03 16:56:53 +00:00
lightmap Generate MeshUniforms on the GPU via compute shader where available. (#12773) 2024-04-10 05:33:32 +00:00
meshlet Normalise matrix naming (#13489) 2024-06-03 16:56:53 +00:00
prepass Normalise matrix naming (#13489) 2024-06-03 16:56:53 +00:00
render Implement PBR anisotropy per KHR_materials_anisotropy. (#13450) 2024-06-03 23:46:06 +00:00
ssao Normalise matrix naming (#13489) 2024-06-03 16:56:53 +00:00
ssr Implement opt-in sharp screen-space reflections for the deferred renderer, with improved raymarching code. (#13418) 2024-05-27 13:43:40 +00:00
volumetric_fog Add some missing reflect for volumetric fog types (#13592) 2024-05-31 10:20:15 +00:00
bundle.rs Implement clone for most bundles. (#12993) 2024-04-16 16:37:09 +00:00
extended_material.rs Add missing Default impl to ExtendedMaterial. (#13008) 2024-04-18 12:57:14 +00:00
fog.rs Migrate from LegacyColor to bevy_color::Color (#12163) 2024-02-29 19:35:12 +00:00
lib.rs Move clustering-related types and functions into their own module. (#13640) 2024-06-03 15:05:48 +00:00
material.rs Implement motion vectors and TAA for skinned meshes and meshes with morph targets. (#13572) 2024-05-31 17:02:28 +00:00
parallax.rs bevy_reflect: FromReflect Ergonomics Implementation (#6056) 2023-06-29 01:31:34 +00:00
pbr_material.rs Implement PBR anisotropy per KHR_materials_anisotropy. (#13450) 2024-06-03 23:46:06 +00:00
wireframe.rs Use WireframeColor to override global color (#13034) 2024-04-20 13:59:12 +00:00