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

Method sample_emissive

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

Sample emissive texture × factor. Emissive textures are sRGB- encoded per the glTF spec.

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

Source from the content-addressed store, hash-verified

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)> {

Callers 1

surface_from_hitFunction · 0.80

Calls 1

sample_texture_srgbMethod · 0.80

Tested by

no test coverage detected