Rendering simple shapes without passing vertices?

Hi.

I would like to know if its possible to render a simple shape(such as a 2d square) via GLSL without passing a single vertice via the fixed pipeline , and if it is , where can i find a simple example ?

Thanks.

As far as i know ,it is impossible. Because GPU can not generate any new vertex without any input data. Only geometry shader can generate new vertex according to your input data.

Depending on what you mean by ‘witout passing single vertice via the fixed pipeline’ it may be possible.

You can issue a draw call without any attributes enabled (at least in core profile) and then hardcode positions of your quad in the shader using gl_VertexID to put each in aproperiate place. This translates to ‘passing’ 4 vertices in your case (but without any data).

Some people here reported issues with this however (but this was some time ago, so the bugs may be already fixed in latest drivers).

Yeah , that’s what i meant.Are there any basic examples to get started ?

I had varying success with zero length buffer. The most recent version of nVidia and ATI drives seem to require real vertices.

This works for me

create a vbo with 4, data is irrelevant and an index buffer with
indices 0,1,2,0,2,3

I use


  glDrawElementsBaseVertex(GL_TRIANGLES,6,GL_UNSIGNED_INT,(void*)0,0);

to draw 1 quad


glDrawElementsInstancedBaseVertex(GL_TRIANGLES,6,GL_UNSIGNED_INT,(void*)0,nbr_of_quads,0);

to draw multiple quads.

in the shader gl_InstanceID tells me which quad.

It’s possible and sometimes referred to as ‘Attribute-less rendering’ (search this forum) or look at:

Attribute-less rendering

To see how to create objects from an ‘empty’ render call, or:

Generating

to see how to generate the geometry itself in the geometry shader (with an empty vertex shader and only one point with no attributes as the rendering call).

The most recent version of nVidia and ATI drives seem to require real vertices.

AMD’s 12.1 drivers certainly don’t, and neither do NVIDIA’s drivers. My impostor tutorial has a section about doing this. It’s about in the middle of that page.

Thanks all for the extra info. I will revisit my code as we can use gpu generated vertices a lot

Alfonse is right, it should work on up-to-date ATI and NVidia drivers.
But rendering like this is very uncommon, so you could run into problems with Intel, MacOS or Linux OpenSource drivers later on.
Be carefull, test alot and document these tricks very well!

Brilliant - Thank you all!

NOTE: attributeless rendering is currently broken on MacOS X 10.7.3, filed as BugID #11335272.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.