random offsets in raygen

This commit is contained in:
CDaut 2024-06-29 19:08:24 +02:00
parent 2bc40926b8
commit 74457d1a9c
Signed by: clara
GPG key ID: 223391B52FAD4463
5 changed files with 37 additions and 38 deletions

View file

@ -339,10 +339,10 @@ void HelloVulkan::createTextureImages(const VkCommandBuffer& cmdBuf, tinygltf::M
void HelloVulkan::createPointsetTexture(const VkCommandBuffer& cmdBuf)
{
VkSamplerCreateInfo samplerCreateInfo{VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO};
samplerCreateInfo.minFilter = VK_FILTER_NEAREST;
samplerCreateInfo.magFilter = VK_FILTER_NEAREST;
samplerCreateInfo.mipmapMode = VK_SAMPLER_MIPMAP_MODE_LINEAR;
samplerCreateInfo.maxLod = FLT_MAX;
samplerCreateInfo.minFilter = VK_FILTER_NEAREST;
samplerCreateInfo.magFilter = VK_FILTER_NEAREST;
samplerCreateInfo.mipmapMode = VK_SAMPLER_MIPMAP_MODE_LINEAR;
samplerCreateInfo.maxLod = FLT_MAX;
samplerCreateInfo.addressModeU = VK_SAMPLER_ADDRESS_MODE_REPEAT;
samplerCreateInfo.addressModeV = VK_SAMPLER_ADDRESS_MODE_REPEAT;
samplerCreateInfo.addressModeW = VK_SAMPLER_ADDRESS_MODE_REPEAT;
@ -351,22 +351,21 @@ void HelloVulkan::createPointsetTexture(const VkCommandBuffer& cmdBuf)
// TODO: generate and parse pointset here
std::vector<float_t> points{};
points.reserve(swapchainExtent.height * swapchainExtent.width * 2);
points.reserve(swapchainExtent.height * swapchainExtent.width * 2 * 4);
for(int y = 0; y < swapchainExtent.height; ++y)
for(int y = 0; y < swapchainExtent.height * 4; ++y)
{
for(int x = 0; x < swapchainExtent.width; ++x)
{
float rand_x = static_cast<float>(rand()) / static_cast<float_t>(RAND_MAX);
float rand_y = static_cast<float>(rand()) / static_cast<float_t>(RAND_MAX);
std::cout << "x: " << rand_x << "|y: " << rand_y << std::endl;
points.emplace_back(rand_x);
points.emplace_back(rand_y);
points.push_back(rand_x);
points.push_back(rand_y);
}
}
VkImageCreateInfo imageCreateInfo = nvvk::makeImage2DCreateInfo(swapchainExtent, VK_FORMAT_R32G32_SFLOAT, VK_IMAGE_USAGE_SAMPLED_BIT, false);
VkImageCreateInfo imageCreateInfo =
nvvk::makeImage2DCreateInfo(swapchainExtent, VK_FORMAT_R32G32_SFLOAT, VK_IMAGE_USAGE_SAMPLED_BIT, false);
nvvk::Image image = m_alloc.createImage(cmdBuf, points.size(), points.data(), imageCreateInfo);
VkImageViewCreateInfo ivInfo = nvvk::makeImageViewCreateInfo(image.image, imageCreateInfo);
m_pointset = m_alloc.createTexture(image, ivInfo, samplerCreateInfo);