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)
| 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 |
no test coverage detected