3D Fundamentals Tutorial 12
From Chilipedia
The vertex shader is the one of the two original shaders introduced in Direct3D 8, and it is the only shader besides the pixel shader that must be provided before triangles can be rendered. It's kind of a big deal.
Video
The tutorial video is on YouTube here.
- What is a Vertex Shader (vs) and its position in the pipeline 0:20
- A vs takes in vertices of the geometries and applies transformations to them
- Our current pipeline function
ProcessVertices()
does this in the most basic form: it applies rotation and translation to move vertices of the mesh from object space to world space - In this video, we will be making the vs configurable
- Code implementation walk-through 1:14
-
Pipeline.h
1:14
-
- - We apply a
std::transform()
on the vertices vector - - We create a new datatype
VSOut
, giving the vs the power to change the datatype of the output vertices - - Note: this can be through a typedef or by implementing a new output type
- - Each vertex shader will define its output type
- - We apply a
- Demo: creating a wave effect 5:24
- Example where Vertex Output type is different from Vertex Input Type 10:48
- Example effect: the color of the vertex is determined by its position
- The input vertex type only holds position as data member, we add color in the output data type
VSOut
- You can procedurally add information to your vertices in the vs
Downloads
The GitHub repository for the tutorial code is here.