diff options
author | Tyler Murphy <tylermurphy534@gmail.com> | 2022-09-26 23:34:05 -0400 |
---|---|---|
committer | Tyler Murphy <tylermurphy534@gmail.com> | 2022-09-26 23:34:05 -0400 |
commit | 63d8a67845b81ed72b5c6dec2a182f8327457811 (patch) | |
tree | a598b442cb07f2d4f5dad4a7644cc1241c1ad8fd /engine | |
parent | window icon (diff) | |
download | minecraftvulkan-63d8a67845b81ed72b5c6dec2a182f8327457811.tar.gz minecraftvulkan-63d8a67845b81ed72b5c6dec2a182f8327457811.tar.bz2 minecraftvulkan-63d8a67845b81ed72b5c6dec2a182f8327457811.zip |
disable anisotropic filtering on chunks
Diffstat (limited to 'engine')
-rw-r--r-- | engine/xe_engine.cpp | 4 | ||||
-rw-r--r-- | engine/xe_engine.hpp | 2 | ||||
-rw-r--r-- | engine/xe_image.cpp | 8 | ||||
-rw-r--r-- | engine/xe_image.hpp | 4 |
4 files changed, 9 insertions, 9 deletions
diff --git a/engine/xe_engine.cpp b/engine/xe_engine.cpp index 56222a9..44e5a4e 100644 --- a/engine/xe_engine.cpp +++ b/engine/xe_engine.cpp @@ -46,8 +46,8 @@ std::shared_ptr<Model> Engine::loadModelFromData(std::vector<unsigned char> vert return std::make_shared<Model>(xeDevice, builder); } -Image* Engine::loadImageFromFile(const std::string &filename) { - return new Image(xeDevice, filename); +Image* Engine::loadImageFromFile(const std::string &filename, bool anisotropic) { + return new Image(xeDevice, filename, anisotropic); } bool Engine::poll() { diff --git a/engine/xe_engine.hpp b/engine/xe_engine.hpp index 9555574..1a208d6 100644 --- a/engine/xe_engine.hpp +++ b/engine/xe_engine.hpp @@ -33,7 +33,7 @@ class Engine { std::shared_ptr<Model> loadModelFromFile(const std::string &filename); std::shared_ptr<Model> loadModelFromData(std::vector<unsigned char> vertexData, uint32_t vertexSize, std::vector<uint32_t> indices); - Image* loadImageFromFile(const std::string &filename); + Image* loadImageFromFile(const std::string &filename, bool anisotropic = true); bool beginFrame() { return xeRenderer.beginFrame(); } void endFrame() { xeRenderer.endFrame(); } diff --git a/engine/xe_image.cpp b/engine/xe_image.cpp index 2580384..cabcea3 100644 --- a/engine/xe_image.cpp +++ b/engine/xe_image.cpp @@ -10,10 +10,10 @@ namespace xe { -Image::Image(Device &xeDevice, const std::string &filename) : xeDevice{xeDevice} { +Image::Image(Device &xeDevice, const std::string &filename, bool anisotropic) : xeDevice{xeDevice} { createTextureImage(filename); createTextureImageView(); - createTextureSampler(); + createTextureSampler(anisotropic); } Image::~Image() { @@ -217,7 +217,7 @@ void Image::createTextureImageView() { textureImageView = createImageView(xeDevice, textureImage, VK_FORMAT_R8G8B8A8_SRGB, VK_IMAGE_ASPECT_COLOR_BIT, mipLevels); } -void Image::createTextureSampler() { +void Image::createTextureSampler(bool anisotropic) { VkSamplerCreateInfo samplerInfo{}; samplerInfo.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; @@ -226,7 +226,7 @@ void Image::createTextureSampler() { samplerInfo.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; samplerInfo.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; samplerInfo.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; - samplerInfo.anisotropyEnable = VK_TRUE; + samplerInfo.anisotropyEnable = anisotropic ? VK_TRUE : VK_FALSE; samplerInfo.maxAnisotropy = xeDevice.getAnisotropy(); samplerInfo.borderColor = VK_BORDER_COLOR_INT_OPAQUE_BLACK; samplerInfo.unnormalizedCoordinates = VK_FALSE; diff --git a/engine/xe_image.hpp b/engine/xe_image.hpp index 1b92e2a..6520a95 100644 --- a/engine/xe_image.hpp +++ b/engine/xe_image.hpp @@ -10,7 +10,7 @@ class Image { public: - Image(Device &xeDevice, const std::string &filename); + Image(Device &xeDevice, const std::string &filename, bool anisotropic); ~Image(); Image(const Image&) = delete; @@ -23,7 +23,7 @@ class Image { void generateMipmaps(VkImage image, VkFormat imageFormat, int32_t texWidth, int32_t texHeight, uint32_t mipLevels); void copyBufferToImage(VkBuffer buffer, VkImage image, uint32_t width, uint32_t height); void createTextureImageView(); - void createTextureSampler(); + void createTextureSampler(bool anisotropic); static void createImage(Device& device, uint32_t width, uint32_t height, uint32_t mipLevels, VkSampleCountFlagBits numSamples, VkFormat format, VkImageTiling tiling, VkImageUsageFlags usage, VkMemoryPropertyFlags properties, VkImage& image, VkDeviceMemory& imageMemory); static VkImageView createImageView(Device& device, VkImage image, VkFormat format, VkImageAspectFlags aspectFlags, uint32_t mipLevels); |