Support Texture-Wrap mode CLAMP_TO_BORDER?

According to OpenGL - Textures threre are 4 modes, but Babylon does not support
#define GL_CLAMP_TO_BORDER 0x812D <==== what I need
#define GL_CLAMP_TO_EDGE 0x812F
#define GL_MIRRORED_REPEAT 0x8370
#define GL_REPEAT 0x2901
On my OSM streeds are direction arrows.
The right one goes to the border and causes side effekts according to GL_CLAMP_TO_EDGE
(The left one needed a transparent 32 pixel border to be ok)

So I “manipulated” babylon.max.js, added TEXTURE_BORDER_ADDRESSMODE = 4 and
case Engine.TEXTURE_BORDER_ADDRESSMODE:
return 0x812D; // there is no _gl.CLAMP_TO_BORDER !!!
But now, I got Error: WebGL warning: texParameter: pname 0x2803: Invalid param 0x812d.
ThreeJS also does NOT support it.
If WebGL does support it, BJS schould do it too please.

I read in the web, using GL_CLAMP_TO_EDGE and set borderColor would do it to. But there is no borderColor in BJS, is there?

1 Like

I have never used this mode, but see exactly why you would want it! It’s supported by glsl 1.3 and up id have to see if webGL supports it though.

Here is some discussion on it https://www.khronos.org/webgl/public-mailing-list/public_webgl/1002/msg00094.php it it sounds like different browsers handle it differently.

Unless I’m wrong I think that OpenGL ES (WebGL) lacks GL_CLAMP_TO_BORDER (and in fact lacks border colours altogether)

I think you are right sir.

So the only thing we cold do is, to clarify the BJS documentation:
CLAMP_ADDRESSMODE equals GL_CLAMP_TO_EDGE
And GL_CLAMP_TO_BORDER is not supported in WebGL Vx.y

What about WebGPU? Looks like it is the same:
enum GPUAddressMode
{
“clamp-to-edge”
“repeat”
“mirror-repeat”
};

I mean you could inject your own sampling method into whatever shader/material you are using and manually clamp to a border color…

like

vec4 clampToBorderTexture(sampler2d ts, vec2 uv, vec4 borderColor){
    vec4 c = texture(ts, uv);
    if(uv>1. || uv<0.){
    return borderColor;
    }
    return c;
}

that’s just off the top of my head though so dont quote me on it <3

Totally agree. Fancy doing a PR?

@Pryme8 Thank you for you inspiration. I think, I understand your code. But as I a totally amateur about shaders, a Playground may help me. Yet it’s not a BJS toppic any more. I will try to understand it, using CYOS …