home *** CD-ROM | disk | FTP | other *** search
/ Encyclopedia of Graphics File Formats Companion / GFF_CD.ISO / formats / radiance / spec / ray.ms < prev    next >
Text File  |  1994-04-15  |  35KB  |  1,269 lines

  1. .\" SCCSid "@(#)ray.1 2.11 5/6/93 LBL"
  2. .DA
  3. .TL
  4. The RADIANCE 2.2
  5. .br
  6. Synthetic Imaging System
  7. .AU
  8. Greg Ward
  9. .br
  10. Lawrence Berkeley Laboratory
  11. .br
  12. 1 Cyclotron Rd.
  13. .br
  14. Berkeley, CA  94720
  15. .br
  16. (510) 486-4757
  17. .NH 1
  18. Introduction
  19. .PP
  20. RADIANCE was developed as a research tool
  21. for predicting the distribution of visible radiation in
  22. illuminated spaces.
  23. It takes as input a three-dimensional geometric model of
  24. the physical environment, and produces a map of
  25. spectral radiance values in a color image.
  26. The technique of ray-tracing follows light backwards
  27. from the image plane to the source(s).
  28. Because it can produce realistic images from a simple description,
  29. RADIANCE has a wide range of applications in graphic arts,
  30. lighting design, computer-aided engineering and architecture.
  31. .KF
  32. .sp 25
  33. .ce
  34. .B "Figure 1."
  35. .sp
  36. .KE
  37. .PP
  38. The diagram in Figure 1 shows the flow between programs (boxes) and
  39. data (ovals).
  40. The central program is
  41. .I rpict,
  42. which produces a picture from a scene description.
  43. .I Rview
  44. is a variation of
  45. .I rpict
  46. that computes and displays images interactively.
  47. .PP
  48. A scene description file lists the surfaces and materials
  49. that make up a specific environment.
  50. The current surface types are spheres, polygons, cones,
  51. and cylinders.
  52. They can be made from materials such as plastic, metal,
  53. and glass.
  54. Light sources can be distant disks as well as local spheres, discs and
  55. polygons.
  56. .PP
  57. From a three-dimensional scene description and a specified view,
  58. .I rpict
  59. produces a two-dimensional image.
  60. A picture file is a compressed binary representation of the
  61. pixels in the image.
  62. This picture can be scaled in size and
  63. brightness, anti-aliased, and sent to a graphics output device.
  64. .PP
  65. A header in each picture file lists the program(s) and
  66. parameters that produced it.
  67. This is useful for identifying a picture 
  68. without having to display it.
  69. The information can be read by the program
  70. .I getinfo.
  71. .NH 1
  72. Scene Description
  73. .PP
  74. A scene description file represents a
  75. three-dimensional physical environment
  76. in Cartesian (rectilinear) world coordinates.
  77. It is stored as ascii text, with the following basic format:
  78. .DS
  79. # comment
  80.  
  81. modifier type identifier
  82. n S1 S2 S3 .. Sn
  83. 0
  84. m R1 R2 R3 .. Rm
  85.  
  86. modifier alias identifier reference
  87.  
  88. ! command
  89.  
  90.  ...
  91. .DE
  92. .PP
  93. A comment line begins with a pound sign, `#'.
  94. .PP
  95. The scene description
  96. .I primitives
  97. all have the same general format, and can
  98. be either surfaces or modifiers.
  99. A primitive has a modifier, a type, and an identifier.
  100. A modifier is either the identifier of a
  101. .I "previously defined"
  102. primitive, or "void"\(dg.
  103. .FS
  104. \(dgThe most recent definition of a modifier is the one used,
  105. and later definitions do not cause relinking of loaded
  106. primitives.
  107. Thus, the same identifier may be used repeatedly, and each new
  108. definition will apply to the primitives following it.
  109. .FE
  110. An identifier can be any string (ie. sequence of non-blank
  111. characters).
  112. The
  113. .I arguments
  114. associated with a primitive can be strings or real numbers.
  115. The first integer following the identifier is the number
  116. of string arguments, and it is followed by the arguments themselves
  117. (separated by white space).
  118. The next integer is the number of integer arguments, and is followed
  119. by the integer arguments.
  120. (There are currently no primitives that use them, however.)
  121. The next integer is the real argument count, and it is followed
  122. by the real arguments.
  123. .PP
  124. An alias gets its type and arguments from a previously defined primitive.
  125. This is useful when the same material is used with a different
  126. modifier, or as a convenient naming mechanism.
  127. Surfaces cannot be aliased.
  128. .PP
  129. A line beginning with an exclamation point, `!',
  130. is interpreted as a command.
  131. It is executed by the shell, and its output is read as input to
  132. the program.
  133. The command must not try to read from its standard input, or
  134. confusion will result.
  135. A command may be continued over multiple lines using a backslash, `\\',
  136. to escape the newline.
  137. .PP
  138. Blank space is generally ignored, except as a separator.
  139. The exception is the newline character after a command or comment.
  140. Commands, comments and primitives may appear in any combination, so long
  141. as they are not intermingled.
  142. .NH 2
  143. Primitive Types
  144. .PP
  145. Primitives can be surfaces, materials, textures or patterns.
  146. Modifiers can be materials, textures or patterns.
  147. Simple surfaces must have one material in their modifier list.
  148. .NH 3
  149. Surfaces
  150. .PP
  151. A scene description will consist mostly of surfaces.
  152. The basic types are given below.
  153. .LP
  154. .UL Source
  155. .PP
  156. A source is not really a surface, but a solid angle.
  157. It is used for specifying light sources that are very distant.
  158. The direction to the center of the source and the number of degrees
  159. subtended by its disk are given as follows:
  160. .DS
  161. mod source id
  162. 0
  163. 0
  164. 4 xdir ydir zdir angle
  165. .DE
  166. .LP
  167. .UL Sphere
  168. .PP
  169. A sphere is given by its center and radius:
  170. .DS
  171. mod sphere id
  172. 0
  173. 0
  174. 4 xcent ycent zcent radius
  175. .DE
  176. .LP
  177. .UL Bubble
  178. .PP
  179. A bubble is simply a sphere whose surface normal points inward.
  180. .LP
  181. .UL Polygon
  182. .PP
  183. A polygon is given by a list of three-dimensional vertices,
  184. which are ordered counter-clockwise as viewed from
  185. the front side (into the surface normal).
  186. The last vertex is automatically connected to the first.
  187. Holes are represented in polygons as interior vertices connected to
  188. the outer perimeter by coincident edges (seams).
  189. .DS
  190. mod polygon id
  191. 0
  192. 0
  193. 3n
  194. x1y1z1
  195. x2y2z2
  196. ...
  197. xnynzn
  198. .DE
  199. .LP
  200. .UL Cone
  201. .PP
  202. A cone is a megaphone-shaped object.
  203. It is truncated by two planes perpendicular to its axis,
  204. and one of its ends may come to a point.
  205. It is given as two axis endpoints, and the starting
  206. and ending radii:
  207. .DS
  208. mod cone id
  209. 0
  210. 0
  211. 8
  212. x0y0z0
  213. x1y1z1
  214. r0r1
  215. .DE
  216. .LP
  217. .UL Cup
  218. .PP
  219. A cup is an inverted cone (ie. has an inward surface normal).
  220. .LP
  221. .UL Cylinder
  222. .PP
  223. A cylinder is like a cone, but its starting and ending radii are
  224. equal.
  225. .DS
  226. mod cylinder id
  227. 0
  228. 0
  229. 7
  230. x0y0z0
  231. x1y1z1
  232. rad
  233. .DE
  234. .LP
  235. .UL Tube
  236. .PP
  237. A tube is an inverted cylinder.
  238. .LP
  239. .UL Ring
  240. .PP
  241. A ring is a circular disk given by its center, surface
  242. normal, and inner and outer radii:
  243. .DS
  244. mod ring id
  245. 0
  246. 0
  247. 8
  248. xcentycentzcent
  249. xdirydirzdir
  250. r0r1
  251. .DE
  252. .LP
  253. .UL Instance
  254. .PP
  255. An instance is a compound surface, given by the contents of an
  256. octree file (created by oconv).
  257. .DS
  258. mod instance id
  259. 1+ octree transform
  260. 0
  261. 0
  262. .DE
  263. If the modifier is "void", then surfaces will use the modifiers given
  264. in the original description.
  265. Otherwise, the modifier specified is used in their place.
  266. The transform moves the octree to the desired location in the scene.
  267. Multiple instances using the same octree take little extra memory,
  268. hence very complex descriptions can be rendered using this primitive.
  269. .PP
  270. There are a number of important limitations to be aware of when using
  271. instances.
  272. First, the scene description used to generate the octree must stand on
  273. its own, without referring to modifiers in the parent description.
  274. This is necessary for oconv to create the octree.
  275. Second, light sources in the octree will not be incorporated correctly
  276. in the calculation, and they are not recommended.
  277. Finally, there is no advantage (other than convenience) to
  278. using a single instance of an octree, or an octree containing only a
  279. few surfaces.
  280. An xform command on the subordinate description is prefered in such cases.
  281. .NH 3
  282. Materials
  283. .PP
  284. A material defines the way light interacts with a surface.
  285. The basic types are given below.
  286. .LP
  287. .UL Light
  288. .PP
  289. Light is the basic material for self-luminous surfaces (ie. light
  290. sources).
  291. In addition to the source surface type, spheres, discs (rings with zero
  292. inner radius), cylinders (provided they are long enough), and
  293. polygons can act as light sources.
  294. Polygons work best when they are rectangular.
  295. Cones cannot be used at this time.
  296. A pattern may be used to specify a light output distribution.
  297. Light is defined simply as a RGB radiance value (watts/rad2/m2):
  298. .DS
  299. mod light id
  300. 0
  301. 0
  302. 3 red green blue
  303. .DE
  304. .LP
  305. .UL Illum
  306. .PP
  307. Illum is used for secondary light sources with broad distributions.
  308. A secondary light source is treated like any other
  309. light source, except when viewed directly.
  310. It then acts like it is made of a different material, or
  311. becomes invisible.
  312. Secondary sources are useful when modeling windows or
  313. brightly illuminated surfaces.
  314. .DS
  315. mod illum id
  316. 1 material
  317. 0
  318. 3 red green blue
  319. .DE
  320. .LP
  321. .UL Glow
  322. .PP
  323. Glow is used for surfaces that are self-luminous, but limited
  324. in their effect.
  325. In addition to the radiance value, a maximum radius for
  326. shadow testing is given:
  327. .DS
  328. mod glow id
  329. 0
  330. 0
  331. 4 red green blue maxrad
  332. .DE
  333. If maxrad is zero, then the surface will never be tested
  334. for shadow, although it may participate in an interreflection calculation.
  335. If maxrad is negative, then the surface will never contribute to scene
  336. illumination.
  337. Glow sources will never illuminate objects on the other side of an
  338. illum surface.
  339. This provides a convenient way to illuminate local light fixture
  340. geometry without overlighting nearby objects.
  341. .LP
  342. .UL Spotlight
  343. .PP
  344. Spotlight is used for self-luminous surfaces having directed output.
  345. As well as radiance, the full cone angle (in degrees)
  346. and orientation (output direction) vector are given.
  347. The length of the orientation vector is the distance
  348. of the effective focus behind the source center (ie. the focal length).
  349. .DS
  350. mod spotlight id
  351. 0
  352. 0
  353. 7 red green blue angle xdir ydir zdir
  354. .DE
  355. .LP
  356. .UL Mirror
  357. .PP
  358. Mirror is used for planar surfaces that produce secondary
  359. source reflections.
  360. This material should be used sparingly, as it may cause the light
  361. source calculation to blow up if it is applied to many small surfaces.
  362. This material is only supported for flat surfaces such as polygons
  363. and rings.
  364. The arguments are simply the RGB reflectance values, which should be
  365. between 0 and 1.
  366. An optional string argument may be used like the illum type to specify a
  367. different material to be used for shading non-source rays.
  368. .DS
  369. mod mirror id
  370. 1 material
  371. 0
  372. 3 red green blue
  373. .DE
  374. .LP
  375. .UL Prism1
  376. .PP
  377. The prism1 material is for general light redirection from prismatic
  378. glazings, generating secondary light sources.
  379. It can only be used to modify a planar surface (ie. a polygon or disk)
  380. and should not result in either light concentration or scattering.
  381. The new direction of the ray can be on either side of the material,
  382. and the definitions must have the correct bidirectional properties
  383. to work properly with secondary light sources.
  384. The arguments give the coefficient for the redirected light
  385. and its direction.
  386. .DS
  387. mod prism1 id
  388. 5+ coef dx dy dz funcfile transform
  389. 0
  390. n A1 A2 .. An
  391. .DE
  392. The new direction variables
  393. .I "dx, dy"
  394. and
  395. .I dz
  396. need not produce a normalized vector.
  397. For convenience, the variables
  398. .I "DxA, DyA"
  399. and
  400. .I DzA
  401. are defined as the normalized direction to the target light source.
  402. See section 2.2.1 on function files for further information.
  403. .LP
  404. .UL Prism2
  405. .PP
  406. The material prism2 is identical to prism1 except that
  407. it provides for two ray redirections rather than one.
  408. .DS
  409. mod direct1 id
  410. 9+ coef1 dx1 dy1 dz1 coef2 dx2 dy2 dz2 funcfile transform
  411. 0
  412. n A1 A2 .. An
  413. .DE
  414. .LP
  415. .UL Plastic
  416. .PP
  417. Plastic is a material with uncolored highlights.
  418. It is given by its RGB reflectance, its fraction of specularity,
  419. and its roughness value.
  420. Roughness is specified as the rms slope of surface facets.
  421. A value of 0 corresponds to a perfectly smooth surface, and
  422. a value of 1 would be a very rough surface.
  423. Specularity fractions greater than 0.1 and
  424. roughness values greater than 0.2 are not very
  425. realistic.
  426. (A pattern modifying plastic will affect the material color.)
  427. .DS
  428. mod plastic id
  429. 0
  430. 0
  431. 5 red green blue spec rough
  432. .DE
  433. .LP
  434. .UL Metal
  435. .PP
  436. Metal is similar to plastic, but specular highlights
  437. are modified by the material color.
  438. Specularity of metals is usually .9 or greater.
  439. As for plastic, roughness values above .2 are uncommon.
  440. .LP
  441. .UL Trans
  442. .PP
  443. Trans is a translucent material, similar to plastic.
  444. The transmissivity is the fraction of penetrating light that
  445. travels all the way through the material.
  446. The transmitted specular component is the fraction of transmitted
  447. light that is not diffusely scattered.
  448. Transmitted and diffusely reflected light is modified by the material color.
  449. Translucent objects are infinitely thin.
  450. .DS
  451. mod trans id
  452. 0
  453. 0
  454. 7 red green blue spec rough trans tspec
  455. .DE
  456. .LP
  457. .UL Plastic2
  458. .PP
  459. Plastic2 is similar to plastic, but with anisotropic
  460. roughness.
  461. This means that highlights in the surface will appear elliptical rather
  462. than round.
  463. The orientation of the anisotropy is determined by the unnormalized
  464. direction vector
  465. .I "ux uy uz".
  466. These three expressions (separated by white space) are evaluated in
  467. the context of the function file
  468. .I funcfile.
  469. If no function file is required (ie. no special variables or
  470. functions are required), a period (`.') may be given in its
  471. place.
  472. (See the discussion of Function Files in the Auxiliary Files section).
  473. The
  474. .I urough
  475. value defines the roughness along the
  476. .B u
  477. vector given projected onto the surface.
  478. The
  479. .I vrough
  480. value defines the roughness perpendicular to this vector.
  481. Note that the highlight will be narrower in the direction of the
  482. smaller roughness value.
  483. Roughness values of zero are not allowed for efficiency reasons
  484. since the behavior would be the same as regular plastic in that
  485. case.
  486. .DS
  487. mod plastic2 id
  488. 4+ ux uy uz funcfile transform
  489. 0
  490. 6 red green blue spec urough vrough
  491. .DE
  492. .LP
  493. .UL Metal2
  494. .PP
  495. Metal2 is the same as plastic2, except that the highlights are
  496. modified by the material color.
  497. .LP
  498. .UL Trans2
  499. .PP
  500. Trans2 is the anisotropic version of trans.
  501. The string arguments are the same as for plastic2, and the real
  502. arguments are the same as for trans but with an additional roughness
  503. value.
  504. .DS
  505. mod trans2 id
  506. 4+ ux uy uz funcfile transform
  507. 0
  508. 8 red green blue spec urough vrough trans tspec
  509. .DE
  510. .LP
  511. .UL Dielectric
  512. .PP
  513. A dielectric material is transparent, and it refracts light
  514. as well as reflecting it.
  515. Its behavior is determined by the index of refraction and
  516. transmissivity in each wavelength band per unit length.
  517. Common glass has a index of refraction (n) around 1.5,
  518. and a transmissivity of roughly 0.92 over an inch.
  519. An additional number, the Hartmann constant, describes how
  520. the index of refraction changes as a function of wavelength.
  521. It is usually zero.
  522. (A pattern modifies only the refracted value.)
  523. .DS
  524. mod dielectric id
  525. 0
  526. 0
  527. 5 rtn gtn btn n hc
  528. .DE
  529. .LP
  530. .UL Interface
  531. .PP
  532. An interface is a boundary between two dielectrics.
  533. The first transmissivities and refractive index are for the inside;
  534. the second ones are for the outside.
  535. Ordinary dielectrics are surrounded by a vacuum (1 1 1 1).
  536. .DS
  537. mod interface id
  538. 0
  539. 0
  540. 8 rtn1 gtn1 btn1 n1 rtn2 gtn2 btn2 n2
  541. .DE
  542. .LP
  543. .UL Glass
  544. .PP
  545. Glass is similar to dielectric, but it is optimized for thin glass
  546. surfaces (n = 1.52).
  547. One transmitted ray and one reflected ray is produced.
  548. By using a single surface is in place of two, internal reflections
  549. are avoided.
  550. The surface orientation is irrelevant, as it is for plastic,
  551. metal, and trans.
  552. The only specification required is the transmissivity at normal
  553. incidence.
  554. To compute transmissivity (tn) from transmittance (Tn) use:
  555. .DS
  556. tn = (sqrt(.8402528435+.0072522239*Tn*Tn)-.9166530661)/.0036261119/Tn
  557. .DE
  558. Standard 88% transmittance glass has a transmissivity of 0.96.
  559. (A pattern modifying glass will affect the transmissivity.)
  560. If a fourth real argument is given, it is interpreted as the index of
  561. refraction to use instead of 1.52.
  562. .DS
  563. mod glass id
  564. 0
  565. 0
  566. 3 rtn gtn btn
  567. .DE
  568. .LP
  569. .UL Plasfunc
  570. .PP
  571. Plasfunc in used for the procedural definition of plastic-like
  572. materials with arbitrary bidirectional reflectance distribution
  573. functions (BRDF's).
  574. The arguments to this material include the color and specularity,
  575. as well as the function defining the specular distribution and the
  576. auxiliary file where it may be found.
  577. .DS
  578. mod plasfunc id
  579. 2+ refl funcfile transform
  580. 0
  581. 4+ red green blue spec A5 ..
  582. .DE
  583. The function
  584. .I refl
  585. must take three arguments, the x, y and z
  586. direction towards the incident light, and should integrate to 1 over
  587. the projected hemisphere.
  588. At least four real arguments must be given, and these are made
  589. available along with any additional values to the reflectance
  590. function.
  591. Currently, only the contribution from direct light sources is
  592. considered in the specular calculation.
  593. .LP
  594. .UL Metfunc
  595. .PP
  596. Metfunc is identical to plasfunc and takes the same arguments, but
  597. the specular component is multiplied also by the material color.
  598. .LP
  599. .UL Transfunc
  600. .PP
  601. Transfunc is similar to plasfunc but with an arbitrary bidirectional
  602. transmittance distribution as well as a reflectance distribution.
  603. Both reflectance and transmittance are specified with the same function.
  604. .DS
  605. mod transfunc id
  606. 2+ refl funcfile transform
  607. 0
  608. 4+ red green blue rspec trans tspec A7 ..
  609. .DE
  610. Where
  611. .I trans
  612. is the total light transmitted and
  613. .I tspec
  614. is the non-Lambertian fraction of transmitted light.
  615. The function
  616. .I refl
  617. should integrate to 1 over each projected hemisphere.
  618. .LP
  619. .UL BRTDfunc
  620. .PP
  621. The material BRTDfunc gives the maximum flexibility over surface
  622. reflectance and transmittance, providing for spectrally-dependent
  623. specular rays and reflectance and transmittance distribution functions.
  624. .DS
  625. mod BRTDfunc id
  626. 10+  rrefl  grefl  brefl
  627.      rtrns  gtrns  btrns
  628.      rbrtd  gbrtd  bbrtd
  629.      funcfile  transform
  630. 0
  631. 6+ red green blue rspec trans tspec A7 ..
  632. .DE
  633. The variables
  634. .I "rrefl, grefl"
  635. and
  636. .I brefl
  637. specify the color coefficients for
  638. the ideal specular (mirror) reflection of the surface.
  639. These values are not modified by
  640. .I rspec,
  641. thus the diffuse reflectances
  642. .I "red, green"
  643. and
  644. .I blue
  645. implicitly exclude the mirrored specular
  646. component and should be set accordingly.
  647. Similarly, the variables
  648. .I "rtrns, gtrns"
  649. and
  650. .I btrns
  651. specify the color coefficients for the transmitted direction.
  652. These values are modified by the total transmittance,
  653. .I trans,
  654. but not by
  655. .I tspec.
  656. The functions
  657. .I "rbrtd, gbrtd"
  658. and
  659. .I bbrtd
  660. take the direction to the incident light
  661. and compute the color coefficient for the non-Lambertian part of
  662. reflection and transmission.
  663. These functions are modified by
  664. .I rspec
  665. and
  666. .I tspec
  667. appropriately, and they
  668. are expected to integrate to 1 over each projected hemisphere.
  669. .LP
  670. .UL Plasdata
  671. .PP
  672. Plasdata is used for arbitrary BRDF's that are most conveniently
  673. given as interpolated data.
  674. The arguments to this material are the data file and coordinate index
  675. functions, as well as a function to optionally modify the data
  676. values.
  677. .DS
  678. mod plasdata id
  679. 3+n+
  680. func datafile
  681. funcfile x1 x2 .. xn transform
  682. 0
  683. 4+ red green blue spec A5 ..
  684. .DE
  685. The coordinate indices
  686. .I "(x1, x2,"
  687. etc.) are themselves functions of
  688. the x, y and z direction to the incident light.
  689. The data function
  690. .I (func)
  691. takes a single variable, which is the
  692. interpolated value from the n-dimensional data file.
  693. .LP
  694. .UL Metdata
  695. .PP
  696. As metfunc is to plasfunc, metdata is to plasdata.
  697. Metdata takes the same arguments as plasdata, but the specular
  698. component is modified by the given material color.
  699. .LP
  700. .UL Transdata
  701. .PP
  702. Transdata is like plasdata but the specification includes transmittance
  703. as well as reflectance.
  704. The parameters are as follows.
  705. .DS
  706. mod transdata id
  707. 3+n+
  708. func datafile
  709. funcfile x1 x2 .. xn transform
  710. 0
  711. 4+ red green blue rspec trans tspec A7 ..
  712. .DE
  713. .LP
  714. .UL Antimatter
  715. .PP
  716. Antimatter is a material that can "subtract" volumes from other volumes.
  717. A ray passing into an antimatter object becomes blind to all the specified
  718. modifiers:
  719. .DS
  720. mod antimatter id
  721. N mod1 mod2 .. modN
  722. 0
  723. 0
  724. .DE
  725. The first modifier will be used to shade the area leaving the
  726. antimatter volume and entering the regular volume.
  727. If mod1 is void, the antimatter volume is completely invisible.
  728. Antimatter does not work properly with the material type "trans",
  729. and multiple antimatter surfaces should be disjoint.
  730. The viewpoint must be outside all volumes concerned for a correct
  731. rendering.
  732. .NH 3
  733. Textures
  734. .PP
  735. A texture is a perturbation of the surface normal, and
  736. is given by either a function or data.
  737. .LP
  738. .UL Texfunc
  739. .PP
  740. A texfunc uses an auxiliary function file
  741. to specify a procedural texture:
  742. .DS
  743. mod texfunc id
  744. 4+ xpert ypert zpert funcfile transform
  745. 0
  746. n A1 A2 .. An
  747. .DE
  748. .LP
  749. .UL Texdata
  750. .PP
  751. A texdata texture uses three data files to get the surface
  752. normal perturbations.
  753. The variables 
  754. .I xfunc, 
  755. .I yfunc
  756. and 
  757. .I zfunc
  758. take three arguments
  759. each from the interpolated values in
  760. .I xdfname,
  761. .I ydfname
  762. and
  763. .I zdfname.
  764. .DS
  765. mod texdata id
  766. 8+ xfunc yfunc zfunc xdfname ydfname zdfname vfname x0 x1 .. xf
  767. 0
  768. n A1 A2 .. An
  769. .DE
  770. .NH 3
  771. Patterns
  772. .PP
  773. Patterns are used to modify the reflectance of materials.
  774. The basic types are given below.
  775. .LP
  776. .UL Colorfunc
  777. .PP
  778. A colorfunc is a procedurally defined color pattern.
  779. It is specified as follows:
  780. .DS
  781. mod colorfunc id
  782. 4+ red green blue funcfile transform
  783. 0
  784. n A1 A2 .. An
  785. .DE
  786. .LP
  787. .UL Brightfunc
  788. .PP
  789. A brightfunc is the same as a colorfunc, except it is monochromatic.
  790. .DS
  791. mod brightfunc id
  792. 2+ refl funcfile transform
  793. 0
  794. n A1 A2 .. An
  795. .DE
  796. .LP
  797. .UL Colordata
  798. .PP
  799. Colordata uses an interpolated data map to modify a material's color.
  800. The map is n-dimensional, and is stored in three
  801. auxiliary files, one for each color.
  802. The coordinates used to look up and interpolate the data are
  803. defined in another auxiliary file.
  804. The interpolated data values are modified by functions of
  805. one or three variables.
  806. If the functions are of one variable, then they are passed the
  807. corresponding color component (red or green or blue).
  808. If the functions are of three variables, then they are passed the
  809. original red, green, and blue values as parameters.
  810. .DS
  811. mod colordata id
  812. 7+n+
  813. rfunc gfunc bfunc rdatafile gdatafile bdatafile
  814. funcfile x1 x2 .. xn transform
  815. 0
  816. m A1 A2 .. Am
  817. .DE
  818. .LP
  819. .UL Brightdata
  820. .PP
  821. Brightdata is like colordata, except monochromatic.
  822. .DS
  823. mod brightdata id
  824. 3+n+
  825. func datafile
  826. funcfile x1 x2 .. xn transform
  827. 0
  828. m A1 A2 .. Am
  829. .DE
  830. .LP
  831. .UL Colorpict
  832. .PP
  833. Colorpict is a special case of colordata, where the pattern is
  834. a two-dimensional image stored in the RADIANCE picture format.
  835. The dimensions of the image data are determined by the picture
  836. such that the smaller dimension is always 1, and the other
  837. is the ratio between the larger and the smaller.
  838. For example, a 500x338 picture would have coordinates (u,v)
  839. in the rectangle between (0,0) and (1.48,1).
  840. .DS
  841. mod colorpict id
  842. 7+
  843. rfunc gfunc bfunc pictfile
  844. funcfile u v transform
  845. 0
  846. m A1 A2 .. Am
  847. .DE
  848. .LP
  849. .UL Colortext
  850. .PP
  851. Colortext is dichromatic writing in a polygonal font.
  852. The font is defined in an auxiliary file, such as
  853. .I helvet.fnt.
  854. The text itself is also specified in a separate file, or
  855. can be part of the material arguments.
  856. The character size, orientation, aspect ratio and slant is
  857. determined by right and down motion vectors.
  858. The upper left origin for the text block as well as
  859. the foreground and background colors
  860. must also be given.
  861. .DS
  862. mod colortext id
  863. 2 fontfile textfile
  864. 0
  865. 15+
  866. Ox Oy Oz
  867. Rx Ry Rz
  868. Dx Dy Dz
  869. rfore gfore bfore
  870. rback gback bback
  871. [spacing]
  872. .DE
  873. or:
  874. .DS
  875. mod colortext id
  876. 2+N fontfile . This is a line with N words ...
  877. 0
  878. 15+
  879. Ox Oy Oz
  880. Rx Ry Rz
  881. Dx Dy Dz
  882. rfore gfore bfore
  883. rback gback bback
  884. [spacing]
  885. .DE
  886. .LP
  887. .UL Brighttext
  888. .PP
  889. Brighttext is like colortext, but the writing is monochromatic.
  890. .DS
  891. mod brighttext id
  892. 2 fontfile textfile
  893. 0
  894. 11+
  895. Ox Oy Oz
  896. Rx Ry Rz
  897. Dx Dy Dz
  898. foreground background
  899. [spacing]
  900. .DE
  901. or:
  902. .DS
  903. mod brighttext id
  904. 2+N fontfile . This is a line with N words ...
  905. 0
  906. 11+
  907. Ox Oy Oz
  908. Rx Ry Rz
  909. Dx Dy Dz
  910. foreground background
  911. [spacing]
  912. .DE
  913. .LP
  914. By default, a uniform spacing algorithm is used that guarantees
  915. every character will appear in a precisely determined position.
  916. Unfortunately, such a scheme results in rather unattractive and difficult to
  917. read text with most fonts.
  918. The optional
  919. .I spacing
  920. value defines the distance between characters for proportional spacing.
  921. A positive value selects a spacing algorithm that preserves right margins and
  922. indentation, but does not provide the ultimate in proportionally spaced text.
  923. A negative value insures that characters are properly spaced, but the
  924. placement of words then varies unpredictably.
  925. The choice depends on the relative importance of spacing versus formatting.
  926. When presenting a section of formatted text, a positive spacing value is
  927. usually preferred.
  928. A single line of text will often be accompanied by a negative spacing value.
  929. A section of text meant to depict a picture, perhaps using a special purpose
  930. font such as hexbit4x1.fnt, calls for uniform spacing.
  931. Reasonable magnitudes for proportional spacing are
  932. between 0.1 (for tightly spaced characters) and 0.3 (for wide spacing).
  933. .NH 3
  934. Mixtures
  935. .PP
  936. A mixture is a blend of one or more textures and patterns.
  937. The basic types are given below.
  938. .LP
  939. .UL Mixfunc
  940. .PP
  941. A mixfunc mixes two modifiers procedurally.
  942. It is specified as follows:
  943. .DS
  944. mod mixfunc id
  945. 4+ foreground background vname funcfile transform
  946. 0
  947. n A1 A2 .. An
  948. .DE
  949. Foreground and background are modifier names that must be uniquely
  950. defined in the scene description.
  951. Vname is the coefficient defined in funcfile that determines the influence
  952. of foreground.
  953. The background coefficient is always (1-vname).
  954. Since the references are not resolved until runtime, the last
  955. definitions of the modifier id's will be used.
  956. This can result in modifier loops, which are detected by the
  957. renderer.
  958. .LP
  959. .UL Mixdata
  960. .PP
  961. Mixdata combines two modifiers using an auxiliary data file:
  962. .DS
  963. mod mixdata id
  964. 5+n+
  965. foreground background func datafile
  966. funcfile x1 x2 .. xn transform
  967. 0
  968. m A1 A2 .. Am
  969. .DE
  970. .LP
  971. .UL Mixtext
  972. .PP
  973. Mixtext uses one modifier for the text foreground, and one for the
  974. background:
  975. .DS
  976. mod mixtext id
  977. 4 foreground background fontfile textfile
  978. 0
  979. 9+
  980. Ox Oy Oz
  981. Rx Ry Rz
  982. Dx Dy Dz
  983. [spacing]
  984. .DE
  985. or:
  986. .DS
  987. mod mixtext id
  988. 4+N
  989. foreground background fontfile .
  990. This is a line with N words ...
  991. 0
  992. 9+
  993. Ox Oy Oz
  994. Rx Ry Rz
  995. Dx Dy Dz
  996. [spacing]
  997. .DE
  998. .NH 2
  999. Auxiliary Files
  1000. .PP
  1001. Auxiliary files used in textures and patterns
  1002. are accessed by the programs during image generation.
  1003. These files may be located in the working directory, or in
  1004. a library directory.
  1005. The environment variable
  1006. .I RAYPATH
  1007. can be assigned an alternate set of search directories.
  1008. Following is a brief description of some common file types.
  1009. .NH 3
  1010. Function Files
  1011. .PP
  1012. A function file contains the definitions of variables, functions
  1013. and constants used by a primitive.
  1014. The transformation that accompanies the file name contains the necessary
  1015. rotations, translations and scalings to bring the coordinates of
  1016. the function file into agreement with the world coordinates.
  1017. The transformation specification is the same as for the
  1018. .I xform
  1019. command.
  1020. An example function file is given below:
  1021. .DS
  1022. {
  1023. This is a comment, enclosed in curly braces.
  1024. {Comments can be nested.}
  1025. }
  1026. { standard expressions use +,-,*,/,^,(,) }
  1027. vname = Ny * func(A1) ;
  1028. { constants are defined with a colon }
  1029. const : sqrt(PI/2) ;
  1030. { user-defined functions add to library }
  1031. func(x) = 5 + A1*sin(x/3) ;
  1032. { functions may be passed and recursive }
  1033. rfunc(f,x) = if(x,f(x),f(-x)*rfunc(f,x+1)) ;
  1034. { constant functions may also be defined }
  1035. cfunc(x) : 10*x / sqrt(x) ;
  1036. .DE
  1037. Many variables and functions are already defined by the program,
  1038. and they are listed in the file
  1039. .I rayinit.cal.
  1040. The following variables are particularly important:
  1041. .DS
  1042. Dx, Dy, Dz- incident ray direction
  1043. Px, Py, Pz- intersection point
  1044. Nx, Ny, Nz- surface normal at intersection point
  1045. Rdot- cosine between ray and normal
  1046. arg(0)- number of real arguments
  1047. arg(i)- i'th real argument
  1048. .DE
  1049. For BRDF types, the following variables are defined as well:
  1050. .DS
  1051. NxP, NyP, NzP- perturbed surface normal
  1052. RdotP- perturbed dot product
  1053. CrP, CgP, CbP- perturbed material color
  1054. .DE
  1055. A unique context is set up for each file so that the same variable
  1056. may appear in different function files without conflict.
  1057. The variables listed above and any others defined in
  1058. rayinit.cal are available globally.
  1059. If no file is needed by a given primitive because all the required
  1060. variables are global, a period (`.') can be given in
  1061. place of the file name.
  1062. It is also possible to give an expression instead of a straight
  1063. variable name in a scene file, although such expressions should
  1064. be kept simple as they cannot contain any white space.
  1065. Also, functions (requiring parameters)
  1066. must be given as names and not as expressions.
  1067. .PP
  1068. Constant expressions are used as an optimization in function
  1069. files.
  1070. They are replaced wherever they occur in an expression by their
  1071. value.
  1072. Constant expressions are evaluated only once, so they must not
  1073. contain any variables or values that can change, such as the ray
  1074. variables Px and Ny or the primitive argument function arg().
  1075. All the math library functions such as sqrt() and cos() have the
  1076. constant attribute, so they will be replaced by immediate values
  1077. whenever they are given constant arguments.
  1078. Thus, the subexpression cos(PI*sqrt(2)) is immediately replaced
  1079. by its value, -.266255342, and does not cause any additional overhead
  1080. in the calculation.
  1081. .PP
  1082. It is generally a good idea to define constants and variables before
  1083. they are referred to in a function file.
  1084. Although evaluation does not take place until later, the interpreter
  1085. does variable scoping and constant subexpression evaluation based on
  1086. what it has compiled already.
  1087. For example, a variable that is defined globally in rayinit.cal then
  1088. referenced in the local context of a function file cannot
  1089. subsequently be redefined in the same file because the compiler
  1090. has already determined the scope of the referenced variable as global.
  1091. To avoid such conflicts, one can state the scope of a variable explicitly
  1092. by preceding the variable name with a context mark (a back-quote) for
  1093. a local variable, or following the name with a context mark for a global
  1094. variable.
  1095. .NH 3
  1096. Data Files
  1097. .PP
  1098. Data files contain n-dimensional arrays of real numbers used
  1099. for interpolation.
  1100. Typically, definitions in a function file determine how
  1101. to index and use interpolated data values.
  1102. The basic data file format is as follows:
  1103. .DS
  1104. N
  1105. beg1 end1 m1
  1106. 0 0 m2 x2.1 x2.2 x2.3 x2.4 .. x2.m2
  1107.  ...
  1108. begN endN mN
  1109. DATA, later dimensions changing faster.
  1110. .DE
  1111. N is the number of dimensions.
  1112. For each dimension, the beginning and ending coordinate
  1113. values and the dimension size is given.
  1114. Alternatively, individual coordinate values can be given when
  1115. the points are not evenly spaced.
  1116. These values must either be increasing or decreasing monotonically.
  1117. The data is m1*m2*...*mN real numbers in ascii form.
  1118. Comments are not allowed in data files.
  1119. .NH 3
  1120. Font Files
  1121. .PP
  1122. A font file lists the polygons which make up a character set.
  1123. There are no comments, and all numbers are decimal integers:
  1124. .DS
  1125. code n
  1126. x0 y0
  1127. x1 y1
  1128.  ...
  1129. xn yn
  1130.  ...
  1131. .DE
  1132. The ascii codes can appear in any order.
  1133. N is the number of vertices, and the last is automatically
  1134. connected to the first.
  1135. Separate polygonal sections are joined by coincident sides.
  1136. The character coordinate system is a square with lower left corner at
  1137. (0,0), lower right at (255,0) and upper right at (255,255).
  1138. .NH 2
  1139. Generators
  1140. .PP
  1141. A generator is any program that produces a scene description
  1142. as its output.
  1143. They usually appear as commands in a scene description file.
  1144. An example of a simple generator is
  1145. .I genbox.
  1146. .I Genbox
  1147. takes the arguments of width, height and depth to produce
  1148. a parallelepiped description.
  1149. .I Genrev
  1150. is a more sophisticated generator
  1151. that produces an object of rotation from parametric functions
  1152. for radius and axis position.
  1153. .I Gensurf
  1154. tessellates a surface defined by the
  1155. parametric functions x(s,t), y(s,t), and z(s,t).
  1156. .I Genworm
  1157. links cylinders and spheres along a curve.
  1158. .I Gensky
  1159. produces a sun and sky distribution corresponding
  1160. to a given time and date.
  1161. .PP
  1162. .I Xform
  1163. is a program that transforms a scene description from one
  1164. coordinate space to another.
  1165. .I Xform
  1166. does rotation, translation, scaling, and mirroring.
  1167. .NH 1
  1168. Image Generation
  1169. .PP
  1170. Once the scene has been described in three-dimensions, it
  1171. is possible to generate a two-dimensional image from a
  1172. given perspective.
  1173. .PP
  1174. The image generating programs use an
  1175. .I octree
  1176. to efficiently trace rays through the scene.
  1177. An octree subdivides space into nested octants which
  1178. contain sets of surfaces.
  1179. In RADIANCE, an octree is created from a scene description by
  1180. .I oconv.
  1181. The details of this process are not important,
  1182. but the octree will serve as input to the ray-tracing
  1183. programs and directs the use of a scene description.
  1184. .PP
  1185. .I Rview
  1186. is ray-tracing program for viewing a scene interactively.
  1187. When the user specifies a new perspective,
  1188. .I rview
  1189. quickly displays a rough
  1190. image on the terminal, then progressively
  1191. increases the resolution as the user looks on.
  1192. He can select a particular section of the image to improve,
  1193. or move to a different view and start over.
  1194. This mode of interaction is useful for debugging scenes
  1195. as well as determining the best view for a final image.
  1196. .PP
  1197. .I Rpict
  1198. produces a high-resolution picture of a scene from
  1199. a particular perspective.
  1200. This program features adaptive sampling, crash
  1201. recovery and progress reporting, all of which are important
  1202. for time-consuming images.
  1203. .PP
  1204. A number of filters are available for manipulating picture files.
  1205. .I Pfilt
  1206. sets the exposure and performs anti-aliasing.
  1207. .I Pcompos
  1208. composites (cuts and pastes) pictures.
  1209. .I Pvalue
  1210. converts a picture to and from alternate forms.
  1211. .PP
  1212. Currently only a few graphics output devices are supported.
  1213. .I Tttyimage
  1214. produces a crude character representation of an
  1215. image on a dumb terminal.
  1216. .I Aedimage
  1217. produces output on an AED 512 graphics terminal, and
  1218. .I ximage
  1219. produces an image on an X-window server.
  1220. Output is also available on certain dot-matrix printers
  1221. and the Dicomed film recorder.
  1222. The list of supported output devices is expected to grow
  1223. as the system is made more widely available.
  1224. .NH 1
  1225. Acknowledgements
  1226. .PP
  1227. This work was supported by the Assistant Secretary of Conservation
  1228. and Renewable Energy, Office of Building Energy Research and
  1229. Development, Buildings Equipment Division of the U.S. Department of
  1230. Energy under Contract No. DE-AC03-76SF00098.
  1231. .PP
  1232. Additional work was sponsored by the Swiss federal government
  1233. under the Swiss LUMEN Project and was
  1234. carried out in the Laboratoire d'Energie Solaire (LESO Group) at
  1235. the Ecole Polytechnique Federale de Lausanne (EPFL University)
  1236. in Lausanne, Switzerland.
  1237. .NH 1
  1238. References
  1239. .LP
  1240. Ward, G.,
  1241. ``Measuring and Modeling Anisotropic Reflection,''
  1242. .I "Computer Graphics",
  1243. Chicago, July 1992.
  1244. .LP
  1245. Ward, G., P. Heckbert,
  1246. ``Irradiance Gradients,''
  1247. .I "Third Annual Eurographics Workshop on Rendering",
  1248. to be published by Springer-Verlag, held in Bristol, UK, May 1992.
  1249. .LP
  1250. Ward, G.,
  1251. ``Adaptive Shadow Testing for Ray Tracing,''
  1252. .I "Second Annual Eurographics Workshop on Rendering",
  1253. to be published by Springer-Verlag, held in Barcelona, SPAIN, May 1991.
  1254. .LP
  1255. Ward, G.,
  1256. ``Visualization,''
  1257. .I "Lighting Design and Application",
  1258. Vol. 20, No. 6, June 1990.
  1259. .LP
  1260. Ward, G., F. Rubinstein, R. Clear,
  1261. ``A Ray Tracing Solution for Diffuse Interreflection,''
  1262. .I "Computer Graphics",
  1263. Vol. 22, No. 4, August 1988.
  1264. .LP
  1265. Ward, G., F. Rubinstein,
  1266. ``A New Technique for Computer Simulation of Illuminated Spaces,''
  1267. .I "Journal of the Illuminating Engineering Society",
  1268. Vol. 17, No. 1, Winter 1988.
  1269.