Coefficients and colors from d'Eon and Luebke skin scattering work
 
ScatterCoeffs
 
 
0.0064, 0.0484, 0.187, 0.567, 1.99, 7.41
Sqrt
2
ScatterColors
 
 
0.233, 0.455, 0.649
,
 
0.1, 0.336, 0.344
,
0.118, 0.198, 0
,
 
0.113, 0.007, 0.007
,
 
0.358, 0.004, 0
,
 
0.078, 0, 0

GaussianFn
var_, x
 :
 1
Sqrt
2
 Pi
 var
 Exp
x
 
 x
2
 var

 Skin scattering profile approximated a sum of multiplegaussians. We don't want to work with three
dimensional RGBvectors so here one of the inputs selects which channel we want
 
ScatterFn
x_, rgb_ 
 :
 Apply
Plus, Table
GaussianFn
var, x
,
 
var, ScatterCoeffs

ScatterColors

rgb

Out[1]=
 
0.00905097, 0.0684479, 0.264458, 0.801859, 2.81428, 10.4793
Out[2]=
 
0.233, 0.455, 0.649
,
 
0.1, 0.336, 0.344
,
 
0.118, 0.198, 0
,
0.113, 0.007, 0.007
,
 
0.358, 0.004, 0
,
 
0.078, 0, 0

In[5]:=
 
 This is the function defined with integrals, as in the paper
 
DiffuseLight
Θ
 _, r_, rgb_ 
 :
 NIntegrate
Clip
Cos
Θ
x
,
 
0, 1

ScatterFn
 Abs
2
 r
 
Sin
x
 
2

, rgb
,
 
x,
 
Pi, Pi

DiffuseWeight
r_, rgb_ 
 :
 NIntegrate
ScatterFn
 Abs
2
 r
 
Sin
x
 
2

, rgb
,
 
x,
 
Pi, Pi

DiffuseIntegral
Θ
 _, r_, rgb_ 
 :
 DiffuseLight
Θ
, r, rgb
DiffuseWeight
r, rgb
 This is a bit faster to evaluate,it's a translation of the code used to generate the lookup table
 
DiffuseWeight2
r_, rgb_ 
 :
 NSum 
ScatterFn
 Abs
2
 r
 
Sin
x
 
2

, rgb
,
 
x,
 
Pi, Pi, 2
 Pi
20

DiffuseLight2
Θ
 _, r_, rgb_ 
 :
 NSum 
Clip
Cos
Θ
x
,
 
0, 1

ScatterFn
 Abs
2
 r
 
Sin
x
 
2

, rgb
,
 
x,
 
Pi, Pi, 2
 Pi
20

DiffuseIntegral2
Θ
 _, r_, rgb_ 
 :
 DiffuseLight2
Θ
, r, rgb
DiffuseWeight2
r, rgb
In[11]:=
 
 Let's theck that they are similar...
 
DiffuseIntegral
0.1, 8, 1
DiffuseIntegral2
0.1, 8, 1
DiffuseIntegral
0.1, 15, 1
DiffuseIntegral2
0.1, 15, 1
Out[11]=
 0.979266
Out[12]=
 0.990889
Out[13]=
 0.990641
Out[14]=
 0.994601
In[16]:=
 
 Let's generate a table of data to be used for the numerical fitting...
 
channel
 
 1;
 
 1
red 2
green 3
 blue
 
dataThetaRVal
 
 Flatten
Table

Θ
, r, DiffuseIntegral
Θ
, r, channel

,
Θ
, 0, Pi, 2
 Pi
20
,
 
r, 0.25, 6, 1
20

, 1
;
 
 an extended range that we will use to check how the fit extrapolates
 
dataIntervalExt
 
 Flatten
Table

Θ
, r
,
 
Θ
, 0, Pi, 2
 Pi
20
,
 
r, 0, 12, 1
20

, 1
;
 LineInterp
a_,b_,x_,x0_,x1_ 
:
 b
Clip
x
x0,
0,1

a
Clip

1
x
x0

x1
x0

,
0,1

 
dataGraph
 
 ListPlot3D
dataThetaRVal, InterpolationOrder
 
 3
cosGraph
 
 ListPlot3D
x
First
x
, Last
x
, Clip
Cos
First
x

,
 
0, 1

 dataIntervalExt
;
 Plotting against the simple lambert cos lighting model,of course that's not dependent on r...
 
Show
dataGraph, cosGraph
Out[18]=Out[20]=
2
 
EricPenner_SkinScattering1.nb 
 
In[24]:=
 
 Ok, let's have a peek at our function to understand its shape... We'll plot asingle slice, then a graph with three slices and the Lambert's clamped cos
 
 plotIn2d 
 
 Plot
DiffuseIntegral
x, 5, 1
,
 
x, 0, Pi

Plot

DiffuseIntegral
x, 1, 1
, DiffuseIntegral
x, 3, 1
,DiffuseIntegral
x, 6, 1
, Max
Cos
x
, 0
,
 
x, 0, Pi

Out[24]=
0.51.01.52.02.53.00.20.40.60.8
Out[25]=
0.51.01.52.02.53.00.20.40.60.81.0
EricPenner_SkinScattering1.nb
3
View on Scribd