​Hi,

The basic idea with what I gave is to compute the simplest light transport
paths from the light to the eye. Specifically, we want all paths that start
at the light, pass through some number of surfaces, scatter off another
surface, pass through some number of surfaces, and then hit the eye.

I've added some comments to my pseudocode, which I've also edited a bit.

#Start with no light
result = 0
for S in surfaces:
    #On this loop iteration, we will consider the
    #    light path that starts at the light, travels
    #    to S, bounces off, and travels to the eye.

    #Figure out the amount of light that gets from
    #    the light to the surface.
    product_of_alphas_between_light_and_S = 1.0
    for T in surfaces:
        if T is between S and the light:
            #Attenuate light by T's transmissivity
            #    (alpha in range [0.0,1.0]).
            product_of_alphas_between_light_and_S *= T.alpha
    #"product_of_alphas_between_light_and_S" should
    #    now be a number between 0.0 and 1.0.  It
    #    represents the attenuation of the light
    #    as it travels to S.

    #This tell you how much light gets to S.  The
    #    "intensity" scales how "strong" the light is.
    #    Technically, it's radiance, not intensity.
    light_at_surface = light_intensity *
product_of_alphas_between_light_and_S

    #Some of the light will be absorbed or transmitted
    #    through S.  The amount that is scattered back
    #    in a particular direction is called the BSDF.
    #    The BSDF I'm using here is diffuse, which is a
    #    constant factor (surface reflectance).  Because
    #    energy is conserved, this factor cannot be
    #    negative or larger than 1.0.
    #Ultimately, this tells how much light leaves the
    #    S heading toward the eye.
    reflected_light = light_at_surface * surface_reflectance

    #Same idea as above.  Here we're attenuating the
    #    reflected light as it travels from S to the eye.
    product_of_surface_alphas_between_S_and_eye = 1.0
    for T in surfaces:
        if T is between S and the eye:
            product_of_surface_alphas_between_S_and_eye *= T.alpha

    #This is the amount of light that finally reaches
    #    the eye.
    light_at_eye = reflected_light *
product_of_surface_alphas_between_S_and_eye

    #Accumulate it.  The sum of all paths (in all the
    #    loop iterations) is the first order light
    #    transport between the light and the eye.
    result += light_at_eye

HTH,
Ian

Reply via email to