PBR examples minor tweaks and updated screenshots
This commit is contained in:
parent
4094aa0ea0
commit
230a70cf4b
6 changed files with 14 additions and 26 deletions
|
|
@ -96,8 +96,8 @@ public:
|
||||||
title = "Vulkan Example - Physical based shading basics";
|
title = "Vulkan Example - Physical based shading basics";
|
||||||
enableTextOverlay = true;
|
enableTextOverlay = true;
|
||||||
camera.type = Camera::CameraType::firstperson;
|
camera.type = Camera::CameraType::firstperson;
|
||||||
camera.setPosition(glm::vec3(13.0f, 8.0f, -10.0f));
|
camera.setPosition(glm::vec3(10.0f, 13.0f, 1.8f));
|
||||||
camera.setRotation(glm::vec3(-31.75f, 45.0f, 0.0f));
|
camera.setRotation(glm::vec3(-62.5f, 90.0f, 0.0f));
|
||||||
camera.movementSpeed = 4.0f;
|
camera.movementSpeed = 4.0f;
|
||||||
camera.setPerspective(60.0f, (float)width / (float)height, 0.1f, 256.0f);
|
camera.setPerspective(60.0f, (float)width / (float)height, 0.1f, 256.0f);
|
||||||
camera.rotationSpeed = 0.25f;
|
camera.rotationSpeed = 0.25f;
|
||||||
|
|
@ -118,7 +118,7 @@ public:
|
||||||
materials.push_back(Material("Blue", glm::vec3(0.0f, 0.0f, 1.0f), 0.1f, 1.0f));
|
materials.push_back(Material("Blue", glm::vec3(0.0f, 0.0f, 1.0f), 0.1f, 1.0f));
|
||||||
materials.push_back(Material("Black", glm::vec3(0.0f), 0.1f, 1.0f));
|
materials.push_back(Material("Black", glm::vec3(0.0f), 0.1f, 1.0f));
|
||||||
|
|
||||||
materialIndex = 8;
|
materialIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
~VulkanExample()
|
~VulkanExample()
|
||||||
|
|
@ -138,22 +138,12 @@ public:
|
||||||
uniformBuffers.params.destroy();
|
uniformBuffers.params.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
void reBuildCommandBuffers()
|
|
||||||
{
|
|
||||||
if (!checkCommandBuffers())
|
|
||||||
{
|
|
||||||
destroyCommandBuffers();
|
|
||||||
createCommandBuffers();
|
|
||||||
}
|
|
||||||
buildCommandBuffers();
|
|
||||||
}
|
|
||||||
|
|
||||||
void buildCommandBuffers()
|
void buildCommandBuffers()
|
||||||
{
|
{
|
||||||
VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo();
|
VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo();
|
||||||
|
|
||||||
VkClearValue clearValues[2];
|
VkClearValue clearValues[2];
|
||||||
clearValues[0].color = { { 0.1f, 0.1f, 0.1f, 1.0f } };
|
clearValues[0].color = defaultClearColor;
|
||||||
clearValues[1].depthStencil = { 1.0f, 0 };
|
clearValues[1].depthStencil = { 1.0f, 0 };
|
||||||
|
|
||||||
VkRenderPassBeginInfo renderPassBeginInfo = vks::initializers::renderPassBeginInfo();
|
VkRenderPassBeginInfo renderPassBeginInfo = vks::initializers::renderPassBeginInfo();
|
||||||
|
|
@ -207,7 +197,7 @@ public:
|
||||||
for (uint32_t x = 0; x < GRID_DIM; x++) {
|
for (uint32_t x = 0; x < GRID_DIM; x++) {
|
||||||
glm::vec3 pos = glm::vec3(float(x - (GRID_DIM / 2.0f)) * 2.5f, 0.0f, float(y - (GRID_DIM / 2.0f)) * 2.5f);
|
glm::vec3 pos = glm::vec3(float(x - (GRID_DIM / 2.0f)) * 2.5f, 0.0f, float(y - (GRID_DIM / 2.0f)) * 2.5f);
|
||||||
vkCmdPushConstants(drawCmdBuffers[i], pipelineLayout, VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(glm::vec3), &pos);
|
vkCmdPushConstants(drawCmdBuffers[i], pipelineLayout, VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(glm::vec3), &pos);
|
||||||
mat.params.metallic = (float)x / (float)(GRID_DIM - 1);
|
mat.params.metallic = glm::clamp((float)x / (float)(GRID_DIM - 1), 0.1f, 1.0f);
|
||||||
mat.params.roughness = glm::clamp((float)y / (float)(GRID_DIM - 1), 0.05f, 1.0f);
|
mat.params.roughness = glm::clamp((float)y / (float)(GRID_DIM - 1), 0.05f, 1.0f);
|
||||||
vkCmdPushConstants(drawCmdBuffers[i], pipelineLayout, VK_SHADER_STAGE_FRAGMENT_BIT, sizeof(glm::vec3), sizeof(Material::PushBlock), &mat);
|
vkCmdPushConstants(drawCmdBuffers[i], pipelineLayout, VK_SHADER_STAGE_FRAGMENT_BIT, sizeof(glm::vec3), sizeof(Material::PushBlock), &mat);
|
||||||
vkCmdDrawIndexed(drawCmdBuffers[i], models.objects[models.objectIndex].indexCount, 1, 0, 0, 0);
|
vkCmdDrawIndexed(drawCmdBuffers[i], models.objects[models.objectIndex].indexCount, 1, 0, 0, 0);
|
||||||
|
|
@ -475,7 +465,7 @@ public:
|
||||||
models.objectIndex = 0;
|
models.objectIndex = 0;
|
||||||
}
|
}
|
||||||
updateUniformBuffers();
|
updateUniformBuffers();
|
||||||
reBuildCommandBuffers();
|
buildCommandBuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
void toggleMaterial(int32_t dir)
|
void toggleMaterial(int32_t dir)
|
||||||
|
|
@ -487,7 +477,7 @@ public:
|
||||||
if (materialIndex > static_cast<int32_t>(materials.size()) - 1) {
|
if (materialIndex > static_cast<int32_t>(materials.size()) - 1) {
|
||||||
materialIndex = 0;
|
materialIndex = 0;
|
||||||
}
|
}
|
||||||
reBuildCommandBuffers();
|
buildCommandBuffers();
|
||||||
updateTextOverlay();
|
updateTextOverlay();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ public:
|
||||||
|
|
||||||
struct UBOParams {
|
struct UBOParams {
|
||||||
glm::vec4 lights[4];
|
glm::vec4 lights[4];
|
||||||
float exposure = 2.0f;
|
float exposure = 4.5f;
|
||||||
float gamma = 2.2f;
|
float gamma = 2.2f;
|
||||||
} uboParams;
|
} uboParams;
|
||||||
|
|
||||||
|
|
@ -114,7 +114,7 @@ public:
|
||||||
|
|
||||||
VulkanExample() : VulkanExampleBase(ENABLE_VALIDATION)
|
VulkanExample() : VulkanExampleBase(ENABLE_VALIDATION)
|
||||||
{
|
{
|
||||||
title = "VK PBR IBL";
|
title = "Vulkan Example - PBR with image based lighting";
|
||||||
|
|
||||||
enableTextOverlay = true;
|
enableTextOverlay = true;
|
||||||
camera.type = Camera::CameraType::firstperson;
|
camera.type = Camera::CameraType::firstperson;
|
||||||
|
|
@ -227,13 +227,11 @@ public:
|
||||||
|
|
||||||
#define SINGLE_ROW 1
|
#define SINGLE_ROW 1
|
||||||
#ifdef SINGLE_ROW
|
#ifdef SINGLE_ROW
|
||||||
mat.params.metallic = 1.0;
|
|
||||||
|
|
||||||
uint32_t objcount = 10;
|
uint32_t objcount = 10;
|
||||||
for (uint32_t x = 0; x < objcount; x++) {
|
for (uint32_t x = 0; x < objcount; x++) {
|
||||||
glm::vec3 pos = glm::vec3(float(x - (objcount / 2.0f)) * 2.15f, 0.0f, 0.0f);
|
glm::vec3 pos = glm::vec3(float(x - (objcount / 2.0f)) * 2.15f, 0.0f, 0.0f);
|
||||||
mat.params.roughness = glm::clamp((float)x / (float)objcount, 0.005f, 1.0f);
|
mat.params.roughness = 1.0f-glm::clamp((float)x / (float)objcount, 0.005f, 1.0f);
|
||||||
mat.params.metallic = 1.0f - glm::clamp((float)x / (float)objcount, 0.005f, 1.0f);
|
mat.params.metallic = glm::clamp((float)x / (float)objcount, 0.005f, 1.0f);
|
||||||
vkCmdPushConstants(drawCmdBuffers[i], pipelineLayout, VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(glm::vec3), &pos);
|
vkCmdPushConstants(drawCmdBuffers[i], pipelineLayout, VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(glm::vec3), &pos);
|
||||||
vkCmdPushConstants(drawCmdBuffers[i], pipelineLayout, VK_SHADER_STAGE_FRAGMENT_BIT, sizeof(glm::vec3), sizeof(Material::PushBlock), &mat);
|
vkCmdPushConstants(drawCmdBuffers[i], pipelineLayout, VK_SHADER_STAGE_FRAGMENT_BIT, sizeof(glm::vec3), sizeof(Material::PushBlock), &mat);
|
||||||
vkCmdDrawIndexed(drawCmdBuffers[i], models.objects[models.objectIndex].indexCount, 1, 0, 0, 0);
|
vkCmdDrawIndexed(drawCmdBuffers[i], models.objects[models.objectIndex].indexCount, 1, 0, 0, 0);
|
||||||
|
|
@ -1438,7 +1436,7 @@ public:
|
||||||
// 3D object
|
// 3D object
|
||||||
uboMatrices.projection = camera.matrices.perspective;
|
uboMatrices.projection = camera.matrices.perspective;
|
||||||
uboMatrices.view = camera.matrices.view;
|
uboMatrices.view = camera.matrices.view;
|
||||||
uboMatrices.model = glm::rotate(glm::mat4(), glm::radians(90.0f + (models.objectIndex == 1 ? -45.0f : 0.0f)), glm::vec3(0.0f, 1.0f, 0.0f));
|
uboMatrices.model = glm::rotate(glm::mat4(), glm::radians(90.0f + (models.objectIndex == 1 ? 45.0f : 0.0f)), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
uboMatrices.camPos = camera.position * -1.0f;
|
uboMatrices.camPos = camera.position * -1.0f;
|
||||||
memcpy(uniformBuffers.object.mapped, &uboMatrices, sizeof(uboMatrices));
|
memcpy(uniformBuffers.object.mapped, &uboMatrices, sizeof(uboMatrices));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@ public:
|
||||||
|
|
||||||
VulkanExample() : VulkanExampleBase(ENABLE_VALIDATION)
|
VulkanExample() : VulkanExampleBase(ENABLE_VALIDATION)
|
||||||
{
|
{
|
||||||
title = "Vulkan textured PBR using IBL";
|
title = "Vulkan Example - Textured PBR with IBL";
|
||||||
|
|
||||||
enableTextOverlay = true;
|
enableTextOverlay = true;
|
||||||
camera.type = Camera::CameraType::firstperson;
|
camera.type = Camera::CameraType::firstperson;
|
||||||
|
|
@ -1385,7 +1385,7 @@ public:
|
||||||
// 3D object
|
// 3D object
|
||||||
uboMatrices.projection = camera.matrices.perspective;
|
uboMatrices.projection = camera.matrices.perspective;
|
||||||
uboMatrices.view = camera.matrices.view;
|
uboMatrices.view = camera.matrices.view;
|
||||||
uboMatrices.model = glm::rotate(glm::mat4(), glm::radians(90.0f), glm::vec3(0.0f, 1.0f, 0.0f));
|
uboMatrices.model = glm::rotate(glm::mat4(), glm::radians(-90.0f), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
uboMatrices.camPos = camera.position * -1.0f;
|
uboMatrices.camPos = camera.position * -1.0f;
|
||||||
memcpy(uniformBuffers.object.mapped, &uboMatrices, sizeof(uboMatrices));
|
memcpy(uniformBuffers.object.mapped, &uboMatrices, sizeof(uboMatrices));
|
||||||
|
|
||||||
|
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 86 KiB After Width: | Height: | Size: 117 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 115 KiB After Width: | Height: | Size: 104 KiB |
BIN
screenshots/pbrtexture.jpg
Normal file
BIN
screenshots/pbrtexture.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 128 KiB |
Loading…
Add table
Add a link
Reference in a new issue