Skip to content

Latest commit

 

History

History
518 lines (366 loc) · 15.6 KB

source.md

File metadata and controls

518 lines (366 loc) · 15.6 KB

Themes

Set your presentation theme:
Black (default) - White - League - Sky - Beige - Simple
Serif - Blood - Night - Moon - Solarized

H:

Rendering

Jean Pierre Charalambos
Universidad Nacional de Colombia
Presentation best seen online
See also the source code

H:

Outline

  1. Introduction: the problem
  2. Rasterization approach
  3. Ray-tracing approach
  4. Final thoughts

H:

Introduction: Alberti's Veil

Linear perspective

[Dürer's Alberti Veil](http://visualcomputing.github.io/Cognitive)

V:

Introduction: Virtual camera model

Representation

Non inversion of the rendered image

V:

Introduction: Virtual camera model

Frustum

Near and far clipping frustum planes

V:

Introduction: Virtual camera model

Image plane

Various valid canvas positions

V:

Introduction: Virtual camera model

Image plane

Positioning the canvas at the near plane

V:

Introduction: Virtual camera model

Frustum

Frustum side view

V:

Introduction: Virtual camera model

Challenges

  1. Spatial coherence -> Visibility

> 2. Visual appealing -> Shading

V:

Introduction: Virtual camera model

Challenges: Visibility

Geometry related

V:

Introduction: Virtual camera model

Challenges: Shading

Physics related

[Rendering equation](https://en.wikipedia.org/wiki/Rendering_equation)

N:

integral equation in which the equilibrium radiance leaving a point is given as the sum of emitted plus reflected radiance under a geometric optics approximation

H:

Raster approach: strategy

Object centric

Perspective projection of points

V:

Raster approach: strategy

Object centric

Perspective projection of a point

V:

Raster approach: strategy

Object centric

for (each point in scene) {
transform point from world space to camera space;
perform perspective divide (x/-z, y/-z);
  if (point lies within canvas boundaries) {
    convert coordinates to NDC space;
    convert coordinates from NDC to raster space;
    record point in image;
  }
}

V:

Raster approach: visibility

  1. Painter's algorithm
  2. Binary space partioning (BSP)
  3. Warnock algorithm
  4. Z-Buffering

V:

Raster approach: visibility

Draw distant objects first

V:

Raster approach: visibility

Input scene

V:

Raster approach: visibility

(Offline) subdivision step

V:

Raster approach: visibility

(Offline) subdivision step

V:

Raster approach: visibility

BSP Tree

V:

Raster approach: visibility

(Runtime) BSP visit

V:

Raster approach: visibility

Polygon visibility cases: a) polygon fills the viewport, b) polygon partially and c) completely visible, d) polygon invisible

V:

Raster approach: visibility

Subdivision step example

V:

Raster approach: visibility

Zbuffer data

V:

Raster approach: shading

Barycentric coordinates overview

$F_{01}(p) := (v_{0y} - v_{1y}) p_x + (v_{1x} - v_{0x}) p_y + (v_{0x} v_{1y} - v_{0y} v_{1x})$ $F_{12}(p) := (v_{1y} - v_{2y}) p_x + (v_{2x} - v_{1x}) p_y + (v_{1x} v_{2y} - v_{1y} v_{2x})$ $F_{20}(p) := (v_{2y} - v_{0y}) p_x + (v_{0x} - v_{2x}) p_y + (v_{2x} v_{0y} - v_{2y} v_{0x})$

