home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / graphics / ftpov_2 / Authors / POVAFX10 < prev    next >
Text File  |  1995-12-19  |  14KB  |  302 lines

  1.                                         ____
  2.                                        /   /   
  3.                    _________  ____    /   /   
  4.                   |         | \   \  /   /
  5.                   |   ,-----'  \   \/   /   
  6.                   |   |____     \      /   
  7.               POVA|        |     \    /   
  8.                   |   ,----'     /    \
  9.                   |   |         /      \
  10.                   |   |        /   /\   \
  11.                   |___|       /   /  \___\
  12.                              /   /    
  13.                             /   /   POVAFX v1.0 extensions 
  14.                            /   /   POV-Ray with Simple Atmospheric Effects 
  15.                           /   /    
  16.                          /   /   Marcos Fajardo 
  17.                         /   /   mfajardo@freenet.hut.fi 
  18.                        /   /   http://www.geopages.com/TimesSquare/2143 
  19.                       /___/    
  20.  
  21.  
  22.  
  23.  
  24. 0. INDEX
  25.  
  26.         0. INDEX
  27.         1. WHAT'S THIS?
  28.         2. WELL, WHAT ARE EXACTLY THOSE FX?
  29.         3. TRICKS AND TIPS
  30.         4. DISTRIBUTION SITES
  31.         5. MAKING BINARIES
  32.         6. CHANGES TO ORIGINAL POV-RAY 2.2 CODE
  33.         7. CONTACTING THE AUTHOR
  34.         8. REFERENCES
  35.  
  36.  
  37.  
  38. 1. WHAT'S THIS?
  39.  
  40.         POVAFX is a custom unofficial version of the POV-Ray ray tracer that 
  41.         is able to render some simple light-atmosphere interactions. This 
  42.         first release comes with two such effects, namely ground fog and 
  43.         glowing lights. A few new reserved words have been added to the 
  44.         parser in order to accomodate smoothly these extensions. Of course, 
  45.         being this just a little extension to POV-Ray 2.2 code, there aren't 
  46.         any compatibility problems with POV-Ray scenes. It will behave 
  47.         exactly as an official POV-Ray does, but with the added functionality 
  48.         of a couple of new switcheable features. 
  49.  
  50.         I've decided to make these simple but useful enhancements public,
  51.         since i know of a lot of people who would like them, and it's been 
  52.         very few work (it was already coded in my own realistic rendering 
  53.         engine, the only issue here was poking around with POV-Ray's code). 
  54.         People out there is very bored waiting for POV-Ray 3.0 to come; it's 
  55.         taking it slowly, so these little and simple goodies may be welcome 
  56.         by some of you. If POV-Ray 3.0 gets released inmediately after this 
  57.         POVAFX v1.0 release, most likely i'll have made an stupidity, since 
  58.         POVAFX v1.0 WILL UNDOUBTEDLY AND SOON BE FORGOTTEN. I'm a fool, i 
  59.         know... i should have made this 6 months ago, not now... it's just 
  60.         too late to complain about it. At least i've had fun hacking POV's 
  61.         code! :-) And if people out there shows some interest in POVAFX v1.0
  62.         i could add some more effects like foggy spotlights with fast volume 
  63.         shadows (Z-buffering from the lights...) or whatever they suggest.
  64.  
  65.  
  66.  
  67. 2. WELL, WHAT ARE EXACTLY THOSE FX?
  68.  
  69.         Ground fog
  70.  
  71.                 This is an enhancement to POV-Ray's uniform fog feature.
  72.                 Now fog density vanishes exponentially along the positive Y 
  73.                 axis, due to the factor exp(-y/height). At y=0 density is 
  74.                 100% its full value, at y=height it's 37%, at y=4*height it's 
  75.                 2% and finally it becomes 0% at y=infinite. Thus the fog 
  76.                 statement has been extended with a new keyword:
  77.  
  78.                         fog { color SkyBlue distance 200 height 50 }
  79.  
  80.                 If height is omitted, you get standard fog. Just remember 
  81.                 that 'distance' controls the fog strength and 'height'
  82.                 controls its decrease rate along Y axis. Please note that
  83.                 when using ground fog, there is no fog at all in the range
  84.                 y<0, so you'll see a discontinuity if your ground plane is
  85.                 below y=0.
  86.  
  87.         Glowing lights
  88.  
  89.                 Traditional point light sources are invisible by themselves,
  90.                 they serve just as illuminators of object surfaces. You 
  91.                 just can't see a point. That holds correct only in a clear 
  92.                 pristine atmosphere, otherwise every ray would transport some
  93.                 amount of scattered energy coming from the atmosphere itself
  94.                 in the ray direction. Rays passing near the light source 
  95.                 would gather more energy because light emanating from it is 
  96.                 attenuated by the distance. That's exactly the phenomenom
  97.                 that POVAFX inexactly models with its glowing lights. And
  98.                 what is the visible effect of this whole story? The answer
  99.                 is simple: point light sources become visible, surrounded by
  100.                 a subtle (or wild if you want) halo. This is managed via 
  101.                 three additional keywords pertaining to POV-Ray's point
  102.                 sources: glow, glow_type_a and glow_type_b. Example:
  103.  
  104.                         light_source { 
  105.                            <0, 5, 0> 
  106.                            color White 
  107.                            glow 0.2 
  108.                            glow_type_b 
  109.                         }
  110.  
  111.                 The glow parameter tells about the local fog density that
  112.                 will be used in the computations involving this light source,
  113.                 and it controls how strong the halo will be. It would have
  114.                 been more correct using the same fog density for all light
  115.                 sources, but this way allows more flexibility, and you can
  116.                 always use the same glow value for all of your lights. The
  117.                 glow type refers to the function used to attenuate light. 
  118.                 Type A uses 1/d^2, with 'd' being distance to the source,
  119.                 which has been the standard for atmospheric scattering due
  120.                 to point light sources in computer graphics because of the 
  121.                 simplicity of the integral involved (see [1] and [3]). Type 
  122.                 B, fruit of my own research, uses a similar but definitely 
  123.                 not the same function: 1/(d^2+1). As is not the case with 
  124.                 type A, halos of type B don't get always wildly saturated 
  125.                 in their center. Anyhow, both glow types are physically 
  126.                 inaccurate, because a more accurate model makes an analytical 
  127.                 solution very difficult to find (or impossible at all).
  128.                 Default model is A.
  129.  
  130.  
  131.  
  132. 3. TRICKS AND TIPS
  133.  
  134.              - Ground fog was implemented to be visible only in y>0, so the
  135.                usual way of using it is with a ground plane at y=0. If you
  136.                position the camera at y=0 you'll clearly see the 
  137.                discontinuity in the fog.
  138.  
  139.              - Try negative values in the light intensity like this:
  140.  
  141.                         light_source { 
  142.                            <1 2 3> 
  143.                            color red -0.3 green -0.3 blue -0.3
  144.                            glow 0.2
  145.                         }
  146.  
  147.                You've effectively created a black hole! or in other words,
  148.                a visible light sucker, a darkness source ... Glassner called
  149.                them darklights in Graphics Gems III. If you put positive
  150.                light but negative glow, the result is similar, since you
  151.                can see the source as an obscure spot, but objects will be
  152.                normally illuminated. Think of it, it's tons of fun.
  153.  
  154.              - Subtle ground fog (high distance, high height) always 
  155.                improves outdoor scenes, being a simple alternative for 
  156.                gradient textured sky spheres.
  157.  
  158.              - Use low values of glow to avoid excessive saturation near 
  159.                the lights, but feel free to turn it up when you want extreme
  160.                effects like explosions devouring cities and the like.
  161.                Remember that glow type B is less prone to saturation, and
  162.                that lights of type A always have a saturated intensity peak
  163.                in their very center, even with low values of glow.
  164.  
  165.              - When using non-white light sources (slightly redish, for 
  166.                example) the three rgb components won't get saturated at the 
  167.                same time, ones will do before others, creating layers of 
  168.                rings due to extreme Mach banding. This is a side effect that
  169.                can look actually very cool, accidentally similar to some
  170.                kind of lens flare so common these days. Play with it!
  171.  
  172.              - You can of course use ground fog at the same time you are
  173.                using glowing lights, but if you are worried about 
  174.                correctness, yes, there is some kind of conceptual 
  175.                incompatibility between both effects as implemented here;
  176.                glowing lights work as if they were inmersed in uniform fog,
  177.                and ground fog lacks uniformity along Y axis, besides being
  178.                designed as illuminated by a directional source as the sun. 
  179.                This is a little but worth to note "defect". There's much, 
  180.                much more to the accurate simulation of atmospheres than 
  181.                these two almost trivial effects. Refer to the research 
  182.                literature and you will find how complex things can get.
  183.  
  184.  
  185.  
  186. 4. DISTRIBUTION SITES
  187.  
  188.         Still looking for them ... I suppose it could be stored in 
  189.         ftp.povray.org, perhaps in pub/povray/incoming/unofficial/compiles
  190.         or somewhere like that.
  191.  
  192.         The original POV-Ray 2.2 package can be downloaded (among other 
  193.         places) from POV-Ray's own official site: ftp.povray.org, in
  194.         /pub/povray/... (i can't remember the full path). You can also 
  195.         access it via www at http://www.povray.org
  196.  
  197.  
  198.  
  199. 5. MAKING BINARIES
  200.  
  201.         POVAFX is distributed as the modified source code from the official
  202.         POV-Ray 2.2, so to compile an executable you just have to replace 
  203.         the old original files with these ones, and proceed normally as 
  204.         indicated for your machine. I've distributed a PC/MSDOS executable 
  205.         compiled with GNU's GCC (djgpp), which suffers from the same display
  206.         problems as the executable distributed with FTPOV; you must specify 
  207.         the correct video card and you are limited to 8 bits per pixel.
  208.         
  209.         
  210.         
  211. 6. CHANGES TO ORIGINAL POV-RAY 2.2 CODE
  212.         
  213.         These are short descriptions of the changes. Wherever i've modified 
  214.         something, i've put near it a comment like this: /* [Marcos] */, so 
  215.         searching the string [Marcos] will lead you there.
  216.  
  217.         LIGHTING.C
  218.  
  219.                 Enhanced function Fog(). Note that it computes ground fog 
  220.                 iff height<>0, and now it takes new arguments. Defined some 
  221.                 macros for improved readability (Lerp, ColorLerp, Clamp).
  222.                 Added new function Glowing_Lights(). Modified functions to 
  223.                 call properly both Fog() and Glowing_Lights().
  224.  
  225.         RENDER.C
  226.         
  227.                 Modified functions to call properly both Fog() and 
  228.                 Glowing_Lights().
  229.  
  230.         POINT.C
  231.         
  232.                 Initialization of glow and glow type fields in light sources.
  233.  
  234.         TOKENIZE.C
  235.         
  236.                 Added new reserved words: "height", "glow", "glow_type_a"
  237.                 and "glow_type_b".
  238.  
  239.         PARSE.C
  240.         
  241.                 Initialization of fog height attribute in frame structure. 
  242.                 Added parsing of all new reserved words.
  243.                   
  244.         FRAME.H
  245.         
  246.                 Added fog height attribute to frame structure. Added glow 
  247.                 and glow type attributes to light sources. Defined M_PI_2 
  248.                 macro (one half pi).
  249.  
  250.         POVPROTO.H
  251.         
  252.                 Declaration of new or modified functions.
  253.  
  254.         PARSE.H
  255.         
  256.                 Added new tokens: HEIGHT_TOKEN, GLOW_TOKEN, GLOW_TYPE_A_TOKEN
  257.                 and GLOW_TYPE_B_TOKEN. Updated LAST_TOKEN.
  258.  
  259.  
  260.  
  261. 7. CONTACTING THE AUTHOR
  262.  
  263.         I will be very happy hearing from you. Please report any bugs or
  264.         inconvenience you find. I'm also always willing to discuss technical
  265.         details of image synthesis, so if you are on the tech side and
  266.         would like to talk about so many interesting things, just don't 
  267.         wait any more and mail me! :-) I have some early tests of some of
  268.         these atmospheric effects in my home page. Check them out.
  269.  
  270.                 mfajardo@freenet.hut.fi
  271.                 http://www.geopages.com/TimesSquare/2143
  272.  
  273.         You could also find me sometimes in IRC, nicknamed MarcosF or Marcos,
  274.         in channels #3d, #lightwave or somesuch. Sometimes even in #guitar
  275.         (hey, do you know of Eric Johnson? i'm looking for info on him :-)
  276.  
  277.         I also have snail mail at your disposal (yes, you'll need to use
  278.         a piece of paper with stamps... truly antique, isn't it? ;-)
  279.  
  280.                 Marcos Fajardo Orellana
  281.                 C/. Pico de las Palomas 11 5-I
  282.                 29004 Malaga
  283.                 SPAIN
  284.  
  285.  
  286.  
  287. 8. REFERENCES
  288.  
  289.         If you are interested in the technical issues behind atmospheric
  290.         effects, use [1] and [2] as starting points; you'll find lots of
  291.         references at the end of both of them.
  292.         
  293.         [1] N. L. Max, "Atmospheric Illumination and Shadows", Proc. of 
  294.             SIGGRAPH '86, pp 117-124
  295.  
  296.         [2] Nishita, Nakamae, Okamoto, Kaneda, "Photorealistic Image 
  297.             Synthesis for Outdoor Scenery under various Atmospheric 
  298.             Conditions", The Visual Computer, 7 (1991), pp 247-258
  299.  
  300.         [3] Han-Wen Nienhuys, short note in The Ray Tracing News v7 n3
  301.  
  302.