Skip to content
Merged
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
8 changes: 4 additions & 4 deletions crates/bevy_solari/src/pathtracer/pathtracer.wgsl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
enable wgpu_ray_query;

#import bevy_core_pipeline::tonemapping::tonemapping_luminance as luminance
#import bevy_pbr::pbr_functions::{calculate_tbn_mikktspace, calculate_F0}
#import bevy_pbr::pbr_functions::calculate_F0
#import bevy_pbr::utils::{rand_f, rand_vec2f}
#import bevy_render::maths::PI
#import bevy_render::maths::{PI, orthonormalize}
#import bevy_render::view::View
#import bevy_solari::brdf::{evaluate_brdf, evaluate_and_sample_brdf, fresnel}
#import bevy_solari::sampling::{sample_random_light, random_emissive_light_pdf, ggx_vndf_pdf, power_heuristic}
Expand Down Expand Up @@ -71,7 +71,7 @@ fn pathtrace(@builtin(global_invocation_id) global_id: vec3<u32>) {
}

// Sample new ray direction from the material BRDF for next bounce and apply BRDF
let next_bounce = evaluate_and_sample_brdf(wo, ray_hit.world_normal, ray_hit.world_tangent, ray_hit.material, &rng);
let next_bounce = evaluate_and_sample_brdf(wo, ray_hit.world_normal, ray_hit.material, &rng);
if next_bounce.pdf == 0.0 { break; }
ray_direction = next_bounce.wi;
ray_origin = ray_hit.world_position + (ray_hit.geometric_world_normal * RAY_T_MIN);
Expand Down Expand Up @@ -103,7 +103,7 @@ fn brdf_pdf(wo: vec3<f32>, wi: vec3<f32>, ray_hit: ResolvedRayHitFull) -> f32 {
let diffuse_weight = mix(df, 0.0, ray_hit.material.metallic);
let specular_weight = 1.0 - diffuse_weight;

let TBN = calculate_tbn_mikktspace(ray_hit.world_normal, ray_hit.world_tangent);
let TBN = orthonormalize(ray_hit.world_normal);
let T = TBN[0];
let B = TBN[1];
let N = TBN[2];
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_solari/src/realtime/specular_gi.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ enable wgpu_ray_query;
#define_import_path bevy_solari::specular_gi

#import bevy_core_pipeline::tonemapping::tonemapping_luminance as luminance
#import bevy_pbr::pbr_functions::{calculate_tbn_mikktspace, calculate_diffuse_color, calculate_F0}
#import bevy_pbr::pbr_functions::{calculate_diffuse_color, calculate_F0}
#import bevy_pbr::utils::rand_f
#import bevy_render::maths::{orthonormalize, PI}
#import bevy_render::view::View
Expand Down Expand Up @@ -100,7 +100,7 @@ fn trace_glossy_path(pixel_id: vec2<u32>, primary_surface: ResolvedGPixel, initi
if ray.kind == RAY_QUERY_INTERSECTION_NONE { break; }
let ray_hit = resolve_ray_hit_full(ray);

let TBN = calculate_tbn_mikktspace(ray_hit.world_normal, ray_hit.world_tangent);
let TBN = orthonormalize(ray_hit.world_normal);
let T = TBN[0];
let B = TBN[1];
let N = TBN[2];
Expand Down
7 changes: 3 additions & 4 deletions crates/bevy_solari/src/scene/brdf.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ enable wgpu_ray_query;

#import bevy_core_pipeline::tonemapping::tonemapping_luminance as luminance
#import bevy_pbr::lighting::{D_GGX, V_SmithGGXCorrelated, specular_multiscatter}
#import bevy_pbr::pbr_functions::{calculate_tbn_mikktspace, calculate_diffuse_color, calculate_F0}
#import bevy_pbr::pbr_functions::{calculate_diffuse_color, calculate_F0}
#import bevy_pbr::utils::{rand_f, sample_cosine_hemisphere}
#import bevy_render::maths::PI
#import bevy_render::maths::{PI, orthonormalize}
#import bevy_solari::sampling::{sample_ggx_vndf, ggx_vndf_pdf, ggx_vndf_sample_invalid}
#import bevy_solari::scene_bindings::{ResolvedMaterial, MIRROR_ROUGHNESS_THRESHOLD, brdf_dfg_lut, brdf_dfg_lut_sampler}

Expand All @@ -19,7 +19,6 @@ struct EvaluateAndSampleBrdfResult {
fn evaluate_and_sample_brdf(
wo: vec3<f32>,
world_normal: vec3<f32>,
world_tangent: vec4<f32>,
material: ResolvedMaterial,
rng: ptr<function, u32>,
) -> EvaluateAndSampleBrdfResult {
Expand All @@ -31,7 +30,7 @@ fn evaluate_and_sample_brdf(
let diffuse_weight = mix(df, 0.0, material.metallic);
let specular_weight = 1.0 - diffuse_weight;

let TBN = calculate_tbn_mikktspace(world_normal, world_tangent);
let TBN = orthonormalize(world_normal);
let T = TBN[0];
let B = TBN[1];
let N = TBN[2];
Expand Down