Search across packages, versions, files, declarations, and comments. Use multiple terms to narrow results (AND), and add @vertex, @fragment, or @compute to filter by shader stage.
1#define_import_path bevy_pbr::ssao_utils
3#import bevy_render::maths::{PI, HALF_PI}
5// Approximates single-bounce ambient occlusion to multi-bounce ambient occlusion
6// https://blog.selfshadow.com/publications/s2016-shading-course/activision/s2016_pbs_activision_occlusion.pdf#page=78
7fn ssao_multibounce(visibility: f32, base_color: vec3<f32>) -> vec3<f32> {
8 let a = 2.0404 * base_color - 0.3324;
9 let b = -4.7951 * base_color + 0.6417;
10 let c = 2.7552 * base_color + 0.6903;
11 let x = vec3<f32>(visibility);
12 return max(x, ((x * a + b) * x + c) * x);
15fn fast_sqrt(x: f32) -> f32 {
16 return bitcast<f32>(0x1fbd1df5 + (bitcast<i32>(x) >> 1u));
19fn fast_acos(in_x: f32) -> f32 {
20 let x = abs(in_x);
21 var res = -0.156583 * x + HALF_PI;
22 res *= fast_sqrt(1.0 - x);
23 return select(PI - res, res, in_x >= 0.0);
Contents