Add additional module path qualification

This commit is contained in:
Marco Buono 2023-07-18 00:11:57 -03:00
parent 592a6c921a
commit a48a3132c3
3 changed files with 15 additions and 13 deletions

View file

@ -112,7 +112,7 @@ fn fragment(
thickness *= (length(mesh.model[0].xyz) + length(mesh.model[1].xyz) + length(mesh.model[2].xyz)) / 3.0;
pbr_input.material.thickness = thickness;
var diffuse_transmission = material.diffuse_transmission;
var diffuse_transmission = pbr_bindings::material.diffuse_transmission;
#ifdef PBR_TRANSMISSION_TEXTURES_SUPPORTED
if ((pbr_bindings::material.flags & STANDARD_MATERIAL_FLAGS_DIFFUSE_TRANSMISSION_TEXTURE_BIT) != 0u) {
diffuse_transmission *= textureSample(pbr_bindings::diffuse_transmission_texture, pbr_bindings::diffuse_transmission_sampler, uv).a;

View file

@ -14,8 +14,9 @@
#import bevy_pbr::environment_map
#endif
#import bevy_pbr::utils E
#import bevy_pbr::mesh_bindings mesh
#import bevy_pbr::mesh_types MESH_FLAGS_SHADOW_RECEIVER_BIT
#import bevy_pbr::mesh_types MESH_FLAGS_SHADOW_RECEIVER_BIT, MESH_FLAGS_TRANSMITTED_SHADOW_RECEIVER_BIT
fn alpha_discard(material: pbr_types::StandardMaterial, output_color: vec4<f32>) -> vec4<f32> {
var color = output_color;
@ -254,7 +255,7 @@ fn pbr(
// F0 = vec3<f32>(0.0)
var transmitted_shadow: f32 = 1.0;
if ((in.flags & (MESH_FLAGS_SHADOW_RECEIVER_BIT | MESH_FLAGS_TRANSMITTED_SHADOW_RECEIVER_BIT)) == (MESH_FLAGS_SHADOW_RECEIVER_BIT | MESH_FLAGS_TRANSMITTED_SHADOW_RECEIVER_BIT)
&& (point_lights.data[light_id].flags & mesh_view_types::POINT_LIGHT_FLAGS_SHADOWS_ENABLED_BIT) != 0u) {
&& (view_bindings::point_lights.data[light_id].flags & mesh_view_types::POINT_LIGHT_FLAGS_SHADOWS_ENABLED_BIT) != 0u) {
transmitted_shadow = shadows::fetch_point_shadow(light_id, diffuse_transmissive_lobe_world_position, -in.world_normal);
}
let light_contrib = lighting::point_light(diffuse_transmissive_lobe_world_position.xyz, light_id, 1.0, 1.0, -in.N, -in.V, vec3<f32>(0.0), vec3<f32>(0.0), vec2<f32>(0.1), diffuse_transmissive_color);
@ -286,7 +287,7 @@ fn pbr(
// F0 = vec3<f32>(0.0)
var transmitted_shadow: f32 = 1.0;
if ((in.flags & (MESH_FLAGS_SHADOW_RECEIVER_BIT | MESH_FLAGS_TRANSMITTED_SHADOW_RECEIVER_BIT)) == (MESH_FLAGS_SHADOW_RECEIVER_BIT | MESH_FLAGS_TRANSMITTED_SHADOW_RECEIVER_BIT)
&& (point_lights.data[light_id].flags & mesh_view_types::POINT_LIGHT_FLAGS_SHADOWS_ENABLED_BIT) != 0u) {
&& (view_bindings::point_lights.data[light_id].flags & mesh_view_types::POINT_LIGHT_FLAGS_SHADOWS_ENABLED_BIT) != 0u) {
transmitted_shadow = shadows::fetch_spot_shadow(light_id, diffuse_transmissive_lobe_world_position, -in.world_normal);
}
let light_contrib = lighting::spot_light(diffuse_transmissive_lobe_world_position.xyz, light_id, 1.0, 1.0, -in.N, -in.V, vec3<f32>(0.0), vec3<f32>(0.0), vec2<f32>(0.1), diffuse_transmissive_color);
@ -320,7 +321,7 @@ fn pbr(
// F0 = vec3<f32>(0.0)
var transmitted_shadow: f32 = 1.0;
if ((in.flags & (MESH_FLAGS_SHADOW_RECEIVER_BIT | MESH_FLAGS_TRANSMITTED_SHADOW_RECEIVER_BIT)) == (MESH_FLAGS_SHADOW_RECEIVER_BIT | MESH_FLAGS_TRANSMITTED_SHADOW_RECEIVER_BIT)
&& (lights.directional_lights[i].flags & mesh_view_types::DIRECTIONAL_LIGHT_FLAGS_SHADOWS_ENABLED_BIT) != 0u) {
&& (view_bindings::lights.directional_lights[i].flags & mesh_view_types::DIRECTIONAL_LIGHT_FLAGS_SHADOWS_ENABLED_BIT) != 0u) {
transmitted_shadow = shadows::fetch_directional_shadow(i, diffuse_transmissive_lobe_world_position, -in.world_normal, view_z);
}
let light_contrib = lighting::directional_light(i, 1.0, 1.0, -in.N, -in.V, vec3<f32>(0.0), vec3<f32>(0.0), vec2<f32>(0.1), diffuse_transmissive_color);
@ -381,14 +382,14 @@ fn pbr(
let emissive_light = emissive.rgb * output_color.a;
if transmission > 0.0 {
transmitted_light += bevy_pbr::lighting::transmissive_light(in.world_position, in.frag_coord.xyz, in.N, in.V, ior, thickness, perceptual_roughness, transmissive_color, transmitted_environment_light_specular).rgb;
transmitted_light += lighting::transmissive_light(in.world_position, in.frag_coord.xyz, in.N, in.V, ior, thickness, perceptual_roughness, transmissive_color, transmitted_environment_light_specular).rgb;
}
if in.material.attenuation_distance < (1.0 / 0.0) /* f32::INFINITY */ {
// 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: Fog;
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

View file

@ -1,5 +1,6 @@
#define_import_path bevy_pbr::lighting
#import bevy_pbr::prepass_utils as prepass_utils
#import bevy_pbr::utils PI
#import bevy_pbr::mesh_view_types as view_types
#import bevy_pbr::mesh_view_bindings as view_bindings
@ -320,7 +321,7 @@ fn transmissive_light(world_position: vec4<f32>, frag_coord: vec3<f32>, N: vec3<
// https://blog.demofox.org/2022/01/01/interleaved-gradient-noise-a-different-kind-of-low-discrepancy-sequence
fn interleaved_gradient_noise(pixel_coordinates: vec2<f32>) -> f32 {
#ifdef TAA
let frame = f32(globals.frame_count % 64u);
let frame = f32(view_bindings::globals.frame_count % 64u);
let xy = pixel_coordinates + 5.588238 * frame;
#else
// Don't vary noise per frame if TAA is not enabled
@ -345,7 +346,7 @@ const MAX_TRANSMISSIVE_TAPS = 16;
fn fetch_transmissive_background(offset_position: vec2<f32>, frag_coord: vec3<f32>, perceptual_roughness: f32, distance: f32) -> vec4<f32> {
// Calculate view aspect ratio, used to scale offset so that it's proportionate
let aspect = view.viewport.z / view.viewport.w;
let aspect = view_bindings::view.viewport.z / view_bindings::view.viewport.w;
// Calculate how blurry the transmission should be.
// Blur is more or less eyeballed to look approximately right, since the correct
@ -365,7 +366,7 @@ fn fetch_transmissive_background(offset_position: vec2<f32>, frag_coord: vec3<f3
let random_angle = interleaved_gradient_noise(frag_coord.xy);
#ifdef TAA
// Alternating pixel mesh: 0 or 1 on even/odd pixels, alternates every frame
let pixel_mesh = (i32(frag_coord.x) + i32(frag_coord.y) + i32(globals.frame_count)) % 2;
let pixel_mesh = (i32(frag_coord.x) + i32(frag_coord.y) + i32(view_bindings::globals.frame_count)) % 2;
#else
// Alternating pixel mesh: 0 or 1 on even/odd pixels
let pixel_mesh = (i32(frag_coord.x) + i32(frag_coord.y)) % 2;
@ -408,15 +409,15 @@ fn fetch_transmissive_background(offset_position: vec2<f32>, frag_coord: vec3<f3
#ifdef PREPASS_DEPTH_SUPPORTED
// Use depth prepass data to reject values that are in front of the current fragment
if (bevy_pbr::prepass_utils::prepass_depth(vec4<f32>(modified_offset_position * view.viewport.zw, 0.0, 0.0), 0u) > frag_coord.z) {
if prepass_utils::prepass_depth(vec4<f32>(modified_offset_position * view_bindings::view.viewport.zw, 0.0, 0.0), 0u) > frag_coord.z {
continue;
}
#endif
// Sample the view transmission texture at the offset position + noise offset, to get the background color
let sample = textureSample(
bevy_pbr::mesh_view_bindings::view_transmission_texture,
bevy_pbr::mesh_view_bindings::view_transmission_sampler,
view_bindings::view_transmission_texture,
view_bindings::view_transmission_sampler,
modified_offset_position,
);