Massively increase block density
This commit is contained in:
Generated
+6
-6
@@ -171,9 +171,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "avif-serialize"
|
||||
version = "0.8.4"
|
||||
version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "19135c0c7a60bfee564dbe44ab5ce0557c6bf3884e5291a50be76a15640c4fbd"
|
||||
checksum = "2ea8ef51aced2b9191c08197f55450d830876d9933f8f48a429b354f1d496b42"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
]
|
||||
@@ -283,9 +283,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.2.27"
|
||||
version = "1.2.29"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d487aa071b5f64da6f19a3e848e3578944b726ee5a4854b82172f02aa876bfdc"
|
||||
checksum = "5c1599538de2394445747c8cf7935946e3cc27e9625f889d979bfb2aaf569362"
|
||||
dependencies = [
|
||||
"jobserver",
|
||||
"libc",
|
||||
@@ -2057,9 +2057,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rgb"
|
||||
version = "0.8.50"
|
||||
version = "0.8.51"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "57397d16646700483b67d2dd6511d79318f9d057fdbd21a4066aeac8b41d310a"
|
||||
checksum = "a457e416a0f90d246a4c3288bd7a25b2304ca727f253f95be383dd17af56be8f"
|
||||
|
||||
[[package]]
|
||||
name = "roxmltree"
|
||||
|
||||
+23
-5
@@ -1,22 +1,40 @@
|
||||
#version 460
|
||||
#include "include.glsl"
|
||||
#include "implicit_include.glsl"
|
||||
|
||||
layout(location = 0) in vec3 position;
|
||||
|
||||
layout(location = 0) out vec4 pos;
|
||||
|
||||
void main() {
|
||||
vec3 internal_pos = vec3(float((gl_InstanceIndex >> 6) & 7) / 8.0,
|
||||
float((gl_InstanceIndex >> 3) & 7) / 8.0,
|
||||
float((gl_InstanceIndex >> 0) & 7) / 8.0);
|
||||
vec3 internal_pos = vec3(
|
||||
float((gl_InstanceIndex >> 10) & 31) / 32.0,
|
||||
float((gl_InstanceIndex >> 5) & 31) / 32.0,
|
||||
float((gl_InstanceIndex >> 0) & 31) / 32.0
|
||||
);
|
||||
|
||||
bool enable = (pc.enable[gl_InstanceIndex >> 5] & (1 << (gl_InstanceIndex & 31))) != 0;
|
||||
bool enable;
|
||||
switch ((gl_InstanceIndex >> 5) & 3) {
|
||||
default:
|
||||
case 0:
|
||||
enable = (object_uniforms.enable[gl_InstanceIndex >> 7].x & (1 << (gl_InstanceIndex & 31))) != 0;
|
||||
break;
|
||||
case 1:
|
||||
enable = (object_uniforms.enable[gl_InstanceIndex >> 7].y & (1 << (gl_InstanceIndex & 31))) != 0;
|
||||
break;
|
||||
case 2:
|
||||
enable = (object_uniforms.enable[gl_InstanceIndex >> 7].z & (1 << (gl_InstanceIndex & 31))) != 0;
|
||||
break;
|
||||
case 3:
|
||||
enable = (object_uniforms.enable[gl_InstanceIndex >> 7].w & (1 << (gl_InstanceIndex & 31))) != 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!enable) {
|
||||
gl_Position = vec4(0.0 / 0.0);
|
||||
return;
|
||||
}
|
||||
|
||||
pos = vec4((((position / 8.0) + internal_pos) * pc.dimensions) + pc.lowest_corner, 1.);
|
||||
pos = vec4((((position / 32.0) + internal_pos) * object_uniforms.dimensions) + object_uniforms.lowest_corner, 1.);
|
||||
gl_Position = camera_uniforms.proj_view * pc.world * pos;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
#ifndef implicit_include
|
||||
#define implicit_include
|
||||
|
||||
layout(set = 1, binding = 0) uniform Object {
|
||||
uvec4 enable[32 * 8];
|
||||
vec3 dimensions;
|
||||
vec3 lowest_corner;
|
||||
uint material;
|
||||
} object_uniforms;
|
||||
|
||||
#endif
|
||||
@@ -4,10 +4,6 @@
|
||||
layout(push_constant) uniform PushConstantData {
|
||||
mat4 world;
|
||||
mat4 inv_world;
|
||||
vec3 dimensions;
|
||||
vec3 lowest_corner;
|
||||
uint enable[16];
|
||||
uint material;
|
||||
} pc;
|
||||
|
||||
layout(set = 0, binding = 0) uniform Lights {
|
||||
|
||||
+63
-19
@@ -188,6 +188,7 @@ struct App {
|
||||
descriptor_set_allocator: Arc<StandardDescriptorSetAllocator>,
|
||||
command_buffer_allocator: Arc<StandardCommandBufferAllocator>,
|
||||
uniform_buffer_allocator: SubbufferAllocator,
|
||||
block_enable_allocator: Arc<Mutex<SubbufferAllocator>>,
|
||||
pipeline_cache: Arc<PipelineCache>,
|
||||
draw_gui: bool,
|
||||
gstate: GState,
|
||||
@@ -373,6 +374,16 @@ impl App {
|
||||
},
|
||||
);
|
||||
|
||||
let block_enable_allocator = Arc::new(Mutex::new(SubbufferAllocator::new(
|
||||
memory_allocator.clone(),
|
||||
SubbufferAllocatorCreateInfo {
|
||||
buffer_usage: BufferUsage::UNIFORM_BUFFER,
|
||||
memory_type_filter: MemoryTypeFilter::PREFER_DEVICE
|
||||
| MemoryTypeFilter::HOST_SEQUENTIAL_WRITE,
|
||||
..Default::default()
|
||||
},
|
||||
)));
|
||||
|
||||
let pipeline_cache = get_pipeline_cache(device.clone());
|
||||
|
||||
let mut gstate = GState::default();
|
||||
@@ -439,6 +450,7 @@ impl App {
|
||||
descriptor_set_allocator,
|
||||
command_buffer_allocator,
|
||||
uniform_buffer_allocator,
|
||||
block_enable_allocator,
|
||||
pipeline_cache,
|
||||
csg_count: gstate.csg.len(),
|
||||
draw_gui: true,
|
||||
@@ -463,7 +475,7 @@ mod implicit_vs {
|
||||
path: "src/implicit.vert.glsl",
|
||||
vulkan_version: "1.3",
|
||||
spirv_version: "1.6",
|
||||
custom_derives: [Debug, Clone, Copy, Default],
|
||||
custom_derives: [Debug, Clone, Copy],
|
||||
}
|
||||
}
|
||||
|
||||
@@ -473,7 +485,7 @@ mod fullscreen_vs {
|
||||
path: "src/fullscreen.vert.glsl",
|
||||
vulkan_version: "1.3",
|
||||
spirv_version: "1.6",
|
||||
custom_derives: [Debug, Clone, Copy, Default],
|
||||
custom_derives: [Debug, Clone, Copy],
|
||||
}
|
||||
}
|
||||
|
||||
@@ -483,7 +495,7 @@ mod lighting_fs {
|
||||
path: "src/lighting.frag.glsl",
|
||||
vulkan_version: "1.3",
|
||||
spirv_version: "1.6",
|
||||
custom_derives: [Debug, Clone, Copy, Default],
|
||||
custom_derives: [Debug, Clone, Copy],
|
||||
}
|
||||
}
|
||||
|
||||
@@ -811,6 +823,9 @@ impl ApplicationHandler for App {
|
||||
self.pipeline_cache.clone(),
|
||||
rcx.shader_modules.clone(),
|
||||
self.previous_debug.clone(),
|
||||
self.block_enable_allocator.clone(),
|
||||
self.descriptor_set_allocator.clone(),
|
||||
rcx.swapchain.image_count(),
|
||||
0,
|
||||
))
|
||||
.unwrap();
|
||||
@@ -946,7 +961,7 @@ impl App {
|
||||
Arc<DescriptorSet>,
|
||||
Arc<DescriptorSet>,
|
||||
) {
|
||||
let implicit_set = if self.csg_count > 0 {
|
||||
let implicit_set1 = if self.csg_count > 0 {
|
||||
let implicit_layout = &self.gstate.csg[0]
|
||||
.read()
|
||||
.unwrap()
|
||||
@@ -992,13 +1007,13 @@ impl App {
|
||||
None
|
||||
};
|
||||
|
||||
let normals_set2 = if self.csg_count > 0 {
|
||||
let normals_set3 = if self.csg_count > 0 {
|
||||
let normals_layout = &self.gstate.csg[0]
|
||||
.read()
|
||||
.unwrap()
|
||||
.normals_pipeline
|
||||
.layout()
|
||||
.set_layouts()[1]
|
||||
.set_layouts()[2]
|
||||
.clone();
|
||||
let normals_set = DescriptorSet::new(
|
||||
self.descriptor_set_allocator.clone(),
|
||||
@@ -1041,9 +1056,9 @@ impl App {
|
||||
.unwrap();
|
||||
|
||||
(
|
||||
implicit_set,
|
||||
implicit_set1,
|
||||
normals_set1,
|
||||
normals_set2,
|
||||
normals_set3,
|
||||
lighting_set1,
|
||||
lighting_set2,
|
||||
)
|
||||
@@ -1084,6 +1099,7 @@ impl App {
|
||||
builder: &mut AutoCommandBufferBuilder<PrimaryAutoCommandBuffer>,
|
||||
push_constants: &Vec<PushConstantData>,
|
||||
implicit_set: Arc<DescriptorSet>,
|
||||
frame_index: usize,
|
||||
) {
|
||||
for (i, csg) in self.gstate.csg.iter().enumerate() {
|
||||
let csg = csg.read().unwrap();
|
||||
@@ -1094,7 +1110,10 @@ impl App {
|
||||
PipelineBindPoint::Graphics,
|
||||
csg.deferred_pipeline.layout().clone(),
|
||||
0,
|
||||
implicit_set.clone(),
|
||||
vec![
|
||||
implicit_set.clone(),
|
||||
csg.deferred_descriptor_set[frame_index].clone(),
|
||||
],
|
||||
)
|
||||
.unwrap()
|
||||
.bind_vertex_buffers(0, self.vertex_buffer.clone())
|
||||
@@ -1104,7 +1123,7 @@ impl App {
|
||||
.push_constants(csg.deferred_pipeline.layout().clone(), 0, push_constants[i])
|
||||
.unwrap();
|
||||
|
||||
unsafe { builder.draw(VERTEX_COUNT as u32, 8 * 8 * 8, 0, 0) }.unwrap();
|
||||
unsafe { builder.draw(VERTEX_COUNT as u32, 32 * 32 * 32, 0, 0) }.unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1114,6 +1133,7 @@ impl App {
|
||||
push_constants: &Vec<PushConstantData>,
|
||||
normals_set1: Arc<DescriptorSet>,
|
||||
normals_set2: Arc<DescriptorSet>,
|
||||
frame_index: usize,
|
||||
) {
|
||||
for (i, csg) in self.gstate.csg.iter().enumerate() {
|
||||
let csg = csg.read().unwrap();
|
||||
@@ -1124,7 +1144,11 @@ impl App {
|
||||
PipelineBindPoint::Graphics,
|
||||
csg.normals_pipeline.layout().clone(),
|
||||
0,
|
||||
vec![normals_set1.clone(), normals_set2.clone()],
|
||||
vec![
|
||||
normals_set1.clone(),
|
||||
csg.normals_descriptor_set[frame_index].clone(),
|
||||
normals_set2.clone(),
|
||||
],
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
@@ -1215,21 +1239,24 @@ impl App {
|
||||
self.pipeline_cache.clone(),
|
||||
rcx.shader_modules.clone(),
|
||||
self.previous_debug.clone(),
|
||||
self.block_enable_allocator.clone(),
|
||||
self.descriptor_set_allocator.clone(),
|
||||
rcx.swapchain.image_count(),
|
||||
-1,
|
||||
))
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
let mut push_constants = vec![PushConstantData::default(); self.gstate.csg.len()];
|
||||
let mut push_constants = vec![
|
||||
PushConstantData {
|
||||
world: Default::default(),
|
||||
inv_world: Default::default(),
|
||||
};
|
||||
self.gstate.csg.len()
|
||||
];
|
||||
let mut push_constants_left = self.gstate.csg.len();
|
||||
|
||||
for (i, csg) in self.gstate.csg.iter().enumerate() {
|
||||
self.thread_work_creation
|
||||
.send(WorkItem::GetPushConstants(csg.clone(), self.time, i))
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
if self.previous_debug != self.gstate.debug {
|
||||
rcx.recreate_pipelines = true;
|
||||
self.previous_debug = self.gstate.debug;
|
||||
@@ -1292,6 +1319,17 @@ impl App {
|
||||
|
||||
let image_index = image_index as usize;
|
||||
|
||||
for (i, csg) in self.gstate.csg.iter().enumerate() {
|
||||
self.thread_work_creation
|
||||
.send(WorkItem::GetPushConstants(
|
||||
csg.clone(),
|
||||
self.time,
|
||||
image_index,
|
||||
i,
|
||||
))
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
if let Some(future) = &mut rcx.previous_frame_end[image_index] {
|
||||
future.wait(None).unwrap();
|
||||
future.cleanup_finished();
|
||||
@@ -1346,7 +1384,12 @@ impl App {
|
||||
}
|
||||
|
||||
if self.gstate.csg.len() > 0 {
|
||||
self.add_commands_depth_pass(&mut builder, &push_constants, implicit_set.unwrap());
|
||||
self.add_commands_depth_pass(
|
||||
&mut builder,
|
||||
&push_constants,
|
||||
implicit_set.unwrap(),
|
||||
image_index,
|
||||
);
|
||||
}
|
||||
self.add_commands_primary_subpass(&mut builder);
|
||||
if self.gstate.csg.len() > 0 {
|
||||
@@ -1355,6 +1398,7 @@ impl App {
|
||||
&push_constants,
|
||||
normals_set1.unwrap(),
|
||||
normals_set2.unwrap(),
|
||||
image_index,
|
||||
);
|
||||
}
|
||||
self.add_commands_primary_subpass(&mut builder);
|
||||
|
||||
@@ -3,11 +3,12 @@
|
||||
#version 460
|
||||
#extension GL_GOOGLE_include_directive:require
|
||||
#include "include.glsl"
|
||||
#include "implicit_include.glsl"
|
||||
|
||||
layout(location = 0) in vec2 v_pos;
|
||||
|
||||
layout(input_attachment_index = 0, set = 1, binding = 0) uniform usubpassInput u_material;
|
||||
layout(input_attachment_index = 1, set = 1, binding = 1) uniform subpassInput u_depth;
|
||||
layout(input_attachment_index = 0, set = 2, binding = 0) uniform usubpassInput u_material;
|
||||
layout(input_attachment_index = 1, set = 2, binding = 1) uniform subpassInput u_depth;
|
||||
|
||||
layout(location = 0) out vec4 f_color;
|
||||
layout(location = 1) out vec4 f_normal;
|
||||
@@ -41,7 +42,7 @@ vec3 getNormal(vec3 p) {
|
||||
|
||||
//Implicit Surface Entrypoint
|
||||
void main() {
|
||||
if (subpassLoad(u_material).x != pc.material) {
|
||||
if (subpassLoad(u_material).x != object_uniforms.material) {
|
||||
discard;
|
||||
}
|
||||
|
||||
|
||||
+12
-8
@@ -5,13 +5,14 @@ use glam::{self, Vec3};
|
||||
use obj::{LoadConfig, ObjData, ObjError};
|
||||
use vulkano::{
|
||||
buffer::{Buffer, BufferCreateInfo, BufferUsage, Subbuffer},
|
||||
descriptor_set::DescriptorSet,
|
||||
memory::allocator::{
|
||||
AllocationCreateInfo, MemoryAllocatePreference, MemoryTypeFilter, StandardMemoryAllocator,
|
||||
},
|
||||
pipeline::{GraphicsPipeline, graphics::vertex_input::Vertex},
|
||||
};
|
||||
|
||||
use crate::ssa::SSATape;
|
||||
use crate::{implicit_vs::Object, ssa::SSATape};
|
||||
|
||||
pub(crate) const PLATONIC_SOLIDS: [(&str, &[u8]); 1] = [("Buny", include_bytes!("bunny.obj"))];
|
||||
|
||||
@@ -36,13 +37,16 @@ pub(crate) struct Mesh {
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct CSG {
|
||||
pub(crate) name: String,
|
||||
pub(crate) parts: SSATape,
|
||||
pub(crate) pos: Vec3,
|
||||
pub(crate) rot: Vec3,
|
||||
pub(crate) scale: Vec3,
|
||||
pub(crate) deferred_pipeline: Arc<GraphicsPipeline>,
|
||||
pub(crate) normals_pipeline: Arc<GraphicsPipeline>,
|
||||
pub(crate) name: String,
|
||||
pub(crate) parts: SSATape,
|
||||
pub(crate) pos: Vec3,
|
||||
pub(crate) rot: Vec3,
|
||||
pub(crate) scale: Vec3,
|
||||
pub(crate) deferred_pipeline: Arc<GraphicsPipeline>,
|
||||
pub(crate) normals_pipeline: Arc<GraphicsPipeline>,
|
||||
pub(crate) enable_buffer: Vec<Subbuffer<Object>>,
|
||||
pub(crate) deferred_descriptor_set: Vec<Arc<DescriptorSet>>,
|
||||
pub(crate) normals_descriptor_set: Vec<Arc<DescriptorSet>>,
|
||||
}
|
||||
|
||||
pub(crate) fn load_obj(
|
||||
|
||||
+134
-64
@@ -2,7 +2,7 @@ use std::{
|
||||
fs::File,
|
||||
io::Write,
|
||||
simd::{StdFloat, cmp::SimdPartialOrd},
|
||||
sync::{Arc, RwLock, mpmc, mpsc},
|
||||
sync::{Arc, Mutex, RwLock, mpmc, mpsc},
|
||||
time::Instant,
|
||||
};
|
||||
|
||||
@@ -11,9 +11,13 @@ use glam::{EulerRot, Mat4, Vec3};
|
||||
use log::info;
|
||||
use rspirv::{binary::Assemble, dr::Module};
|
||||
use vulkano::{
|
||||
buffer::{Subbuffer, allocator::SubbufferAllocator},
|
||||
descriptor_set::{
|
||||
DescriptorSet, WriteDescriptorSet, allocator::StandardDescriptorSetAllocator,
|
||||
},
|
||||
device::Device,
|
||||
pipeline::{
|
||||
DynamicState, GraphicsPipeline, PipelineCreateFlags, PipelineLayout,
|
||||
DynamicState, GraphicsPipeline, Pipeline, PipelineCreateFlags, PipelineLayout,
|
||||
PipelineShaderStageCreateInfo,
|
||||
cache::PipelineCache,
|
||||
graphics::{
|
||||
@@ -34,7 +38,7 @@ use vulkano::{
|
||||
use crate::{
|
||||
DUMP_SPV_TO_FILE, IVertex, ShaderModules, get_spec_constants,
|
||||
gui::PreviousDebug,
|
||||
implicit_vs::PushConstantData,
|
||||
implicit_vs::{Object, PushConstantData},
|
||||
interpreter::{self, IntervalInterpreter, PointInterpreter, VALUE_0},
|
||||
objects::CSG,
|
||||
ssa::{SSAInput, SSAOpcode, SSAOpcodeSized, SSATape},
|
||||
@@ -51,9 +55,12 @@ pub enum WorkItem {
|
||||
Arc<PipelineCache>,
|
||||
ShaderModules,
|
||||
PreviousDebug,
|
||||
Arc<Mutex<SubbufferAllocator>>,
|
||||
Arc<StandardDescriptorSetAllocator>,
|
||||
u32,
|
||||
isize,
|
||||
),
|
||||
GetPushConstants(Arc<RwLock<CSG>>, f32, usize),
|
||||
GetPushConstants(Arc<RwLock<CSG>>, f32, usize, usize),
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -73,6 +80,9 @@ pub fn thread_loop(recv: mpmc::Receiver<WorkItem>, send: mpsc::SyncSender<WorkCo
|
||||
cache,
|
||||
modules,
|
||||
debug,
|
||||
block_enable_allocator,
|
||||
descriptor_set_allocator,
|
||||
frames,
|
||||
index,
|
||||
) => {
|
||||
let csg_start = Instant::now();
|
||||
@@ -97,6 +107,51 @@ pub fn thread_loop(recv: mpmc::Receiver<WorkItem>, send: mpsc::SyncSender<WorkCo
|
||||
debug,
|
||||
);
|
||||
|
||||
let enable_buffer: Vec<Subbuffer<Object>> = (0..frames)
|
||||
.into_iter()
|
||||
.map(|_| {
|
||||
block_enable_allocator
|
||||
.lock()
|
||||
.unwrap()
|
||||
.allocate_sized()
|
||||
.unwrap()
|
||||
})
|
||||
.collect();
|
||||
|
||||
let deferred_layout = deferred_pipeline.layout().set_layouts()[1].clone();
|
||||
let deferred_descriptor_set = (0..frames)
|
||||
.into_iter()
|
||||
.map(|f| {
|
||||
DescriptorSet::new(
|
||||
descriptor_set_allocator.clone(),
|
||||
deferred_layout.clone(),
|
||||
[WriteDescriptorSet::buffer(
|
||||
0,
|
||||
enable_buffer[f as usize].clone(),
|
||||
)],
|
||||
[],
|
||||
)
|
||||
.unwrap()
|
||||
})
|
||||
.collect();
|
||||
|
||||
let normals_layout = normals_pipeline.layout().set_layouts()[1].clone();
|
||||
let normals_descriptor_set = (0..frames)
|
||||
.into_iter()
|
||||
.map(|f| {
|
||||
DescriptorSet::new(
|
||||
descriptor_set_allocator.clone(),
|
||||
normals_layout.clone(),
|
||||
[WriteDescriptorSet::buffer(
|
||||
0,
|
||||
enable_buffer[f as usize].clone(),
|
||||
)],
|
||||
[],
|
||||
)
|
||||
.unwrap()
|
||||
})
|
||||
.collect();
|
||||
|
||||
let csg = Arc::new(RwLock::new(CSG {
|
||||
name: "example".to_string(),
|
||||
parts,
|
||||
@@ -105,6 +160,9 @@ pub fn thread_loop(recv: mpmc::Receiver<WorkItem>, send: mpsc::SyncSender<WorkCo
|
||||
scale: Vec3::ONE,
|
||||
deferred_pipeline,
|
||||
normals_pipeline,
|
||||
enable_buffer,
|
||||
deferred_descriptor_set,
|
||||
normals_descriptor_set,
|
||||
}));
|
||||
|
||||
send.send(WorkComplete::CreateCSG(csg, index)).unwrap();
|
||||
@@ -115,14 +173,10 @@ pub fn thread_loop(recv: mpmc::Receiver<WorkItem>, send: mpsc::SyncSender<WorkCo
|
||||
(csg_end - csg_start).as_secs_f64() * 1000.0
|
||||
);
|
||||
},
|
||||
WorkItem::GetPushConstants(csg, time, index) => {
|
||||
WorkItem::GetPushConstants(csg, time, frame_index, index) => {
|
||||
let mut push_constants = PushConstantData {
|
||||
world: Mat4::IDENTITY.to_cols_array_2d(),
|
||||
inv_world: Mat4::IDENTITY.to_cols_array_2d(),
|
||||
dimensions: Vec3::ONE.to_array().into(),
|
||||
lowest_corner: Vec3::ZERO.into(),
|
||||
enable: [0; 16],
|
||||
material: 0,
|
||||
world: Mat4::IDENTITY.to_cols_array_2d(),
|
||||
inv_world: Mat4::IDENTITY.to_cols_array_2d(),
|
||||
};
|
||||
|
||||
let csg = csg.read().unwrap();
|
||||
@@ -139,9 +193,7 @@ pub fn thread_loop(recv: mpmc::Receiver<WorkItem>, send: mpsc::SyncSender<WorkCo
|
||||
push_constants.world = world.to_cols_array_2d();
|
||||
push_constants.inv_world = world.inverse().to_cols_array_2d();
|
||||
|
||||
interval_check(&csg, &mut push_constants, time);
|
||||
|
||||
push_constants.material = index as u32 + 1;
|
||||
interval_check(&csg, index as u32 + 1, time, frame_index);
|
||||
|
||||
send.send(WorkComplete::GetPushConstants(push_constants, index))
|
||||
.unwrap();
|
||||
@@ -357,7 +409,7 @@ fn create_csg() -> SSATape {
|
||||
tape
|
||||
}
|
||||
|
||||
fn interval_check(csg: &CSG, push_constants: &mut PushConstantData, time: f32) {
|
||||
fn interval_check(csg: &CSG, material: u32, time: f32, frame_index: usize) {
|
||||
const INTERPRET_INPUT_X: interpreter::Value =
|
||||
interpreter::Value::from_array([10000.0, 0.0, 0.0, -10000.0, 0.0, 0.0, 0.0, 0.0]);
|
||||
const INTERPRET_INPUT_Y: interpreter::Value =
|
||||
@@ -384,60 +436,78 @@ fn interval_check(csg: &CSG, push_constants: &mut PushConstantData, time: f32) {
|
||||
let highest_corner = Vec3::new(interpreter_out[0], interpreter_out[1], interpreter_out[2]);
|
||||
let lowest_corner = Vec3::new(interpreter_out[3], interpreter_out[4], interpreter_out[5]);
|
||||
|
||||
push_constants.dimensions = (highest_corner - lowest_corner).to_array().into();
|
||||
push_constants.lowest_corner = lowest_corner.into();
|
||||
let mut obj = Object {
|
||||
dimensions: (highest_corner - lowest_corner).to_array().into(),
|
||||
lowest_corner: lowest_corner.into(),
|
||||
enable: [[0; 4]; 32 * 8],
|
||||
material,
|
||||
};
|
||||
|
||||
push_constants.enable = [0; 16];
|
||||
for x in 0..32 {
|
||||
for y in 0..32 {
|
||||
for z in 0..4 {
|
||||
let interval_input_z: Interval = Interval::new_unchecked(
|
||||
interpreter::Value::from_array([
|
||||
((((8.0 / 32.0) * z as f32) + (0.0 / 32.0)) * obj.dimensions[2])
|
||||
+ obj.lowest_corner[2],
|
||||
((((8.0 / 32.0) * z as f32) + (1.0 / 32.0)) * obj.dimensions[2])
|
||||
+ obj.lowest_corner[2],
|
||||
((((8.0 / 32.0) * z as f32) + (2.0 / 32.0)) * obj.dimensions[2])
|
||||
+ obj.lowest_corner[2],
|
||||
((((8.0 / 32.0) * z as f32) + (3.0 / 32.0)) * obj.dimensions[2])
|
||||
+ obj.lowest_corner[2],
|
||||
((((8.0 / 32.0) * z as f32) + (4.0 / 32.0)) * obj.dimensions[2])
|
||||
+ obj.lowest_corner[2],
|
||||
((((8.0 / 32.0) * z as f32) + (5.0 / 32.0)) * obj.dimensions[2])
|
||||
+ obj.lowest_corner[2],
|
||||
((((8.0 / 32.0) * z as f32) + (6.0 / 32.0)) * obj.dimensions[2])
|
||||
+ obj.lowest_corner[2],
|
||||
((((8.0 / 32.0) * z as f32) + (7.0 / 32.0)) * obj.dimensions[2])
|
||||
+ obj.lowest_corner[2],
|
||||
]),
|
||||
interpreter::Value::from_array([
|
||||
((((8.0 / 32.0) * z as f32) + (1.0 / 32.0)) * obj.dimensions[2])
|
||||
+ obj.lowest_corner[2],
|
||||
((((8.0 / 32.0) * z as f32) + (2.0 / 32.0)) * obj.dimensions[2])
|
||||
+ obj.lowest_corner[2],
|
||||
((((8.0 / 32.0) * z as f32) + (3.0 / 32.0)) * obj.dimensions[2])
|
||||
+ obj.lowest_corner[2],
|
||||
((((8.0 / 32.0) * z as f32) + (4.0 / 32.0)) * obj.dimensions[2])
|
||||
+ obj.lowest_corner[2],
|
||||
((((8.0 / 32.0) * z as f32) + (5.0 / 32.0)) * obj.dimensions[2])
|
||||
+ obj.lowest_corner[2],
|
||||
((((8.0 / 32.0) * z as f32) + (6.0 / 32.0)) * obj.dimensions[2])
|
||||
+ obj.lowest_corner[2],
|
||||
((((8.0 / 32.0) * z as f32) + (7.0 / 32.0)) * obj.dimensions[2])
|
||||
+ obj.lowest_corner[2],
|
||||
((((8.0 / 32.0) * z as f32) + (8.0 / 32.0)) * obj.dimensions[2])
|
||||
+ obj.lowest_corner[2],
|
||||
]),
|
||||
);
|
||||
|
||||
for x in 0..8 {
|
||||
for y in 0..8 {
|
||||
let interval_input_z: Interval = Interval::new_unchecked(
|
||||
interpreter::Value::from_array([
|
||||
(0.0 / 8.0) * push_constants.dimensions[2] + push_constants.lowest_corner[2],
|
||||
(1.0 / 8.0) * push_constants.dimensions[2] + push_constants.lowest_corner[2],
|
||||
(2.0 / 8.0) * push_constants.dimensions[2] + push_constants.lowest_corner[2],
|
||||
(3.0 / 8.0) * push_constants.dimensions[2] + push_constants.lowest_corner[2],
|
||||
(4.0 / 8.0) * push_constants.dimensions[2] + push_constants.lowest_corner[2],
|
||||
(5.0 / 8.0) * push_constants.dimensions[2] + push_constants.lowest_corner[2],
|
||||
(6.0 / 8.0) * push_constants.dimensions[2] + push_constants.lowest_corner[2],
|
||||
(7.0 / 8.0) * push_constants.dimensions[2] + push_constants.lowest_corner[2],
|
||||
]),
|
||||
interpreter::Value::from_array([
|
||||
(1.0 / 8.0) * push_constants.dimensions[2] + push_constants.lowest_corner[2],
|
||||
(2.0 / 8.0) * push_constants.dimensions[2] + push_constants.lowest_corner[2],
|
||||
(3.0 / 8.0) * push_constants.dimensions[2] + push_constants.lowest_corner[2],
|
||||
(4.0 / 8.0) * push_constants.dimensions[2] + push_constants.lowest_corner[2],
|
||||
(5.0 / 8.0) * push_constants.dimensions[2] + push_constants.lowest_corner[2],
|
||||
(6.0 / 8.0) * push_constants.dimensions[2] + push_constants.lowest_corner[2],
|
||||
(7.0 / 8.0) * push_constants.dimensions[2] + push_constants.lowest_corner[2],
|
||||
(8.0 / 8.0) * push_constants.dimensions[2] + push_constants.lowest_corner[2],
|
||||
]),
|
||||
);
|
||||
let mut interpreter = IntervalInterpreter::new(csg);
|
||||
let output = interpreter.scene(
|
||||
Interval::const_splat2(
|
||||
(x as f32 / 32.0) * obj.dimensions[0] + obj.lowest_corner[0],
|
||||
((x + 1) as f32 / 32.0) * obj.dimensions[0] + obj.lowest_corner[0],
|
||||
),
|
||||
Interval::const_splat2(
|
||||
(y as f32 / 32.0) * obj.dimensions[1] + obj.lowest_corner[1],
|
||||
((y + 1) as f32 / 32.0) * obj.dimensions[1] + obj.lowest_corner[1],
|
||||
),
|
||||
interval_input_z,
|
||||
Interval::const_splat(time),
|
||||
);
|
||||
|
||||
let mut interpreter = IntervalInterpreter::new(csg);
|
||||
let output = interpreter.scene(
|
||||
Interval::const_splat2(
|
||||
(x as f32 / 8.0) * push_constants.dimensions[0]
|
||||
+ push_constants.lowest_corner[0],
|
||||
((x + 1) as f32 / 8.0) * push_constants.dimensions[0]
|
||||
+ push_constants.lowest_corner[0],
|
||||
),
|
||||
Interval::const_splat2(
|
||||
(y as f32 / 8.0) * push_constants.dimensions[1]
|
||||
+ push_constants.lowest_corner[1],
|
||||
((y + 1) as f32 / 8.0) * push_constants.dimensions[1]
|
||||
+ push_constants.lowest_corner[1],
|
||||
),
|
||||
interval_input_z,
|
||||
Interval::const_splat(time),
|
||||
);
|
||||
|
||||
let output = ((output.lower().simd_le(VALUE_0) & output.upper().simd_ge(VALUE_0))
|
||||
.to_bitmask() as u32)
|
||||
<< ((y & 0b11) * 8);
|
||||
push_constants.enable[(x << 1) | (y >> 2)] |= output;
|
||||
let output = ((output.lower().simd_le(VALUE_0) & output.upper().simd_ge(VALUE_0))
|
||||
.to_bitmask() as u32)
|
||||
<< (z * 8);
|
||||
obj.enable[(x << 3) | (y >> 2)][y & 0b11] |= output;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*csg.enable_buffer[frame_index].write().unwrap() = obj;
|
||||
}
|
||||
|
||||
fn sdf_specialize_module(
|
||||
|
||||
+3
-2
@@ -3,6 +3,7 @@
|
||||
#version 460
|
||||
#extension GL_GOOGLE_include_directive:require
|
||||
#include "include.glsl"
|
||||
#include "implicit_include.glsl"
|
||||
|
||||
layout(location = 0) in vec4 pos;
|
||||
|
||||
@@ -17,7 +18,7 @@ float scene(vec4 p) {
|
||||
const float EPSILON = .0001;
|
||||
const uint MAX_STEPS = 50;
|
||||
const float NEARPLANE = 0.;
|
||||
float FARPLANE = length(pc.dimensions / 8.);
|
||||
float FARPLANE = length(object_uniforms.dimensions / 8.);
|
||||
|
||||
vec2 spheretracing(vec3 ori, vec3 dir, out vec3 p) {
|
||||
vec2 td = vec2(NEARPLANE, 1.);
|
||||
@@ -46,7 +47,7 @@ void main() {
|
||||
{
|
||||
vec4 tpoint = camera_uniforms.proj_view * pc.world * vec4(p, 1);
|
||||
gl_FragDepth = (tpoint.z / tpoint.w);
|
||||
material = pc.material;
|
||||
material = object_uniforms.material;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user