# Graphics Basics

Some basic concepts about rendering pipeline and graphics. The main contents come from the VTK text book.

Vector space

## Basic concepts

During the programing for rendering sth, it is easy to get confused if we lack the knowledge about the meaning of the terms used by computer graphics, such as actor, scence, mapper, canvas, views. etc.

This sentences shows the relationship between the graphics and visulization “Computer graphics is the foundation of data visualization. Practically speaking, visualization is the process that transforms data into a set of graphics primitives.”

No matter how the rendering pipeline defined or different terms are adopted, two key parts are data pipeline and graphics primiteves.

### VTK rendering pipeline

This paragraph describes clearly about the relationship between different concepts:

Actors represent graphical data or objects, lights illuminate the actors, and the camera constructs a picture by projecting the actors onto a view plane. We call the combination of lights, camera, and actors the scene, and refer to the rendering process as rendering the scene.

light source and actors are easy to understand. When considering how to project the 3d scene into the 2d plane, we need the concepts of cameras. The position of th camera can be described clearly based on figure used in the VTK text book, and we do not describe details here.

The Figure 3-24 shows how different concepts can work together.

Concrete example in VTK rendering process, such as the exmaple in 3.10 of the vtk text boook.

The code example above the figure 3-26 may provide mode direact ideas about how different components can work together.

The operation before the mapper belongs to the data pipeline, the output of the data pipeline is set to the mapper, which map the data into the graphics operation, the operation after the mapper belongs to the graphics pipeline. The actor contains the mapper. The vtkRenderer object handles the actor, light and camera. The vtkRenderWindow object can contains multiple renderers. Then the renderWindowInteractor help to process the interactive operations such as handling the mouse and the keyboard events. It can transfer these events from user to the graphics primitives such as change the view of the camera.

### VTK-m rendering pipeline

Concrete example in VTK-m rendering process.

a view is a unit that collects all the structure needed to perform the rendering. The scene contains a actor (same with vtk). Canvas is a unit that represent the image space that is the target of the rendering. Mappers are similar with the vtk.

### Alpine/ascent example

Another example is the rendering process for ascent project

According to their document, the basic concepts is Scenes, which contains all necessary information, then there is Plots which basically defines the more details data pipeline such as what kind of vis type (mesh volume etc.). One co-existing concepts is Render here, which defines the graphics primitives, such as image size and camera angle etc. They use another different visuzliation pipline, which is different with the vtk-m, their library is called the rover (https://github.com/LLNL/rover)

## Rendering algorithm and library

Although the opengl is adopted as the foundation for most of the rendering pipeline, their upper layer can be different.

We mainly take some nots for the rending things used in the scientific visulization.

Ray tracing
Volume rendering

### Library

IceT (used by paraview)

Rover (used by ascent) https://github.com/LLNL/rover

### References

The Intriduction of Graphics Class online

good references about the opengl camera position

https://learnopengl.com/Getting-started/Camera

### Some notes about the references

ep1
vector spaces，frames
This expression can save some energy, it just express a coordinates vector as a point p in space
the relationship between vector and points, p1+t(p2-p1) any points along the line between p1 and p2, (1-t)p1+tP2, affine combination. Vector + Points-> Affine space.
P in a trangle p1,p2,p3, how to express the P. P = alpa1 P1+alpha2 P2+alpha3 P3 (a1+a2+a3=1) Barycentric coordinate system

45:42, get the matrix form from the affine operation, (1,t,t^2,t^3)^T M (p1,p2,p3,p4)

ep2
the function for a random curve?how to generate curve?
Chaikin’s Algorithm (recursive subdivision), subdivision curve
get several points on the curve line, get control points, tangent, use the cross point as new control points,

ep3

Moving object in space (basic primitives)
use matrix a express the things (scaling + tranform) 3 times 3 for 2d and 4 times 4 for 3d
rotation:
right hand rule, rotate theta, rotate sth around the line (such as x, y and z axis)

ep4

Model-View-Controller (design pattern), the qt make the controller and view interction easier.

Qcompiler, implement siganal and slots(call back function), qglwidget, Canvas, draw routines

Rotation along the arbitry axis

transport the point to the origin, manipulate the vector to the z axis (we multiple rotation along different axis to move the targeted axis back to z), use elementary matrixes to construct more complicated one

Quaternion
Translation between quaternions and matrixes (an intersting way to express the relatioship between the 4th space and other 3d space)
projective space, viewing pyramid

ep5

Camera transform

pinhole camera as the model, image space

view transform (there are some math that is hard to understand for this episode)
camera point, center of attention(direaction vector), up direaction, angle of view, near and far distances

image space is mapped to the screen space

evey single point will multiple that matrix

ep6

viewing pipeline, geometry pipeline

clipping