Three-dimensional model shadow rendering method, device, computer equipment and storage medium
By determining the shadow volume for the three-dimensional model and combining the projection rendering range and vertex position information, the problem of unnatural shadow effects in the existing technology is solved, and a shadow rendering effect with higher realism is achieved.
Patent Information
- Application Number
- CN202210763021.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-30
- Publication Date
- 2025-09-16
- Estimated Expiration
- 2042-06-30
AI Technical Summary
The existing technology has the problem of poor realism when rendering shadows in three-dimensional models, especially rendering black areas, which leads to unnatural shadow effects.
By determining the shadow volume for the 3D model and combining the projection rendering range and vertex position information, the displayed shadow intensity is determined to achieve a natural transition and position fit of the shadow effect.
The realism of the shadow effect is improved, making the simulated shadow fit the position of the 3D model more naturally.
Smart Images

Figure CN115049772B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a shadow rendering method, apparatus, computer equipment, and storage medium for a three-dimensional model. Background Art
[0002] When rendering a 3D model into a virtual scene, shadow effects are often added. To reduce the computational effort required to add shadows to a 3D model, current methods typically render a black area around the bottom of the 3D model. However, this method of rendering shadows lacks realism. Summary of the Invention
[0003] The embodiments of the present disclosure at least provide a method, apparatus, computer equipment, and storage medium for rendering shadows of a three-dimensional model.
[0004] In a first aspect, an embodiment of the present disclosure provides a shadow rendering method for a three-dimensional model, comprising: determining a shadow body corresponding to the three-dimensional model for the three-dimensional model in a virtual three-dimensional space; the shadow body is used to indicate a projection rendering range when the three-dimensional model is projected on a projection surface of a preset object in the virtual three-dimensional space; in response to at least one target vertex on the projection surface being located in the area where the shadow body is located, determining a display shadow intensity corresponding to the target vertex based on second position information of the target vertex in the virtual three-dimensional space and first position information corresponding to the shadow body; rendering the projection surface based on the display shadow intensity corresponding to the at least one target vertex to obtain a shadow rendering result of the three-dimensional model on the projection surface.
[0005] In an optional embodiment, determining a shadow body corresponding to a three-dimensional model in a virtual three-dimensional space includes: determining a first target reference position point of the three-dimensional model; the first target reference position point includes a first target position point of the three-dimensional model, and a second target position point associated with the first target position point; determining first position information of the shadow body corresponding to the three-dimensional model based on the position information of the first target reference position point in the virtual three-dimensional space, and determining the shadow body corresponding to the three-dimensional model based on the first position information.
[0006] In an optional embodiment, determining the first target reference position point of the three-dimensional model includes: based on the type of the three-dimensional model, determining at least two support points corresponding to the three-dimensional model among multiple vertices of the three-dimensional model; and determining the at least two support points as the first target reference position point.
[0007] In an optional embodiment, determining the at least two support points as the first target reference position points includes: determining whether a first height difference between the at least two support points in the three-dimensional virtual space is greater than a height difference threshold; in response to the first height difference being less than or equal to the height difference threshold, determining the at least two support points as the first target reference position points; in response to the first height difference being greater than the height difference threshold, determining a support point to be adjusted from the at least two support points, and determining a new position point based on the position information of the support point to be adjusted in the three-dimensional virtual space; determining the new position point and the non-to-be-adjusted support point among the at least two support points as the first target reference position point; wherein the new position point and the projection of the corresponding support point to be adjusted on the projection surface coincide with each other, and the first height difference between the new position point and the non-to-be-adjusted support point in the three-dimensional virtual space is less than or equal to the height difference threshold.
[0008] In an optional embodiment, determining the first target reference position point of the three-dimensional model includes: based on the type of the three-dimensional model, determining any support point of the three-dimensional model among multiple vertices of the three-dimensional model; determining the any support point as the first target position point; based on the lighting direction of the three-dimensional model and the height information of the three-dimensional model, determining the distance between the first target position point and the second target position point; and determining the second target position point based on the distance and the lighting direction.
[0009] In an optional embodiment, the determining of the shadow body corresponding to the three-dimensional model based on the first position information includes: determining a spherical area with each target position point as the center and a radius of a first preset radius based on the position information corresponding to the first target position point and the second target position point in the first target reference position point in the first position information; in response to the distance between the first target position point and the second target position point being less than or equal to a preset distance threshold, merging the spherical area corresponding to the first target position point and the spherical area corresponding to the second target position point to obtain the shadow body; wherein the preset distance threshold is determined based on the first preset radius.
[0010] In an optional embodiment, it further includes: in response to the distance between the first target position point and the second target position point being greater than the preset distance threshold, the spherical area corresponding to the first target position point and the spherical area corresponding to the second target position point are respectively used as two components of the shadow body.
[0011] In an optional embodiment, the display shadow intensity corresponding to the target vertex is determined based on the second position information of the target vertex in the virtual three-dimensional space and the first position information corresponding to the shadow body, including: for any target vertex, based on the second position information of the target vertex and the first reference position corresponding to the first target position point in the first position information, determining the first distance between the target vertex and the first target position point; and based on the second position information of the target vertex and the second reference position corresponding to the second target position point in the first position information, determining the second distance between the target vertex and the second target position point; determining the first shadow intensity and the second shadow intensity corresponding to the first distance and the second distance respectively, and superimposing the first shadow intensity and the second shadow intensity to obtain the display shadow intensity corresponding to the target vertex.
[0012] In an optional embodiment, determining the shadow body corresponding to the three-dimensional model based on the first position information includes: based on the position information corresponding to the first target position point and the second target position point in the first target reference position point in the first position information, determining a capsule body area with the first target position point and the second target position point as internal fixed points and a hemispherical radius of a second preset radius; using the capsule body area as the shadow body; wherein the internal fixed points are the centers of the two hemispherical areas corresponding to the capsule body, respectively, and the line between the two internal fixed points is the central axis of the cylindrical area in the capsule body.
[0013] In an optional embodiment, it also includes: in response to the height change rate of the projection surface in the virtual three-dimensional space being greater than a preset height change rate threshold, determining, for each area point on the surface of the shadow body, a second height difference between the first target position point or the second target position point and the area point in the three-dimensional virtual space; based on the second height difference corresponding to the area point, performing height adjustment processing on the height of the area point, and obtaining an updated shadow body based on the height processing results corresponding to each area point.
[0014] In an optional embodiment, based on the second position information of the target vertex in the virtual three-dimensional space and the first position information corresponding to the shadow body, the display shadow intensity corresponding to the target vertex is determined, including: for any target vertex, based on the second position information of the target vertex and the first position information of the first target reference position point, determining the sub-area to which the target vertex belongs in the shadow body; in response to the sub-area being the hemispherical area of the shadow body, determining the first distance between the target vertex and the inner fixed point in the hemispherical area, and determining the display shadow intensity corresponding to the target vertex based on the first distance; or, in response to the sub-area being the cylindrical area of the shadow body, determining the second distance between the target vertex and the central axis of the cylinder, and determining the display shadow intensity corresponding to the target vertex based on the second distance.
[0015] In an optional embodiment, determining a shadow body corresponding to the three-dimensional model for the three-dimensional model in the virtual three-dimensional space includes: in response to the current rendering environment meeting a first preset condition, determining a shadow body corresponding to the three-dimensional model for the three-dimensional model in the virtual three-dimensional space.
[0016] In an optional embodiment, the method further includes: in response to the current rendering environment meeting a second preset condition, determining the lighting direction of the three-dimensional model and a second target reference position point of the three-dimensional model on a preset projection plane; wherein the projection plane is a virtual plane determined based on the current position of the three-dimensional model; for any vertex in the three-dimensional model, based on the reference direction between the vertex and the second target reference position point, and the lighting direction, performing a position offset adjustment on the second target reference position point to obtain the target projection point of the vertex on the projection plane; based on the target positions of the target projection points corresponding to each vertex, determining the projection display range of the three-dimensional model on the projection plane, and rendering the projection plane based on the projection display range to obtain the shadow rendering result of the three-dimensional model on the projection plane.
[0017] In an optional embodiment, for any vertex, the following method is used to determine the reference direction between the vertex and the second target reference position point: for any vertex in the three-dimensional model, based on the first position of the vertex in the virtual three-dimensional space and the second position of the second target reference position point in the virtual three-dimensional space, the reference direction between the vertex and the second target reference position point is determined; based on the reference direction between the vertex and the second target reference position point and the illumination direction, the second target reference position point is position-offset adjusted to obtain the target position of the vertex on the projection plane in the virtual three-dimensional space, including: determining the offset between the reference direction and the illumination direction; and based on the offset, the second position of the second target reference position point is position-offset adjusted to obtain the target position of the target projection point of the vertex on the projection plane.
[0018] In an optional embodiment, rendering the projection plane based on the projection display range to obtain a shadow rendering result of the three-dimensional model on the projection plane includes: in response to the existence of an occlusion model on the projection plane under the projection display range, determining an occlusion area of the occlusion model under the projection display range; for each target projection point in the occlusion area, determining the distance between each target projection point and the vertex of the occlusion model in the vertical direction in the virtual three-dimensional space, and determining the display shadow intensity corresponding to each target projection point based on the distance corresponding to each target projection point; determining the shadow rendering effect of the three-dimensional model on the projection plane based on the display shadow intensity corresponding to each target projection point on the projection plane, and rendering the projection plane based on the shadow rendering effect to obtain a shadow rendering result of the three-dimensional model on the projection plane.
[0019] In an optional embodiment, rendering the projection plane based on the projection display range to obtain the shadow rendering result of the three-dimensional model on the projection plane includes: for any of the target projection points, determining the display shadow intensity of the target projection point on the projection plane based on the height value of the vertex corresponding to the target projection point in the three-dimensional model in the virtual three-dimensional space; rendering the projection plane based on the display shadow intensity corresponding to each of the vertices to obtain the shadow rendering result of the three-dimensional model on the projection plane.
[0020] In the second aspect, an embodiment of the present disclosure also provides a shadow rendering device for a three-dimensional model, including: a first determination module, used to determine a shadow body corresponding to the three-dimensional model for the three-dimensional model in a virtual three-dimensional space; the shadow body is used to indicate the projection rendering range of the three-dimensional model when it is projected on the projection surface of a preset object in the virtual three-dimensional space; a second determination module, used to determine the display shadow intensity corresponding to the target vertex based on the second position information of the target vertex in the virtual three-dimensional space and the first position information corresponding to the shadow body in response to at least one target vertex on the preset object being located in the area where the shadow body is located; a third determination module, used to render the projection surface based on the display shadow intensity corresponding to the at least one target vertex to obtain the shadow rendering result of the three-dimensional model on the projection surface.
[0021] In an optional embodiment, when the first determination module determines a shadow body corresponding to a three-dimensional model in a virtual three-dimensional space, it is used to: determine a first target reference position point of the three-dimensional model; the first target reference position point includes the first target position point of the three-dimensional model, and a second target position point associated with the first target position point; based on the position information of the first target reference position point in the virtual three-dimensional space, determine the first position information of the shadow body corresponding to the three-dimensional model, and determine the shadow body corresponding to the three-dimensional model based on the first position information.
[0022] In an optional embodiment, when determining the first target reference position point of the three-dimensional model, the first determination module is used to: based on the type of the three-dimensional model, determine at least two support points corresponding to the three-dimensional model among multiple vertices of the three-dimensional model; and determine the at least two support points as the first target reference position point.
[0023] In an optional embodiment, when the first determination module determines the at least two support points as the first target reference position points, it is used to: determine whether the first height difference between the at least two support points in the three-dimensional virtual space is greater than a height difference threshold; in response to the first height difference being less than or equal to the height difference threshold, determine the at least two support points as the first target reference position points; in response to the first height difference being greater than the height difference threshold, determine a support point to be adjusted from the at least two support points, and determine a new position point based on the position information of the support point to be adjusted in the three-dimensional virtual space; determine the new position point and the non-to-be-adjusted support point among the at least two support points as the first target reference position point; wherein the new position point and the projection of the corresponding support point to be adjusted on the projection surface coincide with each other, and the first height difference between the new position point and the non-to-be-adjusted support point in the three-dimensional virtual space is less than or equal to the height difference threshold.
[0024] In an optional embodiment, when determining the first target reference position point of the three-dimensional model, the first determination module is used to: determine any support point of the three-dimensional model among multiple vertices of the three-dimensional model based on the type of the three-dimensional model; determine the any support point as the first target position point; determine the distance between the first target position point and the second target position point based on the lighting direction of the three-dimensional model and the height information of the three-dimensional model; and determine the second target position point based on the distance and the lighting direction.
[0025] In an optional embodiment, when the first determination module determines the shadow body corresponding to the three-dimensional model based on the first position information, it is used to: determine a spherical area with each target position point as the center and a radius of a first preset radius based on the position information corresponding to the first target position point and the second target position point in the first target reference position point in the first position information; in response to the distance between the first target position point and the second target position point being less than or equal to a preset distance threshold, merge the spherical area corresponding to the first target position point with the spherical area corresponding to the second target position point to obtain the shadow body; wherein, the preset distance threshold is determined based on the first preset radius.
[0026] In an optional embodiment, the first determination module is also used to: in response to the distance between the first target position point and the second target position point being greater than the preset distance threshold, use the spherical area corresponding to the first target position point and the spherical area corresponding to the second target position point as two components of the shadow body respectively.
[0027] In an optional embodiment, when the second determination module determines the display shadow intensity corresponding to the target vertex based on the second position information of the target vertex in the virtual three-dimensional space and the first position information corresponding to the shadow body, it is used to: for any target vertex, determine the first distance between the target vertex and the first target position point based on the second position information of the target vertex and the first reference position corresponding to the first target position point in the first position information; and determine the second distance between the target vertex and the second target position point based on the second position information of the target vertex and the second reference position corresponding to the second target position point in the first position information; determine the first shadow intensity and the second shadow intensity corresponding to the first distance and the second distance respectively, and superimpose the first shadow intensity and the second shadow intensity to obtain the display shadow intensity corresponding to the target vertex.
[0028] In an optional embodiment, when determining the shadow body corresponding to the three-dimensional model based on the first position information, the first determination module is used to: determine, based on the position information corresponding to the first target position point and the second target position point in the first target reference position point in the first position information, a capsule body area with the first target position point and the second target position point as internal fixed points and a hemispherical radius of a second preset radius; wherein the internal fixed points are the centers of the two hemispherical areas in the capsule body respectively corresponding to each other, and the line between the two internal fixed points is the central axis of the cylindrical area in the capsule body.
[0029] In an optional embodiment, the first determination module is also used to: in response to the height change rate of the projection surface in the virtual three-dimensional space being greater than a preset height change rate threshold, determine, for each area point on the surface of the shadow body, the second height difference between the first target position point or the second target position point and the area point in the three-dimensional virtual space; based on the second height difference corresponding to the area point, perform height adjustment processing on the height of the area point, and obtain an updated shadow body based on the height processing results corresponding to each area point.
[0030] In an optional embodiment, when the second determination module determines the display shadow intensity corresponding to the target vertex based on the second position information of the target vertex in the virtual three-dimensional space and the first position information corresponding to the shadow body, it is used to: for any target vertex, determine the sub-area to which the target vertex belongs in the shadow body based on the second position information of the target vertex and the first position information of the first target reference position point; in response to the sub-area being the hemispherical area of the shadow body, determine the first distance between the target vertex and the inner fixed point in the hemispherical area, and determine the display shadow intensity corresponding to the target vertex based on the first distance; or, in response to the sub-area being the cylindrical area of the shadow body, determine the second distance between the target vertex and the central axis of the cylinder, and determine the display shadow intensity corresponding to the target vertex based on the second distance.
[0031] In an optional embodiment, when the first determination module determines a shadow body corresponding to the three-dimensional model in the virtual three-dimensional space, it is used to: in response to the current rendering environment meeting the first preset condition, determine a shadow body corresponding to the three-dimensional model in the virtual three-dimensional space.
[0032] In an optional embodiment, the first determination module is also used to: in response to the current rendering environment meeting a second preset condition, determine the lighting direction of the three-dimensional model and the second target reference position point of the three-dimensional model on a preset projection plane; wherein the projection plane is a virtual plane determined based on the current position of the three-dimensional model; for any vertex in the three-dimensional model, based on the reference direction between the vertex and the second target reference position point, and the lighting direction, perform a position offset adjustment on the second target reference position point to obtain the target projection point of the vertex on the projection plane; based on the target positions of the target projection points corresponding to each vertex, determine the projection display range of the three-dimensional model on the projection plane, and render the projection plane based on the projection display range to obtain the shadow rendering result of the three-dimensional model on the projection plane.
[0033] In an optional embodiment, for any vertex, the following method is used to determine the reference direction between the vertex and the second target reference position point: for any vertex in the three-dimensional model, the reference direction between the vertex and the second target reference position point is determined based on the first position of the vertex in the virtual three-dimensional space and the second position of the second target reference position point in the virtual three-dimensional space; when the first determination module performs a position offset adjustment on the second target reference position point based on the reference direction between the vertex and the second target reference position point and the illumination direction to obtain the target position of the vertex on the projection plane in the virtual three-dimensional space, it is used to: determine the offset between the reference direction and the illumination direction; perform a position offset adjustment on the second position of the second target reference position point based on the offset to obtain the target position of the target projection point of the vertex on the projection plane.
[0034] In an optional embodiment, when the first determination module renders the projection plane based on the projection display range to obtain the shadow rendering result of the three-dimensional model on the projection plane, it is used to: determine the occlusion area of the occlusion model under the projection display range in response to the existence of an occlusion model on the projection plane under the projection display range; for each target projection point in the occlusion area, determine the distance between each target projection point and the vertex of the occlusion model in the vertical direction in the virtual three-dimensional space, and determine the display shadow intensity corresponding to each target projection point based on the distance corresponding to each target projection point; determine the shadow rendering effect of the three-dimensional model on the projection plane based on the display shadow intensity corresponding to each target projection point on the projection plane, and render the projection plane based on the shadow rendering effect to obtain the shadow rendering result of the three-dimensional model on the projection plane.
[0035] In an optional embodiment, when rendering the projection plane based on the projection display range to obtain the shadow rendering result of the three-dimensional model on the projection plane, the first determination module is used to: for any of the target projection points, determine the display shadow intensity of the target projection point on the projection plane based on the height value of the vertex corresponding to the target projection point in the three-dimensional model in the virtual three-dimensional space; render the projection plane based on the display shadow intensity corresponding to each of the vertices to obtain the shadow rendering result of the three-dimensional model on the projection plane.
[0036] In a third aspect, an optional implementation of the present disclosure further provides a computer device, a processor, and a memory, wherein the memory stores machine-readable instructions executable by the processor, and the processor is used to execute the machine-readable instructions stored in the memory. When the machine-readable instructions are executed by the processor, the machine-readable instructions perform the steps of the above-mentioned first aspect, or any possible implementation of the first aspect.
[0037] In a fourth aspect, an optional implementation of the present disclosure further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed, it executes the steps of the above-mentioned first aspect or any possible implementation of the first aspect.
[0038] The disclosed embodiments provide a method, apparatus, computer device, and storage medium for rendering shadows of a three-dimensional model. These methods determine the projection rendering range of the three-dimensional model on a projection surface by determining a corresponding shadow volume for the three-dimensional model. The method then combines the display shadow intensity determined using the second position information of each vertex within the projection rendering range with the first position information of the shadow volume to determine the different display shadow intensities when rendering the shadow effect at each vertex. Because the projection rendering range and the shadow rendering intensity of each vertex within the projection rendering range are taken into account when rendering the shadow effect for the three-dimensional model, the resulting shadow rendering effect has a natural transition and its position more closely matches the position of the three-dimensional model, resulting in a simulated shadow effect with greater realism.
[0039] In order to make the above-mentioned objectives, features and advantages of the present disclosure more obvious and easy to understand, preferred embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the following briefly introduces the drawings required for use in the embodiments. The drawings herein are incorporated into and constitute a part of the specification. These drawings illustrate embodiments consistent with the present disclosure and, together with the specification, are used to illustrate the technical solutions of the present disclosure. It should be understood that the following drawings only illustrate certain embodiments of the present disclosure and should not be regarded as limiting the scope. For those of ordinary skill in the art, other relevant drawings can be obtained based on these drawings without inventive effort.
[0041] Figure 1 A flowchart of a shadow rendering method for a three-dimensional model provided by some embodiments of the present disclosure is shown;
[0042] Figure 2 A schematic diagram showing a three-dimensional model provided by some embodiments of the present disclosure is shown;
[0043] Figure 3A schematic diagram showing a shadow volume provided by some embodiments of the present disclosure is shown;
[0044] Figure 4 A schematic diagram showing a spherical region provided by some embodiments of the present disclosure is shown;
[0045] Figure 5 A schematic diagram showing another shadow volume provided by some embodiments of the present disclosure is shown;
[0046] Figure 6 A schematic diagram showing a cross-sectional view of a shadow volume provided by some embodiments of the present disclosure;
[0047] Figure 7 shows a distribution diagram showing shadow intensity provided by some embodiments of the present disclosure;
[0048] Figure 8 A schematic diagram showing the relative positional relationship between a target vertex and a capsule shadow volume provided by some embodiments of the present disclosure;
[0049] Figure 9 A schematic diagram showing a projection volume and a shadow volume provided by some embodiments of the present disclosure is shown;
[0050] Figure 10 A schematic diagram showing a target projection point of any vertex in a three-dimensional model provided by some embodiments of the present disclosure on a projection plane;
[0051] Figure 11 A schematic diagram of a shadow rendering device for a three-dimensional model provided by some embodiments of the present disclosure is shown;
[0052] Figure 12 A schematic diagram of a computer device provided by some embodiments of the present disclosure is shown. DETAILED DESCRIPTION
[0053] In order to make the purpose, technical solutions and advantages of the embodiments of the present disclosure clearer, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, rather than all of the embodiments. The components of the embodiments of the present disclosure generally described and shown here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present disclosure is not intended to limit the scope of the present disclosure for protection, but merely represents the selected embodiments of the present disclosure. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without making creative work are within the scope of protection of the present disclosure.
[0054] Research has found that when rendering 3D models, to simulate the shadow effects produced in real environments, pseudo-shadows can be used. To simplify calculations, a shadow region can be determined around the base of the 3D model and rendered black, representing the shadow. This creates the illusion of a shadow around the base of the 3D model. However, shadows in real environments exhibit transitional changes, and this method of directly rendering monochromatic shadows results in unnatural shadow effects, resulting in poor realism when simulating shadow effects.
[0055] Based on the above research, the present disclosure provides a shadow rendering method for a three-dimensional model. By determining a corresponding shadow body for the three-dimensional model to determine the projection rendering range of the three-dimensional model on the projection surface, and then combining the display shadow intensity determined using the second position information of each vertex in the projection rendering range with the first position information of the shadow body, it is possible to determine the different display shadow intensities when rendering the shadow effect at each vertex. Because the projection rendering range and the shadow rendering intensity of each vertex within the projection rendering range are taken into account when rendering the shadow effect for the three-dimensional model, the resulting shadow rendering effect has a natural transition and the position is more consistent with the position of the three-dimensional model, so the simulated shadow effect has a higher degree of realism.
[0056] The defects in the above solutions are the results obtained by the inventors after practice and careful research. Therefore, the process of discovering the above problems and the solutions proposed by the present disclosure for the above problems below should be the contributions made by the inventors to the present disclosure during the disclosure process.
[0057] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, it does not need to be further defined or explained in subsequent drawings.
[0058] To facilitate understanding of this embodiment, a shadow rendering method for a three-dimensional model disclosed in an embodiment of the present disclosure is first introduced in detail. The execution subject of the shadow rendering method for a three-dimensional model provided in the embodiment of the present disclosure is generally a computer device with certain computing capabilities. The computer device includes, for example, a terminal device or a server or other processing device. The terminal device can be a user equipment (UE), a mobile device, a user terminal, a terminal, a cellular phone, a cordless phone, a personal digital assistant (PDA), a handheld device, a computing device, an in-vehicle device, a wearable device, etc. In some possible implementations, the shadow rendering method for a three-dimensional model can be implemented by a processor calling computer-readable instructions stored in a memory.
[0059] The shadow rendering method of the three-dimensional model provided by the embodiment of the present disclosure is described below. The shadow rendering method of the three-dimensional model provided by the embodiment of the present disclosure can be used to render the shadow effect of the three-dimensional model, and is specifically applied to rendering the overall shadow effect of the three-dimensional model. The three-dimensional model described here can be a model with dynamic changes, such as a virtual human figure or a game character, etc., or it can be a static model, such as a building, a tree, etc. Therefore, the shadow rendering method of the three-dimensional model provided by the embodiment of the present disclosure can be specifically applied to different application fields such as the production or generation of game screens, animation and film and television production, etc. After the shadow rendering effect is determined by the shadow rendering method provided by the embodiment of the present disclosure, the three-dimensional model and the determined shadow rendering effect can be further rendered, so that the three-dimensional model and the shadow effect displayed by the rendering can be made more realistic and reasonable.
[0060] See also Figure 1 FIG. 1 is a flowchart of a shadow rendering method for a three-dimensional model provided by some embodiments of the present disclosure, wherein the method includes steps S101 to S103, wherein:
[0061] S101: Determine a shadow volume corresponding to a three-dimensional model in a virtual three-dimensional space; the shadow volume is used to indicate a projection rendering range when the three-dimensional model is projected on a projection surface of a preset object in the virtual three-dimensional space;
[0062] S102: In response to at least one target vertex on the projection surface being located within the region where the shadow body is located, determining a display shadow intensity corresponding to the target vertex based on second position information of the target vertex in the virtual three-dimensional space and first position information corresponding to the shadow body;
[0063] S103: Rendering the projection surface based on the display shadow intensity corresponding to the at least one target vertex to obtain a shadow rendering result of the three-dimensional model on the projection surface.
[0064] The above S101 to S103 are described in detail below.
[0065] Regarding the above S101, the concepts of three-dimensional model, virtual three-dimensional space, and shadow volume are first explained. As mentioned above, the three-dimensional model can include virtual human figures, game characters, buildings, trees, etc., and specifically includes multiple vertices located on the surface of the three-dimensional model, and meshes formed by the interconnection relationship between the vertices. The multiple formed meshes can constitute the surface of the three-dimensional model. In the embodiment of the present disclosure, the three-dimensional model includes a virtual character as an example for explanation. See Figure 2 , which is a schematic diagram of a three-dimensional model provided in some embodiments of the present disclosure.
[0066] Since the three-dimensional model does not actually exist in the real physical space, in order to render the three-dimensional model, a corresponding virtual three-dimensional space can usually be determined to place the three-dimensional model in the virtual three-dimensional space. The virtual three-dimensional space can be predetermined or determined based on the three-dimensional model. For example, when determining that the virtual three-dimensional space is a three-dimensional space established with the x, y, and z axes, the plane where the lowest point of the virtual character's feet is located can be used as the plane where the x and y axes are located, and the height direction of the three-dimensional model is the z axis. Exemplarily, the shadow rendering method provided in the embodiment of the present disclosure is applied to a game, and the virtual three-dimensional space may include: a virtual scene in the game.
[0067] In addition to the 3D model, other objects can be placed in the virtual 3D space, such as undulating ground, steps, and pavement. Since these objects reside in the same virtual 3D space as the 3D model, the positional relationship between the 3D model and these objects within the same coordinate system can be determined. This positional relationship can then be used to determine whether these objects will be affected by the 3D model's shadows, as well as the shadow effects within the shadows. After determining the 3D model and the virtual 3D space, in one possible scenario, the current rendering environment can be evaluated to determine whether a corresponding shadow volume is determined for the 3D model.
[0068] Here, the shadow body is first explained. The shadow body is used to indicate the projection rendering range when the three-dimensional model is projected on the projection surface of the preset object in the virtual three-dimensional space. Among them, the preset object may include the objects described above that may be affected by the shadow of the three-dimensional model. Since the shadow is the result of light projecting onto an opaque object, when the virtual character stands on the ground, the shadow cast by the virtual character can be simulated and displayed on the ground; if the virtual character is close to the steps, a part of the shadow of the virtual character can also be displayed on the steps. For the preset object, the shadow rendering effect can be rendered on the surface. Here, the surface portion of the preset object exposed in the virtual three-dimensional space is used as the projection surface of the preset object described in the embodiment of the present disclosure.
[0069] Next, the current rendering environment and the determination of the corresponding shadow volume based on the current rendering environment are described. For example, the current rendering environment may involve two aspects, for example, the shadow rendering requirements for the 3D model and the computing power available from the computer device.
[0070] In a specific implementation, it can be determined whether the current rendering environment meets the first preset condition. For example, in the current shadow rendering requirements for a three-dimensional model, if only a shadow effect is rendered, such as when a virtual image shows a certain movement, because more attention is paid to the movement effect itself, and because the changes are relatively fast, there is no need to present the outline features of the virtual image in the shadow effect, so a shadow body can be determined for the three-dimensional model to determine the corresponding shadow rendering effect. Alternatively, from the perspective of a computer device, if the computing power that the computer device can provide for shadow effect rendering is limited, since the computing power required to use a shadow body to render the shadow effect of a three-dimensional model is relatively small, it is more appropriate to use a shadow body to determine the shadow rendering effect for the three-dimensional model in this case.
[0071] That is, the first preset condition includes but is not limited to two different conditions: the current demand for shadow rendering of the three-dimensional model is low, and the rendering only needs to display the shadow effect, and the computer device has limited computing power that can be provided for shadow effect rendering.
[0072] Furthermore, if the current rendering environment is determined not to meet the first preset condition, such as meeting the second preset condition, including but not limited to a high demand for shadow rendering of the 3D model, requiring shadow effects to present the outline features of the virtual image, or the computing power provided by the current computer device is sufficient to support more realistic shadow rendering of the 3D model, then another method may be used to determine the shadow rendering effect for the 3D model. This is described in detail below, and here the method of determining the shadow volume for the 3D model to render the shadow effect for the 3D model is first described.
[0073] In the case of determining a shadow volume corresponding to the three-dimensional model for the three-dimensional model in the virtual three-dimensional space, in a specific implementation, different shadow volumes may be determined for the three-dimensional model in different ways.
[0074] In an embodiment of the present disclosure, the following method is specifically provided to determine the shadow body: determine the first target reference position point of the three-dimensional model; the first target reference position point includes the first target position point of the three-dimensional model, and the second target position point associated with the first target position point; based on the position information of the first target reference position point in the virtual three-dimensional space, determine the first position information of the shadow body corresponding to the three-dimensional model, and determine the shadow body corresponding to the three-dimensional model based on the first position information.
[0075] Regarding the step of determining the first target reference position point of the three-dimensional model, the method of determining the first target reference point is different when the shadow body is determined to be different. The embodiment of the present disclosure describes the different situations of determining the first target reference position point when determining the meta-ball shadow body and the capsule shadow body. Figure 3 FIG. 1 is a schematic diagram of a shadow body provided by some embodiments of the present disclosure. Figure 3 (a) is a schematic diagram of a meta-sphere shadow volume, and (b) is a schematic diagram of a capsule shadow volume.
[0076] When determining the first target reference point of a 3D model, a vertex of the 3D model can be selected as the first target reference point. In a specific implementation, based on the type of the 3D model, at least two support points corresponding to the 3D model are determined from among the vertices of the 3D model; these at least two support points are then determined as the first target reference point. The two support points are the first and second target points described above.
[0077] Here, since shadows are generally rendered in a low position, such as in an area radiating near the bottom of a three-dimensional model, the support point of the three-dimensional model can be selected to determine the first target reference position point. For example, for a virtual character, the type of the three-dimensional model is a character, and the support point that can be determined is the foot. The bottom surface of the foot has a certain area, so different vertices at the center of the bottom surface of the two feet can be determined as the first target reference position point. Here, the vertex determined by any foot is used as the first target position point, and the correlation between the other determined second target position point and the first target position point is that they both belong to the support point.
[0078] In addition, for other three-dimensional models, such as game monster models, if the support point is the support point of the weapon on the ground or the support point of the tail on the ground, both can be determined as the first target reference position point of the three-dimensional model. Alternatively, for a three-dimensional model with multiple support points, multiple support points can also be used as the first target reference position point; here, the first target position point can be one of the support points, and the second target position point associated with the first target position point can be at least one other support point that is also a support point. Alternatively, in the case of only one support point, such as using a street lamp as a three-dimensional model, the support point of the street lamp on the ground, that is, the intersection with the ground, can also be used as the first target reference position point.
[0079] In one possible scenario, if the first height difference between the two support points of a 3D model in 3D virtual space is large, such as when a virtual character is running in a cartoon-like manner, with one foot on the ground and the other foot in the air, using a shadow volume to render the shadow of the foot in the air may result in the shadow area under the foot being too small, such as appearing as a gray dot, or even no shadow at all. In this case, in a continuous movement, such as when both feet were on the ground in the previous movement and one foot was in the air in the current movement, shadows may appear near both feet in the previous movement, while the shadow of the one foot in the current movement is reduced to a very small size or even disappears. This large difference also lacks consistency, making the displayed shadow effect less realistic.
[0080] Therefore, when determining at least two support points as the first target reference position points, the following method can be specifically adopted: determine whether the first height difference between the at least two support points in the three-dimensional virtual space is greater than the height difference threshold; in response to the first height difference being less than or equal to the height difference threshold, determine the at least two support points as the first target reference position points; in response to the first height difference being greater than the height difference threshold, determine the support point to be adjusted from the at least two support points, and determine a new position point based on the position information of the support point to be adjusted in the three-dimensional virtual space; determine the new position point and the non-to-be-adjusted support point among the at least two support points as the first target reference position point; wherein, the new position point and the projection of the corresponding support point to be adjusted on the projection surface coincide with each other, and the first height difference between the new position point and the non-to-be-adjusted support point in the three-dimensional virtual space is less than or equal to the height difference threshold.
[0081] For example, consider the case of two support points. To determine the first height difference between the two support points in a three-dimensional virtual space, the heights of the two support points in the corresponding coordinate system of the three-dimensional virtual space can be first obtained, and the calculated difference between the two heights can then be used as the first height difference. The height difference threshold can be determined based on actual conditions or empirically to ensure that the shadow determined using the two support points is realistic within this height difference threshold.
[0082] In one possible scenario, if the first height difference between the two support points is less than or equal to the height difference threshold, the two support points are determined as the first target reference position points. In another possible scenario, if the first height difference is greater than the height difference threshold, one of the two support points is adjusted. Here, the support point that needs to be adjusted is referred to as the support point to be adjusted. When determining the support point to be adjusted, a support point with a higher height can be used as the support point to be adjusted, such as the support point corresponding to the foot of the virtual character that is in the air when running.
[0083] When adjusting the support point to be adjusted, a new position point can be determined based on the height direction of the support point to be adjusted in the virtual three-dimensional space, that is, another position point on the projection surface that coincides with the projection of the support point to be adjusted. The new position point satisfies the condition that the first height difference with the support point not to be adjusted in the three-dimensional virtual space is less than or equal to the height difference threshold. This determines the new position point and the support point not to be adjusted as the first target reference position point, which can avoid the above-mentioned situation where the shadow rendering is unrealistic when the first height difference is too large.
[0084] For capsule shadow volumes, when determining the first target reference point for the 3D model, a similar method to that used for meta-sphere shadow volumes can be used. A support point can then be determined from the 3D model. Another position relative to this support point can then be determined, taking into account the lighting direction of the 3D model. This, along with the selected support point, serves as the first target reference point for the 3D model. Because the lighting direction is taken into account, the resulting shadow volume can reflect the lighting direction, resulting in a more realistic shadow rendering effect.
[0085] In a specific implementation, when determining the first target reference position point of the three-dimensional model, the following method can be specifically adopted: based on the type of the three-dimensional model, determine any support point of the three-dimensional model among multiple vertices of the three-dimensional model; determine the any support point as the first target position point; based on the lighting direction of the three-dimensional model and the height information of the three-dimensional model, determine the distance between the first target position point and the second target position point; based on the distance and the lighting direction, determine the second target position point.
[0086] For example, taking the three-dimensional model as a virtual character, the vertex of the center of the bottom surface of the left foot can be used as a support point, and then the support point is determined as the first target position point. Then, the lighting direction of the three-dimensional model is obtained, such as determining the lighting direction by the position of the virtual light source in the three-dimensional virtual space. When the lighting direction is determined, the length of the pseudo shadow on the ground can be estimated based on the angle between the lighting direction and the corresponding horizontal direction in the virtual three-dimensional space, and the height information of the three-dimensional model, as the distance between the first target position point and the second target position point. Specifically, when estimating, for example, the ratio between the height and the tangent value of the angle can be calculated as the obtained distance. In this way, in the horizontal direction corresponding to the lighting direction, the position point with the calculated distance from the first target position point can be determined as the second target position point.
[0087] Thus, for the meta-sphere shadow volume and capsule shadow volume described in the above examples, different methods can be used to determine the corresponding first target reference position point. Here, if there are other shadow volumes that can be used to indicate the rendering range of a three-dimensional model when projected on a projection surface, they are all within the scope of protection of the embodiments of the present disclosure. Because different shadow volumes have different methods for determining the first target reference position point, the above are merely a few different examples and do not limit the shadow rendering method provided by the embodiments of the present disclosure.
[0088] When determining a first target reference location point for a shadow volume, a shadow volume corresponding to the three-dimensional model can be determined based on the first position information of the first target reference location point in the virtual three-dimensional space. The following description will continue with the example of determining two different shadow volumes: a meta shadow volume and a capsule shadow volume.
[0089] First, a method for determining a fused sphere shadow volume is described in detail. In a specific implementation, the following method can be used: based on the position information corresponding to the first target location point and the second target location point in the first target reference location point in the first location information, a spherical region with each target location point as the center and a radius of a first preset radius is determined; in response to the distance between the first target location point and the second target location point being less than or equal to a preset distance threshold, the spherical region corresponding to the first target location point is merged with the spherical region corresponding to the second target location point to obtain the shadow volume; wherein the preset distance threshold is determined based on the first preset radius.
[0090] Taking the three-dimensional model as an example of a virtual character, when determining the first preset radius, the radius selected when the spherical area determined by the first preset radius can wrap the feet can be determined as the first preset radius. Alternatively, the first preset radius of a suitable size can be selected based on actual conditions or experience. Taking the first target position point as an example, when the first target position point is used as the center of the sphere and the first preset radius is used as the radius to determine the spherical area, the spherical area is obtained as follows Figure 4 shown.
[0091] The target position corresponding to the three-dimensional model includes a first target position point and a second target position point, so two different spherical areas can be determined with the first target position point and the second target position point as the center and the first preset radius as the radius.
[0092] In one possible case, if the distance between the first target location point and the second target location point is relatively close, for example, less than or equal to twice the first preset radius, the two spherical areas respectively determined by the first target location point and the second target location point may intersect or be tangent to each other. Here, twice the first preset radius is used as the preset distance threshold to determine whether the two obtained spherical areas have an intersecting area. If there is an intersecting area, the two spherical areas are fused to obtain the following: Figure 3 The meta-ball shadow volume shown in (a).
[0093] In another possible case, if the distance between the first target location point and the second target location point is far, for example, greater than the preset distance threshold described above, there will be no intersection between the two spherical areas. In this case, the spherical area corresponding to the first target location point and the spherical area corresponding to the second target location point can be used as two components of the shadow volume. For example, see Figure 5 FIG. 1 is a schematic diagram of another shadow body provided by some embodiments of the present disclosure. The shadow body provided here is similar to Figure 3 Here, this shadow volume can be used as a special meta-ball shadow volume.
[0094] Next, a method for determining a meta-sphere shadow volume is described in detail. In a specific implementation, the following method can be used: based on the position information corresponding to the first target position point and the second target position point in the first target reference position point in the first position information, a capsule region with the first target position point and the second target position point as inner fixed points and a hemispherical radius of a second preset radius is determined; the capsule region is used as the shadow volume; wherein the two inner fixed points are the centers of the two hemispherical regions of the capsule, respectively, and the line connecting the two inner fixed points is the central axis of the cylindrical region of the capsule.
[0095] For example, see Figure 6 The figure shows a schematic diagram of a cross-sectional view of a shadow volume provided by some embodiments of the present disclosure. The first target point is P0, the second target point is P1, and the second preset radius is r2. The first target point P0 is the center of the left hemispherical area, so it is located at the center of the left semicircle in the plan view. The second target point is located at the center of the right semicircle in the cross-sectional view. The line connecting the two inner fixed points is the central axis of the cylindrical area.
[0096] In one possible scenario, to ensure that shadows are projected on a undulating projection surface, the shadow volume can be scaled in the virtual 3D space's height direction when determining the shadow volume. The resulting shadow volume shape is then updated to a vertically elongated capsule shadow volume. This allows the shadow to be confined within the capsule shadow volume, preventing truncation of the displayed shadow, which would result in a smooth edge and reduced realism.
[0097] In a specific implementation, the following method can be specifically adopted: in response to the height change rate of the projection surface in the virtual three-dimensional space being greater than a preset height change rate threshold, for each area point on the surface of the shadow body, the second height difference between the first target position point or the second target position point and the area point in the three-dimensional virtual space is determined; based on the second height difference corresponding to the area point, the height of the area point is height-adjusted, and based on the height processing results corresponding to each area point, an updated shadow body is obtained.
[0098] When determining whether the projection surface exhibits significant fluctuations, the height change rate of the projection surface in the virtual three-dimensional space can be specifically determined. Since the shadow volume is adjusted in the height direction, the height range of the shadow volume projected on the projection surface can be determined based on the previously determined shadow volume, and whether significant fluctuations exist within this range. Within this range, the height value of each vertex can be determined using the coordinate system corresponding to the virtual three-dimensional space. The height change rate can then be determined by determining the amplitude of the change in height at adjacent vertices, or the amplitude of the change between the highest and lowest points. For example, if the projection surface exhibits continuous steep slopes, this will be reflected in the height change rate, for example, if the height difference between adjacent vertices is 5 height units. A preset height change rate threshold can then be used to measure whether the projection surface exhibits significant fluctuations. For example, a height difference between adjacent vertices of less than 2 height units indicates minimal fluctuations. If the height change rate determined for the projection surface exceeds the height change rate threshold, it can be considered that the projection surface exhibits significant fluctuations.
[0099] In this case, for each region point on the shadow volume surface, a second height difference between the first target point or the second target point and the region point in the three-dimensional virtual space can be determined. As can be seen from the above description, the second target point is actually located in the same plane as the first target point and has the same height. Therefore, when determining the second height difference, the height value corresponding to either the first or second target point can be used for calculation.
[0100] For any area point, taking the first target position point as an example, when determining the second height difference corresponding to the area point, since the height corresponding to the area point may be higher than the height of the first target position point, it may also be lower than the height of the first target position point. Therefore, when calculating the second height difference, the second height difference specifically satisfies the following formula (1):
[0101] Δh=height(p)-height(P0) (1)
[0102] Where p represents the region point, P0 represents the first target position point, height(·) represents the corresponding height, and Δh represents the second height difference. The second height difference is a relative height difference and therefore has positive and negative properties.
[0103] When the second height difference is determined, the height of the point in the area can be adjusted. Since the second height difference has positive and negative properties, the results corresponding to the two height adjustment processes when the second height difference is positive and the second height difference is negative can be selected, and the results of the height adjustment processes with different positive and negative properties from the second height difference can be eliminated through the positive and negative shape judgment in the formula, so as to reduce the judgment of positive and negative properties while ensuring the accuracy of the height adjustment process. Specifically, when determining the result of the height adjustment process, the following formula (2) can be used:
[0104] result=negativeResult+positiveResult (2)
[0105] Among them, positiveResult represents the height adjustment processing result when the second height difference is positive, negativeResult represents the height adjustment processing result when the second height difference is negative, and result is the determined height adjustment processing result.
[0106] positiveResult=(positiveScale×Δh+height(p0))×step(Δh,0) (3)
[0107] negativeResult=(negativeScale×Δh+height(P0))×(1-step(Δh,0)) (4)
[0108] Where positiveScale and negativeScale are height adjustment scaling parameters, which are determined based on actual needs. When the second height difference represented by Δh is a positive number, step(Δh, 0) is 1; when the second height difference represented by Δh is a positive number, step(Δh, 0) is 0.
[0109] After determining the height processing results corresponding to each area point, the original shadow volume can be updated to obtain an updated shadow volume.
[0110] In this way, the shadow volume corresponding to the three-dimensional model is obtained using the first position information of the first target reference position point in the virtual three-dimensional space. The above-mentioned methods for determining the shadow volume are only some examples of the embodiments of the present disclosure. If there are other possible methods for determining the shadow volume, they are also within the scope of protection of the embodiments of the present disclosure.
[0111] With respect to the above-mentioned S102, when determining a shadow body for the three-dimensional model, for at least one target vertex on the projection surface, if the target vertex is located within the region where the shadow body is located, the shadow of the three-dimensional model can be rendered at the target vertex. In addition, to make the rendered shadow more realistic, the transition effect of the shadow can be displayed by varying the display shadow intensity. Here, the display shadow intensity is, for example, a grayscale value. When determining the display shadow intensity of each target vertex, it can be specifically determined based on the second position information of the target vertex in the virtual three-dimensional space and the first position information corresponding to the shadow body.
[0112] The first position information corresponding to the shadow body specifically includes first reference position information corresponding to the first target position point in the shadow body, and second reference position information corresponding to the second target position point.
[0113] In specific implementations, due to the different shadow volumes selected, the methods for determining the display shadow intensity for the target vertex using the first position information corresponding to the shadow volume are also different. Below, the methods for determining the display shadow intensity are described for the two types of shadow volumes described in the above steps: meta shadow volume and capsule shadow volume.
[0114] First, the case where the shadow body includes a meta-sphere shadow body is explained. In a specific implementation, when determining the display shadow intensity corresponding to the target vertex, the following method can be used: for any target vertex, based on the second position information of the target vertex and the first reference position corresponding to the first target position point in the first position information, determine the first distance between the target vertex and the first target position point; and based on the second position information of the target vertex and the second reference position corresponding to the second target position point in the first position information, determine the second distance between the target vertex and the second target position point; determine the first shadow intensity and the second shadow intensity corresponding to the first distance and the second distance, respectively, and superimpose the first shadow intensity and the second shadow intensity to obtain the display shadow intensity corresponding to the target vertex.
[0115] Specifically, in a meta-sphere shadow volume, a spherical area defined by a first target position point is used as an example. When indicating the projection rendering range, the shadow volume determines the target vertex within the shadow volume as the vertex for rendering the shadow effect. Therefore, if a target vertex on the projection surface is determined to be within the shadow volume's area, the shadow of the 3D model can be rendered at the target vertex.
[0116] When it is determined that a shadow is rendered for any target vertex, the second position information of the target vertex and the first reference position information corresponding to the first target position point in the first position information can be used to determine the first distance between the target vertex and the first target position point. In a specific implementation, for the target vertices in the area where the shadow body is located, it is considered that the vertices farther away from the center, that is, the target vertices farther away from the first target position point, are less affected by the shadow of the three-dimensional model, and accordingly the intensity of the displayed shadow is determined to be weaker, which is reflected in the grayscale image as the larger the value of the grayscale image, the more white the displayed color is; and for the target vertices farther away from the first target position point, the greater the influence of the shadow of the three-dimensional model, the intensity of the displayed shadow is determined to be stronger, which is reflected in the grayscale image as the smaller the value of the grayscale image, the more black the displayed color is. This is also similar to the shadow effect of real objects in real scenes, which is manifested as the closer to the object on the projection surface, the darker the shadow color, and the farther away from the object, the lighter the shadow color.
[0117] After determining the first distance between the target vertex and the first target location, the first shadow intensity of the target vertex at that location can be determined based on the relationship between the determined first distance and the displayed shadow intensity. For the spherical area defined by the first target location in the meta-sphere shadow volume, the displayed shadow intensity corresponding to each target vertex can be determined using the following formula (5), for example:
[0118] I=R x / distance(Point, Center) x (5)
[0119] Where I is the first shadow intensity, R is the first preset radius, Point represents the target vertex, Center represents the first target location, and distance(Point, Center) represents the first distance between the target vertex and the first target location. x controls the shadow attenuation curve.
[0120] In fact, for the first shadow intensity calculated by the above formula (5), when the target vertex is close to the first target position point, the first shadow intensity tends to infinity; when the target vertex is far away from the first target position point, the first shadow intensity tends to 0 but will not be equal to 0. In addition, since only the target vertices inside the shadow body will be rendered with the shadow effect of the three-dimensional model, the shadow will be suddenly cut off at the edge of the shadow body, which is less realistic.
[0121] Therefore, when determining the relationship between the first distance and the displayed shadow intensity, the displayed shadow intensity can be normalized such that the first distance is 0 and the grayscale value is 0 (black), respectively, and the displayed shadow intensity is lowest when the first distance is the first preset radius, such as the grayscale value is 255 (white). In this way, as the target vertex gradually increases in the first distance, the corresponding displayed shadow intensity gradually decreases and is weakened to a minimum at the edge of the shadow body, which has a transitional nature and can make the rendered shadow more realistic.
[0122] The above description only describes the spherical area determined by the first target position in the meta-sphere shadow volume. However, for the spherical areas corresponding to the first and second target positions, after the spherical areas are fused, the distribution diagram showing the shadow intensity observed in the front view is as follows: Figure 7 The display shadow intensity corresponding to each target vertex on the same line is the same, and the display shadow intensity corresponding to the target vertex on the outer side of the line is smaller.
[0123] against Figure 7 In the distribution diagram of displayed shadow intensity shown in FIG, for a target vertex located in only one spherical region, such as points p0 and p1 shown in the figure, the corresponding first shadow intensity or second shadow intensity is determined based solely on the first distance or second distance determined in the spherical region, and used as the displayed shadow intensity. For a target vertex located in two spherical regions, such as point p3 shown in the figure, the corresponding first shadow intensity and second shadow intensity are determined in the two spherical regions using the first distance and second distance determined respectively, and then the displayed shadow intensity corresponding to the target vertex is determined by superposition.
[0124] Secondly, the case where the shadow body includes a capsule shadow body is explained. In a specific implementation, when determining the display shadow intensity corresponding to the target vertex, the following method can be used: for any target vertex, based on the second position information of the target vertex and the first position information of the first target reference position point, determine the sub-area to which the target vertex belongs in the shadow body; in response to the sub-area being the hemispherical area of the shadow body, determine the first distance between the target vertex and the inner fixed point in the hemispherical area, and determine the display shadow intensity corresponding to the target vertex based on the first distance; or, in response to the sub-area being the cylindrical area of the shadow body, determine the second distance between the target vertex and the central axis in the cylinder, and determine the display shadow intensity corresponding to the target vertex based on the second distance.
[0125] Similar to meta shadow volumes, capsule shadow volumes indicate the projection rendering range by defining the target vertex within the shadow volume as the vertex to be rendered. When determining the displayed shadow intensity, the corresponding displayed shadow intensity is also determined by distance. Since capsule shadow volumes specifically include a central axis connected by internal fixed points, the displayed shadow intensity of each target vertex can be determined by determining the distance between each target vertex and the central axis.
[0126] When determining the distance between each target vertex and the central axis, see Figure 8 As shown, it is a schematic diagram of the relative position relationship between the target vertex and the capsule shadow body provided by some embodiments of the present disclosure. Using the first target position point P0 and the second target position point P1, the capsule shadow body can be divided into three parts, namely area A, area B and area C in the figure. Area A and area C are hemispherical areas, and area B is a cylindrical area. Taking a target vertex p0 in area A as an example, the distance to the central axis, that is, the distance L1 between the target vertex p0 and the first target position point P0, is used as the second distance. For a target vertex p1 in area B, its distance to the central axis, that is, the distance L2 between the target vertex p1 and the central axis, is used as the second distance. For the target vertex in area C, similar to the target vertex in area A, the distance to the second target position point is determined as the second distance.
[0127] Once the second distance is determined for the target vertex, the corresponding displayed shadow intensity can be determined using normalization and other steps, similar to the aforementioned meta shadow volume. Similarly, using normalization and other steps can ensure that the shadows of the target vertices within the capsule shadow volume's region change continuously and transition naturally, without the transition being minimized at the edges. This can also make the rendered shadows appear more realistic.
[0128] Regarding the above S103, in the above steps, for each vertex on the projection surface, the target vertex used to render the shadow and the display shadow intensity corresponding to each target vertex are determined through the shadow body. Therefore, the shadow effect of the projection surface can be rendered by the display shadow intensity corresponding to at least one target vertex, and the shadow rendering result of the three-dimensional model on the projection surface is obtained.
[0129] In a specific implementation, a projection body that wraps the shadow body may also be included to render shadow effects for each target vertex in the shadow body. Figure 9 As shown, it is a schematic diagram of the projection body and shadow body provided by some embodiments of the present disclosure. For the convenience of explanation, the shadow body is represented by a spherical shadow body. The center of the projection body and the center of the shadow body are at the same position. There is a certain gap between the projection body and the shadow body, but in fact the gap is small. For the target vertex determined in the shadow body and the display shadow intensity corresponding to the target vertex, the position of the projection body on the line connecting the center of the sphere and the target vertex can be shadow rendered for the target vertex according to the display shadow intensity. In this way, for multiple target vertices determined in the shadow body, after the shadow rendering of the projection body, they can be combined together to present the shadow projection effect of the three-dimensional model, that is, the shadow rendering result of the three-dimensional model on the projection surface.
[0130] In this way, using a shadow body to render the shadow of a three-dimensional model on a projection surface can take into account the position of the three-dimensional model and the influence of the lighting direction on the projected shadow. When rendering the shadow, the transition effect of the shadow and the weakening treatment at the shadow boundary are also taken into account, thus making the displayed shadow more realistic. In addition, because the shadow body can determine the target vertex to be rendered on the projection surface by limiting the range, when there are undulations on the projection surface, it can also be determined whether to render the shadow by judging whether the vertex on it falls within the interior of the shadow body. Therefore, it is more suitable for scenes with undulations on the projection surface.
[0131] In another embodiment of the present disclosure, for the case where the current rendering environment described above meets the second preset condition, since there may be sufficient computing power, or it is necessary to render a clearer contour feature of the three-dimensional model, the shadow rendering result of the three-dimensional model can also be obtained by rendering in the following manner: determining the illumination direction of the three-dimensional model and the second target reference position point of the three-dimensional model on a preset projection plane; wherein the projection plane is a virtual plane determined based on the current position of the three-dimensional model; for any vertex in the three-dimensional model, based on the reference direction between the vertex and the second target reference position point, and the illumination direction, the second target reference position point is adjusted for a position offset to obtain the target projection point of the vertex on the projection plane; based on the target positions of the target projection points corresponding to each vertex, the projection display range of the three-dimensional model on the projection plane is determined, and the projection plane is rendered based on the projection display range to obtain the shadow rendering result of the three-dimensional model on the projection plane.
[0132] When rendering shadows for a 3D model using this method, the model's outline is determined in the direction of the lighting. This outline is a flat surface that also reflects the lighting direction, so it conforms to the plane of the 3D model, creating a shadow effect that reflects the model's outline in the direction of the lighting.
[0133] Among them, the method of determining the direction of illumination can be found in the description of the corresponding position above, and will not be repeated here. The preset projection plane is different from the projection plane described in the above embodiment. It is specifically determined according to the current position of the three-dimensional model. For example, the plane where a support point of the three-dimensional model is located in the virtual three-dimensional space is used as the projection plane. Compared with the projection plane, the projection plane is a virtual plane and is not composed of the surfaces of objects such as the ground and steps. Since it is a plane, it does not have ups and downs.
[0134] The second target reference point of the three-dimensional model on the projection plane can be any point on the projection plane. Figure 10 The figure shows a schematic diagram of using a second target reference position point to determine a target projection point on a projection plane for any vertex in a three-dimensional model using some embodiments of the present disclosure. The second target reference point determined on the projection plane is point O, any vertex in the three-dimensional model is point V, and the illumination direction is For ease of understanding, the starting point of the illumination direction is combined with point V, which can be understood as the influence of the illumination direction on the direction of the shadow cast by vertex point V. That is, the point projected on the projection plane by vertex point V in the illumination direction is point Y, which is also the target projection point of vertex point V. Therefore, when determining the target projection point of each vertex on the projection plane, it can be determined by determining the offset between the target projection point of the vertex in the illumination direction and the second target reference point. For ease of calculation, the normal vector on the projection plane is also determined at point O.
[0135] In a specific implementation, for any vertex, a reference direction between the vertex and the second target reference point can be determined using the following method: For any vertex in the 3D model, the reference direction between the vertex and the second target reference point is determined based on the vertex's first position in the virtual 3D space and the second position of the second target reference point in the virtual 3D space. Then, using the reference direction determined for the vertex and the illumination direction, a position offset adjustment can be performed on the second target reference point to obtain the target projection point of the vertex on the projection plane.
[0136] Here, in order to determine the offset between the target projection point of the vertex in the illumination direction and the second target reference point, the offset between the reference direction and the illumination direction can be determined first, and then the second position of the second target reference position point is adjusted based on the offset to obtain the target position of the target projection point of the vertex on the projection plane.
[0137] Next, use Figure 10 The schematic diagram shown illustrates this step through the computational relationship between the vectors formed between the points. First, the vector formed by the vertex V and the second target reference position point O, that is, the reference direction described above, and the vector corresponding to the illumination direction satisfy the following formula (6), that is, the projection formula:
[0138]
[0139] Where t represents the offset between the reference direction and the illumination direction, and can also indirectly represent the offset between the vertex V and the second target reference position point O in the illumination direction. Using the above formula (6), the formula for calculating the offset t can be deduced, namely the following formula (7):
[0140]
[0141] In this way, by calculating the offset t, the second position of the second target reference position point can be adjusted to determine the target position of the target projection point of the vertex on the projection plane, such as the target position of the target projection point Y corresponding to the vertex V on the projection plane.
[0142] As for the shadow rendering method described above, the projection display range for rendering shadows on the projection plane can be determined for the 3D model, but there is no specific shadow intensity corresponding to each target projection point. Here, shadows of the same color can be rendered within the projection display range, such as all rendered black. This method is relatively simple, but it obviously does not conform to the phenomenon of shadows with light and dark variations in real scenes. Therefore, it is possible to further update and optimize the shadow rendering effect of the 3D model within the determined projection display range. Specifically, this can be done by, but not limited to, the following methods.
[0143] In one possible case, if there is an occlusion model within the projection display range of the projection plane, such as an opaque model such as a step, the display shadow intensity of each target projection point within the projection display range can be adjusted according to the position corresponding to the surface vertex of the opaque model within the projection display range.
[0144] In a specific implementation, the following method can be adopted: in response to the existence of an occlusion model on the projection plane under the projection display range, the occlusion area of the occlusion model under the projection display range is determined; for each target projection point in the occlusion area, the distance between each target projection point and the vertex of the occlusion model in the vertical direction in the virtual three-dimensional space is determined, and based on the distance corresponding to each target projection point, the display shadow intensity corresponding to each target projection point is determined; based on the display shadow intensity corresponding to each target projection point on the projection plane, the shadow rendering effect of the three-dimensional model on the projection plane is determined.
[0145] Specifically, within the projection display range, an occlusion region of the occlusion model surface can be determined. For each target projection point within the occlusion region, i.e., the target projection point on the projection plane, the distance between the target projection point and the vertex of the occlusion model in the direction perpendicular to the virtual three-dimensional space can be determined. In other words, the distance determined here is the distance between the vertex of the occlusion model and the projection plane in the direction perpendicular to the target projection point.
[0146] Among them, when using the distance obtained here to determine the display shadow intensity corresponding to each target projection point, the following rules can be specifically followed: the longer the distance corresponding to the target projection point, the lower the display shadow intensity corresponding to the target projection point; the shorter the distance corresponding to the target projection point, the higher the display shadow intensity corresponding to the target projection point. That is, in the projection display range, if the distance between the vertex of the occluding model surface and the projection plane is large, for example, the height of the vertex is high, then the display shadow intensity is determined to be weaker accordingly; if the distance between the vertex of the occluding model surface and the projection plane is small, for example, the height of the vertex is low, then the display shadow intensity is determined to be stronger accordingly. This is also in line with the law of change in shadow intensity displayed on the surface of other objects in real scenes.
[0147] In this way, after determining the display shadow intensity based on the distance corresponding to each target projection point, the shadow rendering effect of the 3D model on the projection plane can be determined. The shadow rendering effect on the projection plane described here includes the shadow rendering effect determined in the area of the projection plane that is not obscured by the obstructing model, as well as the shadow rendering effect reflected on the obstructing model surface within the obscured area. Therefore, after rendering the shadow rendering effect, the complete shadow rendering result of the 3D model can be displayed on the projection plane and the obscured model surface.
[0148] In another possible case, the shadow rendering effect on the projection surface can be adjusted by following the shadow display rule in real scenes, that is, the shadow intensity corresponding to the projection at a higher point of the object is weaker, and the shadow intensity corresponding to the projection at a lower point of the object is stronger.
[0149] In a specific implementation, for any of the target projection points, the display shadow intensity of the target projection point on the projection plane can be determined based on the height value of the vertex corresponding to the target projection point in the three-dimensional model in the virtual three-dimensional space; the projection plane is rendered based on the display shadow intensity corresponding to each of the vertices to obtain the shadow rendering result of the three-dimensional model on the projection plane.
[0150] Among them, when using the height value corresponding to the vertex to determine the display shadow intensity, the maximum height of each object in the virtual three-dimensional space can be referred to to predetermine the corresponding relationship between the height value and the display shadow intensity. For example, when determining that the tallest object in the virtual three-dimensional space is a building with a height of 100 units, it can be determined that the display shadow intensity determined at a height of 100 units is the lowest, and the display shadow intensity is the highest at a corresponding height of 0 units. The display shadow intensity corresponding to each unit height can be determined by normalization. In this way, there is a unified display shadow intensity determination standard for each object in the virtual three-dimensional space, and there will be no situation where the shadow intensity corresponding to the shadow rendered by the taller object is higher than that of the shadow rendered by the lower object when rendering the shadow, resulting in the rendered shadow rendering result violating the shadow display law in the real scene.
[0151] Therefore, after using the height value to determine the display shadow intensity of each target projection point on the projection plane, the position corresponding to each target projection point can be rendered on the projection plane according to the display shadow intensity corresponding to each target projection point to obtain the shadow rendering result of the three-dimensional model on the projection plane.
[0152] In this way, the contour features of the three-dimensional model in the lighting direction can be displayed in the shadow rendering result, and the intensity change effect of the shadow is also taken into account, so the displayed shadow rendering result is more realistic.
[0153] Those skilled in the art will understand that in the above-mentioned method of the specific implementation method, the writing order of each step does not mean a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of each step should be determined by its function and possible internal logic.
[0154] Based on the same inventive concept, the embodiment of the present disclosure also provides a shadow rendering device for a three-dimensional model corresponding to the shadow rendering method for a three-dimensional model. Since the principle of solving the problem by the device in the embodiment of the present disclosure is similar to the shadow rendering method for the three-dimensional model in the above-mentioned embodiment of the present disclosure, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.
[0155] Reference Figure 11 FIG. 1 is a schematic diagram of a shadow rendering device for a three-dimensional model provided by some embodiments of the present disclosure, wherein the device includes: a first determining module 111, a second determining module 112, and a third determining module 113; wherein,
[0156] A first determining module 111 is configured to determine a shadow volume corresponding to a three-dimensional model in a virtual three-dimensional space; the shadow volume is configured to indicate a projection rendering range of the three-dimensional model when projecting the three-dimensional model onto a projection surface of a preset object in the virtual three-dimensional space;
[0157] a second determining module 112 configured to, in response to at least one target vertex on the preset object being located within the region where the shadow body is located, determine a display shadow intensity corresponding to the target vertex based on second position information of the target vertex in the virtual three-dimensional space and first position information corresponding to the shadow body;
[0158] The third determining module 113 is configured to determine a shadow rendering effect of the three-dimensional model on the projection surface based on a display shadow intensity corresponding to the at least one target vertex.
[0159] In an optional embodiment, when determining a shadow body corresponding to a three-dimensional model in a virtual three-dimensional space, the first determination module 111 is used to: determine a first target reference position point of the three-dimensional model; the first target reference position point includes a first target position point of the three-dimensional model, and a second target position point associated with the first target position point; based on the position information of the first target reference position point in the virtual three-dimensional space, determine the first position information of the shadow body corresponding to the three-dimensional model, and determine the shadow body corresponding to the three-dimensional model based on the first position information.
[0160] In an optional embodiment, when determining the first target reference position point of the three-dimensional model, the first determination module 111 is used to: based on the type of the three-dimensional model, determine at least two support points corresponding to the three-dimensional model among multiple vertices of the three-dimensional model; and determine the at least two support points as the first target reference position point.
[0161] In an optional embodiment, when determining the at least two support points as the first target reference position points, the first determination module 111 is used to: determine whether the first height difference between the at least two support points in the three-dimensional virtual space is greater than a height difference threshold; in response to the first height difference being less than or equal to the height difference threshold, determine the at least two support points as the first target reference position points; in response to the first height difference being greater than the height difference threshold, determine a support point to be adjusted from the at least two support points, and determine a new position point based on the position information of the support point to be adjusted in the three-dimensional virtual space; determine the new position point and the non-to-be-adjusted support point among the at least two support points as the first target reference position point; wherein the new position point and the projection of the corresponding support point to be adjusted on the projection surface coincide with each other, and the first height difference between the new position point and the non-to-be-adjusted support point in the three-dimensional virtual space is less than or equal to the height difference threshold.
[0162] In an optional embodiment, when determining the first target reference position point of the three-dimensional model, the first determination module 111 is used to: determine any support point of the three-dimensional model among multiple vertices of the three-dimensional model based on the type of the three-dimensional model; determine the any support point as the first target position point; determine the distance between the first target position point and the second target position point based on the lighting direction of the three-dimensional model and the height information of the three-dimensional model; and determine the second target position point based on the distance and the lighting direction.
[0163] In an optional embodiment, when determining the shadow body corresponding to the three-dimensional model based on the first position information, the first determination module 111 is used to: determine a spherical area with each target position point as the center and a radius of a first preset radius based on the position information corresponding to the first target position point and the second target position point in the first target reference position point in the first position information; in response to the distance between the first target position point and the second target position point being less than or equal to a preset distance threshold, merge the spherical area corresponding to the first target position point with the spherical area corresponding to the second target position point to obtain the shadow body; wherein, the preset distance threshold is determined based on the first preset radius.
[0164] In an optional embodiment, the first determination module 111 is also used to: in response to the distance between the first target position point and the second target position point being greater than the preset distance threshold, use the spherical area corresponding to the first target position point and the spherical area corresponding to the second target position point as two components of the shadow body respectively.
[0165] In an optional embodiment, when the second determination module 112 determines the display shadow intensity corresponding to the target vertex based on the second position information of the target vertex in the virtual three-dimensional space and the first position information corresponding to the shadow body, it is used to: for any target vertex, determine the first distance between the target vertex and the first target position point based on the second position information of the target vertex and the first reference position corresponding to the first target position point in the first position information; and determine the second distance between the target vertex and the second target position point based on the second position information of the target vertex and the second reference position corresponding to the second target position point in the first position information; determine the first shadow intensity and the second shadow intensity corresponding to the first distance and the second distance respectively, and superimpose the first shadow intensity and the second shadow intensity to obtain the display shadow intensity corresponding to the target vertex.
[0166] In an optional embodiment, when determining the shadow body corresponding to the three-dimensional model based on the first position information, the first determination module 111 is used to: determine, based on the position information corresponding to the first target position point and the second target position point in the first target reference position point in the first position information, a capsule body area with the first target position point and the second target position point as internal fixed points and a hemispherical radius of a second preset radius; and use the capsule body area as the shadow body; wherein the internal fixed points are the centers of the two hemispherical areas in the capsule body, respectively, and the line between the two internal fixed points is the central axis of the cylindrical area in the capsule body.
[0167] In an optional embodiment, the first determination module 111 is also used to: in response to the height change rate of the projection surface in the virtual three-dimensional space being greater than a preset height change rate threshold, determine, for each area point on the surface of the shadow body, a second height difference between the first target position point or the second target position point and the area point in the three-dimensional virtual space; based on the second height difference corresponding to the area point, perform height adjustment processing on the height of the area point, and obtain an updated shadow body based on the height processing results corresponding to each area point.
[0168] In an optional embodiment, when the second determination module 112 determines the display shadow intensity corresponding to the target vertex based on the second position information of the target vertex in the virtual three-dimensional space and the first position information corresponding to the shadow body, it is used to: for any target vertex, determine the sub-area to which the target vertex belongs in the shadow body based on the second position information of the target vertex and the first position information of the first target reference position point; in response to the sub-area being the hemispherical area of the shadow body, determine the first distance between the target vertex and the inner fixed point in the hemispherical area, and determine the display shadow intensity corresponding to the target vertex based on the first distance; or, in response to the sub-area being the cylindrical area of the shadow body, determine the second distance between the target vertex and the central axis of the cylinder, and determine the display shadow intensity corresponding to the target vertex based on the second distance.
[0169] In an optional embodiment, when the first determination module 111 determines a shadow body corresponding to a three-dimensional model in a virtual three-dimensional space, it is used to: in response to the current rendering environment meeting a first preset condition, determine a shadow body corresponding to the three-dimensional model in the virtual three-dimensional space.
[0170] In an optional embodiment, the first determination module 111 is also used to: in response to the current rendering environment meeting a second preset condition, determine the lighting direction of the three-dimensional model and the second target reference position point of the three-dimensional model on a preset projection plane; wherein the projection plane is a virtual plane determined based on the current position of the three-dimensional model; for any vertex in the three-dimensional model, based on the reference direction between the vertex and the second target reference position point, and the lighting direction, perform a position offset adjustment on the second target reference position point to obtain the target projection point of the vertex on the projection plane; based on the target positions of the target projection points corresponding to each vertex, determine the projection display range of the three-dimensional model on the projection plane, and render the projection plane based on the projection display range to obtain the shadow rendering result of the three-dimensional model on the projection plane.
[0171] In an optional embodiment, for any vertex, the following method is used to determine the reference direction between the vertex and the second target reference position point: for any vertex in the three-dimensional model, the reference direction between the vertex and the second target reference position point is determined based on the first position of the vertex in the virtual three-dimensional space and the second position of the second target reference position point in the virtual three-dimensional space; when the first determination module 111 performs a position offset adjustment on the second target reference position point based on the reference direction between the vertex and the second target reference position point and the illumination direction to obtain the target position of the vertex on the projection plane in the virtual three-dimensional space, it is used to: determine the offset between the reference direction and the illumination direction; perform a position offset adjustment on the second position of the second target reference position point based on the offset to obtain the target position of the target projection point of the vertex on the projection plane.
[0172] In an optional embodiment, when rendering the projection plane based on the projection display range to obtain the shadow rendering result of the three-dimensional model on the projection plane, the first determination module 111 is used to: determine the occlusion area of the occlusion model under the projection display range in response to the existence of an occlusion model on the projection plane under the projection display range; for each target projection point in the occlusion area, determine the distance between each target projection point and the vertex of the occlusion model in the vertical direction in the virtual three-dimensional space, and determine the display shadow intensity corresponding to each target projection point based on the distance corresponding to each target projection point; determine the shadow rendering effect of the three-dimensional model on the projection plane based on the display shadow intensity corresponding to each target projection point on the projection plane, and render the projection plane based on the shadow rendering effect to obtain the shadow rendering result of the three-dimensional model on the projection plane.
[0173] In an optional embodiment, when rendering the projection plane based on the projection display range to obtain the shadow rendering result of the three-dimensional model on the projection plane, the first determination module 111 is used to: for any of the target projection points, determine the display shadow intensity of the target projection point on the projection plane based on the height value of the vertex corresponding to the target projection point in the three-dimensional model in the virtual three-dimensional space; render the projection plane based on the display shadow intensity corresponding to each of the vertices to obtain the shadow rendering result of the three-dimensional model on the projection plane.
[0174] For descriptions of the processing flow of each module in the device and the interaction flow between each module, reference can be made to the relevant descriptions in the above method embodiment, which will not be described in detail here.
[0175] The present disclosure also provides a computer device, such as Figure 12 FIG. 1 is a schematic diagram of a computer device structure provided by some embodiments of the present disclosure, including:
[0176] A processor 10 and a memory 20; the memory 20 stores machine-readable instructions executable by the processor 10, and the processor 10 is configured to execute the machine-readable instructions stored in the memory 20. When the machine-readable instructions are executed by the processor 10, the processor 10 performs the following steps:
[0177] A shadow body corresponding to a three-dimensional model in a virtual three-dimensional space is determined; the shadow body is used to indicate a projection rendering range of the three-dimensional model when it is projected on a projection surface of a preset object in the virtual three-dimensional space; in response to at least one target vertex on the projection surface being located within the area where the shadow body is located, a display shadow intensity corresponding to the target vertex is determined based on second position information of the target vertex in the virtual three-dimensional space and first position information corresponding to the shadow body; the projection surface is rendered based on the display shadow intensity corresponding to the at least one target vertex to obtain a shadow rendering result of the three-dimensional model on the projection surface.
[0178] The above-mentioned memory 20 includes internal memory 210 and external memory 220; the memory 210 here is also called internal memory, which is used to temporarily store the calculation data in the processor 10, as well as the data exchanged with the external memory 220 such as the hard disk. The processor 10 exchanges data with the external memory 220 through the internal memory 210.
[0179] The specific execution process of the above instructions can refer to the steps of the shadow rendering method of the three-dimensional model described in the embodiment of the present disclosure, and will not be repeated here.
[0180] The present disclosure also provides a computer-readable storage medium having a computer program stored thereon. When executed by a processor, the computer program executes the steps of the shadow rendering method for a three-dimensional model described in the above method embodiment. The storage medium may be a volatile or non-volatile computer-readable storage medium.
[0181] The embodiments of the present disclosure also provide a computer program product, which carries program code. The instructions included in the program code can be used to execute the steps of the shadow rendering method of the three-dimensional model described in the above method embodiment. For details, please refer to the above method embodiment, which will not be repeated here.
[0182] The computer program product may be implemented in hardware, software, or a combination thereof. In one embodiment, the computer program product is implemented as a computer storage medium. In another embodiment, the computer program product is implemented as a software product, such as a software development kit (SDK).
[0183] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems and devices described above can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here. In the several embodiments provided in the present disclosure, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0184] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0185] In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0186] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present disclosure, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present disclosure. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0187] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present disclosure, which are used to illustrate the technical solutions of the present disclosure, rather than to limit them. The scope of protection of the present disclosure is not limited thereto. Although the present disclosure has been described in detail with reference to the above-described embodiments, those skilled in the art should understand that any person skilled in the art can modify or easily conceive of changes to the technical solutions described in the above-described embodiments within the technical scope disclosed in the present disclosure, or replace some of the technical features therein with equivalents. Such modifications, changes, or replacements do not deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should be included in the scope of protection of the present disclosure. Therefore, the scope of protection of the present disclosure shall be subject to the scope of protection of the claims.
Claims
1. A shadow rendering method for a three-dimensional model, characterized in that: include: determining a shadow volume corresponding to the three-dimensional model for the three-dimensional model in the virtual three-dimensional space; The shadow volume is used to indicate a projection rendering range when the three-dimensional model is projected on a projection surface of a preset object in the virtual three-dimensional space; In response to at least one target vertex on the projection surface being located within the region where the shadow body is located, determining a display shadow intensity corresponding to the target vertex based on second position information of the target vertex in the virtual three-dimensional space and first position information corresponding to the shadow body; Rendering the projection surface based on the display shadow intensity corresponding to the at least one target vertex to obtain a shadow rendering result of the three-dimensional model on the projection surface; The step of determining a shadow volume corresponding to a three-dimensional model in a virtual three-dimensional space includes: Determine a first target reference position point of the three-dimensional model; the first target reference position point includes a first target position point of the three-dimensional model and a second target position point associated with the first target position point; The determining, based on the second position information of the target vertex in the virtual three-dimensional space and the first position information corresponding to the shadow volume, of the display shadow intensity corresponding to the target vertex includes: For any target vertex, determining a first distance between the target vertex and the first target position point based on the second position information of the target vertex and a first reference position corresponding to the first target position point in the first position information; and determining a second distance between the target vertex and the second target point based on the second position information of the target vertex and a second reference position corresponding to the second target point in the first position information; The displayed shadow intensity is determined according to a first shadow intensity corresponding to the first distance and / or a second shadow intensity corresponding to the second distance.
2. The method according to claim 1, characterized in that The step of determining a shadow volume corresponding to the three-dimensional model in the virtual three-dimensional space includes: Based on the position information of the first target reference position point in the virtual three-dimensional space, first position information of the shadow body corresponding to the three-dimensional model is determined, and based on the first position information, the shadow body corresponding to the three-dimensional model is determined.
3. The method according to claim 2, characterized in that Determining a first target reference position point of the three-dimensional model includes: Based on the type of the three-dimensional model, at least two support points corresponding to the three-dimensional model are determined among multiple vertices of the three-dimensional model; and the at least two support points are determined as the first target reference position points.
4. The method according to claim 3, characterized in that The step of determining the at least two support points as the first target reference position points includes: determining whether a first height difference between the at least two support points in the three-dimensional virtual space is greater than a height difference threshold; In response to the first height difference being less than or equal to the height difference threshold, determining the at least two support points as the first target reference position points; In response to the first height difference being greater than the height difference threshold, determining a support point to be adjusted from the at least two support points, and determining a new position point based on position information of the support point to be adjusted in the three-dimensional virtual space; The new position point and the non-to-be-adjusted support point among the at least two support points are determined as the first target reference position point; wherein, the new position point and the projection of the corresponding support point to be adjusted on the projection surface coincide with each other, and the first height difference between the new position point and the non-to-be-adjusted support point in the three-dimensional virtual space is less than or equal to the height difference threshold.
5. The method according to claim 2, characterized in that Determining a first target reference position point of the three-dimensional model includes: Based on the type of the three-dimensional model, determining any one support point of the three-dimensional model among multiple vertices of the three-dimensional model; and determining the any one support point as the first target position point; determining a distance between the first target location point and the second target location point based on a lighting direction of the three-dimensional model and height information of the three-dimensional model; The second target location point is determined based on the distance and the light direction.
6. The method according to any one of claims 2 to 5, characterized in that: The determining, based on the first position information, a shadow volume corresponding to the three-dimensional model includes: Determine, based on the position information corresponding to the first target position point and the second target position point in the first target reference position point in the first position information, a spherical area with each target position point as the sphere center and a radius of a first preset radius; In response to a distance between a first target location point and a second target location point being less than or equal to a preset distance threshold, fusing a spherical region corresponding to the first target location point with a spherical region corresponding to the second target location point to obtain the shadow volume; The preset distance threshold is determined based on the first preset radius.
7. The method according to claim 6, characterized in that Also includes: In response to the distance between the first target position point and the second target position point being greater than the preset distance threshold, the spherical area corresponding to the first target position point and the spherical area corresponding to the second target position point are respectively used as two components of the shadow volume.
8. The method according to claim 6, characterized in that The determining the display shadow intensity according to the first shadow intensity corresponding to the first distance and / or the second shadow intensity corresponding to the second distance includes: A first shadow intensity and a second shadow intensity corresponding to the first distance and the second distance are determined respectively, and the first shadow intensity and the second shadow intensity are superimposed to obtain a display shadow intensity corresponding to the target vertex.
9. The method according to any one of claims 2 to 5, characterized in that: The determining, based on the first position information, a shadow volume corresponding to the three-dimensional model includes: Determine, based on the position information corresponding to the first target position point and the second target position point in the first target reference position point in the first position information, a capsule body region with the first target position point and the second target position point as inner fixed points and a hemispherical radius of a second preset radius; Using the capsule area as the shadow volume; The inner fixed points are the centers of the two hemispherical regions in the capsule body, respectively, and the line connecting the two inner fixed points is the central axis of the cylindrical region in the capsule body.
10. The method according to claim 9, characterized in that Also includes: In response to a height change rate of the projection surface in the virtual three-dimensional space being greater than a preset height change rate threshold, determining, for each area point on the surface of the shadow volume, a second height difference between the first target position point or the second target position point and the area point in the three-dimensional virtual space; Based on the second height differences respectively corresponding to the area points, height adjustment processing is performed on the heights of the area points, and based on the height processing results respectively corresponding to each area point, an updated shadow volume is obtained.
11. The method according to claim 9, characterized in that Determining a display shadow intensity corresponding to the target vertex based on second position information of the target vertex in the virtual three-dimensional space and first position information corresponding to the shadow volume includes: For any target vertex, determining the sub-region to which the target vertex belongs in the shadow volume based on the second position information of the target vertex and the first position information of the first target reference position point; In response to the sub-region being a hemispherical region of the shadow volume, determining a first distance between the target vertex and an inner fixed point in the hemispherical region, and determining a display shadow intensity corresponding to the target vertex based on the first distance; or In response to the sub-region being a cylindrical region of the shadow body, a second distance between the target vertex and a central axis of the cylinder is determined, and a display shadow intensity corresponding to the target vertex is determined based on the second distance.
12. The method according to claim 1, characterized in that The step of determining a shadow volume corresponding to the three-dimensional model in the virtual three-dimensional space includes: In response to the current rendering environment meeting the first preset condition, a shadow volume corresponding to the three-dimensional model is determined for the three-dimensional model in the virtual three-dimensional space.
13. The method according to claim 12, characterized in that The method further comprises: In response to the current rendering environment meeting a second preset condition, determining a lighting direction of the three-dimensional model and a second target reference position point of the three-dimensional model on a preset projection plane; wherein the projection plane is a virtual plane determined based on the current position of the three-dimensional model; For any vertex in the three-dimensional model, based on a reference direction between the vertex and the second target reference position point and the illumination direction, perform a position offset adjustment on the second target reference position point to obtain a target projection point of the vertex on the projection plane; Based on the target positions of the target projection points corresponding to each vertex, the projection display range of the three-dimensional model on the projection plane is determined, and the projection plane is rendered based on the projection display range to obtain a shadow rendering result of the three-dimensional model on the projection plane.
14. The method according to claim 13, characterized in that For any vertex, the reference direction between the vertex and the second target reference position point is determined in the following manner: For any vertex in the three-dimensional model, determining a reference direction between the vertex and the second target reference point based on a first position of the vertex in the virtual three-dimensional space and a second position of the second target reference point in the virtual three-dimensional space; The step of performing a position offset adjustment on the second target reference position point based on a reference direction between the vertex and the second target reference position point and the illumination direction to obtain a target position of the vertex on a projection plane in the virtual three-dimensional space includes: determining an offset between the reference direction and the illumination direction; A position offset adjustment is performed on the second position of the second target reference position point based on the offset to obtain a target position of the target projection point of the vertex on the projection plane.
15. The method according to claim 13 or 14, characterized in that Rendering the projection plane based on the projection display range to obtain a shadow rendering result of the three-dimensional model on the projection plane includes: In response to an occlusion model existing on the projection plane under the projection display range, determining an occlusion area of the occlusion model under the projection display range; For each target projection point in the occlusion area, determining a distance between each target projection point and a vertex of the occlusion model in a vertical direction in the virtual three-dimensional space, and determining a display shadow intensity corresponding to each target projection point based on the distance corresponding to each target projection point; The shadow rendering effect of the three-dimensional model on the projection plane is determined based on the display shadow intensity corresponding to each target projection point on the projection plane, and the projection plane is rendered based on the shadow rendering effect to obtain the shadow rendering result of the three-dimensional model on the projection plane.
16. The method according to claim 13 or 14, characterized in that Rendering the projection plane based on the projection display range to obtain a shadow rendering result of the three-dimensional model on the projection plane includes: For any of the target projection points, determining a display shadow intensity of the target projection point on the projection plane based on a height value of a vertex corresponding to the target projection point in the three-dimensional model in the virtual three-dimensional space; The projection plane is rendered based on the display shadow intensities corresponding to the vertices to obtain a shadow rendering result of the three-dimensional model on the projection plane.
17. A shadow rendering device for a three-dimensional model, characterized in that: include: A first determining module, configured to determine a shadow volume corresponding to a three-dimensional model in a virtual three-dimensional space; The shadow volume is used to indicate a projection rendering range when the three-dimensional model is projected on a projection surface of a preset object in the virtual three-dimensional space; a second determining module, configured to determine, in response to at least one target vertex on the preset object being located within the region where the shadow body is located, an intensity of a displayed shadow corresponding to the target vertex based on second position information of the target vertex in the virtual three-dimensional space and first position information corresponding to the shadow body; a third determining module, configured to render the projection surface based on the display shadow intensity corresponding to the at least one target vertex, to obtain a shadow rendering result of the three-dimensional model on the projection surface; The step of determining a shadow volume corresponding to a three-dimensional model in a virtual three-dimensional space includes: Determine a first target reference position point of the three-dimensional model; the first target reference position point includes a first target position point of the three-dimensional model and a second target position point associated with the first target position point; The determining, based on the second position information of the target vertex in the virtual three-dimensional space and the first position information corresponding to the shadow volume, of the display shadow intensity corresponding to the target vertex includes: For any target vertex, determining a first distance between the target vertex and the first target position point based on the second position information of the target vertex and a first reference position corresponding to the first target position point in the first position information; and determining a second distance between the target vertex and the second target point based on the second position information of the target vertex and a second reference position corresponding to the second target point in the first position information; The displayed shadow intensity is determined according to a first shadow intensity corresponding to the first distance and / or a second shadow intensity corresponding to the second distance.
18. A computer device, characterized in that: include: A processor and a memory, wherein the memory stores machine-readable instructions executable by the processor, and the processor is used to execute the machine-readable instructions stored in the memory. When the machine-readable instructions are executed by the processor, the processor performs the steps of the shadow rendering method for a three-dimensional model as described in any one of claims 1 to 16.
19. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program. When the computer program is executed by a computer device, the computer device executes the steps of the shadow rendering method for a three-dimensional model according to any one of claims 1 to 16.
Citation Information
Patent Citations
Shade drafting method and rendering device
CN101127127A
3D rendering and shadow information storing method and apparatus
CN106558090A