working on additive blending for determination of winding order. Saving here because this bug is very pretty
This commit is contained in:
@@ -7,7 +7,12 @@ layout(location = 0) in vec4 out_color;
|
|||||||
layout(location = 0) out vec4 f_color;
|
layout(location = 0) out vec4 f_color;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
f_color = out_color;
|
if (int(out_color.w) % 2 == 0) {
|
||||||
|
|
||||||
|
f_color = out_color;
|
||||||
|
f_color.w = 255.0;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ layout(location = 0) out vec4 out_color;
|
|||||||
void main() {
|
void main() {
|
||||||
out_color = color;
|
out_color = color;
|
||||||
gl_Position = vec4(v_position, 1.0);
|
gl_Position = vec4(v_position, 1.0);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -8,5 +8,13 @@ layout(location = 0) in vec4 out_color;
|
|||||||
layout(location = 0) out vec4 f_color;
|
layout(location = 0) out vec4 f_color;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
f_color = out_color;
|
|
||||||
|
|
||||||
|
if (int(out_color.w) % 2 == 0) {
|
||||||
|
|
||||||
|
f_color = out_color;
|
||||||
|
f_color.w = 255.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//f_color = out_color;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -392,7 +392,7 @@ impl CanvasState {
|
|||||||
let mut image_vertex_buffer: HashMap<Arc<CanvasImageHandle>, Vec<ImageVertex3D>> = HashMap::new();
|
let mut image_vertex_buffer: HashMap<Arc<CanvasImageHandle>, Vec<ImageVertex3D>> = HashMap::new();
|
||||||
let mut text_instances: HashMap<Arc<CanvasFontHandle>, Vec<TextVertex3D>> = HashMap::new();
|
let mut text_instances: HashMap<Arc<CanvasFontHandle>, Vec<TextVertex3D>> = HashMap::new();
|
||||||
|
|
||||||
let mut text_vertex_buffer: Vec<TextVertex3D> = Vec::new();
|
let mut text_vertex_buffer: Vec<ColorVertex3D> = Vec::new();
|
||||||
|
|
||||||
for value in canvas_frame.map {
|
for value in canvas_frame.map {
|
||||||
match value {
|
match value {
|
||||||
@@ -542,29 +542,58 @@ impl CanvasState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.dynamic_state = DynamicState {
|
|
||||||
line_width: None,
|
|
||||||
viewports: self.dynamic_state.viewports.clone(),
|
|
||||||
scissors: None,
|
|
||||||
compare_mask: Some(DynamicStencilValue {
|
|
||||||
face: StencilFaceFlags::StencilFrontAndBack,
|
|
||||||
value: 0xFF,
|
|
||||||
}),
|
|
||||||
write_mask: Some(DynamicStencilValue {
|
|
||||||
face: StencilFaceFlags::StencilFrontAndBack,
|
|
||||||
value: 0xFF,
|
|
||||||
}),
|
|
||||||
reference: Some(DynamicStencilValue {
|
|
||||||
face: StencilFaceFlags::StencilFrontAndBack,
|
|
||||||
value: 0xFF,
|
|
||||||
}),
|
|
||||||
};
|
|
||||||
|
|
||||||
// Text
|
// Text
|
||||||
let mut shader = self.shader_buffers.get(
|
let mut shader = self.shader_buffers.get(
|
||||||
self.get_shader_handle(String::from("simple_text"))
|
self.get_shader_handle(String::from("simple_text"))
|
||||||
.unwrap().clone().get_handle() as usize
|
.unwrap().clone().get_handle() as usize
|
||||||
).unwrap();
|
).unwrap();
|
||||||
|
//
|
||||||
|
// self.dynamic_state = DynamicState {
|
||||||
|
// line_width: None,
|
||||||
|
// viewports: self.dynamic_state.viewports.clone(),
|
||||||
|
// scissors: None,
|
||||||
|
// compare_mask: Some(DynamicStencilValue {
|
||||||
|
// face: StencilFaceFlags::StencilFrontAndBack,
|
||||||
|
// value: 0x00,
|
||||||
|
// }),
|
||||||
|
// write_mask: Some(DynamicStencilValue {
|
||||||
|
// face: StencilFaceFlags::StencilFrontAndBack,
|
||||||
|
// value: 0xFF,
|
||||||
|
// }),
|
||||||
|
// reference: Some(DynamicStencilValue {
|
||||||
|
// face: StencilFaceFlags::StencilFrontAndBack,
|
||||||
|
// value: 0x00,
|
||||||
|
// }),
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// if !allocated_buffers.text_vertex_buffer.is_empty() {
|
||||||
|
// command_buffer = command_buffer.draw(
|
||||||
|
// shader.get_pipeline().clone(),
|
||||||
|
// &self.dynamic_state.clone(),
|
||||||
|
// allocated_buffers.text_vertex_buffer.clone(),
|
||||||
|
// (), (),
|
||||||
|
// ).unwrap();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// self.dynamic_state = DynamicState {
|
||||||
|
// line_width: None,
|
||||||
|
// viewports: self.dynamic_state.viewports.clone(),
|
||||||
|
// scissors: None,
|
||||||
|
// compare_mask: Some(DynamicStencilValue {
|
||||||
|
// face: StencilFaceFlags::StencilFrontAndBack,
|
||||||
|
// value: 0xFF,
|
||||||
|
// }),
|
||||||
|
// write_mask: Some(DynamicStencilValue {
|
||||||
|
// face: StencilFaceFlags::StencilFrontAndBack,
|
||||||
|
// value: 0x00,
|
||||||
|
// }),
|
||||||
|
// reference: Some(DynamicStencilValue {
|
||||||
|
// face: StencilFaceFlags::StencilFrontAndBack,
|
||||||
|
// value: 0x00,
|
||||||
|
// }),
|
||||||
|
// };
|
||||||
|
|
||||||
if !allocated_buffers.text_vertex_buffer.is_empty() {
|
if !allocated_buffers.text_vertex_buffer.is_empty() {
|
||||||
command_buffer = command_buffer.draw(
|
command_buffer = command_buffer.draw(
|
||||||
@@ -575,6 +604,7 @@ impl CanvasState {
|
|||||||
).unwrap();
|
).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
command_buffer
|
command_buffer
|
||||||
.end_render_pass()
|
.end_render_pass()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ use crate::canvas::managed::shader::generic_shader::GenericShader;
|
|||||||
use crate::canvas::managed::shader::dynamic_vertex::RuntimeVertexDef;
|
use crate::canvas::managed::shader::dynamic_vertex::RuntimeVertexDef;
|
||||||
use crate::canvas::managed::ShaderSpecializationConstants;
|
use crate::canvas::managed::ShaderSpecializationConstants;
|
||||||
use crate::util::vertex::ColorVertex3D;
|
use crate::util::vertex::ColorVertex3D;
|
||||||
|
use vulkano::pipeline::blend::{LogicOp, AttachmentBlend, BlendOp, BlendFactor};
|
||||||
|
|
||||||
|
|
||||||
/// CanvasShader holds the pipeline and render pass for the input shader source
|
/// CanvasShader holds the pipeline and render pass for the input shader source
|
||||||
@@ -80,19 +81,19 @@ impl CompiledShader for TextShader {
|
|||||||
depth_write: true,
|
depth_write: true,
|
||||||
depth_bounds_test: DepthBounds::Disabled,
|
depth_bounds_test: DepthBounds::Disabled,
|
||||||
stencil_front: Stencil {
|
stencil_front: Stencil {
|
||||||
compare: Compare::Equal,
|
compare: Compare::NotEqual,
|
||||||
pass_op: StencilOp::IncrementAndWrap,
|
pass_op: StencilOp::Keep,
|
||||||
fail_op: StencilOp::DecrementAndClamp,
|
fail_op: StencilOp::IncrementAndWrap,
|
||||||
depth_fail_op: StencilOp::Keep,
|
depth_fail_op: StencilOp::Keep,
|
||||||
compare_mask: None,
|
compare_mask: None,
|
||||||
write_mask: None,
|
write_mask: None,
|
||||||
reference: None,
|
reference: None,
|
||||||
},
|
},
|
||||||
stencil_back: Stencil {
|
stencil_back: Stencil {
|
||||||
compare: Compare::Equal,
|
compare: Compare::NotEqual,
|
||||||
pass_op: StencilOp::Invert,
|
pass_op: StencilOp::Keep,
|
||||||
fail_op: StencilOp::Zero,
|
fail_op: StencilOp::DecrementAndWrap,
|
||||||
depth_fail_op: StencilOp::Zero,
|
depth_fail_op: StencilOp::Keep,
|
||||||
compare_mask: None,
|
compare_mask: None,
|
||||||
write_mask: None,
|
write_mask: None,
|
||||||
reference: None,
|
reference: None,
|
||||||
@@ -101,6 +102,21 @@ impl CompiledShader for TextShader {
|
|||||||
|
|
||||||
let vertex_definition = RuntimeVertexDef::from_primitive(0);
|
let vertex_definition = RuntimeVertexDef::from_primitive(0);
|
||||||
|
|
||||||
|
|
||||||
|
let blend = AttachmentBlend {
|
||||||
|
enabled: true,
|
||||||
|
color_op: BlendOp::Add,
|
||||||
|
color_source: BlendFactor::SrcAlpha,
|
||||||
|
color_destination: BlendFactor::OneMinusSrcAlpha,
|
||||||
|
alpha_op: BlendOp::Add,
|
||||||
|
alpha_source: BlendFactor::SrcAlpha,
|
||||||
|
alpha_destination: BlendFactor::OneMinusSrcAlpha,
|
||||||
|
mask_red: true,
|
||||||
|
mask_green: true,
|
||||||
|
mask_blue: true,
|
||||||
|
mask_alpha: true,
|
||||||
|
};
|
||||||
|
|
||||||
TextShader {
|
TextShader {
|
||||||
graphics_pipeline:
|
graphics_pipeline:
|
||||||
Some(Arc::new(GraphicsPipeline::start()
|
Some(Arc::new(GraphicsPipeline::start()
|
||||||
@@ -124,8 +140,9 @@ impl CompiledShader for TextShader {
|
|||||||
third_constant: 0.0,
|
third_constant: 0.0,
|
||||||
})
|
})
|
||||||
|
|
||||||
.depth_stencil(stencil)
|
.depth_stencil_simple_depth()
|
||||||
|
.blend_collective(blend)
|
||||||
|
.blend_logic_op(LogicOp::And)
|
||||||
// We have to indicate which subpass of which render pass this pipeline is going to be used
|
// We have to indicate which subpass of which render pass this pipeline is going to be used
|
||||||
// in. The pipeline will only be usable from this particular subpass.
|
// in. The pipeline will only be usable from this particular subpass.
|
||||||
.render_pass(Subpass::from(render_pass.clone(), 0).unwrap())
|
.render_pass(Subpass::from(render_pass.clone(), 0).unwrap())
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ impl Text {
|
|||||||
},
|
},
|
||||||
ColorVertex3D {
|
ColorVertex3D {
|
||||||
v_position: [-1.0, 1.0, normalized_depth],
|
v_position: [-1.0, 1.0, normalized_depth],
|
||||||
color: [1.0, 1.0, 1.0, 1.0],
|
color: [1.0, 0.8, 1.0, 1.0],
|
||||||
},
|
},
|
||||||
ColorVertex3D {
|
ColorVertex3D {
|
||||||
v_position: [-0.25, 0.0, normalized_depth],
|
v_position: [-0.25, 0.0, normalized_depth],
|
||||||
@@ -34,7 +34,7 @@ impl Text {
|
|||||||
},
|
},
|
||||||
ColorVertex3D {
|
ColorVertex3D {
|
||||||
v_position: [-0.25, 0.0, normalized_depth],
|
v_position: [-0.25, 0.0, normalized_depth],
|
||||||
color: [1.0, 1.0, 1.0, 1.0],
|
color: [0.8, 1.0, 1.0, 1.0],
|
||||||
},
|
},
|
||||||
ColorVertex3D {
|
ColorVertex3D {
|
||||||
v_position: [-1.0, 1.0, normalized_depth],
|
v_position: [-1.0, 1.0, normalized_depth],
|
||||||
@@ -42,7 +42,7 @@ impl Text {
|
|||||||
},
|
},
|
||||||
ColorVertex3D {
|
ColorVertex3D {
|
||||||
v_position: [0.0, 0.5, normalized_depth],
|
v_position: [0.0, 0.5, normalized_depth],
|
||||||
color: [1.0, 1.0, 1.0, 1.0],
|
color: [1.0, 1.0, 0.8, 1.0],
|
||||||
},
|
},
|
||||||
ColorVertex3D {
|
ColorVertex3D {
|
||||||
v_position: [0.25, 0.0, normalized_depth],
|
v_position: [0.25, 0.0, normalized_depth],
|
||||||
@@ -50,7 +50,7 @@ impl Text {
|
|||||||
},
|
},
|
||||||
ColorVertex3D {
|
ColorVertex3D {
|
||||||
v_position: [-1.0, 1.0, normalized_depth],
|
v_position: [-1.0, 1.0, normalized_depth],
|
||||||
color: [1.0, 1.0, 1.0, 1.0],
|
color: [1.0, 0.8, 1.0, 1.0],
|
||||||
},
|
},
|
||||||
ColorVertex3D {
|
ColorVertex3D {
|
||||||
v_position: [0.0, 0.5, normalized_depth],
|
v_position: [0.0, 0.5, normalized_depth],
|
||||||
@@ -119,7 +119,7 @@ impl Text {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
verts: VertexTypes::ColorType(verts),
|
verts: VertexTypes::TextType(verts),
|
||||||
position: position,
|
position: position,
|
||||||
size: size,
|
size: size,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ pub enum VertexTypes {
|
|||||||
ImageType(Vec<ImageVertex3D>, Arc<CanvasImageHandle>),
|
ImageType(Vec<ImageVertex3D>, Arc<CanvasImageHandle>),
|
||||||
ColorType(Vec<ColorVertex3D>),
|
ColorType(Vec<ColorVertex3D>),
|
||||||
ThreeDType(Vec<Vertex3D>),
|
ThreeDType(Vec<Vertex3D>),
|
||||||
TextType(Vec<TextVertex3D>),
|
TextType(Vec<ColorVertex3D>),
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user