diff --git a/crates/bevy_tape_drive_solari/src/pathtracer/pathtracer.wesl b/crates/bevy_tape_drive_solari/src/pathtracer/pathtracer.wesl index 7cd4811..f9b9877 100644 --- a/crates/bevy_tape_drive_solari/src/pathtracer/pathtracer.wesl +++ b/crates/bevy_tape_drive_solari/src/pathtracer/pathtracer.wesl @@ -40,20 +40,19 @@ fn pathtrace(@builtin(global_invocation_id) global_id: vec3) { var p_bounce = 0.0; loop { let ray = trace_ray(ray_origin, ray_direction, ray_t_min, RAY_T_MAX, RAY_FLAG_NONE); - if ray.kind == RAY_QUERY_INTERSECTION_GENERATED { - textureStore(view_output, global_id.xy, vec4(f32(ray.instance_custom_data), f32(ray.primitive_index), ray.t, 1.0)); - return; - //if ray.t > 0.0 { - // radiance = vec3(100.0,0.0,0.0); - //} else if ray.t < 0.0 { - // radiance = vec3(0.0,100.0,0.0); - //} else if ray.t == 0.0 { - // radiance = vec3(0.0,0.0,100.0); - //} - //break; - } if ray.kind != RAY_QUERY_INTERSECTION_NONE { let ray_hit = resolve_ray_hit_full(ray, ray_origin, ray_direction); + //if ray.kind == RAY_QUERY_INTERSECTION_GENERATED { + // //textureStore(view_output, global_id.xy, vec4(ray_hit.world_position, ray_hit.triangle_area)); + // //textureStore(view_output, global_id.xy, vec4(ray_hit.previous_frame_world_position, f32(ray_hit.triangle_count))); + // textureStore(view_output, global_id.xy, vec4(ray_hit.world_normal, f32(ray_hit.double_sided))); + // //textureStore(view_output, global_id.xy, vec4(ray_hit.geometric_world_normal, ray_hit.material.reflectance)); + // //textureStore(view_output, global_id.xy, ray_hit.world_tangent); + // //textureStore(view_output, global_id.xy, vec4(ray_hit.uv, ray_hit.material.perceptual_roughness, ray_hit.material.roughness)); + // //textureStore(view_output, global_id.xy, vec4(ray_hit.material.base_color, ray_hit.material.metallic)); + // //textureStore(view_output, global_id.xy, vec4(ray_hit.material.emissive, f32(ray_hit.material.alpha_masked_out))); + // return; + //} let wo = -ray_direction; let NdotV = max(dot(ray_hit.world_normal, wo), 0.0001); let F_ab = F_AB(ray_hit.material.perceptual_roughness, NdotV); diff --git a/crates/bevy_tape_drive_solari/src/scene/bindings.wesl b/crates/bevy_tape_drive_solari/src/scene/bindings.wesl index 69fa910..845e840 100644 --- a/crates/bevy_tape_drive_solari/src/scene/bindings.wesl +++ b/crates/bevy_tape_drive_solari/src/scene/bindings.wesl @@ -443,8 +443,8 @@ fn resolve_tape_data_full(instance_id: u32, position: vec3) -> ResolvedRayH world_normal = normalize(Nt.x * T + Nt.y * B + Nt.z * N); } - let triangle_area: f32 = 0.0; // ??? - let triangle_count: u32 = 0; // ??? + let triangle_area: f32 = 0.1; // ??? + let triangle_count: u32 = 100; // ??? let resolved_material = resolve_material(material, uv); diff --git a/crates/bevy_tape_drive_solari/src/scene/tapes/blas.rs b/crates/bevy_tape_drive_solari/src/scene/tapes/blas.rs index 979002e..45174b5 100644 --- a/crates/bevy_tape_drive_solari/src/scene/tapes/blas.rs +++ b/crates/bevy_tape_drive_solari/src/scene/tapes/blas.rs @@ -305,7 +305,7 @@ pub fn compile_raytracing_blas( compute_pass.set_pipeline(pipeline); compute_pass.set_bind_group(0, &bind_group, &[]); compute_pass.set_immediates(0, bytemuck::bytes_of(&pc)); - compute_pass.dispatch_workgroups(1, 1, 1); + compute_pass.dispatch_workgroups(4, 4, 4); updated_blases.push(key.tape); diff --git a/crates/bevy_tape_load/src/render/allocator.rs b/crates/bevy_tape_load/src/render/allocator.rs index a1c19f3..35bba8c 100644 --- a/crates/bevy_tape_load/src/render/allocator.rs +++ b/crates/bevy_tape_load/src/render/allocator.rs @@ -385,9 +385,9 @@ impl TapeAllocator { sample_count: 1, view_formats: &[TextureFormat::R32Float], size: Extent3d { - width: tape.subdivision, - height: tape.subdivision, - depth_or_array_layers: tape.subdivision, + width: tape.subdivision * 4, + height: tape.subdivision * 4, + depth_or_array_layers: tape.subdivision * 4, }, }); let texture_view = texture.create_view(&TextureViewDescriptor { diff --git a/crates/bevy_tape_load/src/render/enable_gen.wesl b/crates/bevy_tape_load/src/render/enable_gen.wesl index ae5c818..a8b6247 100644 --- a/crates/bevy_tape_load/src/render/enable_gen.wesl +++ b/crates/bevy_tape_load/src/render/enable_gen.wesl @@ -76,8 +76,8 @@ fn main(compute_input: ComputeInput) { let internal_pos = vec3f(compute_input.global_invocation_id); let mid_point = - (((internal_pos + 0.5f) / f32(1 << metadata.subdivision_log2)) * metadata.dimensions) - + metadata.lowest_corner; + (((internal_pos + 0.5f) / f32(4 << metadata.subdivision_log2)) * metadata.dimensions * 1.2) + + metadata.lowest_corner - 0.1; let point = scene(vec4(mid_point, metadata.time)); diff --git a/crates/bevy_tape_load/src/render/normal.wesl b/crates/bevy_tape_load/src/render/normal.wesl index 57958aa..5f74eb5 100644 --- a/crates/bevy_tape_load/src/render/normal.wesl +++ b/crates/bevy_tape_load/src/render/normal.wesl @@ -1,7 +1,7 @@ import package::render::metadata_types::TapeMetadata; import package::render::spatial_implicit::spatial_scene; -const EPSILON = .0001; +const EPSILON = .001; fn get_normal(metadata: TapeMetadata, spatial_texture: u32, p: vec3) -> vec3 { let n = vec3( diff --git a/crates/bevy_tape_load/src/render/spatial_implicit.wesl b/crates/bevy_tape_load/src/render/spatial_implicit.wesl index 0e22eb0..45d73c6 100644 --- a/crates/bevy_tape_load/src/render/spatial_implicit.wesl +++ b/crates/bevy_tape_load/src/render/spatial_implicit.wesl @@ -5,6 +5,6 @@ import package::render::metadata_types::TapeMetadata; @group(0) @binding(5) var spatial_texture_sampler: sampler; fn spatial_scene(metadata: TapeMetadata, spatial_texture: u32, p: vec4) -> f32 { - let actual = (p.xyz - metadata.lowest_corner) / metadata.dimensions; + let actual = ((p.xyz - metadata.lowest_corner + 0.1) / metadata.dimensions) / 1.2; return textureSampleLevel(spatial_textures[spatial_texture], spatial_texture_sampler, actual, 0.0).x; } diff --git a/crates/bevy_tape_load/src/render/trace.wesl b/crates/bevy_tape_load/src/render/trace.wesl index e242898..5d84163 100644 --- a/crates/bevy_tape_load/src/render/trace.wesl +++ b/crates/bevy_tape_load/src/render/trace.wesl @@ -43,7 +43,7 @@ fn trace_tape(metadata: TapeMetadata, spatial_texture: u32, primitive_id: u32, r let near_plane = near_far.x; let far_plane = near_far.y; - if (true) { // SPEC_BOUNDING_BOXES + if (false) { // SPEC_BOUNDING_BOXES return near_plane; } diff --git a/examples/pica_pica.rs b/examples/pica_pica.rs index f983627..69ef9aa 100644 --- a/examples/pica_pica.rs +++ b/examples/pica_pica.rs @@ -162,8 +162,10 @@ fn create_csg(seed: u64) -> SSATape { pos[0], pos[1], pos[2], - SSAInput::Constant(rng.random_range(0.0..1.0)), - SSAInput::Constant(rng.random_range(0.0..1.0)), + //SSAInput::Constant(rng.random_range(0.0..1.0)), + //SSAInput::Constant(rng.random_range(0.0..1.0)), + SSAInput::Constant(0.9), + SSAInput::Constant(0.3), ], ); let min = tape.push_instruction(