POV-Ray : Newsgroups : povray.general : Actual Specular calculations? Server Time
17 Nov 2024 05:15:11 EST (-0500)
  Actual Specular calculations? (Message 1 to 9 of 9)  
From: Tim Nikias v2 0
Subject: Actual Specular calculations?
Date: 11 Jun 2003 12:10:44
Message: <3ee75484@news.povray.org>
I've looked around in the docs, but can't find any
reference to the actual formulae used to derive
the specular effect when using the specular-finish
along with roughness, so perhaps someone might
jump in and explain it to me?

What I'm trying to do (in order to clear up what exactly
I want to know):
Shoot a ray at an object, and from that point shoot
rays to the different light-sources to check for specular
highlights from them (just the way a raytracer does). Now
I know that at certain angles, the highlight is generated,
but I'd like to know the exact angles etc for my pixel-
post-processing script. I don't want to simulate the
raytracing process with that script, but to gather information
on where highlights are occuring, in order to bleed the
bright light across the objects boundaries, just like it
happens in the human eye (or probably any eye, for
that matter).

-- 
Tim Nikias v2.0
Homepage: http://www.digitaltwilight.de/no_lights
Email: Tim### [at] gmxde


Post a reply to this message

From: ABX
Subject: Re: Actual Specular calculations?
Date: 11 Jun 2003 12:19:07
Message: <udleevo2isdltcnh931uhfpeljfucton1b@4ax.com>
On Wed, 11 Jun 2003 18:09:13 +0200, "Tim Nikias v2.0" <tim### [at] gmxde> wrote:
> someone might jump in and explain it to me?

I suggest you do go to the sources, open lighting.cpp and find function
do_specular(). Its header contains formula. It is not that I'm lazy not copying
it here but I imagine you will have further questions so following my advise
will save you time.

ABX


Post a reply to this message

From: Tim Nikias v2 0
Subject: Re: Actual Specular calculations?
Date: 11 Jun 2003 12:34:20
Message: <3ee75a0c@news.povray.org>
Ah, thanks. I wouldn't know where to
look for that, so your advice is greatly
appreciated.

Regards,
Tim

-- 
Tim Nikias v2.0
Homepage: http://www.digitaltwilight.de/no_lights
Email: Tim### [at] gmxde


>
> I suggest you do go to the sources, open lighting.cpp and find function
> do_specular(). Its header contains formula. It is not that I'm lazy not
copying
> it here but I imagine you will have further questions so following my
advise
> will save you time.
>
> ABX


Post a reply to this message

From: Christopher James Huff
Subject: Re: Actual Specular calculations?
Date: 11 Jun 2003 17:06:05
Message: <cjameshuff-118730.15574211062003@netplex.aussie.org>
In article <3ee75484@news.povray.org>,
 "Tim Nikias v2.0" <tim### [at] gmxde> wrote:

> I've looked around in the docs, but can't find any
> reference to the actual formulae used to derive
> the specular effect when using the specular-finish
> along with roughness, so perhaps someone might
> jump in and explain it to me?

This is documented in the function do_specular() in lighting.cpp.


> What I'm trying to do (in order to clear up what exactly
> I want to know):
> Shoot a ray at an object, and from that point shoot
> rays to the different light-sources to check for specular
> highlights from them (just the way a raytracer does). Now
> I know that at certain angles, the highlight is generated,
> but I'd like to know the exact angles etc for my pixel-
> post-processing script. I don't want to simulate the
> raytracing process with that script, but to gather information
> on where highlights are occuring, in order to bleed the
> bright light across the objects boundaries, just like it
> happens in the human eye (or probably any eye, for
> that matter).

Well, the highlight isn't a point, it practically covers every point on 
the object is not in shadow, and could have multiple relative maxima and 
non-point maxima. For example, the points of maximum intensity on a 
torus can be a ring. This approach is pretty much a dead-end.

In any case, this happens because of the brightness, not because of 
anything special to highlights. What you want sounds somewhat similar to 
the old MegaPOV glow post-process filter, which operated by combining a 
slightly blurred version of the image with the unblurred version. High 
brightness areas bleed more, giving them a glowing look. If you are 
trying to implement this in POV script instead of a patch, you will need 
to use the HDR patch to avoid clipping the values.

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tagpovrayorg
http://tag.povray.org/


Post a reply to this message

