Texture units parameters in OpenGL 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?
Your understanding of the behavior of texture units and state is confused. That's to be expected: OpenGL's pre-DSA API is not making it easy to understand this.

As far as core profile OpenGL is concerned, the only texture unit state is what textures are bound to which targets. That's all. Therefore, all glTexParameter calls affect the state of the texture object bound to the currently active texture unit, not of the texture unit itself.

So there is no "precedence". Texture objects have state, which are modified by glTexParameter calls. This is made more clear in direct state access APIs, because glTextureParameter directly takes a texture object, rather than a bound texture target.

If you call glTexParameter when texture object 0 is bound to the given texture target, then you're setting the parameter of the default texture object for that unit/target. And you shouldn't do that.