(19)
(11) EP 2 234 069 A1

(12) EUROPEAN PATENT APPLICATION

(43) Date of publication:
29.09.2010 Bulletin 2010/39

(21) Application number: 09364002.7

(22) Date of filing: 27.03.2009
(51) International Patent Classification (IPC): 
G06T 15/60(2006.01)
(84) Designated Contracting States:
AT BE BG CH CY CZ DE DK EE ES FI FR GB GR HR HU IE IS IT LI LT LU LV MC MK MT NL NO PL PT RO SE SI SK TR
Designated Extension States:
AL BA RS

(71) Applicant: Thomson Licensing
92130 Issy-les-Moulineaux (FR)

(72) Inventors:
  • Gautron, Pascal
    92130 Issy les Moulineaux (FR)
  • Marvie, Jean-Eudes
    92130 Issy les Moulineaux (FR)
  • Briand, Gérard
    92130 Issy les Moulineaux (FR)

(74) Representative: Huchet, Anne 
Technicolor 1-5 rue Jeanne d'Arc
92130 Issy-les-Moulineaux
92130 Issy-les-Moulineaux (FR)

   


(54) Method for generating shadows in an image


(57) The invention concerns a method for generating shadows in an image (10) comprising the steps of:
- Computing (E2) a depth-map (6) that comprises an array of pixels, wherein pixels in the depth-map (6) have a depth value (dsm) that indicates a depth from the light source (2) to a portion of the nearest occluding object (4) visible through the pixel,
- projecting (E6) each point (Pix) visible from a virtual camera (1) into the light space,
- calculating (E7) the distance (dp) between the said visible projected point (P) and the light source (2),
- fetching (E8) the depth value (dsm) in the depth-map (6) corresponding to the light ray from the light source to said visible projected point (P),
The method further comprises the steps of
- computing (E9), for each pixel, an adaptive bias (b) as a function of a predetermined base bias (bbase) and the orientation of the surface (3) on which the said visible point is located,
- comparing (E10) for each pixel (Pix) in the image, the distance (dp) between said visible projected point (P) and the light source (2) with the sum of the corresponding depth map value ((dsm) and said adaptive bias (bbase),
- labelling (E11, E12) said pixel (Pix) as lit or shadowed according to said comparison.




Description


[0001] In graphics rendering, it is important to produce images that are realistic on a real-time basis. The basic difficulty in achieving total visual realism is the complexity of quickly and accurately representing real world visual effects. A scene can include a variety of textures, color gradations, reflections, translucency, and , most particularly, shadows. Shadows enhance the realism of an image because they give a two-dimensional (2D) image the appearance of being three-dimensional.

[0002] The generation of shadows is critical in games environment for instance as it has to be generated in real-time according to the movements in the scene which are guided by the games users.

[0003] In the past, there have been a number of different ways to determine how objects in a scene would cast shadows and how these shadows should be represented in the rendered image.

[0004] A common shadowing method, called shadow volumes is described in the document from F. Crow entitled "Shadow Algorithms for Computer Graphics" published in the proceedings of SIGGRAPH in 1977.

[0005] In this document, the silhouette of shadow-casting objects is extruded to determine the shadowing. While this method provides high quality shadows, it is limited to simple scenes and is computationally intensive.

[0006] A more general technique for real-time shadow generation is described in the document from L. Williams entitled "Casting curved shadows on curved surfaces" published in the proceedings of SIGGRAPH in 1978.

[0007] While this method is very efficient and easy to implement, it suffers from sampling drawbacks due to the finite resolution of the shadow map: most , of the time a single shadow map texel gets used in several pixels of the final image, yielding several aliasing artifacts. The most known artifact is the apparition of shadow blocks in the final image.

[0008] This artifact can typically be reduced using percentage-closer filtering disclosed in the article from M. Bunnell and F. Pellacini entitled "Shadow Map Antialiasing" published in GPU Gems, Addison Wesley Edition in 2004, in which several shadow map texels are used to determine the percentage of lighting incoming to the point. Many other methods have been devised to reduce such aliasing artifacts by focusing the shadow map only on the visible parts of the scene. However all those methods are view-dependent, and hence require regenerating the shadow map for each movement of the user. Furthermore, the quality of the shadow map is not constant depending on the user location.

[0009] Another artifact is due both to the precision of the distance information and to the limited resolution of the map: the distance comparison may return erroneous values for occluding objects very close to each other, or on surfaces nearly tangent to the light direction. To overcome this problem, the user-defined bias value offsets the distance comparisons so that erroneous shadowing is removed. However, this results in an undesired shifting of the shadows. As a same bias value is used for rendering the entire scene, 'problematic' objects force a shifting of all the other shadows to avoid artifacts.

[0010] US 5,870,097 filed on January 27, 1996 in the name of Snyder, proposes a method for improving shadowing in a graphics rendering system. It proposes an automatic calculation of a bias for shadow-mapping. However, the method proposed in this patent requires complex computations, and namely a computation of the distance from the source to the two closest surfaces.

[0011] The present invention proposes to solve at least one of these drawbacks. To this end, the present invention concerns a method for generating shadows in an image comprising the steps of:
  • Computing a depth-map that comprises an array of pixels, wherein pixels in the depth-map have a depth value that indicates a depth from the light source to a portion of the nearest occluding object visible through the pixel,
  • projecting each point visible from a virtual camera into the light space,
  • calculating the distance between the said visible projected point and the light source,
  • fetching the depth value in the depth-map corresponding to the light ray from the light source to said visible projected point.
The method further comprises the steps of
  • computing, for each pixel, an adaptive bias as a function of a predetermined base bias and the orientation of the surface on which the said visible point is located,
  • comparing for each pixel in the image, the distance between said visible projected point and the light source with the sum of the corresponding depth map value and said adaptive bias,
  • labelling said pixel as lit or shadowed according to said comparison.


[0012] Preferentially, said adaptive bias is dependant on said surface normal.

[0013] According to a preferred embodiment, said adaptive bias is defined as the division of said predetermined base bias by the dot product of the surface normal by the incident light direction.

[0014] Preferentially, said adaptive bias is limited to a maximum value.

[0015] According to a second aspect, the invention concerns also a graphics processing unit comprising code instructions for performing the method according to any of the previous claims.

[0016] According to a third aspect, the invention concerns also a computer program product for computing shadows for an image, the computer program product comprising a computer-readable medium containing computer program code for performing the steps of the method according to any of claims 1 to 4.

[0017] According to a second aspect, the invention concerns a graphics processing unit comprising code instructions for performing the method according to any of the previous claims.

[0018] According to a third aspect, the invention concerns a computer program product for computing shadows for an image, the computer program product comprising a computer-readable medium containing computer program code for performing the steps of the method according to the invention.

[0019] Other characteristics and advantages of the invention will appear through the description of a non-limiting embodiment of the invention, which will be illustrated, with the help of the enclosed drawings.
  • Figure 1 represents an overview of a scene for which shadows have to be generated,
  • Figure 2 represents an algorithm of shadow mapping, with adaptive bias,
  • Figure 3 represents the values used in the bias calculation according to a preferred embodiment of the invention,
  • Figure 4 represents the aliasing phenomenon on surfaces.


[0020] On figure 1, the scene for which shadows have to be generated is represented. The proposed method enables the generation of shadows in real-time. When a video game is played, according to the displacement of persons in a scene, guided by the user, the shadows have to be generated in real-time. Therefore, the method is advantageously executed thanks to a Graphics Processing unit, known under the acronym of GPU, on a computer or graphics processing board of a computer. The GPU will execute the software instructions to execute the method which is disclosed hereafter. The code instructions are stored on a computer-readable medium, such as a memory.

[0021] The method is based on the fact that a light source and a virtual camera are positioned in the scene. One embodiment is shown on figure 1.

[0022] A virtual camera 1 captures the scene for which shadows have to be generated. A light source 2 is positioned as shown on figure 1. A sphere 4 is located in the scene and represents an occluding object for an image 10. The pixels are projected on a surface plane 3. The light source 2 projects light rays 5 which illuminate part of the sphere 4. The image 10 comprises an array of pixels that represent a three-dimensional scene as viewed from a particular point of the virtual camera 1. For a given light source 2, a depth map 6 is computed. The depth map 6 includes an array of pixels, where instead of having a color value, each pixel has a depth value. Each pixel in the depth map has coordinates (xsm, ysm). In one embodiment, the depth value is defined with reference to a z-axis, which is normal to the depth-map.

[0023] The flowchart given in figure 2 is based on a real-time shadow-mapping algorithm but it is not limited to this method and the invention can be based on any shadow mapping-based technique.

[0024] In the case of perspective shadow mapping methods, steps E2 and E7 described later on are different.

[0025] In a step E1, a camera is positioned at the light source location, thanks to the facilities offered by virtual reality.

[0026] In a step E2, the scene is rendered from the camera positioned at the light source location. The distance dsm (xsm, ysm), visible on figure 1 with reference numeral 8, to each point which is visible from this camera position is stored in the shadow map. The shadow map is a depth-map texture stored in a graphics memory.

[0027] In a step E3, the rendering process is initialized and in the following steps the camera is located in its original position.

[0028] In a step E4, the user defines the bias bbase which depends only on the scene scale. For instance, the value 0,1 is suitable for a scene which length unit is the meter.

[0029] In a step E5 a first pixel Pix as in the final image is chosen. All the pixels will be chosen one after the others. In other embodiments, depending on the processor capabilities, several pixels can be processed simultaneously.

[0030] In a step E6, the point P visible through pixel Pix is projected into the light space.

[0031] In a step E7, the distance dp from P to the light source is computed. It is shown on figure 1 as reference numeral 9.

[0032] This light ray, from the light source to the point P, crosses the depth map at pixel of coordinates (xsm, ysm) and the corresponding distance dsm (xsm, ysm) to the nearest occluder is fetched from the shadow map in a step E8.

[0033] In a step E9, an adaptive bias is computed. As shown in figure 4, in conventional methods, there is aliasing on surfaces. Aliasing artifacts tend to appear when the rendered surface gets tangent to the lighting direction.

[0034] As each pixel of the shadow map stores the distance to the point visible in the middle of the pixel, the limited sampling rate yields zones in which points are successively labeled as lit or shadowed.

[0035] To remove the artifacts, the bias value must be raised. Conversely, surfaces nearly perpendicular to the lighting direction do not require a high bias value.

[0036] According to the present embodiment of the invention, based on the surface orientation at each visible point, a per-pixel bias adaptation function is defined. Given the user-defined base bias value bbase which only depends on the scene scale, the actual bias b used to determine the shadowing is computed according to the following equation:



[0037] where '.' is the vector dot product operator, N is the surface normal, L is the incident light direction and ε is a minimum value, typically 0.05, to prevent the bias value to go to infinity when N gets nearly perpendicular to L.

[0038] Figure 3 illustrates this by showing the L and N representations.

[0039] In a step E10, a test is performed. Dp represents the distance from the light source to the point P and Dsm represents the distance from the light source to the shadow map.

[0040] If dpdsm +b, then one moves forward to a step E11 in which the pixel Pix is labeled as a shadowed pixel.

[0041] If dp < dsm +b, then one moves forward to a step E12 in which the pixel is labeled as a lit pixel.

[0042] Then one moves further to step E13, in which a test is performed in order to check whether this is the last pixel of the scene. If yes, the whole scene has been processed, otherwise, one moves further to step E15, in which a next pixel is chosen and one moves back to step E6, and so on and so forth until all pixels have been reviewed (step E14).

[0043] When all the pixels of the image have been labeled either lit or shadowed, an image processing method is performed on these pixels to respectively light or shadow them.

[0044] The invention as described in the preferred embodiments, is advantageously computed using a Graphics processing unit (GPU) on a graphics processing board.

[0045] The invention is also therefore implemented preferentially as software code instructions and stored on a computer-readable medium such as a memory (flash, SDRAM...), said instructions being read by a graphics processing unit.

[0046] The foregoing description of the embodiments of the invention has been presented for the purposes of illustration and description. It is not intended to be exhaustive or to limit the invention to the precise form disclosed. Persons skilled in the relevant art can appreciate that many modifications and variations are possible in light of the above teaching. It is therefore intended that the scope of the invention is not limited by this detailed description, but rather by the claims appended hereto.


Claims

1. Method for generating shadows in an image (10) comprising the steps of:

- Computing (E2) a depth-map (6) that comprises an array of pixels, wherein pixels in the depth-map (6) have a depth value (dsm) that indicates a depth from the light source (2) to a portion of the nearest occluding object (4) visible through the pixel,

- projecting (E6) each point (Pix) visible from a virtual camera (1) into the light space,

- calculating (E7) the distance (dp) between the said visible projected point (P) and the light source (2),

- fetching (E8) the depth value (dsm) in the depth-map (6) corresponding to the light ray from the light source to said visible projected point (P),

Characterized in that it further comprises the steps of

- computing (E9), for each pixel, an adaptive bias (b) as a function of a predetermined base bias (bbase) and the orientation of the surface (3) on which the said visible point is located,

- comparing (E10) for each pixel (Pix) in the image, the distance (dp) between said visible projected point (P) and the light source (2) with the sum of the corresponding depth map value ((dsm) and said adaptive bias (bbase),

- labelling (E11, E12) said pixel (Pix) as lit or shadowed according to said comparison.


 
2. Method according to claim 1 characterized in that said adaptive bias (bbase) is dependant on said surface normal (N).
 
3. Method according to claim 2 characterized in that said adaptive bias (b) is defined as the division of said predetermined base bias (bbase) by the dot product of the surface normal (N) by the incident light direction (L).
 
4. Method according to any of the previous claims characterized in that said adaptive bias is limited to a maximum value.
 
5. Graphics processing unit comprising code instructions for performing the method according to any of the previous claims.
 
6. Computer program product for computing shadows for an image, the computer program product comprising a computer-readable medium containing computer program code for performing the steps of the method according to any of claims 1 to 4.
 




Drawing













Search report













Cited references

REFERENCES CITED IN THE DESCRIPTION



This list of references cited by the applicant is for the reader's convenience only. It does not form part of the European patent document. Even though great care has been taken in compiling the references, errors or omissions cannot be excluded and the EPO disclaims all liability in this regard.

Patent documents cited in the description




Non-patent literature cited in the description