From: Tim Nikias v2 0
Subject: Re: Actual Specular calculations?
Date: 11 Jun 2003 18:36:03
Message: <3ee7aed3$1@news.povray.org>
It is similiar to what MegaPOV did, yes. What I want is to
limit the area of effect to the places where the actual
specular highlights appear (and I know that this depends
on viewing angle and lighting angle, which is why I asked
for that). So far, my tests have succeeded in "emulating"
specular highlights on a two-triangle-per-pixel base by
casting rays (via trace()) at the center where the actual
pixels would be, thus getting information on depth and
surface normals. Based on that, I calculate the specular
highlight the same way as POV-Ray does it internally
(thanks to you two), although I've simplified some values
to 1 for testing purposes.
So for now, I can have a simple image without specular
highlights, and yet post-process them onto the very
image, during the creation of the image.
If I'd go into insane detail and emulate the entire
rendering process of POV-Ray, I could even implement
my own means of blurred reflections (with a nice
distribution of samples as said in some other thread),
but I don't want to do that (unless I've got too much time :-).

Its fairly interesting what could be possible, though so far
I haven't found much which can't be done with some
paint program (doh!) or even with POV itself... But I desperately
wanted that bleeding/blinding effect of sparkling and bright objects,
so I attacked the code and went on! :-)

-- 
Tim Nikias v2.0
Homepage: http://www.digitaltwilight.de/no_lights
Email: Tim### [at] gmxde

>
> > I've looked around in the docs, but can't find any
> > reference to the actual formulae used to derive
> > the specular effect when using the specular-finish
> > along with roughness, so perhaps someone might
> > jump in and explain it to me?
>
> This is documented in the function do_specular() in lighting.cpp.
>
>
> > What I'm trying to do (in order to clear up what exactly
> > I want to know):
> > Shoot a ray at an object, and from that point shoot
> > rays to the different light-sources to check for specular
> > highlights from them (just the way a raytracer does). Now
> > I know that at certain angles, the highlight is generated,
> > but I'd like to know the exact angles etc for my pixel-
> > post-processing script. I don't want to simulate the
> > raytracing process with that script, but to gather information
> > on where highlights are occuring, in order to bleed the
> > bright light across the objects boundaries, just like it
> > happens in the human eye (or probably any eye, for
> > that matter).
>
> Well, the highlight isn't a point, it practically covers every point on
> the object is not in shadow, and could have multiple relative maxima and
> non-point maxima. For example, the points of maximum intensity on a
> torus can be a ring. This approach is pretty much a dead-end.
>
> In any case, this happens because of the brightness, not because of
> anything special to highlights. What you want sounds somewhat similar to
> the old MegaPOV glow post-process filter, which operated by combining a
> slightly blurred version of the image with the unblurred version. High
> brightness areas bleed more, giving them a glowing look. If you are
> trying to implement this in POV script instead of a patch, you will need
> to use the HDR patch to avoid clipping the values.
>
> -- 
> Christopher James Huff <cja### [at] earthlinknet>
> http://home.earthlink.net/~cjameshuff/
> POV-Ray TAG: chr### [at] tagpovrayorg
> http://tag.povray.org/


Post a reply to this message

From: Peter Popov
Subject: Re: Actual Specular calculations?
Date: 12 Jun 2003 06:16:10
Message: <mikgev4ebrvk3tktdbg5i77bj86mpksehi@4ax.com>
On Wed, 11 Jun 2003 18:09:13 +0200, "Tim Nikias v2.0"
<tim### [at] gmxde> wrote:

>in order to bleed the
>bright light across the objects boundaries, just like it
>happens in the human eye (or probably any eye, for
>that matter).

Do you want the bleed to actually extend *beyond* the object
boundaries? If not, why don't you use two highlights? For example, I
often use something like this:

finish {
	specular 0.5 roughness 0.0025
	phong 0.25 phong_size 7.5
}

Or you could layer or average textures, one with fully metallic, soft
highlight and the other one with a tight, more plasticy-looking
highlight.


Peter Popov ICQ : 15002700
Personal e-mail : pet### [at] vipbg
TAG      e-mail : pet### [at] tagpovrayorg


Post a reply to this message

From: Tim Nikias v2 0
Subject: Re: Actual Specular calculations?
Date: 12 Jun 2003 06:17:56
Message: <3ee85354$1@news.povray.org>
The first thing you mentioned is what I'm after. I want
to have the highlight "bleed" beyond the objects boundaries.
Thanks anyway!

-- 
Tim Nikias v2.0
Homepage: http://www.digitaltwilight.de/no_lights
Email: Tim### [at] gmxde

>
> >in order to bleed the
> >bright light across the objects boundaries, just like it
> >happens in the human eye (or probably any eye, for
> >that matter).
>
> Do you want the bleed to actually extend *beyond* the object
> boundaries? If not, why don't you use two highlights? For example, I
> often use something like this:
>
> finish {
> specular 0.5 roughness 0.0025
> phong 0.25 phong_size 7.5
> }
>
> Or you could layer or average textures, one with fully metallic, soft
> highlight and the other one with a tight, more plasticy-looking
> highlight.
>
>
> Peter Popov ICQ : 15002700
> Personal e-mail : pet### [at] vipbg
> TAG      e-mail : pet### [at] tagpovrayorg


