Unmoving Plaid Effect

Shader to use in a Sprite. Usefull if you want to render a static pattern effect.

The shader is intended for use in a Sprite. You can use the whole texture or a region. The Offset/Centered must be disabled to work properly.

If you want an infinite background you can create a sprite that is child of the camera and update all the uniforms in the shader.

Shader code
shader_type canvas_item;

uniform vec2 position = vec2(0); // Global position of the sprite
uniform vec2 scale = vec2(1); // Scale of the sprite
uniform vec2 offset = vec2(0); // Offset in pixels

uniform bool regionEnabled = false; // Enable Sprite Region
uniform vec2 regionPosition = vec2(0); // Region Sprite Position
uniform vec2 regionSize = vec2(16); // Region Sprite Size

void fragment() {
	vec2 uv = UV + (position + offset) * TEXTURE_PIXEL_SIZE / scale;
	if (regionEnabled) {
		uv -= regionPosition * TEXTURE_PIXEL_SIZE;
		uv = mod(uv * scale, regionSize * TEXTURE_PIXEL_SIZE) + regionPosition * TEXTURE_PIXEL_SIZE;
	}
	else {
		uv = mod(uv * scale, 1.0);
	}
	
	COLOR = texture(TEXTURE, uv);
}
Tags
2d, background, infinite, sprite, static pattern, unoming plaid
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.

More from christt105

Sprite Water Reflection Pixel Art Pokémon Style

Related shaders

WRIP EFFECT WITH GODOT SHADER

Post-Processing, Grain PP effect and Palette Color

Rain and Snow with Parallax Effect

Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments