Alpha/transparency should be easy, right? I don’t know what I’m doing wrong here…
I couldn’t figure out how alpha works in a shader. Whatever I do, it blends with the clear color(even its alpha is 0) and never becomes transparent. I know it’s possible (even semi-transparent) because @d954mas has it working in Cashchubbies Island for the windows.
- I set clear color to 0,0,0,0 on render script(to be sure)
- I don’t want to use discard
- Using default texture_profiles(Rgba)
Shader is very simple:
#version 140
out vec4 FragColor;
void main()
{
vec3 color = vec3(1.0); // White color
vec3 premultiplied_color = color * 0.5; // Premultiply alpha
FragColor = vec4(premultiplied_color, 0.5);
}
Nothing special in render.script, but I also tried using different blend modes (FACTOR_ZERO, FACTOR_ONE) while making the proper changes in the shader as well but no luck.
render.enable_state(graphics.STATE_DEPTH_TEST)
render.enable_state(graphics.STATE_BLEND)
render.set_blend_func(graphics.BLEND_FACTOR_SRC_ALPHA, graphics.BLEND_FACTOR_ONE_MINUS_SRC_ALPHA)
render.enable_state(graphics.STATE_CULL_FACE)
render.draw(predicates.model, draw_options_world)
render.set_depth_mask(false)
render.disable_state(graphics.STATE_CULL_FACE)
I’ll be glad if anyone can point me in the right direction!