Depth draw issue?
Asked Answered
S

4

0

Im using godot 4. I have some billboards that are not drawing ontop of each other correctly and im not sure why.

The sprites farther away from the camera are drawing ontop of the closer sprites.

Here are relevant parts of my shader:

shader_type spatial;
render_mode blend_mix, depth_draw_opaque, cull_back, diffuse_burley, specular_schlick_ggx, unshaded;

uniform vec4 albedo : source_color;
uniform sampler2D texture_albedo : source_color,filter_nearest,repeat_enable;
uniform float point_size : hint_range(0, 128)

and

	vec2 base_uv = UV;
		vec4 albedo_tex = texture(texture_albedo,base_uv);
		albedo_tex *= COLOR;
		ALBEDO = albedo.rgb * albedo_tex.rgb;
		SPECULAR = specular;
		ALPHA = albedo.a * albedo_tex.a;

Perhaps I need to enable alpha_scissors? Or maybe there is something wrong with the way I made the billboard in blender?
Any help would be great!
Thanks!

Edit. The individual billboards are actually larger than the dirt sprite. Im using a transparent png for the sprite. This is what the sprites look like when I disable the transparency by commenting out // ALPHA = albedo.a * albedo_tex.a; Notice the black and brown outline around the sprite:

If I switch to depth_draw_always mode then I get the correct drawing order (blocks in front are drawn on top) however the transparent area is weird:

Snitch answered 2/9, 2022 at 18:20 Comment(0)
G
0

I think the problem is with these two:

render_mode blend_mix, depth_draw_opaque,

Blend mix would be used for transparency, but then you are depth drawing opaque, which doesn't make sense if the billboards are cutout. You probably want to remove blend mix (transparency on billboards can work, but it will likely be too slow) and use the alpha scissor for the cutout.

Gingerly answered 3/9, 2022 at 0:59 Comment(0)
K
0

I wonder, might it be up to the Node order in SceneTree?

Komsomol answered 2/9, 2022 at 20:11 Comment(0)
O
0

Which version of Godot 4 are you using?
I've tested Alpha10 and Alpha15 with your shader on a bunch of plane meshes, they are correctly being depth sorted based on camera distance.
(I tried Alpha1, but adding a png crashed it)

Oolite answered 2/9, 2022 at 22:52 Comment(0)
G
0

I think the problem is with these two:

render_mode blend_mix, depth_draw_opaque,

Blend mix would be used for transparency, but then you are depth drawing opaque, which doesn't make sense if the billboards are cutout. You probably want to remove blend mix (transparency on billboards can work, but it will likely be too slow) and use the alpha scissor for the cutout.

Gingerly answered 3/9, 2022 at 0:59 Comment(0)
S
0

Gingerly
That works thank you!

Snitch answered 3/9, 2022 at 15:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.