Adjust specular_multiscatter to not take LightingInput (#20068)

Small refactor for a future bevy_solari PR.

Suggest reviewing while hiding the whitespace diff.
This commit is contained in:
JMS55 2025-07-10 21:54:53 -07:00 committed by GitHub
parent 6792cebfd0
commit 0d6c591491
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -235,16 +235,13 @@ fn fresnel(f0: vec3<f32>, LdotH: f32) -> vec3<f32> {
// Multiscattering approximation:
// <https://google.github.io/filament/Filament.html#listing_energycompensationimpl>
fn specular_multiscatter(
input: ptr<function, LightingInput>,
D: f32,
V: f32,
F: vec3<f32>,
F0: vec3<f32>,
F_ab: vec2<f32>,
specular_intensity: f32,
) -> vec3<f32> {
// Unpack.
let F0 = (*input).F0_;
let F_ab = (*input).F_ab;
var Fr = (specular_intensity * D * V) * F;
Fr *= 1.0 + F0 * (1.0 / F_ab.x - 1.0);
return Fr;
@ -329,7 +326,7 @@ fn specular(
let F = fresnel(F0, LdotH);
// Calculate the specular light.
let Fr = specular_multiscatter(input, D, V, F, specular_intensity);
let Fr = specular_multiscatter(D, V, F, F0, (*input).F_ab, specular_intensity);
return Fr;
}
@ -397,7 +394,7 @@ fn specular_anisotropy(
let Fa = fresnel(F0, LdotH);
// Calculate the specular light.
let Fr = specular_multiscatter(input, Da, Va, Fa, specular_intensity);
let Fr = specular_multiscatter(Da, Va, Fa, F0, (*input).F_ab, specular_intensity);
return Fr;
}