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

Computer Graphics SS 2014 Rasterization PowerPoint PPT Presentation


  • 130 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

Rüdiger Westermann

Lehrstuhl für Computer Graphik und Visualisierung


Rasterizationbasedgraphicspipeline

  • Concept

    • Transformstrianglesandprojectsthetransformedtrianglesintothepixelraster

    • The rasterizerdeterminesthepixelsthatarecoveredby a triangleandgenerates a fragmentforeverycoveredpixel

    • Performsoperations (texturing,blending)on fragments


User / Driver

Vertex/GeometryStage

Pixel Stage

Texture 0

Texture 1

Texture 2

Texture 3

Rasterizationbasedgraphicspipeline

Vertex Stream

Transform

Rasterizer

Fragment Stream

Texturing

Blending/Ops


Rasterizationbasedgraphicspipeline

  • The pipelinestages

Geometry Processing

Modelview

TransformVertices

Perspective

TransformVertices

Geometry

Scan

ConversionTriangles

Fragment

Tests & OpsFragments

FramebufferPixels

TexturingFragments

BlendingFragments

Rasterization

Fragment Processing


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


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!


Rasterizationbasedgraphicspipeline

  • The pipelinestages

Geometry Processing

Modelview

TransformVertices

Perspective

TransformVertices

Geometry

Scan

ConversionTriangles

Fragment

Tests & OpsFragments

FramebufferPixels

TexturingFragments

BlendingFragments

Rasterization

Fragment 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

  • The GPU canonlyrendertriangles

Trianglesareflat!

A linear interpolationfunctionexistswithin a triangle– seebarycentricinterpolation


Geometryprocessing

  • Transformation – cameraanalogy

    • Modeling: scale, rotate, translatethe model

    • Viewing: positionandorientationofthecamera

    • Projection: adjustcameralens

    • Viewport: photograph

viewing volume

camera

Model


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


Geometryprocessing

  • Transformations

    • Transformations in homogeneouscoordinates

Rotation

Shear

Scaling

Translation

Homogeneous part

Projection


Geometry processing

  • Objects are placed in the global world coordinatespace

    • Done via the affine modeling transformation (see chapter on transformations)

Objectcoordinatesystem

World coordinatesystem


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 processing

  • How to build the viewing transformation

    • The user specifies:

      • Camera position C

      • Viewing direction D

      • Up vector U

U

D


Geometry processing

U

  • Move camera C to origin:

    • Translation by –C:Mtrans

D

U

D


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


ModelviewTransformation

Matrix M

Geometry processing

  • Modeling andviewingtransform in onesingletransformThemodelviewmatrix:

Vertex P

Transformedvertex& normalotherattributestypicallyremainunchanged

After themodelviewtransformtheverticesare in viewspace

Normal N


Geometryprocessing

  • The cameralensissetbydefiningthetransformationwhichprojectstheverticesontothescreen

  • This is a perspectivetransformationwiththecamerabeingthecenterofprojection

y

camera

z

screen


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

y

eye

z

View

Coordinates

are

perspectivelydistorted

near

far

y

eye

at

infinity

z

near

far


De-Homogenization

  • Observation:To project ontoz=1, dividecomponentsbyz

y

1

z


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 Projections

  • The projectionmatrix (n = near, f = far)

    • Not complete,seelater


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 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 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 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)


PerspectiveProjections

  • Modelview and perspective transformation in one single transformation

    vertex transformation:

    perspective (homogeneous) division: =


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


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


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


Rasterization

  • Fragment generation: foreachcoveredpixel, onefragmentisgenerated

  • Foreachfragment: per-vertex attributes (color, normal, z-value, texturecoordinates,…) areinterpolated at pixelcenter via barycentricinterpolation


Rasterization

  • Resultofrasterizationstage:A setoffragments, eachstoringitspixelcoordinateaswellasinterpolated z-value, color, texturecoordinate, normal, etc. A fragmentis in fact a surfacepointseenthroughtherespectivepixel

X,Y

z

RGB

u,v


  • Login