How to enable texture filtering on one texture, but not others in a material

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
LuckyLMJ
Posts: 4
Joined: Fri Nov 25, 2022 10:09 pm

How to enable texture filtering on one texture, but not others in a material

Post by LuckyLMJ »

I've been working on a little model of the earth. I have a shader which reads a texture to figure out what country is at a specific spot of the world, and recolour it based on that. However, in order for this to work, I have to disable filtering on the textures of the material (as I'm just using a map of each country with their ID as a colour, and filtering would break this).
However, it does make the terrain look pretty bad without the filtering (here's a picture of Italy to show what I mean): https://imgur.com/a/sAJdLSb

Is there a way to disable filtering on one texture in a material, but not others? Alternately, is there a way to pass a texture to a shader without putting it on the material first (and thereby making it not run through the filtering)? A third solution I've considered is filtering the texture in the shader but I have absolutely no idea how to do that.
LuckyLMJ
Posts: 4
Joined: Fri Nov 25, 2022 10:09 pm

Re: How to enable texture filtering on one texture, but not others in a material

Post by LuckyLMJ »

Nevermind, I've figured out a solution.

I simply rounded the texture coordinates when fetching the texture at a position in my shader, so that it always gets the centre of the pixel (and thus disables any filtering that may exist).
Post Reply