How do Draw lines in 3d like the ones that appear as the x, y, z axis in the editor?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By hidemat

I need this to help me for debugging, helping me visualize a 3d grid for building geometry. I also need them to not be visible through geometry that is in front.

:bust_in_silhouette: Reply From: wombatstampede

One would think that ImmediateGeometry might come in handy but in Godot 3.x it is not possible to use the line width. And a width of 1 is not something you’ll need most of the time.

I propose that you assemble the grid with meshinstances of geometric primitives.
If you want to display your grid in plane(s), you could also use shaders.

Here’s an example that I use for a “dotted line” along the z-axis. (Shader is applied to a box shape, thin on x/y, long on z). I think it is a good example of how to obtain the local coords in a fragment shaders. This could be extended to draw a checkerboard or some … grid. :wink:

shader_type spatial;
render_mode unshaded;

uniform float len1=0.4;
uniform float len2=0.1;
uniform vec4 color1: hint_color = vec4(1.0,0.0,0.0,0.5); 
uniform vec4 color2: hint_color = vec4(1.0,1.0,1.0,0.25); 

varying vec3 loc_vertex;

void vertex() {
	loc_vertex = VERTEX;

void fragment() {
	if (mod(loc_vertex.z,len1+len2)<=len1) {
			ALBEDO = color1.rgb;
			ALPHA = color1.a;
	} else {
			ALBEDO = color2.rgb;
			ALPHA = color2.a;

Thanks, I think i can use this. If my noobness allows for it XD

hidemat | 2019-04-17 15:47