Fast Mirror Repeat Snippet

Veryvery basic code snippet, but i need this so very often I might as well post it XD

Shader code
uniform float tile_multiplier = 4.0;
//↑ move this to your top of file

vec2 mirroring(vec2 uv) {
    uv = fract(uv); uv = 1.0 - abs(2.0 * uv - 1.0);
    return uv;
}
//---------- move this to fragment -----------
//vec2 mirror_tiled_uv = mirroring(UV*tile_multiplier);
//--------------------------------------------
Live Preview
Tags
mirror, snippet, tiling
The shader code and all code snippets in this post are under CC0 license and can be used freely without the author's permission. Images and videos, and assets depicted in those, do not fall under this license. For more info, see our License terms.

Related shaders

guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments