Week 3 - Friday.  What did we talk about last time?  Vertex shaders  Geometry shaders  Pixel shaders.

Slides:



Advertisements
Similar presentations
Vectors, Points, Lines and Planes Jim Van Verth Lars M. Bishop
Advertisements

Chapter 4 Euclidean Vector Spaces
Linear Algebra (Mathematics for CG) Reading: HB Appendix A
Perspective aperture ygyg yryr n zgzg y s = y g (n/z g ) ysys y s = y r (n/z r ) zrzr.
CS 450: COMPUTER GRAPHICS LINEAR ALGEBRA REVIEW SPRING 2015 DR. MICHAEL J. REALE.
Coordinatate systems are used to assign numeric values to locations with respect to a particular frame of reference commonly referred to as the origin.
Math Review Guest Lecturer: Michiel van de Panne Week 1, Wed Jan 9
Signal , Weight Vector Spaces and Linear Transformations
Signal , Weight Vector Spaces and Linear Transformations
Chapter 4.1 Mathematical Concepts
Chapter 4.1 Mathematical Concepts. 2 Applied Trigonometry Trigonometric functions Defined using right triangle  x y h.
CSC 123 – Computational Art Points and Vectors
Now Playing: My Mathematical Mind Spoon From Gimme Fiction Released May 10, 2005.
CSCE 590E Spring 2007 Basic Math By Jijun Tang. Applied Trigonometry Trigonometric functions  Defined using right triangle  x y h.
Computer Graphics CSC 630 Lecture 2- Linear Algebra.
Computer Graphics (Fall 2008) COMS 4160, Lecture 3: Transformations 1
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Math Review Week 1, Wed.
Class 25: Question 1 Which of the following vectors is orthogonal to the row space of A?
Linear Equations in Linear Algebra
Chapter 2: Vectors Ian Parberry University of North Texas Fletcher Dunn Valve Software 3D Math Primer for Graphics and Game Development.
Vectors.
Computer Graphics (Fall 2005) COMS 4160, Lecture 2: Review of Basic Math
Linear Algebra, Principal Component Analysis and their Chemometrics Applications.
Linear Algebra Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.
Week 4 - Monday.  What did we talk about last time?  Vectors.
Linear Algebra Review By Tim K. Marks UCSD Borrows heavily from: Jana Kosecka Virginia de Sa (UCSD) Cogsci 108F Linear.
A vector can be interpreted as a file of data A matrix is a collection of vectors and can be interpreted as a data base The red matrix contain three column.
Length and Dot Product in R n Notes: is called a unit vector. Notes: The length of a vector is also called its norm. Chapter 5 Inner Product Spaces.
Foundations of Computer Graphics (Fall 2012) CS 184, Lecture 2: Review of Basic Math
Week 3 - Wednesday.  What did we talk about last time?  Project 1  Graphics processing unit  Programmable shading.
Geometric Intuition Randy Gaul. Vectors, Points and Basis Matrices Rotation Matrices Dot product and how it’s useful Cross product and how it’s useful.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
Graphics Graphics Korea University cgvr.korea.ac.kr 1.2 Notation and Definition 그래픽스 연구실 정병선.
Graphics CSE 581 – Interactive Computer Graphics Mathematics for Computer Graphics CSE 581 – Roger Crawfis (slides developed from Korea University slides)
6.837 Linear Algebra Review Patrick Nichols Thursday, September 18, 2003.
1 February 24 Matrices 3.2 Matrices; Row reduction Standard form of a set of linear equations: Chapter 3 Linear Algebra Matrix of coefficients: Augmented.
Patrick Nichols Thursday, September 18, Linear Algebra Review.
Kansas State University Department of Computing and Information Sciences CIS 736: Computer Graphics Monday, 26 January 2004 William H. Hsu Department of.
Recap of linear algebra: vectors, matrices, transformations, … Background knowledge for 3DM Marc van Kreveld.
Little Linear Algebra Contents: Linear vector spaces Matrices Special Matrices Matrix & vector Norms.
Vectors & Matrices Marq Singer
Chapter 5 Orthogonality.
Linear Algebra Chapter 4 Vector Spaces.
Computer Graphics World, View and Projection Matrices CO2409 Computer Graphics Week 8.
Intro to 3D Models Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
6.837 Linear Algebra Review Patrick Nichols Thursday, September 18, 2003.
Digital Image Processing, 3rd ed. © 1992–2008 R. C. Gonzalez & R. E. Woods Gonzalez & Woods Matrices and Vectors Objective.
Mathematics for Graphics. 1 Objectives Introduce the elements of geometry  Scalars  Vectors  Points Develop mathematical operations among them in a.
Week 5 - Wednesday.  What did we talk about last time?  Project 2  Normal transforms  Euler angles  Quaternions.
1 1.3 © 2012 Pearson Education, Inc. Linear Equations in Linear Algebra VECTOR EQUATIONS.
CSE 381 – Advanced Game Programming GLSL. Rendering Revisited.
Class 26: Question 1 1.An orthogonal basis for A 2.An orthogonal basis for the column space of A 3.An orthogonal basis for the row space of A 4.An orthogonal.
1 Chapter 2: Geometric Camera Models Objective: Formulate the geometrical relationships between image and scene measurements Scene: a 3-D function, g(x,y,z)
Basic Entities Scalars - real numbers sizes/lengths/angles Vectors - typically 2D, 3D, 4D directions Points - typically 2D, 3D, 4D locations Basic Geometry.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2016 Tamara Munzner Math Basics Week 1, Fri.
CSCE 552 Fall 2012 Math By Jijun Tang. Applied Trigonometry Trigonometric functions  Defined using right triangle  x y h.
Chapter 4 Vector Spaces Linear Algebra. Ch04_2 Definition 1: ……………………………………………………………………. The elements in R n called …………. 4.1 The vector Space R n Addition.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Math Review Week 1, Fri.
Computer Graphics Mathematical Fundamentals Lecture 10 Taqdees A. Siddiqi
Linear Algebra Review Tuesday, September 7, 2010.
1 Objective To provide background material in support of topics in Digital Image Processing that are based on matrices and/or vectors. Review Matrices.
Graphics Graphics Korea University kucg.korea.ac.kr Mathematics for Computer Graphics 고려대학교 컴퓨터 그래픽스 연구실.
CSE 167 [Win 17], Lecture 2: Review of Basic Math Ravi Ramamoorthi
Week 4 - Monday CS361.
Elementary Linear Algebra
Lecture 03: Linear Algebra
Linear Algebra review (optional)
Math review - scalars, vectors, and matrices
Presentation transcript:

Week 3 - Friday

 What did we talk about last time?  Vertex shaders  Geometry shaders  Pixel shaders

 So, people in the industry have tried to collect useful programs for rendering things  A collection of shaders to achieve a particular rendering effect can be stored in an effect file (commonly with extension.fx )  The syntax of the effects language allows your application to set specific arguments

 You can download existing.fx files or write your own  There are also tools like NVIDIA's FX Composer 2.5 that allow you to create effects with a GUI  Now, let's examine the book's example effect file for Gooch shading

 Camera parameters are supplied automatically  Syntax is type id : semantic  type is a system defined type or a user defined struct  id is whatever identifier the user wants  semantic is a system defined use float4x4 WorldXf : World; float4x4 WorldITXf: WorldInverseTranspose; float4x4 WvpXf: WorldViewProjection; float4x4 WorldXf : World; float4x4 WorldITXf: WorldInverseTranspose; float4x4 WvpXf: WorldViewProjection;

 Default values are given for these variables  The annotations given inside angle brackets allow the outside program to set them float3 Lamp0Ps : Position < string Object = "PointLight0"; string UIName = "Lamp 0 Position"; string Space = "World"; > = {-0.5f, 2.0f, 1.25f}; float3 WarmColor < string UIName = "Gooch Warm Tone"; string UIWidget = "Color"; > = {1.0f, 0.9f, 0.15f}; float3 CoolColor < string UIName = "Gooch Cool Tone"; string UIWidget = "Color"; > = {0.05f, 0.05f, 0.6f}; float3 Lamp0Ps : Position < string Object = "PointLight0"; string UIName = "Lamp 0 Position"; string Space = "World"; > = {-0.5f, 2.0f, 1.25f}; float3 WarmColor < string UIName = "Gooch Warm Tone"; string UIWidget = "Color"; > = {1.0f, 0.9f, 0.15f}; float3 CoolColor < string UIName = "Gooch Cool Tone"; string UIWidget = "Color"; > = {0.05f, 0.05f, 0.6f};

 Input and output types are usually defined by the user  The TEXCOORD1 and TEXCOORD2 semantics are used for historical reasons struct appdata { float3 Position: POSITION; float3 Normal : NORMAL; } struct vertexOutput { float4 HPosition: POSITION; float3 LightVec: TEXCOORD1; float3 WorldNormal: TEXCOORD2; }; struct appdata { float3 Position: POSITION; float3 Normal : NORMAL; } struct vertexOutput { float4 HPosition: POSITION; float3 LightVec: TEXCOORD1; float3 WorldNormal: TEXCOORD2; };

