POV-Ray : Newsgroups : povray.programming : Ambient lighting in POV-Ray : Ambient lighting in POV-Ray Server Time
17 May 2024 05:18:02 EDT (-0400)
  Ambient lighting in POV-Ray  
From: Jing Li
Date: 5 Dec 2005 22:50:01
Message: <web.439509906fa4293fe49f817c0@news.povray.org>
I am studying the implementation of the Ambient lighting in POV-Ray.

As I know that the illumination equation of Ambient is the multiplication of
the intensity of the ambient light (Ia) and the ambient-reflection
coefficient of the object (Ka).

What I understand is that in POV-Ray, the ambient light source is a global
setting which is declared as "global_settings { ambient_light rgb<1, 0, 0>
}", the ambient for the surface of the object is set in Finish statement as
"finish {ambient rgb<0.4, 0, 0>}" defining a red ambient. The POV-Ray's
implementation defines the keyword "ambient_light" as the token
"AMBIENT_LIGHT_TOKEN". When the parser reads the token, it processes
Parse_Colour (Frame.Ambient_Light) method which stores the ambient color to
the variable Frame.Ambient_Light. When initialing the frame, its ambient
light is set to white (rgb<1, 1, 1>). POV-Ray's help document confirms the
default value of the global ambient light is rgb<1, 1, 1>.

POV-Ray uses the formula below to compute the ambient contribution.

TmpCol += FilCol*Att * LayCol * Layer->Finish->Ambient *
Frame.Ambient_Light; [Formula 1]

where TmpCol is a color variable to strore the ambient contribution
temporarily. The method is put in the section of computing the BRDF
contribution. The Wikipedia says a material's BRDF (Bidirectional
Reflectance Distribution Function) defines the ratio of ilght reflected
from a surface to the incident luminosity. I do not understand it. There is
a good explanation at http://geography.bu.edu/brdf/brdfexpl.html.

The implementation of POV-Ray has a paragraph comments about the variable
FilCol saying "FilCol serves two purposes. It accumulates the filter
properties of a multi-layer texture so that if a ray makes it all the way
through all layers, the color of object behind is filtered by this object.
It also is used to attenuate how much of an underlayer you can see in a
layered texture. Note that when computing the reflective properties of a
layered texture, teh upper layers don't filter the light from the lower
layers -- the layer colors add together (even before we added additive
transparency via the "transmit" 5th color channel). However when computing
the transmitted rays, all layers filter the light from any objects behind
this object. "

Att is computed using formula

Att = (1.0 - (LayCol[pFILTER]*max3(LayCol[0],LayCol[1],LayCol[2]) +
LayCol[pTRANSM])); [Formula 2]

where pFILTER, pTRANSM are the elements of a enum variable which defining
the indices of the Color array elements: pRED = 0; pGREEN = 1; pBLUE = 2;
pFILTER = 4; pTRANSM = 4; The LayCol is the color from the certain layer
for a given 3d point and a pigment. It is computed by calling the method
"Compute_Pigment(...)" in file pigment.cpp. POV-Ray's help document
explains the pigment as the color or pattern of colors for an object. It is
the basic color of the object, not the color the object looks like in a
scene which is brightened or darkened by POV-Ray depending on the lighting
in the scene.

The test scene has ambient lighting rgb<0.3, 0.3, 0.3> except any other
lighting sources. The sphere's surface has ambient rgb<0.6, 0.6, 0.6>, and
black pigment. POV-Ray generates a total black image when only define the
global ambient lighting and the object's ambient reflection. From the
[Formula 1], it is obvious that the LayCol is black as it is the pigment of
the object. As a result, the result color computed by [Formula 1] is black.

I am confused why POV-Ray implements the ambient light like this.

Thanks,

Jing


Post a reply to this message

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