Is there a way to use a transparent texture in Beer/Malt? #51
-
I've been trying to see if I can use transparent textures while using the Malt render engine. I've tried using the Basic Texture Shader, but there is no transparency when I use a .png. Is there a way I could change the shaders code to achieve this, and make a texture visible without having to add a light to the scene? For the example I pushed the logo to sit in front of the character more, to try and be clearer about what I mean. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 9 replies
-
If you look at the code, the line 13 is reading only the rgb channels: vec3 diffuse_color = texture(diffuse_texture, UV[uv_index]).rgb; If you just want a flat texture without lighting, you could use a shader that simply outputs the full texture rgba values as the pixel color output: #include "Pipelines/NPR_Pipeline.glsl"
uniform sampler2D diffuse_texture;
uniform int uv_index = 0;
void COMMON_PIXEL_SHADER(Surface S, inout PixelOutput PO)
{
PO.color = texture(diffuse_texture, S.uv[uv_index]);
} If you want to adapt the basic_texture.mesh.glsl you could just use the texture alpha as pixel color output alpha: #include "Pipelines/NPR_Pipeline.glsl"
uniform vec3 ambient_color = vec3(0.1,0.1,0.1);
uniform sampler2D diffuse_texture;
uniform int uv_index = 0;
uniform vec3 specular_color = vec3(1.0,1.0,1.0);
uniform float roughness = 0.5;
void COMMON_PIXEL_SHADER(Surface S, inout PixelOutput PO)
{
vec4 diffuse_color = texture(diffuse_texture, S.uv[uv_index]);
vec3 diffuse = diffuse_color.rgb * get_diffuse();
vec3 specular = specular_color * get_specular(roughness);
vec3 color = ambient_color + diffuse + specular;
PO.color.rgb = color;
PO.color.a = diffuse_color.a;
} By default, only pixels with alpha 0 will be transparent and the rest will be fully opaque. If you want alpha blending enable the Transparency options in the material UI. |
Beta Was this translation helpful? Give feedback.
If you look at the code, the line 13 is reading only the rgb channels:
If you just want a flat texture without lighting, you could use a shader that simply outputs the full texture rgba values as the pixel color output:
If you want to adapt the basic_texture.mesh.glsl you could just use the texture alpha as pixel col…