lygia
/lighting
/common
/henyeyGreenstein
)Dependencies:
// Henyey-Greenstein phase function factor [-1, 1]
// represents the average cosine of the scattered directions
// 0 is isotropic scattering
// > 1 is forward scattering, < 1 is backwards
#ifndef HENYEYGREENSTEIN_SCATTERING
#define HENYEYGREENSTEIN_SCATTERING 0.76
#endif
#ifndef FNC_HENYEYGREENSTEIN
#define FNC_HENYEYGREENSTEIN
float henyeyGreenstein(const in float mu) {
return max(0.0, (1.0 - HENYEYGREENSTEIN_SCATTERING*HENYEYGREENSTEIN_SCATTERING) / ((4. + PI) * pow(1.0 + HENYEYGREENSTEIN_SCATTERING*HENYEYGREENSTEIN_SCATTERING - 2.0 * HENYEYGREENSTEIN_SCATTERING * mu, 1.5)));
}
float henyeyGreenstein(float mu, float g) {
float gg = g * g;
return (1.0 / (4.0 * PI)) * ((1.0 - gg) / pow(1.0 + gg - 2.0 * g * mu, 1.5));
}
float henyeyGreenstein(float mu, float g, float dual_lobe_weight) {
return mix(henyeyGreenstein( mu, -g), henyeyGreenstein(mu, g), dual_lobe_weight);
}
#endif
Dependencies:
// Henyey-Greenstein phase function factor [-1, 1]
// represents the average cosine of the scattered directions
// 0 is isotropic scattering
// > 1 is forward scattering, < 1 is backwards
#ifndef HENYEYGREENSTEIN_SCATTERING
#define HENYEYGREENSTEIN_SCATTERING 0.76
#endif
#ifndef FNC_HENYEYGREENSTEIN
#define FNC_HENYEYGREENSTEIN
float henyeyGreenstein(float mu) {
return max(0.0, (1.0 - HENYEYGREENSTEIN_SCATTERING*HENYEYGREENSTEIN_SCATTERING) / ((4. + PI) * pow(1.0 + HENYEYGREENSTEIN_SCATTERING*HENYEYGREENSTEIN_SCATTERING - 2.0 * HENYEYGREENSTEIN_SCATTERING * mu, 1.5)));
}
float henyeyGreenstein(float mu, float g) {
float gg = g * g;
return (1.0 / (4.0 * PI)) * ((1.0 - gg) / pow(1.0 + gg - 2.0 * g * mu, 1.5));
}
float henyeyGreenstein(float mu, float g, float dual_lobe_weight) {
return lerp(henyeyGreenstein( mu, -g), henyeyGreenstein(mu, g), dual_lobe_weight);
}
#endif
LYGIA is dual-licensed under the Prosperity License and the Patron License for sponsors and contributors.
Sponsors and contributors are automatically added to the Patron License and they can ignore the any non-commercial rule of the Prosperity Licensed software (please take a look to the exception).
It's also possible to get a permanent comercial license hook to a single and specific version of LYGIA.
Sign up for the news letter bellow, joing the LYGIA's channel on Discord or follow the Github repository