disable anisotropic filtering on chunks
This commit is contained in:
parent
bc2a2d08c9
commit
63d8a67845
5 changed files with 10 additions and 10 deletions
|
@ -46,8 +46,8 @@ std::shared_ptr<Model> Engine::loadModelFromData(std::vector<unsigned char> vert
|
||||||
return std::make_shared<Model>(xeDevice, builder);
|
return std::make_shared<Model>(xeDevice, builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
Image* Engine::loadImageFromFile(const std::string &filename) {
|
Image* Engine::loadImageFromFile(const std::string &filename, bool anisotropic) {
|
||||||
return new Image(xeDevice, filename);
|
return new Image(xeDevice, filename, anisotropic);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Engine::poll() {
|
bool Engine::poll() {
|
||||||
|
|
|
@ -33,7 +33,7 @@ class Engine {
|
||||||
|
|
||||||
std::shared_ptr<Model> loadModelFromFile(const std::string &filename);
|
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);
|
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(); }
|
bool beginFrame() { return xeRenderer.beginFrame(); }
|
||||||
void endFrame() { xeRenderer.endFrame(); }
|
void endFrame() { xeRenderer.endFrame(); }
|
||||||
|
|
|
@ -10,10 +10,10 @@
|
||||||
|
|
||||||
namespace xe {
|
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);
|
createTextureImage(filename);
|
||||||
createTextureImageView();
|
createTextureImageView();
|
||||||
createTextureSampler();
|
createTextureSampler(anisotropic);
|
||||||
}
|
}
|
||||||
|
|
||||||
Image::~Image() {
|
Image::~Image() {
|
||||||
|
@ -217,7 +217,7 @@ void Image::createTextureImageView() {
|
||||||
textureImageView = createImageView(xeDevice, textureImage, VK_FORMAT_R8G8B8A8_SRGB, VK_IMAGE_ASPECT_COLOR_BIT, mipLevels);
|
textureImageView = createImageView(xeDevice, textureImage, VK_FORMAT_R8G8B8A8_SRGB, VK_IMAGE_ASPECT_COLOR_BIT, mipLevels);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Image::createTextureSampler() {
|
void Image::createTextureSampler(bool anisotropic) {
|
||||||
|
|
||||||
VkSamplerCreateInfo samplerInfo{};
|
VkSamplerCreateInfo samplerInfo{};
|
||||||
samplerInfo.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
|
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.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE;
|
||||||
samplerInfo.addressModeV = 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.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE;
|
||||||
samplerInfo.anisotropyEnable = VK_TRUE;
|
samplerInfo.anisotropyEnable = anisotropic ? VK_TRUE : VK_FALSE;
|
||||||
samplerInfo.maxAnisotropy = xeDevice.getAnisotropy();
|
samplerInfo.maxAnisotropy = xeDevice.getAnisotropy();
|
||||||
samplerInfo.borderColor = VK_BORDER_COLOR_INT_OPAQUE_BLACK;
|
samplerInfo.borderColor = VK_BORDER_COLOR_INT_OPAQUE_BLACK;
|
||||||
samplerInfo.unnormalizedCoordinates = VK_FALSE;
|
samplerInfo.unnormalizedCoordinates = VK_FALSE;
|
||||||
|
|
|
@ -10,7 +10,7 @@ class Image {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Image(Device &xeDevice, const std::string &filename);
|
Image(Device &xeDevice, const std::string &filename, bool anisotropic);
|
||||||
~Image();
|
~Image();
|
||||||
|
|
||||||
Image(const Image&) = delete;
|
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 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 copyBufferToImage(VkBuffer buffer, VkImage image, uint32_t width, uint32_t height);
|
||||||
void createTextureImageView();
|
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 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);
|
static VkImageView createImageView(Device& device, VkImage image, VkFormat format, VkImageAspectFlags aspectFlags, uint32_t mipLevels);
|
||||||
|
|
|
@ -61,7 +61,7 @@ static std::map<std::string, uint32_t> texturesIds{};
|
||||||
static std::vector<xe::Image*> textures{};
|
static std::vector<xe::Image*> textures{};
|
||||||
|
|
||||||
void loadTexture(const std::string& filePath) {
|
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());
|
texturesIds[filePath] = static_cast<uint32_t>(textures.size());
|
||||||
textures.push_back(image);
|
textures.push_back(image);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue