POV-Ray : Newsgroups : povray.programming : Ambient lighting in POV-Ray Server Time
22 Dec 2024 07:07:04 EST (-0500)
  Ambient lighting in POV-Ray (Message 1 to 5 of 5)  
From: Jing Li
Subject: Ambient lighting in POV-Ray
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

From: Thorsten Froehlich
Subject: Re: Ambient lighting in POV-Ray
Date: 6 Dec 2005 10:45:59
Message: <4395b237$1@news.povray.org>
Jing Li wrote:
> I am studying the implementation of the Ambient lighting in POV-Ray.

The implementation is a lot better "studied" by reading a textbook than then 
the optimised POV-Ray implementation.

> 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).

Please be advised that the variable names in formulas, including those for 
the ambient term, vary from author to author.  No need to go into this 
detail here, you can safely assume we know what the ambient term is :-)

> 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.

This explanation is not good at all.  I am not even sure it aims to explain 
what you think it does at all.  I would strongly recommend you go with one 
of the books cited in the documentation, see 
<http://www.povray.org/documentation/view/3.6.1/211/>, in particular with 
(1) and (8).

> 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.

No need to rephrase the source code, it just makes your posts harder to read 
to find your real problem :-)

> POV-Ray's help document explains

Please note that the documentation is not the appropriate source for 
information about the algorithms used inside POV-Ray, it is written for 
users, not implementors.  As such, deriving formulas from information in the 
documentation will not get you where you want!

> 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.

I think you are misunderstanding the documentation here.  You interpretation 
"basic color of the object, not the color the object looks like" does not 
make sense.  The pigment provides _the_ object's surface color, without it 
the object is black.

I get the impression you are not understanding the difference between 
shading and color.  The common shading functions compute the lighting at a 
specific surface location, they do not compute the color!  As such, you will 
not find the color in the common descriptions of shading functions (though 
extending them is easy).

To get a color, a lot more has to be taken into consideration. There is the 
surface color, the color of the reflection and the color of the refraction. 
  And then you have your shading function, which, in more elaborate models, 
the light sources which may have a color as well.  Essentially the final 
color is the addition of the weighted colors, as appropriate multiplied by 
the result of the shading function result.

And, to repeat myself, the POV-Ray source code is the wrong place to try to 
learn about this.  Books provide a much better structured, step-by-step 
description.

> 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.

 From your somewhat confusing explanation so far it looks like you did not 
specify a pigment.  Without it, your object will be black.

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

Your confusion is not about POV-Ray, it is due to you looking at the wrong 
place for explanations.  Please read, and make sure you understand, a 
textbook on the subject first!  Then the POV-Ray source code will be clear(er).

	Thorsten Froehlich, POV-Team


Post a reply to this message

From: Jing Li
Subject: Re: Ambient lighting in POV-Ray
Date: 6 Dec 2005 16:25:01
Message: <web.4396009ddac0172de49f817c0@news.povray.org>
First thanks for you pointing out my mistakes.  I have read Foley's book
"Computer Graphics Principles and Practice" and Hill's book "Computer
Graphics using OpenGL" and will borrow the book  "An Introduction to Ray
tracing" from our library and read it.

The POV scene I used to test is
===================================================
global_settings { max_trace_level 5 }
global_settings { ambient_light rgb<0.3, 0.3, 0.3> }

background { color red 0 green 0 blue 0 }
camera
{
location <0, 0.0, -6>
angle 45.0
look_at <0, 0.0, 0>
}
sphere
{ <0, 0, 0>, 1
pigment{rgbf <0, 0.0, 0.0>} // black
finish { ambient rgb<0.6, 0.6, 0.6> }
}
===================================================

I did define the pigment for the object, just define it black rather than
other color on purpose. What my understanding through reading Foley's book
and Hill's book is that the ambient light should contribute to the final
color of the ray even though the diffuse color of the object hit by the ray
is black.

Please correct me.

