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

Method sample_metallic_roughness

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

Sample metallic-roughness texture. The glTF convention packs occlusion in R, roughness in G, metallic in B; values are LINEAR (no sRGB decode). When no texture is present, falls back to the material's scalar factors alone.

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

Source from the content-addressed store, hash-verified

243 /// LINEAR (no sRGB decode). When no texture is present, falls back
244 /// to the material's scalar factors alone.
245 fn sample_metallic_roughness(&self, material: &Material, uv: Vec2) -> (f32, f32) {
246 let (metallic_factor, roughness_factor) = (material.metallic, material.roughness);
247 let tex_idx = match material.metallic_roughness_texture {
248 Some(i) => i as usize,
249 None => return (metallic_factor, roughness_factor),
250 };
251 let (r, g, b) = match self.sample_texture_linear(tex_idx, uv) {
252 Some(c) => c,
253 None => return (metallic_factor, roughness_factor),
254 };
255 let _ = r; // occlusion — ignored here, sampled separately if needed
256 let roughness = g * roughness_factor;
257 let metallic = b * metallic_factor;
258 (metallic, roughness)
259 }
260
261 /// Sample emissive texture × factor. Emissive textures are sRGB-
262 /// encoded per the glTF spec.

Callers 1

surface_from_hitFunction · 0.80

Calls 1

sample_texture_linearMethod · 0.80

Tested by

no test coverage detected