"Clamp to border" effect in WebGL #396
Unanswered
computersarecool
asked this question in
Q&A
Replies: 1 comment
-
If you want to simulate an OpenGL border I'm guessing this would work
https://jsgist.org/?src=a11a5fbb89548ebcb0a97150421ede00 PS: I'm assuming OpenGL does not filter the texture with the border but I'm too lazy to go look it up. PPS: the 2nd half of that shader, the part that clamps the UV coords, is not needed if you set the texture filtering to |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
To my recent dismay I recently learned that WebGL does not supported a "Clamp To Border".
So, if you shrink UV coordinates (to scale an image for example) it is on you if you do not want the texture repeated in some fashion (clamped, mirrored whatever).
On the web you could just add a one pixel alpha border like this answer suggests but it seems there should be a cleaner way (technically for non-square images I think that would very slightly change the aspect ratio).
Is the correct approach to check during your scaling step for UV coordinates past your scaling range?
I think I am doing that correctly, but for textures that have zero whitespace, I still see a bit of clamping going on.
The situation that makes this harder is that I want to apply to a blur (which is why I am shrinking the texture) from a second texture, so I need valid UV coordinates in some of the scaled region (just not for the first texture).
Very curious here. Thanks!
Beta Was this translation helpful? Give feedback.
All reactions