disable anisotropic filtering on chunks

This commit is contained in:
Tyler Murphy 2022-09-26 23:34:05 -04:00
parent bc2a2d08c9
commit 63d8a67845
5 changed files with 10 additions and 10 deletions

View file

@ -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() {

View file

@ -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(); }

View file

@ -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;

View file

@ -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);

View file

@ -61,7 +61,7 @@ static std::map<std::string, uint32_t> texturesIds{};
static std::vector<xe::Image*> textures{};
void loadTexture(const std::string& filePath) {
xe::Image* image = xe::Engine::getInstance()->loadImageFromFile(filePath);
xe::Image* image = xe::Engine::getInstance()->loadImageFromFile(filePath, false);
texturesIds[filePath] = static_cast<uint32_t>(textures.size());
textures.push_back(image);
}