# Computer Graphics (CG)

# Resources

### Foundations

Computational geometry.

### 3D impressions

### Artistic skills and product management

https://www.khanacademy.org/computing/pixar/

### Fundamentals of computer graphics

Solomon, J. (2020, December 29). Introduction to Computer Graphics (Lecture 1): Introduction, applications of computer graphics. Youtube. Retrieved from https://www.youtube.com/watch?v=-LqUu61oRdk&list=PLQ3UicqQtfNuBjzJ-KEWmG1yjiRMXYKhh&ab_channel=JustinSolomon

https://www.cs.middlebury.edu/~candrews/classes/cs461/

https://www.cs.unm.edu/~angel/BOOK/INTERACTIVE_COMPUTER_GRAPHICS/SEVENTH_EDITION/

Fundamentals of Computer Graphics, 4th Edition. ISBN 9781315360201

Interactive Computer Graphics A Top-Down Approach with WebGL Edward Angel and Dave Shreiner Seventh Edition, Addison-Wesley 2015

Acmsiggraph. "Imaging a Black Hole with The Event Horizon Telescope | SIGGRAPH Frontiers." 15 Oct. 2019, www.youtube.com/watch?v=2vUj2_jjSwk&list=PLUPhVMQuDB_aWSKj7L_-3Ot_nxBze_YMy&ab_channel=ACMSIGGRAPH.

https://www.youtube.com/c/InigoQuilez/videos

CS 4600 - Fall 2020 - Introduction to Computer Graphics. (2023, January 15). Retrieved from https://graphics.cs.utah.edu/courses/cs4600/fall2020

Yuksel, C. (2021, January 30). Intro to Graphics 00 - Opening. Youtube. Retrieved from https://www.youtube.com/watch?v=vLSphLtKQ0o&list=PLplnkTzzqsZTfYh4UbhLGpI5kGd5oW_Hh&index=1&ab_channel=CemYuksel

Crane, K. (2020, September 01). Computer Graphics (CMU 15-462/662): Welcome Video. Youtube. Retrieved from https://www.youtube.com/watch?v=W6yEALqsD7k&list=PL9_jI1bdZmz2emSh0UQ5iOdT2xRHFHL7E&index=1&ab_channel=KeenanCrane

Computer Graphics : Spring 2023. (2023, January 15). Retrieved from http://15462.courses.cs.cmu.edu/spring2023

### Software packages (Blender)

https://cgcookie.com/lesson/intro-to-blender-and-cg-cookie

https://www.youtube.com/c/GlebAlexandrov/playlists

### Libraries

*WebGL: Up and Running*

. Tony Parsi. 2012. O'Reilly.

## Laboratories

"Chrome Experiments - Experiments with Google." 20 Jan. 2023, experiments.withgoogle.com/collection/chrome.

https://graphics.stanford.edu/

## Videogames

*"Some people think games are kid's stuff, but gamedev is one of the few areas that uses almost every item of the standard CS curriculum."- *

*Dr. Sepideh Chakaveh*

https://www.conted.ox.ac.uk/profiles/sepideh-chakaveh

# Meaning

- CGI (computer-generated imagery). Abbreviation. common gateway interface.

- Computer graphics is as create coherent models, not fit with reality.

- It’s not about user interfaces.

# History of Computer Graphics

https://deseng.ryerson.ca/dokuwiki/mec222:brief_history_of_computer_graphics

## The world of computer graphics

# Research

https://www.youtube.com/watch?v=cw88Y36qgDg&ab_channel=SilviaSellán

- ACM

## CG industry

- Motion Graphics

- 3D Rendering

- VFX

## Actual ecosystem

- Maya, Blender, Max.

- OpenGL, DirectX, WebGL

**libGDX**

- GTK+

- LibSDL

# GitHub Repository

https://github.com/sanchezcarlosjr/computer-graphics/

## Examples

https://cg.sanchezcarlosjr.com/

## How do I render my models when don’t have enough computational power?

**Render farm**

https://www.sheepit-renderfarm.com

**How Many FPS Can the Human Eye See? and Frame rate**

30-60 is an animation.

# Description and ecosystem

- Fundamentals of computer graphics.
- Basics of real-time rendering and graphics hardware.

