Allow toggling spatial texture
This commit is contained in:
@@ -1,11 +0,0 @@
|
|||||||
#ifndef implicit_spatial_tex_include
|
|
||||||
#define implicit_spatial_tex_include
|
|
||||||
|
|
||||||
uniform layout(set = 3, binding = 0) sampler3D spatial_texture;
|
|
||||||
|
|
||||||
float spatial_scene(vec3 p) {
|
|
||||||
vec3 actual = (p - object.lowest_corner) / object.dimensions;
|
|
||||||
return texture(spatial_texture, actual).x;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -13,6 +13,7 @@ layout(constant_id = 8) const bool SPEC_SHOW_MATERIAL3 = false;
|
|||||||
layout(constant_id = 9) const bool SPEC_SHOW_ALL = false;
|
layout(constant_id = 9) const bool SPEC_SHOW_ALL = false;
|
||||||
layout(constant_id = 10) const bool SPEC_DISABLE_AO = false;
|
layout(constant_id = 10) const bool SPEC_DISABLE_AO = false;
|
||||||
layout(constant_id = 11) const bool SPEC_USE_LINEAR_AO = false;
|
layout(constant_id = 11) const bool SPEC_USE_LINEAR_AO = false;
|
||||||
|
layout(constant_id = 12) const bool SPEC_USE_SPATIAL_TEXTURE = false;
|
||||||
|
|
||||||
layout(set = 0, binding = 0) uniform Lights {
|
layout(set = 0, binding = 0) uniform Lights {
|
||||||
vec4[32] pos;
|
vec4[32] pos;
|
||||||
|
|||||||
@@ -15,14 +15,14 @@ const float NAN = 0.0 / 0.0;
|
|||||||
Object object;
|
Object object;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
if (SPEC_BRUTE_FORCE) {
|
if (!SPEC_USE_SPATIAL_TEXTURE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
object = objects.objects[pc.object_index];
|
object = objects.objects[pc.object_index];
|
||||||
|
|
||||||
vec3 internal_pos = vec3(gl_GlobalInvocationID);
|
vec3 internal_pos = vec3(gl_GlobalInvocationID);
|
||||||
vec3 mid_point = (((internal_pos + 0.5) / 64.0)
|
vec3 mid_point = (((internal_pos + 0.5) / 32.0)
|
||||||
* object.dimensions) + object.lowest_corner;
|
* object.dimensions) + object.lowest_corner;
|
||||||
|
|
||||||
float s = scene(
|
float s = scene(
|
||||||
|
|||||||
@@ -3,10 +3,12 @@
|
|||||||
#extension GL_GOOGLE_include_directive:require
|
#extension GL_GOOGLE_include_directive:require
|
||||||
|
|
||||||
#include "include.glsl"
|
#include "include.glsl"
|
||||||
//#include "implicit_include.glsl"
|
|
||||||
|
uniform layout(set = 3, binding = 0) sampler3D spatial_texture;
|
||||||
|
|
||||||
|
#include "implicit_include.glsl"
|
||||||
|
|
||||||
Object object;
|
Object object;
|
||||||
#include "implicit_spatial_tex.glsl"
|
|
||||||
|
|
||||||
const float EPSILON = .001;
|
const float EPSILON = .001;
|
||||||
|
|
||||||
@@ -27,6 +29,11 @@ vec2 box_intersection(in vec3 ro, in vec3 rd, vec3 box_size)
|
|||||||
return vec2(tN, tF);
|
return vec2(tN, tF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float spatial_scene(vec3 p) {
|
||||||
|
vec3 actual = (p - object.lowest_corner) / object.dimensions;
|
||||||
|
return texture(spatial_texture, actual).x;
|
||||||
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
object = objects.objects[gl_InstanceID];
|
object = objects.objects[gl_InstanceID];
|
||||||
|
|
||||||
@@ -67,7 +74,7 @@ void main() {
|
|||||||
float total_dist = near_plane;
|
float total_dist = near_plane;
|
||||||
vec3 p = fma(raydir, vec3(total_dist), raypos);
|
vec3 p = fma(raydir, vec3(total_dist), raypos);
|
||||||
for (uint i = 0; i < MAX_STEPS; i++) {
|
for (uint i = 0; i < MAX_STEPS; i++) {
|
||||||
float dist = spatial_scene(p);
|
float dist = SPEC_USE_SPATIAL_TEXTURE ? spatial_scene(p) : scene(vec4(p, camera_uniforms.campos_and_time.w));
|
||||||
total_dist += dist;
|
total_dist += dist;
|
||||||
p = fma(raydir, vec3(total_dist), raypos);
|
p = fma(raydir, vec3(total_dist), raypos);
|
||||||
if (abs(dist) < EPSILON) {
|
if (abs(dist) < EPSILON) {
|
||||||
|
|||||||
+17
-12
@@ -15,18 +15,19 @@ fn sized_text(ui: &mut egui::Ui, text: impl Into<String>, size: f32) {
|
|||||||
|
|
||||||
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
|
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
|
||||||
pub(crate) struct PreviousDebug {
|
pub(crate) struct PreviousDebug {
|
||||||
pub(crate) bounding_boxes: bool,
|
pub(crate) bounding_boxes: bool,
|
||||||
pub(crate) brute_force: bool,
|
pub(crate) brute_force: bool,
|
||||||
pub(crate) show_normals: bool,
|
pub(crate) show_normals: bool,
|
||||||
pub(crate) show_depth: bool,
|
pub(crate) show_depth: bool,
|
||||||
pub(crate) show_position: bool,
|
pub(crate) show_position: bool,
|
||||||
pub(crate) show_albedo: bool,
|
pub(crate) show_albedo: bool,
|
||||||
pub(crate) show_material1: bool,
|
pub(crate) show_material1: bool,
|
||||||
pub(crate) show_material2: bool,
|
pub(crate) show_material2: bool,
|
||||||
pub(crate) show_material3: bool,
|
pub(crate) show_material3: bool,
|
||||||
pub(crate) show_all: bool,
|
pub(crate) show_all: bool,
|
||||||
pub(crate) disable_ao: bool,
|
pub(crate) disable_ao: bool,
|
||||||
pub(crate) use_linear_ao: bool,
|
pub(crate) use_linear_ao: bool,
|
||||||
|
pub(crate) use_spatial_textures: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@@ -345,6 +346,10 @@ pub(crate) fn gui_up(gui: &mut Gui, state: &mut GState) {
|
|||||||
&mut state.debug.use_linear_ao,
|
&mut state.debug.use_linear_ao,
|
||||||
"Use linear falloff for occlusion calculation",
|
"Use linear falloff for occlusion calculation",
|
||||||
);
|
);
|
||||||
|
ui.toggle_value(
|
||||||
|
&mut state.debug.use_spatial_textures,
|
||||||
|
"Use spatial textures rather than tracing directly to the surface",
|
||||||
|
);
|
||||||
|
|
||||||
state.recreate_pipelines = ui.button("Force recompile pipelines").clicked();
|
state.recreate_pipelines = ui.button("Force recompile pipelines").clicked();
|
||||||
state.reset_time = ui.button("Reset time to 0").clicked();
|
state.reset_time = ui.button("Reset time to 0").clicked();
|
||||||
|
|||||||
@@ -1523,7 +1523,7 @@ impl App {
|
|||||||
|
|
||||||
debug_assert_eq!(csg.subdivision % 8, 0);
|
debug_assert_eq!(csg.subdivision % 8, 0);
|
||||||
|
|
||||||
unsafe { builder.dispatch([64 / 8, 64 / 8, 64 / 8]) }.unwrap();
|
unsafe { builder.dispatch([32 / 8, 32 / 8, 32 / 8]) }.unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2265,6 +2265,7 @@ fn get_spec_constants(debug: &PreviousDebug) -> HashMap<u32, SpecializationConst
|
|||||||
const SPEC_SHOW_ALL: u32 = 9;
|
const SPEC_SHOW_ALL: u32 = 9;
|
||||||
const SPEC_DISABLE_AO: u32 = 10;
|
const SPEC_DISABLE_AO: u32 = 10;
|
||||||
const SPEC_USE_LINEAR_AO: u32 = 11;
|
const SPEC_USE_LINEAR_AO: u32 = 11;
|
||||||
|
const SPEC_USE_SPATIAL_TEXTURE: u32 = 12;
|
||||||
|
|
||||||
let mut spec_constants = HashMap::with_capacity(6);
|
let mut spec_constants = HashMap::with_capacity(6);
|
||||||
spec_constants.insert(
|
spec_constants.insert(
|
||||||
@@ -2312,6 +2313,10 @@ fn get_spec_constants(debug: &PreviousDebug) -> HashMap<u32, SpecializationConst
|
|||||||
SPEC_USE_LINEAR_AO,
|
SPEC_USE_LINEAR_AO,
|
||||||
SpecializationConstant::Bool(debug.use_linear_ao),
|
SpecializationConstant::Bool(debug.use_linear_ao),
|
||||||
);
|
);
|
||||||
|
spec_constants.insert(
|
||||||
|
SPEC_USE_SPATIAL_TEXTURE,
|
||||||
|
SpecializationConstant::Bool(debug.use_spatial_textures),
|
||||||
|
);
|
||||||
|
|
||||||
trace!("Specs: {:?}", spec_constants);
|
trace!("Specs: {:?}", spec_constants);
|
||||||
|
|
||||||
|
|||||||
@@ -150,11 +150,7 @@ pub fn thread_loop(recv: mpmc::Receiver<WorkItem>, send: mpsc::SyncSender<WorkCo
|
|||||||
image_type: ImageType::Dim3d,
|
image_type: ImageType::Dim3d,
|
||||||
format: Format::R16_SFLOAT,
|
format: Format::R16_SFLOAT,
|
||||||
view_formats: vec![Format::R16_SFLOAT],
|
view_formats: vec![Format::R16_SFLOAT],
|
||||||
extent: [
|
extent: [32, 32, 32],
|
||||||
MAXIMUM_SUBDIVISION,
|
|
||||||
MAXIMUM_SUBDIVISION,
|
|
||||||
MAXIMUM_SUBDIVISION,
|
|
||||||
],
|
|
||||||
usage: ImageUsage::STORAGE | ImageUsage::SAMPLED,
|
usage: ImageUsage::STORAGE | ImageUsage::SAMPLED,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user