Method and apparatus for shadow generation through depth mapping

- Silicon Graphics, Inc.

A method and apparatus for creating shadowed scenes for interactive image generation. Shadowing is effected by generation of a shadowing coefficient for each pixel, which is then used when the scene is rendered. The present invention utilizes z-buffer and projective texture mapping facilities of an image generation system. Generation of the shadow coefficient is achieved by the steps of: rendering the scene from the viewpoint of a light source using z-buffering to create a two dimensional depth map from said z-buffer; storing the depth map in texture mapping storage; rendering the scene from the viewpoint of the viewer; for every pixel in view creating an index info said depth map and a iterated depth value; retrieving a predetermined number of depth map samples from the depth map based on the position of a depth map index; comparing said iterated depth value with each of the depth map samples to determine which of the depth map samples are in shadow; creating a weighted average shadow coefficient from the results of the comparisons; and using the shadow coefficient for rendering. Optionally, the values in the depth map are offset by an amount dependent on the slope of the distance function relative to the depth map indices. The scene is then rendered utilizing surfaces and/or shading information. The shadow coefficient is used to calculate the pixel intensity thus creating realistic shadow effect.

Skip to:  ·  Claims  ·  References Cited  · Patent History  ·  Patent History

Claims

1. In a computer controlled display system for displaying three dimensional scenes, each of said three dimensional scenes comprised of a plurality of graphical primitives, said graphical primitives represented by pixels on a display screen, a method for displaying shadows in a scene caused by a light source, said method comprising the steps of:

a) generating a depth map in a light coordinate system and storing said depth map in a texture map storage, said light coordinate system having said light source as an origin, said depth map storing in said texture map storage a plurality of depth map sample values, wherein each depth map sample value identifies a distance from a pixel location in one of said graphical primitives to said light source;
b) rendering said scene from the viewpoint of a viewer by processing each of said graphical primitives of said scene, said processing comprising the steps of:
1) identifying pixels corresponding to each of said graphical primitives;
2) for each pixel, determining if it is visible from said viewer's viewpoint;
3) ignoring pixels that are not visible;
4) for each pixel that is visible, generating a shadow coefficient, indicating the degree to which a pixel is in shadow, wherein each pixels shadow coefficient is used to shade said pixel, wherein said shadow coefficient for said pixel is generated by performing the steps of:
generating light system coordinates for said pixel using a projective texture mapping technique, said light system coordinates comprising a pixel depth map index for indexing said texture map storage and a pixel depth value;
retrieving a predetermined number of depth map sample values from said texture map storage based on said pixel depth map index;
comparing each of said predetermined number of depth map sample values to said pixel depth value; and
using results of said comparison between said predetermined number of depth map sample values, and said pixel depth value to generate said shadow coefficient for said pixel and using said shadow coefficient to generate shading values for said pixel and displaying said pixel.

2. The method as recited in claim 1 wherein said step of generating a depth map in a light coordinate system is further comprised of the steps of:

h) rendering said scene from the viewpoint of said light source using a z-buffer technique to create a z-buffer of values in a z-buffer storage of said computer controlled display system; and
i) storing said z-buffer as said depth map by transferring said z-buffer of values from said z-buffer storage into said texture map storage.

3. The method as recited in claim 2 wherein prior to said step of storing said z-buffer as said depth map, performing the step of biasing each depth map sample value by an offset, said offset being proportional to the rate of change of the depth map sample value in a predetermined direction across said depth map.

4. The method as recited in claim 1 wherein said step of retrieving a predetermined number of depth map sample values based on said pixel depth map index is further comprised of the steps of:

h) determining a location of said pixel depth map index within said depth map; and
i) selecting said predetermined number of depth map sample values surrounding the location of said pixel depth map index.

5. The method as recited in claim 4 wherein said step of using results of said comparison between said predetermined number of depth map sample values and said pixel depth value to generate said shadow coefficient for said pixel comprises the steps of:

j) ignoring depth map sample values which are less than or equal to said pixel depth value;
k) for each depth map sample value that is greater than said pixel depth value, creating a weighted shadow factor of said depth map sample value based on the distance between said depth map sample value and said pixel depth map index location;
l) summing said weighted shadow factors as said shadow coefficient.

6. The method as recited in claim 5 wherein said predetermined number of depth map sample values is 1.

7. The method as recited in claim 5 wherein said predetermined number of depth map sample values is 4.

8. The method as recited in claim 5 wherein said predetermined number of depth map sample values is 9.

9. The method as recited in claim 5 wherein said predetermined number of depth map sample values is 16.

10. The method as recited in claim 5 wherein said predetermined number of depth map sample values is interactively set by a user.

11. In a computer controlled display system comprising interactive projective texture mapping means, said projective texture mapping means operating in a three dimensional (x, y, z) light coordinate system with a variably defined light source origin point, said projective texture mapping means for projecting a two dimensional texture map onto a three dimensional scene being rendered, said texture map indexed by (x, y) coordinates of said light coordinate system, said three dimensional scene comprising a plurality of graphics primitives, a method for rendering of scenes having shadows using said projective texture mapping means, said method comprising the steps of:

a) determining a position of a light source as the origin of said light coordinate system;
b) generating a depth map in said light coordinate system, said depth map storing a plurality of depth map sample values, wherein each depth map sample value identifies a distance from a pixel location in one of said graphics primitives to said light source;
c) storing said depth map for access as a texture map in a texture map storage;
d) for ail pixels corresponding to one of said graphics primitives performing the steps of:
1) determining that a particular pixel is visible from a viewer's viewpoint;
2) performing a texture map look-up on said depth map for said particular pixel, said texture map look-up including generation of coordinates in said light coordinate system for said particular pixel using said projective texture mapping means; wherein said coordinates in said light coordinate system for said particular pixel comprise a pixel depth map index and a pixel depth value;
3) retrieving a plurality of depth map sample values from said depth map based on said pixel depth map index;
4) assigning a first binary value to each of said retrieved depth map sample values that is in shadow and a second binary value to each of said retrieved depth map sample values that is not in shadow based on a comparison with the pixel depth value;
5) generating a shadow coefficient for said particular pixel from said binary values, said shadow coefficient indicating the degree to which said particular pixel is in shadow;
6) using said shadow coefficient to generate shading values for said particular pixel and displaying said pixel using said shading values.

12. The method as recited in claim 11 wherein said step of generating a depth map in said light coordinate system is further comprised of the step of performing a z-buffer hidden surface removal operation for each pixel to create a z-buffer, wherein said z-buffer comprises said depth map.

13. The method as recited in claim 12 wherein said step of retrieving a plurality of depth map sample values from said depth map based on said pixel depth map index is further comprised of the steps of:

a) determining a location of said pixel depth map index within said depth map; and
b) selecting said predetermined number of depth map sample values so that said location of said pixel depth map index is surrounded by said predetermined number of depth map sample values.

14. The method as recited in claim 13 wherein said step of assigning a first binary value to each of said retrieved depth map sample values that is in shadow and a second binary value to each of said retrieved depth map sample values that is not in shadow based on a comparison with the pixel depth value is further comprised of the steps of:

a) assigning said first binary value to said retrieved depth map sample value if said depth map sample value is less than said pixel depth value; and
b) assigning said second binary value to said retrieved depth map sample value if said retrieved depth map sample value is greater than or equal to said pixel depth value.

15. The method as recited in claim 14 wherein said first binary value is 1 and said second binary value is 0.

16. The method as recited in claim 15 wherein said predetermined number of depth map sample values is 1.

17. The method as recited in claim 15 wherein said predetermined number of depth map sample values is 4.

18. The method as recited in claim 15 wherein said predetermined number of depth map sample values is 9.

19. The method as recited in claim 15 wherein said predetermined number of depth map sample values is 16.

20. The method as recited in claim 15 wherein said predetermined number of depth map sample values is interactively set by a user.

21. The method as recited in claim 11 wherein prior to said step of storing said depth map for access as a texture map, performing the step of biasing each depth map sample value by an offset, said offset being proportional to the rate of change of the depth map sample value across said depth map.

22. The method as recited in claim 11 wherein said step of using said shadow coefficient is further comprised of the steps of:

a) applying said shadow coefficient to a light source color to determine a light source contribution to pixel color intensity;
b) determining an ambient light color; and
c) combining said light source contribution with said ambient light color to generate said shading values.

23. A computer controlled display system for interactive generation of shadowed scenes comprising:

a texture map storage;
a projective texture mapping means for generating a texture map index and a pixel depth value;
a z-buffering means for identifying surface points of a plurality of graphics primitives which are closest to a viewpoint;
a display means;
rendering means for rendering pixels based on a shadow coefficient, said shadow coefficient identifying the amount a pixel is in shadow, said display means coupled to rendering means to display said pixel;
shadow coefficient generation means coupled to said projective texture mapping means and said z-buffering means and to said rendering means, said shadow coefficient generation means for calculating said shadow coefficient, said shadow coefficient generation means further comprised of:
means for generating a depth map utilizing said z-buffering means, said depth map storing a plurality of depth map sample values, wherein each depth map sample value identifies a distance from a pixel location of a graphics primitive to a light source;
means for storing said depth map as a texture in said texture map storage;
means for utilizing said projective texture mapping means for accessing said depth map stored in said texture map storage;
means for identifying a predetermined number of depth map sample values based on said texture map index; and
means for generating a weighted average from said predetermined number of depth map sample values said weighted average representing said shadow coefficient;
means for generating a shading value for said pixel, said means for generating being coupled to said display means for displaying said pixel.

24. The computer controlled display system as recited in claim 23 wherein said projective texture mapping means is further comprised of:

means for identifying a position of said light source;
means for assigning the position of said light source as the origin for a light coordinate system;
means for converting coordinates in a screen coordinate system to coordinates in said light coordinate system; and
means for generating said texture map index from said coordinates in said light coordinate system.

25. The computer controlled display system as recited in claim 23 wherein said shadow coefficient generation means is further comprised of depth map bias generation means, said depth map bias generation means comprised of:

means for generating a unique offset for each entry of said depth map, said unique offset being proportional to the rate of change of the depth map sample values across said depth map; and
means for applying the generated unique offset to the corresponding entry of said depth map.

26. In a computer controlled display system for interactively displaying three dimensional scenes, each of said three dimensional scenes comprised of a plurality of graphical primitives, said graphical primitives represented by pixels on a display screen, a method for displaying shadows in a scene caused by a light source, said method comprising the steps of:

A) generating a depth map in a light coordinate system and storing said depth map in a texture map storage, said light coordinate system having said light source as an origin, said depth map storing in said texture map storage a plurality of depth map sample values each identifying a distance from a pixel location in one of said graphical primitives to said light source;
B) biasing each depth map sample value by an offset, said offset being proportional to the rate of change of the depth map sample value in a predetermined direction across said depth map;
C) rendering said scene from the viewpoint of a viewer by processing each of said graphical primitives of said scene, said processing comprising the steps of:
1) identifying pixels corresponding to each of said graphical primitives;
2) for each pixel, determining if it is visible from said viewer's viewpoint;
3) ignoring pixels that are not visible;
4) for each pixel that is visible, generating a shadow coefficient indicating the degree to which a pixel is in shadow, wherein each pixel's shadow coefficient is used to shade said pixel, wherein said shadow coefficient for said pixel is generated by performing the steps of:
a) generating coordinates in said light coordinate system for said pixel texture mapping techniques, said coordinates comprising a pixel depth map index for indexing said texture map storage and a pixel depth value;
b) retrieving a predetermined number of depth map sample values from said texture map storage based on said pixel depth map index;
c) comparing each of said predetermined number of depth map sample values to said pixel depth value; and
d) using the results of the comparing step to generate a shadow coefficient for said pixel and using said shadow coefficient to generate shading values for said pixel and displaying said pixel using said shading values.
Referenced Cited
U.S. Patent Documents
4586038 April 29, 1986 Sims et al.
4709231 November 24, 1987 Sakaibara et al.
4727365 February 23, 1988 Bunker et al.
4807158 February 21, 1989 Blanton et al.
4821212 April 11, 1989 Heartz
4845651 July 4, 1989 Aizawa et al.
4928250 May 22, 1990 Greenberg et al.
4943938 July 24, 1990 Aushima et al.
5025405 June 18, 1991 Swanson
5083287 January 21, 1992 Obata et al.
5179638 January 12, 1993 Dawson et al.
5224208 June 29, 1993 Miller, Jr. et al.
5239624 August 24, 1993 Cook et al.
5268996 December 7, 1993 Steiner et al.
5282262 January 25, 1994 Kurashige
5305430 April 19, 1994 Glassner
5307450 April 26, 1994 Grossman
5317689 May 31, 1994 Nack et al.
5321797 June 14, 1994 Morton
5325471 June 28, 1994 Inoue
5325472 June 28, 1994 Horiuchi et al.
5333245 July 26, 1994 Vecchione
5345541 September 6, 1994 Kelley et al.
5361386 November 1, 1994 Watkins et al.
5363477 November 8, 1994 Kuragano et al.
5367615 November 22, 1994 Economy et al.
5469535 November 21, 1995 Jarvis et al.
5537638 July 16, 1996 Morita et al.
Other references
  • "Computer Graphics Principles and Practices, Second Edition", Foley et al., Addison-Wesley Publishing Company, pp. 745-756. "Casting Curved Shadows on Curved Surfaces", Williams, Proceedings of SIGGRAPH '78, pp. 270-274. "The RenderMan Companion", Steve Upstill, Addison-Wesley Publishing Company, 1990. "Fast Shadows and Lighting Effects Using Texture Mapping", Segal, et al., Computer Graphics, 26, 2, Jul. 1992, pp. 249-252. Peachey, Darwyn R., "Solid Texturing of Complex Surfaces", Siggraph, vol. 19, No. 3, pp. 279-286 (Jul. 22-26, 1985). "High-Performance Polygon Rendering", Kurt Akeley & Tom Jermoluk, Computer Graphics, vol. 22, No. 4, Aug. 1988.
Patent History
Patent number: 5742749
Type: Grant
Filed: Feb 20, 1996
Date of Patent: Apr 21, 1998
Assignee: Silicon Graphics, Inc. (Mountain View, CA)
Inventors: James L. Foran (Milpitas, CA), Rolf A. van Widenfelt (San Francisco, CA)
Primary Examiner: Anton W. Fetting
Law Firm: Blakely, Sokoloff, Taylor & Zafman
Application Number: 8/603,691
Classifications
Current U.S. Class: 395/126; 395/130
International Classification: G06T 1140;