mirror of
https://github.com/bevyengine/bevy
synced 2025-02-27 21:07:17 +00:00
Qualify module path of functions and bindings
This commit is contained in:
parent
c353b41bd6
commit
3e9f74d9e5
3 changed files with 26 additions and 26 deletions
|
@ -95,18 +95,18 @@ fn fragment(
|
|||
pbr_input.material.metallic = metallic;
|
||||
pbr_input.material.perceptual_roughness = perceptual_roughness;
|
||||
|
||||
var transmission: f32 = material.transmission;
|
||||
var transmission: f32 = pbr_bindings::material.transmission;
|
||||
#ifdef PBR_TRANSMISSION_TEXTURES_SUPPORTED
|
||||
if ((material.flags & STANDARD_MATERIAL_FLAGS_TRANSMISSION_TEXTURE_BIT) != 0u) {
|
||||
transmission *= textureSample(transmission_texture, transmission_sampler, uv).r;
|
||||
if ((pbr_bindings::material.flags & STANDARD_MATERIAL_FLAGS_TRANSMISSION_TEXTURE_BIT) != 0u) {
|
||||
transmission *= textureSample(pbr_bindings::transmission_texture, pbr_bindings::transmission_sampler, uv).r;
|
||||
}
|
||||
#endif
|
||||
pbr_input.material.transmission = transmission;
|
||||
|
||||
var thickness: f32 = material.thickness;
|
||||
var thickness: f32 = pbr_bindings::material.thickness;
|
||||
#ifdef PBR_TRANSMISSION_TEXTURES_SUPPORTED
|
||||
if ((material.flags & STANDARD_MATERIAL_FLAGS_THICKNESS_TEXTURE_BIT) != 0u) {
|
||||
thickness *= textureSample(thickness_texture, thickness_sampler, uv).g;
|
||||
if ((pbr_bindings::material.flags & STANDARD_MATERIAL_FLAGS_THICKNESS_TEXTURE_BIT) != 0u) {
|
||||
thickness *= textureSample(pbr_bindings::thickness_texture, pbr_bindings::thickness_sampler, uv).g;
|
||||
}
|
||||
#endif
|
||||
thickness *= (length(mesh.model[0].xyz) + length(mesh.model[1].xyz) + length(mesh.model[2].xyz)) / 3.0;
|
||||
|
@ -114,8 +114,8 @@ fn fragment(
|
|||
|
||||
var diffuse_transmission = material.diffuse_transmission;
|
||||
#ifdef PBR_TRANSMISSION_TEXTURES_SUPPORTED
|
||||
if ((material.flags & STANDARD_MATERIAL_FLAGS_DIFFUSE_TRANSMISSION_TEXTURE_BIT) != 0u) {
|
||||
diffuse_transmission *= textureSample(diffuse_transmission_texture, diffuse_transmission_sampler, uv).a;
|
||||
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;
|
||||
}
|
||||
#endif
|
||||
pbr_input.material.diffuse_transmission = diffuse_transmission;
|
||||
|
|
|
@ -254,10 +254,10 @@ 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 & POINT_LIGHT_FLAGS_SHADOWS_ENABLED_BIT) != 0u) {
|
||||
transmitted_shadow = fetch_point_shadow(light_id, diffuse_transmissive_lobe_world_position, -in.world_normal);
|
||||
&& (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 = 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);
|
||||
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);
|
||||
transmitted_light += light_contrib * transmitted_shadow;
|
||||
}
|
||||
}
|
||||
|
@ -286,10 +286,10 @@ 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 & POINT_LIGHT_FLAGS_SHADOWS_ENABLED_BIT) != 0u) {
|
||||
transmitted_shadow = fetch_spot_shadow(light_id, diffuse_transmissive_lobe_world_position, -in.world_normal);
|
||||
&& (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 = 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);
|
||||
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);
|
||||
transmitted_light += light_contrib * transmitted_shadow;
|
||||
}
|
||||
}
|
||||
|
@ -320,10 +320,10 @@ 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 & DIRECTIONAL_LIGHT_FLAGS_SHADOWS_ENABLED_BIT) != 0u) {
|
||||
transmitted_shadow = fetch_directional_shadow(i, diffuse_transmissive_lobe_world_position, -in.world_normal, view_z);
|
||||
&& (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 = 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);
|
||||
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);
|
||||
transmitted_light += light_contrib * transmitted_shadow;
|
||||
}
|
||||
}
|
||||
|
@ -340,7 +340,7 @@ fn pbr(
|
|||
// NdotV = 1.0;
|
||||
// F0 = vec3<f32>(0.0)
|
||||
// occlusion = vec3<f32>(1.0)
|
||||
transmitted_light += ambient_light(diffuse_transmissive_lobe_world_position, -in.N, -in.V, 1.0, diffuse_transmissive_color, vec3<f32>(0.0), 1.0, vec3<f32>(1.0));
|
||||
transmitted_light += ambient::ambient_light(diffuse_transmissive_lobe_world_position, -in.N, -in.V, 1.0, diffuse_transmissive_color, vec3<f32>(0.0), 1.0, vec3<f32>(1.0));
|
||||
}
|
||||
|
||||
// Environment map light (indirect)
|
||||
|
@ -368,7 +368,7 @@ fn pbr(
|
|||
refract(in.V, -in.N, 1.0 / ior) * thickness // add refracted vector scaled by thickness, towards exit point
|
||||
); // normalize to find exit point view vector
|
||||
|
||||
let transmitted_environment_light = environment_map_light(perceptual_roughness, roughness, diffuse_transmissive_color, 1.0, vec2<f32>(0.1), -in.N, T, vec3<f32>(0.16));
|
||||
let transmitted_environment_light = bevy_pbr::environment_map::environment_map_light(perceptual_roughness, roughness, diffuse_transmissive_color, 1.0, vec2<f32>(0.1), -in.N, T, vec3<f32>(0.16));
|
||||
transmitted_light += transmitted_environment_light.diffuse;
|
||||
transmitted_environment_light_specular = transmitted_environment_light.specular;
|
||||
}
|
||||
|
@ -381,7 +381,7 @@ fn pbr(
|
|||
let emissive_light = emissive.rgb * output_color.a;
|
||||
|
||||
if transmission > 0.0 {
|
||||
transmitted_light += 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 += 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;
|
||||
}
|
||||
|
||||
if in.material.attenuation_distance < (1.0 / 0.0) /* f32::INFINITY */ {
|
||||
|
@ -393,7 +393,7 @@ fn pbr(
|
|||
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 = atmospheric_fog(
|
||||
transmitted_light = fog::atmospheric_fog(
|
||||
attenuation_fog, vec4<f32>(transmitted_light, 1.0), thickness,
|
||||
vec3<f32>(0.0) // TODO: Pass in (pre-attenuated) scatterd light contribution here
|
||||
).rgb;
|
||||
|
|
|
@ -287,7 +287,7 @@ fn directional_light(light_id: u32, roughness: f32, NdotV: f32, normal: vec3<f32
|
|||
|
||||
fn transmissive_light(world_position: vec4<f32>, frag_coord: vec3<f32>, N: vec3<f32>, V: vec3<f32>, ior: f32, thickness: f32, perceptual_roughness: f32, transmissive_color: vec3<f32>, transmitted_environment_light_specular: vec3<f32>) -> vec3<f32> {
|
||||
// Calculate distance, used to scale roughness transmission blur
|
||||
let distance = length(view.world_position - world_position.xyz);
|
||||
let distance = length(view_bindings::view.world_position - world_position.xyz);
|
||||
|
||||
// Calculate the ratio between refaction indexes. Assume air/vacuum for the space outside the mesh
|
||||
let eta = 1.0 / ior;
|
||||
|
@ -304,7 +304,7 @@ fn transmissive_light(world_position: vec4<f32>, frag_coord: vec3<f32>, N: vec3<
|
|||
let exit_position = world_position.xyz + T * thickness;
|
||||
|
||||
// Transform exit_position into clip space
|
||||
let clip_exit_position = view.view_proj * vec4<f32>(exit_position, 1.0);
|
||||
let clip_exit_position = view_bindings::view.view_proj * vec4<f32>(exit_position, 1.0);
|
||||
|
||||
// Scale / offset position so that coordinate is in right space for sampling transmissive background texture
|
||||
let offset_position = (clip_exit_position.xy / clip_exit_position.w) * vec2<f32>(0.5, -0.5) + 0.5;
|
||||
|
@ -408,15 +408,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 (prepass_depth(vec4<f32>(modified_offset_position * view.viewport.zw, 0.0, 0.0), 0u) > frag_coord.z) {
|
||||
if (bevy_pbr::prepass_utils::prepass_depth(vec4<f32>(modified_offset_position * 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(
|
||||
view_transmission_texture,
|
||||
view_transmission_sampler,
|
||||
bevy_pbr::mesh_view_bindings::view_transmission_texture,
|
||||
bevy_pbr::mesh_view_bindings::view_transmission_sampler,
|
||||
modified_offset_position,
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue