• 沒有找到結果。

spline ( basis spline) : for 4 control points, given B0, B1, B2, and B3 as the weighting function

(Curves) Geometry and drag equation

B- spline ( basis spline) : for 4 control points, given B0, B1, B2, and B3 as the weighting function

0 <= U <= 1.0

B-spline matrix: Bs,

with 4 control points Pi

Cubic B-Spline Curve

• Cubic B-Spline Curve, C2 continuous

• P(u) = uTM p, where P is control points [pi-2, pi-1, pi, pi+1]T

• At first define it to be C2continuous, set up boundary conditions, and we can get

if u is defined as [1,u, u2, u3] in this order, P(u) = uTMS p

basis function = MsTu = (1/6) [ (1-u)3, 4-6u2+3u3, 1+3u+3u2-3u3, u3]T

1 3 3

1

0 3 6 3

0 3 0

3

0 1 4

1

6 Ms 1

Curve DEMO

• DEMO 1: Bezier curve

http://math.hws.edu/eck/cs424/notes2013/canvas/bezier.ht ml (connected curve)

http://blogs.sitepointstatic.com/examples/tech/canvas-curves/bezier-curve.html (basic curve)

DEMO 2: B-spline curve demo

https://www.cs.utexas.edu/~teammco/research/bsplines/

DEMO 3: Bezier , Bsline, NURBS DEMO

(note: manually add more control points)

Bezier Patch demo

• DEMO 3:

Youtube video:

https://www.youtube.com/watch?v=2tLC0oIbKS 0

DEMO 4: Bezier Surfaces (patch)

http://www.ibiblio.org/e-notes/Splines/bezier3d.html Fighter plane demo:

http://www.ibiblio.org/e-notes/webgl/deflate/yf23.html

WebGL Interactive models

http://www.ibiblio.org/e-notes/webgl/models.htm#spline

• (including animated horse, fox, eagle, shark,

human elbow bones, and more static 3D models, such as bike, etc.)

DEMO 5: more control points for B-spline curve http://nurbscalculator.in/ (need to add more control points)(Q1: make the first three control

points to be at the same position, what happens?)

Ray tracing: Turner Whitted

• Key to success, from light to eye or from eye to screen?

Concept: how to win? (shooting ball game below)

The Rendering Equation: Jim Kajiya, 1986

(渲染方程式)

I(x, x’): light (intensity) from patch x’ to patch x g(x,x’): visibility geometry, o: invisible, 1: visible

e(x, x’): the rate at which light is emitted from patch x’ to x, when x’ is an emitter.

ρ (x, x’, x’’): patch’s reflectivity,

Definitions

• where

I(x, x’): light (intensity) from patch x’ to patch x g(x,x’): visibility geometry, o: invisible, 1: visible e(x, x’): the rate at which light is emitted from patch x’ to x, when x’ is an emitter.

ρ (x, x’, x’’): patch’s reflectivity, light from x’’ to x’

and the ratio reflected to x

Another detailed definition of the Rendering Equation

The rendering equation describes the total amount of light emitted from a point x along a particular viewing direction, given a function for incoming light and a BRDF.

Explanation

1. Conservation of energy.

2. Assuming that L denotes radiance, we have that at each particular position and direction, the outgoing light (Lo) is the sum of the emitted light (Le) and the reflected light.

3. The reflected light itself is the sum from all

directions of the incoming light (Li) multiplied by the surface reflection and cosine of the incident angle.

The Rendering Equation

Terminology

Radiance: 輻射, 光芒, light or heat that comes from something.

Illumination, 照明, light

Illuminance: 照度: 單位面積上的光通量,

單位: LUX, 1 LUX = 1 流明/平方米, Lumen (lm) :流明, luminous flux, 1 lm = 1 cd.sr,

1 cd: Candela, 燭光 (一瓦的白燈光, 約等於一燭光),

1 sr: steradian, 球面度, 立體角 (半徑 , 若張開的面積為 r2, 則角度為 1立體角, 1 sr)

Ray tracing(1)

Simple recursive ray tracing

Li: shadow ray Ri: reflected ray Ni: normal

Ti: transmitted ray whether

1. L1=R1+T1? or

2. f1(L1)=f(R1)+f(T1)? or 3. Color=f(L1,R1,T1 )

Shadow in ray tracing

Faster: ray tracing

• halfway vector

From known data to unknown

Ray Tracing Algorithm

Trace(ray)

For each object in scene Intersect(ray, object) If no intersections

return BackgroundColor For each light

For the object in scene

Intersect(ShadowRay, object) Accumulate local illumination Trace(ReflectionRay)

Trace(TransmissionRay)

Accumulate global illumination

Ray Tracing Algorithm

Code example: A simple ray tracer

• Author: Turner Whitted

– famous for his implementation of recursive ray tracer.

• Simplified version:

– input: quadric surfaces only

i.e. f(x,y,z)=ax2 + by2 + cz2 + 2dxy + 2eyz + 2fxz + 2gx + 2hy + 2jz + k = 0

– Shading calculation: as simple as possible

• Surface normal

[df/dx, df/dy, df/dz]

= [ 2ax+2dy+2fz+2g, 2by+2dx+2ez+2h, 2cz+2ey+2fx+2j ]

Sample program

Color trace_ray( Ray original_ray ) {

Color point_color, reflect_color, refract_color Object obj

obj = get_first_intersection( original_ray ) point_color = get_point_color( obj )

if ( object is reflective )

reflect_color = trace_ray( get_reflected_ray( original_ray, obj ) ) if ( object is refractive )

refract_color = trace_ray( get_refracted_ray( original_ray, obj ) ) return ( combine_colors( point_color, reflect_color, refract_color )) }

Code example: A simple ray tracer

• The simple ray tracer is complete and free to copy [need modification to be term project]

• Input surface properties

– r, g, b, relative_index_of_refraction, reflection_coef, transmission_coef, object_type

– number_of_objects, number_of_surfaces, number_of_properties

• How to calculate the intersection of a ray and a quadric surface?

Ray to quadric surface intersection

• intersection calculation:

– let direction=(Dx, Dy, Dz), origin=(Ox, Oy, Oz) line ==> (x,y,z)=(Ox, Oy, Oz) + t*(Dx, Dy, Dz) – quadric surface

f(x,y,z) = ax2 + by2 + cz2 + 2dxy + 2eyz + 2fxz + 2gx + 2hy + 2jz + k = 0

– replace (x,y,z) in (2) by (1),

acoef*t2 + bcoef*t + ccoef = 0, solve for t

• for example:

acoef = a*Dx2 + b*Dx*Dy + c*Dx*Dz + e*Dy2 + f*Dy*Dz + h*Dz2

(1)

(2)

Special notice:

1. Avoid to intersect a surface twice within a tiny triange

– e.g. t1=100, t2=100.001

– This may happen because of numeric percision

2. If a ray doesn't hit anything, give it a non-offensive background color, (20,92,192).

– This is the sky color(assume it is day time, of course).

– Otherwise, choose twilight or dark sky color.

3. How to modify this program to accept triangles?

Grid methods?

– Each grid center contains a pointer to the list of triangles which are(partly) contained in the grid.

Special notice:

4. Shading model

5. I I

N L

KS S KT T n

j

j

a

1

• Ultimately, this yields the following pseudo code:

• For more info, please see my document Ray_Tracing.bw

Ray-object intersection acceleration

More about Ray-Tracing: Photon Mapping

• Photon mapping is a two-pass global

illumination rendering algorithm developed by Henrik Wann Jensen between 1995 and 2001[1] that approximately solves the rendering equation for integrating light radiance at a given point in space. Rays from the light source (like photons) and rays from the camera are traced independently until some termination criterion is met, then they are connected in a second step to

produce a radiance value.

• Progressive photon mapping (PPM) starts with ray tracing and then adds more and more photon mapping passes to provide a progressively more accurate render.

Photon Mapping: result

Global illumination using photon maps, EuroRendering 1996, by Henrik Wann Jensen

More about Ray-Tracing: Photon Mapping

Photon: A Modular, Research-Oriented Rendering System, Siggraph 2019 poster

Figure 1: Several visualization techniques implemented using the building blocks provided by our system. In the center, the buddha features Belcour’s BSDF model [Belcour 2018], while the left one, the glass brick induces caustics that can be rendered efficiently using particle tracing methods.

Radiosity (熱輻射法)

Donald Greenberg and Tomoyuki Nishita (1985)

What is Radiosity in Computer Graphics?

(DEMO)

Turner Whitted (

upper middle

, ray tracing), Donald Greenberg(

lower right,

radiosity)

129

Tomoyuki Nishita,

Rendering, 2011/11

Steven Coons Award 2005, major Asian CG researcher

130

What is still missing in ray-traced images?

• Diffuse to diffuse reflection?

The Rendering Equation: Jim Kajiya, 1986

(渲染方程式)

I(x, x’): light (intensity) from patch x’ to patch x g(x,x’): visibility geometry, o: invisible, 1: visible

e(x, x’): the rate at which light is emitted from patch x’ to x, when x’ is an emitter.

ρ (x, x’, x’’): patch’s reflectivity,

134

E. Angel and D. Shreiner: Interactive Computer Graphics 6E ©

Addison-Wesley 2012

Rendering Equation: Another version

Consider light at a point p arriving from p’

i(p, p’) = υ(p, p’)(ε(p,p’)+ ∫ ρ(p, p’, p’’)i(p’, p’’)dp’’

occlusion = 0 or 1/d2 emission from p’ to p

light reflected at p’ from all points p’’ towards p

135

E. Angel and D. Shreiner: Interactive Computer Graphics 6E ©

Addison-Wesley 2012

Radiosity

• Consider objects to be broken up into flat patches (which may correspond to the

polygons in the model)

• Assume that patches are perfectly diffuse reflectors

• Radiosity = flux = energy/unit area/ unit time leaving patch

136

E. Angel and D. Shreiner: Interactive Computer Graphics 6E ©

Addison-Wesley 2012

Patches

Radiosity

A

k

Definitions

• where

Bi: B are the radiosity of patches i and j Ei: the rate at which light is emitted from patch i

Pi: patch i's reflectivity

Fji:formfactor (configuration factor ) , which specifies the fraction of energy leaving the patch j that arrives at patch i.

Ai, Aj areas of patch i and j.

Reciprocity in radiosity

(互換, 互惠)

Total energy

passing through Ai and Aj should be the same!

(2)

(3)Simplified Eq from (1)

互惠 互惠

A

i

A

j

140

E. Angel and D. Shreiner: Interactive Computer Graphics 6E ©

Addison-Wesley 2012

Radiosity Equation

energy balance

b

i

a

i

= e

i

a

i

+ ρ

i

∑ f

ji

b

j

a

j

reciprocity

f

ij

a

i

= f

ji

a

j

radiosity equation

b

i

= e

i

+ ρ

i

∑ f

ij

b

j

141

E. Angel and D. Shreiner: Interactive Computer Graphics 6E ©

Addison-Wesley 2012

Notation

n patches numbered 1 to n bi = radiosity of patch I

ai = area patch I

total intensity leaving patch i = bi ai ei ai = emitted intensity from patch I ρi = reflectivity of patch I

fij = form factor = fraction of energy leaving patch j that reaches patch i

142

E. Angel and D. Shreiner: Interactive Computer Graphics 6E ©

Addison-Wesley 2012

Matrix Form

b = [b

i

] e = [e

i

]

R = [r

ij

] r

ij

= ρ

i if

i ≠ j r

ii

= 0

F = [f

ij

]

143

E. Angel and D. Shreiner: Interactive Computer Graphics 6E ©

Addison-Wesley 2012

Matrix Form

相關文件