Regarding GL profiling

Frogblast Wrote:I'd be interested in seeing the Occlusion Query results. It might be possible to use discard/alpha test, but if you're just drawing Too Many Pixels, then you're next course of action is probably to try to coalesce far-away pieces of grass into a single quad, so you can draw multiple neighboring pieces of grass with as little overdraw as possible.

Tomorrow I'll write up some OC code to better get an idea of what kind of overdraw I've got.

That being said, It's looking a lot like some sort of early z-pass/fail situation is being short circuited here and that's why my performance is tanking. I'm going to try depth sorting ( shudder ) and see how that turns out.

I note from one of your earlier messages you said "visibleDrawingPatches: 141".... sorting a mere 141 things isn't going to hurt performance :-)

In past grass implementations I've worked on, we sorted and drew blended(src_alpha,on_minus_src_alpa) with no alpha test... and performance didn't tank through overdraw until after the grass height was around 25% of the screen height - though our shaders were a lot simpler than yours.

ps I still haven't sorted out this mouse thing with your demo, even after pluggin my ol' mighty mouse back into the keyboard... puzzling..

In past grass implementations I've worked on, we sorted and drew blended(src_alpha,on_minus_src_alpa) with no alpha test... and performance didn't tank through overdraw until after the grass height was around 25% of the screen height - though our shaders were a lot simpler than yours.

Well, I gotta sort the quads inside each patch, too! But it's not going to be too bad.

Quote:ps I still haven't sorted out this mouse thing with your demo, even after pluggin my ol' mighty mouse back into the keyboard... puzzling..

I made some changes to my HID code to pretend all attached mice are one single mouse. For my tests ( a MBP with an attached mouse ) it worked. But, well, nothing's ever right the first time

First: I went to depth-sorted no-depth-writes rendering. I was able to turn off GL_ALPHA_TEST and in general it looks not just good, but better than before since I have proper alpha blending now.

Second: I had to break one of my rules for this codebase. I've strived for general purpose, flexible code since the start. No special case, etc. However, I can't do multi-pass lighting of the foliage if I'm not writing to the depth buffer, so I broke my own rules and special cased the foliage to only render for one light, and to perform lighting for that one light in one pass.

I still have some fill-rate problems, but they're independent of the texture being used. So I'm not seeing that wacko performance drop switching between the debug texture and the foliage. Hopefully, further streamlining of the GLSL will help here.

BTW -- & amazingly -- depth sorting has no performance hit for me. The patches only hold a few hundred quads each, which is quick to sort. And the patches themselves are coarsely depth-sorted by the scene graph since they're marked as non-opaque. So there's not that much sorting actually going on.

NOTE: I need to come up with a better algorithm to pick random points on the surface of a triangle. The distribution has obvious artifacts.

Your triangle has vertices v0, v1, v2, with v0 equal to the origin. Pick 2 random numbers s, t in [0, 1]. Then your random point is
[INDENT]p = s*v0 + t*v1[/INDENT]
If p is not in the triangle, then you can discard it or mirror it about the line from v0 to v1. To sample over many triangles, sample from each triangle with propability proportional to its area.

mattz Wrote:If p is not in the triangle, then you can discard it or mirror it about the line from v0 to v1. To sample over many triangles, sample from each triangle with propability proportional to its area.

Sure -- I *may* have solved the input issue I was having, and as of this morning i have the distribution density modulated by 3d perlin noise, so it looks more "organic" and less like a carpet. Plus, I figrued out how to mix billboarded and crossed foliage into one shader so I can draw foliage and bushes in a single draw call. That's a performance boost.