+2 votes

I'm making a 2d platformer, and I would like the level to look like you are standing on a small planet. I'm thinking about using a shader to accomplish this. I had never used them before so, with help from this post, I managed to create something similar to what I was imagining:


This is the code I used. The shader is applied in a ColorRect node that is parented by a CanvasLayer node, in order to apply the effect to the entire viewport.


This is the result. It works as intended, but it's not exactly what I wanted. The effect is too extreme. I want to have at least some control over how big the "planet" is. I don't really want everything just come crashing down when it hits the border. This is especially noticeable when we resize the screen:


The ColorRect resizes along with it, making the effect even more extreme.

So I want to know either how I can improve this shader, or if there already exist resources that do something similar so I can implement them in my game. If neither, I can just ditch this idea altogether, no problem. I don't know if I'm asking for too much...

in Engine by (83 points)

Eu não sei nada sobre shaders mas só um comentário: tu sabe que tu pode usar PI pra pegar o valor de pi né? Tu não precisa definir uma variável que nem tu ta usando float pi = 3.14.

Eu sei, mas acho que só tem no GDscript, porque quando eu tento colocar no editor de shader ele dá um erro: Unknown identifier in expression: PI

@Fupicat English pls?

They were just saying that I could have used PI instead of creating a variable for storing pi, but that only works in GDscript.

Anyway, you got any ideas on my issue?

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.