--wip-- [skip ci]
This commit is contained in:
+1
-1
@@ -6,7 +6,7 @@ layout(push_constant) uniform PushConstantData {
|
|||||||
vec3 dimensions;
|
vec3 dimensions;
|
||||||
vec3 lowest_corner;
|
vec3 lowest_corner;
|
||||||
uint enable[16];
|
uint enable[16];
|
||||||
float material;
|
uint material;
|
||||||
} pc;
|
} pc;
|
||||||
|
|
||||||
layout(set = 0, binding = 0) uniform Lights {
|
layout(set = 0, binding = 0) uniform Lights {
|
||||||
|
|||||||
+31
-71
@@ -46,7 +46,7 @@ use vulkano::{
|
|||||||
Device, DeviceCreateInfo, DeviceExtensions, DeviceFeatures, DeviceOwned, Queue,
|
Device, DeviceCreateInfo, DeviceExtensions, DeviceFeatures, DeviceOwned, Queue,
|
||||||
QueueCreateInfo, QueueFlags, physical::PhysicalDeviceType,
|
QueueCreateInfo, QueueFlags, physical::PhysicalDeviceType,
|
||||||
},
|
},
|
||||||
format::Format,
|
format::{ClearValue, Format},
|
||||||
image::{
|
image::{
|
||||||
Image, ImageCreateInfo, ImageType, ImageUsage, SampleCount,
|
Image, ImageCreateInfo, ImageType, ImageUsage, SampleCount,
|
||||||
view::{ImageView, ImageViewCreateInfo},
|
view::{ImageView, ImageViewCreateInfo},
|
||||||
@@ -214,8 +214,7 @@ struct RenderContext {
|
|||||||
render_pass: Arc<RenderPass>,
|
render_pass: Arc<RenderPass>,
|
||||||
framebuffers: Vec<Arc<Framebuffer>>,
|
framebuffers: Vec<Arc<Framebuffer>>,
|
||||||
color_buffer: Arc<ImageView>,
|
color_buffer: Arc<ImageView>,
|
||||||
material_colour_buffer: Arc<ImageView>,
|
material: Arc<ImageView>,
|
||||||
material_depth_buffer: Arc<ImageView>,
|
|
||||||
normal_buffer: Arc<ImageView>,
|
normal_buffer: Arc<ImageView>,
|
||||||
depth_buffer: Arc<ImageView>,
|
depth_buffer: Arc<ImageView>,
|
||||||
shader_modules: ShaderModules,
|
shader_modules: ShaderModules,
|
||||||
@@ -787,18 +786,12 @@ impl ApplicationHandler for App {
|
|||||||
load_op: Clear,
|
load_op: Clear,
|
||||||
store_op: Store,
|
store_op: Store,
|
||||||
},
|
},
|
||||||
material_as_colour: {
|
material: {
|
||||||
format: Format::R16_UNORM,
|
format: Format::R16_UINT,
|
||||||
samples: 1,
|
samples: 1,
|
||||||
load_op: Clear,
|
load_op: Clear,
|
||||||
store_op: DontCare,
|
store_op: DontCare,
|
||||||
},
|
},
|
||||||
material_as_depth: {
|
|
||||||
format: Format::D,
|
|
||||||
samples: 1,
|
|
||||||
load_op: Load,
|
|
||||||
store_op: DontCare,
|
|
||||||
},
|
|
||||||
color: {
|
color: {
|
||||||
format: Format::A2B10G10R10_UNORM_PACK32,
|
format: Format::A2B10G10R10_UNORM_PACK32,
|
||||||
samples: 1,
|
samples: 1,
|
||||||
@@ -819,14 +812,14 @@ impl ApplicationHandler for App {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
passes: [{
|
passes: [{
|
||||||
color: [material_as_colour],
|
color: [material],
|
||||||
depth_stencil: {depth},
|
depth_stencil: {depth},
|
||||||
input: [],
|
input: [],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
color: [color, normals],
|
color: [color, normals],
|
||||||
depth_stencil: {material_as_depth},
|
depth_stencil: {},
|
||||||
input: [depth],
|
input: [material, depth],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
color: [final_color],
|
color: [final_color],
|
||||||
@@ -847,14 +840,8 @@ impl ApplicationHandler for App {
|
|||||||
depth_range: 0.0..=1.0,
|
depth_range: 0.0..=1.0,
|
||||||
};
|
};
|
||||||
|
|
||||||
let (
|
let (framebuffers, color_buffer, material, normal_buffer, depth_buffer) =
|
||||||
framebuffers,
|
framebuffer_generation(&images, &render_pass, &self.memory_allocator);
|
||||||
color_buffer,
|
|
||||||
material_colour_buffer,
|
|
||||||
material_depth_buffer,
|
|
||||||
normal_buffer,
|
|
||||||
depth_buffer,
|
|
||||||
) = framebuffer_generation(&images, &render_pass, &self.memory_allocator);
|
|
||||||
|
|
||||||
let lighting_pipeline = pipeline_recompile(
|
let lighting_pipeline = pipeline_recompile(
|
||||||
&render_pass,
|
&render_pass,
|
||||||
@@ -886,8 +873,7 @@ impl ApplicationHandler for App {
|
|||||||
render_pass,
|
render_pass,
|
||||||
framebuffers,
|
framebuffers,
|
||||||
color_buffer,
|
color_buffer,
|
||||||
material_colour_buffer,
|
material,
|
||||||
material_depth_buffer,
|
|
||||||
normal_buffer,
|
normal_buffer,
|
||||||
depth_buffer,
|
depth_buffer,
|
||||||
shader_modules,
|
shader_modules,
|
||||||
@@ -1057,8 +1043,7 @@ impl App {
|
|||||||
(
|
(
|
||||||
rcx.framebuffers,
|
rcx.framebuffers,
|
||||||
rcx.color_buffer,
|
rcx.color_buffer,
|
||||||
rcx.material_colour_buffer,
|
rcx.material,
|
||||||
rcx.material_depth_buffer,
|
|
||||||
rcx.normal_buffer,
|
rcx.normal_buffer,
|
||||||
rcx.depth_buffer,
|
rcx.depth_buffer,
|
||||||
) = framebuffer_generation(&new_images, &rcx.render_pass, &self.memory_allocator);
|
) = framebuffer_generation(&new_images, &rcx.render_pass, &self.memory_allocator);
|
||||||
@@ -1202,7 +1187,7 @@ impl App {
|
|||||||
dimensions: Vec3::ONE.to_array().into(),
|
dimensions: Vec3::ONE.to_array().into(),
|
||||||
lowest_corner: Vec3::ZERO.into(),
|
lowest_corner: Vec3::ZERO.into(),
|
||||||
enable: [0; 16],
|
enable: [0; 16],
|
||||||
material: 0.,
|
material: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
let uniform_data = implicit_vs::Camera {
|
let uniform_data = implicit_vs::Camera {
|
||||||
@@ -1351,6 +1336,7 @@ impl App {
|
|||||||
RenderPassBeginInfo {
|
RenderPassBeginInfo {
|
||||||
clear_values: vec![
|
clear_values: vec![
|
||||||
Some([0.0, 0.0, 0.0, 1.0].into()),
|
Some([0.0, 0.0, 0.0, 1.0].into()),
|
||||||
|
Some(ClearValue::Uint([0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF])),
|
||||||
Some([0.12, 0.1, 0.1, 1.0].into()),
|
Some([0.12, 0.1, 0.1, 1.0].into()),
|
||||||
Some([0.0, 0.0, 0.0, 1.0].into()),
|
Some([0.0, 0.0, 0.0, 1.0].into()),
|
||||||
Some(1.0.into()),
|
Some(1.0.into()),
|
||||||
@@ -1534,7 +1520,6 @@ fn framebuffer_generation(
|
|||||||
Arc<ImageView>,
|
Arc<ImageView>,
|
||||||
Arc<ImageView>,
|
Arc<ImageView>,
|
||||||
Arc<ImageView>,
|
Arc<ImageView>,
|
||||||
Arc<ImageView>,
|
|
||||||
) {
|
) {
|
||||||
let depth_buffer = ImageView::new_default(
|
let depth_buffer = ImageView::new_default(
|
||||||
Image::new(
|
Image::new(
|
||||||
@@ -1572,38 +1557,21 @@ fn framebuffer_generation(
|
|||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let material_image = Image::new(
|
let material_buffer = ImageView::new_default(
|
||||||
allocator.clone(),
|
Image::new(
|
||||||
ImageCreateInfo {
|
allocator.clone(),
|
||||||
image_type: ImageType::Dim2d,
|
ImageCreateInfo {
|
||||||
format: Format::D16_UNORM,
|
image_type: ImageType::Dim2d,
|
||||||
extent: images[0].extent(),
|
format: Format::R16_UINT,
|
||||||
usage: ImageUsage::COLOR_ATTACHMENT
|
extent: images[0].extent(),
|
||||||
| ImageUsage::DEPTH_STENCIL_ATTACHMENT
|
usage: ImageUsage::COLOR_ATTACHMENT
|
||||||
| ImageUsage::TRANSIENT_ATTACHMENT,
|
| ImageUsage::INPUT_ATTACHMENT
|
||||||
..Default::default()
|
| ImageUsage::TRANSIENT_ATTACHMENT,
|
||||||
},
|
..Default::default()
|
||||||
AllocationCreateInfo::default(),
|
},
|
||||||
)
|
AllocationCreateInfo::default(),
|
||||||
.unwrap();
|
)
|
||||||
|
.unwrap(),
|
||||||
let material_colour_buffer = ImageView::new(
|
|
||||||
material_image.clone(),
|
|
||||||
ImageViewCreateInfo {
|
|
||||||
format: Format::R16_UNORM,
|
|
||||||
usage: ImageUsage::COLOR_ATTACHMENT | ImageUsage::TRANSIENT_ATTACHMENT,
|
|
||||||
..ImageViewCreateInfo::from_image(&material_image)
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let material_depth_buffer = ImageView::new(
|
|
||||||
material_image.clone(),
|
|
||||||
ImageViewCreateInfo {
|
|
||||||
format: Format::D16_UNORM,
|
|
||||||
usage: ImageUsage::DEPTH_STENCIL_ATTACHMENT | ImageUsage::TRANSIENT_ATTACHMENT,
|
|
||||||
..ImageViewCreateInfo::from_image(&material_image)
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
@@ -1634,8 +1602,7 @@ fn framebuffer_generation(
|
|||||||
FramebufferCreateInfo {
|
FramebufferCreateInfo {
|
||||||
attachments: vec![
|
attachments: vec![
|
||||||
view,
|
view,
|
||||||
material_colour_buffer.clone(),
|
material_buffer.clone(),
|
||||||
material_depth_buffer.clone(),
|
|
||||||
color_buffer.clone(),
|
color_buffer.clone(),
|
||||||
normal_buffer.clone(),
|
normal_buffer.clone(),
|
||||||
depth_buffer.clone(),
|
depth_buffer.clone(),
|
||||||
@@ -1650,8 +1617,7 @@ fn framebuffer_generation(
|
|||||||
(
|
(
|
||||||
framebuffers,
|
framebuffers,
|
||||||
color_buffer,
|
color_buffer,
|
||||||
material_colour_buffer,
|
material_buffer,
|
||||||
material_depth_buffer,
|
|
||||||
normal_buffer,
|
normal_buffer,
|
||||||
depth_buffer,
|
depth_buffer,
|
||||||
)
|
)
|
||||||
@@ -1856,13 +1822,7 @@ fn deferred_pipelines_recompile(
|
|||||||
polygon_mode: PolygonMode::Fill,
|
polygon_mode: PolygonMode::Fill,
|
||||||
..RasterizationState::default()
|
..RasterizationState::default()
|
||||||
}),
|
}),
|
||||||
depth_stencil_state: Some(DepthStencilState {
|
depth_stencil_state: None,
|
||||||
depth: Some(DepthState {
|
|
||||||
write_enable: false,
|
|
||||||
compare_op: CompareOp::Equal,
|
|
||||||
}),
|
|
||||||
..Default::default()
|
|
||||||
}),
|
|
||||||
multisample_state: Some(MultisampleState::default()),
|
multisample_state: Some(MultisampleState::default()),
|
||||||
color_blend_state: Some(ColorBlendState::with_attachment_states(
|
color_blend_state: Some(ColorBlendState::with_attachment_states(
|
||||||
normals_subpass.num_color_attachments(),
|
normals_subpass.num_color_attachments(),
|
||||||
|
|||||||
@@ -6,7 +6,8 @@
|
|||||||
|
|
||||||
layout(location = 0) in vec2 v_pos;
|
layout(location = 0) in vec2 v_pos;
|
||||||
|
|
||||||
layout(input_attachment_index = 0, set = 1, binding = 0) uniform subpassInput u_depth;
|
layout(input_attachment_index = 0, set = 1, binding = 0) uniform subpassInput u_material;
|
||||||
|
layout(input_attachment_index = 1, set = 1, binding = 1) uniform subpassInput u_depth;
|
||||||
|
|
||||||
layout(location = 0) out vec4 f_color;
|
layout(location = 0) out vec4 f_color;
|
||||||
layout(location = 1) out vec4 f_normal;
|
layout(location = 1) out vec4 f_normal;
|
||||||
@@ -35,6 +36,10 @@ vec3 getNormal(vec3 p) {
|
|||||||
|
|
||||||
//Implicit Surface Entrypoint
|
//Implicit Surface Entrypoint
|
||||||
void main() {
|
void main() {
|
||||||
|
if (subpassLoad(u_material).x != pc.material) {
|
||||||
|
discard;
|
||||||
|
}
|
||||||
|
|
||||||
float depth = subpassLoad(u_depth).x;
|
float depth = subpassLoad(u_depth).x;
|
||||||
if (depth == 1.0) {
|
if (depth == 1.0) {
|
||||||
discard;
|
discard;
|
||||||
|
|||||||
+1
-1
@@ -8,7 +8,7 @@ layout(location = 0) in vec4 pos;
|
|||||||
|
|
||||||
layout(depth_greater) out float gl_FragDepth;
|
layout(depth_greater) out float gl_FragDepth;
|
||||||
|
|
||||||
layout(location = 0) out float material;
|
layout(location = 0) out uint material;
|
||||||
|
|
||||||
float scene(vec3 p) {
|
float scene(vec3 p) {
|
||||||
return length(p) - 1.0;
|
return length(p) - 1.0;
|
||||||
|
|||||||
Reference in New Issue
Block a user