Triangle/vertix count with tessellation

Howdy JMonkeys,

i’ve got a problem there. I actually working on my bachelor thesis: Displacement Mapping with Tessellation

I’m almost done with it but what is left is a triangle/vertix count.
The normal jme statistics are only giving me the triangle count of my base object, for example my quad, if i increase my tessellation level now the triangle count doesnt increase.
The number of triangles is obviously increasing. I guess i have to get the number out of the shader (control or evaluation), but i have no idea how to do it.

If you need some code to get an idea, just tell me, i can show you some as soon as i am at home.

Greetings

Chief

Are you using a tessellation shader or something? Like… a modified JME?

JME reports the triangles that it dispatched. If you are creating the triangles on the CPU and it is not reporting them then something is wrong with how you are updating the mesh.

If you have modified JME to support tessellation shaders then you will have to see if there is some way to further modify it to get the rendered triangle count from the GPU (I know nothing about tessellation shaders).

Yes, sorry i forgot to mention, i modified JME, so i creating the triangles on the GPU.

I also haven’t delved into tesselation shaders, but I know they are all the rage these days. I became more interested in them watching a few pixar documentaries which they can create extra detail in only places that need it.

It’s called OpenSubDiv, and was used a lot in Monsters University (awesome film btw). There might be some helpful code somewhere in there.

<cite>@wezrule said:</cite> I also haven't delved into tesselation shaders, but I know they are all the rage these days.

I remember them for few years back when people were crazy about them and then I thought they died for most purposes and now geometry shaders are the ‘hot’ topic. Has something changed in past few years or am I confused?

@abies said: I remember them for few years back when people were crazy about them and then I thought they died for most purposes and now geometry shaders are the 'hot' topic. Has something changed in past few years or am I confused?
I think that's the other way around. Some say tesselation shaders made the geometry shader useless.

@Chief don’t you know how you tesselate your triangles? I think you control how many triangles are generated through the inner and outer level in the control shader. Depending on those params you can know how many triangles are generated for esch original triangle.
But you’ll have to compute that yourself on the cpu side and display it on screen. there is no way to get this information back from the GPU.
I’m not an expert in tesselation though, so I might be mistaken.
Anyway I’m pretty interested in your work. It’d be wonderful to have some feedback when you’re done.

<cite>@nehon said:</cite> I think that's the other way around. Some say tesselation shaders made the geometry shader useless.

Yes, you are right - I got the things confused.

Regarding the query, maybe this can help ?

http://www.opengl.org/wiki/Query_Object

Primitive queries are the collective name for the GL_PRIMITIVES_GENERATED and GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN query object types. These are used for detecting how many primitives were generated during one or more rendering operations. This is primarily used for Transform Feedback, particularly in cases where the number of items to be generated by a geometry and/or Tessellation Shader depends on the data provided

1 Like

Thx for the replies.

<cite>@nehon said:</cite>

@Chief don’t you know how you tesselate your triangles? I think you control how many triangles are generated through the inner and outer level in the control shader. Depending on those params you can know how many triangles are generated for esch original triangle.
But you’ll have to compute that yourself on the cpu side and display it on screen. there is no way to get this information back from the GPU.

That will be the point where I will start to investigate in the next days, but I have to make a pre-presentation for my professor and his department. After I have done this I will try to implement the counter.

I will keep you guys informed.

see ya…

Heyho Monkeys,

thats how i implemented a counter:

[java] public void simpleRender(RenderManager rm) {
IntBuffer queries = BufferUtils.createIntBuffer(1);
GL15.glGenQueries(queries);
int occquery = queries.get(0);

    GL15.glBeginQuery(GL30.GL_PRIMITIVES_GENERATED, occquery);
    rm.render(30, inputEnabled);
    GL15.glEndQuery(GL30.GL_PRIMITIVES_GENERATED);
    IntBuffer samples = BufferUtils.createIntBuffer(1);
             
    GL15.glGetQueryObject(occquery, GL15.GL_QUERY_RESULT, samples);
    counter = samples.get(0);
    tessLabel.setText("Counts = " + counter);
}[/java] 

GL_Primitves_Generated counts the triangle which are generated in a single rendercall.
Needed a long time to hit on it ^^

I dont know if this is efficient but atleast it works.

1 Like