texture
This commit is contained in:
parent
01a3211dfb
commit
98b775e33e
21 changed files with 361 additions and 5541 deletions
55
Crafter.Graphics-TextureShader.cppm
Normal file
55
Crafter.Graphics-TextureShader.cppm
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
module;
|
||||
|
||||
#include <cstdint>
|
||||
#include <vulkan/vulkan.h>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#define GLM_FORCE_RADIANS
|
||||
#define GLM_FORCE_DEPTH_ZERO_TO_ONE
|
||||
#define GLM_ENABLE_EXPERIMENTAL
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
#include <glm/gtc/matrix_inverse.hpp>
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
|
||||
export module Crafter.Graphics:TextureShader;
|
||||
import Crafter.Component;
|
||||
import :VulkanTexture;
|
||||
import :VulkanPipeline;
|
||||
|
||||
namespace Crafter {
|
||||
export template <typename PixelType>
|
||||
class TextureShader {
|
||||
public:
|
||||
VkSampler textureSampler;
|
||||
VkDescriptorImageInfo imageInfo;
|
||||
ComponentRefOwning<VulkanTexture<PixelType>> texture;
|
||||
TextureShader(VulkanTexture<PixelType>* texture) : texture(texture) {
|
||||
VkSamplerCreateInfo samplerInfo{};
|
||||
samplerInfo.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
|
||||
samplerInfo.magFilter = VK_FILTER_LINEAR;
|
||||
samplerInfo.minFilter = VK_FILTER_LINEAR;
|
||||
samplerInfo.addressModeU = VK_SAMPLER_ADDRESS_MODE_REPEAT;
|
||||
samplerInfo.addressModeV = VK_SAMPLER_ADDRESS_MODE_REPEAT;
|
||||
samplerInfo.addressModeW = VK_SAMPLER_ADDRESS_MODE_REPEAT;
|
||||
samplerInfo.anisotropyEnable = VK_FALSE;
|
||||
samplerInfo.maxAnisotropy = 1;
|
||||
samplerInfo.borderColor = VK_BORDER_COLOR_INT_OPAQUE_BLACK;
|
||||
samplerInfo.unnormalizedCoordinates = VK_FALSE;
|
||||
samplerInfo.compareEnable = VK_FALSE;
|
||||
samplerInfo.compareOp = VK_COMPARE_OP_ALWAYS;
|
||||
samplerInfo.mipmapMode = VK_SAMPLER_MIPMAP_MODE_LINEAR;
|
||||
samplerInfo.mipLodBias = 0.0f;
|
||||
samplerInfo.minLod = 0.0f;
|
||||
samplerInfo.maxLod = 0.0f;
|
||||
VulkanDevice::CHECK_VK_RESULT(vkCreateSampler(VulkanDevice::device, &samplerInfo, nullptr, &textureSampler));
|
||||
|
||||
imageInfo.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
|
||||
imageInfo.imageView = texture->imageView;
|
||||
imageInfo.sampler = textureSampler;
|
||||
}
|
||||
void WriteDescriptors(DescriptorSet& set) {
|
||||
set.Write(1, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 0, &imageInfo);
|
||||
}
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue