Math end algebra. Vector

Содержание

Слайд 2

Слайд 3

MATH & ALGEBRA

MATH & ALGEBRA

Слайд 4

VECTOR

VECTOR

Слайд 5

Length Pythagorean Formula |V| = sqrt(x2 + y2)

Length

Pythagorean Formula
|V| = sqrt(x2 + y2)

Слайд 6

Addition A = (1, 2) B = (4, 0) A +

Addition

A = (1, 2)
B = (4, 0)
A + B = (1+4,

2+0) = (5, 2)
Слайд 7

Subtraction A = (1, 2) B = (4, 0) A -

Subtraction

A = (1, 2)
B = (4, 0)
A - B = A

+ (-B)
A - B = (1-4, 2-0) = (-3, 2)
Слайд 8

Scalar Multiplication A*3 = (3*1, 3*2) = (3, 6) (unit vector

Scalar Multiplication

A*3 = (3*1, 3*2) = (3, 6)
(unit vector = divide the

vector by it's length)
Слайд 9

Dot Product A = (Ax, Ay, Az) B = (Bx, By,

Dot Product

A = (Ax, Ay, Az) B = (Bx, By, Bz)
A·B =

AxBx + AyBy + AzBz A·B = |A||B|cosθ 
Слайд 10

Cross Product AxB = (AyBz - AzBy, AzBx - AxBz, AxBy - AyBx)

Cross Product

AxB = (AyBz - AzBy, AzBx - AxBz, AxBy - AyBx)

Слайд 11

Real world examples In which direction should the missile be fired

Real world examples

In which direction should the missile be fired to hit the target?
Is the enemy visible

in the field of view?
How far is the bullet from the window?
Слайд 12

Solutions Solutions have been done by many before. Know the basics

Solutions

Solutions have been done by many before.
Know the basics to find

them quicker.
Use utils and classes like:
Vector3D
Vector3DUtils
Plane3D, Ray (4.0)
Vector3
Слайд 13

SPACES

SPACES

Слайд 14

Spaces Euclidean space using Cartesian coordinates. (X, Y and Z) Local/Model

Spaces

Euclidean space using Cartesian coordinates. (X, Y and Z)
Local/Model Space
World Space
View/Camera

Space (Point-of-view)
Screen space (2D)
Слайд 15

Left- and right-handed systems

Left- and right-handed systems

Слайд 16

MATRICES AND SPACES ENTER THE MATRIX

MATRICES AND SPACES

ENTER THE MATRIX

Слайд 17

Matrices Matrix = Transformation placeholder So again: Local/Model matrix World matrix

Matrices

Matrix = Transformation placeholder
So again:
Local/Model matrix
World matrix
View/Camera matrix
WVP = world *

view * projection
Слайд 18

Classes/Utils Matrix3D Matrix3DUtils Matrix4x4

Classes/Utils

Matrix3D
Matrix3DUtils
Matrix4x4

Слайд 19

TRANSFORMATIONS

TRANSFORMATIONS

Слайд 20

Linear transformation Translation

Linear transformation

Translation

Слайд 21

Linear transformation Scale

Linear transformation

Scale

Слайд 22

Linear transformation Skew

Linear transformation

Skew

Слайд 23

Linear transformation Eulers Quaternions Avoids gimbal lock Slerp (Smooth interpolated rotation) Matrix – memory intensive Rotation

Linear transformation

Eulers
Quaternions
Avoids gimbal lock
Slerp (Smooth interpolated rotation)
Matrix – memory intensive

Rotation

Слайд 24

Multi linear transformation Stack of matrices Apply all at once to

Multi linear transformation

Stack of matrices
Apply all at once to an object
The

order is importent
Identity matrix
Слайд 25

Nonlinear transformations Sin curve displacement Warp

Nonlinear transformations

Sin curve displacement
Warp

Слайд 26

PROJECTIONS Converting a three-dimensional graphics object or scene into two dimensions

PROJECTIONS

Converting a three-dimensional graphics object
or scene into two dimensions

Слайд 27

Most common projections

Most common projections

Слайд 28

GRAPHICS PIPELINE

GRAPHICS PIPELINE

Слайд 29

Programmable pipeline Illustration from db-in.com

Programmable pipeline

Illustration from db-in.com

Слайд 30

Слайд 31

Слайд 32

Слайд 33

Слайд 34

Слайд 35

Слайд 36

Слайд 37

Слайд 38

Слайд 39

Слайд 40

Stages overview Post-processing Display on screen or readback: Render to buffer

Stages overview

Post-processing
Display on screen
or readback: Render to buffer and retrieve values.

Really slow!
Forward / Deferred rendering

Convert geometry into fragments
(r,g,b,a), (x,y,z,w), (tx,ty)
Interpolate vertex colors/texture coordinates over the fragment.
Each fragment has RGB color and depth value (z-buffer)

From Clip Space to Window Space.
e.g. [-1,1] ?[0,640]
Z-value retained for testing.

Don't render what we can't see
Clipping:
Remove primitives outside of the camera's view frustum
Back-face culling:
Remove triangles facing away from camera

From Camera Space to Clip Space
Orthographic or Perspective
Use frustum box

Primitive Assembling.
If geometry shader is available, new primitives can be generated.

From world space to camera space

Calculate lighting on each vertex.
Emissive + ambient + diffuse + specular ? output vertex color
Vertex shader

Transformations
Provide vertices and indicies as arrays and variables/constants to pipeline input.

Слайд 41

SHADERS The method to render an object.

SHADERS

The method to render an object.

Слайд 42

About shaders Small programs that runs on the GPU. Most shader

About shaders

Small programs that runs on the GPU.
Most shader languages are

the same.
Vertex and Fragment shaders work in pairs.
The pair is compiled into a Program
Uniforms, Attributes, Varyings, Built in attributes
Слайд 43

Low level shading language Assembly language ARB (GPU) AGAL (Adobe Graphics

Low level shading language

Assembly language
ARB (GPU)
AGAL (Adobe Graphics Assembly Language)

!!ARBfp1.0
TEMP

color;
MUL color, fragment.texcoord[0].y, 2.0;
ADD color, 1.0, -color;
ABS color, color;
ADD result.color, 1.0, -color;
MOV result.color.a, 1.0;
Слайд 44

High level shading languages HLSL – DirectX API Cg – NVIDIA

High level shading languages

HLSL – DirectX API
Cg – NVIDIA
GLSL – OpenGL
ShaderLab

– Unity3D
PixelBender3D – Molehill
HxSL – haXe Shader
Слайд 45

Vertex shader VS or VSH Executed at each vertex Transform between

Vertex shader

VS or VSH
Executed at each vertex
Transform between coordinate systems
Lighting
Defines

the final position of that vertex
Outputs some variables to the Fragment shader.
Слайд 46

Geometry Shader Dynamic creation of geometry on the GPU Only Shader

Geometry Shader

Dynamic creation of geometry on the GPU
Only Shader Model 4.0
Direct3D

10, OpenGL 3.2
Not available in OpenGL ES 2.0 (Molehill, webGL)
Слайд 47

Fragment Shader FSH Processed at each visible fragment Fragment != Pixel

Fragment Shader

FSH
Processed at each visible fragment
Fragment != Pixel
Handles bump effects, shadows

and lights, reflections, refractions, textures, ray casting and other effects.
Output is a pixel color in the format RGBA
Слайд 48

Texture objects Texels Power of Two (POT) 2, 4,…512, 1024 pixels Flipped pixel order (OpenGL) Integer/Floating-point

Texture objects

Texels
Power of Two (POT)  2, 4,…512, 1024 pixels
Flipped pixel order

(OpenGL)
Integer/Floating-point
Слайд 49

Texture Filtering Fixing artifacts Texture magnification/minification Mipmapping Different techniques:

Texture Filtering

Fixing artifacts
Texture magnification/minification
Mipmapping
Different techniques:

Слайд 50

Let’s have a look at the WegGL implementation (click on image) three.js

Let’s have a look at the WegGL implementation (click on image)

three.js


Слайд 51

Cubemap texture 3D texture Skybox Reflections Environment map

Cubemap texture

3D texture
Skybox
Reflections
Environment map

Слайд 52

Shader tool examples Shader Toy – WebGL MeShade – WebGL PixelBender3D

Shader tool examples

Shader Toy – WebGL
MeShade – WebGL
PixelBender3D – Molehill
Node

Based Shader Editor – Unity3D
Слайд 53

Interior mapping

Interior mapping

Слайд 54

Animations, Skin and Bones Tweens Animation controllers Blending Mixing/Additive Vertex animations in shader Procedurally animating

Animations, Skin and Bones

Tweens
Animation controllers Blending Mixing/Additive 
Vertex animations in shader
Procedurally animating

Слайд 55

Animations in Away3D Broomstick

Animations in Away3D Broomstick

Слайд 56

Materials Material is the collection of properties applied to an object.

Materials

Material is the collection of properties applied to an object.
Shaders is

the implemention. ”The code”
In Unity, think that materials is a collection of exposed properties of the shader.
Слайд 57

Some ingredients: Color Diffuse: base color Ambient: color of ambient light

Some ingredients:

Color
Diffuse: base color
Ambient: color of ambient light (shadowed parts). Mostly

the same as diffuse.
Specular: Highlight color
Emissive: Glow. Overrides shadows.
Alpha: Transparency
Texture (2D,Cubemap)
Shininess: size of specular highlights (gloss)
Reflection/Refraction
Bump-mapping: height, grayscaled image
Normal-mapping: Dot3 bump mapping, xyz->rgb
Paralax-mapping: height + direction, graycaled+rgb
Слайд 58

Example

Example

Слайд 59

Unitys Normal Shader Family

Unitys Normal Shader Family

Слайд 60

Lighting Uses normals Directional/point-lights Material settings to decide final color. Lighting

Lighting

Uses normals
Directional/point-lights
Material settings to decide final color.
Lighting is computed at each

vertex.
Light mapping (beast)
Deferred shading
Слайд 61

Lambert shading

Lambert shading

Слайд 62

Real-time shadows

Real-time shadows

Слайд 63

Quality and performance Non realtime-shadows fastest! Shadow map resolution Number of lights

Quality and performance

Non realtime-shadows fastest!
Shadow map resolution
Number of lights

Слайд 64

Example in Unity

Example in Unity

Слайд 65

Special effects Effects Color correction Postprocessing stage / GPU LDR/HDR, Tone mapping

Special effects

Effects
Color correction
Postprocessing stage / GPU
LDR/HDR, Tone mapping

Слайд 66

Слайд 67

Physics

Physics

Слайд 68

Very simple physics demo

Very simple physics demo

Слайд 69

Frameworks Goal: Games, experimental, Vizualisation? Reach: Plugin? Multiple platforms/screens? Cost: Open source? Licenced? Support: Large community?

Frameworks

Goal: Games, experimental, Vizualisation?
Reach: Plugin? Multiple platforms/screens?
Cost: Open source? Licenced?
Support: Large

community?
Слайд 70

Слайд 71

Unity3D Boo, C# and JavaScript Plugin Great and simple IDE Competent

Unity3D

Boo, C# and JavaScript
Plugin
Great and simple IDE
Competent and mature framework
Pro version

to get all goodies
Multiple screens/targets
Future: Export to flash/molehill
Слайд 72

Слайд 73

Flash/Molehill Actionscript Plugin 3D content always under the DisplayList All the

Flash/Molehill

Actionscript
Plugin
3D content always under the DisplayList
All the other stuff in

the flash player.
Molehill currently in alpha
Слайд 74

Flash 3D Engines

Flash 3D Engines

Слайд 75

Optimizing Profiling memory usage, cleanup/destroy Object Pooling! polygonal lab Take control

Optimizing

Profiling memory usage, cleanup/destroy
Object Pooling! polygonal lab
Take control of rendering pipeline
Compression/Model

to ByteArray
AWD, Away3Ds own format (Prefab)
Trends of resource-load in online 3D?
Optimize opcodes in swf: http://www.buraks.com/azoth/
Слайд 76

Слайд 77

WebGL Javascript No plugin Open / Royalty-free Not available in all

WebGL

Javascript
No plugin
Open / Royalty-free
Not available in all browsers yet
Frameworks in early

states
Probably available on iOS soon
Слайд 78

WebGL Frameworks

WebGL Frameworks

Слайд 79

Jellyfish Aleksandar Rodic

Jellyfish

Aleksandar Rodic

Слайд 80

Particles alteredqualia.com

Particles

alteredqualia.com

Слайд 81

Hello Racer HelloEnjoy™

Hello Racer

HelloEnjoy™

Слайд 82

Clouds Mr Doob

Clouds

Mr Doob

Слайд 83

WebGL vs. Molehill APIs HTML5 vs. Plugin. WebGL will probably run

WebGL vs. Molehill APIs

HTML5 vs. Plugin.
WebGL will probably run in iOS

browser.
Easy to port between them.
Once it running on the GPU, performance is hardware related regardless of API.
It is the high level frameworks that makes the difference.
Слайд 84

Debugging Profiling CPU FlashPreloadProfiler Profiling GPU Pix for windows Intel® Graphics Performance Analyzers (GPA)

Debugging

Profiling CPU
FlashPreloadProfiler
Profiling GPU
Pix for windows
Intel® Graphics Performance Analyzers

(GPA)
Слайд 85

3D Model filetypes

3D Model filetypes

Слайд 86

Learning tips

Learning tips

Слайд 87

Random interesting topics

Random interesting topics

Слайд 88

Random interesting topics Level of detail

Random interesting topics

Level of detail

Слайд 89

Octree, BSP Tree, Portals and Sectors Random interesting topics

Octree, BSP Tree, Portals and Sectors

Random interesting topics

Слайд 90

Global illumination / Ambient occlusion Random interesting topics

Global illumination / Ambient occlusion

Random interesting topics

Слайд 91

Raytracing/Raycasting/Raymarching Random interesting topics

Raytracing/Raycasting/Raymarching

Random interesting topics

Слайд 92

Some useful resources

Some useful resources

Слайд 93

Books and papers Away3D 3.6 essentials Mathematics for Game Developer by

Books and papers

Away3D 3.6 essentials
Mathematics for Game Developer by Christopher Tremblay
Mathematics

for 3D Game Programming and Computer Graphics by Eric Lengyel
Game Graphics Programming by Allen Sherrod
Realtime shadows
Raycasting in GPU shaders by Joost van Dongen