Tell me, please, how I can add new vertex in vertex shader?
4 Answers
7
votes
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.
3
votes
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."
3
votes
0
votes
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.