Level of Details in Computer Rendering - · PDF fileLevel of Details in Computer Rendering...

30
2/23/2005 © Ariel Shamir Level of Details in Computer Rendering Ariel Shamir Ariel Shamir Ariel Shamir 2/23/2005 © Ariel Shamir Overview 1. Photo realism vs. Non photo realism (NPR) 2. Objects representations 3. Level of details 1. 1. Photo realism vs. Non photo Photo realism vs. Non photo realism (NPR) realism (NPR) 2. 2. Objects representations Objects representations 3. 3. Level of details Level of details

Transcript of Level of Details in Computer Rendering - · PDF fileLevel of Details in Computer Rendering...

2/23/2005 © Ariel Shamir �

Level of Details inComputer Rendering

Ariel ShamirAriel ShamirAriel Shamir

2/23/2005 © Ariel Shamir �

Overview1. Photo realism vs. Non photo

realism (NPR)

2. Objects representations

3. Level of details

1.1. Photo realism vs. Non photo Photo realism vs. Non photo realism (NPR)realism (NPR)

2.2. Objects representationsObjects representations

3.3. Level of detailsLevel of details

2/23/2005 © Ariel Shamir �

Photo Realism Vs. Non

2/23/2005 © Ariel Shamir �

Pixar Demonstrations

2/23/2005 © Ariel Shamir �

Sketching, Pen-and-Ink

2/23/2005 © Ariel Shamir �

Painterly Style

2/23/2005 © Ariel Shamir �

Enhanced Illustration

2/23/2005 © Ariel Shamir �

Representations

2/23/2005 © Ariel Shamir

Object Representations Schemes in 3DSamples:• Point Clouds

• Images

Boundary:• Implicit

• Parametric

• Meshes

• Subdivision

Samples:Samples:•• Point CloudsPoint Clouds

•• ImagesImages

Boundary:Boundary:•• ImplicitImplicit

•• ParametricParametric

•• MeshesMeshes

•• SubdivisionSubdivision

Volume:• Voxels

• Octree

• BSP

High Level:• CSG

• Skeleton, Sweep

• Scene Graph

• Constraints

• Feature Based

Volume:Volume:•• VoxelsVoxels

•• OctreeOctree

•• BSPBSP

High Level:High Level:•• CSGCSG

•• Skeleton, SweepSkeleton, Sweep

•• Scene GraphScene Graph

•• ConstraintsConstraints

•• Feature BasedFeature Based

2/23/2005 © Ariel Shamir �

Meshes

2/23/2005 © Ariel Shamir ��

Entities & RelationsThe entities in a boundary mesh are faces, edges, vertices (in volumetric also elements).The relations between these entities are incidence & Adjacency:FF, FE, FVEF, EE, EVVF,VE,VV

The entities in a boundary mesh are faces, The entities in a boundary mesh are faces, edges, vertices (in volumetric also edges, vertices (in volumetric also elements).elements).

The relations between these entities are The relations between these entities are incidence & Adjacency:incidence & Adjacency:FF, FE, FVFF, FE, FV

EF, EE, EVEF, EE, EV

VF,VE,VVVF,VE,VVf1

f2e1

e2

e3 e4

e5

v1

v3 v4

v2

2/23/2005 © Ariel Shamir ��

Separation of Topology and GeometryThe relations between the all entities in the mesh are the topology (connectivity) of the mesh.The positions of the entities in space are the geometry of the mesh.A mesh is defined by its topology and geometry together, but they can be separated as different views of the object.

The relations between the all entities in The relations between the all entities in the mesh are the the mesh are the topologytopology (connectivity) of (connectivity) of the mesh.the mesh.

The positions of the entities in space are The positions of the entities in space are the the geometrygeometry of the mesh.of the mesh.

A mesh is defined by its topology and A mesh is defined by its topology and geometry together, but they can be geometry together, but they can be separated as different views of the object.separated as different views of the object.

2/23/2005 © Ariel Shamir ��

Polygonal Mesh RepresentationThe description of all relations is the topology (connectivity) of the mesh.THE representation issue: which of those relations we store explicitly and which (and how) implicitly?Most used in graphics: triangle soups and indexed face set.In solid modeling: half-edge, winged-edge.

The description of all relations is the The description of all relations is the topology (connectivity) of the mesh.topology (connectivity) of the mesh.

THE representation issue: which of those THE representation issue: which of those relations we store explicitly and which relations we store explicitly and which (and how) implicitly?(and how) implicitly?

