Reputation: 6345
I have a couple questions about glTexParameter and filtering
1) What is the scope when applying a glTexParameter (specifically the filtering)? Here's a scenario:
When I use the textures in a shader, will one be linear and the other be nearest? Or will they both be nearest because it was called last?
2) Is it possible to set the filtering method in GLSL?
Upvotes: 2
Views: 1781
Reputation: 21
The same thing bother me too, but when I saw your post, I came up with a solution, which is to use both nearest & linear at the same shader.
First, set the texture to linear. When you need the nearest, you just clamp the uv position to the center of the pixel grid. Based on the Linear interpolation's behaviour, the result will be just like nearest, I hope.
Upvotes: 2
Reputation: 162164
1) Filtering mode is a parameter of the texture object, i.e. the filtering mode will only apply to the texture objects that has been active when setting the filter mode.
2) Filtering mode is a parameter of the sampler that must be constant during the whole shader execution. As such it can not be changed from within the shader. However it is possible to address individual texture levels and samples w/o any filtering applied, which can be used to implement custom filtering methods (though those will be much less performant).
Upvotes: 5