POV-Ray : Newsgroups : povray.off-topic : ANN: New, open-source, free software rendering system for physically correc= : Re: ANN: New, open-source, free software rendering system for physically co= Server Time
11 Oct 2024 19:15:41 EDT (-0400)
  Re: ANN: New, open-source, free software rendering system for physically co=  
From: Warp
Date: 28 Oct 2007 17:56:54
Message: <472513b5@news.povray.org>
Vincent Le Chevalier <gal### [at] libertyallsurfspamfr> wrote:
> color = 0
> for ray=1 to 1000
> r = random number between 0 and 1
> a = specular_amount
> b = specular_amount+diffuse_amount
> c = specular_amount+diffuse_amount+refraction_amount

> if 0 < r < a
>   color += reflection_color * fire_reflection_ray

> if a < r < b
>   color += diffuse_color * fire_diffuse_ray_in_random_direction

> if b < r < c
>   color += refraction_color * fire_refraction_ray

> if c<r<1.0 //absorption
>   color += 0

> //Of course you could have emitting surfaces as well
> if emission
>   color += emitted_color

> next

> pixel_color = color / 1000

  As far as I can see this has still the problem that light reflected
from the surface of the object by specular reflection is not *added*
to the rest of the light emitted by the object (by diffuse reflection
and/or refraction), but instead it's *averaged* with the rest.

  This will effectively make the reflection dimmer and the surface
possibly more opaque (if it was defined to be semitransparent) than
originally defined.

  The problem is that using this formula to render an object will most
probably result in a very different result than the regular way it's done
now. And this different result might not be better or more realistic.
While it could still be feasible, I'm not completely convinced the end
result will be "correct".
  (Besides, the basic idea I had was that you could optionally switch to
this alternative rendering method and get basically the same image in
average coloration, give or take some graininess. However, as presented
above, it will most probably not give the same image.)

  Basically what POV-Ray uses is the phong lighting model. While it's not
a 100% physically accurate lighting model, it's often close enough to
reality that quite realistic images can be created using it.

  In the phong lighting model the diffuse and specular reflection components
are added. While in real life a pure addition doesn't probably ever happen,
but more of a weighted average (the weighting factors depending on angles
of incidence, etc), it's not far off with many materials which is why this
simple lighting model often gives good-enough results.

  The algorithm presented above calculates the non-weighted average of
the diffuse and specular components. This means that, for example, a
black object cannot have a completely white highlight (because the averaging
will make it gray), even though in real life it's perfectly possible for
this to happen.

  Another problematic case I can see is an object which has been defined
to have a completely clear surface pigment, a strong reflection and
refraction. The algorithm given above will make the surface visibly look
only semi-transparent instead of completely clear. This is because the
reflection is not added to the refraction, but instead averaged with it.

  Once again, the simple phong lighting model might not be 100% accurate
in this case, but it's close nevertheless. Reflected and refracted light
is indeed added in reality, not averaged. A light ray cannot make another
light ray dimmer, it can only make it brighter. Averaging would mean that
eg. a refracted ray can make a reflected ray dimmer, which I think is not
physically correct.

  The following definitions are a bit problematic:

> a = specular_amount
> b = specular_amount+diffuse_amount
> c = specular_amount+diffuse_amount+refraction_amount

  If a texture has been defined to have "reflection 1" and "transmit 1"
(which I suppose would be 100% refraction_amount) and a standard diffuse
finish value of 0.6, what would be the values of a, b and c?

  If you want to make a+b+c = 1, then you would have to actually lower
those values. You would have to make reflection be about 0.38, transmit
be about 0.38 and diffuse be about 0.23. Effecively you are making the
object less transparent, less reflective and less diffuse, which is not
how the original texture was defined.

> The algorithm should check that c<1, obviously, otherwise the surface 
> transmits more light than it receives.

  A surface can receive light from more than one source, and the lighting
is added. Most obviously, the lighting at a certain point may be the caused
by reflection *and* refraction. This means that two different rays of light
from different sources are arriving at the same point on the surface of
the object, and from there to the same point in the projection plane.

  Thus, obviously, the lighting of the surface at that point can be brighter
than if it was illuminated by only one of the original sources.

  A surface is not emitting more light than it receices simply because it's
emitting more light than *one* light source can emit.

> The real problem with that approach, that you should have pointed out, 
> is that the lights are missed most of the time if you don't fire rays to 
> them specifically. If all your lights are point lights, they will always 
> be missed.

  This is not a problem because light rays can be shot towards point light
sources (and area light sources as well).

> The other problem is deciding when you stop firing rays. If many 
> surfaces have no absorption, it's possible to end up with very long 
> paths...

  That's what max_trace_level is for.

-- 
                                                          - Warp


Post a reply to this message

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