Most used in graphics: triangle soups and Most used in graphics: triangle soups and indexed face set.indexed face set.

In solid modeling: halfIn solid modeling: half--edge, wingededge, winged--edge.edge.

2/23/2005 © Ariel Shamir ��

Triangle Soup(x00,y00,z00) (x01,y01,z01) (x02,y02,z02) (x10,y10,z10) (x11,y11,z11) (x12,y12,z12)

(xn0,yn0,zn0) (xn1,yn1,zn1) (xn2,yn2,zn2)

Do we have any relations?Is this an efficient representation?

(x(x0000,y,y0000,z,z0000) (x) (x0101,y,y0101,z,z0101) (x) (x0202,y,y0202,z,z0202) ) (x(x1010,y,y1010,z,z1010) (x) (x1111,y,y1111,z,z1111) (x) (x1212,y,y1212,z,z1212))

……

(x(xn0n0,y,yn0n0,z,zn0n0) (x) (xn1n1,y,yn1n1,z,zn1n1) (x) (xn2n2,y,yn2n2,z,zn2n2))

Do we have any relations?Do we have any relations?Is this an efficient representation?Is this an efficient representation?

2/23/2005 © Ariel Shamir ��

Index Face SetV0… Vn then F0 … Fm(x0,y0,z0)

(xn,yn,zn)

(i0,j0,k0)

(im,jm,km)

Maybe other information: N0…Nn

Which relation we have?

VV00…… VVnn then Fthen F00 …… FFmm(x(x00,y,y00,z,z00))

……

((xxnn,y,ynn,z,znn))

(i(i00,j,j00,k,k00))

……

((iimm,j,jmm,k,kmm))

Maybe other information: NMaybe other information: N00……NNnn

Which relation we have?Which relation we have? FF��������VV

2/23/2005 © Ariel Shamir ��

Display DeviceDisplay devices (screens, printers etc.) are usually raster devices. This means they use discrete 2D color elements called pixels to display images.

As a consequence every type of virtual model must be turned into 2D pixels in order to be viewed!

Display devices (screens, printers etc.) are Display devices (screens, printers etc.) are usually usually rasterraster devices. This means they use devices. This means they use discrete 2D color elements called discrete 2D color elements called pixelspixels to to display images.display images.

As a consequence every type of virtual As a consequence every type of virtual model must be turned into 2D pixels in model must be turned into 2D pixels in order to be viewed!order to be viewed!

2/23/2005 © Ariel Shamir ��

Hardware SupportMost computers today include a “video card”. It is in fact a collection of hardware implementations of a rendering pipeline.

Most computers today include a Most computers today include a ““video cardvideo card””. It is in fact a collection . It is in fact a collection of hardware implementations of a of hardware implementations of a rendering pipelinerendering pipeline..

2/23/2005 © Ariel Shamir ��

The Rendering Pipeline

2/23/2005 © Ariel Shamir �

Visibility & ShadingIn terms of converting a 3D scene to a 2D image, one can think of two basic rendering tasks:• Visibility determination: what is visible

and what is occluded.

• Shading: what is the color of each visible 3D element (and 2D pixel)

In terms of converting a 3D scene to a In terms of converting a 3D scene to a 2D image, one can think of two basic 2D image, one can think of two basic rendering tasks:rendering tasks:•• Visibility determination: what is visible Visibility determination: what is visible

and what is occluded.and what is occluded.

•• Shading: what is the color of each visible Shading: what is the color of each visible 3D element (and 2D pixel)3D element (and 2D pixel)

2/23/2005 © Ariel Shamir �

3D Projection & 2D Rasterization

Virtual World Models

Projection

Rasterization

RasterScreen

Hardware support for triangles!

��

2/23/2005 © Ariel Shamir ��

Visibility Using The Z-bufferAny pixel rendered holds a color and a distance from the viewer (z).Pixels are accumulated in a buffer using the following algorithm:

Clear Z buffer (set z to infinity and store bg-color)

For each new pixel P(i,j) rendered

If the distance zP of P is smaller than Z(i,j)

store the zP & color of P in Z(i,j)

Any pixel rendered holds a color and a Any pixel rendered holds a color and a distance from the viewer (z).distance from the viewer (z).

Pixels are accumulated in a buffer using Pixels are accumulated in a buffer using the following algorithm:the following algorithm:

Clear Z buffer (set z to infinity and store Clear Z buffer (set z to infinity and store bgbg--color)color)

