Open DGriffin91 opened 1 month ago
The faulty calculations are in https://github.com/bevyengine/bevy/blob/ee6dfd35c9fd44c1d1984319e1134f15b87abc7a/crates/bevy_pbr/src/render/pbr_lighting.wgsl#L194 It is based on this: http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf Page 14-16 It contains the following section: "Irradiance for a sphere light is equivalent to a point light if the sphere is above the horizon. Al- though counter-intuitive, this means we only need to address specular lighting if we accept inaccuracies when the sphere dips below the horizon." So, I assume it is a shortcoming of the algorithm and should be documented.
Bevy version Main dcb8a13b223fbc9425f7af01b3941dd80a229384, 0.13
This isn't a new issue. I checked and the same issue occurs in bevy 0.6.
When the radius of a point or spot light intersects with a mesh, it creates a sharp cutoff in the specular reflection. This sharp cutoff is also not aligned with the intersection between the mesh and the light radius.
Point light with radius of 3 at Y=2: (Example code below)![bevy](https://github.com/bevyengine/bevy/assets/33357138/ece4f083-84aa-46f8-87f0-bef8f7aeb8e9)
Sphere with same radius and location as point light![bevy_with_sphere](https://github.com/bevyengine/bevy/assets/33357138/538d105d-c8be-423d-99c4-c2a409319392)
The same scene in Blender (4.1 eevee):![blender](https://github.com/bevyengine/bevy/assets/33357138/ff28a5f3-27f3-4e98-9cee-d836a6c76aee)
With sphere:![blender_with_sphere](https://github.com/bevyengine/bevy/assets/33357138/f2330dbf-3325-481c-9c24-7e8b0ed236e7)
Blender also has a "Soft Falloff" setting that is enabled by default for point/spot lights:![blender_soft_falloff](https://github.com/bevyengine/bevy/assets/33357138/a033ee3b-7dd7-48d8-9efd-50d455b5c540)