Jens Krüger & Polina Kondratieva – Computer Graphics and Visualization Group computer graphics &...
-
Upload
stephen-wilkerson -
Category
Documents
-
view
225 -
download
1
Transcript of Jens Krüger & Polina Kondratieva – Computer Graphics and Visualization Group computer graphics &...
![Page 1: Jens Krüger & Polina Kondratieva – Computer Graphics and Visualization Group computer graphics & visualization 3D Rendering Praktikum: Shader Gallery The.](https://reader031.fdocuments.in/reader031/viewer/2022032200/56649f575503460f94c7b448/html5/thumbnails/1.jpg)
Jens Krüger & Polina Kondratieva – Computer Graphics and Visualization GroupJens Krüger & Polina Kondratieva – Computer Graphics and Visualization Group
computer graphics & computer graphics & visualizationvisualization
3D Rendering Praktikum:3D Rendering Praktikum:Shader GalleryShader Gallery
The Rendering PipelineThe Rendering Pipeline
![Page 2: Jens Krüger & Polina Kondratieva – Computer Graphics and Visualization Group computer graphics & visualization 3D Rendering Praktikum: Shader Gallery The.](https://reader031.fdocuments.in/reader031/viewer/2022032200/56649f575503460f94c7b448/html5/thumbnails/2.jpg)
computer graphics & computer graphics & visualizationvisualization
Kai Bürger & Polina Kondratieva – Computer Graphics and Kai Bürger & Polina Kondratieva – Computer Graphics and Visualization GroupVisualization Group
… … what an „end user“ sees.what an „end user“ sees.
The Rendering Pipeline …The Rendering Pipeline …
![Page 3: Jens Krüger & Polina Kondratieva – Computer Graphics and Visualization Group computer graphics & visualization 3D Rendering Praktikum: Shader Gallery The.](https://reader031.fdocuments.in/reader031/viewer/2022032200/56649f575503460f94c7b448/html5/thumbnails/3.jpg)
computer graphics & computer graphics & visualizationvisualization
Kai Bürger & Polina Kondratieva – Computer Graphics and Kai Bürger & Polina Kondratieva – Computer Graphics and Visualization GroupVisualization Group
The Rendering Pipeline …The Rendering Pipeline …
… … in picturesin pictures
![Page 4: Jens Krüger & Polina Kondratieva – Computer Graphics and Visualization Group computer graphics & visualization 3D Rendering Praktikum: Shader Gallery The.](https://reader031.fdocuments.in/reader031/viewer/2022032200/56649f575503460f94c7b448/html5/thumbnails/4.jpg)
computer graphics & computer graphics & visualizationvisualization
Kai Bürger & Polina Kondratieva – Computer Graphics and Kai Bürger & Polina Kondratieva – Computer Graphics and Visualization GroupVisualization Group
Rendering pipelineRendering pipeline
Geometrysubsystem
Rastersubsystem
Objects in3D world
Colorimage
2D primitives
![Page 5: Jens Krüger & Polina Kondratieva – Computer Graphics and Visualization Group computer graphics & visualization 3D Rendering Praktikum: Shader Gallery The.](https://reader031.fdocuments.in/reader031/viewer/2022032200/56649f575503460f94c7b448/html5/thumbnails/5.jpg)
computer graphics & computer graphics & visualizationvisualization
Kai Bürger & Polina Kondratieva – Computer Graphics and Kai Bürger & Polina Kondratieva – Computer Graphics and Visualization GroupVisualization Group
Pixel Stage
Vertex Stage
User / Driver
OverviewOverview
Transform & LightingTransform & Lighting Rasterizer
TexturingTexturingBlending/Ops
Texture 3Texture 2Texture 1Texture 0
![Page 6: Jens Krüger & Polina Kondratieva – Computer Graphics and Visualization Group computer graphics & visualization 3D Rendering Praktikum: Shader Gallery The.](https://reader031.fdocuments.in/reader031/viewer/2022032200/56649f575503460f94c7b448/html5/thumbnails/6.jpg)
computer graphics & computer graphics & visualizationvisualization
Kai Bürger & Polina Kondratieva – Computer Graphics and Kai Bürger & Polina Kondratieva – Computer Graphics and Visualization GroupVisualization Group
Rendering pipelineRendering pipeline
Geometrysubsystem
Rastersubsystem
Objects in3D world
Colorimage
2D primitives
2D
Objectcoordinates
Worldcoordinates
Eyecoordinates
Modellingtransform
Viewingtransform
Normalizingtransform
Normalized(Clip-)coord.
clipping
affine
affine
Model-View-Transformation
![Page 7: Jens Krüger & Polina Kondratieva – Computer Graphics and Visualization Group computer graphics & visualization 3D Rendering Praktikum: Shader Gallery The.](https://reader031.fdocuments.in/reader031/viewer/2022032200/56649f575503460f94c7b448/html5/thumbnails/7.jpg)
computer graphics & computer graphics & visualizationvisualization
Kai Bürger & Polina Kondratieva – Computer Graphics and Kai Bürger & Polina Kondratieva – Computer Graphics and Visualization GroupVisualization Group
TransformationsTransformations
- A transformation is like a function of a point
- Modeling:
- Define objects in „convenient“ coordinate systems
- Multiply-instantiated geometry
- Hierarchically defined linked figures
- Viewing:
- Window systems
- Virtual camera
- Perspective transformations
)(' PTP
![Page 8: Jens Krüger & Polina Kondratieva – Computer Graphics and Visualization Group computer graphics & visualization 3D Rendering Praktikum: Shader Gallery The.](https://reader031.fdocuments.in/reader031/viewer/2022032200/56649f575503460f94c7b448/html5/thumbnails/8.jpg)
computer graphics & computer graphics & visualizationvisualization
Kai Bürger & Polina Kondratieva – Computer Graphics and Kai Bürger & Polina Kondratieva – Computer Graphics and Visualization GroupVisualization Group
Point representationPoint representation
- Represent as row or column vector
- Affects the kind of matrices we can multiply with
y
xP
yxP
![Page 9: Jens Krüger & Polina Kondratieva – Computer Graphics and Visualization Group computer graphics & visualization 3D Rendering Praktikum: Shader Gallery The.](https://reader031.fdocuments.in/reader031/viewer/2022032200/56649f575503460f94c7b448/html5/thumbnails/9.jpg)
computer graphics & computer graphics & visualizationvisualization
Kai Bürger & Polina Kondratieva – Computer Graphics and Kai Bürger & Polina Kondratieva – Computer Graphics and Visualization GroupVisualization Group
Transformation representationTransformation representation
- Represent 2D transformations by a 2x2 matrix
- If the point is a column vector
- If the point is a row vector
dc
ba
y
x
dc
ba
y
x
Mpp
'
'
'
db
cayxyx
pMp T
''
'
![Page 10: Jens Krüger & Polina Kondratieva – Computer Graphics and Visualization Group computer graphics & visualization 3D Rendering Praktikum: Shader Gallery The.](https://reader031.fdocuments.in/reader031/viewer/2022032200/56649f575503460f94c7b448/html5/thumbnails/10.jpg)
computer graphics & computer graphics & visualizationvisualization
Kai Bürger & Polina Kondratieva – Computer Graphics and Kai Bürger & Polina Kondratieva – Computer Graphics and Visualization GroupVisualization Group
Linear transformationsLinear transformations
- Scaling
- Reflection
y
x
s
syxP0
0
sx = sy uniform scaling
S
10
01yxP
![Page 11: Jens Krüger & Polina Kondratieva – Computer Graphics and Visualization Group computer graphics & visualization 3D Rendering Praktikum: Shader Gallery The.](https://reader031.fdocuments.in/reader031/viewer/2022032200/56649f575503460f94c7b448/html5/thumbnails/11.jpg)
computer graphics & computer graphics & visualizationvisualization
Kai Bürger & Polina Kondratieva – Computer Graphics and Kai Bürger & Polina Kondratieva – Computer Graphics and Visualization GroupVisualization Group
Linear transformationsLinear transformations
- Shearing
- Rotation around origin by
1
01
ayxP
a1
cossin
sincosyxP
R(90°)
![Page 12: Jens Krüger & Polina Kondratieva – Computer Graphics and Visualization Group computer graphics & visualization 3D Rendering Praktikum: Shader Gallery The.](https://reader031.fdocuments.in/reader031/viewer/2022032200/56649f575503460f94c7b448/html5/thumbnails/12.jpg)
computer graphics & computer graphics & visualizationvisualization
Kai Bürger & Polina Kondratieva – Computer Graphics and Kai Bürger & Polina Kondratieva – Computer Graphics and Visualization GroupVisualization Group
Affine transformationsAffine transformations- Affine transformations: parallelism is preserved, length & angles not
- All linear transformations can be written as matrix multiplication
- What about translation ?
- We want to write
y
x
t
t
y
xP
T t
11
010
001
1 yx
yx
tytx
tt
yxP
Homogeneous coordinates!Homogeneous coordinates!
Tzyx pppP )0(vector
Tzyx pppP )1(point
![Page 13: Jens Krüger & Polina Kondratieva – Computer Graphics and Visualization Group computer graphics & visualization 3D Rendering Praktikum: Shader Gallery The.](https://reader031.fdocuments.in/reader031/viewer/2022032200/56649f575503460f94c7b448/html5/thumbnails/13.jpg)
computer graphics & computer graphics & visualizationvisualization
Kai Bürger & Polina Kondratieva – Computer Graphics and Kai Bürger & Polina Kondratieva – Computer Graphics and Visualization GroupVisualization Group
General Camera SetupGeneral Camera Setup
- Look at:- Position
- Orientation
- Frustum:- Camera parameters
- Viewport:- 2D coordinate system
Look atLook atLook atLook at
FrustumFrustumFrustumFrustum
ViewportViewportViewportViewport
![Page 14: Jens Krüger & Polina Kondratieva – Computer Graphics and Visualization Group computer graphics & visualization 3D Rendering Praktikum: Shader Gallery The.](https://reader031.fdocuments.in/reader031/viewer/2022032200/56649f575503460f94c7b448/html5/thumbnails/14.jpg)
computer graphics & computer graphics & visualizationvisualization
Kai Bürger & Polina Kondratieva – Computer Graphics and Kai Bürger & Polina Kondratieva – Computer Graphics and Visualization GroupVisualization Group
Camera look atCamera look at
- Move camera C to originTranslate by –C
- Build orthonormal frame„right“ R=DxU„zenith“ U=RxD
- Adjust orientationRotation [R,U,D][X,Y,-Z]
Right
View direction
Up
![Page 15: Jens Krüger & Polina Kondratieva – Computer Graphics and Visualization Group computer graphics & visualization 3D Rendering Praktikum: Shader Gallery The.](https://reader031.fdocuments.in/reader031/viewer/2022032200/56649f575503460f94c7b448/html5/thumbnails/15.jpg)
computer graphics & computer graphics & visualizationvisualization
Kai Bürger & Polina Kondratieva – Computer Graphics and Kai Bürger & Polina Kondratieva – Computer Graphics and Visualization GroupVisualization Group
Frustum (Perspective Projection)Frustum (Perspective Projection)
nf
nf
bB
tT
nb
nt
)tan(
)tan(
2
2
0100
00
00
00
2)(
2
2
nffn
nfnfbtbt
btn
lrlr
lrn
TT
tt
BB
bb
-f-f
-n-n
-z-z
yy
![Page 16: Jens Krüger & Polina Kondratieva – Computer Graphics and Visualization Group computer graphics & visualization 3D Rendering Praktikum: Shader Gallery The.](https://reader031.fdocuments.in/reader031/viewer/2022032200/56649f575503460f94c7b448/html5/thumbnails/16.jpg)
computer graphics & computer graphics & visualizationvisualization
Kai Bürger & Polina Kondratieva – Computer Graphics and Kai Bürger & Polina Kondratieva – Computer Graphics and Visualization GroupVisualization Group
Last TransformationsLast Transformations
- After all the projections we have:
- Perspective division:
- Viewport transformation:
TwzyxP )(
Tddddd wzwywxwzyxP )1()(
2/)(]2/)[(
)1()2/(
)2/(
nearDfarDznearDfarD
Oyvp
Oxvp
z
y
x
P
d
ydy
xdx
v
v
v
v
![Page 17: Jens Krüger & Polina Kondratieva – Computer Graphics and Visualization Group computer graphics & visualization 3D Rendering Praktikum: Shader Gallery The.](https://reader031.fdocuments.in/reader031/viewer/2022032200/56649f575503460f94c7b448/html5/thumbnails/17.jpg)
computer graphics & computer graphics & visualizationvisualization
Kai Bürger & Polina Kondratieva – Computer Graphics and Kai Bürger & Polina Kondratieva – Computer Graphics and Visualization GroupVisualization Group
Pixel Stage
Vertex Stage
User / Driver
OverviewOverview
Transform & LightingTransform & Lighting Rasterizer
TexturingTexturingBlending/Ops
Texture 3Texture 2Texture 1Texture 0
![Page 18: Jens Krüger & Polina Kondratieva – Computer Graphics and Visualization Group computer graphics & visualization 3D Rendering Praktikum: Shader Gallery The.](https://reader031.fdocuments.in/reader031/viewer/2022032200/56649f575503460f94c7b448/html5/thumbnails/18.jpg)
computer graphics & computer graphics & visualizationvisualization
Kai Bürger & Polina Kondratieva – Computer Graphics and Kai Bürger & Polina Kondratieva – Computer Graphics and Visualization GroupVisualization Group
Bresenham (Line Drawing)Bresenham (Line Drawing)
pp xxmyy
myy
mxxmyxxmyy
xxmyy
kk
ppppk
ppk
1
1 1
![Page 19: Jens Krüger & Polina Kondratieva – Computer Graphics and Visualization Group computer graphics & visualization 3D Rendering Praktikum: Shader Gallery The.](https://reader031.fdocuments.in/reader031/viewer/2022032200/56649f575503460f94c7b448/html5/thumbnails/19.jpg)
computer graphics & computer graphics & visualizationvisualization
Kai Bürger & Polina Kondratieva – Computer Graphics and Kai Bürger & Polina Kondratieva – Computer Graphics and Visualization GroupVisualization Group
Getting to Bresenham …Getting to Bresenham …/*********************************
* Input:
* xP: x-value of the startpoint
* yP: y-value of the startpoint
* xQ: x-value of the endpoint
* yQ: y-value of the endpoint
*********************************/
function drawLine(int xP, int yP, int xQ, int yQ) {
x = xP;
y = yP;
d = 0;
m = (yQ - yP) / (xQ - xP)
while(true) {
// put the pixel on the screen
putPixel(x, y);
if(x == xQ)
break;
x++;
d += m;
if(d > 0.5) {
y++;
d--;
}
}
}
/*********************************
* Input:
* xP: x-value of the startpoint
* yP: y-value of the startpoint
* xQ: x-value of the endpoint
* yQ: y-value of the endpoint
*********************************/
function drawLine(int xP, int yP, int xQ, int yQ) {
x = xP;
y = yP;
d = 0;
m = (yQ - yP) / (xQ - xP)
while(true) {
// put the pixel on the screen
putPixel(x, y);
if(x == xQ)
break;
x++;
d += m;
if(d > 0.5) {
y++;
d--;
}
}
}
Problem:• still floating point arithmetic
Obersvation:• m is rational• d is rational
![Page 20: Jens Krüger & Polina Kondratieva – Computer Graphics and Visualization Group computer graphics & visualization 3D Rendering Praktikum: Shader Gallery The.](https://reader031.fdocuments.in/reader031/viewer/2022032200/56649f575503460f94c7b448/html5/thumbnails/20.jpg)
computer graphics & computer graphics & visualizationvisualization
Kai Bürger & Polina Kondratieva – Computer Graphics and Kai Bürger & Polina Kondratieva – Computer Graphics and Visualization GroupVisualization Group
Bresenham …Bresenham …
function drawLine(int xP, int yP, int xQ, int yQ) {
x = xP;
y = yP;
D = 0;
H = xQ - xP;
c = 2 * H;
M = 2 * (yQ - yP);
while(true) {
putPixel(x, y);
if(x == xQ) break;
x++;
D += M;
if(D > H) {
y++;
D -= c;
}
}
}
function drawLine(int xP, int yP, int xQ, int yQ) {
x = xP;
y = yP;
D = 0;
H = xQ - xP;
c = 2 * H;
M = 2 * (yQ - yP);
while(true) {
putPixel(x, y);
if(x == xQ) break;
x++;
D += M;
if(D > H) {
y++;
D -= c;
}
}
}
Introduce the following integer variables:
•
•
•
•
pq xxc 2:
pq yymcM 2:
dcD :
pq xxcH 5,0: