Computer Graphics
This presentation is the property of its rightful owner.
Sponsored Links
1 / 34

Computer Graphics SS 2014 Rasterization PowerPoint PPT Presentation


  • 120 Views
  • Uploaded on
  • Presentation posted in: General

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

Download Presentation

Computer Graphics SS 2014 Rasterization

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


Computer graphics ss 2014 rasterization

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


  • Login