home *** CD-ROM | disk | FTP | other *** search
/ Encyclopedia of Graphics File Formats Companion / GFF_CD.ISO / formats / radiance / spec / behavr.txt next >
Text File  |  1994-06-01  |  14KB  |  519 lines

  1.                 Behavior of Materials in RADIANCE
  2.  
  3.                             Greg Ward
  4.                    Lawrence Berkeley Laboratory
  5.  
  6.  
  7. 1. Definitions
  8.  
  9. This document describes in gory detail how each material type in
  10. RADIANCE behaves in terms of its parameter values. The following
  11. variables are given:
  12.  
  13.      R("P","v")     Value of a ray starting at "P" in direction
  14. "v"
  15.                          (in watts/sr/m^2)
  16.      "P"o           Eye ray origin
  17.      "v"            Eye ray direction
  18.      "P"s           Intersection point of ray with surface
  19.      "n"            Unperturbed surface normal at intersection
  20.       an            Real argument number n
  21.       C             Material color, {a1, a2, a3)
  22.       p             Material pattern value, {1,1,1} if none
  23.      "d"            Material texture vector, [0,0,0] if none
  24.      "b"            orientation vector given by the string
  25.                          arguments of anisotropic types
  26.       n1            Index of refraction on eye ray side
  27.       n2            Index of refraction on opposite side
  28.       A             Indirect irradiance (in watts/m^2)
  29.       At            Indirect irradiance from opposite side (in
  30.                          watts/m^2)
  31.      "m"            Mirror direction, which can vary with Monte
  32.                          Carlo sampling
  33.       ts            Specular threshold (set by -st option)
  34.       Bi            Radiance of light source sample i (in
  35.                          watts/sr/m^2)
  36.      "q"i           Direction to source sample i
  37.       wi            Solid angle of source sample i (in sr)
  38.  
  39. Variables with an arrow over them are vectors. Variables with a
  40. circumflex are unit vectors (ie. normalized). All variables
  41. written in bold represent color values.
  42.  
  43. 1.1. Derived Variables
  44.  
  45. The following values are computed from the variables above:
  46.  
  47.      cos1           Cosine of angle between surface normal and
  48.                          eye ray
  49.      cos2           Cosine of angle between surface normal and
  50.                          transmitted direction
  51.      "n"p           Perturbed surface normal (after texture
  52.                          application)
  53.      "h"i           Bisecting vector between eye ray and source
  54.                          sample i
  55.      FTE            Fresnel coefficient for TE -polarized light
  56.      FTM            Fresnel coefficient for TM -polarized light
  57.      F              Fresnel coefficient for unpolarized light
  58.  
  59. These values are computed as follows:
  60.  
  61.      cos1 = -"v"."n"p
  62.  
  63.      cos2 = 1 - (n1/n2)2(1 - cos12)
  64.  
  65.      "n"p = "n" + "d"
  66.             ||"n" + "d"||
  67.  
  68.      "h"i = "q"i - "v"
  69.  
  70.      FTE  = [n1cos1 - n2cos2]2
  71.             [n1cos1 + n2cos2]
  72.  
  73.      FTM  = [n1/cos1 - n2/cos2]2
  74.             [n1/cos1 = n2/cos2]
  75.  
  76.      F    = 1/2FTE + 1/2FTM
  77.  
  78.  
  79. 1.2. Vector Math
  80.  
  81. Variables that represent vector values are written with an arrow
  82. above (eg. "v"). Unit vectors (ie. vectors whose lengths are
  83. normalized to 1) have a hat (eg. "v"). Equations containing
  84. vectors are implicitly repeated three times, once for each
  85. component. Thus, the equation:
  86.  
  87.      "v" = 2"n" + "P"
  88.  
  89. is equivalent to the three equations:
  90.  
  91.      vx = 2nx + Px
  92.  
  93.      vy = 2ny + Py
  94.  
  95.      vz = 2nz + Pz
  96.  
  97. There are also cross and dot product operators defined for
  98. vectors, as well as the vector norm:
  99.  
  100.      Vector Dot Product
  101.  
  102.         "a"."b" = axbx + ayby + azbz
  103.  
  104.      Vector Cross Product
  105.  
  106.         "a" x "b" = | "i" "j" "k" |
  107.                     | ax  ay  az  |
  108.                     | bx  by  bz  |
  109.  
  110.      or, written out:
  111.  
  112.  
  113.         "a" x "b" = [aybz - azby, azbx - axbz, axby - aybx]
  114.  
  115.      Vector Norm
  116.  
  117.         ||"v"|| = vx2 + vy2 + vz2
  118.  
  119. Values are collected into a vector using square brackets:
  120.  
  121.      "v" = [vx,vy,vz]
  122.  
  123.  
  124. 1.3. Color Math
  125.  
  126. Variables that represent color values are written in boldface
  127. type. Color values may have any number of spectral samples.
  128. Currently, RADIANCE uses only three such values, referred to
  129. generically as red, green and blue. Whenever a color variable
  130. appears in an equation, that equation is implicitly repeated once
  131. for each spectral sample. Thus, the equation:
  132.  
  133.      C = AB + dF
  134.  
  135. is shorthand for the set of equations:
  136.  
  137.      C1 = A1B1 + dF1
  138.  
  139.      C2 = A2B2 + dF2
  140.  
  141.      C3 = A3B3 + dF3
  142.  
  143.   ...
  144.  
  145. And so on for however many spectral samples are used. Note that
  146. color math is not the same as vector math. For example, there is
  147. no such thing as a dot product for colors.
  148.  
  149. Curly braces are used to collect values into a single color, like
  150. so:
  151.  
  152.      C = {r,g,b}
  153.  
  154.  
  155. 2. Light Sources
  156.  
  157. Light sources are extremely simple in their behavior when viewed
  158. directly. Their color in a particular direction is given by the
  159. equation:
  160.  
  161. R = p C
  162.  
  163. The special light source material types, glow, spotlight, and
  164. illum, differ only in their affect on the direct calculation, ie.
  165. which rays are traced to determine shadows. These differences are
  166. explained in the RADIANCE reference manual, and will not be
  167. repeated here.
  168.  
  169.  
  170. 3. Specular Types
  171.  
  172. Specular material types do not involve special light source
  173. testing and are thus are simpler to describe than surfaces with a
  174. diffuse component. The output radiance is usually a function of
  175. one or two other ray evaluations.
  176.  
  177. 3.1. Mirror
  178.  
  179. The value at a mirror surface is a function of the ray value in
  180. the mirror direction:
  181.  
  182. R = p C R("P"s, "m")
  183.  
  184. 3.2. Dieletric
  185.  
  186. The value of a dieletric material is computed from Fresnel's
  187. equations:
  188.  
  189. R = p Ct(1-F)R("P"s,"t") + Ct F R("P"s, "m")
  190.  
  191. where:
  192.  
  193.      Ct = C"P"s - "P"o"
  194.  
  195.     "t" = n1"v" + {n1cos1 - cos2}"n"p
  196.           n2      {n2           }
  197.  
  198. The Hartmann constant is used only to calculate the index of
  199. refraction for a dielectric, and does not otherwise influence the
  200. above equations. In particular, transmitted directions are not
  201. sampled based on dispersion. Dispersion is only modeled in a very
  202. crude way when a light source is casting a beam towards the eye
  203. point. We will not endeavor to explain the algorithm here as it
  204. is rather nasty.
  205.  
  206. For the material type "interface", the color which is used for C
  207. as well as the indices of refraction n1 and n2 is determined by
  208. which direction the ray is headed.
  209.  
  210. 3.3. Glass
  211.  
  212. Glass uses an infinite series solution to the interreflection
  213. inside a pane of thin glass.
  214.  
  215. R = pCt R("P"s, "t")[1 (1 - FTE)2 + 1 (1 - FTM)2] +
  216.                     [2 1 - FTE2Ct2+ 2  1 - F2TMCt2]
  217. R("P"s,"m")[1 FTE(1 + (1 - 2FTE)Ct2) + 
  218.            [2       1 - fTE2 CT2
  219. 1 FTM(1 + (1 - 2FTM)Ct2)]
  220. 2       1 - FTM2Ct2     ]
  221.  
  222.  
  223. where:
  224.           Ct = C(1/cos2)
  225.  
  226.           "t" = "v" + 2(1 - n2)"d"
  227.  
  228.  
  229. 4. Basic Reflection Model
  230.  
  231. The basic reflection model used in RADIANCE takes into account
  232. both specular and diffuse interactions with both sides of a
  233. surface. Most RADIANCE material types are special cases of this
  234. more general formula:
  235.  
  236. R = E    B1w1 {Max (0,"q"i."n"p)[Pd + Psi] + Max(0, -"q"i."n"p)
  237.   sources                        "T"
  238.   [Td + Tsi]}
  239.    "T"     ]}  (1)
  240.  
  241.    + PsR("P"s, "m") + TsR("P"s, "t")
  242.  
  243.    + Pa A + Ta At
  244.      "T"    "T"
  245.  
  246. Note that only one of the transmitted or reflected components in
  247. the first term of the above equation can be non-zero, depending
  248. on whether the given light source is in front of or behind the
  249. surface. The values of the various P and T variables will be
  250. defined differently for each material type, and are given in the
  251. following sections for plastic, metal and trans.
  252.  
  253. 4.1. Plastic
  254.  
  255. A plastic surface has uncolored highlights and no transmitted
  256. component. If the surface roughness (a5) is zero or the
  257. specularity (rs) is greater than the threshold (ts) then a ray is
  258. traced in or near the mirror direction. An approximation to the
  259. Fresnel reflection coefficient (rs = 1-F) is used to modify the
  260. specularity to account for the increase in specular reflection
  261. near grazing angles.
  262.  
  263. The reflection formula for plastic is obtained by adding the
  264. following definitions to the basic formula given in equation (1):
  265.  
  266.     Pd  = p C(1 - rs)
  267.  
  268.           {rs fs("q"i)
  269.               ("q"i."n"p)cos1  if a5>0
  270.     Psi = {0                    otherwise
  271.  
  272.     Ps  = {rs if a5=0 or rs>ts
  273.            0  otherwise
  274.     Pa  =  p C(1 - rs) if a5=0 or rs>ts
  275.            p C            otherwise
  276.  
  277.  
  278.     Ta, Td, Tsi, Ts = 0
  279.  
  280.     rs = a4 + (1 - a4)e -6cos1
  281.  
  282.     fs("q"i) = e[("h"i."n"p)2 - ||"h"||2]/ai
  283.                          4"T"ai
  284.  
  285.     ai = a52 + wi
  286.                4"T"
  287.  
  288. There is one additional caveat to the above formulas. If the
  289. roughness is greater than zero and the reflected ray,
  290. R("P"s,"t"), intersects a light source, then it is not used in
  291. the calculation. Using such a ray would constitute
  292. double-counting, since the direct component has already been
  293. included in the source sample summation.
  294.  
  295.  
  296. 4.2. Metal
  297.  
  298. Metal is identical to plastic, except for the definition of rs,
  299. which now includes the color of the material:
  300.  
  301.      rs = {a1a4 + (1-a1a4)e -6cos1, a2a4 + (1-a2a4)e -6cos1, a3a4 
  302.           + (1-a3a4)e-6cos1}
  303.  
  304. 4.3. Trans
  305.  
  306. The trans type adds transmitted and colored specular and diffuse
  307. components to the colored diffuse and uncolored specular
  308. components of the plastic type. Again, the roughness value and
  309. specular threshold determine whether or not specular rays will be
  310. followed for this material.
  311.  
  312.      Pd  = p C(1 - rs)(1 - a6)
  313.           {rs fs("q"i)
  314.               ("q"i."n"p)cos1   if a5>0
  315.      Psi = {0                   otherwise
  316.      Ps  = {rs if a5 = 0 or rs>ts
  317.             0  otherwise
  318.      Pa  = {p C (1 - rs)(1 - a6) if a5=0 or rs>ts
  319.            {p C (1 - a6)             otherwise
  320.      Td  = a6(1 - rs)(1 - a7)p C
  321.            {a6a7(1 - rs)p C gs("q"i)
  322.                             -"q"i."n"p)cos1  if a5>0
  323.      Tsi = {0                                 otherwise
  324.      Ts  = {a6a7(1 - rs)p C if a5=0 or a6a7(1 - rs)>ts
  325.            {0                otherwise
  326.      Ta  = {a6a7(1 - rs)(1 - a7)p C if a5=0 or a6a67(1 - rs)>ts
  327.            {a6(1 - rs)p C              otherwise
  328.      rs  = a4 + (1 - a4)e -6cos1
  329.      fs("q"i) = e[("h"i."n"p)s - ||"h"||2]/ai
  330.                       4"T"ai
  331.  
  332.      ai = a2 + Wi
  333.            5   4"T"
  334.      gs("q"i) = e(2"q"i."t" - 2)/Bi
  335.                    "T"Bi
  336.      "t" = "v" - "d"
  337.            ||"v" - "d"||
  338.      Bi  = a2 + Wi
  339.             5   "T"
  340.  
  341. 4.4 Anisotropic Types
  342.  
  343. The anisotropic reflectance types (plastic2, metal2, trans2) use
  344. the same formulas as their counterparts with the exception of the
  345. exponent terms, fs ("q"i) and gs ("q"i). These terms now use an
  346. additional vector, "b", to orient an elliptical highlight. (Note
  347. also that the argument numbers for the type trans2 have been
  348. changed so that a6 is a7 and a7 is a8.)
  349.  
  350.      fs("q"i) =   1       exp    [ ("h"i."x")2 + ("h"i."y")2
  351.                       4"T" aixaiy     aix            aiy
  352.                                            ("h"."n"p)2
  353.  
  354.      "x" = "y" x "n"p
  355.  
  356.      "y" = "n"p x "b"
  357.            ||"n"p x "b"||
  358.  
  359.      aix = a2 + wi
  360.             5   4"T"
  361.  
  362.      Aiy = a2 + wi
  363.             6   4"T"
  364.  
  365.      gs("q"i) =  1        exp  [("c"i."x")2 + ("c"i."y")2
  366.                                  Bix            Biy
  367.                                    ("n"."c"i)2 - 1
  368.                                       ||"c"i||2]
  369.      "c"i = "q"i - "t"
  370.  
  371.      "t"  =   "v" - "d"
  372.            ||"v" - "d"||
  373.  
  374.      Bix  =  a2 + wi
  375.               5   "T"
  376.  
  377.      Biy  =  a2 + wi
  378.               6   "T"
  379.  
  380. 4.5. BRDF Types
  381.  
  382. The more general brdf types (plasfunc, plasdata, metfunc,
  383. metdata, BRTDfunc) use the same basic formula given in equation
  384. (1), but allow the user to specify Psi and Tsi as either
  385. functions or data, instead of using the default Gaussian
  386. formulas. Note that only the exponent terms, fs("q"i) and
  387. gs("q"i) with the radicals in their denominators are replaced,
  388. and not the coefficients preceding them. It is very important
  389. that the user give properly normalized functions (ie. functions
  390. that integrate to 1 over the hemisphere) to maintain correct
  391. energy balance.
  392.  
  393. Materials and their reasonable values:
  394.  
  395. Material:
  396.           parameter 1
  397.           (open:closed]
  398.           interpretation
  399.  
  400.           parameter 2
  401.           [closed:approximate>
  402.           interpretation
  403.  
  404. Light:
  405.           color
  406.           (0:inf),(0:inf),(0:inf)
  407.           output brightness
  408.  
  409. Glow:
  410.           color
  411.           (0:inf),(0:inf),(0:inf)
  412.           output brightness
  413.  
  414.           maximum radius
  415.           [0:inf)
  416.           no shadows - always shadows
  417.  
  418. Spotlight:
  419.           color
  420.           (0:inf),(0:inf),(0:inf)
  421.           output brightness
  422.  
  423.           maximum angle
  424.           [0:360]
  425.           no shadows - always shadows
  426.  
  427.           direction
  428.           any
  429.           aimed orientation
  430.  
  431. Mirror:
  432.           color
  433.           [0:1],[0:1],[0:1]
  434.           black - silver
  435.  
  436. Plastic:
  437.           color
  438.           [0:1],(0:1],[0:1]
  439.           black - white
  440.  
  441. specularity
  442.           [0:.07>
  443.           matte - satin
  444.  
  445.           roughness
  446.           [0:.2>
  447.           polished - low gloss
  448.  
  449. Metal:
  450.           color
  451.           [0:1],[0:1],[0:1]
  452.           0-100% reflectance
  453.  
  454.           specularity
  455.           <.5:1]
  456.           dirty - clean
  457.  
  458. roughness
  459.  
  460.           [0:.5>
  461.           polished - roughened
  462.  
  463. Trans:
  464.           color
  465.           [0:1],[0:1],[0:1]
  466.           black - white
  467.  
  468.           specularity
  469.           [0:.07>
  470.           matte - satin
  471.  
  472.           roughness
  473.           [0:.2>
  474.           polished - low gloss
  475.  
  476.           transmission
  477.           [0:1]
  478.           opaque - transparent
  479.  
  480.           transmitted specularity
  481.           [0:1]
  482.           diffuse - clear
  483.  
  484. Dielectric:
  485.           transmission
  486.           [0:1],[0:1],[0:1]
  487.           black - transparent
  488.  
  489.           refractive index
  490.           (1:2>
  491.           vacuum - diamond
  492.  
  493.           Hartmann's constant
  494.           <-20:30>
  495.           negative dispersion - positive dispersion
  496.  
  497. Interface:
  498.           interior transmission
  499.           [0:1],[0:1],[0:1]
  500.           black - transparent
  501.  
  502.           interior refractive index
  503.           (1:2>
  504.           vacuum - diamond
  505.  
  506.           exterior transmission
  507.           [0:1],[0:1],[0:1]
  508.           black - transparent
  509.  
  510.           exterior refractive index
  511.           (1:2>
  512.           vacuum - diamond
  513.  
  514. Glass:
  515.           transmission
  516.           [0:1],[0:1],[0:1]
  517.           black - transparent
  518.  
  519.