Target object image rendering method, device, electronic device and storage medium
By determining target normal directions and brightness values with weighted processing and texture data fusion, the method achieves efficient rendering of subsurface scattering effects, reducing processing volume and enhancing device applicability.
Patent Information
- Application Number
- CN202010725846.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-07-24
- Publication Date
- 2024-12-03
- Estimated Expiration
- 2040-07-24
AI Technical Summary
Existing methods for rendering images with subsurface scattering effects require high processing volumes and have low efficiency.
A method that determines the target normal direction and brightness value of each position point on a target object's surface, considering the influence of surrounding points within a subsurface scattering range, using weighted processing to control virtual incident light directions and texture data fusion to achieve a realistic subsurface scattering effect.
Reduces processing volume and performance requirements while maintaining accuracy, enabling wider application of image rendering methods across various devices.
Smart Images

Figure CN113971714B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of image processing technology, and in particular to a method, device, electronic device and storage medium for rendering a target object image. Background Art
[0002] Subsurface scattering refers to the process in which light passes through an object made of a transparent material, scatters inside the object, and then leaves the object from the inside. In daily life, the light transmission through ears and leaves is caused by subsurface scattering. When rendering an image, in order to make the rendered image more realistic, it is necessary to consider the subsurface scattering effect of the objects in the rendered image.
[0003] At present, the subsurface scattering effect is achieved by performing multiple Gaussian blur processing on the surface texture data of the target object, rendering based on the processed surface texture data and virtual light source, and obtaining the target object image. However, the above solution has a large processing volume and low rendering efficiency. Summary of the invention
[0004] The present disclosure provides a method, device, electronic device and storage medium for rendering a target object image, so as to reduce the processing amount required for image rendering. The technical solution of the present disclosure is as follows:
[0005] According to a first aspect of an embodiment of the present disclosure, a method for rendering a target object image is provided, comprising: determining a target normal direction of each position point according to an initial normal direction of each position point on the surface of the target object and an initial normal direction of at least one other position point within a subsurface scattering range of each position point; acquiring a first brightness value of each position point according to the target normal direction of each position point and a direction of a virtual incident light ray, wherein each position point receives a virtual incident light ray emitted by at least one virtual light source, and the directions of the virtual incident light rays emitted by the same virtual light source are the same; rendering is performed according to texture data of each position point and the first brightness value of each position point to obtain a target object image with a subsurface scattering effect; wherein the subsurface scattering range of any position point refers to: scattering occurs inside the target object, and virtual light rays including the light emission range of any position point are formed on the surface of the target object, and the incident range on the surface of the target object.
[0006] In a possible implementation, before determining the target normal direction of each position point based on the initial normal direction of each position point on the surface of the target object and the initial normal direction of at least one other position point within the sub-surface scattering range of each position point, the method further includes: determining the surface curvature of each position point on the surface of the target object based on the shape parameters of the target object; determining the sub-surface scattering range of each position point based on the surface curvature of each position point, wherein the size of the sub-surface scattering range of the position point is positively correlated with the surface curvature of the position point.
[0007] In a possible implementation, determining the subsurface scattering range of each position point according to the surface curvature of each position point includes: when the surface curvature of any position point is greater than a target curvature threshold, increasing the subsurface scattering radius of the position point according to an increase corresponding to a difference between the surface curvature and the target curvature threshold, the surface scattering radius is the radius of the subsurface scattering range, and the difference is positively correlated with the increase; when the surface curvature of the position point is less than the target curvature threshold, decreasing the subsurface scattering radius of the position point according to a decrease corresponding to the difference between the surface curvature and the target curvature threshold, and the difference is positively correlated with the decrease; when the surface curvature of the position point is equal to the target curvature threshold, keeping the subsurface scattering radius of the position point unchanged.
[0008] In a possible implementation, determining the target normal direction of each position point based on the initial normal direction of each position point on the surface of the target object and the initial normal direction of at least one other position point within the subsurface scattering range of each position point includes: performing weighted processing on the initial normal direction of the first position point and the initial normal direction of at least one other position point within the subsurface scattering range of the first position point according to a weight of the initial normal direction of the first position point and a weight of the initial normal direction of the first position point to obtain the target normal direction of the first position point, wherein the first position point is any position point on the surface of the target object.
[0009] In a possible implementation, the method further includes at least one of the following items: determining the weight of the first initial normal direction based on the distance between a second position point corresponding to the first initial normal direction and the first position point, wherein the weight is negatively correlated with the distance; determining the weight of the first initial normal direction based on the surface curvature of the second position point corresponding to the first initial normal direction, wherein the weight is positively correlated with the surface curvature; wherein the second position point is any position point within the subsurface scattering range of the first position point that is different from the first position point.
[0010] In one possible implementation, obtaining the first brightness value of each position point based on the target normal direction of each position point and the direction of the virtual incident light includes: obtaining the first brightness value of each position point based on the angle between the target normal direction of each position point and the direction of the virtual incident light, the first brightness value being negatively correlated with the angle.
[0011] In one possible implementation, before rendering according to the texture data of each position point and the first brightness value of each position point to obtain the target object image with a subsurface scattering effect, the method further includes: for any position point, according to the weight of the diffuse reflection texture data of the any position point and the weight of the diffuse reflection texture data of at least one other position point within the subsurface scattering range of the any position point, weighted processing is performed on the diffuse reflection texture data of the any position point and the diffuse reflection texture data of the at least one other position point to obtain the texture data of the any position point; wherein the diffuse reflection texture data of the any position point is obtained after diffuse reflection rendering is performed on the initial texture data of the any position point.
[0012] In one possible implementation, for any position point, weighted processing is performed on the diffuse reflection texture data of any position point and the diffuse reflection texture data of at least one other position point within a subsurface scattering range of the any position point according to the weight of the diffuse reflection texture data of the any position point and the weight of the diffuse reflection texture data of at least one other position point, and before obtaining the texture data of each position point, the method further includes: determining the weight of the diffuse reflection texture data of the at least one other position point according to the surface curvature of the at least one other position point within the subsurface scattering range, wherein the weight is positively correlated with the surface curvature.
[0013] In a possible implementation, before rendering according to the texture data of each position point and the first brightness value of each position point to obtain the target object image with a subsurface scattering effect, the method further includes: for any position point, fusing the diffuse reflection texture data of the any position point and the diffuse reflection texture data of at least one other position point within the subsurface scattering range of the any position point, and continuing to fuse with the diffuse reflection texture data of the any position point to obtain the texture data of the any position point.
[0014] In one possible implementation, rendering is performed according to the texture data of each position point and the first brightness value of each position point to obtain a target object image with a subsurface scattering effect, including: determining a fused color value of each position point according to a first color value of a virtual incident light at each position point and a second color value indicated by the texture data of each position point; rendering is performed according to the texture data of each position point, the first brightness value of each position point and the fused color value of each position point to obtain a target object image with a subsurface scattering effect.
[0015] In one possible implementation, rendering is performed according to the texture data of each position point and the first brightness value of each position point to obtain a target object image with a subsurface scattering effect, including: obtaining the second brightness value of each position point according to the light reflectivity, virtual incident light direction and initial normal direction of each position point; superimposing the first brightness value of each position point with the second brightness value of the corresponding position point to obtain the third brightness value of each position point; rendering is performed according to the texture data of each position point and the third brightness value of each position point to obtain a target object image with a subsurface scattering effect.
[0016] According to a second aspect of an embodiment of the present disclosure, a target object image rendering device is provided, comprising: a normal determination unit, configured to determine a target normal direction of each position point on the surface of the target object according to an initial normal direction of each position point and an initial normal direction of at least one other position point within a subsurface scattering range of each position point; a brightness value determination unit, configured to obtain a first brightness value of each position point according to the target normal direction of each position point and a virtual incident light direction, wherein each position point receives a virtual incident light emitted by at least one virtual light source, and the directions of the virtual incident light rays emitted by the same virtual light source are the same; a rendering unit, configured to perform rendering according to texture data of each position point and the first brightness value of each position point, to obtain a target object image with a subsurface scattering effect; wherein the subsurface scattering range of any position point refers to: a virtual light ray that is scattered inside the target object and forms a light emission range of any position point on the surface of the target object, and an incident range on the surface of the target object.
[0017] In a possible implementation, the device also includes: a curvature determination unit, configured to determine the surface curvature of each position point on the surface of the target object according to the shape parameters of the target object; and a range determination unit, configured to determine the sub-surface scattering range of each position point according to the surface curvature of each position point, wherein the size of the sub-surface scattering range of the position point is positively correlated with the surface curvature of the position point.
[0018] In a possible implementation, the range determination unit is configured to perform the following steps: when the surface curvature of any position point is greater than a target curvature threshold, the sub-surface scattering radius of the position point is increased according to the increase amplitude corresponding to the difference between the surface curvature and the target curvature threshold, the surface scattering radius is the radius of the sub-surface scattering range, and the difference is positively correlated with the increase amplitude; when the surface curvature of the position point is less than the target curvature threshold, the sub-surface scattering radius of the position point is reduced according to the decrease amplitude corresponding to the difference between the surface curvature and the target curvature threshold, and the difference is positively correlated with the decrease amplitude; when the surface curvature of the position point is equal to the target curvature threshold, the sub-surface scattering radius of the position point is kept unchanged.
[0019] In one possible implementation, the normal determination unit is configured to perform weighted processing on the initial normal direction of the first position point and the initial normal direction of at least one other position point within a subsurface scattering range of the first position point, to obtain a target normal direction of the first position point, where the first position point is any position point on the surface of the target object.
[0020] In one possible implementation, the device also includes: a weight determination unit, configured to perform at least one of the following: determining a weight of the first initial normal direction based on a distance between a second position point corresponding to the first initial normal direction and the first position point, wherein the weight is negatively correlated with the distance; determining a weight of the first initial normal direction based on a surface curvature of the second position point corresponding to the first initial normal direction, wherein the weight is positively correlated with the surface curvature; wherein the second position point is any position point within a subsurface scattering range of the first position point that is different from the first position point.
[0021] In one possible implementation, the brightness value determination unit is configured to obtain a first brightness value of each position point based on an angle between a target normal direction of each position point and a direction of a virtual incident light ray, wherein the first brightness value is negatively correlated with the angle.
[0022] In one possible implementation, the device also includes: a texture fusion unit, which is configured to perform weighted processing on the diffuse reflection texture data of any position point and the diffuse reflection texture data of at least one other position point within the subsurface scattering range of any position point, so as to obtain the texture data of any position point; wherein the diffuse reflection texture data of any position point is obtained after diffuse reflection rendering of the initial texture data of any position point.
[0023] In one possible implementation, the device also includes: a weight determination unit, configured to determine the weight of the diffuse reflection texture data of at least one other position point according to the surface curvature of at least one other position point within the subsurface scattering range, wherein the weight is positively correlated with the surface curvature.
[0024] In one possible implementation, the device also includes: a texture fusion unit, which is configured to perform fusion processing on the diffuse reflection texture data of any position point and the diffuse reflection texture data of at least one other position point within the subsurface scattering range of any position point, and continue to perform fusion processing with the diffuse reflection texture data of any position point to obtain the texture data of any position point.
[0025] In one possible implementation, the rendering unit includes: a color fusion subunit, configured to determine the fused color value of each position point based on the first color value of the virtual incident light at each position point and the second color value indicated by the texture data of each position point; a rendering subunit, configured to perform rendering based on the texture data of each position point, the first brightness value of each position point and the fused color value of each position point to obtain a target object image with a subsurface scattering effect.
[0026] In one possible implementation, the rendering unit is configured to obtain a second brightness value of each position point based on the light reflectivity, virtual incident light direction and initial normal direction of each position point; superimpose the first brightness value of each position point with the second brightness value of the corresponding position point to obtain a third brightness value of each position point; and render according to the texture data of each position point and the third brightness value of each position point to obtain an image of the target object with a subsurface scattering effect.
[0027] According to a third aspect of an embodiment of the present disclosure, an electronic device is provided, the electronic device comprising:
[0028] one or more processors;
[0029] a volatile or non-volatile memory for storing the one or more processor-executable instructions;
[0030] Wherein, the one or more processors are configured to execute the target object image rendering method as described in the first aspect above.
[0031] According to a fourth aspect of an embodiment of the present disclosure, a storage medium is provided. When instructions in the storage medium are executed by a processor of an electronic device, the electronic device can execute the target object image rendering method as described in the first aspect above.
[0032] According to a fifth aspect of an embodiment of the present disclosure, a computer program product is provided, comprising executable instructions. When the instructions in the computer program product are executed by a processor of an electronic device, the electronic device is enabled to execute the target object image rendering method as described in the first aspect above.
[0033] The technical solution provided by the embodiments of the present disclosure brings at least the following beneficial effects:
[0034] The embodiments of the present disclosure provide a method, device, electronic device and storage medium for rendering a target object image. When subsurface scattering occurs at any position point in an object, the brightness value of the position point will be affected by the brightness values of other surrounding position points, and the brightness value of the position point is determined by the normal direction of the position point and the direction of the virtual incident light. Therefore, the directions of the virtual incident light rays emitted by the same virtual light source are controlled to be the same, and the virtual incident light rays received by the target object are regarded as parallel light to avoid the influence of the direction of the virtual incident light rays, thereby reducing the processing volume and the performance requirements for the device, so that the target object image rendering method can be applied to more types of devices and has a wider range of applications. When obtaining the brightness value of each position point, only the influence of the normal direction of other surrounding position points needs to be considered. Therefore, the initial normal direction of each position point is fused with the initial normal direction of other surrounding position points, and the brightness value is obtained according to the target normal direction and the virtual incident light direction obtained after the fusion of each position point. The accuracy of the brightness value can still be guaranteed, thereby ensuring the subsurface scattering effect of the target object image.
[0035] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] The drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description are used to explain the principles of the present disclosure, and do not constitute improper limitations on the present disclosure.
[0037] Figure 1 The figure is a schematic diagram of an implementation environment according to an exemplary embodiment.
[0038] Figure 2 The figure is a flow chart of a method for rendering a target object image according to an exemplary embodiment.
[0039] Figure 3 The figure is a flow chart of a method for rendering a target object image according to an exemplary embodiment.
[0040] Figure 4 is a schematic diagram of a target object image according to an exemplary embodiment.
[0041] Figure 5 is a schematic diagram of a target object image according to an exemplary embodiment.
[0042] Figure 6 is a schematic diagram of a target object image according to an exemplary embodiment.
[0043] Figure 7 is a schematic diagram of a target object image according to an exemplary embodiment.
[0044] Figure 8 The invention is a block diagram of a device for rendering a target object image according to an exemplary embodiment.
[0045] Fig. 9 The figure is a block diagram of another target object image rendering device according to an exemplary embodiment.
[0046] Fig.10 It is a block diagram of a terminal according to an exemplary embodiment.
[0047] Fig.11 It is a block diagram of a server according to an exemplary embodiment. DETAILED DESCRIPTION
[0048] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0049] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0050] The disclosed embodiment provides a target object image rendering method, which can render a target object image with a subsurface scattering effect and can be applied to a variety of scenarios.
[0051] For example, the method provided in the embodiment of the present disclosure can be applied to a game scene. When rendering a virtual scene of the game, the method provided in the embodiment of the present disclosure can be used to render a virtual object with a subsurface scattering effect.
[0052] Alternatively, the method provided by the embodiment of the present disclosure may also be applied to an animation production scene. When producing an animated character, the method provided by the embodiment of the present disclosure may be used to render an animated character with a subsurface scattering effect.
[0053] In addition, the method provided by the embodiment of the present disclosure can also be applied to any scene in which images are rendered, such as a special effects production scene, a live broadcast scene, etc., and the embodiment of the present disclosure is not limited here.
[0054] The target object image rendering method provided by the embodiment of the present disclosure can be applied to an electronic device. In one possible implementation, the electronic device can be a terminal, which can be a mobile phone, a tablet computer, a computer, or other types of terminals. In another possible implementation, the electronic device can also be a server, which can be a server, or a server cluster composed of several servers, or a cloud computing service center.
[0055] In another possible implementation, the electronic device may include a terminal and a server. Figure 1 FIG. 1 is a schematic diagram of an implementation environment according to an exemplary embodiment. Figure 1 As shown, the implementation environment includes: a terminal 101 and a server 102. The terminal 101 and the server 102 are connected via a network.
[0056] In a possible implementation, the terminal 101 may send the object parameters of the target object to the server 102, and the object parameters may include the shape parameters, material parameters, etc. of the target object. The server 102 receives the object parameters, and determines the initial normal direction of each position point in the target object and the subsurface scattering range of each position point according to the shape parameters of the target object, and obtains the brightness value of each position point according to the target normal direction and the virtual incident light direction of each position point. The server 102 can also obtain the texture data of the target object according to the material parameters, and render according to the texture data of each position point of the target object and the brightness value of each position point to obtain the target object image with subsurface scattering effect.
[0057] Figure 2 is a flow chart of a method for rendering a target object image according to an exemplary embodiment. Figure 2 As shown, the target object image rendering method is used in a terminal and includes the following steps.
[0058] In step 201, a target normal direction of each position point is determined according to an initial normal direction of each position point on the surface of the target object and an initial normal direction of at least one other position point within a subsurface scattering range of each position point.
[0059] In step 202, the first brightness value of each position point is obtained according to the target normal direction and the direction of the virtual incident light of each position point, and each position point receives a virtual incident light emitted by at least one virtual light source, and the direction of the virtual incident light emitted by the same virtual light source is the same.
[0060] In step 203, rendering is performed according to the texture data of each position point and the first brightness value of each position point to obtain a target object image with a subsurface scattering effect.
[0061] The subsurface scattering range of any position point refers to: scattering occurs inside the target object, and a virtual light beam including the light emission range of any position point is formed on the surface of the target object, and the incident range on the surface of the target object.
[0062] The target object image rendering method provided by the embodiment of the present disclosure is that when subsurface scattering occurs at any position point in the object, the brightness value of the position point will be affected by the brightness values of other surrounding position points, and the brightness value of the position point is determined by the normal direction of the position point and the direction of the virtual incident light. Therefore, the directions of the virtual incident light emitted by the same virtual light source are controlled to be the same, and the virtual incident light received by the target object is regarded as parallel light to avoid the influence of the direction of the virtual incident light, thereby reducing the processing amount and the performance requirements for the device, so that the target object image rendering method can be applied to more types of devices and has a wider range of applications. When obtaining the brightness value of each position point, only the influence of the normal direction of other surrounding position points needs to be considered. Therefore, the initial normal direction of each position point is fused with the initial normal direction of other surrounding position points, and the brightness value is obtained according to the target normal direction and the virtual incident light direction obtained after the fusion of each position point. The accuracy of the brightness value can still be guaranteed, thereby ensuring the subsurface scattering effect of the target object image.
[0063] In a possible implementation, before determining the target normal direction of each position point according to the initial normal direction of each position point on the surface of the target object and the initial normal direction of at least one other position point within the subsurface scattering range of each position point, the method further includes:
[0064] Determine the surface curvature of each position point on the surface of the target object according to the shape parameters of the target object;
[0065] According to the surface curvature of each position point, the sub-surface scattering range of each position point is determined, and the size of the sub-surface scattering range of the position point is positively correlated with the surface curvature of the position point.
[0066] In a possible implementation, determining the subsurface scattering range of each position point according to the surface curvature of each position point includes:
[0067] When the surface curvature of any position point is greater than the target curvature threshold, the subsurface scattering radius of the position point is increased according to the increase corresponding to the difference between the surface curvature and the target curvature threshold. The surface scattering radius is the radius of the subsurface scattering range, and the difference is positively correlated with the increase.
[0068] When the surface curvature of the position point is less than the target curvature threshold, the subsurface scattering radius of the position point is reduced according to the reduction amplitude corresponding to the difference between the surface curvature and the target curvature threshold, and the difference is positively correlated with the reduction amplitude;
[0069] When the surface curvature of a position point is equal to the target curvature threshold, the subsurface scattering radius of the position point is kept unchanged.
[0070] In a possible implementation, determining the target normal direction of each position point according to the initial normal direction of each position point on the surface of the target object and the initial normal direction of at least one other position point within the subsurface scattering range of each position point includes:
[0071] According to the weight of the initial normal direction of the first position point and the weight of the initial normal direction of at least one other position point within the subsurface scattering range of the first position point, the initial normal direction of the first position point and the initial normal direction of at least one other position point are weighted to obtain a target normal direction of the first position point, where the first position point is any position point on the surface of the target object.
[0072] In a possible implementation, before weighted processing is performed on the initial normal direction of the first position point and the other at least one initial normal direction according to the weight of the initial normal direction of the first position point and the weight of the initial normal direction of at least one other position point within the subsurface scattering range of the first position point to obtain the target normal direction of the first position point, the method further includes at least one of the following:
[0073] Determine the weight of the first initial normal direction according to the distance between the second position point corresponding to the first initial normal direction and the first position point, where the weight is negatively correlated with the distance;
[0074] Determine a weight of the first initial normal direction according to the surface curvature of the second position point corresponding to the first initial normal direction, where the weight is positively correlated with the surface curvature;
[0075] The second position point is any position point within the subsurface scattering range of the first position point that is different from the first position point.
[0076] In a possible implementation, obtaining a first brightness value of each position point according to a target normal direction and a virtual incident light direction of each position point includes:
[0077] According to the angle between the target normal direction of each position point and the direction of the virtual incident light, a first brightness value of each position point is obtained, and the first brightness value is negatively correlated with the angle.
[0078] In a possible implementation, before rendering is performed according to the texture data of each position point and the first brightness value of each position point to obtain the target object image with the subsurface scattering effect, the method further includes:
[0079] For any position point, according to the weight of the diffuse reflection texture data of any position point and the weight of the diffuse reflection texture data of at least one other position point within the subsurface scattering range of any position point, weighted processing is performed on the diffuse reflection texture data of any position point and the diffuse reflection texture data of at least one other position point to obtain the texture data of any position point;
[0080] The diffuse reflection texture data of any position point is obtained by performing diffuse reflection rendering on the initial texture data of any position point.
[0081] In a possible implementation, for any position point, according to the weight of the diffuse reflection texture data of any position point and the weight of the diffuse reflection texture data of at least one other position point within the subsurface scattering range of any position point, weighted processing is performed on the diffuse reflection texture data of any position point and the diffuse reflection texture data of at least one other position point, before obtaining the texture data of each position point, the method further includes:
[0082] The weight of the diffuse reflection texture data of at least one other position point is determined according to the surface curvature of at least one other position point within the subsurface scattering range, and the weight is positively correlated with the surface curvature.
[0083] In a possible implementation, before rendering is performed according to the texture data of each position point and the first brightness value of each position point to obtain the target object image with the subsurface scattering effect, the method further includes:
[0084] For any position point, the diffuse reflection texture data of any position point and the diffuse reflection texture data of at least one other position point within the subsurface scattering range of any position point are fused, and then fused with the diffuse reflection texture data of any position point to obtain the texture data of any position point.
[0085] In a possible implementation, rendering is performed according to the texture data of each position point and the first brightness value of each position point to obtain a target object image with a subsurface scattering effect, including:
[0086] Determine a fused color value for each position point according to a first color value of a virtual incident light ray at each position point and a second color value indicated by texture data at each position point;
[0087] Rendering is performed according to the texture data of each position point, the first brightness value of each position point and the fused color value of each position point to obtain a target object image with a subsurface scattering effect.
[0088] In a possible implementation, rendering is performed according to the texture data of each position point and the first brightness value of each position point to obtain a target object image with a subsurface scattering effect, including:
[0089] Obtain a second brightness value of each position point according to the light reflectivity, virtual incident light direction and initial normal direction of each position point;
[0090] Superimpose the first brightness value of each position point with the second brightness value of the corresponding position point to obtain a third brightness value of each position point;
[0091] Rendering is performed according to the texture data of each position point and the third brightness value of each position point to obtain a target object image with a subsurface scattering effect.
[0092] Figure 3 is a flow chart of a method for rendering a target object image according to an exemplary embodiment. Figure 3 As shown, the target object image rendering method is used in a terminal and includes the following steps.
[0093] In step 301 , the initial normal direction of each position point on the surface of the target object and the subsurface scattering range of each position point are determined according to the object parameters of the target object.
[0094] The target object may be a virtual object that needs to be rendered. In a possible implementation, the target object may be any virtual object, such as a virtual human body, a virtual leaf, a virtual candle, a virtual jade, and the like.
[0095] The object parameter of the target object is a parameter used to describe the properties of the target object. In a possible implementation, the object parameter may include a shape parameter of the target object. The shape parameter is used to indicate the shape of the target object and may include the coordinates of multiple position points in the target object. The shape of the target object can be obtained by fitting the multiple position points according to the coordinates of the multiple position points.
[0096] In a possible implementation, the object parameter may further include a material parameter, and the material parameter may indicate that the target object is a transparent material object or a non-transparent material object. The transparent material object may include a completely transparent material object and a non-completely transparent material object. For example, the material parameter may be a transparency parameter of the target object, and whether the target object is a transparent material object may be determined based on the transparency parameter.
[0097] For another example, the material parameter may be a type parameter of the target object, and according to the type of the target object, it may be determined whether the target object is a transparent material object. When the target object is a virtual wall, it may be determined that the target object is a non-transparent material object; when the target object is a virtual human body, it may be determined that the target object is a transparent material object.
[0098] If it is determined that the target object is an object of transparent material, the target object image rendering method provided in the embodiment of the present disclosure may be executed to render the target object image.
[0099] In the real world, when light shines on an object, it may be reflected, refracted or scattered on the object. The reflected, refracted or scattered light enters the human eye and the person can see the object. Therefore, the human eye observes the object and is related to the reflection, refraction or scattering of light on the object. In order to render a target object that is more realistic, the embodiments of the present disclosure can set a virtual light source, control the virtual light source to emit virtual light, and thereby simulate the effect of light on the target object.
[0100] The target object can be regarded as an object composed of multiple position points. For example, the target object is an object model, which is composed of multiple position points, and the multiple position points constitute the surface of the target object. The effect of the virtual incident light on the target object can be approximately regarded as the effect on multiple position points on the surface of the target object. After the virtual incident light irradiates any position point on the surface of the target object, the direction of the reflected, refracted or scattered virtual light will be affected by the direction of the virtual incident light and the normal direction of the position point. Therefore, the initial normal direction of each position point can be obtained first. Among them, the initial normal direction of each position point is the vertical direction of the plane where the position point is located.
[0101] It should be noted that the denser the multiple position points of the target object, the finer the rendered image and the more realistic it is; the sparser the multiple position points of the target object, the coarser the rendered image and the greater the difference from the realistic effect. Since the more position points there are, the greater the amount of processing required to render the target object image, the appropriate number of position points can be determined based on the performance of the device. For example, if the performance of the device is good, developers can set more position points when building the object model.
[0102] The part of an object that contacts the external environment can be considered as the outer surface of the object. In the real world, when light hits an object, it can not only be diffusely reflected on the outer surface of the object, but also enter the interior of the object and be scattered. The area inside the object where scattering occurs can be called the subsurface of the object. For example, the object is skin, which includes a lipid layer, an epidermis layer, and a dermis layer. The lipid layer can be considered as the outer surface of the skin, and the epidermis layer and the dermis layer can be considered as the subsurface of the skin.
[0103] Subsurface scattering refers to the light transmission process in which light penetrates an object, scatters inside the object, and then leaves the object from the inside. Therefore, after any position point on the surface of the target object receives virtual incident light, the virtual incident light may enter the target object and scatter from other positions on the surface of the target object. Therefore, the display effect of the position point on the surface of the target object is not only affected by the virtual incident light received by the position point, but also by the virtual incident light of the surrounding positions. Therefore, it is necessary to determine the subsurface scattering range of each position point, wherein the subsurface scattering range of any position point refers to: the area range of other position points that affect the position point, that is, after the virtual light enters the target object from the subsurface scattering range of the first position point, after scattering inside the target object, the scattered virtual light may leave the target object from the first position point. That is, the virtual light within the subsurface scattering range of the position point enters the target object, scatters inside the target object, and the light scattering range formed includes the position point. In other words, the subsurface scattering range of any position point refers to: scattering occurs inside the target object, and a virtual light ray including the light emission range of any position point is formed on the surface of the target object, and the incident range on the surface of the target object.
[0104] According to the meaning of subsurface scattering range, the larger the subsurface scattering range, the easier it is for the subsurface scattering effect to appear. In the real world, the parts of an object where the subsurface scattering effect appears are usually the thinner areas of the object, for example, the ears and nose of the human body are more likely to produce subsurface scattering effects. Therefore, it can be considered that the thinner the object, the easier it is for the subsurface scattering effect to appear, and the larger the subsurface scattering range of the corresponding position point.
[0105] For a thinner area in an object, the surface curvature of a point on the surface of the area is greater than the surface curvature of a point in a thicker area in the object. Therefore, the subsurface scattering range of the point can be determined based on the surface curvature of the point. In one possible implementation, the surface curvature of each point in the target object is determined based on the shape parameters of the target object, and the subsurface scattering range of each point is determined based on the surface curvature of each point. The size of the subsurface scattering range of the point is positively correlated with the surface curvature of the point. Since the surface curvature of the point, the subsurface scattering unit, and the subsurface scattering effect are interrelated, the subsurface scattering range of the point can be accurately obtained by obtaining the surface curvature of the point, and the subsurface scattering effect can be rendered more accurately later.
[0106] The greater the surface curvature of a position point, the thinner the area where the position point is located, the larger the subsurface scattering range of the position point, and the greater the influence of other surrounding position points, so that the subsurface scattering effect is more likely to occur.
[0107] In another possible implementation, the subsurface scattering range may also be determined by the user. For example, the user may set the subsurface scattering radius, and the subsurface scattering range of the position point is a circular area with the position point as the center and the subsurface scattering radius set by the user as the radius.
[0108] In another possible implementation, the subsurface scattering range may be determined by the subsurface scattering radius set by the user and the surface curvature of the location point. For example, the subsurface scattering radius of the location point may be increased or decreased according to the surface curvature of the location point.
[0109] For example, when the surface curvature of any position point is greater than the target curvature threshold, the subsurface scattering radius of the position point is increased according to the increase corresponding to the difference between the surface curvature of the position point and the target curvature threshold, and the difference is positively correlated with the increase; when the surface curvature of any position point is less than the target curvature threshold, the subsurface scattering radius of the position point is reduced according to the difference between the surface curvature of the position point and the target curvature threshold, and the difference is positively correlated with the increase; when the surface curvature of any position point is equal to the target curvature threshold, the subsurface scattering radius of the position point is kept unchanged. The subsurface scattering radius is the radius of the subsurface scattering range. On the basis of the subsurface scattering effect controlled by the user, the subsurface scattering radius is adjusted by the surface curvature of the position point, ensuring that the rendered subsurface scattering effect is more realistic.
[0110] In step 302, a target normal direction of each position point is determined according to the initial normal direction of each position point on the surface of the target object and the initial normal direction of at least one other position point within the subsurface scattering range of each position point.
[0111] Since each position point on the surface of the target object is affected by the virtual incident light received by the surrounding position points, and the impact of the virtual incident light on the object is related to the initial normal direction of the object and the direction of the virtual incident light. The virtual light source used in the embodiment of the present disclosure may include at least one of a direct virtual light source or an indirect virtual light source, wherein the direct virtual light source may be a virtual sun, etc., and the indirect virtual light source may be other virtual objects in the virtual environment where the target object is located that can reflect light.
[0112] Since the virtual sun is far away from the target object, the virtual incident light emitted by the virtual sun can be regarded as parallel light, and the virtual incident light reflected by other virtual objects in the virtual environment can also be regarded as parallel light. Since the virtual incident light received in the virtual environment where the target object is located is parallel light, the direction of the virtual incident light received by each position point is the same, wherein the direction of the virtual incident light received by each position point is the same means that each position point receives a virtual incident light emitted by at least one virtual light source, and the direction of the virtual incident light emitted by the same virtual light is the same.
[0113] Since the direction of the virtual incident light received by each position point is the same, for each position point, the influence of the virtual incident light received by other position points can be approximated as the fusion of the initial normal direction of other position points and the initial normal direction of the position point.
[0114] Among them, other positions within the subsurface scattering range of any position point may have different effects on the position point. Therefore, different weights can be assigned to the initial normal directions of multiple position points within the subsurface scattering range to perform fusion processing on the initial normal directions of the multiple position points.
[0115] In a possible implementation, determining the target normal direction of each position point according to the initial normal direction of each position point on the surface of the target object and the initial normal direction of at least one other position point within the subsurface scattering range of each position point may include: performing weighted processing on the initial normal direction of the first position point and the initial normal direction of at least one other position point within the subsurface scattering range of the first position point according to the weight of the initial normal direction of the first position point and the weight of the initial normal direction of the other at least one position point to obtain the target normal direction of the first position point, wherein the first position point is any position point on the surface of the target object. When the initial normal directions of other surrounding position points are fused with the initial normal direction of the position point, different weights are assigned to the initial normal directions of different position points in consideration of the different degrees of influence of different position points, so that the weight of the position point with greater influence among the other surrounding position points is also greater, and the weight of the position point with less influence is also smaller. Therefore, the brightness of the position point after subsurface scattering can be accurately obtained according to the fused target normal direction.
[0116] It should be noted that the at least one other position point may be other position points in the subsurface scattering range of the first position point except the first position point, or may be all position points in the subsurface scattering range of the first position point except the first position point. The more the at least one other position point, the better the rendering effect.
[0117] The weight of the initial normal direction of the first position point may be a fixed value, for example, 0.5, 1, etc. The weight of the initial normal direction of the first position point may be a system default or a user setting, which is not limited in the embodiment of the present application.
[0118] In addition, other positions within the subsurface scattering range of the first position point may have different effects on the first position point. Therefore, it is necessary to determine weights for the initial normal directions of the other position points. The weight determination method is as follows:
[0119] In a possible implementation, determining a weight of at least one initial normal direction within a subsurface scattering range of the first position point includes at least one of the following:
[0120] (1) Determine a weight of the first initial normal direction according to a distance between a second position point corresponding to the first initial normal direction and the first position point, wherein the weight is negatively correlated with the surface curvature. The first position point is any position point in the target object. The first initial normal direction is any initial normal direction of at least one initial normal direction within a subsurface scattering range of the first position point.
[0121] Among them, the farther the position point is from the first position point, the smaller the influence on the first position point. Therefore, the weight of the initial normal direction of the corresponding position point can be determined according to the distance from the first position point, and weights are assigned to the initial normal directions of other position points, and the weight is negatively correlated with the distance. Then, the initial normal directions of other position points are weighted according to the assigned weights, and the target normal direction of the first position point is more accurate.
[0122] (2) Determine a weight of the first initial normal direction according to the surface curvature of the second position point corresponding to the first initial normal direction, where the weight is positively correlated with the surface curvature.
[0123] If the surface curvature of other points around a certain point is high, the thinner the corresponding area is, the easier it is for the virtual incident light entering the area to be scattered and emitted from other points. Therefore, it can be considered that the point with higher surface curvature will have a greater impact on the point, so the initial normal directions of multiple points within the subsurface scattering range can be weighted according to the surface curvature of multiple points within the subsurface scattering range.
[0124] The thinner the area where the location point is located, the easier it is to affect the surrounding location points, and the surface curvature of the location point can indicate the thickness of the area where the location point is located. Therefore, the surface curvature of each location point can indicate the degree of influence of the location point on other location points. A weight is assigned to the initial normal direction of each location point according to the surface curvature of each location point, and the weight is positively correlated with the surface curvature. The initial normal directions of other location points can be weighted according to the assigned weight, so that the target normal direction of the first location point is more accurate.
[0125] It should be noted that the above two schemes for determining the initial normal direction can be combined, that is, determining the weight of at least one initial normal direction within the subsurface scattering range of the first position point can include: determining the weight of the first initial normal direction according to the distance between the second position point corresponding to the first initial normal direction and the first position point, and the surface curvature of the second position point corresponding to the first initial normal direction.
[0126] In step 303, a first brightness value of each position point is obtained according to the target normal direction of each position point and the direction of the virtual incident light.
[0127] The normal direction is relative to the surface of the object. The normal is a straight line perpendicular to the surface of the object. The normal of a position point is a straight line perpendicular to the plane where the position point is located. The brightness of an object depends on the angle of the light irradiating the object and the illumination intensity of the light itself. Optionally, in the embodiment of the present disclosure, the illumination intensity of all light can be defaulted to a fixed value. Therefore, the first brightness value of each position point can be obtained based on the normal direction of each position point and the direction of the virtual incident light.
[0128] Since the first brightness value of a point on the surface of the target object may be affected by the virtual incident light received by other surrounding points, and each point on the surface of the target object receives virtual incident light emitted by at least one virtual light source, and the directions of the virtual incident light emitted by the same virtual light source are the same, the influence of the virtual incident light received by other points around any point is approximated by fusing the initial normal direction of the point with other surrounding points, and the first brightness value of each point is obtained by combining the fused target normal direction with the direction of the virtual incident light, so as to simulate the influence of the virtual incident light received by other surrounding points and the virtual incident light received by the point on the point.
[0129] Among them, the first brightness value of the position point is related to the direction of the virtual incident light and the plane where the position point is located. For example, if the virtual incident light shines on the plane where the position point is located from the front, then the brightness value of the position point will be higher; if the virtual incident light shines on the plane where the position point is located from the side, then the brightness value of the position point will be lower; if the virtual incident light shines on the plane where the position point is located from the back, then the brightness value of the position point is 0.
[0130] In one possible implementation, the first brightness value of each position point is obtained according to the angle between the target normal direction of each position point and the direction of the virtual incident light, and the first brightness value is negatively correlated with the angle. The target normal direction may be the direction in which the target normal points to the surface of the target object. The first brightness value of each position point can be obtained according to the angle between the target normal direction of each position point and the direction of the virtual incident light, without the need to obtain the first brightness value of each position point according to the angle between the initial normal direction of each position point and the direction of the virtual incident light, and the angle between the initial normal direction of at least one other position point within the subsurface scattering range of each position point and the direction of the virtual incident light, thereby simplifying the process of obtaining the brightness value and being able to obtain the brightness value of each position point more quickly.
[0131] Since the normal of the position point is perpendicular to the plane where the position point is located, the brightness value of each position point can be obtained by the angle between the normal direction and the direction of the virtual incident light. For example, obtaining the first brightness value of each position point according to the angle between the target normal direction of each position point and the direction of the virtual incident light can include: performing a dot multiplication operation on the target normal of each position point and the virtual incident light to obtain the first brightness value of each position point.
[0132] In addition, each position point may receive virtual incident light rays emitted by multiple virtual light sources, and the virtual incident light rays emitted by each virtual light source may have the same or different virtual incident light directions. Therefore, obtaining the brightness value of each position point based on the angle between the target normal direction of each position point and the virtual incident light direction may include: for each virtual light source among the multiple virtual light sources, obtaining the first brightness value of each position point based on the target normal direction of each position point and the virtual incident light direction corresponding to the virtual light source; and performing statistical processing on the multiple first brightness values of each position point to obtain the processed first brightness value of each position point.
[0133] The statistical processing of the multiple first brightness values of each position point to obtain the processed first brightness value of each position point may include: superimposing the multiple first brightness values of each position point to obtain the processed first brightness value of each position point. That is, the processed first brightness value is the sum of the multiple first brightness values.
[0134] In step 304, texture data of each position point on the surface of the target object is obtained.
[0135] The texture data is used to describe the surface texture of the object. For example, if the target object is a virtual human body, the texture data of the target object may be the human skin texture; if the target object is a virtual leaf, the texture data of the target object may be the leaf epidermis texture. The target object includes multiple position points, and the texture data of the target object includes the texture data of the multiple position points in the target object. In a possible implementation, the texture data of the target object may be a surface texture image of the target object.
[0136] The texture data in step 304 is the texture data after blurring. By blurring the texture data, the subsurface scattering effect of the texture can be simulated. For example, after blurring the texture data of the target object, the surface texture color of the target object in the obtained texture data is close to the color scattered by the subsurface of the target object. Therefore, the obtained texture data can simulate the effect of subsurface scattering of the texture. The color scattered by the subsurface refers to the color of the light scattered on the subsurface of the object and emitted from the object, which is also the color displayed by the human eye after the object undergoes subsurface scattering, and the color is close to the color of the subsurface itself.
[0137] Since the virtual incident light at any position point may be emitted from other positions, the diffuse reflection texture data at any position point will be affected by the diffuse reflection texture data of other surrounding positions. The virtual incident light at any position point refers to the light irradiated to the position point. The virtual incident light irradiated to the position point may have part of the light reflected to the outside of the target object, or may have part of the light incident to the inside of the target object and scattered inside the target object. The virtual incident light at any position point may be emitted from other positions, which means that the virtual incident light entering the inside of the target object from any position point is scattered inside the target object, and the scattered virtual light may be emitted from other positions and leave the target object. For example, the virtual incident light at the first position point is emitted from the second position point, and the virtual incident light emitted from the second position point is affected by the diffuse reflection texture data of the first position point. The color of the virtual incident light will change, thereby affecting the display effect of the first position point. Therefore, it is necessary to fuse the diffuse reflection texture data of multiple positions within the subsurface scattering range of any position point to simulate the subsurface scattering effect.
[0138] In addition, the diffuse reflection texture data of at least one other position point within the subsurface scattering range of any position point has different effects on the position point, so a corresponding weight can be determined for the diffuse reflection texture data of at least one other position point within the subsurface scattering range.
[0139] In a possible implementation, obtaining texture data of multiple positions in the target object may include: for any position, fusing the diffuse reflection texture data of the any position and the diffuse reflection texture data of at least one other position within the subsurface scattering range of the any position to obtain the texture data of each position. The diffuse reflection texture data of any position is obtained after diffuse reflection rendering of the initial texture data of the any position.
[0140] The fusion processing is performed on the diffuse reflection texture data of any position point and the diffuse reflection texture data of at least one other position point within the subsurface scattering range of the any position point, that is, the texture data of the any position point is blurred.
[0141] Among them, when the diffuse reflection texture data of any position point and the diffuse reflection texture data of at least one other position point within the subsurface scattering range of the any position point are fused, the weights of the diffuse reflection texture data of at least one other position point may be the same or different. In one possible implementation, when acquiring the texture data of any position point, the weight of the texture data of the any position point may be a fixed value, for example, 0.5, 1, etc. The weight may be a system default or a user setting, which is not limited in the embodiments of the present application. The influence of at least one other position within the subsurface scattering range on the any position point is different, so different weights may be assigned to the diffuse reflection texture data of at least one other position point within the subsurface scattering range.
[0142] In a possible implementation, for any position point, the diffuse reflection texture data of the any position point and the diffuse reflection texture data of at least one other position point within the subsurface scattering range of the any position point are fused to obtain the texture data of each position point, including: for any position point, according to the weight of the diffuse reflection texture data of any position point and the weight of the diffuse reflection texture data of at least one other position point within the subsurface scattering range of the any position point, the diffuse reflection texture data of any position point and the diffuse reflection texture data of at least one other position point are weighted to obtain the texture data of any position point. Considering the different influences of different position points on the same position point, when the diffuse reflection texture data of multiple position points are fused, the fusion is performed according to the weights of different position points, so as to ensure that the fused texture data is more accurate and more consistent with the real texture data.
[0143] Before obtaining the texture data of the position point, the weight of the diffuse reflection texture data of each position point can be determined first. In one possible implementation, the weight of the diffuse reflection texture data of at least one other position point within the subsurface scattering range of any position point is determined, including: according to the surface curvature of at least one other position point within the subsurface scattering range, the weight of the diffuse reflection texture data of the at least one other position point is determined, and the weight is positively correlated with the surface curvature. Because the greater the surface curvature of the position point, the thinner the area where the position point is located, the easier it is for the light entering the target object from the position point to be emitted from other position points, and the greater the influence of the position point on other position points, therefore, the weight of the diffuse reflection texture data of the position point can be accurately determined according to the surface curvature of the position point.
[0144] In the related art, if Gaussian blur processing is performed on texture data, real-time sampling is required during the image rendering process. Therefore, Gaussian blur processing needs to be performed in real time during the image rendering process. Although the more blur times, the better the subsurface scattering effect, in order to ensure the rendering speed of real-time rendering, only a small number of Gaussian blur processing can be performed, resulting in poor subsurface scattering effect in the rendered image. In the present application, when blurring is performed, there is no need to perform real-time sampling during the image rendering process, and the parameters involved in the blurring are determined by the surface curvature of multiple position points in the target object. Since the shape of the target object is fixed, the surface curvature of multiple position points and the parameters involved in the blurring are all fixed. Therefore, the diffuse reflection texture data of the target object can be blurred multiple times in the preprocessing process before rendering the target object image to ensure the subsurface scattering effect in the target object image, and will not affect the real-time rendering progress of the image.
[0145] Since the fusion processing of the initial normal direction of the position point and the fusion processing of the diffuse reflection texture data of the position point are both for simulating the subsurface scattering effect, the processing method of the initial normal direction and the processing method of the diffuse reflection texture data can be similar.
[0146] In another possible implementation, determining the weights of diffuse reflection texture data of multiple position points within a subsurface scattering range of a first position point includes: determining the weight of the diffuse reflection texture data based on the distance between a position point corresponding to any diffuse reflection texture data within the subsurface scattering range and the first position point, wherein the weight is negatively correlated with the distance.
[0147] One point that needs to be explained is that the weight of the diffuse reflection texture can also be determined based on the distance and surface curvature provided above, which is not limited in the embodiment of the present disclosure.
[0148] Another point to be explained is that the texture data obtained by blurring can simulate the subsurface scattering effect of the target object. In order to better maintain the diffuse reflection effect of the target object, the diffuse reflection texture data of multiple positions on the surface of the target object and the blurred texture data can also be fused to obtain the fused texture data, and the texture data of multiple positions are obtained from the fused texture data as the texture data of multiple positions in step 304. In a possible implementation, before rendering is performed according to the texture data of each position and the first brightness value of each position to obtain the target object image with subsurface scattering effect, for any position, the diffuse reflection texture data of any position and the diffuse reflection texture data of at least one other position within the subsurface scattering range of any position are fused, and then continue to be fused with the diffuse reflection texture data of any position to obtain the texture data of each position. In this way, the texture data of multiple positions obtained can not only simulate the subsurface scattering effect well, but also simulate the diffuse reflection effect, thereby improving the realism of the target object image.
[0149] Another point that needs to be explained is that the texture data of multiple position points provided in the embodiment of the present disclosure can also be obtained through Gaussian blur processing or other blur processing methods, which is not limited in the embodiment of the present disclosure.
[0150] Another point that needs to be explained is that in one possible implementation, the diffuse reflection texture data of the position point in the embodiment of the present disclosure can be directly obtained from the device. For example, the diffuse reflection texture data of the target object is the surface texture image of the real target object taken by the camera device. Since the light is diffusely reflected on the surface of the real target object, the camera device can capture the real target object. Therefore, the surface texture image of the real target object can be used as the diffuse reflection texture data.
[0151] In another possible implementation, the diffuse reflection texture data of multiple position points in the embodiment of the present disclosure can also be obtained by performing diffuse reflection rendering on the initial surface texture data of the target object, that is, the initial surface texture data of the target object is rendered by a virtual light source to obtain the diffuse reflection texture data of the target object.
[0152] In step 305, a fused color value of each position point is determined according to the first color value of the virtual incident light at each position point and the second color value indicated by the texture data of each position point.
[0153] The display effect of an object is affected by the light of the environment in which it is located. The texture data of the multiple position points obtained in step 304 of the embodiment of the present disclosure have not been affected by the virtual environment in which the target object is located. If only the texture data of the multiple position points are used for rendering, the target object in the obtained target object image may be out of tune with the surrounding environment. Therefore, it is necessary to further fuse the texture data of each position point with the light in the virtual environment in which the target object is located.
[0154] Among them, the color of the target object will be affected by the color of the outer surface of the target object, the color of the sub-surface and the color of the ambient light. For example, the target object is a leaf, the outer surface color and the sub-surface color of the target object are green, and the ambient light is orange-red. Then, the target object is displayed as green or orange-red, which is inconsistent with the actual display effect. It is necessary to merge green and orange-red to obtain the color displayed by the target object.
[0155] For example, the first color value of the virtual incident light at each position point, the second color value indicated by the texture data at each position point, and the fused color value at each position point may satisfy the following relationship:
[0156] CompositeColor=LightColor*(1.0+Ds)
[0157] Among them, CompositeColor is the fused color value of each position point, LightColor is the first color value of the virtual incident light at each position point, and Ds is the second color value indicated by the texture data of each position point.
[0158] In one possible implementation, the texture data of the target object is in a picture format, the texture data of multiple position points of the target object are pixel values of the multiple position points, and obtaining the second color value indicated in the texture data of each position point may include: obtaining the pixel value of each position point as the second color value of each position point; or, de-gamma processing the pixel value of each position point to obtain the second color value of each position point.
[0159] The texture data of each position point is the texture data obtained in step 304. In a possible implementation, the texture data of each position point is the data after the diffuse reflection texture data of each position point is blurred, and the color of each position point in the texture data is similar to the color scattered by the subsurface of the target object. Therefore, the color value of the virtual incident light is merged with the color value of each position point in the texture data, which can better simulate the subsurface scattering effect of the target object in the current environment.
[0160] In another possible implementation, the texture data of the multiple position points are: the diffuse reflection texture data of the multiple position points and the blurred texture data are fused to obtain the fused texture data. The color of each position point in the fused texture data is similar to the fused color of the color scattered from the subsurface of the target object and the color diffusely reflected from the surface of the target object. By merging the color value of the virtual incident light with the color value of each position point in the fused texture data, the subsurface scattering effect and diffuse reflection effect of the target object in the current environment can be better simulated.
[0161] In a possible implementation, the target object receives virtual incident light rays emitted by multiple virtual light sources, and then ....
[0162] For example, the target object is a human body, and the virtual environment in which the target object is located includes a virtual sun and a virtual forest, wherein the virtual incident light emitted by the virtual sun can be considered as white light, and the virtual incident light reflected by the virtual forest can be considered as green light. If a certain position point receives the virtual incident light emitted by the virtual sun and the virtual incident light reflected by the virtual forest, and the texture data of the position point indicates that the position point is red, then the color displayed by the position point should be a fusion of white, green and red.
[0163] For example, Figure 4 As shown in FIG. 1 , the target object is a human body, and the virtual environment in which the human body is located includes a virtual plain. The color of the virtual plain is yellow, and the color displayed by the human body will be affected by the yellow color. Figure 5 As shown, the virtual environment in which the human body is located includes a virtual ocean, and the color of the virtual ocean is blue. Then the color displayed by the human body will be affected by the blue color, such as Figure 6 As shown, the virtual environment in which the human body is located includes a virtual forest, and the color of the virtual forest is green. Then the color displayed by the human body will be affected by green, such as Figure 7 As shown, the virtual environment where the human body is located does not include other virtual objects, so the color displayed by the human body is not affected by the virtual environment.
[0164] It should be noted that the embodiments of the present disclosure provide Figures 4 to 7 Different grayscale values are used to represent different display colors of the human body.
[0165] In step 306, rendering is performed according to the texture data of each position point, the first brightness value of each position point, and the fused color value of each position point to obtain a target object image with a subsurface scattering effect.
[0166] The texture data of each position point represents the texture of the object with subsurface scattering effect, the first brightness value of each position point represents the brightness of the object with subsurface scattering effect, and the fused color value of each position point represents the color that the object should display under the influence of ambient light. Therefore, rendering can be performed based on the texture data of each position point, the first brightness value of each position point, and the fused color value of each position point to obtain the target object image with subsurface scattering effect.
[0167] In one possible implementation, rendering is performed according to the texture data of each position point, the first brightness value of each position point, and the fused color value of each position point to obtain a target object image with a subsurface scattering effect, which may include: rendering the texture data of each position point according to the first brightness value of each position point and the fused color value of each position point to obtain rendered texture data, mapping the rendered texture data onto the target object, and generating a target object image with a subsurface scattering effect.
[0168] Among them, rendering the texture data of each position point according to the first brightness value of each position point and the fused color value of each position point can include: fusing the first brightness value of each position point and the fused color value of each position point to obtain a fused pixel value, and rendering the texture data of each position point according to the fused pixel value of each position point.
[0169] Alternatively, in another possible implementation, rendering is performed according to the texture data of each position point, the first brightness value of each position point, and the fused color value of each position point to obtain a target object image with a subsurface scattering effect, which may include: fusing the texture data of each position point, the first brightness value of each position point, and the fused color value of each position point to obtain a pixel value of each position point, and rendering is performed according to the pixel value of each position point to obtain a target object image with a subsurface scattering effect.
[0170] One point that needs to be explained is that, since the embodiment of the present disclosure provides a target object image rendering method, a target object image with a subsurface scattering effect will be generated. If the subsurface scattering range size of a certain position point in the target object is smaller than the size of a pixel, the subsurface scattering effect of the position point cannot be rendered. Therefore, in order to reduce the amount of calculation, after obtaining the subsurface scattering range of each position point, the target normal direction can be obtained for multiple position points whose subsurface scattering range size is larger than the size of a pixel, and the diffuse reflection texture data within the subsurface scattering range can be fused. For multiple position points whose subsurface scattering range size is less than or equal to the size of a pixel, the initial normal direction and diffuse reflection texture data can be kept unchanged.
[0171] Another point that needs to be explained is that in order to obtain a realistic target object image, a highlight effect can also be superimposed on the target object. In a possible implementation, rendering is performed according to the texture data of each position point and the first brightness value of each position point to obtain a target object image with a subsurface scattering effect, including: obtaining the second brightness value of each position point according to the light reflectivity, virtual incident light direction and initial normal direction of each position point; superimposing the first brightness value of each position point with the second brightness value of the corresponding position point respectively to obtain the third brightness value of each position point; rendering is performed according to the texture data of each position point and the third brightness value of each position point to obtain a target object image with a subsurface scattering effect. The target object image has not only a subsurface scattering effect, but also a highlight effect, so the target object image is more realistic. Among them, the light reflectivity of each position point is related to the material of the position point. For example, the oil layer in the forehead of the human body will secrete more oil, which is prone to highlight effects, so the light reflectivity corresponding to the forehead is higher.
[0172] The target object image rendering method provided by the embodiment of the present disclosure is that when subsurface scattering occurs at any position point in the object, the brightness value of the position point will be affected by the brightness values of other surrounding position points, and the brightness value of the position point is determined by the normal direction of the position point and the direction of the virtual incident light. Therefore, the directions of the virtual incident light emitted by the same virtual light source are controlled to be the same, and the virtual incident light received by the target object is regarded as parallel light to avoid the influence of the direction of the virtual incident light, thereby reducing the processing amount and the performance requirements for the device, so that the target object image rendering method can be applied to more types of devices and has a wider range of applications. When obtaining the brightness value of each position point, only the influence of the normal direction of other surrounding position points needs to be considered. Therefore, the initial normal direction of each position point is fused with the initial normal direction of other surrounding position points, and the brightness value is obtained according to the target normal direction and the virtual incident light direction obtained after the fusion of each position point. The accuracy of the brightness value can still be guaranteed, thereby ensuring the subsurface scattering effect of the target object image.
[0173] Moreover, when the initial normal directions of other surrounding position points are fused with the initial normal direction of the position point, different weights are assigned to the initial normal directions of different position points, taking into account the different influence degrees of different position points, so that the weights of the position points with greater influence among other surrounding position points are also greater, and the weights of the position points with less influence are also smaller. Therefore, the brightness of the position point after subsurface scattering can be accurately obtained according to the fused target normal direction.
[0174] Furthermore, since the closer the distance between the position points is, the higher the degree of mutual influence is, therefore, weights can be assigned to the initial normal directions of other position points according to the distances between the other position points and the first position point within the subsurface scattering range of the first position point, and the weight is negatively correlated with the distance, and then the initial normal directions of the other position points are weighted according to the assigned weights, so that the target normal direction of the first position point is more accurate.
[0175] In addition, since the thinner the area where the location point is located, the easier it is to affect the surrounding location points, and the surface curvature of the location point can indicate the thickness of the area where the location point is located, the surface curvature of each location point can indicate the degree of influence of the location point on other location points. A weight is assigned to the initial normal direction of each location point according to the surface curvature of each location point, and the weight is positively correlated with the surface curvature. The initial normal directions of other location points can be weighted according to the assigned weight, and the target normal direction of the first location point obtained can be more accurate.
[0176] Furthermore, the disclosed embodiment takes into account the influence of ambient light on the display effect of an object and determines the brightness and color of the target object according to the ambient light and the texture data of the target object, so that the rendered image of the target object is more in line with the environment and more realistic.
[0177] In addition, when blurring the diffuse texture data, there is no need to perform real-time sampling during the image rendering process, and the parameters involved in the blurring are determined by the surface curvature of multiple position points in the target object. Since the shape of the target object is fixed, the surface curvature of multiple position points and the parameters involved in the blurring are fixed. Therefore, the diffuse texture data of the target object can be blurred multiple times in the preprocessing process before rendering the image to ensure the subsurface scattering effect in the target object image without affecting the real-time rendering progress of the image.
[0178] Figure 8 is a block diagram of a target object image rendering device according to an exemplary embodiment. Figure 8 The device includes a normal determining unit 801, a brightness value determining unit 802 and a rendering unit 803.
[0179] The normal determination unit 801 is configured to determine the target normal direction of each position point according to the initial normal direction of each position point on the surface of the target object and the initial normal direction of at least one other position point within the subsurface scattering range of each position point;
[0180] The brightness value determining unit 802 is configured to obtain a first brightness value of each position point according to the target normal direction and the direction of the virtual incident light at each position point, wherein each position point receives a virtual incident light emitted by at least one virtual light source, and the direction of the virtual incident light emitted by the same virtual light source is the same;
[0181] A rendering unit 803 is configured to perform rendering according to the texture data of each position point and the first brightness value of each position point to obtain a target object image with a subsurface scattering effect;
[0182] The subsurface scattering range of any position point refers to: scattering occurs inside the target object, and a virtual light beam including the light emission range of any position point is formed on the surface of the target object, and the incident range on the surface of the target object.
[0183] The target object image rendering device provided by the embodiment of the present disclosure assumes that the directions of virtual incident light rays emitted by the same virtual light source are the same, and regards the virtual incident light rays received by the target object as parallel light. Thus, the influence of the brightness of any position point in the target object on the brightness of other surrounding position points can be approximated as the fusion of the initial normal direction of other surrounding position points and the initial normal direction of the position point. Therefore, the processing steps and processing amount required to obtain the brightness of the object under the subsurface scattering effect are reduced, thereby reducing the processing steps and processing amount for obtaining the target object image with the subsurface scattering effect, reducing the performance requirements for the device, and making the target object image rendering method applicable to more types of devices and having a wider range of applications.
[0184] like Fig. 9 As shown, in a possible implementation, the device further includes:
[0185] The curvature determination unit 804 is configured to determine the surface curvature of each position point on the surface of the target object according to the shape parameters of the target object;
[0186] The range determination unit 805 is configured to determine the sub-surface scattering range of each position point according to the surface curvature of each position point, and the size of the sub-surface scattering range of the position point is positively correlated with the surface curvature of the position point.
[0187] In a possible implementation, the range determination unit 805 is configured to perform the following steps:
[0188] When the surface curvature of any position point is greater than the target curvature threshold, the subsurface scattering radius of the position point is increased according to the increase corresponding to the difference between the surface curvature and the target curvature threshold. The surface scattering radius is the radius of the subsurface scattering range, and the difference is positively correlated with the increase.
[0189] When the surface curvature of the position point is less than the target curvature threshold, the subsurface scattering radius of the position point is reduced according to the reduction amplitude corresponding to the difference between the surface curvature and the target curvature threshold, and the difference is positively correlated with the reduction amplitude;
[0190] When the surface curvature of a position point is equal to the target curvature threshold, the subsurface scattering radius of the position point is kept unchanged.
[0191] In one possible implementation, the normal determination unit 801 is configured to perform weighted processing on the initial normal direction of the first position point and the initial normal direction of at least one other position point within the subsurface scattering range of the first position point, to obtain a target normal direction of the first position point, where the first position point is any position point on the surface of the target object.
[0192] In a possible implementation, the device further includes:
[0193] The weight determination unit 806 is configured to perform at least one of the following:
[0194] Determine the weight of the first initial normal direction according to the distance between the second position point corresponding to the first initial normal direction and the first position point, where the weight is negatively correlated with the distance;
[0195] Determine a weight of the first initial normal direction according to the surface curvature of the second position point corresponding to the first initial normal direction, where the weight is positively correlated with the surface curvature;
[0196] The second position point is any position point within the subsurface scattering range of the first position point that is different from the first position point.
[0197] In a possible implementation, the brightness value determination unit 802 is configured to obtain the brightness value of each position point according to the angle between the target normal direction of each position point and the direction of the virtual incident light, and the brightness value is negatively correlated with the angle.
[0198] In a possible implementation, the device further includes:
[0199] The texture fusion unit 807 is configured to perform weighted processing on the diffuse reflection texture data of any position point and the diffuse reflection texture data of at least one other position point within the subsurface scattering range of any position point, so as to obtain texture data of any position point;
[0200] The diffuse reflection texture data of any position point is obtained by performing diffuse reflection rendering on the initial texture data of any position point.
[0201] In a possible implementation, the device further includes:
[0202] The weight determination unit 806 is configured to determine the weight of the diffuse reflection texture data of at least one other position point according to the surface curvature of at least one other position point within the subsurface scattering range, and the weight is positively correlated with the surface curvature.
[0203] In a possible implementation, the device further includes:
[0204] The texture fusion unit 807 is configured to perform fusion processing on the diffuse reflection texture data of any position point and the diffuse reflection texture data of at least one other position point within the subsurface scattering range of any position point, and continue to perform fusion processing with the diffuse reflection texture data of any position point to obtain the texture data of any position point.
[0205] In a possible implementation, the rendering unit 803 includes:
[0206] The color fusion subunit 8031 is configured to determine a fusion color value of each position point according to a first color value of a virtual incident light at each position point and a second color value indicated by texture data of each position point;
[0207] The rendering subunit 8032 is configured to perform rendering according to the texture data of each position point, the first brightness value of each position point and the fused color value of each position point to obtain a target object image with a subsurface scattering effect.
[0208] In one possible implementation, the rendering unit 803 is configured to obtain a second brightness value for each position point based on the light reflectivity, virtual incident light direction and initial normal direction of each position point; superimpose the first brightness value of each position point with the second brightness value of the corresponding position point to obtain a third brightness value for each position point; and render according to the texture data of each position point and the third brightness value of each position point to obtain an image of the target object with a subsurface scattering effect.
[0209] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0210] Fig.10It is a structural block diagram of an electronic device, such as a terminal, provided in an embodiment of the present disclosure. The terminal 1000 is used to execute the steps executed by the terminal in the above embodiment, and can be a portable mobile terminal, such as: a smart phone, a tablet computer, an MP3 player (Moving Picture Experts Group Audio Layer III, Moving Picture Experts Group Audio Layer 3), an MP4 (Moving Picture Experts Group Audio Layer IV, Moving Picture Experts Group Audio Layer 4) player, a laptop computer or a desktop computer. The terminal 1000 may also be called a user device, a portable terminal, a laptop terminal, a desktop terminal, and other names.
[0211] Typically, the terminal 1000 includes a processor 1001 and a memory 1002 .
[0212] The processor 1001 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 1001 may be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). The processor 1001 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 1001 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 1001 may also include an AI (Artificial Intelligence) processor, which is used to process computing operations related to machine learning.
[0213] The memory 1002 may include one or more computer-readable storage media, which may be non-transitory. The memory 1002 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In some embodiments, the non-transitory computer-readable storage medium in the memory 1002 is used to store at least one instruction, which is used to be executed by the processor 1001 to implement the target object image rendering method provided in the method embodiment of the present application.
[0214] In some embodiments, the terminal 1000 may also optionally include: a peripheral device interface 1003 and at least one peripheral device. The processor 1001, the memory 1002 and the peripheral device interface 1003 may be connected via a bus or a signal line. Each peripheral device may be connected to the peripheral device interface 1003 via a bus, a signal line or a circuit board. Specifically, the peripheral device includes: at least one of a radio frequency circuit 1004, a touch display screen 1005, a camera assembly 1006, an audio circuit 1007, a positioning assembly 1008 and a power supply 1009.
[0215] The peripheral device interface 1003 may be used to connect at least one peripheral device related to I / O (Input / Output) to the processor 1001 and the memory 1002. In some embodiments, the processor 1001, the memory 1002, and the peripheral device interface 1003 are integrated on the same chip or circuit board; in some other embodiments, any one or two of the processor 1001, the memory 1002, and the peripheral device interface 1003 may be implemented on a separate chip or circuit board, which is not limited in this embodiment.
[0216] The radio frequency circuit 1004 is used to receive and transmit RF (Radio Frequency) signals, also known as electromagnetic signals. The radio frequency circuit 1004 communicates with the communication network and other communication devices through electromagnetic signals. The radio frequency circuit 1004 converts the electrical signal into an electromagnetic signal for transmission, or converts the received electromagnetic signal into an electrical signal. Optionally, the radio frequency circuit 1004 includes: an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a user identity module card, etc. The radio frequency circuit 1004 can communicate with other terminals through at least one wireless communication protocol. The wireless communication protocol includes but is not limited to: the World Wide Web, a metropolitan area network, an intranet, various generations of mobile communication networks (2G, 3G, 4G and 5G), a wireless local area network and / or a WiFi (Wireless Fidelity) network. In some embodiments, the radio frequency circuit 1004 may also include circuits related to NFC (Near Field Communication), which is not limited in this application.
[0217] The display screen 1005 is used to display a UI (User Interface). The UI may include graphics, text, icons, videos, and any combination thereof. When the display screen 1005 is a touch display screen, the display screen 1005 also has the ability to collect touch signals on the surface or above the surface of the display screen 1005. The touch signal can be input to the processor 1001 as a control signal for processing. At this time, the display screen 1005 can also be used to provide virtual buttons and / or virtual keyboards, also known as soft buttons and / or soft keyboards. In some embodiments, the display screen 1005 can be one, and the front panel of the terminal 1000 is set; in other embodiments, the display screen 1005 can be at least two, which are respectively set on different surfaces of the terminal 1000 or are folded; in some other embodiments, the display screen 1005 can be a flexible display screen, which is set on the curved surface or folded surface of the terminal 1000. Even, the display screen 1005 can also be set to a non-rectangular irregular shape, that is, a special-shaped screen. The display screen 1005 can be made of materials such as LCD (Liquid Crystal Display) and OLED (Organic Light-Emitting Diode).
[0218] The camera assembly 1006 is used to capture images or videos. Optionally, the camera assembly 1006 includes a front camera and a rear camera. Typically, the front camera is arranged on the front panel of the terminal, and the rear camera is arranged on the back of the terminal. In some embodiments, there are at least two rear cameras, which are any one of a main camera, a depth of field camera, a wide-angle camera, and a telephoto camera, so as to realize the fusion of the main camera and the depth of field camera to realize the background blur function, the fusion of the main camera and the wide-angle camera to realize the panoramic shooting and VR (Virtual Reality) shooting function or other fusion shooting functions. In some embodiments, the camera assembly 1006 may also include a flash. The flash can be a monochrome temperature flash or a dual-color temperature flash. A dual-color temperature flash refers to a combination of a warm light flash and a cold light flash, which can be used for light compensation at different color temperatures.
[0219] The audio circuit 1007 may include a microphone and a speaker. The microphone is used to collect sound waves from the user and the environment, and convert the sound waves into electrical signals and input them into the processor 1001 for processing, or input them into the radio frequency circuit 1004 to achieve voice communication. For the purpose of stereo acquisition or noise reduction, there may be multiple microphones, which are respectively arranged at different parts of the terminal 1000. The microphone may also be an array microphone or an omnidirectional acquisition microphone. The speaker is used to convert the electrical signal from the processor 1001 or the radio frequency circuit 1004 into sound waves. The speaker may be a traditional film speaker or a piezoelectric ceramic speaker. When the speaker is a piezoelectric ceramic speaker, it can not only convert the electrical signal into sound waves audible to humans, but also convert the electrical signal into sound waves inaudible to humans for purposes such as ranging. In some embodiments, the audio circuit 1007 may also include a headphone jack.
[0220] The positioning component 1008 is used to locate the current geographical location of the terminal 1000 to implement navigation or LBS (Location Based Service). The positioning component 1008 can be a positioning component based on the US GPS (Global Positioning System), China's Beidou system, Russia's Greiner system, or the European Union's Galileo system.
[0221] The power supply 1009 is used to power various components in the terminal 1000. The power supply 1009 can be an alternating current, a direct current, a disposable battery, or a rechargeable battery. When the power supply 1009 includes a rechargeable battery, the rechargeable battery can support wired charging or wireless charging. The rechargeable battery can also be used to support fast charging technology.
[0222] In some embodiments, the terminal 1000 further includes one or more sensors 1010 , including but not limited to: an acceleration sensor 1011 , a gyroscope sensor 1012 , a pressure sensor 1013 , a fingerprint sensor 1014 , an optical sensor 1015 , and a proximity sensor 1016 .
[0223] The acceleration sensor 1011 can detect the magnitude of acceleration on the three coordinate axes of the coordinate system established by the terminal 1000. For example, the acceleration sensor 1011 can be used to detect the components of gravity acceleration on the three coordinate axes. The processor 1001 can control the touch display screen 1005 to display the user interface in a horizontal view or a vertical view according to the gravity acceleration signal collected by the acceleration sensor 1011. The acceleration sensor 1011 can also be used for collecting game or user motion data.
[0224] The gyro sensor 1012 can detect the body direction and rotation angle of the terminal 1000, and the gyro sensor 1012 can cooperate with the acceleration sensor 1011 to collect the user's 3D actions on the terminal 1000. The processor 1001 can implement the following functions based on the data collected by the gyro sensor 1012: motion sensing (such as changing the UI according to the user's tilt operation), image stabilization during shooting, game control, and inertial navigation.
[0225] The optical sensor 1015 is used to collect the ambient light intensity. In one embodiment, the processor 1001 can control the display brightness of the touch display screen 1005 according to the ambient light intensity collected by the optical sensor 1015. Specifically, when the ambient light intensity is high, the display brightness of the touch display screen 1005 is increased; when the ambient light intensity is low, the display brightness of the touch display screen 1005 is reduced. In another embodiment, the processor 1001 can also dynamically adjust the shooting parameters of the camera assembly 1006 according to the ambient light intensity collected by the optical sensor 1015.
[0226] Those skilled in the art will understand that Fig.10 The structure shown in the figure does not constitute a limitation on the terminal 1000, and the terminal 1000 may include more or less components than those shown in the figure, or combine some components, or adopt a different component arrangement.
[0227] Fig.11It is a block diagram of a server 1100 according to an exemplary embodiment. The server 1100 may have relatively large differences due to different configurations or performances, and may include one or more processors (central processing units, CPU) 1101 and one or more memories 1102, wherein the memory 1102 stores at least one instruction, and at least one instruction is loaded and executed by the processor 1101 to implement the methods provided by the above-mentioned various method embodiments. Of course, the server may also have components such as a wired or wireless network interface, a keyboard, and an input and output interface for input and output, and the server may also include other components for implementing device functions, which will not be repeated here.
[0228] The server 1100 may be used to execute the steps executed by the server in the above-mentioned target object image rendering method.
[0229] In an exemplary embodiment, a storage medium is further provided. When instructions in the storage medium are executed by a processor of an electronic device, the electronic device can execute the target object image rendering method as described above.
[0230] In an exemplary embodiment, a computer program product is also provided, including executable instructions. When the instructions in the computer program product are executed by a processor of an electronic device, the electronic device can execute the target object image rendering method provided by the embodiment of the present disclosure.
[0231] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.
[0232] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A method for rendering a target object image, characterized in that: The method comprises: Determine the weight of the first initial normal direction by at least one of method 1 and method 2: Method 1: determining the weight of the first initial normal direction according to the distance between the second position point corresponding to the first initial normal direction and the first position point, wherein the weight is negatively correlated with the distance; Method 2: determining a weight of the first initial normal direction according to the surface curvature of the second position point corresponding to the first initial normal direction, wherein the weight is positively correlated with the surface curvature; The first position point is any position point on the surface of the target object, and the second position point is any position point different from the first position point within the subsurface scattering range of the first position point; According to the weight of the initial normal direction of the first position point and the weight of the initial normal direction of at least one other position point within the subsurface scattering range of the first position point, weighted processing is performed on the initial normal direction of the first position point and the initial normal direction of the at least one other position point to obtain a target normal direction of the first position point; Acquire a first brightness value of each position point according to a target normal direction and a virtual incident light direction of each position point on the surface of the target object, wherein each position point receives a virtual incident light emitted by at least one virtual light source, and the direction of the virtual incident light emitted by the same virtual light source is the same; Rendering is performed according to the texture data of each position point and the first brightness value of each position point to obtain a target object image with a subsurface scattering effect; The subsurface scattering range of any position point refers to: scattering occurs inside the target object, and a virtual light beam including the light emission range of any position point is formed on the surface of the target object, and the incident range on the surface of the target object.
2. The method according to claim 1, characterized in that The method further comprises: Determining the surface curvature of each position point on the surface of the target object according to the shape parameters of the target object; The sub-surface scattering range of each position point is determined according to the surface curvature of each position point, and the size of the sub-surface scattering range of the position point is positively correlated with the surface curvature of the position point.
3. The method according to claim 2, characterized in that Determining the subsurface scattering range of each position point according to the surface curvature of each position point includes: When the surface curvature of any position point is greater than the target curvature threshold, the subsurface scattering radius of the position point is increased according to the increase amplitude corresponding to the difference between the surface curvature and the target curvature threshold, the subsurface scattering radius is the radius of the subsurface scattering range, and the difference is positively correlated with the increase amplitude; When the surface curvature of the position point is less than the target curvature threshold, the subsurface scattering radius of the position point is reduced according to the reduction amplitude corresponding to the difference between the surface curvature and the target curvature threshold, and the difference is positively correlated with the reduction amplitude; When the surface curvature of the position point is equal to the target curvature threshold, the subsurface scattering radius of the position point is kept unchanged.
4. The method according to claim 1, characterized in that: The step of obtaining a first brightness value of each position point according to a target normal direction and a virtual incident light direction of each position point on the surface of the target object comprises: According to the angle between the target normal direction of each position point and the direction of the virtual incident light, a first brightness value of each position point is obtained, and the first brightness value is negatively correlated with the angle.
5. The method according to claim 1, characterized in that Before rendering according to the texture data of each position point and the first brightness value of each position point to obtain the target object image with subsurface scattering effect, the method further includes: For any position point, according to the weight of the diffuse reflection texture data of the any position point and the weight of the diffuse reflection texture data of at least one other position point within the subsurface scattering range of the any position point, weighted processing is performed on the diffuse reflection texture data of the any position point and the diffuse reflection texture data of the at least one other position point to obtain the texture data of the any position point; The diffuse reflection texture data of any position point is obtained by performing diffuse reflection rendering on the initial texture data of any position point.
6. The method according to claim 5, characterized in that Before obtaining the texture data of any position point, the method further comprises: performing weighted processing on the diffuse reflection texture data of any position point and the diffuse reflection texture data of at least one other position point within the subsurface scattering range of the any position point according to the weight of the diffuse reflection texture data of the any position point and the weight of the diffuse reflection texture data of at least one other position point, and obtaining the texture data of the any position point. The weight of the diffuse reflection texture data of at least one other position point is determined according to the surface curvature of at least one other position point within the subsurface scattering range, and the weight is positively correlated with the surface curvature.
7. The method according to claim 1, characterized in that Before rendering according to the texture data of each position point and the first brightness value of each position point to obtain the target object image with subsurface scattering effect, the method further includes: For any position point, the diffuse reflection texture data of the any position point and the diffuse reflection texture data of at least one other position point within the subsurface scattering range of the any position point are fused, and then fused with the diffuse reflection texture data of the any position point to obtain the texture data of the any position point.
8. The method according to claim 1, characterized in that: The rendering is performed according to the texture data of each position point and the first brightness value of each position point to obtain a target object image with a subsurface scattering effect, including: Determine a fused color value of each position point according to a first color value of a virtual incident light at each position point and a second color value indicated by texture data at each position point; Rendering is performed according to the texture data of each position point, the first brightness value of each position point and the fused color value of each position point to obtain a target object image with a subsurface scattering effect.
9. The method according to claim 1, characterized in that: The rendering is performed according to the texture data of each position point and the first brightness value of each position point to obtain a target object image with a subsurface scattering effect, including: Acquire a second brightness value of each position point according to the light reflectivity, virtual incident light direction and initial normal direction of each position point; Superimposing the first brightness value of each position point with the second brightness value of the corresponding position point to obtain a third brightness value of each position point; Rendering is performed according to the texture data of each position point and the third brightness value of each position point to obtain a target object image with a subsurface scattering effect.
10. A target object image rendering device, characterized in that: The device comprises: The weight determination unit is configured to perform at least one of the following: Determine a weight of the first initial normal direction according to a distance between a second position point corresponding to the first initial normal direction and the first position point, wherein the weight is negatively correlated with the distance; Determine a weight of the first initial normal direction according to the surface curvature of the second position point corresponding to the first initial normal direction, wherein the weight is positively correlated with the surface curvature; The first position point is any position point on the surface of the target object, and the second position point is any position point different from the first position point within the subsurface scattering range of the first position point; a normal determining unit, configured to perform weighted processing on the initial normal direction of the first position point and the initial normal direction of at least one other position point within a subsurface scattering range of the first position point according to the weight of the initial normal direction of the first position point and the weight of the initial normal direction of the at least one other position point, so as to obtain a target normal direction of the first position point; a brightness value determining unit, configured to obtain a first brightness value of each position point on the surface of the target object according to a target normal direction and a virtual incident light direction of each position point, wherein each position point receives a virtual incident light emitted by at least one virtual light source, and the direction of the virtual incident light emitted by the same virtual light source is the same; A rendering unit, configured to perform rendering according to the texture data of each position point and the first brightness value of each position point, to obtain a target object image with a subsurface scattering effect; The subsurface scattering range of any position point refers to: scattering occurs inside the target object, and a virtual light beam including the light emission range of any position point is formed on the surface of the target object, and the incident range on the surface of the target object.
11. The device according to claim 10, characterized in that The device also includes: a curvature determination unit, configured to determine the surface curvature of each position point on the surface of the target object according to the shape parameters of the target object; The range determination unit is configured to determine the sub-surface scattering range of each position point according to the surface curvature of each position point, wherein the size of the sub-surface scattering range of the position point is positively correlated with the surface curvature of the position point.
12. The device according to claim 11, characterized in that The range determination unit is configured to perform the following steps: When the surface curvature of any position point is greater than the target curvature threshold, the subsurface scattering radius of the position point is increased according to the increase amplitude corresponding to the difference between the surface curvature and the target curvature threshold, the subsurface scattering radius is the radius of the subsurface scattering range, and the difference is positively correlated with the increase amplitude; When the surface curvature of the position point is less than the target curvature threshold, the subsurface scattering radius of the position point is reduced according to the reduction amplitude corresponding to the difference between the surface curvature and the target curvature threshold, and the difference is positively correlated with the reduction amplitude; When the surface curvature of the position point is equal to the target curvature threshold, the subsurface scattering radius of the position point is kept unchanged.
13. The device according to claim 10, characterized in that The brightness value determination unit is configured to obtain a first brightness value of each position point according to an angle between a target normal direction of each position point and a direction of a virtual incident light ray, wherein the first brightness value is negatively correlated with the angle.
14. The device according to claim 10, characterized in that The device also includes: The texture fusion unit is configured to perform weighted processing on the diffuse reflection texture data of any position point and the diffuse reflection texture data of at least one other position point within the subsurface scattering range of the any position point according to the weight of the diffuse reflection texture data of the any position point and the weight of the diffuse reflection texture data of at least one other position point, so as to obtain the texture data of the any position point; The diffuse reflection texture data of any position point is obtained by performing diffuse reflection rendering on the initial texture data of any position point.
15. The device according to claim 14, characterized in that The weight determination unit is further configured to determine the weight of the diffuse reflection texture data of at least one other position point according to the surface curvature of at least one other position point within the subsurface scattering range, wherein the weight is positively correlated with the surface curvature.
16. The device according to claim 10, characterized in that The device also includes: The texture fusion unit is configured to perform fusion processing on the diffuse reflection texture data of any position point and the diffuse reflection texture data of at least one other position point within the subsurface scattering range of any position point, and continue to perform fusion processing with the diffuse reflection texture data of any position point to obtain the texture data of any position point.
17. The device according to claim 10, characterized in that The rendering unit comprises: A color fusion subunit is configured to determine a fusion color value of each position point according to a first color value of a virtual incident light at each position point and a second color value indicated by texture data of each position point; The rendering subunit is configured to perform rendering according to the texture data of each position point, the first brightness value of each position point and the fused color value of each position point to obtain a target object image with a subsurface scattering effect.
18. The device according to claim 10, characterized in that The rendering unit is configured to obtain a second brightness value of each position point according to the light reflectivity, the virtual incident light direction and the initial normal direction of each position point; Superimposing the first brightness value of each position point with the second brightness value of the corresponding position point to obtain a third brightness value of each position point; Rendering is performed according to the texture data of each position point and the third brightness value of each position point to obtain a target object image with a subsurface scattering effect.
19. An electronic device, characterized in that: The electronic device comprises: one or more processors; a volatile or non-volatile memory for storing the one or more processor-executable instructions; The one or more processors are configured to execute the target object image rendering method according to any one of claims 1 to 9.
20. A storage medium, characterized in that: When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the target object image rendering method as described in any one of claims 1 to 9.
21. A computer program product, characterized in that The computer program product comprises executable instructions. When the instructions in the computer program product are executed by a processor of an electronic device, the electronic device is enabled to execute the target object image rendering method as described in any one of claims 1 to 9.
Citation Information
Patent Citations
Dynamic texture waterfall modeling method combined with multiple physical attributes
CN101937576A
Physical method based on environment mapping for simulating human skin subsurface scattering
CN104484896A
Three-dimensional virtual image displaying method, device, terminal and storage medium
CN109427083A
Virtual model rendering method and device, storage medium and electronic equipment
CN109685869A
Method, apparatus, and computer readable medium for light energy accounting in ray tracing
US20090096789A1
