B
bitbutter

  • Mar 3, 2023
  • Joined Dec 22, 2022
  • 0 best answers
  • Hi all. I have a (godot 4) project where i need to show a circle outline superimposed on a flat map. the circle will change size during the scene and the 3d camera will move away from/towards the circle in response so that it remains easily readable on the screen.

    the way i've tried setting up the circle is to use a MeshInstance, containing a plane mesh, with a little shader drawing the circle against a transparent background. this seems to work well until i scale down the MshInstance and move the camera close to it. when i do that the quality of the circle image becomes very poor. is there a way i can keep this general setup but have the circle display without quality loss no matter how small the MeshInstance is scaled down?

    the circle shader:

    shader_type spatial;
    render_mode unshaded;
    float circle(vec2 position, float radius, float feather){
    	return smoothstep(radius, radius + feather, length(position - vec2(0.5)));
    }
    void fragment() {
    	// Place fragment code here.
    	ALBEDO = vec3(1,1,1);
    	float bigcirc = circle(UV, .498, 0.0005);
    	float smallcirc = circle(UV, .48, 0.0005);
    	ALPHA = smallcirc-bigcirc;
    }

    a screenshot showing the unwanteds quality loss of the circle image on the right: