O'Reilly logo

Mastering openFrameworks: Creative Coding Demystified by Denis Perevalov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Deforming objects with a vertex shader

A vertex shader processes each vertex of drawing objects and can change their built-in attributes such as position, color, normal, and can also change any custom attributes. Here, we consider the example of the vertex shader that just moves vertices according to a rule with the help of parameters that are controlled by the mouse position.

Note

This is example 08-Shaders/06-VertexDeformation.

This example is based on the example given in the The triangles cloud example section of Chapter 2, Drawing in 3D. The original example draws a rotated sphere-shaped cloud of random triangles.

Vertex shader

In the bin/data folder, create a new text file shaderVert.c containing the following code:

#version 120 #extension GL_ARB_texture_rectangle ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required