7

Tell me, please, how I can add new vertex in vertex shader?

itun
  • 3,439
  • 12
  • 51
  • 75

4 Answers4

7

The vertex shader only transforms vertices. If you need to output additional geometry based on the input vertices a geometry shader is what you need.

pmr
  • 58,701
  • 10
  • 113
  • 156
3

You can add vertices using a geometry shader http://www.opengl.org/wiki/Geometry_Shader

"A GS can create new primitives, unlike vertex shaders, which are limited to a 1:1 input to output ratio."

Roy T.
  • 9,429
  • 2
  • 48
  • 70
3

You can't. That's what geometry shaders are for.

genpfault
  • 51,148
  • 11
  • 85
  • 139
0

It's not possible to create new vertices using a vertex shader; it can only transform vertices. The Khronos documentation for the vertex shader states:

A vertex shader receives a single vertex from the vertex stream and generates a single vertex to the output vertex stream. There must be a 1:1 mapping from input vertices to output vertices.

There are several options for adding new vertices:

  • Generate the new vertices on the CPU before rendering them.
  • Use a geometry shader for creating new vertices based on a given primitive.
  • Use tessellation for creating new vertices based on a given patch.
Yun
  • 3,056
  • 6
  • 9
  • 28