Godot Version
4.4
Question
Hi all,
Someone know why from above the leaves are dark coloured and also the down part but when looking up the leaves are very transparant.
Cull is disabled but still this is what I see
4.4
Hi all,
Someone know why from above the leaves are dark coloured and also the down part but when looking up the leaves are very transparant.
Cull is disabled but still this is what I see
Cull as in “backface culling”? How do you make the leaves?
It might be something within the shader, without seeing it, it’s difficult to tell what might be happening. But, if your using a visual shader you can try this, hopefully it helps
I have this code. Also I see what is causing it. When there is a background then the leaves are normal but when the tree is with the sky behind it then is transparant. I use sky3D and I guess it is something with that because when disable that Sky3d it is normal.
// NOTE: Shader automatically converted from Godot Engine 4.3.stable.mono's StandardMaterial3D.
shader_type spatial;
//render_mode blend_mix, depth_draw_opaque, cull_disabled, diffuse_burley, specular_schlick_ggx, depth_prepass_alpha;
render_mode blend_mix, depth_draw_opaque, cull_disabled, diffuse_lambert_wrap, specular_schlick_ggx, depth_test_disabled;
uniform vec4 albedo : source_color;
uniform sampler2D texture_albedo : source_color, filter_linear_mipmap, repeat_enable;
uniform float point_size : hint_range(0.1, 128.0, 0.1);
uniform float roughness : hint_range(0.0, 1.0);
uniform sampler2D texture_metallic : hint_default_white, filter_linear_mipmap, repeat_enable;
uniform vec4 metallic_texture_channel;
uniform sampler2D texture_roughness : hint_roughness_r, filter_linear_mipmap, repeat_enable;
uniform float specular : hint_range(0.0, 1.0, 0.01);
uniform float metallic : hint_range(0.0, 1.0, 0.01);
uniform sampler2D texture_emission : source_color, hint_default_black, filter_linear_mipmap, repeat_enable;
uniform vec4 emission : source_color;
uniform float emission_energy : hint_range(0.0, 100.0, 0.01);
uniform vec3 uv1_scale;
uniform vec3 uv1_offset;
uniform vec3 uv2_scale;
uniform vec3 uv2_offset;
uniform float sway_speed = 1.0;
uniform float sway_strength = 0.05;
uniform float sway_phase_len = 8.0;
void vertex() {
UV=UV*uv1_scale.xy+uv1_offset.xy;
float strength = COLOR.b * sway_strength;
VERTEX.x += sin(VERTEX.x * sway_phase_len * 1.123 + TIME * sway_speed) * strength;
VERTEX.y += sin(VERTEX.y * sway_phase_len + TIME * sway_speed * 1.12412) * strength;
VERTEX.z += sin(VERTEX.z * sway_phase_len * 0.9123 + TIME * sway_speed * 1.3123) * strength;
}
void fragment() {
vec2 base_uv = UV;
vec4 albedo_tex = texture(texture_albedo, base_uv);
ALBEDO = albedo.rgb * albedo_tex.rgb;
float metallic_tex = dot(texture(texture_metallic, base_uv), metallic_texture_channel);
METALLIC = metallic_tex * metallic;
SPECULAR = specular;
vec4 roughness_texture_channel = vec4(1.0, 0.0, 0.0, 0.0);
float roughness_tex = dot(texture(texture_roughness, base_uv), roughness_texture_channel);
ROUGHNESS = roughness_tex * roughness;
// Emission: Enabled
vec3 emission_tex = texture(texture_emission, base_uv).rgb;
// Emission Operator: Add
EMISSION = (emission.rgb + emission_tex) * emission_energy;
ALPHA *= albedo.a * albedo_tex.a;
}
You helped me in the right direction. Used alpha scissor and anti aliassing mode to alpha edge blend, then it looks better
I might be misreading, but, did you enable No Depth Test? If so that might be the issue. If not I made this StandardMaterial3D you can look though (Hopefully it helps, though, I haven’t used Sky3D and this shader might not work with it.)
// NOTE: Shader automatically converted from Godot Engine 4.4.stable's StandardMaterial3D.
shader_type spatial;
render_mode blend_mix, depth_draw_opaque, cull_disabled, diffuse_lambert_wrap, specular_schlick_ggx, alpha_to_coverage;
uniform vec4 albedo : source_color;
uniform sampler2D texture_albedo : source_color, filter_linear_mipmap, repeat_enable;
uniform float alpha_scissor_threshold : hint_range(0.0, 1.0, 0.001);
uniform float alpha_antialiasing_edge : hint_range(0.0, 1.0, 0.01);
uniform ivec2 albedo_texture_size;
uniform float point_size : hint_range(0.1, 128.0, 0.1);
uniform float roughness : hint_range(0.0, 1.0);
uniform sampler2D texture_metallic : hint_default_white, filter_linear_mipmap, repeat_enable;
uniform vec4 metallic_texture_channel;
uniform sampler2D texture_roughness : hint_roughness_r, filter_linear_mipmap, repeat_enable;
uniform float specular : hint_range(0.0, 1.0, 0.01);
uniform float metallic : hint_range(0.0, 1.0, 0.01);
uniform vec3 uv1_scale;
uniform vec3 uv1_offset;
uniform vec3 uv2_scale;
uniform vec3 uv2_offset;
void vertex() {
UV = UV * uv1_scale.xy + uv1_offset.xy;
}
void fragment() {
vec2 base_uv = UV;
vec4 albedo_tex = texture(texture_albedo, base_uv);
ALBEDO = albedo.rgb * albedo_tex.rgb;
float metallic_tex = dot(texture(texture_metallic, base_uv), metallic_texture_channel);
METALLIC = metallic_tex * metallic;
SPECULAR = specular;
vec4 roughness_texture_channel = vec4(1.0, 0.0, 0.0, 0.0);
float roughness_tex = dot(texture(texture_roughness, base_uv), roughness_texture_channel);
ROUGHNESS = roughness_tex * roughness;
ALPHA *= albedo.a * albedo_tex.a;
ALPHA_SCISSOR_THRESHOLD = alpha_scissor_threshold;
ALPHA_ANTIALIASING_EDGE = alpha_antialiasing_edge;
ALPHA_TEXTURE_COORDINATE = UV * vec2(albedo_texture_size);
}
(Also, I suggest checking if you made the leaves transparent in GeometryInstance3D, as it having transparency can also cause issue)