For each new pixel P(i,j) renderedFor each new pixel P(i,j) rendered

If the distance If the distance zzPP of P is smaller than Z(i,j)of P is smaller than Z(i,j)

store the store the zzPP & color of P in Z(i,j)& color of P in Z(i,j)

2/23/2005 © Ariel Shamir ��

Illumination & ShadingThe color of each point on a 3D object is calculated according to:The color of each point on a 3D object The color of each point on a 3D object is calculated according to:is calculated according to:

��

2/23/2005 © Ariel Shamir ��

Object PropertiesAn object O material properties includes a diffuse component Od���� and a specular components Os���� for each color (e.g. �������� {R,G,B}).It also includes ambient diffuse and specular reflection coefficients:ka kd ks

An object An object OO material properties material properties includes a diffuse component includes a diffuse component OOdd�������� and and a a specularspecular components components OOss�������� for each for each color (e.g. color (e.g. ���������������� {R,G,B}).{R,G,B}).It also includes ambient diffuse and It also includes ambient diffuse and specularspecular reflection coefficients:reflection coefficients:kka a kkdd kkss

2/23/2005 © Ariel Shamir ��

Lights PropertiesThere is a global ambient light intensity Ia����

There are multiple point light sources, each light i has its own intensity Ip����i

There is a light attenuation factor for each light i fatt i

There is a global ambient light There is a global ambient light intensity intensity IIaa��������

There are multiple point light There are multiple point light sources, each light i has its own sources, each light i has its own intensity intensity IIpp��������ii

There is a light attenuation factor for There is a light attenuation factor for each light i each light i ffattatt ii

��

2/23/2005 © Ariel Shamir ��

Basic Display PrimitivesThe rendering pipeline supports two basic

display primitives:1. Pixels (e.g. from images) are used

directly or combined into the image.2. Polygon (usually triangle) are

converted to pixels using vertex information by rasterization and interpolation.

The rendering pipeline supports two basic The rendering pipeline supports two basic display primitives:display primitives:

1.1. Pixels (e.g. from images) are used Pixels (e.g. from images) are used directly or combined into the image.directly or combined into the image.

2.2. Polygon (usually triangle) are Polygon (usually triangle) are converted to pixels using vertex converted to pixels using vertex information by information by rasterizationrasterization and and interpolation.interpolation.

2/23/2005 © Ariel Shamir ��

Why Triangles?•Most simple polygon, a planar polygon.•Simplifies hardware design and implementation.•Every polygon can be triangulated.•Higher degree surfaces can be approximated to any extent by triangles.•Bilinear interpolation gives reasonable results (color, position, normal).

••Most simple polygon, a planar polygon.Most simple polygon, a planar polygon.

••Simplifies hardware design and Simplifies hardware design and implementation.implementation.••Every polygon can be triangulated.Every polygon can be triangulated.

••Higher degree surfaces can be Higher degree surfaces can be approximated to any extent by triangles.approximated to any extent by triangles.

••Bilinear interpolation gives reasonable Bilinear interpolation gives reasonable results (color, position, normal).results (color, position, normal).

��

2/23/2005 © Ariel Shamir ��

Vertex InformationPosition in space (Depth)

Normal

Color/Shading

Texture map coordinate

Position in space (Depth) Position in space (Depth)

NormalNormal

Color/ShadingColor/Shading

Texture map coordinateTexture map coordinate

OpenGL demo

2/23/2005 © Ariel Shamir ��

From Triangle to PixelsTriangles are planar, this means a simple bilinear interpolation can be used to interpolate the attributes from the vertices to any pixel inside.

Triangles are planar, this means a Triangles are planar, this means a simple bilinear interpolation can be simple bilinear interpolation can be used to interpolate the attributes used to interpolate the attributes from the vertices to any pixel inside.from the vertices to any pixel inside.

��

2/23/2005 © Ariel Shamir �

Guarard Vs. PhongShading• Guarard: calculate color in corners and

interpolate

• Phong: interpolate normals and calculate colors at each pixel

•• GuarardGuarard: calculate color in corners and : calculate color in corners and interpolateinterpolate

•• PhongPhong: interpolate : interpolate normalsnormals and calculate and calculate colors at each pixelcolors at each pixel

Phong

Flat

Guarard

2/23/2005 © Ariel Shamir �

Normal Bilinear Smoothing

SMF demo

��

2/23/2005 © Ariel Shamir ��

From Model To Triangles To Pixels

Model

Triangulation

TrianglesPixels

Rasterization

2/23/2005 © Ariel Shamir ��

The Other Option: Pixels (Points)The algorithm composes the image pixels by itself. No rasterization is used!• Example: ray tracing is a technique to create more realistic

images from modeled scenes.

The algorithm composes the image pixels by The algorithm composes the image pixels by itself. No itself. No rasterizationrasterization is used!is used!•• Example: Example: ray tracingray tracing is a technique to create more realistic is a technique to create more realistic

images from modeled scenes.images from modeled scenes.

��

2/23/2005 © Ariel Shamir ��

Ray Tracing

2/23/2005 © Ariel Shamir ��

Ray Tracing IdeaSimulate the path that light rays take as they bounce around within the world - they are ‘traced’ through the scene.

Simulate the path that light rays take Simulate the path that light rays take as they bounce around within the as they bounce around within the world world -- they are they are ‘‘tracedtraced’’ through the through the scene.scene.

When tracing rays from When tracing rays from light sources to the eye light sources to the eye many are wasted since many are wasted since they never reach the eyethey never reach the eye

��

2/23/2005 © Ariel Shamir ��

‘Reverse’ TracingEach pixel color is created by shooting a ray from the eye through the pixel into the scene and tracing its refractions and reflections up to the light source.

How many?

Each pixel color is created by Each pixel color is created by shooting a ray from the eye through shooting a ray from the eye through the pixel into the scene and tracing its the pixel into the scene and tracing its refractions and reflections up to the refractions and reflections up to the light source.light source.

How many?How many?

2/23/2005 © Ariel Shamir ��

Hardware Aware Efficient RenderingIn terms of rendering the best model is a polygonal boundary representation:

A triangle mesh.In fact, it is heavily used in computer graphics and animation.Disadvantages?

In terms of rendering the best In terms of rendering the best model is a polygonal boundary model is a polygonal boundary representation: representation:

A triangle mesh.A triangle mesh.

In fact, it is heavily used in In fact, it is heavily used in computer graphics and computer graphics and animation.animation.

DisadvantageDisadvantages?s?

2/23/2005 © Ariel Shamir ��

Polygonal Model Deficiencies• Limited expressive power: it is only a

linear model.

• No smoothness: only C0.

• No realism: surfaces in real world are rarely polygonal.

• Rendering complexity is dependent on the scene, not the image, complexity.

•• Limited expressive power: it is only a Limited expressive power: it is only a linear model. linear model.

•• No smoothness: only CNo smoothness: only C00..

•• No realism: surfaces in real world are No realism: surfaces in real world are rarely polygonal.rarely polygonal.

•• Rendering complexity is dependent on Rendering complexity is dependent on the scene, not the image, complexity.the scene, not the image, complexity.

2/23/2005 © Ariel Shamir ��

Triangle RenderingRendering using triangles is most efficient if each triangle covers a number of pixels (at least more than one).If we have many triangles for each pixel than we do not need most of them.Rendering is always dependent on the number of triangles in the scene. Bad examples?

Rendering using triangles is most efficient Rendering using triangles is most efficient if each triangle covers a number of pixels if each triangle covers a number of pixels (at least more than one).(at least more than one).

If we have many triangles for each pixel If we have many triangles for each pixel than we do not need most of them.than we do not need most of them.

Rendering is always dependent on the Rendering is always dependent on the number of triangles in the scene. number of triangles in the scene.

Bad examples?Bad examples?

2/23/2005 © Ariel Shamir �

Complex Environments & Objects

2500 horses 50 million triangles

90000 objects575 million triangles

One complex object376,436 triangles

2/23/2005 © Ariel Shamir �

Number of Pixels Vs. Scene ComplexityThe end result is an image with a specified number of pixels.

Is there a way to make rendering an order of the number of pixels instead of the scene complexity?

This would be beneficial for large models, complex models and large scenes.

The end result is an image with a specified The end result is an image with a specified number of pixels.number of pixels.

Is there a way to make rendering an order Is there a way to make rendering an order of the number of pixels instead of the scene of the number of pixels instead of the scene complexity?complexity?

This would be beneficial for large models, This would be beneficial for large models, complex models and large scenes.complex models and large scenes.

��

2/23/2005 © Ariel Shamir ��

SolutionsMulti-resolution models: • Use the appropriate resolution as a function of the

number of pixels (next lecture).

Image based rendering: • The model is a set of images taken from different

directions.

• No model � very difficult to create new images.

Others…

MultiMulti--resolution models: resolution models: •• Use the appropriate resolution as a function of the Use the appropriate resolution as a function of the

