# US 2021/0279948 A1 · Shadow rendering method and apparatus, computer device, and storage medium

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2021/0279948 A1
- Document ID: US20210279948A1
- Status: Published application
- Kind: A1
- Application number: 17/327,585
- Filed: 2021-05-21
- Published: 2021-09-09
- Earliest claimed: 2019-04-11
- Assignees: Tencent Technology (Shenzhen) Company Limited
- Applicants: Tencent Technology (Shenzhen) Company Limited
- Inventors: Cangjian HOU
- Web page: https://patentgrep.com/patent/US20210279948A1

## CPC

- G06T 15/60: Shadow generation
- G06T 15/04: Texture mapping
- G06T 15/20: Perspective computation
- G06T 2215/12: Shadow map, environment map
- G06T: IMAGE DATA PROCESSING OR GENERATION, IN GENERAL

## Abstract

This application discloses a shadow rendering method and apparatus, a computer device, and a storage medium, the method including: obtaining at least one rendering structure in virtual scene according to an illumination direction in the virtual scene; obtaining model coordinates of a plurality of pixels according to a current viewing angle associated with the virtual scene and depth information of the plurality of pixels; sampling at least one shadow map according to the model coordinates of the plurality of pixels to obtain a plurality of sampling points corresponding to the plurality of pixels; and rendering the plurality of sampling points in the virtual scene to obtain at least one shadow associated with the at least one virtual object.

## Claims

### Claim 1

A shadow rendering method, performed by a computer device, the method comprising:
obtaining at least one rendering structure in a virtual scene according to an illumination direction in the virtual scene, the at least one rendering structure being used for rendering at least one shadow of at least one virtual object, and each rendering structure comprising a plurality of pixels in the virtual scene;
obtaining model coordinates of the plurality of pixels according to a current viewing angle associated with the virtual scene and depth information of the plurality of pixels, the model coordinates being used for describing texture information of the pixels relative to a model vertex of each virtual object;
sampling at least one shadow map according to the model coordinates of the plurality of pixels to obtain a plurality of sampling points corresponding to the plurality of pixels, each shadow map being used for providing texture information of a shadow associated with the at least one virtual object; and
rendering the plurality of sampling points in the virtual scene to obtain the at least one shadow.

### Claim 2 (depends on 1)

The method according to claim 1, wherein the obtaining model coordinates of the plurality of pixels according to a current viewing angle associated with the virtual scene and depth information of the plurality of pixels comprises:
obtaining world coordinates of the plurality of pixels in the virtual scene according to the current viewing angle and the depth information of the plurality of pixels, the world coordinates being used for describing position information of the pixels relative to a scene base point of the virtual scene; and
obtaining the model coordinates of the plurality of pixels according to the world coordinates of the plurality of pixels in the virtual scene.

### Claim 3 (depends on 2)

The method according to claim 2, wherein the obtaining world coordinates of the plurality of pixels in the virtual scene according to the current viewing angle and the depth information of the plurality of pixels comprises:
determining, for each pixel, with a view of the current viewing angle as a ray endpoint, in a ray direction determined according to the view and the pixel, a target pixel with a distance from the view meeting depth information of the pixel; and
determining world coordinates of the target pixel in the virtual scene as the world coordinates of the pixel in the virtual scene.

### Claim 4 (depends on 2)

The method according to claim 2, wherein the obtaining the model coordinates of the plurality of pixels according to the world coordinates of the plurality of pixels in the virtual scene comprises:
left multiplying a view matrix of the current viewing angle by the world coordinates of the plurality of pixels to obtain local coordinates of the plurality of pixels in the virtual scene; and
mapping the local coordinates of the plurality of pixel to a texture mapping space to obtain the model coordinates of the plurality of pixels.

### Claim 5 (depends on 1)

The method according to claim 1, further comprising:
before obtaining model coordinates of the plurality of pixels according to a current viewing angle associated with the virtual scene and depth information of the plurality of pixels in the virtual scene, obtaining the depth information of the plurality of pixels from a depth map according to screen coordinates of the plurality of pixels, screen coordinates being used for describing position information of a pixel relative to a screen base point of a terminal screen.

### Claim 6 (depends on 1)

The method according to claim 1, wherein the obtaining at least one rendering structure in a virtual scene according to an illumination direction in the virtual scene comprises:
determining an initial size and an initial position of the at least one rendering structure according to the at least one virtual object, the initial size and the initial position matching the at least one virtual object; and
determining a direction of the at least one rendering structure according to the illumination direction, and adjusting the initial size and the initial position, to obtain the at least one rendering structure.

### Claim 7 (depends on 1)

The method according to claim 1, wherein the at least one rendering structure is a cube, a sphere, or a cylinder.

### Claim 8 (depends on 1)

The method according to claim 1, further comprising:
before sampling at least one shadow map according to the model coordinates of the plurality of pixels to obtain a plurality of sampling points corresponding to the plurality of pixels, left multiplying a view matrix of the illumination direction by world coordinates of the at least one virtual object, and generating the at least one shadow map for performing shadow projection on the at least one virtual object from the illumination direction.

### Claim 9 (depends on 1)

The method according to claim 1, further comprising:
marking a material of a virtual object that is not allowed to be obscured as a target material, the target material being a material that does not support shadow rendering in a rendering process.

### Claim 10

