Jump to content

  • Log In with Google      Sign In   
  • Create Account


Drawing vertices without actual vertices?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
9 replies to this topic

#1 SeraphLance   Members   -  Reputation: 1299

Like
0Likes
Like

Posted 09 December 2013 - 10:51 PM

Namely, I want to write a vertex shader something akin to this:

in vec3 vertex;

void main()
{
	vertex.x = gl_VertexID % vertexWidth;
	vertex.y = gl_VertexID / vertexWidth;
        //vertex.z = someProceduralFunction(...);
	gl_Position = projection * modelview * vec4(vertex, 1.0);
}

Ignoring the question of whether the code even compiles, it's abundantly clear that I don't actually need any VBOs in the theoretical sense, so is it possible to just pump some kind of shadow vertices to this shader?  Or do I need to allocate the space in the buffer regardless?



Sponsor:

#2 Hodgman   Moderators   -  Reputation: 28447

Like
0Likes
Like

Posted 09 December 2013 - 10:55 PM

I've never tried this in GL, but yep, this trick is completely valid in D3D! In D3D, you basically just make sure that no VBOs or vertex attributes are bound/exist.



#3 ryutenchi   Members   -  Reputation: 353

Like
0Likes
Like

Posted 10 December 2013 - 12:06 AM

you will need at the very least 1 vertex and an index buffer with a length == to the number of vertices you want to generate. I could be wrong, but I'm almost positive that the vertex shader only runs and only runs once per vertex in the VBO.



#4 Aliii   Members   -  Reputation: 1411

Like
1Likes
Like

Posted 10 December 2013 - 12:24 AM

I did ask something very similar on OpenGL.org and got an answer.

http://www.opengl.org/discussion_boards/showthread.php/182969-Draw-with-fragment-shader-without-vertices

 

You dont have to glEnableVertexAttribArray( 0); the vertex attribute but define a default value with glVertexAttrib1f( 0, 0);

Define the input attribute in the shader: layout(location = 0) in float dummy_attrib;

 

....and then just use gl_VertexID as you said.

I dont use any VBOs when I do this but if you are afraid of broken drivers then use one.


Edited by Aliii, 10 December 2013 - 12:25 AM.


#5 dpadam450   Members   -  Reputation: 857

Like
0Likes
Like

Posted 12 December 2013 - 12:52 AM

Fancy, though what is the use?



#6 Aks9   Members   -  Reputation: 785

Like
1Likes
Like

Posted 12 December 2013 - 02:42 AM

you will need at the very least 1 vertex and an index buffer with a length == to the number of vertices you want to generate. I could be wrong, but I'm almost positive that the vertex shader only runs and only runs once per vertex in the VBO.

No, you don't. It is perfectly valid to draw without a single attribute.

 

 

 

Fancy, though what is the use?

 

Rendering without attributes (not without vertices, since it is impossible) is an awfully powerfully rendering method. In last 3 or 4 years I have almost everything drawn without a single attribute. From screen-aligned quads and 2D charts to some very complex geometries. For simple shapes index buffer is not required, but complex ones need "scheme" for "vertex distribution". For my purposes, attributless rendering is more powerful than tesselation shaders since there is no limitations for patch size.


Edited by Aks9, 12 December 2013 - 03:25 PM.


#7 ryutenchi   Members   -  Reputation: 353

Like
0Likes
Like

Posted 13 December 2013 - 04:35 PM


No, you don't. It is perfectly valid to draw without a single attribute.

 

Ok, then I'm confussed how does the GPU know how many times to call the vertex shader? How does one invoke this black mage?^^



#8 Aks9   Members   -  Reputation: 785

Like
0Likes
Like

Posted 13 December 2013 - 05:29 PM

The primitive type as well as the number of vertices (or entries in the index buffer) are the parameters of draw calls.

#9 Hodgman   Moderators   -  Reputation: 28447

Like
0Likes
Like

Posted 13 December 2013 - 05:29 PM

No, you don't. It is perfectly valid to draw without a single attribute.

 
Ok, then I'm confussed how does the GPU know how many times to call the vertex shader? How does one invoke this black mage?^^
Even when you are using VBOs, it's the actual draw call itself that specifies the number of vertices to be drawn (or the number of triangles/etc, but that's the same thing).

#10 ryutenchi   Members   -  Reputation: 353

Like
0Likes
Like

Posted 15 December 2013 - 03:34 PM


Even when you are using VBOs, it's the actual draw call itself that specifies the number of vertices to be drawn (or the number of triangles/etc, but that's the same thing).

 

ooooh...  I aways thought that would lead to an exception because of trying to access a null pointer... interesting^^ Learn something new everyday^^






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS