Different scene, toon shading and separate parameters for color input attachment
This commit is contained in:
parent
bdb9af7ef7
commit
0fb88d5467
8 changed files with 74 additions and 31 deletions
|
|
@ -36,7 +36,6 @@ public:
|
|||
vks::VERTEX_COMPONENT_POSITION,
|
||||
vks::VERTEX_COMPONENT_COLOR,
|
||||
vks::VERTEX_COMPONENT_NORMAL,
|
||||
vks::VERTEX_COMPONENT_UV,
|
||||
});
|
||||
|
||||
vks::Model scene;
|
||||
|
|
@ -48,6 +47,7 @@ public:
|
|||
} uboMatrices;
|
||||
|
||||
struct UBOParams {
|
||||
glm::vec2 brightnessContrast = glm::vec2(0.5f, 1.8f);
|
||||
glm::vec2 range = glm::vec2(0.6f, 1.0f);
|
||||
int32_t attachmentIndex = 1;
|
||||
} uboParams;
|
||||
|
|
@ -68,7 +68,6 @@ public:
|
|||
} pipelineLayouts;
|
||||
|
||||
struct {
|
||||
VkDescriptorSet attachmentWrite;
|
||||
VkDescriptorSet attachmentRead;
|
||||
} descriptorSets;
|
||||
|
||||
|
|
@ -93,12 +92,9 @@ public:
|
|||
{
|
||||
title = "Input attachments";
|
||||
camera.type = Camera::CameraType::firstperson;
|
||||
camera.movementSpeed = 5.0f;
|
||||
#ifndef __ANDROID__
|
||||
camera.rotationSpeed = 0.25f;
|
||||
#endif
|
||||
camera.setPosition(glm::vec3(-3.2f, 1.0f, 5.9f));
|
||||
camera.setRotation(glm::vec3(0.5f, 210.05f, 0.0f));
|
||||
camera.movementSpeed = 2.5f;
|
||||
camera.setPosition(glm::vec3(1.65f, 1.75f, -6.15f));
|
||||
camera.setRotation(glm::vec3(-12.75f, 380.0f, 0.0f));
|
||||
camera.setPerspective(60.0f, (float)width / (float)height, 0.1f, 256.0f);
|
||||
settings.overlay = true;
|
||||
}
|
||||
|
|
@ -219,6 +215,7 @@ public:
|
|||
std::array<VkAttachmentDescription, 3> attachments{};
|
||||
|
||||
// Swap chain image color attachment
|
||||
// Will be transitioned to present layout
|
||||
attachments[0].format = swapChain.colorFormat;
|
||||
attachments[0].samples = VK_SAMPLE_COUNT_1_BIT;
|
||||
attachments[0].loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
|
||||
|
|
@ -229,6 +226,9 @@ public:
|
|||
attachments[0].finalLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
|
||||
|
||||
// Input attachments
|
||||
// These will be written in the first subpass, transitioned to input attachments
|
||||
// and then read in the secod subpass
|
||||
|
||||
// Color
|
||||
attachments[1].format = this->attachments.color.format;
|
||||
attachments[1].samples = VK_SAMPLE_COUNT_1_BIT;
|
||||
|
|
@ -380,7 +380,7 @@ public:
|
|||
|
||||
/*
|
||||
Second sub pass
|
||||
Reads from the attachments via input attachments
|
||||
Render a full screen quad, reading from the previously written attachments via input attachments
|
||||
*/
|
||||
{
|
||||
vks::debugmarker::beginRegion(drawCmdBuffers[i], "Subpass 1: Reading attachments", glm::vec4(1.0f, 1.0f, 1.0f, 1.0f));
|
||||
|
|
@ -402,7 +402,7 @@ public:
|
|||
|
||||
void loadAssets()
|
||||
{
|
||||
scene.loadFromFile(getAssetPath() + "models/samplebuilding.dae", vertexLayout, 1.0f, vulkanDevice, queue);
|
||||
scene.loadFromFile(getAssetPath() + "models/treasure_smooth.dae", vertexLayout, 1.0f, vulkanDevice, queue);
|
||||
}
|
||||
|
||||
void setupDescriptors()
|
||||
|
|
@ -518,10 +518,9 @@ public:
|
|||
|
||||
// Attribute descriptions
|
||||
std::vector<VkVertexInputAttributeDescription> vertexInputAttributes = {
|
||||
vks::initializers::vertexInputAttributeDescription(0, 0, VK_FORMAT_R32G32B32_SFLOAT, 0), // Location 0: Position
|
||||
vks::initializers::vertexInputAttributeDescription(0, 1, VK_FORMAT_R32G32B32_SFLOAT, sizeof(float) * 3), // Location 1: Color
|
||||
vks::initializers::vertexInputAttributeDescription(0, 2, VK_FORMAT_R32G32B32_SFLOAT, sizeof(float) * 6), // Location 2: Normal
|
||||
vks::initializers::vertexInputAttributeDescription(0, 3, VK_FORMAT_R32G32_SFLOAT, sizeof(float) * 9), // Location 3: UV
|
||||
vks::initializers::vertexInputAttributeDescription(0, 0, VK_FORMAT_R32G32B32_SFLOAT, 0), // Location 0: Position
|
||||
vks::initializers::vertexInputAttributeDescription(0, 1, VK_FORMAT_R32G32B32_SFLOAT, sizeof(float) * 3), // Location 1: Color
|
||||
vks::initializers::vertexInputAttributeDescription(0, 2, VK_FORMAT_R32G32B32_SFLOAT, sizeof(float) * 6), // Location 2: Normal
|
||||
};
|
||||
|
||||
VkPipelineVertexInputStateCreateInfo vertexInputStateCI = vks::initializers::pipelineVertexInputStateCreateInfo();
|
||||
|
|
@ -624,15 +623,30 @@ public:
|
|||
virtual void OnUpdateUIOverlay(vks::UIOverlay *overlay)
|
||||
{
|
||||
if (overlay->header("Settings")) {
|
||||
if (overlay->comboBox("Attachment", &uboParams.attachmentIndex, { "color", "depth" })) {
|
||||
overlay->text("Input attachment");
|
||||
if (overlay->comboBox("##attachment", &uboParams.attachmentIndex, { "color", "depth" })) {
|
||||
updateUniformBuffers();
|
||||
}
|
||||
overlay->text("Visible range");
|
||||
if (overlay->sliderFloat("min", &uboParams.range[0], 0.0f, uboParams.range[1])) {
|
||||
updateUniformBuffers();
|
||||
}
|
||||
if (overlay->sliderFloat("max", &uboParams.range[1], uboParams.range[0], 1.0f)) {
|
||||
updateUniformBuffers();
|
||||
switch (uboParams.attachmentIndex) {
|
||||
case 0:
|
||||
overlay->text("Brightness");
|
||||
if (overlay->sliderFloat("##b", &uboParams.brightnessContrast[0], 0.0f, 2.0f)) {
|
||||
updateUniformBuffers();
|
||||
}
|
||||
overlay->text("Contrast");
|
||||
if (overlay->sliderFloat("##c", &uboParams.brightnessContrast[1], 0.0f, 4.0f)) {
|
||||
updateUniformBuffers();
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
overlay->text("Visible range");
|
||||
if (overlay->sliderFloat("min", &uboParams.range[0], 0.0f, uboParams.range[1])) {
|
||||
updateUniformBuffers();
|
||||
}
|
||||
if (overlay->sliderFloat("max", &uboParams.range[1], uboParams.range[0], 1.0f)) {
|
||||
updateUniformBuffers();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue