I am writing a procedural terrain renderer for OpenGL. To shade the terrain I use multitexturing, that is 4 material textures and a blend map which distributes them across the terrain (encoded in RGBA).
Should I decide to split my terrain patch into two, blend map, consequently gets split too. Now there is a seam problem. Because of texture filtering, on the edges, the color "bleeds" from the opposite side of the texture. I recognize this can be fixed by setting texture repeat parameter to GL_MIRRORED_REPEAT or GL_CLAMP_TO_EDGE.
I believe that glTexParameteri function sets parameters for currently bound texture unit, still I'm unsure if these parameters get saved in texture unit's state, e.g. each texture unit "remembers" its parameters. Moreover, I know these parameters can be set per texture object. In that case whose parameters should take precedence?
On a more concrete note, I sample blend map from GL_TEXTURE0. So I had an idea to set repeat parameters for GL_TEXTURE0 once before rendering all terrains, but it doesn't work.
However, if I set this for every terrain rendered (absolutely the same code), it works. I'm inclined to believe that texture units don't "remember" their parameters. Is there something else I'm missing here?