Tutorial 8: Shader Sine Wave Calculations
The sine wave calculations can be performed in the vertex shader on the GPU ratther than on the CPU. This should mean that an animated sine wave, where every coordinate changes every frame, is much faster. For a static sine wave, i.e. static geometry the performance implications are not as obvious, as although the grid is static, the sine wave calculations are being performed every frame - but on the GPU rather than the CPU.
- Only the
x
andz
vertex grid coordinates ened to be calculated, set they
coordinate to 0.0 (or 2D “grid” coordinates can be used, but how to do that is less obvious). Move the calculation of they
coordinates of the vertices from the application program to the vertex shader. - After doing this the normal vectors will also need to be calculated directly on the GPU. This means that they no longer need to be passed to the GPU.