Post a reply to this message

From: Christopher James Huff
Subject: Re: Actual Specular calculations?
Date: 12 Jun 2003 11:55:20
Message: <cjameshuff-634DE0.10465412062003@netplex.aussie.org>
In article <3ee7aed3$1@news.povray.org>,
 "Tim Nikias v2.0" <tim### [at] gmxde> wrote:

> It is similiar to what MegaPOV did, yes. What I want is to
> limit the area of effect to the places where the actual
> specular highlights appear (and I know that this depends
> on viewing angle and lighting angle, which is why I asked
> for that).

If that is the case, then it is nothing like the MegaPOV patch. 
Highlights are a surface reflection effect, and have nothing to do with 
the eye viewing them. What you describe sounds like post-process 
highlights, which sounds perfectly useless.


> So for now, I can have a simple image without specular
> highlights, and yet post-process them onto the very
> image, during the creation of the image.

But why? What else does it do?


> Its fairly interesting what could be possible, though so far
> I haven't found much which can't be done with some
> paint program (doh!) or even with POV itself... But I desperately
> wanted that bleeding/blinding effect of sparkling and bright objects,
> so I attacked the code and went on! :-)

Well, that does not depend on any highlight method, or even the 
existance of highlights. The blurring method is the most obvious way of 
doing it, and is actually a fairly accurate approximation of what really 
happens in the eye. You wanted one thing, so you attacked the code and 
did something completely different?

BTW, you're using a flat mesh to render the image? Have you tried 
writing to an ASCII image format or using boxes instead? Maybe using 
banded gradient pigments to cut down on the number of primitives 
required? You should be able to get 128 "pixels" per primitive that way, 
more if you use fancier pigment maps. (16384 for 128 gradient pigments 
nested in another gradient pigment_map)

The automatic bounding heirarchy is not specialized for this kind of 
thing, you may get a speedup by building your own heirarchy. Have a 
union of unions of unions until you get to unions of a few boxes each. 
Maybe do it with scanlines, and use the nested pigment trick to do each 
scanline as a single box.

If you don't have any programs that will read ASCII PPM, write it anyway 
and use it as an image_map on a box.

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tagpovrayorg
http://tag.povray.org/


Post a reply to this message

From: Tim Nikias v2 0
Subject: Re: Actual Specular calculations?
Date: 13 Jun 2003 08:29:58
Message: <3ee9c3c6@news.povray.org>
> If that is the case, then it is nothing like the MegaPOV patch.
> Highlights are a surface reflection effect, and have nothing to do with
> the eye viewing them. What you describe sounds like post-process
> highlights, which sounds perfectly useless.

You might have misunderstood what I'm attempting.

The eye, as we all know, is lightsensitive. Now, what happens
when you look at a mirror which reflects the sun? The glaring
light won't stay just "on top" of the mirror, which is what happens
with POV-Rays specular highlight, it can only be generated on
the surface itself.
This glaring effect is what I want.
In MegaPOV, it took the rgb values and used their intensity
in order to determine how much "glow" might be added. Problem
with this is, a specular highlight might have rgb <1,1,1>, and a
white paper might have rgb <1,1,1> too. They'd be treated the
same.
What I want is to limit this "glow" to just the specular highlights,
and avoid the overall softening of the image as was (is?) the case
with MegaPOVs post-process glowing. (Haven't used the latest
version, so that might have changed).

So, for now, its just post-process highlights, but I want to
increase their effect across the borders of the objects themselves.

To return to the eye-example: there are certain lightsensitive cells
in your eye (I'm not too firm on the english words for that), which,
when reacting strongly, might get their neighbours to act as well.
Thus, a blinding pointlight might be seen as a large white "wall" of
light.

> Well, that does not depend on any highlight method, or even the
> existance of highlights. The blurring method is the most obvious way of
> doing it, and is actually a fairly accurate approximation of what really
> happens in the eye. You wanted one thing, so you attacked the code and
> did something completely different?

As mentioned above, I wanted to limit the effect to the specular
highlights, so that the effect would only occur where light is really
reflected, not just shining on a white object.

As for the objects: I'm using two triangles per pixel, because of
the possibility that the camera might be angled or such. Although...
The boxes per pixel might be skewed with a matrix... Hm. Well,
it's just been a quick approach. Haven't got the time to fumble
with it, and it doesn't seem to actually have THAT much use... I
do crazy stuff, but when its completely unnecessary...

Thanks for your suggestions though!

-- 
Tim Nikias v2.0
Homepage: http://www.digitaltwilight.de/no_lights
Email: Tim### [at] gmxde


Post a reply to this message

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