- Basic OpenGL.

- C++ programming experience.

- Algorithms.

- Mathematics.

- Software packages.
- Graphics editor. Photoshop, Illustrator, ...

- Computer graphics. Blender, Maya, RenderMan, ...

- Video-games. Unity, ...

- Libraries.
- OpenGL.

- DirectX.

- WebGL.

- Manim

- Cinder (programming library)

- ...

- Hardware.
- Graphic cards.

- Displays.

- Artistic skills and product management.
- Video-games.

- Movies.

- Animations.

- Simulations.

# People

**Disney's Nine Old Men**

**Disney Legends**

# Computer graphics files

STL

PDF, SVG, ...

## 3D impression

# Visual system

https://www.geogebra.org/calculator/vuvjfafb

https://www.geogebra.org/3d/nvj62eqr

# Languages

Penrose: from mathematical notation to beautiful diagrams. (2023, January 01). Retrieved from https://penrose.cs.cmu.edu/siggraph20

# Introduction

# Math

## Bitmap

# Raster images

Images are presented on some raster display. So, raster images are the most common way to store and process images.

Raster means converting **vector images to pixel images**.

Raster displays:

- Printers.

- Monitor.

- Television.

- Camera

- ...

https://en.wikipedia.org/wiki/Bayer_filter

Render means generating **from a 3D model, 2D model, or effects** to an** image by a computer program. **Raster displays show images as rectangular arrays of pixels. A raster image is a 2D array that stores the pixel value for each pixel.

Render programs:

- Blender

- After Effects

- ...

Rasterization, Ray Tracing, and Ray Tracing are rendering techniques.

**Rendering Equation.**

### Vector images vs raster images

# Rendering

## Perspective

## Ray Tracing

In computing, Ray Tracing is a process that draws a set of objects producing an array of pixels. From a material way, rendering means converting 3D objects to 2D images into realistic images, which considers how each object contributes to each pixel. So, if you want it, you need an image-order algorithm called Ray Tracing. Reversing reality, it takes an image based on the camera geometry, known as an array of pixels, running through each pixel in the image shoots rays through the normal surface, checking every object of the scene to see if it intersects with any of them. Also, it computes the pixel color based on the results of the ray intersection. My implementation of the algorithm in pseudocode, thanks to Appel:

```
for each pixel on the scene based on the camera geometry do
compute the ray direction
find first object hit by ray and its surface normal
compute illumination
calculate color
```

https://www.desmos.com/calculator/s4zfc085d4

## Notes

https://www.khanacademy.org/computing/pixar/rendering

“Ray Tracing in One Weekend.” raytracing.github.io/book/RayTracingInOneWeekend.html (accessed Feb. 21, 2022)

https://en.wikipedia.org/wiki/Netpbm#File_formats

https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/A_basic_ray-caster

## Properties of lighting & Light rays

There are properties of lighting and lights rays. So this lesson is about the spotlight, diffuse reflection, specular reflection, refraction, shadows rays, and how does work light rays with different mediums.

* Spotlight means the intensity of a lamp. When the light comes from directly a source, it's called direct illumination. Otherwise, it's called indirect illumination, that is, either refraction or reflection.

- Reflection

* Diffuse reflection is the reflection of light in a random direction on a surface.

* Specular reflection is the mirror-like reflection of light in a single direction on a surface.

* Refraction signifies the change in direction of light passing from one medium. For example, a glass with water.

* Ray tracing determines shadows rays from the object intersection to the light source.

* The camera is a factor to determine the brightness and racy tracing -image plane-.

## Rasterization and his graphic pipeline

The process of taking a primitive, generally a triangle, and figuring out which pixels it covers is called rasterization

https://www.youtube.com/watch?v=t7Ztio8cwqM

## Notes

https://www.scratchapixel.com/lessons/3d-basic-rendering/rasterization-practical-implementation

# Transformations

Geometric transformations and projections in computer graphics are linear transformations such that they are matrices, so we will be able to operate on Linear Algebra ideas. As shown below

is called translation.

is called scaling.

is called rotating.

