grphics08 - raytracing and radiosity

27
RAY-TRACING AND RADIOSITY Michael Heron

Upload: michael-heron

Post on 13-Jan-2015

129 views

Category:

Technology


0 download

DESCRIPTION

This is a course on the theoretical underpinnings of 3D Graphics in computing, suitable for students with a suitable grounding in technical computing.

TRANSCRIPT

Page 1: GRPHICS08 - Raytracing and Radiosity

RAY-TRACING AND RADIOSITYMichael Heron

Page 2: GRPHICS08 - Raytracing and Radiosity

INTRODUCTION

Thus far our discussion of 3D graphics has concentrated mainly of real-time rendering.

In today’s lecture, we will discuss the two main techniques for non real-time rendering. Raytracing Radiosity

Page 3: GRPHICS08 - Raytracing and Radiosity

REFLECTION MODELS Local reflection model

Imagine lights and objects are floating in dark space

Considers only direct illumination Global reflection model

Indirect light considered Light is reflected multiple times

Much more computationally expensive. Outside the reach of most real-time applications.

For now…

Page 4: GRPHICS08 - Raytracing and Radiosity

LOCAL VERSUS GLOBAL

Direct illumination only

Local model

Light source

Global model

Direct and indirectillumination

Page 5: GRPHICS08 - Raytracing and Radiosity

GLOBAL ILLUMINATION In theory, for this we:

Trace rays from each light source to each point visible from that light source

Trace reflections and refractions from this point to other surfaces

Continue until: We reach the viewport, or We exit the scene entirely

Approximations still used Can’t trace all rays of light from a light source.

Page 6: GRPHICS08 - Raytracing and Radiosity

RAY-TRACING

Ray tracing is the process of tracing the path of light through pixels in an image.Capable of producing high degrees of

realism. Still not quite photorealistic, but not far off.

High computational cost Best used for scenes and animations that can be

pre-rendered. Incorporates many aspects of physics

Light reflectionLight refractionLight scattering

Page 7: GRPHICS08 - Raytracing and Radiosity

RAY-TRACING

Rays send away from the camera rather than to itMost rays of light emitted from a source

would not hit the viewing plane. Comparable method called photon mapping

exists. Many orders of magnitude more expensive to

calculate.

Provides advantages:Reflections and shadows realistically

produced And disadvantages:

Expensive to calculate each sceneStill an approximation

Page 8: GRPHICS08 - Raytracing and Radiosity

RAY-TRACING

Rays sent backwards from the camera.

Much less computationally expensive than the alternative.

http://www.codinghorror.com/blog/archives/001073.html

Page 9: GRPHICS08 - Raytracing and Radiosity

LIGHT INTERACTIONS

Remember our different kinds of light interactions.Perfect Specular Imperfect SpecularDiffuse

Must be able to combine light interactions in a ray-tracing model.Specular to DiffuseDiffuse to SpecularAnd so on

Page 10: GRPHICS08 - Raytracing and Radiosity

TRANSMISSION OF LIGHT Indirect transmission of light occurs in

several ways Reflection Transparent refractions Translucent diffusion

Transparency should refract light It looks unrealistic otherwise.

Translucency transmits light in multiple new directions.

Page 11: GRPHICS08 - Raytracing and Radiosity

RAY-TRACING For each pixel, we calculate the ray from the

centre of the viewport through that pixel. Find the intersection of that ray with the

nearest object. Determine the pixel colour based o surface

properties, orientation, and light intensities This may in itself have a component from reflected

or refracted light rays If the surface is reflective or transparent,

generate a new ray. Trace that onwards.

Repeat for all pixels. If no intersection, pixel colour is background

colour.

Page 12: GRPHICS08 - Raytracing and Radiosity

RAY-TRACING

Secondary rays may be used for diffuse reflection. Generate multiple new rays and trace them on.

Depends on the kind of reflection needed. Each secondary ray is followed until it hits

another object, light source, or background. Recursion is used to permit this relationship

to extend to predefined limits.

Page 13: GRPHICS08 - Raytracing and Radiosity

RAY-TRACING RESULTS

Page 14: GRPHICS08 - Raytracing and Radiosity

EFFICIENCY

Expense of computation based on number of calculations required.Consider a 1000x1000 resolution.

On a scene with 1000 objects. With a single light source.

Consider primary illumination first How about secondary rays?

Further orders of illumination? How about a second light source?

Or a third?

Various optimisation schemes exist.

Page 15: GRPHICS08 - Raytracing and Radiosity

RADIOSITY

Radiosity is based on a model of radiative heat transfer.Assumes conservation of light energy in a

closed environment. Energy emitted or reflected by every

surface accounted for by:AbsorptionReflectionRefractionFluorescence

Page 16: GRPHICS08 - Raytracing and Radiosity

RADIOSITY

All surfaces are broken up into patches and elements.Patches can emit or send light

They send light to other parts of the model.Elements can absorb light

They receive light from other parts of the model.

Number of patches relates to computational intensity.

Each element is associated with a patch. Indeed, a patch may have many elements

Page 17: GRPHICS08 - Raytracing and Radiosity

RADIOSITY

Radiosity works through a system of progressive refinement Start with the patch which has most energy to

‘shoot’ Each of the elements receive the energy appropriately,

and add to the energy of their own patches. Repeat with the patch which now has the most

unspent energy. Repeat until all patches are empty, or some minimal

bound is reached.

Page 18: GRPHICS08 - Raytracing and Radiosity

RADIOSITYEvery polygon gets treated as a patch (a light source)

Every patch is associated with a number of elements,

http://www.cs.princeton.edu/courses/archive/fall00/cs426/lectures/radiosity/radiosity.pdf

Page 19: GRPHICS08 - Raytracing and Radiosity

PATCHES Patches may be present in higher resolution

than surfaces. One surface may be broken up into many

patches. Subdivision algorithms used to further refine

patch mapping over surfaces. Can be done blindly Or intelligently

Focus at areas of high contrast in light levels.

Page 20: GRPHICS08 - Raytracing and Radiosity

RADIOSITY – A FIRST APPROACH Imagine a simple room

Four walls A Ceiling A Floor No light source

Radiosity makes each of the surfaces in the scene a light source. Some of these surfaces may have no energy to spend to

begin with. Imagine the roof as a giant light source.

Like in a supermarket Each surface stores:

How brightly lit it is How much surplus energy it has to spend.

We must calculate the interaction of energy to surface of all surfaces in the scene. Can be calculated in many ways. Most usual is by

geometric distance. The resulting number is the form factor.

Page 21: GRPHICS08 - Raytracing and Radiosity

RADIOSITY

Radiosity creates a scene of soft diffuse light. Represents the interaction of surfaces well, but cannot suitably deal with specular reflection.

http://www.cs.dartmouth.edu/~spl/Academic/ComputerGraphics/Fall2004/outline.html

Page 22: GRPHICS08 - Raytracing and Radiosity

GLOBAL REFLECTION MODELS Ray Tracing

Simulates perfect specular reflections Good for shiny objects reflecting in each other.

Ray-traced images tend to have lots of shiny objects with perfect reflections.

Is viewport dependant. Change the viewport and you need to rerender.

Radiosity Simulates the interactions of diffuse light

Good for matte surfaces Images rendered using radiosity tend to be softly lit

rooms without shiny objects. Is viewport independent.

Change the viewport and the radiosity image remains the same.

Page 23: GRPHICS08 - Raytracing and Radiosity

GLOBAL REFLECTION MODELS

Best results obtained by combining the two into a two-pass method. Radiosity used to build a model of diffuse

illumination across a scene. Raytracing used to build a viewport dependant

illumination of the scene. Combination of two has representation of

specular and diffuse radiation. Permits soft and hard lighting in a single scene.

Page 24: GRPHICS08 - Raytracing and Radiosity

TWO PASS - RAYTRACING

Page 25: GRPHICS08 - Raytracing and Radiosity

TWO PASS - RADIOSITY

Page 26: GRPHICS08 - Raytracing and Radiosity

TWO PASS - COMBINED

Page 27: GRPHICS08 - Raytracing and Radiosity

SUMMARY

Non real-time rendering works through two primary methods. Ray-tracing

Map the path of light from a viewport to objects. Radiosity

Light interactions modelled as energy interactions between patches.

Best results obtained by combining both approaches into a two-pass algorithm.