0

You can disable texture wrapping in a webgl texture ala

gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);

If the texture is the same size as the render target, is there any particular advantage to doing this? Are there any performance reasons to do so?

If it matters, here I'm particularly interested in just rendering textures on 2D billboards.

1
  • Yes, there is a huge advantage to doing this, and it has to do with what happens when you linearly filter a texture coordinate of 0.0 or 1.0. I have explained this so many times, I am just going to refer you to another answer I wrote recently. That doesn't disable wrapping, by the way, it just sets the behavior when you try to sample coordinates at or beyond the edge of a single image. Apr 19, 2014 at 20:15

1 Answer 1

1

Functionally, the only reason to change it is that there might be a subtle difference at the edge of the rendered texture if you use linear filtering. For example on the right side of the texture, if wrap is set to REPEAT, the linear filtering would interpolate between the colors of the rightmost and leftmost texels at the edge. With CLAMP_TO_EDGE, it uses the color of the rightmost texels.

Performance should be identical. The only time there could potentially be a performance difference for wrap modes is if the GPU does not natively support one of the modes, and has to emulate it in shader code. But any GPU that is not completely ancient should support both these modes.

I would normally set the values to CLAMP_TO_EDGE unless you specifically need the repeating behavior.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.