We are ready to introduce composite transformations, i.e. multiply matrices. $T_aT_b$ means applying translation and after scaling. How we can check $T_aT_b \neq T_bT_a$, but $T_{a1}T_{a_2} = T_{a2}T_{a_1}$ and $T_{b1}T_{b_2} = T_{b2}T_{b_1}$.

- Affine space

https://gist.github.com/sanchezcarlosjr/b80754bc9122727d19d52ca0750f7d1d

# How does a low-level library work?

# Blender

https://git.blender.org/gitweb/

# Storytelling

# Color

# Camera

Virtual cameras work similar way to real cameras simulating optics and their behavior. The camera lens is about focal length, f-stop, diameter, and their relationship is $f_{stop}=\dfrac{\text{focal length}}{diameter}$. Focal length is the distance between the lens and focal point on mm, and it’s possible manipulating in-camera with Lens Curvature. Diameter measures the diameter of the aperture on mm. Focal length classifies as a natural view (~50mm), narrow view (~150mm), and wide view (~28mm).

Another hand, the Depth of field is a region where the objects in a scene are in focus. It determines choosing of a lens, aperture, and f-stop. A narrow depth of field gets by a small f-stop. A wide depth of field gets by a bigger f-stop.

# Animation

The techniques used to animate objects consist of artist-directed, data-driven, and procedural methods.

## Keyframing

The basic ideas of keyframing are specify important only and computer fills in the rest via interpolation/approximation.

### How do you interpolate data?

Data interpolation is a method used to estimate values between two known values in a series of data. There are several methods to perform data interpolation, including:

**Linear Interpolation**: This is the simplest method of interpolation. In this method, we assume that the rate of change of the function between the two given points is constant. We then use this rate of change to find the value at the desired point.

**Polynomial Interpolation**: In this method, a polynomial function is fit through the known data points and the value at the desired point is estimated from this polynomial function. The order of the polynomial function is usually one less than the number of known data points.

**Spline Interpolation**: This is a type of interpolation where we fit a special type of piecewise polynomial, called a spline, through the data points. Each polynomial in the piecewise polynomial matches with the adjacent polynomials at the known data points, which makes the function smooth at these points.

**Nearest Neighbor Interpolation**: This is a type of interpolation where the value at a new point is set to the value of the closest known point. This method is often used in image processing.

## Simulation

Leverage tools from physics + numerical methods.

Any system has a configuration $q(t)$. It also has a velocity $\dot{q}:=\dfrac{d}{dt}q$ and some kind mass $M$ with a forces $F$ and some constraints $g(q,\dot{q}, t)=0$.

We collect all variables into a single vector of generalized coordinates:

We think of $q$ as a single point moving along a trajectory in $R^n$.

Velocity is the time derivative of the generalized coordinates .

Physically-based animation.

## Particle system

### Subsubsection

**Parallax effect**

https://www.youtube.com/watch?v=z9tBce8eFqE

## AABB Collision detection

Alix-aligned bounding boxes

NO rotation.

### Detection

### Kinematics

https://www.geogebra.org/calculator/rramnueg

## Exercises and Projects

## Summary

### Key decisions

## FAQ

## Reference Notes

https://www.youtube.com/watch?v=XVTw68iHef0&list=PL9_jI1bdZmz2emSh0UQ5iOdT2xRHFHL7E&index=22

Reeves, William (1983). "Particle Systems—A Technique for Modeling a Class of Fuzzy Objects" (PDF). *ACM Transactions on Graphics*. **2** (2): 91–108. CiteSeerX 10.1.1.517.4835. doi:10.1145/357318.357320. S2CID 181508. Retrieved 2018-06-13.

## Bouncing Ball Equation

# Raster images

# Ray tracing

- Algorithm

# Linear Algebra

# Viewing

- Field of view
- Len mm

- Perspective distortion

# Images

## What is an image?

A pixel is not a little square! Alvy Ray Smith

CppCon. (2023, January 13). What Is an Image? - Cpp Computer Graphics Tutorial, (GPU, GUI, 2D Graphics and Pixels Explained). Youtube. Retrieved from https://www.youtube.com/watch?v=zi57OkPwzbk&ab_channel=CppCon

## Image formation

