Łukasz Stalmach
Łukasz Stalmach

Reputation: 143

Texture with alpha channel covers background objects

While implementing billboard objects to my engine i encountered a problem (screenshot below)

enter image description here

as you can see billboard object covers everything in background (skybox seems to be an exception). And this is not exacly how i would like it to work. I have no idea where is the problem.

my fragment shader is pretty simple:

#version 330

uniform sampler2D tex;

in vec2 TexCoord;
out vec4 FragColor;

void main()
{
    FragColor = texture2D(tex, TexCoord);
}

and the billboard is just triangle strip made in geometry shader.

All ideas would be nice.

Upvotes: 1

Views: 173

Answers (1)

Barış Uşaklı
Barış Uşaklı

Reputation: 13532

Probably draw order issue, you need to draw opaque objects first and then alpha blended objects back to front. Alternatively you can enabled alpha testing or in your shader discard fragments if their alpha is below a certain threshold.

Upvotes: 2

Related Questions