POV-Ray : Newsgroups : povray.programming : Fog and Color Maps : Re: Fog and Color Maps Server Time
28 Jul 2024 20:27:28 EDT (-0400)
  Re: Fog and Color Maps  
From: Nathan Kopp
Date: 30 Jun 1999 21:07:33
Message: <377ABE60.1E6E7EC4@Kopp.com>
Looks pretty good.  Of course, this is limited to the gradient color_map.
The computation and effect would be similar to multiple layers of ground
fog, although the syntax of this is a bit nicer.

-Nathan

Robert Dawson wrote:
>     Well, actually, I can see the possibility of a fog_map [syntactically
> equivalent to a color_map except that the index values would probably be
> unbounded] without ray-marching, fast, and true to the fog philosophy.
> Basically, it would integrate through the color table, doing one calculation
> for each separate entry.
> 
>     EG: fog_map{[-50 color Red] [0 color White] [0 color Clear]}}
> 
> would represent a fog that was red from -50 units down, faded to white
> between -50 and 0, and suddenly stopped at 0.  Fog density is a linear
> function of position, and hence the amount of fog color in the pixel can be
> found by one (piecewise, with up to n+1 sections if there are n entries in
> the map) integration for each primary color. The integral is, of course,
> done at coding time, as with the existing fog.
> 
>     So instead of (as now) having one channel's intensity determined by
> 
>     dl = - l rho dx              [this is for a black fog; for
>     l/dl = - rho dx               any other color work with the difference]
>     log(l) = - rho x + c
> 
>     l = K exp(- rho x)
> 
> it would be
> 
>     dl = - l rho(x) dx
>     l/dl = - (ax+b) dx          [a,b determined from fog_map]
>     log(l) = -(ax^2/2 + bx + c)
> 
>     l = K exp(-(ax^2 + bx))
> 
> -practically no harder to calculate.
> 
>    If the ray travels a distance D from camera to object, and the camera is
> at height H relative to the fog direction and fogmap while the object is at
> height h,
> we first go through the fog_map from the appropriate end until we find an
> interval containing the object, whose color is determined. We then see if
> the camera or the end of the map interval comes first.
> 
>     Whichever does, we determine, for each color component, coefficients a
> and b such that
> 
>    fog.r-original.r == a.r*distance + b.r
>    fog.b-original.b == a.b*distance + b.b
>       -etc
> 
> on the interval. We then compute
> 
>     k =  exp(-(a*d*d/2 + b*d))  /* proportion of original channel value left
> 
>     color.r = fog.r*(1-k) + color.r*k
> 
> and repeat, interval by interval, until we reach the camera.
> 
> I may mave made some minor mistakes here but the idea ought to work.
> 
>     Turbulation would be somewhat ad hoc, but (eg) moving the end point
> ought to work fairly well. Because fog is, well, foggy, the details would
> not be too important. There aren't a zillion distinctive things you can do
> to fog, so this would cover most of the options as far as you could tell by
> eye.
> 
>     -Robert Dawson


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.