The elements of image formation are Objects, Viewers —cameras, and Light sources which interdepend on each other. Light is part of the electromagnetic spectrum. Ray Tracing is an algorithm that simulates the interaction between lights and objects —how much complex interaction do we want? But, Ray tracing is not well suited to real-time applications.

Color Image has three attributes hue —color identifier, saturation, and lightness. Three-Color Theory. Additive color forms a color by adding Red (R), Green (G), and Blue (B).

Global vs local lighting.

## Human visual system

The human visual system has two types of sensors: Rods and Cones. We have three primary colors.

## Pinhole camera

## Synthetic Camera Model

We separate objects, viewers, and light sources. Two-dimensional graphics is a special case of three-dimensional graphics.

**Image-based rendering**

https://www.inf.ufrgs.br/~oliveira/pubs_files/RITA_IBMR.pdf

https://graphics.stanford.edu/courses/cs248-05/IBR/IBR.pdf

https://pages.cs.wisc.edu/~dyer/cs534/papers/ibr-survey.pdf

# Animation

**Twelve basic principles of animation**

**Disney Animation: The Illusion of Life**

# Software architecture

Our concern is building programs device-independent.

## Software Process

We program WebGL programs as

```
Describe page
Define shaders
Compute
Send data to GPU
Render data
```

You can do operations in CPU or GPU, in software, we say application code or GLSL code —shaders. If you program with application code your program is slower but easy to learn if you program with GLSL code your program is faster but you must start thinking differently.

## Hardware

## GPU

# Graphical models

## Camera specification

## Lights and Materials

We have different types of lights, Point sources , distributed sources

Near and far sources

Color properties

Material properties are absorption and scattering.

# The Graphics Pipeline

Vertices.

```
put geometric data in an array accepted by GPU
send array to GPU
tell GPU as render (Triangles, Points, ...)
```

Vertex processor. Object coordinates, Camera coordinates, Screen coordinates. **When you program graphics you write this by the Vertex shader. **The vertex shader receives a vertex and its attributes.** **

Primitive assembler. Line segments, Polygons, Curves, and Segmentation.

Clipper. Ignore not visible objects.

Rasterizer. Produce fragments (i.e. potential pixels) into a frame buffer.

Fragment processor. **When you program graphics you write this by the fragment shader. **The fragment shader receives a vertex and its attributes.** **

Pixels.

- Object-order rendering.

### Date:

### Topic: Rasterization

### Recall

How does a developer write his own animation?

The developer writes vertices and modes -geometric objects, and the computer interpolates.

Curves? Chain of line segments.

Polygons? Break them up into triangles.

### Notes

- INPUT: Geometric primitive by clipper.

- It enumerates the pixels.

- It interpolates values.

- OUTPUT: A set of
**fragments**-pixels, with their information, including color, location, and depth- for each primitive in the frame buffer.

- A raster is a matrix of pixels.

- Geometric primitive to pixels is called rasterization.

- Triangles are the most often used primitive.

- A fragment shader is a shader about fragments.

- A vertex shader is a shader about vertices.

- A shader is a program that runs over GPU.

### Date:

### Topic: Clipping

https://www.tutorialandexample.com/clipping-in-computer-graphics

### Recall

### Notes

- It’s implemented to improve rendering performance.

- ...

## References

## Worked examples

# Pipeline

# Textures

# Data Structures

# Curves

# Animation

# Computer Graphics in Games

# Visual perception

# Imaging systems, visual science, and computer vision

# WebGL

## Project

https://graph-theory.sanchezcarlosjr.com/

## Shaders

https://www.vertexshaderart.com/

# Blender

## Projects

https://www.youtube.com/watch?v=8WpAkU5W9Os&ab_channel=CarlosSanchezExplica

https://www.youtube.com/watch?v=tZfIPQg02aU

https://www.youtube.com/watch?v=UwILfseD41M

https://www.youtube.com/watch?v=8NkgmvGzU7I

# Videogames

## References

Programming Games Wiki. (2022, October 26). Retrieved from https://programminggames.org/Main_Page

Millar, H. (2006). Videogames: content and responsibility. SIGGRAPH Comput. Graph., 40(3), 7-es. doi: 10.1145/1186743.1186753

## Computer graphics. Geometrical computer problems.

- Convex hull.