|
|
> However, I don't want to read lengthy books filled with material and
> lighting theory just to try this. If someone could write me a simple
> algorithm then I could try it.
>
Well Scott did, and it's not all that difficult to perfect it to obtain
the result you seek, i.e. to have different colors for diffusion and
reflection.
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
The algorithm should check that c<1, obviously, otherwise the surface
transmits more light than it receives.
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.
With very simple BRDF such as these (specular + diffuse), you would only
have to fire shadow rays in the diffuse case above. And possibly sample
all visible emitting surfaces. I don't remember the details...
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... I think one of the books uses a form of Russian roulette to
stop ray spawning and still keep an unbiased picture.
--
Vincent
Post a reply to this message
|
|