38
Realistic Rendering Realistic Rendering Pavel Zemčík Pavel Zemčík Department of Computer Science and Department of Computer Science and Engineering, Engineering, Faculty of Electrical Engineering and Faculty of Electrical Engineering and Computer Science, Computer Science, Technical University of Brno, Technical University of Brno, Czech Republic Czech Republic [email protected] [email protected]

Realistic Rendering Pavel Zemčík Department of Computer Science and Engineering, Faculty of Electrical Engineering and Computer Science, Technical University

  • View
    218

  • Download
    2

Embed Size (px)

Citation preview

Page 1: Realistic Rendering Pavel Zemčík Department of Computer Science and Engineering, Faculty of Electrical Engineering and Computer Science, Technical University

Realistic RenderingRealistic Rendering

Pavel ZemčíkPavel ZemčíkDepartment of Computer Science and Engineering,Department of Computer Science and Engineering,

Faculty of Electrical Engineering and Computer Faculty of Electrical Engineering and Computer Science,Science,

Technical University of Brno,Technical University of Brno,

Czech RepublicCzech Republic

[email protected]@dcse.fee.vutbr.cz

Page 2: Realistic Rendering Pavel Zemčík Department of Computer Science and Engineering, Faculty of Electrical Engineering and Computer Science, Technical University

What is realistic What is realistic rendering?rendering?

Realistic (photo-realistic) rendering Realistic (photo-realistic) rendering is the process of production of is the process of production of photograph-like images from a 3D photograph-like images from a 3D modelmodel

• Measure of “realism” is humanMeasure of “realism” is human

• Affected by wide range of factorsAffected by wide range of factors

Page 3: Realistic Rendering Pavel Zemčík Department of Computer Science and Engineering, Faculty of Electrical Engineering and Computer Science, Technical University

The realistic rendering The realistic rendering needsneeds

• Models of objects, environment, and Models of objects, environment, and lightlight

• Light features (particle and wave Light features (particle and wave effects)effects)

• Fine structure of objectsFine structure of objects’’ surface surface

• The material features (e.g. for glass)The material features (e.g. for glass)

Page 4: Realistic Rendering Pavel Zemčík Department of Computer Science and Engineering, Faculty of Electrical Engineering and Computer Science, Technical University

Is realistic rendering Is realistic rendering possible?possible?

NO!!! True realism is not possibleNO!!! True realism is not possible

• Accurate models not availableAccurate models not available

• Light features impossible to modelLight features impossible to model

• Any close approximation very Any close approximation very demandingdemanding

• Very rough approximations usedVery rough approximations used

Page 5: Realistic Rendering Pavel Zemčík Department of Computer Science and Engineering, Faculty of Electrical Engineering and Computer Science, Technical University

Rough realistic renderingRough realistic rendering

The approximations usually assumeThe approximations usually assume

• empty space between objectsempty space between objects

• no particle or wave light effectsno particle or wave light effects

• simple scene geometry and lightssimple scene geometry and lights

• simple materials and surfacessimple materials and surfaces

Page 6: Realistic Rendering Pavel Zemčík Department of Computer Science and Engineering, Faculty of Electrical Engineering and Computer Science, Technical University

Models of 3D scenesModels of 3D scenes

Page 7: Realistic Rendering Pavel Zemčík Department of Computer Science and Engineering, Faculty of Electrical Engineering and Computer Science, Technical University

Constructive Solid Constructive Solid GeometryGeometry

Constructive Solid Geometry (CSG) Constructive Solid Geometry (CSG) is a method for representing the 3D is a method for representing the 3D objectsobjects

• tree structure (binary or n-ary)tree structure (binary or n-ary)

• primitive objects in the leavesprimitive objects in the leaves

• CSG (set) operations in other nodesCSG (set) operations in other nodes

Page 8: Realistic Rendering Pavel Zemčík Department of Computer Science and Engineering, Faculty of Electrical Engineering and Computer Science, Technical University

CSG - exampleCSG - example

Page 9: Realistic Rendering Pavel Zemčík Department of Computer Science and Engineering, Faculty of Electrical Engineering and Computer Science, Technical University

CSG operationsCSG operations

CSG operations are generally set CSG operations are generally set operations on 3D objectsoperations on 3D objects’ volumes’ volumes

• unary operation unary operation (not) (not)

• binary operations binary operations (intersection, and) (intersection, and) (union, or) \ (difference) (union, or) \ (difference)

• operations can be extended to n-aryoperations can be extended to n-ary

Page 10: Realistic Rendering Pavel Zemčík Department of Computer Science and Engineering, Faculty of Electrical Engineering and Computer Science, Technical University

CSG surface exclusionCSG surface exclusion

CSG objects sometimes do not CSG objects sometimes do not include the surface (for include the surface (for mathematical purity)mathematical purity)

In such case, e.g. CSG union can be In such case, e.g. CSG union can be defined as:defined as:

}),,(,0|{

),(

YtXtxotx

YXCSG

Page 11: Realistic Rendering Pavel Zemčík Department of Computer Science and Engineering, Faculty of Electrical Engineering and Computer Science, Technical University

CSG - 3D exampleCSG - 3D example

Page 12: Realistic Rendering Pavel Zemčík Department of Computer Science and Engineering, Faculty of Electrical Engineering and Computer Science, Technical University

CSG - 3D rendered CSG - 3D rendered exampleexample

Page 13: Realistic Rendering Pavel Zemčík Department of Computer Science and Engineering, Faculty of Electrical Engineering and Computer Science, Technical University

CSG - 3D simple exampleCSG - 3D simple example

Page 14: Realistic Rendering Pavel Zemčík Department of Computer Science and Engineering, Faculty of Electrical Engineering and Computer Science, Technical University

CSG - 3D fractal exampleCSG - 3D fractal example

Page 15: Realistic Rendering Pavel Zemčík Department of Computer Science and Engineering, Faculty of Electrical Engineering and Computer Science, Technical University

CSG - 3D glass exampleCSG - 3D glass example

Page 16: Realistic Rendering Pavel Zemčík Department of Computer Science and Engineering, Faculty of Electrical Engineering and Computer Science, Technical University

CSG - 3D complex CSG - 3D complex exampleexample

Page 17: Realistic Rendering Pavel Zemčík Department of Computer Science and Engineering, Faculty of Electrical Engineering and Computer Science, Technical University

Rendering methods - Rendering methods - objectsobjects

• The objects are processed in a The objects are processed in a sequencesequence

• No objects interaction - no shadowsNo objects interaction - no shadows

Page 18: Realistic Rendering Pavel Zemčík Department of Computer Science and Engineering, Faculty of Electrical Engineering and Computer Science, Technical University

Rendering methods - Rendering methods - pixelspixels

• The pixels are processed in a The pixels are processed in a sequencesequence

• No global interaction - no half-No global interaction - no half-shadowsshadows

Page 19: Realistic Rendering Pavel Zemčík Department of Computer Science and Engineering, Faculty of Electrical Engineering and Computer Science, Technical University

Rendering methods - Rendering methods - scenescene

• The complete scene is processedThe complete scene is processed• Very complex - no sharp shadowsVery complex - no sharp shadows

Page 20: Realistic Rendering Pavel Zemčík Department of Computer Science and Engineering, Faculty of Electrical Engineering and Computer Science, Technical University

Rendering methods Rendering methods comparisoncomparison

Object Pixel Scene

Z-buffer -3D boards

Ray tracingray casting

Radiationparticle tracing

low realism high realism highest realism

very fast (0.01-0.1s) slow (100-1000s) very slow (hours)

no shadows sharp shadows only smooth shadows

CAD drawings,games, virtual reality,3D modelling

realistic images ofgeometrical objects,

medical imaging

realistic images, pre-calculation forgames, etc.

Page 21: Realistic Rendering Pavel Zemčík Department of Computer Science and Engineering, Faculty of Electrical Engineering and Computer Science, Technical University

Radiosity principleRadiosity principle

• Get form factorsGet form factors• Assign lightsAssign lights• Solve equationSolve equation• Render usingRender using

a pixel methoda pixel method

nn

n

nn l

l

l

x

x

x

x

x

f

f

fff

ff

0

0

10

00

2

1

1

3

2

1

32

232221

1211

Page 22: Realistic Rendering Pavel Zemčík Department of Computer Science and Engineering, Faculty of Electrical Engineering and Computer Science, Technical University

Ray tracing principleRay tracing principle The image is created by evaluation of The image is created by evaluation of

content of each of the picture elementscontent of each of the picture elements

Durer A.: The Art of Measurement, Volume IV, The Netherlands, 1538Durer A.: The Art of Measurement, Volume IV, The Netherlands, 1538

Page 23: Realistic Rendering Pavel Zemčík Department of Computer Science and Engineering, Faculty of Electrical Engineering and Computer Science, Technical University

Ray tracing algorithmRay tracing algorithm

For each pixelFor each pixel

• send a ray eye send a ray eye pixel pixel scene scene

• calculate what can be seencalculate what can be seen

• calculate the value of the pixel -calculate the value of the pixel -

• if necessary, proceed recursivelyif necessary, proceed recursively

Page 24: Realistic Rendering Pavel Zemčík Department of Computer Science and Engineering, Faculty of Electrical Engineering and Computer Science, Technical University

Ray tracing - secondary Ray tracing - secondary raysrays Secondary rays are necessary for Secondary rays are necessary for

evaluation of shadows and mirrorsevaluation of shadows and mirrors

Page 25: Realistic Rendering Pavel Zemčík Department of Computer Science and Engineering, Faculty of Electrical Engineering and Computer Science, Technical University

Sending a raySending a ray

• Simple task, involves 3D projective Simple task, involves 3D projective transformationtransformation

Page 26: Realistic Rendering Pavel Zemčík Department of Computer Science and Engineering, Faculty of Electrical Engineering and Computer Science, Technical University

Geometry - what can be Geometry - what can be seenseen

• Very complex task, in naive approach it Very complex task, in naive approach it involves calculation of intersection of the involves calculation of intersection of the ray with all objects in the sceneray with all objects in the scene

(intersection often involves quadratic (intersection often involves quadratic equation solution, or similar task)equation solution, or similar task)

Estimated complexity: (P+S)*NEstimated complexity: (P+S)*N

e.g. (256x256+3*256x256)*1024=256Me.g. (256x256+3*256x256)*1024=256M

Page 27: Realistic Rendering Pavel Zemčík Department of Computer Science and Engineering, Faculty of Electrical Engineering and Computer Science, Technical University

Calculation of pixel valueCalculation of pixel value

• Depends on the local light modelDepends on the local light model

Basic models include e.g.Basic models include e.g.

• flat modelflat model

• diffusiondiffusion

• Phong modelPhong model

• mirrormirror

Page 28: Realistic Rendering Pavel Zemčík Department of Computer Science and Engineering, Faculty of Electrical Engineering and Computer Science, Technical University

Geometry - sphereGeometry - sphere

Page 29: Realistic Rendering Pavel Zemčík Department of Computer Science and Engineering, Faculty of Electrical Engineering and Computer Science, Technical University

Geometry - sphere Geometry - sphere equationsequations

• DefinitionDefinition

• Intersection (note that |d|=1)Intersection (note that |d|=1)

oror

• Normal vectorNormal vector

}0)(|{=S 22 rpxx

0)( 22 rt pds

0))(())((2 222 rtt pspsd

dsy 1t

pyn

dsy 2t

Page 30: Realistic Rendering Pavel Zemčík Department of Computer Science and Engineering, Faculty of Electrical Engineering and Computer Science, Technical University

Geometry - halfspaceGeometry - halfspace

Page 31: Realistic Rendering Pavel Zemčík Department of Computer Science and Engineering, Faculty of Electrical Engineering and Computer Science, Technical University

Geometry - halfspace Geometry - halfspace equationsequations

• Definition (note that p·n is constant)Definition (note that p·n is constant)

• IntersectionIntersection

• Normal vector (already in definition)Normal vector (already in definition)

}0p|{H nnxx

0p)( nnds t

ndnsn

p

t

dsy t

n

Page 32: Realistic Rendering Pavel Zemčík Department of Computer Science and Engineering, Faculty of Electrical Engineering and Computer Science, Technical University

Geometry - cylinderGeometry - cylinder

Page 33: Realistic Rendering Pavel Zemčík Department of Computer Science and Engineering, Faculty of Electrical Engineering and Computer Science, Technical University

Geometry - cylinder Geometry - cylinder equationsequations

• DefinitionDefinition

• Intersection (substitution l=s-p, |d|=1)Intersection (substitution l=s-p, |d|=1)

• Normal vector (intersection reused)Normal vector (intersection reused)

}))(()(|{=C 222 r pxvpxx

222 ))(()( rtt pdsvpds

0))(())())((())(1( 22222 rtt ldlldlvvdvd

])()))((()())(([ 222 ddvdvldvdvln r

Page 34: Realistic Rendering Pavel Zemčík Department of Computer Science and Engineering, Faculty of Electrical Engineering and Computer Science, Technical University

Geometry - Quadric Geometry - Quadric equationsequations

• DefinitionDefinition

• Intersection (dIntersection (d’’, s, s’ are d, s in 4D)’ are d, s in 4D)

• NormalNormal

}0 |{G xQxx t

0) )(() )((2) )(( 2 sQsdQsdQd ttt tt

)]) (

,) (

,) (

[(dzdydx

ttt xQxxQxxQxn

Page 35: Realistic Rendering Pavel Zemčík Department of Computer Science and Engineering, Faculty of Electrical Engineering and Computer Science, Technical University

Geometry - CSGGeometry - CSG

Page 36: Realistic Rendering Pavel Zemčík Department of Computer Science and Engineering, Faculty of Electrical Engineering and Computer Science, Technical University

Geometry - CSG algorithmGeometry - CSG algorithm

• Shoot a ray & Convert sets to Shoot a ray & Convert sets to intervalsintervals

• Apply CSG operations to intervalsApply CSG operations to intervals

• or Convert to simpler list operationsor Convert to simpler list operations

• Get the “realGet the “real” intersection” intersection

Page 37: Realistic Rendering Pavel Zemčík Department of Computer Science and Engineering, Faculty of Electrical Engineering and Computer Science, Technical University

ReferencesReferences

• Gouraud H: Continouous Shading of Curved Surfaces, IEEE Gouraud H: Continouous Shading of Curved Surfaces, IEEE Transactions on Computer Graphics, n. 6, vol. C-20, june Transactions on Computer Graphics, n. 6, vol. C-20, june 1971, USA, pp. 623-6291971, USA, pp. 623-629

• Foley J D, Van Dam A: Fundamentals of Interactive Computer Foley J D, Van Dam A: Fundamentals of Interactive Computer Graphics, Addison-Wesley 1983, USAGraphics, Addison-Wesley 1983, USA

• Goral C M, Torrance K E, Greenberg D P, Battaile B: Goral C M, Torrance K E, Greenberg D P, Battaile B: Modelling The Modelling The Interaction of Light Between Diffuse Interaction of Light Between Diffuse Surfaces, sborník SIGGRAPH '84, ACM Computer Graphics, Surfaces, sborník SIGGRAPH '84, ACM Computer Graphics, USA, 1984USA, 1984

• Watt A, Watt M: Advanced Animation and Rendering Watt A, Watt M: Advanced Animation and Rendering Techniques, Addison-Wesley 1992, USA, str. 33-64Techniques, Addison-Wesley 1992, USA, str. 33-64

Page 38: Realistic Rendering Pavel Zemčík Department of Computer Science and Engineering, Faculty of Electrical Engineering and Computer Science, Technical University

The The endend