mirror of
https://github.com/slendidev/lunar.git
synced 2025-12-08 10:29:52 +02:00
@@ -99,6 +99,41 @@ auto GraphicsPipelineBuilder::disable_blending() -> GraphicsPipelineBuilder &
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto GraphicsPipelineBuilder::enable_blending_additive()
|
||||
-> GraphicsPipelineBuilder &
|
||||
{
|
||||
m_color_blend_attachment.colorWriteMask = VK_COLOR_COMPONENT_R_BIT
|
||||
| VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT
|
||||
| VK_COLOR_COMPONENT_A_BIT;
|
||||
m_color_blend_attachment.blendEnable = VK_TRUE;
|
||||
m_color_blend_attachment.srcColorBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA;
|
||||
m_color_blend_attachment.dstColorBlendFactor = VK_BLEND_FACTOR_ONE;
|
||||
m_color_blend_attachment.colorBlendOp = VK_BLEND_OP_ADD;
|
||||
m_color_blend_attachment.srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE;
|
||||
m_color_blend_attachment.dstAlphaBlendFactor = VK_BLEND_FACTOR_ZERO;
|
||||
m_color_blend_attachment.alphaBlendOp = VK_BLEND_OP_ADD;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto GraphicsPipelineBuilder::enable_blending_alpha_blend()
|
||||
-> GraphicsPipelineBuilder &
|
||||
{
|
||||
m_color_blend_attachment.colorWriteMask = VK_COLOR_COMPONENT_R_BIT
|
||||
| VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT
|
||||
| VK_COLOR_COMPONENT_A_BIT;
|
||||
m_color_blend_attachment.blendEnable = VK_TRUE;
|
||||
m_color_blend_attachment.srcColorBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA;
|
||||
m_color_blend_attachment.dstColorBlendFactor
|
||||
= VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
|
||||
m_color_blend_attachment.colorBlendOp = VK_BLEND_OP_ADD;
|
||||
m_color_blend_attachment.srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE;
|
||||
m_color_blend_attachment.dstAlphaBlendFactor = VK_BLEND_FACTOR_ZERO;
|
||||
m_color_blend_attachment.alphaBlendOp = VK_BLEND_OP_ADD;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto GraphicsPipelineBuilder::set_color_attachment_format(VkFormat format)
|
||||
-> GraphicsPipelineBuilder &
|
||||
{
|
||||
|
||||
@@ -26,6 +26,8 @@ struct GraphicsPipelineBuilder {
|
||||
-> GraphicsPipelineBuilder &;
|
||||
auto set_multisampling_none() -> GraphicsPipelineBuilder &;
|
||||
auto disable_blending() -> GraphicsPipelineBuilder &;
|
||||
auto enable_blending_additive() -> GraphicsPipelineBuilder &;
|
||||
auto enable_blending_alpha_blend() -> GraphicsPipelineBuilder &;
|
||||
auto set_color_attachment_format(VkFormat format)
|
||||
-> GraphicsPipelineBuilder &;
|
||||
auto set_depth_format(VkFormat format) -> GraphicsPipelineBuilder &;
|
||||
|
||||
@@ -417,7 +417,7 @@ auto VulkanRenderer::triangle_pipeline_init() -> void
|
||||
.set_input_topology(VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST)
|
||||
.set_polygon_mode(VK_POLYGON_MODE_FILL)
|
||||
.set_multisampling_none()
|
||||
.disable_blending()
|
||||
.enable_blending_additive()
|
||||
.disable_depth_testing()
|
||||
.set_color_attachment_format(m_vk.draw_image.format)
|
||||
.set_depth_format(m_vk.depth_image.format)
|
||||
@@ -781,8 +781,8 @@ auto VulkanRenderer::draw_geometry(VkCommandBuffer cmd) -> void
|
||||
|
||||
GPUDrawPushConstants push_constants;
|
||||
auto rect_model { smath::scale(
|
||||
smath::translate(smath::Vec3 { 0.0f, 0.0f, -5.0f }),
|
||||
smath::Vec3 { 5.0f, 5.0f, 1.0f }) };
|
||||
smath::translate(smath::Vec3 { 0.0f, 0.0f, -5.0f }),
|
||||
smath::Vec3 { 5.0f, 5.0f, 1.0f }) };
|
||||
push_constants.world_matrix = view_projection * rect_model;
|
||||
push_constants.vertex_buffer = m_vk.rectangle.vertex_buffer_address;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user