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