Sample emissive texture × factor. Emissive textures are sRGB- encoded per the glTF spec.
(&self, material: &Material, uv: Vec2)
| 261 | /// Sample emissive texture × factor. Emissive textures are sRGB- |
| 262 | /// encoded per the glTF spec. |
| 263 | fn sample_emissive(&self, material: &Material, uv: Vec2) -> Vec3 { |
| 264 | let factor = Vec3::from(material.emissive_factor); |
| 265 | let tex_idx = match material.emissive_texture { |
| 266 | Some(i) => i as usize, |
| 267 | None => { |
| 268 | // No texture: just the factor. But factor=[1,1,1] |
| 269 | // without a texture is a common glTF default meaning |
| 270 | // "use the texture if present, otherwise no emission". |
| 271 | // Treat as non-emissive when there's no texture. |
| 272 | return Vec3::ZERO; |
| 273 | } |
| 274 | }; |
| 275 | match self.sample_texture_srgb(tex_idx, uv) { |
| 276 | Some(c) => Vec3::new(c.0, c.1, c.2) * factor, |
| 277 | None => Vec3::ZERO, |
| 278 | } |
| 279 | } |
| 280 | |
| 281 | /// Bilinear sRGB-decoded texture sample at UV. |
| 282 | fn sample_texture_srgb(&self, tex_idx: usize, uv: Vec2) -> Option<(f32, f32, f32)> { |
no test coverage detected