MCPcopy Create free account
hub / github.com/Bloom-Engine/engine / sample_occlusion

Method sample_occlusion

tools/bloom-reference/src/main.rs:310–321  ·  view source on GitHub ↗

Sample occlusion in [0,1]. glTF packs occlusion in R of the occlusion texture; strength blends between "no AO" (0) and "full AO" (1). Returns 1.0 (no attenuation) when absent.

(&self, material: &Material, uv: Vec2)

Source from the content-addressed store, hash-verified

308 /// occlusion texture; strength blends between "no AO" (0) and
309 /// "full AO" (1). Returns 1.0 (no attenuation) when absent.
310 fn sample_occlusion(&self, material: &Material, uv: Vec2) -> f32 {
311 let tex_idx = match material.occlusion_texture {
312 Some(i) => i as usize,
313 None => return 1.0,
314 };
315 let (r, _g, _b) = match self.sample_texture_linear(tex_idx, uv) {
316 Some(c) => c,
317 None => return 1.0,
318 };
319 // mix(1.0, r, strength)
320 1.0 + (r - 1.0) * material.occlusion_strength
321 }
322
323 /// Sample a tangent-space normal from the normal texture, in
324 /// [-1,1]³. Returns (0,0,1) (i.e. "no perturbation") when the

Callers 1

surface_from_hitFunction · 0.80

Calls 1

sample_texture_linearMethod · 0.80

Tested by

no test coverage detected