vertexOutput std_VS(appdata IN) { vertexOutput OUT; float4 No = float4(IN.Normal,0); OUT.WorldNormal = mul(No,WorldITXf).xyz; float4 Po = float4(IN.Position,1); float4 Pw = mul(Po,WorldXf); OUT.LightVec = (Lamp0Pos – Pw.xyz); OUT.HPosition = mul(Po,WvpXf); return OUT; } vertexOutput std_VS(appdata IN) { vertexOutput OUT; float4 No = float4(IN.Normal,0); OUT.WorldNormal = mul(No,WorldITXf).xyz; float4 Po = float4(IN.Position,1); float4 Pw = mul(Po,WorldXf); OUT.LightVec = (Lamp0Pos – Pw.xyz); OUT.HPosition = mul(Po,WvpXf); return OUT; }

 We linearly interpolate between cool and warm colors based on the dot product float4 gooch_PS(vertexOutput IN) : COLOR { float3 Ln = normalize(IN.LightVec); float3 Nn = normalize(IN.WorldNormal); float ldn = dot(Ln,Nn); float mixer = 0.5 * (ldn + 1.0); float4 result = lerp(CoolColor, WarmColor, mixer); return result; } float4 gooch_PS(vertexOutput IN) : COLOR { float3 Ln = normalize(IN.LightVec); float3 Nn = normalize(IN.WorldNormal); float ldn = dot(Ln,Nn); float mixer = 0.5 * (ldn + 1.0); float4 result = lerp(CoolColor, WarmColor, mixer); return result; }

 Z-buffer configuration is done here technique Gooch { pass p0 { VertexShader = compile vs_2_0 std_VS(); PixelShader = compile ps_2_a gooch_PS(); ZEnable = true; ZWriteEnable = true; ZFunc = LessEqual; AlphaBlendEnable = false; } technique Gooch { pass p0 { VertexShader = compile vs_2_0 std_VS(); PixelShader = compile ps_2_a gooch_PS(); ZEnable = true; ZWriteEnable = true; ZFunc = LessEqual; AlphaBlendEnable = false; }

 The result of the shader given before applied to a teapot:

 The Utah teapot was modeled in 1975 by graphics pioneer Martin Newell at the University of Utah  It's actually taller than it looks  They distorted the model so that it would look right on their non-square pixel displays

 Original  Modern

Yeah… just what do you know about vectors?

 We refer to n-dimensional real Euclidean space as R n  A vector v in this space is an n-tuple, an ordered list of n real numbers  To match the book (and because we are computer scientists), we'll index these from 0 to n – 1  We will generally write our vectors as column vectors rather than row vectors

 We will be interested in a number of operations on vectors, including:  Addition  Scalar multiplication  Dot product  Norm

 Addition of two vectors is just element-by- element addition

 Vector addition is associative:  Vector addition is commutative:

 There is a unique vector for R n which is 0 = (0,0,…,0) with a total of n zeroes  o is additive identity:  For vector v, there is a unique inverse –v = (-v 0, -v 1, … -v n-1 )  -v is the additive inverse:

 Multiplication by a scalar is just element-by- element multiplication of that scalar

 Rules for scalar multiplication can easily be inferred from the normal properties of reals under addition and multiplication:

 The dot product is a form of multiplication between two vectors that produces a scalar

 Mathematical rules are one thing  Understanding how they are interpreted in geometry is something else  Unfortunately, this means getting more math to link up the existing math with geometry

 A set of vectors u 0, u 1, … u n-1 is linearly independent if the only scalars that satisfy the following identity are v 0 = v 1 = … = v n-1 = 0  In other words, you can't make any one vector out of any of the others

 A set of vectors u 0, u 1, … u n-1 spans R n if any vector v  R n can be written:  In addition, if v 0, v 1, …, v n-1 are uniquely determined for all v  R n, then u 0, u 1, … u n-1 form a basis of R n

 To properly describe R n, the vectors we give are actually scalar multiplied by each of the basis vectors u i  By convention, we leave off the basis vectors u i, because it would be cumbersome to show them  Also, they are often boring: (1,0,0), (0,1,0), and (0,0,1)

 A vector can either be a point in space or an arrow (direction and distance)  The norm of a vector is its distance from the origin (or the length of the arrow)  In R 2 and R 3, the dot product is: where  is the smallest angle between u and v

 A basis is orthogonal if every vector in the basis is orthogonal to every other (has dot product 0)  An orthogonal basis is orthonormal if every vector in it has length 1  The standard basis is orthonormal and made up of vectors e i which are all 0's except a 1 at location i

 We can find the orthogonal projection w of vector u onto vector v  Essentially, this means the part of u that's in v

 The cross product of two vectors finds a vector that is orthogonal to both  For 3D vectors u and v in an orthonormal basis, the cross product w is:

 More linear algebra  Matrices  Homogeneous notation  Geometric techniques

 Keep reading Appendix A  Assignment 1 due tonight by midnight!  Keep working on Project 1, due next Friday, February 6 by 11:59