A computer device, comprising a memory and a processor, the memory storing computer-readable instructions, and the computer-readable instructions, when executed by the processor, causing the processor to perform the following operations:
obtaining at least one rendering structure in a virtual scene according to an illumination direction in the virtual scene, the at least one rendering structure being used for rendering at least one shadow of at least one virtual object, and each rendering structure comprising a plurality of pixels in the virtual scene;
obtaining model coordinates of the plurality of pixels according to a current viewing angle associated with the virtual scene and depth information of the plurality of pixels, the model coordinates being used for describing texture information of the pixels relative to a model vertex of each virtual object;
sampling at least one shadow map according to the model coordinates of the plurality of pixels to obtain a plurality of sampling points corresponding to the plurality of pixels, each shadow map being used for providing texture information of a shadow associated with the at least one virtual object; and
rendering the plurality of sampling points in the virtual scene to obtain the at least one shadow.

### Claim 11 (depends on 10)

The computer device according to claim 10, wherein the obtaining model coordinates of the plurality of pixels according to a current viewing angle associated with the virtual scene and depth information of the plurality of pixels comprises:
obtaining world coordinates of the plurality of pixels in the virtual scene according to the current viewing angle and the depth information of the plurality of pixels, the world coordinates being used for describing position information of the pixels relative to a scene base point of the virtual scene; and
obtaining the model coordinates of the plurality of pixels according to the world coordinates of the plurality of pixels in the virtual scene.

### Claim 12 (depends on 11)

The computer device according to claim 11, wherein the obtaining world coordinates of the plurality of pixels in the virtual scene according to the current viewing angle and the depth information of the plurality of pixels comprises:
determining, for each pixel, with a view of the current viewing angle as a ray endpoint, in a ray direction determined according to the view and the pixel, a target pixel with a distance from the view meeting depth information of the pixel; and
determining world coordinates of the target pixel in the virtual scene as the world coordinates of the pixel in the virtual scene.

### Claim 13 (depends on 11)

The computer device according to claim 11, wherein the obtaining the model coordinates of the plurality of pixels according to the world coordinates of the plurality of pixels in the virtual scene comprises:
left multiplying a view matrix of the current viewing angle by the world coordinates of the plurality of pixels to obtain local coordinates of the plurality of pixels in the virtual scene; and
mapping the local coordinates of the plurality of pixel to a texture mapping space to obtain the model coordinates of the plurality of pixels.

### Claim 14 (depends on 10)

The computer device according to claim 10, wherein the plurality of operations further comprise:
before obtaining model coordinates of the plurality of pixels according to a current viewing angle associated with the virtual scene and depth information of the plurality of pixels in the virtual scene, obtaining the depth information of the plurality of pixels from a depth map according to screen coordinates of the plurality of pixels, screen coordinates being used for describing position information of a pixel relative to a screen base point of a terminal screen.

### Claim 15 (depends on 10)

The computer device according to claim 10, wherein the obtaining at least one rendering structure in a virtual scene according to an illumination direction in the virtual scene comprises:
determining an initial size and an initial position of the at least one rendering structure according to the at least one virtual object, the initial size and the initial position matching the at least one virtual object; and
determining a direction of the at least one rendering structure according to the illumination direction, and adjusting the initial size and the initial position, to obtain the at least one rendering structure.

### Claim 16 (depends on 10)

The computer device according to claim 10, wherein the plurality of operations further comprise:
before sampling at least one shadow map according to the model coordinates of the plurality of pixels to obtain a plurality of sampling points corresponding to the plurality of pixels, left multiplying a view matrix of the illumination direction by world coordinates of the at least one virtual object, and generating the at least one shadow map for performing shadow projection on the at least one virtual object from the illumination direction.

### Claim 17 (depends on 10)

The computer device according to claim 10, wherein the plurality of operations further comprise:
marking a material of a virtual object that is not allowed to be obscured as a target material, the target material being a material that does not support shadow rendering in a rendering process.

### Claim 18

One or more non-transitory computer-readable storage media storing computer-readable instructions, the computer-readable instructions, when executed by one or more processors of a computer device, causing the computer device to perform a plurality of operations including:
obtaining at least one rendering structure in a virtual scene according to an illumination direction in the virtual scene, the at least one rendering structure being used for rendering at least one shadow of at least one virtual object, and each rendering structure comprising a plurality of pixels in the virtual scene;
obtaining model coordinates of the plurality of pixels according to a current viewing angle associated with the virtual scene and depth information of the plurality of pixels, the model coordinates being used for describing texture information of the pixels relative to a model vertex of each virtual object;
sampling at least one shadow map according to the model coordinates of the plurality of pixels to obtain a plurality of sampling points corresponding to the plurality of pixels, each shadow map being used for providing texture information of a shadow associated with the at least one virtual object; and
rendering the plurality of sampling points in the virtual scene to obtain the at least one shadow.

### Claim 19 (depends on 18)

The non-transitory computer-readable storage media according to claim 18, wherein the plurality of operations further comprise:
before obtaining model coordinates of the plurality of pixels according to a current viewing angle associated with the virtual scene and depth information of the plurality of pixels in the virtual scene, obtaining the depth information of the plurality of pixels from a depth map according to screen coordinates of the plurality of pixels, screen coordinates being used for describing position information of a pixel relative to a screen base point of a terminal screen.

### Claim 20 (depends on 18)

The non-transitory computer-readable storage media according to claim 18, wherein the plurality of operations further comprise:
before sampling at least one shadow map according to the model coordinates of the plurality of pixels to obtain a plurality of sampling points corresponding to the plurality of pixels, left multiplying a view matrix of the illumination direction by world coordinates of the at least one virtual object, and generating the at least one shadow map for performing shadow projection on the at least one virtual object from the illumination direction.
