I am facing issues with texture wrapping. which is causing artifacts. Since my codebase has grown huge the only way that I can think of is to perform certain checks to see if certain textures fall under the category which are causing artifacts and change the parameters before drawing onto the renderbuffer.
So is it generally ok? to set parameters like
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT);
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT);
after glBindTexture during render loop? or would it effect FPS as it would increase operations during each render frame?
Changing texture parameters usually doesn't have a too serious impact on performance, as it leaves caches intact and only changes the access pattern.
However in later versions of OpenGL for this very specific usage scenario "Sampler Objects" have been introduced. I think you might want to have a look at them.
The general rule of thumb is this: do not change any state you don't have to.
If a texture has an intrinsic property that makes you use a mirrored-repeat wrapping mode, then it should always have that property. Therefore, the texture should have been originally set with that wrapping mode.
If it's something that you need to do at render time, then yes, you can do it. Whether it affects your performance adversely depends entirely on how CPU bound your rendering code is.
Note:
Since my codebase has grown huge
This is never a good reason to do anything. If you can't figure out a way to make your code do this the right way, then something bad has probably happened within your codebase. And you should fix that before trying to deal with this texture issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With