Program 2A - Dancing Sun

GitHub Classroom Assignment Page

This assignment is due on Friday 2/2.

Practice with OpenGL, GLSL data, parametric equations, and vectors

The goal of this program is to practice using OpenGL and GLSL in order to simulate a dancing sun. You will need to manage the generation of the geometry to represent a circle, passing the data to the GPU and computations on both the CPU and GPU to create the specific animation and rendering. You will need to apply your knowledge about simple math and vectors to create the specific animation. You will also need to add an additional shader to show mastery of using two different shaders. In general, the vertex shaders will be used to reposition the points and the fragment shader will be used to control render attributes of your program.

Your task is to make a simple simulation of a sun with dancing rays with a gradient coloring on both the background and sun. And example frame is included below as an example and then specific tasks are listed on the following pages.

Two frames of the animation you will create of a dancing sun:

program2a_1.png
program2a_2.png

Task 1:

Generate the geometry to represent a circle. Using the paramtric equation for a circle in 2D, generate at least 80 sample points (vertices) around the exterior of a circle. These vertices should be packed into an array on the CPU as:

[x0, y0, z0, x1, y1, z1, …., xn, yn, zn]

make sure to include a vertex for the center of the circle as well, as you will need to then form triangles (like a pizza). You will then also need to fill in an index buffer object which specifies which vertices are connected together to make a triangle. This CPU data, needs to then be passed to the GPU as a vertex buffer object and index buffer object. For example see below.

program2a_3.png

Create vertices and indices and fill in a VBO and IBO for a circle with an arbitrary number of vertices using a parametric equation *you cannot use an existing obj – method must be procedural

program2a_4.png

Next, sample the triangle with at least 80 samples and make every other vertex offset (like a sun).

Task 2:

In the vertex shader write code to update the vertices positions based on moving in or out from the center of the circle for each vertex

You will need to think about this carefully and add enough data and computation to the vertex shader to update where the points draw. Note that the data in the buffer will not actually change, you will just modify the position sent to gl_Position using a vector to represent the direction of travel and a coefficient to represent how far to travel along that vector in order to achieve the desired animation.

program2a_5.png

Next animate the vertices to move in and out over time two frames shown here – this frame shows the rays in a very spikey mode

program2a_6.png

Another frame of the animation showing the rays in a less spikey mode

Task 3:

Finally modify the fragment shader in order to make the rendering of your animation more interesting (read about gl_FragCoord). You must do several things:

program2a_7

Some general comments:

Percentage point break down: