1. A method comprising:
- receiving a request to generate a color value of a point P with surface normal N; and
- computing the color value for the point P using an importance sampling estimator for a reflected radiance integral, where the importance sampling estimator selects a plurality of ray samples for evaluation of the reflected radiance integral at the point P to generate the color value, where ray sample directions are chosen according to information obtained from at least a light source term and a bi-directional reflectance distribution function (BRDF) term of the reflected radiance integral.
2. The method of claim 1, wherein computing the color value comprises:
- generating an importance function for an integrand of the reflected radiance integral; and
- selecting a plurality of ray samples on a unit hemisphere surrounding the point P with surface normal N according to the importance function.
3. The method of claim 1, wherein the importance sampling estimator selects the plurality of ray samples and ray sample directions according to information obtained from the based on a visibility term, the BRDF term and the light source term of the reflected radiance integral.
4. The method of claim 2, wherein the importance function approximates a product of the light source term and the BRDF term of the integrand of the reflected radiance integral.
5. The method of claim 2, wherein the importance function approximates a product of the light source term, the BRDF term, and the visibility term of the integrand of the reflected radiance integral.
6. The method of claim 2, wherein generating the importance function comprises:
- partitioning a unit hemisphere surrounding the point P into M non-overlapping regions;
- approximating a value of the integrand of the reflected radiance integral as a piece-wise constant function that is constant over each of the M non-overlapping regions; and
- using this piece-wise constant approximated value as the importance function.
7. The method of claim 2, wherein selecting ray samples comprises:
- partitioning a hemisphere about the surface normal N into M non-overlapping regions;
- computing a normalized weight of each non-overlapping region; and
- mapping points from a unit square into a unit hemisphere according to the normalized weight of the non-overlapping regions.
8. The method of claim 7, wherein mapping further comprises:
- dividing an interval into a plurality of sub-intervals according to the non-overlapping regions such that a length of each respective sub-interval is equal to a normalized weight of the non-overlapping region used to form the sub-interval;
- selecting a random point X,Y from a unit square;
- determining a sub-interval containing the X-component of the selected point;
- mapping the point to the unit square according to a length of the sub-interval; and
- mapping the point from the unit square to a non-overlapping region corresponding to the determined sub-interval.
9. The method of claim 8, wherein mapping to the unit square comprises:
- normalizing a position of the point within the determined sub-interval; and
- mapping the normalized position of the point within the unit square.
10. The method of claim 2, wherein selecting ray samples comprises:
- tessellating an environment map sphere into M non-overlapping spherical triangles;
- forming a hemisphere from the tessellated sphere about the surface normal N for the point P;
- generating a visible triangle list of the non-overlapping spherical triangles on the hemisphere;
- computing a normalized weight of each visible spherical triangle; and
- mapping points from a unit square onto triangles of the hemisphere according to a respective normalized weight of the triangles, such that the mapped points on the hemisphere are used as the selected ray samples.
11. The method of claim 10, wherein tessellating the environment map sphere further comprises:
- determining one or more triangles within the tessellated sphere having a variance above a predetermined value;
- tessellating the one or more identified triangles into non-overlapping triangles; and
- repeating the identifying and tessellating until a predetermined number of spherical triangles are formed.
12. The method of claim 8, wherein generating the visible triangle list further comprises:
- determining, for each spherical triangle, whether the triangle is contained within the hemisphere;
- placing each triangle within the hemisphere in the visible triangle list;
- subdividing triangles determined as partially included in the hemisphere into one or more triangles contained in the hemisphere;
- adjusting a weight of each of the subdivided triangles; and
- adding the subdivided triangles into the visible triangle list.
13. The method of claim 2, wherein prior to receiving the request, the method further comprises:
- tessellating a spherical environment map into M non-overlapping spherical triangles;
- calculating a convolution of each spherical triangle against a surface BRDF; and
- storing each calculated convolution in a map.
14. The method of claim 13, wherein calculating the convolution comprises:
- selecting a spherical triangle;
- selecting a direction to be used as a free parameter of the BRDF term;
- selecting a direction that is subtended by the selected spherical triangle;
- computing a product of a value of the BRDF term for the selected free parameter direction times a value of the environment map in the selected direction from the spherical triangle;
- adding the product to a sum;
- repeating selecting of the free parameter direction and computing of the product for each direction subtended by the selected spherical triangle; and
- repeating selecting the spherical triangle, selecting of the free parameter and computing of the diffuse convolution for each of the M spherical triangles.
15. The method of claim 1, wherein computing the color value comprises:
- selecting a ray sample according to an importance function;
- selecting an environment color from an environment map according to the ray sample;
- determining a visibility value according to the selected ray sample;
- calculating the BRDF term according to the selected ray sample, a surface normal and an eye ray to a virtual camera;
- calculating an intermediate color value according to the environment color, visibility value and BRDF value, divided by a value of the importance function according to the ray sample;
- adding the intermediate color value to a sum; and
- repeating selecting of the ray sample, selecting of the environment color, determining of the visibility term, determining of the BRDF term and calculating of the intermediate color value for each ray sample such that a final value of the sum represents a color value for the point P with surface normal N.
16. The method of claim 10, wherein computing a normalized weight of each visible spherical triangle comprises:
- selecting a spherical triangle;
- looking up a color value in a convolved map generated for the selected triangle at a pixel location determined by the surface normal N and the eye ray;
- calculating a weight of the selected triangle as an intensity of the color value;
- adding the weight of the selected triangle to a sum;
- repeating the looking up of the color value, calculating the triangle weight and adding the triangle weight for each triangle; and
- dividing each triangle's weight by the sum of the weights of all of the triangles.
17. The method of claim 16, wherein calculating the weight of the selected triangle by the sum of the weight for each triangle further comprises:
- estimating a value of the visibility term over the selected triangle; and
- scaling the weight selected by the estimated value.
18. The method of claim 17, wherein estimating the value of the visibility term comprises:
- querying a visibility data structure for visibility values of one or more points proximate the point P;
- computing a blend of the one or more visibility values; and
- computing a visibility value for the point P according to the blend of the proximate visibility points.
19. The method of claim 1, wherein prior to receiving the request, the method further comprises:
- selecting a scene;
- casting a predetermined number of rays for each surface point of the scene; and
- determining a count of a number of rays in a given direction indicated as occluded/unoccluded;
- forming a low resolution image according to the count; and
- storing the low resolution image within a data structure.
20. The method of claim 15, wherein calculating the intermediate color value comprises:
- computing a product of the BRDF term, the visibility term and the color term;
- identifying a region associated with the ray sample;
- computing an inverse probability value of the region associated with the ray sample; and
- computing the initial color value as the computed product divided by the inverse probability value.
21. The method of claim 2, wherein generating the importance function comprises:
- computing, for each pixel within an environment map, a product of a BRDF term, evaluated in a direction corresponding to the pixel, times an environment map term evaluated in the direction corresponding to the pixel.
22. The method of claim 2, wherein selecting ray samples comprises:
- subdividing a unit interval into several regions, where a length of each region is equal to a value of an integrand approximation for a pixel times an area subtended by the pixel, divided by a sum of the integrand approximation times an area subtended by each pixel over all pixels;
- choosing a point from a unit square;
- normalizing a position of the selected point within its subdivided region; and
- selecting a ray sample according to a direction of the pixel.
23. The method of claim 2, wherein selecting ray samples, the method further comprises:
- selecting a pixel with probability determined by a value of the integrand approximation multiplied by an area of the pixel;
- choosing a random point within the pixel;
- mapping the point within the pixel to a sphere such that the map point represents a ray sample; and
- repeating the choosing of a pixel, choosing of a random point and mapping for each pixel of the environment map.
24. The method of claim 1, wherein the light source term of the reflected radiance integral comprises:
- a contribution function that depends only on direction, such that the point P is lit by an environment map.
25. An article of manufacture including a machine readable medium having stored thereon instructions which may be used to program a system to perform a method, comprising:
- receiving a request to generate a color value of a point P with surface normal N; and
- computing the color value for the point P using an importance sampling estimator for a reflected radiance integral, where the importance sampling estimator selects a plurality of ray samples for evaluation of the reflected radiance integral at the point P to generate the color value, where ray sample directions are chosen according to information obtained from at least a light source term and a bi-directional reflectance distribution function (BRDF) term of the reflected radiance integral.
26. The article of manufacture of claim 25, wherein computing the color value comprises:
- generating an importance function for an integrand of the reflected radiance integral; and
- selecting a plurality of ray samples on a unit hemisphere surrounding the point P with surface normal N according to the importance function.
27. The article of manufacture of claim 25, wherein the importance sampling estimator selects the plurality of ray samples and ray sample directions according to information obtained from the based on a visibility term, the BRDF term and the light source term of the reflected radiance integral.
28. The article of manufacture of claim 26, wherein the importance function approximates a product of the light source term and the BRDF term of the integrand of the reflected radiance integral.
29. The article of manufacture of claim 26, wherein the importance function approximates a product of the light source term, the BRDF term, and the visibility term of the integrand of the reflected radiance integral.
30. The article of manufacture of claim 26, wherein generating the importance function comprises:
- partitioning a unit hemisphere surrounding the point P into M non-overlapping regions;
- approximating a value of the integrand of the reflected radiance integral as a piece-wise constant function that is constant over each of the M non-overlapping regions; and
- using this piece-wise constant approximated value as the importance function.
31. The article of manufacture of claim 26, wherein selecting ray samples comprises:
- partitioning a hemisphere about the surface normal N into M non-overlapping regions;
- computing a normalized weight of each non-overlapping region; and
- mapping points from a unit square into a unit hemisphere according to the normalized weight of the non-overlapping regions.
32. The article of manufacture of claim 31, wherein mapping further comprises:
- dividing an interval into a plurality of sub-intervals according to the non-overlapping regions such that a length of each respective sub-interval is equal to a normalized weight of the non-overlapping region used to form the sub-interval;
- selecting a random point X,Y from a unit square;
- determining a sub-interval containing the X-component of the selected point;
- mapping the point to the unit square according to a length of the sub-interval; and
- mapping the point from the unit square to a non-overlapping region corresponding to the determined sub-interval.
33. The article of manufacture of claim 32, wherein mapping to the unit square comprises:
- normalizing a position of the point within the determined sub-interval; and
- mapping the normalized position of the point within the unit square.
34. The article of manufacture of claim 26, wherein selecting ray samples comprises:
- tessellating an environment map sphere into M non-overlapping spherical triangles;
- forming a hemisphere from the tessellated sphere about the surface normal N for the point P;
- generating a visible triangle list of the non-overlapping spherical triangles on the hemisphere;
- computing a normalized weight of each visible spherical triangle; and
- mapping points from a unit square onto triangles of the hemisphere according to a respective normalized weight of the triangles, such that the mapped points on the hemisphere are used as the selected ray samples.
35. The article of manufacture of claim 34, wherein tessellating the environment map sphere further comprises:
- determining one or more triangles within the tessellated sphere having a variance above a predetermined value;
- tessellating the one or more identified triangles into non-overlapping triangles; and
- repeating the identifying and tessellating until a predetermined number of spherical triangles are formed.
36. The article of manufacture of claim 34, wherein generating the visible triangle list further comprises:
- determining, for each spherical triangle, whether the triangle is contained within the hemisphere;
- placing each triangle within the hemisphere in the visible triangle list;
- subdividing triangles determined as partially included in the hemisphere into one or more triangles contained in the hemisphere;
- adjusting a weight of each of the subdivided triangles; and
- adding the subdivided triangles into the visible triangle list.
37. The article of manufacture of claim 26, wherein prior to receiving the request, the method further comprises:
- tessellating a spherical environment map into M non-overlapping spherical triangles;
- calculating a convolution of each spherical triangle against a surface BRDF; and
- storing each calculated convolution in a map.
38. The article of manufacture of claim 37, calculating the convolution comprises:
- selecting a spherical triangle;
- selecting a direction to be used as a free parameter of the BRDF term;
- selecting a direction that is subtended by the selected spherical triangle;
- computing a product of a value of the BRDF term for the selected free parameter direction times a value of the environment map in the selected direction from the spherical triangle;
- adding the product to a sum;
- repeating selecting of the free parameter direction and computing of the product for each direction subtended by the selected spherical triangle; and
- repeating selecting the spherical triangle, selecting of the free parameter and computing of the diffuse convolution for each of the M spherical triangles.
39. The article of manufacture of claim 25, wherein computing the color value comprises:
- selecting a ray sample according to an importance function;
- selecting an environment color from an environment map according to the ray sample;
- determining a visibility value according to the selected ray sample;
- calculating the BRDF term according to the selected ray sample, a surface normal and an eye ray to a virtual camera;
- calculating an intermediate color value according to the environment color, visibility value and BRDF value, divided by a value of the importance function according to the ray sample;
- adding the intermediate color value to a sum; and
- repeating selecting of the ray sample, selecting of the environment color, determining of the visibility term, determining of the BRDF term and calculating of the intermediate color value for each ray sample such that a final value of the sum represents a color value for the point P with surface normal N.
40. The article of manufacture of claim 34, wherein computing a normalized weight of each visible spherical triangle comprises:
- selecting a spherical triangle;
- looking up a color value in a convolved map generated for the selected triangle at a pixel location determined by the surface normal N and the eye ray;
- calculating a weight of the selected triangle as an intensity of the color value;
- adding the weight of the selected triangle to a sum;
- repeating the looking up of the color value, calculating the triangle weight and adding the triangle weight for each triangle; and
- dividing each triangle's weight by the sum of the weights of all of the triangles.
41. The article of manufacture of claim 40, wherein calculating the weight of the selected triangle by the sum of the weight for each triangle further comprises:
- estimating a value of the visibility term over the selected triangle; and
- scaling the weight selected by the estimated value.
42. The article of manufacture of claim 41, wherein estimating the value of the visibility term comprises:
- querying a visibility data structure for visibility values of one or more points proximate the point P;
- computing a blend of the one or more visibility values; and
- computing a visibility value for the point P according to the blend of the proximate visibility points.
43. The article of manufacture of claim 25, wherein prior to receiving the request, the method further comprises:
- selecting a scene;
- casting a predetermined number of rays for each surface point of the scene; and
- determining a count of a number of rays in a given direction indicated as occluded/unoccluded;
- forming a low resolution image according to the count; and
- storing the low resolution image within a data structure.
44. The article of manufacture of claim 39, wherein calculating the intermediate color value comprises:
- computing a product of the BRDF term, the visibility term and the color term;
- identifying a region associated with the ray sample;
- computing an inverse probability value of the region associated with the ray sample; and
- computing the initial color value as the computed product divided by the inverse probability value.
45. The article of manufacture of claim 26, wherein generating the importance function comprises:
- computing, for each pixel within an environment map, a product of a BRDF term, evaluated in a direction corresponding to the pixel, times an environment map term evaluated in the direction corresponding to the pixel.
46. The article of manufacture of claim 26, wherein selecting ray samples comprises:
- subdividing a unit interval into several regions, where a length of each region is equal to a value of an integrand approximation for a pixel times an area subtended by the pixel, divided by a sum of the integrand approximation times an area subtended by each pixel over all pixels;
- choosing a point from a unit square;
- normalizing a position of the selected point within its subdivided region; and
- selecting a ray sample according to a direction of the pixel.
47. The article of manufacture of claim 26, wherein selecting ray samples, the method further comprises:
- selecting a pixel with probability determined by a value of the integrand approximation multiplied by an area of the pixel;
- choosing a random point within the pixel;
- mapping the point within the pixel to a sphere such that the map point represents a ray sample; and
- repeating the choosing of a pixel, choosing of a random point and mapping for each pixel of the environment map.
48. The article of manufacture of claim 25, wherein the light source term of the reflected radiance integral comprises:
- a contribution function that depends only on direction, such that the point P is lit by an environment map.
49. An apparatus comprising:
- render logic to receive a request to generate a color value of a point P with surface normal N; and
- shade logic to compute the color value of the point P using an importance sampling estimator for a reflected radiance integral to select a plurality ray samples for evaluation of the reflected radiance integral at the point P to generate the color value according to a light source term, a visibility term and a bi-directional reflectance distribution function (BRDF) term of the reflected radiance integral.
50. The apparatus of claim 49, wherein the shade logic comprises:
- importance function logic to partition a unit hemisphere surrounding the point P into M non-overlapping regions, approximate a value of the integrand of the reflected radiance integral as a piece-wise constant function that is constant over each of the M non-overlapping regions, and use this piece-wise constant approximated value as the importance function.
51. The apparatus of claim 49, wherein the shade logic comprises:
- ray sample logic to tessellate an environment map sphere into M non-overlapping spherical triangles, generate a visible triangle list of the non-overlapping spherical triangles on a hemisphere, about the surface normal N for the point P, compute a normalized weight of each visible spherical triangle, and map points from a unit square onto triangles of the hemisphere according to a respective normalized weight of the triangles, such that the mapped points on the hemisphere are used as the selected ray samples.
52. The apparatus of claim 49, wherein the shade logic comprises:
- BRDF convolution logic to tessellate a spherical environment map into M non-overlapping spherical triangles, calculate a convolution of each spherical triangle against a surface BRDF, and store each calculated convolution in a map.
53. The apparatus of claim 49, wherein the shade logic comprises:
- visibility logic to select a scene, cast a predetermined number of rays for each surface point of the scene, determine a count of a number of rays in a given direction indicated as occluded/unoccluded, form a low resolution image according to the count, and store the low resolution image within a data structure.
54. A system comprising:
- a chipset;
- a processor coupled to the chipset via a system bus;
- a memory coupled to the chipset via a memory bus; and
- graphics logic coupled to the chipset, the graphics logic, comprising
- rendering logic to receive a request to generate a color value of a point P with surface normal N, and
- shading logic to compute the color value of the point P using an importance sampling estimator for a reflected radiance integral to select a plurality ray samples for evaluation of the reflected radiance integral at the point P to generate the color value according to a light source term, a visibility term and a bi-directional reflectance distribution function (BRDF) term of the reflected radiance integral.
55. The system of claim 54, wherein the shade logic comprises:
- importance function logic to partition a unit hemisphere surrounding the point P into M non-overlapping regions, approximate a value of the integrand of the reflected radiance integral as a piece-wise constant function that is constant over each of the M non-overlapping regions, and use this piece-wise constant approximated value as the importance function.
56. The system of claim 54, wherein the shade logic comprises:
- ray sample logic to tessellate an environment map sphere into M non-overlapping spherical triangles, generate a visible triangle list of the non-overlapping spherical triangles on a hemisphere, about the surface normal N for the point P, compute a normalized weight of each visible spherical triangle, and map points from a unit square onto triangles of the hemisphere according to a respective normalized weight of the triangles, such that the mapped points on the hemisphere are used as the selected ray samples.
57. The system of claim 54, wherein the shade logic comprises:
- BRDF convolution logic to tessellate a spherical environment map into M non-overlapping spherical triangles, calculate a convolution of each spherical triangle against a surface BRDF, and store each calculated convolution in a map.
58. The system of claim 54, wherein the shade logic comprises:
- visibility logic to select a scene, cast a predetermined number of rays for each surface point of the scene, determine a count of a number of rays in a given direction indicated as occluded/unoccluded, form a low resolution image according to the count, and store the low resolution image within a data structure.