it works
This commit is contained in:
@@ -40,20 +40,19 @@ fn pathtrace(@builtin(global_invocation_id) global_id: vec3<u32>) {
|
||||
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);
|
||||
|
||||
@@ -443,8 +443,8 @@ fn resolve_tape_data_full(instance_id: u32, position: vec3<f32>) -> 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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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));
|
||||
|
||||
|
||||
@@ -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<f32>) -> vec3<f32> {
|
||||
let n = vec3(
|
||||
|
||||
@@ -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>) -> 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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user