quads with transparent textures act funny

Started by
12 comments, last by C0lumbo 8 years, 3 months ago

Hi, Here is a screenshot of my game:

screnn.jpg

For some reason some of the leaf quads are being discarded to draw the trunk underneath. Also the shadow seems to act a bit weird on the tree, like as a square, but acts just fine on everything else.

How Do i fix this, or what could be causing this error? It all works just fine for the little man, but he has no alpha values. seems only transparent textures have this issue.

If there's any particular code you want to see, let me know.

Advertisement

its possible that you use blending to draw leafs and you dont sort quads properly, this will give you the 'bug' you describe. hard to say without code that draws the tree. both trunk and leafs.

Also the shadow seems to act a bit weird on the tree, like as a square, but acts just fine on everything else.

Because you don’t discard translucent/transparent pixels when generating the shadow map.
Since you don’t have this problem on the ground shadows, I assume you are creating 2 separate shadow maps. The one you are using to shadow translucent objects is wrong.

For some reason some of the leaf quads are being discarded to draw the trunk underneath.

This seems imaginary—nothing looks suspicious in your picture except a few spots that aren’t clear because of the shadow issue. Fix that first and then show a picture if this issue remains.


L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

its possible that you use blending to draw leafs and you dont sort quads properly, this will give you the 'bug' you describe. hard to say without code that draws the tree. both trunk and leafs.

They are in the same mesh object, so they get drawn in one hit.

I am using blending

glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
I assumed this would just work for me, but maybe not?

Also the shadow seems to act a bit weird on the tree, like as a square, but acts just fine on everything else.

Because you don’t discard translucent/transparent pixels when generating the shadow map.
Since you don’t have this problem on the ground shadows, I assume you are creating 2 separate shadow maps. The one you are using to shadow translucent objects is wrong.

For some reason some of the leaf quads are being discarded to draw the trunk underneath.

This seems imaginary—nothing looks suspicious in your picture except a few spots that aren’t clear because of the shadow issue. Fix that first and then show a picture if this issue remains.


L. Spiro

No, I'm using the same shadow map for everything, which is why this is so confusing.

For reference, here how it looks when modelling it:

tree.jpg

No, I'm using the same shadow map for everything, which is why this is so confusing.

Then it may be time to start posting shaders.

As for parts of the quad disappearing where there seems to be leaves, your alpha test is likely too low. Raise it.


L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

No, I'm using the same shadow map for everything, which is why this is so confusing.

Then it may be time to start posting shaders.

As for parts of the quad disappearing where there seems to be leaves, your alpha test is likely too low. Raise it.


L. Spiro

What's an "alpha test" ? you mean "glClearDepth(1.0);"?

Ok I think I got it fixed correctly.

I just added an if statement to the fragment shader:

if (color.a <= 0.1)
discard;
and results look good now. Is this what you mean by alpha test?

happysoul.jpg

and results look good now. Is this what you mean by alpha test?

Yes.


L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

and results look good now. Is this what you mean by alpha test?

Yes.


L. Spiro

alright thanks for your help, greatly appreciated!

This topic is closed to new replies.

Advertisement