Jump to content
  • Advertisement
Sign in to follow this  
Jossos

quads with transparent textures act funny

This topic is 1084 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Edited by WiredCat

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

 

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

Edited by Jossos

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

 

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);"?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

 

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

Yes.


L. Spiro

 

alright thanks for your help, greatly appreciated!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!