I am rendering terrain and putting some grass on it. Grass is gif texture with alpha channel on quad. What I get is strange - from one side of grass1, since it is transparent I can see other grass2 and terrain through it, but when I move to the other side of grass2, I can't see grass1 but I still can see terrain through it! Something with depth_function or blend_function or... ??

yes, they are two sided. As you can see on pic, from the "back" you can see poly, texture (grass), even terrain behind, but another grass being cut off. From the "fromt" this is not happening. When I play with different depth function, I can get to see grass behind, but now it is in the front... So, it is not transparency problem after all, I think, but something with rendering order and depth function (now it is GL_LEQUAL)

Not if you use AlphaFunc and only pass 1.0 alpha values, which is perfectly acceptable for grass. Great for intersecting polys (common in grass) which can't be sorted. This saves you the depth-sorting and results into perfect results from any angle.

Hi, appreciate more people! Σ ♥ = ¾Learn how to award medals... and work your way up the social rankings!

riven, i tried to sort polys and it really worked. What I want now is to try your method, but didn't quite understand it. I AM using GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);if that is what you were talking about. Please tell me more

Let's say you want to render a tree, would you really want to depth-sort all leafs every frame?

Let's say the alpha-channel is either 0.0 or 1.0 in your texture. If you only want to show the pixels (and only let those write to the depthbuffer*) that have an alpha of 1.0, you enable alpha-testing and set the parameters with alpha-func.

* depth-buffer writes are the cause you have to depth-sort, so if you get those right, you don't have to sort.

Note that you shuold only enable alpha-testing when you really need it.From my experience a while ago I remember it was quite a costly check.

Gord knows why, but enabling the alpha test turns off hierarcial depth buffer testing (on cards that support it, natch) which can cause a speed hit (I can only assume that they're reusing the same physical bit of circitry for both).

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org