Thanks,

Jing


Post a reply to this message

From: Y Tanabe
Subject: Re: Ambient lighting in POV-Ray
Date: 7 Dec 2005 05:09:06
Message: <4397334D.D595DFD2@kh.rim.or.jp>
Dear Jing Li San

I can not explan about your question.
But your POV-Ray SDL is not correct,I think.

>background { color red 0 green 0 blue 0 }
+background { color red 1 green 1 blue 1 }

>pigment{rgbf <0, 0.0, 0.0>} // black
+pigment{rgbf <0,0,0,0>} // black & filtering
or
+pigment{rgb <0,0,0>} // black & no filtering

And no light_source{} statement.

Of cource,I know Mega POV-Ray0.7 Source well and compiling by Apple MPW MrC,
then lighting.c or lighting.cpp are very difficult to understand.
For me,I can not set optimize for compiler to lighting.c,
if I do optimize,then light of orient do not works well.

I am sorry by my poor English.

Y.Tanabe
Kobe,Japan




Jing Li wrote:

> First thanks for you pointing out my mistakes.  I have read Foley's book
> "Computer Graphics Principles and Practice" and Hill's book "Computer
> Graphics using OpenGL" and will borrow the book  "An Introduction to Ray
> tracing" from our library and read it.
>
> The POV scene I used to test is
> ===================================================
> global_settings { max_trace_level 5 }
> global_settings { ambient_light rgb<0.3, 0.3, 0.3> }
>
> background { color red 0 green 0 blue 0 }
> camera
> {
> location <0, 0.0, -6>
> angle 45.0
> look_at <0, 0.0, 0>
> }
> sphere
> { <0, 0, 0>, 1
> pigment{rgbf <0, 0.0, 0.0>} // black
> finish { ambient rgb<0.6, 0.6, 0.6> }
> }
> ===================================================
>
> I did define the pigment for the object, just define it black rather than
> other color on purpose. What my understanding through reading Foley's book
> and Hill's book is that the ambient light should contribute to the final
> color of the ray even though the diffuse color of the object hit by the ray
> is black.
>
> Please correct me.
>
> Thanks,
>
> Jing


Post a reply to this message

From: Le Forgeron
Subject: Re: Ambient lighting in POV-Ray
Date: 7 Dec 2005 10:31:38
Message: <4397005a$1@news.povray.org>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Jing Li wrote:

> I did define the pigment for the object, just define it black rather than
> other color on purpose. What my understanding through reading Foley's book
> and Hill's book is that the ambient light should contribute to the final
> color of the ray even though the diffuse color of the object hit by the ray
> is black.
> 
> Please correct me.

Pov-ray ambient light use a shortcut: ambient light is everywhere, and
resulting color for the ray of light which hit/come from a surface is
independant of any angle. This is not true for the Diffuse part of the
same ray.
Now, despite being under light, black is black; in particular, ambient
black is not shiny or anything else, it's just black. Deep, and black.
Shinyness/glossiness/whatever is a coloring-model which need some
variations according some angles, so it's not possible with ambient.

The ambient global setting is the default light source spectrum.
The ambient in the finish setting is the light source spectrum to use
for that texture instead of the default one.
The resulting "ambient" light/color is as every reflected light/color:
the product of the spectrum of the incoming ray (here, the "ambient"
light source, everywhere) by the spectrum of the reflecting surface.

Your full 0.6 gets absorbed by the deep 0 black. So, it's not because it
is 0 that it does not contribute... you just do not see it.
Use a less deep black, and you might see more of its contribution.


- --
Eifersucht ist die Leidenschaft, die mit Eifer sucht, was Leiden schafft.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFDlwBZs/YJ43cSjHIRAtgIAJ4/kh/gyVADMNd9B2bHK6VeaP8skACffx37
mmd1ab7Ry5oVJ9o2H723aSs=
=uQun
-----END PGP SIGNATURE-----


Post a reply to this message

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