Writing vertex shaders
Vertex processing is a first graphics pipeline stage that can be programmed. Its main purpose is to convert positions of vertices, which form our geometry, from their local coordinate system into a coordinate system called a clip space. The clip coordinate system is used to allow graphics hardware to perform all following steps in a much easier and more optimal way. One of these steps is clipping, which clips processed vertices to only those that can be potentially visible, hence the name of the coordinate system. Apart from that, we can perform all the other operations, which are executed once per each vertex of drawn geometry.
How to do it...
- Create a text file. Select a name for the file, but use a
vert
extension for it (for example,shader.vert
). - Insert
#version 450
in the first line of the file. - Define a set of vertex input variables (attributes) that will be provided from the application for each vertex (unless otherwise specified). For each input variable:
- Define...