Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Godot shader bending a flat 2d world (e.g. a platformer) to a tiny planet.
shader_type canvas_item;
uniform float radius = 3.0;
void fragment() {
vec2 uv = SCREEN_UV;
vec2 surface = vec2(0.5, 0.2);
vec2 center = surface - vec2(0, radius);
float base = length(uv - center);
float height = base - radius;
float xdiff = (uv.x - surface.x) / base * height;
uv = clamp(vec2 (uv.x - xdiff, surface.y + height), vec2(0.0, 0.0), vec2(1.0, 1.0));
COLOR.rgb = textureLod(SCREEN_TEXTURE, uv, 0.0).rgb;

This comment has been minimized.

Copy link
Owner Author

@t-karcher t-karcher commented Nov 9, 2020




This comment has been minimized.

Copy link

@caburet caburet commented Feb 19, 2021

Very nice! It just what i need!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment