Improve/fix comments based on PR feedback

This commit is contained in:
Marco Buono 2023-09-24 14:16:24 -03:00
parent 4c0b6a18b7
commit 12c2d43f7f
4 changed files with 8 additions and 7 deletions

View file

@ -238,7 +238,8 @@ shader_format_glsl = ["bevy_internal/shader_format_glsl"]
# Enable support for shaders in SPIR-V # Enable support for shaders in SPIR-V
shader_format_spirv = ["bevy_internal/shader_format_spirv"] shader_format_spirv = ["bevy_internal/shader_format_spirv"]
# Enable support for transmission-related textures in the `StandardMaterial`, at the risk of blowing past the texture limit in lower-end adapters # Enable support for transmission-related textures in the `StandardMaterial`, at the risk of blowing past
# the global, per-shader texture limit in lower-end GPUs (i.e. `MAX_TEXTURE_IMAGE_UNITS` in OpenGL/WebGL)
pbr_transmission_textures = ["bevy_internal/pbr_transmission_textures"] pbr_transmission_textures = ["bevy_internal/pbr_transmission_textures"]
# Enable some limitations to be able to use WebGL2. If not enabled, it will default to WebGPU in Wasm # Enable some limitations to be able to use WebGL2. If not enabled, it will default to WebGPU in Wasm

View file

@ -556,7 +556,7 @@ pub fn prepare_core_3d_transmission_textures(
.or_insert_with(|| { .or_insert_with(|| {
let usage = TextureUsages::TEXTURE_BINDING | TextureUsages::COPY_DST; let usage = TextureUsages::TEXTURE_BINDING | TextureUsages::COPY_DST;
// The size of the depth texture // The size of the transmission texture
let size = Extent3d { let size = Extent3d {
depth_or_array_layers: 1, depth_or_array_layers: 1,
width: physical_target_size.x, width: physical_target_size.x,

View file

@ -396,7 +396,7 @@ fn pbr(
// attenuation_fog.bi = /* ... */ // attenuation_fog.bi = /* ... */
transmitted_light = fog::atmospheric_fog( transmitted_light = fog::atmospheric_fog(
attenuation_fog, vec4<f32>(transmitted_light, 1.0), thickness, attenuation_fog, vec4<f32>(transmitted_light, 1.0), thickness,
vec3<f32>(0.0) // TODO: Pass in (pre-attenuated) scatterd light contribution here vec3<f32>(0.0) // TODO: Pass in (pre-attenuated) scattered light contribution here
).rgb; ).rgb;
} }

View file

@ -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> { 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 // Calculate distance from the camera, used to scale roughness transmission blur
let distance = length(view_bindings::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 // Calculate the ratio between refaction indexes. Assume air/vacuum for the space outside the mesh
@ -365,10 +365,10 @@ fn fetch_transmissive_background(offset_position: vec2<f32>, frag_coord: vec3<f3
let num_spirals = (num_taps >> 3u) + 1; let num_spirals = (num_taps >> 3u) + 1;
let random_angle = interleaved_gradient_noise(frag_coord.xy); let random_angle = interleaved_gradient_noise(frag_coord.xy);
#ifdef TEMPORAL_JITTER #ifdef TEMPORAL_JITTER
// Alternating pixel mesh: 0 or 1 on even/odd pixels, alternates every frame // Alternating pixel checkerboard pattern: 0 or 1 on even/odd pixels, alternates every frame
let pixel_mesh = (i32(frag_coord.x) + i32(frag_coord.y) + i32(view_bindings::globals.frame_count)) % 2; let pixel_mesh = (i32(frag_coord.x) + i32(frag_coord.y) + i32(view_bindings::globals.frame_count)) % 2;
#else #else
// Alternating pixel mesh: 0 or 1 on even/odd pixels // Alternating pixel checkerboard pattern: 0 or 1 on even/odd pixels
let pixel_mesh = (i32(frag_coord.x) + i32(frag_coord.y)) % 2; let pixel_mesh = (i32(frag_coord.x) + i32(frag_coord.y)) % 2;
#endif #endif
@ -404,7 +404,7 @@ fn fetch_transmissive_background(offset_position: vec2<f32>, frag_coord: vec3<f3
// Rotate and correct for aspect ratio // Rotate and correct for aspect ratio
let rotated_spiral_offset = (rotation_matrix * spiral_offset) * vec2(1.0, aspect); let rotated_spiral_offset = (rotation_matrix * spiral_offset) * vec2(1.0, aspect);
// Calucalte final offset position, with blur and spiral offset // Calculate final offset position, with blur and spiral offset
let modified_offset_position = offset_position + rotated_spiral_offset * blur_intensity * (1.0 - f32(pixel_mesh) * 0.1); let modified_offset_position = offset_position + rotated_spiral_offset * blur_intensity * (1.0 - f32(pixel_mesh) * 0.1);
#ifdef PREPASS_DEPTH_SUPPORTED #ifdef PREPASS_DEPTH_SUPPORTED