Adding in simple alpha blending
This commit is contained in:
@@ -95,6 +95,12 @@ GraphicsPipeline::Builder& GraphicsPipeline::Builder::setVertexInput(
|
||||
return *this;
|
||||
}
|
||||
|
||||
GraphicsPipeline::Builder& GraphicsPipeline::Builder::setAlphaBlending(
|
||||
bool enabled) {
|
||||
this->alphaBlending = enabled;
|
||||
return *this;
|
||||
}
|
||||
|
||||
std::unique_ptr<GraphicsPipeline> GraphicsPipeline::Builder::build() const {
|
||||
if (this->vertexShader == nullptr || this->fragmentShader == nullptr) {
|
||||
log::fatal(
|
||||
@@ -128,7 +134,8 @@ std::unique_ptr<GraphicsPipeline> GraphicsPipeline::Builder::build() const {
|
||||
this->device, *this->vertexShader, *this->fragmentShader,
|
||||
this->pipelineLayout, this->colorAttachmentFormats,
|
||||
this->depthAttachmentFormat, this->stencilAttachmentFormat,
|
||||
this->bindingDescriptions, this->attributeDescriptions));
|
||||
this->bindingDescriptions, this->attributeDescriptions,
|
||||
this->alphaBlending));
|
||||
}
|
||||
|
||||
GraphicsPipeline::GraphicsPipeline(
|
||||
@@ -137,10 +144,21 @@ GraphicsPipeline::GraphicsPipeline(
|
||||
std::vector<vk::Format> colorAttachmentFormats,
|
||||
vk::Format depthAttachmentFormat, vk::Format stencilAttachmentFormat,
|
||||
std::vector<vk::VertexInputBindingDescription> bindingDescriptions,
|
||||
std::vector<vk::VertexInputAttributeDescription> attributeDescriptions)
|
||||
std::vector<vk::VertexInputAttributeDescription> attributeDescriptions,
|
||||
bool alphaBlending)
|
||||
: Pipeline(device, vk::PipelineBindPoint::eGraphics) {
|
||||
setDefaultGraphicsPipelineConfig();
|
||||
|
||||
if (alphaBlending) {
|
||||
vk::PipelineColorBlendAttachmentState& blend =
|
||||
this->config.colorBlendAttachment;
|
||||
blend.blendEnable = vk::True;
|
||||
blend.srcColorBlendFactor = vk::BlendFactor::eSrcAlpha;
|
||||
blend.dstColorBlendFactor = vk::BlendFactor::eOneMinusSrcAlpha;
|
||||
blend.srcAlphaBlendFactor = vk::BlendFactor::eOne;
|
||||
blend.dstAlphaBlendFactor = vk::BlendFactor::eOneMinusSrcAlpha;
|
||||
}
|
||||
|
||||
this->config.bindingDescriptions = std::move(bindingDescriptions);
|
||||
this->config.attributeDescriptions = std::move(attributeDescriptions);
|
||||
this->config.pipelineLayout = pipelineLayout;
|
||||
|
||||
Reference in New Issue
Block a user