120 likes | 293 Views
Ray Tracing Implicit Surfaces. John C. Hart CS 319 Advanced Topics in Computer Graphics. Problem. Intersection of ray r ( t ) with implicit surface f ( x ) = 0 Easy to solve f ( r ( t )) when f algebraic Implicit surfaces can be defined by an arbitrary function More general techniques
E N D
Ray Tracing Implicit Surfaces John C. Hart CS 319 Advanced Topics in Computer Graphics
Problem • Intersection of ray r(t) with implicit surface f(x) = 0 • Easy to solve f(r(t)) when f algebraic • Implicit surfaces can be defined by an arbitrary function • More general techniques • LG Surfaces (Kalra&Barr 89) • Sphere Tracing (Hart 96) • Interval Analysis (Mitchell 89)
Problem Statement • Given a cell (cube), can one guarantee that the implicit surface • passes through it? • does not pass through it? • Sign of function values at corners • Different signs: guarantees surface intersects cell • Same signs: surface may or may not intersect cell • How can we determine definitively if a surface intersects any given cell?
Lipschitz Functions • Function f is Lipschitz ifL |f(x) – f(y)|/||x – y||for some value L • Smallest such L is the Lipschitz constant Lip f • Lipschitz constant is the maximum slope of a continuous function L = max f’(x) • Function might by Lipschitz only over a given region (e.g. x2) • Function might not be Lipschitz (e.g. sin 1/x)
Lipschitz Arithmetic • Let f(x) and g(x) be real functions over a compact subset of 3-D Lip(f+g) = max(f+g)’ = max(f’+g’) max f’ + max g’ = Lip f + Lip g Lip(fg) = max(fg)’ = max(f’g + fg’) max(f’ g) + max(fg’) • Let h be a real function Lip(f(h)) = max(f’(h) h’) = h’ Liph(x)f
Lipschitz Guarantee f(x) • Let L Lip f be a Lipschitz bound of f, and let f(x) 0 • Then f 0 over the region(x – f(x)/L, x + f(x)/L) • Why? Because f can’t get back to zero fast enough • Let x be the center of a cell, and let r be the radius of the cell (distance to farthest corner) • If f(x)/L > r then f 0 over the entire cell no implicit surface in cell • Otherwise subdivide the cell f(x)/L r
Root Isolation • Let G be a Lipschitz bound off’(t) = df(r(t))/dt • Derivative of f(r(t))? • Directional derivative of f df(r(t))/dt = f rd • Change in f in ray direction • If f’(t)/G >t then derivative of f can’t get back to zero over interval • Hence f is monotonic over interval • Hence we can use Newton’s method to find root • Otherwise subdivide interval f(t) f’(t)
Sphere Tracing • Let d(x,A) be a signed distance bound d(x,A) min ||x – y|| for all y in A • If f is Lipschitz with bound L then f(x)/L is a signed distance bound • d(x,A) is radius of a ball guaranteed not to intersect implicit surface A • March along ray by distance steps x = r0 x += d(x,A) rd • Intersection when steps converge
Interval Analysis • Replace values x with ranges of values [x0,x1] • Interval arithmetic [a,b] + [c,d] = [a+c,b+d] [a,b] – [c,d] = [a-d,b-c] [a,b] * [c,d] = [min(ac,ad,bc,bd), max(ac,ad,bc,bd)] 1 / [c,d] = [1/d,1/c] [a,b]3 = [a3,b3] • Implement function using interval arithmetic f [a,b] [a,b]
Interval Roots • Let [y0,y1] = f[x0,x1] • If y0 > 0 or y1 < 0 then no root over interval [x0,x1] • Otherwise subdivide [x0,x1] and recurse • Let [y’0,y’1] = f’[x0,x1] • If y’0 > 0 or y’1 < 0 then f monotonic over interval [x0,x1] • Then we can find root with Newton’s method • Otherwise subdivide [x0,x1] and recurse [y0,y1] [x0, x1] [y’0,y’1]