[Edge functions](https://fgiesen.wordpress.com/2013/02/06/the-barycentric-conspirac/)

V:

Raster approach: shading

Barycentric coordinates: properties

$F_{01}(v_0) = F_{01}(v_1) = 0$

$F_{01}(v_2) = 2 \triangle(v_0,v_1,v_2)$

[Edge functions](https://fgiesen.wordpress.com/2013/02/06/the-barycentric-conspirac/)

V:

Raster approach: shading

Barycentric coordinates of a point $p$

$w_0(p) := F_{12}(p)$

$w_1(p) := F_{20}(p)$

$w_2(p) := F_{01}(p)$

which are simply the edge functions evaluated at $p$

if $w_0(p) > 0$, $w_1(p) > 0$ and $w_2(p) > 0$ (for WCC) then $p \in \triangle(v_0,v_1,v_2)$

V:

Raster approach: shading

Normalized barycentric coordinates of a point $p$

$\lambda_0(p) := F_{12}(p) / 2 \triangle(v_0,v_1,v_2)$

$\lambda_1(p) := F_{20}(p) / 2 \triangle(v_0,v_1,v_2)$

$\lambda_2(p) := F_{01}(p) / 2 \triangle(v_0,v_1,v_2)$

where $\lambda_0(p) + \lambda_1(p) + \lambda_2(p) = 1$

V:

Raster approach: shading

Uses: 1. Rasterization (using signed edge functions)

[Rasterization](https://www.scratchapixel.com/lessons/3d-basic-rendering/rasterization-practical-implementation/rasterization-stage)

V:

Raster approach: shading

Uses: 2. Antialiasing (using signed edge functions)

[Anti-aliasing](https://www.scratchapixel.com/lessons/3d-basic-rendering/rasterization-practical-implementation/rasterization-practical-implementation)

V:

Raster approach: shading

Uses: 2. Antialiasing (using signed edge functions)

[Anti-aliasing](https://www.scratchapixel.com/lessons/3d-basic-rendering/rasterization-practical-implementation/rasterization-practical-implementation)

V:

Raster approach: shading

Uses: 3. Interpolation (using normalized barycentric coordinate)

[Color interpolation](https://www.scratchapixel.com/lessons/3d-basic-rendering/rasterization-practical-implementation/rasterization-stage)

Anything can be interpolated!

V:

Raster approach: shading

References

H:

Ray-tracing approach: strategy

Image centric

Casting rays into a scene

V:

Ray-tracing approach: strategy

Image centric

Photorealism

V:

Ray-tracing approach: strategy

Image centric

for (each pixel in the image) {
  // step 1
  build a camera ray: trace line from current pixel location to camera's aperture;
  // step 2
  cast ray into the scene;
  // step 3
  if (ray intersects an object) {
    set current pixel's color with object's color at the intersection point;
  } else {
    set current pixel's color to black;
  }
}

V:

Ray-tracing approach: visibility

Visibility computation

V:

Ray-tracing approach: visibility

for (each pixel in the image) {
  // step 1
  build a camera ray: trace line from current pixel location to camera's aperture;
  // step 2
  cast ray into the scene;
  // step 3
  for (each object in the scene) {
    set current pixel's color with closest object's color at the intersection point;
  }
}

V:

Ray-tracing approach: shading

  1. Overview of the Ray-Tracing Rendering Technique.
  2. Light Transport Algorithms and Ray-Tracing: Whitted Ray-Tracing.

H:

Final thoughts

Problem: Implement Alberti's Veil on a computer -> virtual (pinhole) camera model

Challenges: visibility (geometry) & shading (physics)

Strategies: Raster vs Ray-tracing

V:

Final thoughts

Raster vs Ray-tracing

Feature Rasterization Ray-tracing
Philosophy Intromission Emission
Visibility Easy Trivial
Shading realism Promising Great
Parallelizable Easy Hard
Complexity Linear Exponential

V:

Final thoughts

Opengl Rendering Pipeline

N:

  1. Virtual camera: vertex specification & vertex shader
  2. Shading: fragment shader
  3. Visibility (z-buffer): per sample operations

V:

Final thoughts

Matrix transform operations

H:

References

  1. Learn Computer Graphics From Scratch!
  2. 2D cross-product
  3. OpenGL coordinate systems
  4. OpenGL pipeline