So You Want to Write a Ray Tracer Checkpoint 7 – Tone Reproduction Ray Tracing Assignment Goal is to reproduce the following Whitted, 1980 1
Ray Tracing Assignment Seven checkpoints Setting the Scene Camera Modeling Basic Shading Procedural Shading Recursive Ray Tracing – Reflection Recursive Ray Tracing – Transmission Tone Reproduction Ray Tracing Assignment Seven checkpoints Setting the Scene Camera Modeling Basic Shading Procedural Shading Recursive Ray Tracing – Reflection Recursive Ray Tracing – Transmission Tone Reproduction 2
Checkpoint 7 Goal is to take this from CG units to real units! Tone Reproduction Change your ray tracer so that it: Maps lighting units (0-1) to real lighting units Applies a tone reproduction operator to compress these simulated radiances to display radiances 3
The framework HDR Image Capture Response Display compression Output device Image Device Appearance color management The framework HDR Image (10 -8 - 10 8 cd/m 2 ) RESULTS OF RAY TRACER Capture Response Display compression Output device Image Device Appearance color management 4
Compression You will implement two different tone reproduction operators: Perceptual: Ward’s from Graphics Gems IV Photographic: Reinhard, et al. in 2002 Target Device: maximum output luminance of new parameter L dmax. Assume standard sRGB color space. The framework HDR Image (10 -8 - 10 8 cd/m 2 ) RESULTS OF RAY TRACER Capture Response Display compression Output device Image Device Appearance (0 - Ldmax) color management 5
Color Management For sake of the checkpoint You can ignore Color Appearance Modeling (assume target viewing conditions is the same as the actual viewing condition) Assume a simple actual device that has a maximum output of L dmax and a gamma of 1 with standard sRGB color space. Simple linear scaling of target image by L dmax The framework HDR Image (10 -8 - 10 8 cd/m 2 ) RESULTS OF RAY TRACER Capture Response Display compression Output device Image Device Appearance (0 - 1) (0 - Ldmax) color management 6
Steps to modifying the ray tracer New parameters: L max = maximum illuminance from the scene L dmax = maximum display illuminance. whichTR = which tone reproduction operator to use. Step 1: Prepare your HDR image The values in each image pixel will represent illuminance at that pixel from the scene. Currently in range of 0-1. Multiply each channel of each pixel by L max Call the result R (x,y) -- illuminance of red channel G (x,y) -- illuimanance of green channel B (x,y) -- illuminance of blue channel 7
Step 2: Calculate overall luminance For both tone reproduction operators, you will need absolute luminance at each pixel (in addition to luminance on an RGB basis). L (x,y) = absolute luminance at pixel x,y Step 2: Calculate overall illuminance Like in photography, the operators deal in luminances and not radiances. 120 100 % Efficiency 80 60 40 20 0 5 0 5 0 5 0 5 0 5 0 5 0 5 0 5 0 7 0 2 5 7 0 2 5 7 0 2 5 7 0 2 5 3 4 4 4 4 5 5 5 5 6 6 6 6 7 7 7 Wavelength 8
Step 2: Calculate overall illuminance Quick and dirty approximation to pixel illuminance given R, G, B : Based on standard CRT color space. L (x,y) = 0.27 R (x,y)+0.67 G (x,y) +0.06 B (x,y) Note: L is in the range [0, L max ] Step 3: Perform compression You will implement two different tone reproduction operators: Perceptual: Ward’s from Graphics Gems IV Photographic: Reinhard, et al. in 2002 More on that later. Compression: will be applied on R(x,y), G(x,y), B(x,y) defines R target (x,y), G target (x,y), B target (x,y) In range [0, L dmax ] 9
Step 4: Apply device model Assume a simple actual device that has a maximum output of L dmax and a gamma of 1 with standard sRGB color space. Simple linear scaling of target image by L dmax R final (x,y) = R target (x,y) / L dmax G final (x,y) = G target (x,y) / L dmax B final (x,y) = B target (x,y) / L dmax Questions so far? 10
Let’s talk about the compression (step 3) Operators Perceptual: Ward’s from Graphics Gems IV Photographic: Reinhard, et al. in 2002 Ward model: Simple heuristic based on perceptual tests. Includes some visual adaptation. Easy to implement Gets the job done!!! Ward Tone Reproduction 2.5 � � sf = 1.219 + ( L d max /2) 0.4 � � 0.4 1.219 + L wa � � Ward’s TR Operator defines a scale factor: L d = sf L w Where L wa = adaptation luminance (can use log-average luminance in scene) 11
Log Average Luminance To find the log-average luminance of scene � � L = exp 1 � log( � + L ( x , y )) � � � � N � � x , y where L (x,y) = absolute luminance at pixel x,y N = number of pixels δ = some small number (to prevent log going to infinity) Ward Tone Reproduction 2.5 � � sf = 1.219 + ( L d max /2) 0.4 � � 0.4 1.219 + L wa � � Calculate sf by setting L wa = L Final display colors (R target , G target , B target ) are the results of applying the sf to the R, G, B . 12
Let’s talk about the compression (step 3) Operators Perceptual: Ward’s from Graphics Gems IV Photographic: Reinhard, et al. in 2002 Reinhard model: Simple heuristic based on photographic systems. Models photographic-like response. Easy to implement Gets the job done!!! Reinhard Tone Reproduction Mimics Ansel Adam’s Zone System http://photography.cicada.com/zs/emulator/ 13
Reinhard Tone Reproduction Basic idea: Define the “key” value to the average scene luminance and map that to Zone 5. You’ll need log average luminance as caculated for Ward Map remaining luminances based on “photographic-like” response. Reinhard Tone Reproduction Step 1 Create scaled luminance values R s , G s , B s by mapping the key value to Zone V (18% gray) B s = a R s = a G s = a L B ( x , y ) L R ( x , y ) L G ( x , y ) where L = the key value R/G/B(x,y) = scene luminance at pixel x,y a = % gray for zone V; use a = 0.18 R s , G s , B s (x,y) = scaled luminance, i.e., 14
Reinhard Tone Reproduction Step 2 Find the reflectance for R r , G r , B r , based on film-like response R s ( x , y ) G s ( x , y ) B s ( x , y ) R r ( x , y ) = G r ( x , y ) = B r ( x , y ) = 1 + R s ( x , y ) 1 + G s ( x , y ) 1 + B s ( x , y ) where R s , G s , B s (x,y) = scaled luminance R r , G r , B r (x,y)= reflectance (range 0-1) Reinhard Tone Reproduction Step 3 Calculate target display luminance by simulating illumination. Assume that illuminant is “white” with luminance L dmax G t arg et ( x , y ) = G r ( x , y ) L d max B t arg et ( x , y ) = B r ( x , y ) L d max R t arg et ( x , y ) = R r ( x , y ) L d max where R target , G target , B target (x,y) = target display luminance R r , G r , B r (x,y) = reflectance (range 0-1) 15
Reinhard’s Results Using TR Operator Linear scaling Loss of detail [Reinhard,2002] Checkpoint 7 To be posted to Web site Six images produced by running your raytracer with three different values of L max for EACH tone reproduction operator: Lo-Range Lighting: L max = 1 nit Mid-Range Lighting: L max = 1000 nits Hi-Range Lighting: L max = 10,000 nits Tone Reproduction: Ward’s Model Reinhard’s Model Please label which is which. 16
Extra Extra For 5 points Modify the Reinhard operator so that you can specify what luminance is to be used as the key value. Constant value Value at a pixel Implement vignetting. Checkpoint 7 Due dates: Images to be posted to Web site Wednesday, Feb 13th . Final raytracer code to be posted on mycourses (dropboxes set up) Feb 15th. Code must be submitted to receive credit! Include README with details to build Questions? 17
Recommend
More recommend