slide1
Download
Skip this Video
Download Presentation
Computer Graphics SS 2014 Rasterization

Loading in 2 Seconds...

play fullscreen
1 / 34

Computer Graphics SS 2014 Rasterization - PowerPoint PPT Presentation


  • 172 Views
  • Uploaded on

Computer Graphics SS 2014 Rasterization. Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung. Rasterization based graphics pipeline. Concept Transforms triangles and projects the transformed triangles into the pixel raster

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Computer Graphics SS 2014 Rasterization' - ganya


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
slide1
Computer Graphics

SS 2014

Rasterization

Rüdiger Westermann

Lehrstuhl für Computer Graphik und Visualisierung

rasterization based graphics pipeline
Rasterizationbasedgraphicspipeline
  • Concept
    • Transformstrianglesandprojectsthetransformedtrianglesintothepixelraster
    • The rasterizerdeterminesthepixelsthatarecoveredby a triangleandgenerates a fragmentforeverycoveredpixel
    • Performsoperations (texturing,blending)on fragments
rasterization based graphics pipeline1
User / Driver

Vertex/GeometryStage

Pixel Stage

Texture 0

Texture 1

Texture 2

Texture 3

Rasterizationbasedgraphicspipeline

Vertex Stream

Transform

Rasterizer

Fragment Stream

Texturing

Blending/Ops

rasterization based graphics pipeline2
Rasterizationbasedgraphicspipeline
  • The pipelinestages

Geometry Processing

Modelview

TransformVertices

Perspective

TransformVertices

Geometry

Scan

ConversionTriangles

Fragment

Tests & OpsFragments

FramebufferPixels

TexturingFragments

BlendingFragments

Rasterization

Fragment Processing

graphics pipeline on recent graphics cards
Graphics pipeline on recentgraphicscards

IB

Input Data

Memory

VB

Input Assembler

Buffer

Resources:

Stage (IA)

Buffers,

Textures,

Vertex Shader

Texture, Constant Buffer

Stage (VS)

Geometryisstored in vertex, indexandattributebuffers(seechaptermodelling.sharedvertexrep.)

Shadersareprogramswrittenbythegraphics

programmer

Geometry Shader

Texture, Constant Buffer

Stage (GS)

Stream Output

Buffer

Stage (SO)

Rasterizer Stage

(RS)

Texture, Constant Buffer

Pixel Shader

Stage (PS)

States

Output Merger

Stage (OM)

Output Data

Buffer, Texture, Constant Buffer

programmable graphics pipeline
Programmablegraphicspipeline
  • Allows „almost“ arbitrarygraphicseffectsbyperformingoperations on verticesandfragments
  • Shadinglanguages: GLSL (OpenGL), HLSL (DirectX), Nvidia CG (both)
    • Syntax similarto C/C++
    • Compile (atprogramstartup)  Link (shaderstages)  Run (drawobjects)
    • Hardware independent (compilerembeddedintodriver)
  • A graphicsengineprogrammerwritesshaderprograms!
rasterization based graphics pipeline3
Rasterizationbasedgraphicspipeline
  • The pipelinestages

Geometry Processing

Modelview

TransformVertices

Perspective

TransformVertices

Geometry

Scan

ConversionTriangles

Fragment

Tests & OpsFragments

FramebufferPixels

TexturingFragments

BlendingFragments

Rasterization

Fragment Processing

geometry processing
Geometry processing
  • Works on vertices; performed in thevertexshaderstage

Per-vertexattributes:

Coordinate (x,y,z,1)Color (RGB)Normal (nx,ny,nz,0)Texturecoordinate (u,v)

A setoftransformationmatrices,typicallyissued via theapplicationprogram

+

geometric primitives
Geometric primitives
  • The GPU canonlyrendertriangles

Trianglesareflat!

A linear interpolationfunctionexistswithin a triangle– seebarycentricinterpolation

geometry processing1
Geometryprocessing
  • Transformation – cameraanalogy
    • Modeling: scale, rotate, translatethe model
    • Viewing: positionandorientationofthecamera
    • Projection: adjustcameralens
    • Viewport: photograph

viewing volume

camera

Model

geometry processing2
Geometryprocessing
  • The transformationpipeline
    • Green: in thevertexshaderstage
    • Orange: in therasterizerstage

Normalized

device ccordinates

Viewspace

Objectspace

Clipspace

Window

coordinates

v

e

r

t

e

x

Modelview

Matrix

Projection

Matrix

Perspective

Division

Viewport

Transform

geometry processing3
Geometryprocessing
  • Transformations
    • Transformations in homogeneouscoordinates

Rotation

Shear

Scaling

Translation

Homogeneous part

Projection

geometry processing4
Geometry processing
  • Objects are placed in the global world coordinatespace
    • Done via the affine modeling transformation (see chapter on transformations)

Objectcoordinatesystem

World coordinatesystem

geometry processing5
Geometry processing
  • To render a portion of the world coordinatespace, one positions and orients the camera
    • The same image can be shotby fixing the camera in world space (eg. at (0.0.0), orienting along (0,0,1)), and transforming objects accordingly
    • This is the viewing transform
geometry processing6
Geometry processing
  • How to build the viewing transformation
    • The user specifies:
      • Camera position C
      • Viewing direction D
      • Up vector U

U

D

geometry processing7
Geometry processing

U

  • Move camera C to origin:
    • Translation by –C:Mtrans

D

U

D

geometry processing8
Geometry processing
  • Build orthonormal frame:
    • „right“R = DxU
    • „zenith“ U= RxD(only if U and D are not orthogonal)
  • Adjust orientation:
    • Matrix [R,U,D]maps [] to [R,U,D]
    • So use [R,U,D]-1
    • Final transform: = [R,U,D]-1Mtrans

U

D

U

D

geometry processing9
ModelviewTransformation

Matrix M

Geometry processing
  • Modeling andviewingtransform in onesingletransformThemodelviewmatrix:

Vertex P

Transformedvertex& normalotherattributestypicallyremainunchanged

After themodelviewtransformtheverticesare in viewspace

Normal N

geometry processing10
Geometryprocessing
  • The cameralensissetbydefiningthetransformationwhichprojectstheverticesontothescreen
  • This is a perspectivetransformationwiththecamerabeingthecenterofprojection

y

camera

z

screen

geometry processing11
Geometryprocessing
  • The perspectiveprojectionisdefinedbyspecifyingthe so calledviewfrustum
    • The field of view of the camera, or the region of space that is mapped onto the image plane
    • Defined by the field of view angle (in the 'y' direction), front & near plane, aspect ratio; or alternatively by n = near, f = far, r= right, l = left, t = top, b= bottom

(r,t,f)

(r,t,n)

width

(l,b,n)

fov

height

perspective projections
Perspective Projections

y

eye

z

View

Coordinates

are

perspectivelydistorted

near

far

y

eye

at

infinity

z

near

far

de h omogenization
De-Homogenization
  • Observation:To project ontoz=1, dividecomponentsbyz

y

1

z

perspective projections1
Perspectiveprojections
  • Matrix representation of the standard projection onto the z= 1 plane
    • Note that a division by one of the vector components cannot be realized as a matrix-vector operation
    • Thus, projection in two step: 1. matrix-vector operation to bring z component into the 4th component, 2. divide through 4th component
perspective projections2
Perspective Projections
  • The projectionmatrix (n = near, f = far)
    • Not complete,seelater
perspective projections3
Perspective Projections
  • Examples

Point on near plane remains on near plane

Point on far plane remains on far plane

Point on near plane remainsunchanged on near plane

perspective projections4
Perspective Projections
  • Examples

Point on far plane moves on far plane

Points betweennearandfarmovetowardsfar plane

Assume n = 1, f = 2, z = 1.5  z = 5/3 > 1.5

perspective projections5
Perspective Projections

y

eye

at

infinity

View

Coordinates

arefinally

transformed

Into

Normalized Device

Coordinates

z

near

far

y

1

eye

at

infinity

–1

1

z

–1

perspective projections6
Perspective Projections

View frustum

  • The API projectionmatrix
    • n = near, f = far, r = right, l = left, t = top, b = bottom
    • Scalesthetransformedfrustumto -1,1 andcentersaround (0,0,0) via a translation

(r,t,f)

(r,t,n)

(l,b,n)

perspective projections7
PerspectiveProjections
  • Modelview and perspective transformation in one single transformation

vertex transformation:

perspective (homogeneous) division: =

rasterization
Rasterization

normalized

device

view

object

homogeneousclip

window

v

e

r

t

e

x

Modelview

Matrix

Projection

Matrix

Perspective

Division

Viewport

Transform

transformedvertices

Rasterization

Fragment Generation

fragments

Green: in thevertexshaderstage

Orange: in therasterizerstage

rasterization1
Rasterization
  • Viewport transformationmapsfrom NDC (Normalized Device Coordinates) topixelcoordinates
    • Example: Px = 1024, Py = 512 
    • (613, 306) arethepixelcoordinatesofthevertex

Py

1

WindowCoordinates

Normalized Device Coordinates

-1

1

Px

-1

rasterization based graphics pipeline4
Rasterizationbasedgraphicspipeline
  • Resultofvertexshaderstage
    • Homogeneousvertexcoordinates after perspectiveprojection
    • (modelviewtransformed) normals
    • Additional attributeslikecolorandtexturecoordinates
  • The transformed, attributedvertexstreamispassedtotherasterizerstage
    • The rasterizerperformsdivisionbyw andmaps NDC topixelcoordinates
    • Foreachtriangle, therasterizerdeterminesthepixelscoveredbythistriangle – foreach such pixel a fragmentisgenerated
    • Per-vertex attributesareinterpolatedtoeachfragment
rasterization2
Rasterization
  • Fragment generation: foreachcoveredpixel, onefragmentisgenerated
  • Foreachfragment: per-vertex attributes (color, normal, z-value, texturecoordinates,…) areinterpolated at pixelcenter via barycentricinterpolation
rasterization3
Rasterization
  • Resultofrasterizationstage:A setoffragments, eachstoringitspixelcoordinateaswellasinterpolated z-value, color, texturecoordinate, normal, etc. A fragmentis in fact a surfacepointseenthroughtherespectivepixel

X,Y

z

RGB

u,v

ad