Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | TobiLa |
Hi,
I have a mesh instance imported from blender which has a texture with transparent pixels.
In blender these pixels are correctly shown as transparent, in Godot they are painted black.
What can I do to show them as transparent pixels?
I am using a shader material which I converted from a spatial material.
The texture is a .png with 4096*4096 pixels and 32 bits.
The godot version is 3.0.6 stable.
Thanks in advance,
Tobi
Does your shader have the blend_mix
render mode?
Zylann | 2018-11-08 19:06
Yes, it does. What should it be set to?
TobiLa | 2018-11-08 19:13
For the texture to show as transparent, you need to set the ALPHA
variable in the fragment shader as well. Not just ALBEDO
. Have you done this?
SIsilicon | 2018-11-08 20:12
No, I haven’t. You mean to set the ALPHA vaulue in the fragment shader? What should I assign to ALPHA
?
Btw, my shader code looks like this:
shader_type spatial;
render_mode blend_mix,depth_draw_opaque,cull_back,diffuse_burley,specular_schlick_ggx;
uniform vec4 albedo : hint_color;
uniform sampler2D texture_albedo : hint_albedo;
uniform float specular;
uniform float metallic;
uniform float roughness : hint_range(0,1);
uniform float point_size : hint_range(0,128);
uniform sampler2D texture_metallic : hint_white;
uniform vec4 metallic_texture_channel;
uniform sampler2D texture_roughness : hint_white;
uniform vec4 roughness_texture_channel;
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;
float roughness_tex = dot(texture(texture_roughness,base_uv),roughness_texture_channel);
ROUGHNESS = roughness_tex * roughness;
SPECULAR = specular;
}
TobiLa | 2018-11-08 20:19