Slipgate texture warp
This is a shader I made in an attempt to recreate the slipgates from Quake. There is also an option to warp the screen UVs if you want to make something that looks a bit more like a portal.
Shader code
shader_type spatial;
render_mode unshaded, depth_draw_always; // NO LIGHTING!, "depth_draw_always" to 'fix' Z-ordering
uniform bool warp_ScreenSpace = false;
uniform sampler2D texture_albedo : source_color, filter_nearest;
void fragment() {
vec2 uv = vec2(0.0);
if(warp_ScreenSpace){
uv = SCREEN_UV;
}else{
uv = UV;
}
// TODO: ADD NOISE SAMPLER INSTEAD OF USING TRIG?
// TWEAK THE COEFFS AND/OR EQUATION FOR A DIFFERENT WARP PATTERN
uv.x += sin(uv.y * 1.54 * PI + TIME) * cos(uv.y * 1.31 * PI + TIME) * 0.1;
uv.y += cos(uv.x * 1.74 * PI + TIME) * -sin(uv.y * 1.64 * PI + TIME) * 0.1;
vec4 color = texture(texture_albedo, uv * 2.0);
ALBEDO = color.xyz;
ALPHA = color.a;
}
Hello! This is a shader effect. The only issue I have with it is that it seems to only work when the mesh it’s applied to is at the word origin. I’m perhaps the least qualified for shaders so it is likely possible I just messed something up, but after attempts to make the portal center a global offset by rewriting the fragment method, I was still unable to make the effect work when the mesh is not at the world origin.