Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Introduction to 3D Graphics - BostonVR VR/AR Hack Day

Introduction to 3D Graphics - BostonVR VR/AR Hack Day

Introduction to 3D Graphics
Presented at BostonVR VR/AR Hack Day
March 11 2017

Douglass Turner

March 11, 2017
Tweet

More Decks by Douglass Turner

Other Decks in Technology

Transcript

  1. INTRO TO 3D GRAPHICS Douglass Turner [email protected] @dugla 781 775

    3708 DOUGLASS TURNER ELASTICIMAGE SOFTWARE email: [email protected] twitter: @dugla
  2. Camera. Lights. Models. They all rely on various flavors of

    transformation matrices for position, orientation, and scale.
  3. Transform Transformation Matrix Coordinate Frame Reference Frame Eye Space Model

    Space World Space Different words for the same thing
  4. Every object in Unity exists in a hierarchy. Think tree-branch.

    Think parent-child, or sibling relationship.
  5. Unity uses quaternions for rotation. They are easier to specify

    and control then rotation via matrices.
  6. Quaternion demo: HelloLight - iPhone For an implementation of quaternions

    in Swift for iOS see the EIArcball class in my HelloMetal repository on Github: https://github.com/turner/HelloMetal
  7. We attach a set of attributes to each vertex. •

    position: x, y, z • surface normal: nx, ny, nz, • texture coordinate: u, v
  8. u,v define a coordinate system on the surface of an

    object for attaching a texture u v
  9. PrettyPixels = kd * (N.L) + ks * (R.V)^n An

    illumination model describes the interaction between a object’s surface and light sources
  10. PrettyPixels = kd * (N.L) + ks * (R.V)^n •

    V - Eye vector • L - Light source vector • N - Normal vector • kd - diffuse scale factor Diffuse Illumination
  11. PrettyPixels = kd * (N.L) + ks * (R.V)^n •

    V - Eye vector • L - Light source vector • N - Normal vector • R - Refection vector • n - specular exponent • ks - specular scale factor Specular Illumination
  12. Image Based Lighting (IBL) combined with High Dynamic Range (HDR)

    Images allows us to eliminate “lights” entirely. Global Illumination (GI) takes things to another level.
  13. All of what we have talked about up to this

    point is preamble to where the real action happens, the … GPU
  14. The GPU takes the triangles and textures and rasterizes then

    for display. We control the GPU with small programs called shaders written in GLSL or Metal (iOS).
  15. A shader defines the look of an object Shaders come

    in pairs • vertex shader • fragment shader
  16. void main() { vec4 raw = texture2D(hero, v_st); vec3 inverted

    = 1.0 - raw.rgb; gl_FragColor = vec4(inverted, 1.0); } fragmentShader code
  17. The shader concept was introduced by Pixar in the form

    of RenderMan. It is a powerful idea that has unleashed all the visual f/x we take for granted in games and effects-heavy movies.
  18. I wrote a 3D rendering system with an interpreted object-based

    language where shaders are first class citizens