#ifndef rdo_lighting_H #define rdo_lighting_H /* Tools for light and shading computations. */ #define rdo_lighting_H_COPYRIGHT "Copyright © 2008 Danillo Pereira and J. Stolfi, UNICAMP" /* Last edited on 2024-12-21 11:52:09 by stolfi */ #include #include #include #include #include #include #include #include finish_t *rdo_lighting_get_site_finish(site_t *st, solid_vec_t *sds, finish_vec_t *fns); /* Returns the address of the finish {fns->e[i]} associated to the solid object in the list {sds} on whose surface the site {st} lies. If {s} lies on no object, returns NULL. Uses the {.isd} field of {st} to identify the solid, and the {.ifn} field of the solid to identify its finish. */ dspmat_t rdo_lighting_compute_site_transfer_matrix ( solid_vec_t *sds, site_t so[], double ao[], int no, site_t sd[], int nd ); /* Computes the matrix {T} that expresses the transfer of radiance from the sites {so[0..no-1]} to the sites {sd[0..nd-1]}, assuming that the former have areas {ao[0..no-1]} and the latter are Lambertian diffusers with albedo 1.0. Element {T[i,j]} of this matrix tells the radiance at sampling site {i} produced by photons that were emitted by a disk of unit area and radiance 1.0 at site {so[j]}, and suffered a single Lambertian scattering event at {sd[i]}. Accounts for the visibility between the two points, the orientations of the two surface patches, the area of the source patch, and the distance between the patches. */ void rdo_lighting_apply_diffusion_coeffs_to_matrix ( dspmat_t *S, site_vec_t *smp, solid_vec_t *sds, finish_vec_t *fns, int channel ); /* Assumes that the matrix {S} has one row for each sampling site {smp->e[0..smp->ne-1]}. Multiplies each row {i} of {S} by the Lambertian diffusion coefficient of the surface at site {sts->e[i]}, for color band {channel}. The albedo is obtained from the solid object list {sds} and the finish list {fns}. */ double rdo_lighting_compute_radiance_coeff_between_sites ( solid_vec_t *sds, point3_t *pO, vector3_t *nO, point3_t *pD, vector3_t *nD ); /* Computes the radiance of the surface near a point {pD} with normal {nD}, when the only source of light is a surface patch of unit area and unit radiance at {pO}, with normal {nO}. Assumes that the surface at {pD} is Lambertian with diffusion coefficient 1.0, and consider only photons that suffered exactly one scattering event (at {pD}) before being recorded by the eye. */ /* OBTAINING SITE RADIANCES */ double rdo_lighting_compute_site_radiance_quadrants(site_t *st, solid_t *sd, int channel); /* Computes a radiance function that depends only on the site {st} and the solid object {sd} where it sits on. */ /* OBTAINING SITE LIST RADIANCES */ void rdo_lighting_get_site_vec_diffusion_coeffs ( site_vec_t *sts, solid_vec_t *sds, finish_vec_t *fns, int channel, double B[], int nB ); /* Fills the vector {B[0..nB]} with the diffusion coeffs of sites {sts->e[0..nB-1]}, obtained from the finish list {fns} by way of the solid object list {sds} (see {}). Requires {sts->ne == nB}. */ void rdo_lighting_get_site_vec_emission_coeffs ( site_vec_t *sts, solid_vec_t *sds, finish_vec_t *fns, int channel, double B[], int nB ); /* Sets {B[0..nB-1]} to the emission coefficients of the sampling sites {smp->e[0..smp->ne-1]}, which are assumed to reside on the solid objects {sds->e[0..sds->ne-1]} which have the finishes {fns->e[0..fns-ne-1]}. Requires {nB == smp->ne}. */ void rdo_lighting_compute_site_vec_radiances_quadrants ( site_vec_t *sts, solid_vec_t *sds, int channel, double B[], int nB ); /* Fills the vector {B[0..nB]} with radiances of sites {sts->e[0..nB-1]}, computed with {rdo_lighting_plain_compute_site_radiance_quadrants}. Requires {sts->ne == nB}. */ #endif