work around the texture parameter thing
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
import package::render::metadata_types::TapeMetadata;
|
||||
|
||||
fn scene(scene_input_one: vec4<f32>) -> f32 {
|
||||
return 0.0;
|
||||
}
|
||||
@@ -14,8 +12,3 @@ fn interval_scene(
|
||||
fn gradient_scene(gradient_scene_input_one: vec4<f32>) -> vec4<f32> {
|
||||
return vec4(0.0);
|
||||
}
|
||||
|
||||
fn spatial_scene(metadata: TapeMetadata, spatial_texture: texture_3d<f32>, spatial_texture_sampler: sampler, p: vec4<f32>) -> f32 {
|
||||
let actual = (p.xyz - metadata.lowest_corner) / metadata.dimensions;
|
||||
return textureSampleLevel(spatial_texture, spatial_texture_sampler, actual, 0.0).x;
|
||||
}
|
||||
|
||||
@@ -76,6 +76,7 @@ impl Plugin for TapeRenderAssetPlugin {
|
||||
load_shader_library!(app, "aabb.wesl");
|
||||
load_shader_library!(app, "metadata_types.wesl");
|
||||
load_shader_library!(app, "implicit.wesl");
|
||||
load_shader_library!(app, "spatial_implicit.wesl");
|
||||
load_shader_library!(app, "trace.wesl");
|
||||
load_shader_library!(app, "util.wesl");
|
||||
load_shader_library!(app, "normal.wesl");
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import package::render::metadata_types::TapeMetadata;
|
||||
import package::render::implicit::{spatial_scene};
|
||||
import package::render::spatial_implicit::spatial_scene;
|
||||
|
||||
const EPSILON = .0001;
|
||||
|
||||
fn get_normal(metadata: TapeMetadata, spatial_texture: texture_3d<f32>, spatial_texture_sampler: sampler, p: vec3<f32>) -> vec3<f32> {
|
||||
fn get_normal(metadata: TapeMetadata, spatial_texture: u32, p: vec3<f32>) -> vec3<f32> {
|
||||
let n = vec3(
|
||||
spatial_scene(metadata, spatial_texture, spatial_texture_sampler, vec4(p.x + EPSILON, p.y, p.z, metadata.time)),
|
||||
spatial_scene(metadata, spatial_texture, spatial_texture_sampler, vec4(p.x, p.y + EPSILON, p.z, metadata.time)),
|
||||
spatial_scene(metadata, spatial_texture, spatial_texture_sampler, vec4(p.x, p.y, p.z + EPSILON, metadata.time)),
|
||||
spatial_scene(metadata, spatial_texture, vec4(p.x + EPSILON, p.y, p.z, metadata.time)),
|
||||
spatial_scene(metadata, spatial_texture, vec4(p.x, p.y + EPSILON, p.z, metadata.time)),
|
||||
spatial_scene(metadata, spatial_texture, vec4(p.x, p.y, p.z + EPSILON, metadata.time)),
|
||||
);
|
||||
return normalize(n - (spatial_scene(metadata, spatial_texture, spatial_texture_sampler, vec4(p, metadata.time))));
|
||||
return normalize(n - (spatial_scene(metadata, spatial_texture, vec4(p, metadata.time))));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import package::render::metadata_types::TapeMetadata;
|
||||
|
||||
// This is to work around that you can't pass textures as parameters, it seems.
|
||||
@group(0) @binding(4) var spatial_textures: binding_array<texture_3d<f32>>;
|
||||
@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;
|
||||
return textureSampleLevel(spatial_textures[spatial_texture], spatial_texture_sampler, actual, 0.0).x;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import package::render::metadata_types::TapeMetadata;
|
||||
import package::render::implicit::{spatial_scene};
|
||||
import package::render::spatial_implicit::spatial_scene;
|
||||
import package::render::util::{get_internal_pos, get_low_corner, get_high_corner};
|
||||
|
||||
enable wgpu_binding_array;
|
||||
@@ -25,7 +25,7 @@ fn box_intersection(ro: vec3<f32>, rd: vec3<f32>, box_size: vec3<f32>) -> vec2<f
|
||||
return vec2(tN, tF);
|
||||
}
|
||||
|
||||
fn trace_tape(metadata: TapeMetadata, spatial_texture: texture_3d<f32>, spatial_texture_sampler: sampler, primitive_id: u32, raypos: vec3<f32>, raydir: vec3<f32>) -> f32 {
|
||||
fn trace_tape(metadata: TapeMetadata, spatial_texture: u32, primitive_id: u32, raypos: vec3<f32>, raydir: vec3<f32>) -> f32 {
|
||||
let internal_pos = get_internal_pos(primitive_id, metadata.subdivision_log2);
|
||||
|
||||
let low_corner = get_low_corner(internal_pos, metadata);
|
||||
@@ -50,7 +50,7 @@ fn trace_tape(metadata: TapeMetadata, spatial_texture: texture_3d<f32>, spatial_
|
||||
var total_dist = near_plane;
|
||||
var p = fma(raydir, vec3(total_dist), raypos);
|
||||
for (var i = 0; i < MAX_STEPS; i++) {
|
||||
let dist = spatial_scene(metadata, spatial_texture, spatial_texture_sampler, vec4(p, metadata.time));
|
||||
let dist = spatial_scene(metadata, spatial_texture, vec4(p, metadata.time));
|
||||
total_dist += dist;
|
||||
p = fma(raydir, vec3(total_dist), raypos);
|
||||
if (abs(dist) < EPSILON) {
|
||||
|
||||
Reference in New Issue
Block a user