number of pixels (next lecture).number of pixels (next lecture).

Image based rendering: Image based rendering: •• The model is a set of images taken from different The model is a set of images taken from different

directions.directions.

•• No model No model �� vvery difficult to create new images.ery difficult to create new images.

OthersOthers……

2/23/2005 © Ariel Shamir ��

Other Rendering Option?Maybe we do not need triangles!

Maybe there are other primitives for rendering which will be faster than converting a high degree models to triangles and then rendering.

Maybe we do not need triangles!Maybe we do not need triangles!

Maybe there are other primitives for Maybe there are other primitives for rendering which will be faster than rendering which will be faster than converting a high degree models to converting a high degree models to triangles and then rendering.triangles and then rendering.

��

2/23/2005 © Ariel Shamir ��

Point Based RenderingAny image is a sampling result of objects interaction with light.In order to render we can sample the object with respect to its• Geometric properties

• Material properties

The simplest primitive needed is in fact a point and a normal.

Any image is a sampling result of objects Any image is a sampling result of objects interaction with light.interaction with light.

In order to render we can sample the object In order to render we can sample the object with respect to itswith respect to its•• Geometric propertiesGeometric properties

•• Material propertiesMaterial properties

The simplest primitive needed is in fact a The simplest primitive needed is in fact a point and a normal. point and a normal.

2/23/2005 © Ariel Shamir ��

Image As Samples

��

2/23/2005 © Ariel Shamir ��

SplatsOnce we know the color calculation according to the position and normal, we can create a ‘splat’ (any geometric 2D shape) and send it to the z-buffer.

Once we know the color calculation Once we know the color calculation according to the position and normal, according to the position and normal, we can create a we can create a ‘‘splatsplat’’ (any geometric (any geometric 2D shape) and send it to the z2D shape) and send it to the z--buffer.buffer.

2/23/2005 © Ariel Shamir ��

Surface Splats

��

2/23/2005 © Ariel Shamir ��

Iso-splat

Sampling

Projection

2/23/2005 © Ariel Shamir ��

QSplat - Demo

��

2/23/2005 © Ariel Shamir �

LOD for Photo Realistic RenderingOne word: efficiency (time & space)!

Bigger, more complex models with more details, faster and better…

Using LOD: reduces details where it is not important…meaning it is not noticed and does not degrade visual realism or quality.

One word: efficiency (time & space)!One word: efficiency (time & space)!

Bigger, more complex models with more Bigger, more complex models with more details, faster and betterdetails, faster and better……

Using LOD: reduces details where it is not Using LOD: reduces details where it is not importantimportant……meaning it is not noticed and meaning it is not noticed and does not degrade visual realism or quality.does not degrade visual realism or quality.

2/23/2005 © Ariel Shamir �

Examples

�������������� ������������������

�������������� ������������������

��

2/23/2005 © Ariel Shamir ��

Distance & Resolution

Distance

Resolution

2/23/2005 © Ariel Shamir ��

Another Example

��

2/23/2005 © Ariel Shamir ��

View Dependent

2/23/2005 © Ariel Shamir ��

View Dependent (cont.)

����� ��� ��� ��� ��� � ��� ��� ���������� ���

��

2/23/2005 © Ariel Shamir ��

Temporal LOD

2/23/2005 © Ariel Shamir ��

LOD for NPRNPR is strongly based on LOD as well but for other efficiency measures… visual space or perception space (cluttering)

Reducing details where it is not important this time means the image does not degrade the perception or understanding or insight!

NPR is strongly based on LOD as well but NPR is strongly based on LOD as well but for other efficiency measuresfor other efficiency measures…… visual visual space or perception space (cluttering)space or perception space (cluttering)

Reducing details where it is not important Reducing details where it is not important this time means the image does not this time means the image does not degrade the perception or understanding or degrade the perception or understanding or insight!insight!

2/23/2005 © Ariel Shamir ��

Perceptual Based

2/23/2005 © Ariel Shamir ��

Enhanced Understanding

2/23/2005 © Ariel Shamir �

Summary Either for efficiency (Photo-Realism) or for better insight and perception (NPR) LOD reduces details where it is not important and enhances details where it is!

Either for efficiency (PhotoEither for efficiency (Photo--Realism) or for Realism) or for better insight and perception (NPR) LOD better insight and perception (NPR) LOD reduces details where it is not important reduces details where it is not important and enhances details where it is!and enhances details where it is!