Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions crates/bevy_gltf/src/loader/gltf_ext/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ pub(crate) fn get_linear_textures(document: &Document) -> HashSet<usize> {
{
linear_textures.insert(texture_index);
}
#[cfg(feature = "pbr_transmission_textures")]
if let Some(texture) = material
.volume()
.and_then(|volume| volume.thickness_texture())
{
linear_textures.insert(texture.texture().index());
}

// None of the clearcoat maps should be loaded as sRGB.
#[cfg(feature = "pbr_multi_layer_material_textures")]
Expand Down
21 changes: 8 additions & 13 deletions crates/bevy_pbr/src/render/pbr_functions.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -851,19 +851,14 @@ fn apply_pbr_lighting(
#ifdef STANDARD_MATERIAL_SPECULAR_TRANSMISSION
transmitted_light += transmission::specular_transmissive_light(in.world_position, in.frag_coord.xyz, view_z, in.N, in.V, F0, ior, thickness, perceptual_roughness, specular_transmissive_color, specular_transmitted_environment_light).rgb;

if (in.material.flags & pbr_types::STANDARD_MATERIAL_FLAGS_ATTENUATION_ENABLED_BIT) != 0u {
// We reuse the `atmospheric_fog()` function here, as it's fundamentally
// equivalent to the attenuation that takes place inside the material volume,
// and will allow us to eventually hook up subsurface scattering more easily
var attenuation_fog: mesh_view_types::Fog;
attenuation_fog.base_color.a = 1.0;
attenuation_fog.be = pow(1.0 - in.material.attenuation_color.rgb, vec3<f32>(E)) / in.material.attenuation_distance;
// TODO: Add the subsurface scattering factor below
// attenuation_fog.bi = /* ... */
transmitted_light = bevy_pbr::fog::atmospheric_fog(
attenuation_fog, vec4<f32>(transmitted_light, 1.0), thickness,
vec3<f32>(0.0) // TODO: Pass in (pre-attenuated) scattered light contribution here
).rgb;
if (in.material.flags & pbr_types::STANDARD_MATERIAL_FLAGS_ATTENUATION_ENABLED_BIT) != 0u
&& in.material.attenuation_distance != 0.0 {
// Compute light attenuation using Beer's law.
let transmittance = pow(
in.material.attenuation_color.rgb,
vec3<f32>(thickness / in.material.attenuation_distance),
);
transmitted_light *= transmittance;
}
#endif

Expand Down
Loading