Image rendering method, device, electronic device and storage medium
By performing pixel point conversion and illumination intensity coefficient calculation on the image in mixed reality technology, diverse projection pattern shapes are supported, and projection singularity problem in the prior art is solved and spatial reality is improved.
Patent Information
- Application Number
- CN202111436901.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-29
- Publication Date
- 2024-12-31
- Estimated Expiration
- 2041-11-29
AI Technical Summary
In the prior art, mixed reality (MR) projection lamps only support circular projection, resulting in a single projection pattern projected into real scene images, reducing the sense of spatial reality.
By obtaining the pixel points in the original image and converting them to the world coordinate system, determining the target pixel points and their lighting intensity coefficients within the preset projection range, reading the transparency channel value in the projection pattern texture map, and calculating the target pixels The projection color value of the point, and then the original image is projected and rendered, supporting a diverse projection pattern shape.
The diversity of the MR projection lights on the projection patterns in real scene images is realized, and the spatial reality is improved.
Smart Images

Figure CN114187400B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to an image rendering method, device, electronic device and storage medium. Background Art
[0002] Mixed Reality (MR) is a further development of Augmented Reality (AR) technology. Mixed Reality technology combines real and virtual world information, presents virtual information in real scenes, and allows virtual objects to interact with real scenes in real time, further enhancing the spatial reality of the user experience and bringing an immersive virtual-real interaction experience.
[0003] When the relevant technology performs lighting rendering on real scene images based on MR projectors on mobile devices, it only supports simple projection effects such as circular projection, which results in a single projection pattern projected into the real scene image and reduces the sense of spatial reality. Summary of the invention
[0004] The present disclosure provides an image rendering method, device, electronic device and storage medium to at least solve the problem that the related art only supports circular projection of MR projection lamps, resulting in a single projection pattern projected into the real scene image and poor spatial reality. The technical solution of the present disclosure is as follows:
[0005] According to a first aspect of an embodiment of the present disclosure, there is provided an image rendering method, comprising:
[0006] Acquire an original image, convert original pixel points in the original image into a world coordinate system, and obtain pixel space points corresponding to each original pixel point;
[0007] Determine a target pixel space point in each pixel space point that is within a preset projection range, and a light intensity coefficient corresponding to the target pixel space point; the preset projection range is a projection range of a preset virtual light source;
[0008] Determine the target coordinate value corresponding to the target pixel space point in the preset projection pattern texture map; the projection light intensity is stored in the transparency channel of the preset projection pattern texture map;
[0009] Reading the transparency channel value of the preset projection pattern texture map according to the target coordinate value to obtain the target projection light intensity corresponding to the target pixel space point;
[0010] Determine, according to the illumination intensity coefficient corresponding to the target pixel space point and the target projection light intensity, a projection color value corresponding to the target original pixel point corresponding to the target pixel space point under the preset virtual light source;
[0011] The original image is projected and rendered according to the projection color value corresponding to the target original pixel point under the preset virtual light source.
[0012] In an exemplary embodiment, determining a target pixel space point located within a preset projection range among the pixel space points, and a light intensity coefficient corresponding to the target pixel space point, includes:
[0013] Determine the cosine value of the angle between the light source direction vector of the preset virtual light source and a first vector; the first vector refers to a vector from the preset virtual light source to a first pixel space point, and the first pixel space point is any pixel space point among the pixel space points;
[0014] Determine a first target calculation value corresponding to the first pixel space point according to the angle cosine value and a preset boundary cosine value; the preset boundary cosine value indicates the preset projection range;
[0015] When the first target calculated value meets a preset condition, determining the first pixel space point as a target pixel space point;
[0016] Determine the illumination intensity coefficient corresponding to the target pixel space point according to the first target calculated value corresponding to the target pixel space point.
[0017] In an exemplary embodiment, determining the target coordinate value corresponding to the target pixel space point in the preset projection pattern texture map includes:
[0018] According to the illumination intensity coefficient corresponding to the target pixel space point, a maximum projection circle range corresponding to the target pixel space point is obtained;
[0019] According to the maximum projection circle range, determining a preset projection pattern texture map corresponding to the target pixel space point; the maximum center circle range of the preset projection pattern texture map is the maximum projection circle range;
[0020] The target pixel point within the maximum projection circle is mapped to the maximum center circle of the preset projection pattern texture map to obtain the target coordinate value corresponding to the target pixel space point in the preset projection pattern texture map.
[0021] In an exemplary embodiment, when the preset projection range is a cone, mapping the target pixel point within the maximum projection circle range to the maximum center circle range of the preset projection pattern texture map to obtain the target coordinate value corresponding to the target pixel space point in the preset projection pattern texture map includes:
[0022] Determine a first calculation vector according to the product of the unit axis vector of the cone and a second vector; the second vector refers to a vector from the preset virtual light source to the target pixel space point;
[0023] Determine a difference between the first calculation vector and the second vector to obtain a difference vector;
[0024] Dividing the difference vector by the product of the first calculation vector and the tangent value of the target angle to obtain a quotient; the target angle refers to the angle between the side surface of the cone and the central axis of the cone;
[0025] Determine a target sine value and a target cosine value according to the difference vector and a target unit direction vector; the target unit direction vector refers to a direction vector perpendicular to the central axis of the cone;
[0026] A target coordinate value is determined according to the quotient value, the target sine value, and the target cosine value.
[0027] In an exemplary embodiment, before performing projection rendering on the original image according to the projection color value corresponding to the target original pixel point under the preset virtual light source, the method further includes:
[0028] The target pixel space point is converted into a camera coordinate system corresponding to a target virtual camera to obtain a virtual camera projection point; the target virtual camera is a virtual camera that is set at the preset virtual light source and has a shooting direction that is consistent with the illumination direction of the preset virtual light source;
[0029] Determine the distance between the virtual camera projection point and the preset virtual light source;
[0030] Determine the depth information corresponding to the projection point of the virtual camera according to the depth map corresponding to the target virtual camera;
[0031] When the distance is less than the depth information, the step of rendering the original image according to the projection color value corresponding to the target original pixel under the preset virtual light source is performed.
[0032] In an exemplary embodiment, after performing projection rendering on the original image according to the projection color value corresponding to the target original pixel point under the preset virtual light source, the method further includes:
[0033] Determine a target line having an intersection with the preset projection range according to a line between a coordinate point of a main camera and each of the pixel space points; the main camera is a camera that captures the original image;
[0034] Determine a first distance between an intersection point corresponding to the target line and a coordinate point of the main camera, and a second distance between a pixel space point corresponding to the target line and a coordinate point of the main camera;
[0035] When the first distance is less than the second distance, light stepping is performed along the target line from the intersection point to the pixel space point on the target line to obtain the volume light color value of the original pixel point corresponding to the pixel space point on the target line;
[0036] The original image is volumetrically rendered according to the volumetric light color values of the original pixel points corresponding to the pixel space points on the target line.
[0037] In an exemplary embodiment, performing light stepping along the target line from the intersection point to a pixel space point on the target line to obtain a volume light color value of an original pixel point corresponding to the pixel space point on the target line includes:
[0038] Determine a disturbance amplitude value according to an original pixel point corresponding to the pixel space point on the target line and a preset three-dimensional floating-point constant vector;
[0039] Update the first distance according to the disturbance amplitude value;
[0040] Determine a stepping starting point on the target line according to the updated first distance;
[0041] Light stepping is performed from the stepping starting point along the target line toward a pixel space point on the target line to obtain a volume light color value of an original pixel point corresponding to the pixel space point on the target line.
[0042] In an exemplary embodiment, performing light stepping from the stepping starting point along the target line toward a pixel space point on the target line to obtain a volume light color value of an original pixel point corresponding to the pixel space point on the target line includes:
[0043] Determine a step distance, and determine a current step point on the target line according to a previous step point and the step distance;
[0044] Determine the color value of the current step point under the preset virtual light source;
[0045] Update the accumulated color value according to the color value of the current step point under the preset virtual light source and the transparent channel value of the accumulated color value; the accumulated color value refers to the sum of the color values of each target step point before the current step point under the preset virtual light source, and the target step point refers to the step point on the target line;
[0046] When a preset stepping end condition is met, the light stepping is stopped, and the accumulated color value when the light stepping is stopped is used as the volume light color value of the original pixel point corresponding to the pixel space point on the target line.
[0047] In an exemplary embodiment, determining the step distance includes:
[0048] determining a difference between the second distance and the updated first distance;
[0049] The step distance is determined according to the difference, a preset minimum step distance and a preset number of steps.
[0050] In an exemplary embodiment, when the preset projection range is a cone, determining the color value of the current step point under the preset virtual light source includes:
[0051] If the current step point is not in the shadow of the preset virtual light source, determining a third distance from the projection point of the current step point on the central axis of the cone to the preset virtual light source;
[0052] Determine a second target calculation value according to the third distance, the maximum projection distance of the cone center axis and a target angle; the target angle refers to the angle between the side surface of the cone and the cone center axis;
[0053] Determine a third target calculated value according to a fourth distance from the current step point to the central axis of the cone and the second target calculated value;
[0054] Determine a volume light color coefficient according to the third target calculated value, a fifth distance from the preset virtual light source to the current step point, and a maximum projection distance of the central axis of the cone;
[0055] According to the volume light color coefficient, the color value of the current step point under the preset virtual light source is determined.
[0056] According to a second aspect of an embodiment of the present disclosure, there is provided an image rendering device, including:
[0057] The original image acquisition unit is configured to acquire the original image, convert the original pixel points in the original image into the world coordinate system, and obtain the pixel space point corresponding to each original pixel point;
[0058] The illumination intensity coefficient determination unit is configured to determine a target pixel space point located within a preset projection range among each pixel space point, and an illumination intensity coefficient corresponding to the target pixel space point; the preset projection range is a projection range of a preset virtual light source;
[0059] A projection pattern texture coordinate determination unit is configured to determine a target coordinate value corresponding to the target pixel space point in a preset projection pattern texture map; the projection light intensity is stored in a transparency channel of the preset projection pattern texture map;
[0060] a projection light intensity determination unit, configured to read a transparency channel value of the preset projection pattern texture map according to the target coordinate value, and obtain a target projection light intensity corresponding to the target pixel space point;
[0061] a projection color value determining unit, configured to determine a projection color value corresponding to a target original pixel point corresponding to the target pixel space point under the preset virtual light source according to the illumination intensity coefficient corresponding to the target pixel space point and the target projection light intensity;
[0062] The projection rendering unit is configured to perform projection rendering on the original image according to the projection color value corresponding to the target original pixel point under the preset virtual light source.
[0063] In an exemplary embodiment, the illumination intensity coefficient determination unit includes:
[0064] A first determining unit is configured to determine a cosine value of an angle between a light source direction vector of the preset virtual light source and a first vector; the first vector refers to a vector from the preset virtual light source to a first pixel space point, and the first pixel space point is any pixel space point among the pixel space points;
[0065] A second determining unit is configured to determine a first target calculated value corresponding to the first pixel space point according to the angle cosine value and a preset boundary cosine value; the preset boundary cosine value indicates the preset projection range;
[0066] a target pixel space point determination unit, configured to determine the first pixel space point as a target pixel space point when the first target calculated value satisfies a preset condition;
[0067] The third determining unit is configured to determine the illumination intensity coefficient corresponding to the target pixel space point according to the first target calculated value corresponding to the target pixel space point.
[0068] In an exemplary embodiment, the projection pattern texture coordinate determination unit includes:
[0069] A maximum projection circle range determination unit is configured to obtain a maximum projection circle range corresponding to the target pixel space point according to the illumination intensity coefficient corresponding to the target pixel space point;
[0070] A preset projection pattern texture map determining unit is configured to determine the preset projection pattern texture map corresponding to the target pixel space point according to the maximum projection circle range; the maximum center circle range of the preset projection pattern texture map is the maximum projection circle range;
[0071] The mapping unit is configured to map the target pixel point within the maximum projection circle to the maximum center circle of the preset projection pattern texture map to obtain the target coordinate value corresponding to the target pixel space point in the preset projection pattern texture map.
[0072] In an exemplary embodiment, when the preset projection range is a cone, the mapping unit includes:
[0073] a fourth determining unit configured to determine a first calculation vector according to the product of the unit axis vector of the cone and a second vector; the second vector refers to a vector from the preset virtual light source to the target pixel space point;
[0074] a difference vector determining unit, configured to determine a difference between the first calculation vector and the second vector to obtain a difference vector;
[0075] a quotient determination unit configured to perform the division of the difference vector by the product of the first calculation vector and the tangent value of the target angle to obtain a quotient; the target angle refers to the angle between the side surface of the cone and the central axis of the cone;
[0076] A fifth determining unit is configured to determine a target sine value and a target cosine value according to the difference vector and a target unit direction vector; the target unit direction vector refers to a direction vector perpendicular to the central axis of the cone;
[0077] The sixth determining unit is configured to determine a target coordinate value according to the quotient value, the target sine value and the target cosine value.
[0078] In an exemplary embodiment, the apparatus further comprises:
[0079] A virtual camera projection point determination unit is configured to convert the target pixel space point into a camera coordinate system corresponding to a target virtual camera to obtain a virtual camera projection point; the target virtual camera is a virtual camera that is set at the preset virtual light source and has a shooting direction that is consistent with the illumination direction of the preset virtual light source;
[0080] A seventh determining unit is configured to determine the distance between the virtual camera projection point and the preset virtual light source;
[0081] A depth information determining unit, configured to determine the depth information corresponding to the projection point of the virtual camera according to the depth map corresponding to the target virtual camera;
[0082] Correspondingly, the projection rendering unit is configured to execute the step of rendering the original image according to the projection color value corresponding to the target original pixel point under the preset virtual light source when the distance is less than the depth information.
[0083] In an exemplary embodiment, the apparatus further comprises:
[0084] a target line determination unit, configured to determine a target line having an intersection with the preset projection range according to a line from a coordinate point of a main camera to each of the pixel space points; the main camera refers to a camera that captures the original image;
[0085] a distance determination unit, configured to determine a first distance between an intersection point corresponding to the target line and a coordinate point of the main camera, and a second distance between a pixel space point corresponding to the target line and a coordinate point of the main camera;
[0086] a light stepping unit configured to perform light stepping along the target line from the intersection point to a pixel space point on the target line when the first distance is less than the second distance, so as to obtain a volume light color value of an original pixel point corresponding to the pixel space point on the target line;
[0087] The volume light rendering unit is configured to perform volume light rendering on the original image according to the volume light color value of the original pixel point corresponding to the pixel space point on the target line.
[0088] In an exemplary embodiment, the light stepping unit comprises:
[0089] A disturbance amplitude determination unit is configured to determine a disturbance amplitude value according to an original pixel point corresponding to the pixel space point on the target line and a preset three-dimensional floating point constant vector;
[0090] A first updating unit, configured to update the first distance according to the disturbance amplitude value;
[0091] a stepping starting point determining unit, configured to determine a stepping starting point on the target line according to the updated first distance;
[0092] The light stepping subunit is configured to perform light stepping from the stepping starting point along the target line to the pixel space point on the target line to obtain the volume light color value of the original pixel point corresponding to the pixel space point on the target line.
[0093] In an exemplary embodiment, the light stepping subunit comprises:
[0094] a current step point determination unit, configured to determine a step distance and determine a current step point on the target line according to a previous step point and the step distance;
[0095] An eighth determining unit is configured to determine a color value of the current step point under the preset virtual light source;
[0096] A second updating unit is configured to update the accumulated color value according to the color value of the current step point under the preset virtual light source and the transparent channel value of the accumulated color value; the accumulated color value refers to the sum of the color values of each target step point before the current step point under the preset virtual light source, and the target step point refers to the step point on the target line;
[0097] The volume light color value determination unit is configured to stop light stepping when a preset stepping end condition is met, and use the accumulated color value when the light stepping stops as the volume light color value of the original pixel point corresponding to the pixel space point on the target line.
[0098] In an exemplary embodiment, the current step point determination unit includes:
[0099] a distance difference determination unit, configured to determine a difference between the second distance and the updated first distance;
[0100] The step distance determining unit is configured to determine the step distance according to the difference, a preset minimum step distance and a preset number of steps.
[0101] In an exemplary embodiment, when the preset projection range is a cone, the eighth determining unit includes:
[0102] a ninth determining unit, configured to determine, if the current step point is not in the shadow of the preset virtual light source, a third distance from a projection point of the current step point on the central axis of the cone to the preset virtual light source;
[0103] a tenth determining unit, configured to determine a second target calculated value according to the third distance, the maximum projection distance of the central axis of the cone, and a target angle; the target angle refers to an angle between the side surface of the cone and the central axis of the cone;
[0104] an eleventh determining unit, configured to determine a third target calculated value according to a fourth distance from the current step point to the central axis of the cone and the second target calculated value;
[0105] a volume light color coefficient determination unit, configured to determine the volume light color coefficient according to the third target calculation value, a fifth distance from the preset virtual light source to the current step point, and a maximum projection distance of the central axis of the cone;
[0106] A twelfth determining unit is configured to determine the color value of the current step point under the preset virtual light source according to the volume light color coefficient.
[0107] According to a third aspect of an embodiment of the present disclosure, there is provided an electronic device, including:
[0108] processor;
[0109] a memory for storing instructions executable by the processor;
[0110] Wherein, the processor is configured to execute the instructions to implement the image rendering method of the first aspect mentioned above.
[0111] According to a fourth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided. When instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the image rendering method of the first aspect described above.
[0112] According to a fifth aspect of an embodiment of the present disclosure, there is provided a computer program product, comprising a computer program / instruction, which implements the image rendering method of the first aspect when executed by a processor.
[0113] The technical solution provided by the embodiments of the present disclosure brings at least the following beneficial effects:
[0114] The pixel space points corresponding to each original pixel point are obtained by converting the original pixel points in the original image into the world coordinate system, and the target pixel space points in each pixel space point that are located within the preset projection range and the illumination intensity coefficient corresponding to the target pixel space point are determined, and then the coordinate value corresponding to the target pixel space point in the preset projection pattern texture map is determined, and the transparent channel value of the preset projection pattern texture map is read according to the target coordinate value to obtain the target projection light intensity corresponding to the target pixel space point, so as to determine the corresponding projection color value of the target original pixel point corresponding to the target pixel space point under the preset virtual light source according to the illumination intensity coefficient corresponding to the target pixel space point and the target projection light intensity, and the original image is projected and rendered according to the projection color value. Therefore, the above technical scheme supports defining the projection pattern shape in the original image through the preset projection pattern texture map, so that the projection pattern of the MR projector lamp on the real scene image is no longer just a circular projection, and a custom shape pattern can also be projected through the preset projection pattern texture, so as to realize the diversity of the projection pattern projected by the MR projector lamp into the real scene image, thereby improving the spatial realism.
[0115] 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
[0116] 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.
[0117] Figure 1 is a flowchart of an image rendering method according to an exemplary embodiment;
[0118] Figure 2 is an example of projection rendering obtained by using the image rendering method of the embodiment of the present disclosure;
[0119] Figure 3 is a flowchart of another image rendering method according to an exemplary embodiment;
[0120] Figure 4 is a flowchart of another image rendering method according to an exemplary embodiment;
[0121] Figure 5 This is an example of volumetric light rendering effect with obvious striped color blocks;
[0122] Figure 6 It is a flowchart showing a method of performing light stepping from an intersection point to a pixel space point on a target line along a target line to obtain a volume light color value of an original pixel point corresponding to the pixel space point on the target line according to an exemplary embodiment;
[0123] Figure 7 It is a flowchart of performing light stepping from a stepping starting point along a target line to a pixel space point on the target line to obtain a volume light color value of an original pixel point corresponding to the pixel space point on the target line according to an exemplary embodiment;
[0124] Figure 8 is an example of rendering with volumetric light obtained by using the image rendering method of the embodiment of the present disclosure;
[0125] Fig. 9 is a block diagram of an image rendering device according to an exemplary embodiment;
[0126] Fig.10 It is a block diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION
[0127] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings.
[0128] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. 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.
[0129] The image rendering method of the embodiment of the present disclosure may be executed by an electronic device, which may be a terminal or a server. The method may be executed by the terminal or the server alone, or by the terminal and the server in cooperation with each other.
[0130] The terminal may be a smart phone, a tablet computer, a laptop computer, a desktop computer, etc., but is not limited thereto; an application with an image rendering function may be installed in the terminal, and the application may be an independent application that realizes the image rendering function, or a subroutine in the application. Exemplarily, the application may include, but is not limited to, a video application, a live broadcast application, a game application, etc.
[0131] The server can be a background server that provides corresponding background services for the terminal's application. The server can be an independent physical server, a server cluster or a distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, as well as big data and artificial intelligence platforms.
[0132] Figure 1 is a flowchart of an image rendering method according to an exemplary embodiment. Figure 1 As shown, the following steps are included:
[0133] In step S101, an original image is acquired, and original pixel points in the original image are converted into a world coordinate system to obtain pixel space points corresponding to each original pixel point.
[0134] The original image may be an existing image stored in an image library or an image shot in real time; the original image may also be a video frame image in a video, and the video may be an existing video stored in a video library or a video shot in real time.
[0135] In the disclosed embodiment, the camera used to capture the original image is referred to as the main camera. When converting the original pixel points in the original image to the world coordinate system, the inverse view projection matrix of the main camera and the camera depth map can be combined, wherein the camera depth map can be determined using a trained scene depth map prediction model. Specifically, the original image can be input into the scene depth map prediction model, so that the corresponding camera depth map output by the scene depth map prediction model can be obtained. Among them, the training of the scene depth map prediction model can refer to the relevant methods in the prior art, which will not be repeated here. Exemplarily, the pixel space point corresponding to the original pixel point (x, y) can be expressed by the following formula (1):
[0136] wPos=M IVP *(x, y, depth, 1) (1)
[0137] Among them, wPos represents the pixel space point, M IVP Represents the inverse view projection matrix of the main camera, and depth represents the depth information corresponding to the original pixel point (x, y) in the camera depth map.
[0138] In step S103, a target pixel space point located within a preset projection range among the pixel space points and a light intensity coefficient corresponding to the target pixel space point are determined.
[0139] Wherein, the preset projection range is the projection range of the preset virtual light source.
[0140] In an exemplary embodiment, determining a target pixel space point located within a preset projection range among the pixel space points and a light intensity coefficient corresponding to the target pixel space point may include the following steps:
[0141] (1) Determine the cosine value of the angle between the light source direction vector of the preset virtual light source and the first vector.
[0142] The first vector refers to a vector from a preset virtual light source to a first pixel space point, and the first pixel space point is any pixel space point among the pixel space points.
[0143] (2) Determine a first target calculation value corresponding to the first pixel space point according to the angle cosine value corresponding to the first pixel space point and the preset boundary cosine value.
[0144] Among them, the preset boundary cosine value indicates the preset projection range. In a specific implementation, the preset boundary cosine value may include a first preset boundary cosine value and a second preset boundary cosine value. The first preset boundary cosine value indicates the boundary cosine value from the strongest illumination to the attenuation situation, and the second preset boundary cosine value indicates the boundary cosine value from the attenuation of illumination to the complete absence of illumination. Exemplarily, the first preset boundary cosine value may be 0.9, and the second preset boundary cosine value may be 0.8.
[0145] Then, when determining the first target calculation value corresponding to the first pixel space point according to the angle cosine value and the preset boundary cosine value, a smooth interpolation process can be performed according to the angle cosine value and the preset boundary cosine value, and the smooth interpolation process result is used as the first target calculation value corresponding to the first pixel space point, which can be specifically expressed as the following formula (2):
[0146]
[0147] Among them, c represents the cosine value of the angle corresponding to the first pixel space point; c′ represents the first target calculation value corresponding to the first pixel space point; clamp() is an interval limiting function used to constrain the return value between 0 and 1; t1 represents the second preset boundary cosine value; t2 represents the first preset boundary cosine value.
[0148] (3) When the first target calculated value meets a preset condition, determining the first pixel space point as a target pixel space point.
[0149] Among them, the preset condition is that it is greater than the value zero, that is, when the first target calculation value is greater than the value zero, the first pixel space point corresponding to the first target calculation value is determined to be the target pixel space point.
[0150] (4) Determine a light intensity coefficient corresponding to the target pixel space point according to the first target calculation value corresponding to the target pixel space point.
[0151] For example, the illumination intensity coefficient corresponding to the target pixel space point can be calculated by the following formula (3):
[0152] Cu=c′*c′*(3-2*c′) (3)
[0153] Wherein, Cu represents the illumination intensity coefficient; c′ represents the first target calculated value.
[0154] The disclosed embodiment accurately determines the target pixel space point within a preset projection range corresponding to the preset virtual light source and the illumination intensity coefficient corresponding to the target pixel space point based on the cosine value of the angle between the vector from the preset virtual light source to each pixel space point and the light source direction vector, thereby facilitating improving the accuracy of subsequent determination of the target projection light intensity corresponding to the target pixel space point.
[0155] In step S105, the target coordinate value corresponding to the target pixel space point in the preset projection pattern texture map is determined.
[0156] Among them, the preset projection pattern texture map is a texture map with preset projection light intensity and preset pattern corresponding to the preset virtual light source. The preset projection light intensity is stored in the transparency channel of the preset projection pattern texture map. The preset pattern can be set according to actual needs, for example, it can be a five-pointed star pattern, a square pattern, a heart pattern, etc.
[0157] In an exemplary embodiment, determining the target coordinate value corresponding to the target pixel space point in the preset projection pattern texture map may include: obtaining the maximum projection circle range corresponding to the target pixel space point based on the light intensity coefficient corresponding to the target pixel space point; determining the preset projection pattern texture map corresponding to the target pixel space point based on the maximum projection circle range; the maximum center circle range of the preset projection pattern texture map is the maximum projection circle range; mapping the target pixel point within the maximum projection circle range to the maximum center circle range of the preset projection pattern texture map, and obtaining the target coordinate value corresponding to the target pixel space point in the preset projection pattern texture map.
[0158] Among them, the illumination intensity coefficient corresponding to the pixel space point within the maximum projection circle range is greater than or equal to zero, while the illumination intensity coefficient of the pixel space point outside the maximum projection circle range is less than zero, that is, the boundary of the maximum projection circle range is defined by the pixel space point with an illumination intensity coefficient of zero. The preset projection pattern texture map is determined based on the maximum projection circle range, so that the maximum center circle range of the preset projection pattern texture map is the maximum projection circle range, and then the coordinate value corresponding to the target pixel space point within the maximum projection circle range in the preset projection pattern texture map can be accurately obtained through mapping processing, which is conducive to accurately obtaining the projection light intensity of the target pixel space point.
[0159] In an exemplary embodiment, the preset projection range may be a cone, and mapping the target pixel point within the maximum projection circle range to the maximum center circle range of the preset projection pattern texture map, and obtaining the target coordinate value corresponding to the target pixel space point in the preset projection pattern texture map may include the following steps:
[0160] (1) Determine a first calculation vector according to the product of the unit axis vector of the cone and the second vector.
[0161] The second vector refers to the vector from the preset virtual light source to the target pixel space point. In a specific implementation, the product of the unit axis vector of the cone and the second vector can be first calculated to obtain the length value of the first calculation vector, and then the length value is multiplied by the unit axis vector of the cone to obtain the first calculation vector.
[0162] (2) Determine the difference between the first calculation vector and the second vector to obtain a difference vector.
[0163] (3) Divide the difference vector by the product of the first calculation vector and the target angle tangent value to obtain a quotient.
[0164] The target angle refers to the angle between the side surface of the cone and the central axis of the cone.
[0165] (4) Determine a target sine value and a target cosine value based on the difference vector and the target unit direction vector.
[0166] The target unit direction vector refers to a direction vector perpendicular to the central axis of the cone.
[0167] (5) Determine a target coordinate value based on the quotient value, the target sine value, and the target cosine value.
[0168] For example, represents the unit axis vector of the cone, with represents the target unit direction vector, represents the second vector, represents the first calculation vector, represents the difference vector, len represents the quotient, α represents the angle between the side surface of the cone and the central axis of the cone, sinθ represents the target sine value, and cosθ represents the target cosine value, then the target coordinate value pos uv It can be expressed as the following formula (4):
[0169] POS uv =(0.5+len*sinθ, 0.5+len*cosθ) (4)
[0170] in, normalize() represents the normalization function;
[0171] The disclosed embodiment can accurately determine the coordinate value corresponding to the target pixel space point in the preset projection pattern texture map, thereby facilitating improving the accuracy of subsequent determination of the projection light intensity.
[0172] In step S107, the transparency channel value of the preset projection pattern texture map is read according to the target coordinate value to obtain the target projection light intensity corresponding to the target pixel space point.
[0173] In step S109, a projection color value corresponding to a target original pixel point corresponding to the target pixel space point under the preset virtual light source is determined according to the illumination intensity coefficient corresponding to the target pixel space point and the target projection light intensity.
[0174] Specifically, the product of the illumination intensity coefficient corresponding to the target pixel space point and the corresponding target projection light intensity can be calculated to obtain a first product value, and then the first product value is multiplied by the color value of the preset virtual light source to obtain the projection color value corresponding to the target pixel point corresponding to the target pixel space point under the preset virtual light source.
[0175] In step S111, the original image is projected and rendered according to the projection color value corresponding to the target original pixel under the preset virtual light source.
[0176] Specifically, the original color value of the target original pixel in the original image can be determined, and then the sum of the original color value and the projection color value corresponding to the target original pixel under the preset virtual light source is calculated to obtain the projection rendering color value, and then the projection rendering color value is used as the color value of the target original pixel in the original image, thereby obtaining an image of the rendered projection light. At this point, the preset virtual light source only needs to have a corresponding preset projection pattern texture map to support the projection of any shape of illumination pattern in the original image, such as Figure 2 The figure shows an example of projection rendering obtained by using the image rendering method of an embodiment of the present disclosure.
[0177] In practical applications, when rendering projection light, if there is an object blocking the light propagation path, the blocked object will be in the shadow range of the preset virtual light source, and the projection pattern should not be generated even within the projection range of the preset virtual light source. In order to ensure this blocking effect, it is necessary to generate a shadow mask for the preset virtual light source. Specifically, a virtual camera with a shooting direction consistent with the illumination direction of the preset virtual light source can be set at the preset virtual light source position, and a depth map can be rendered for the virtual camera. In mixed reality applications, the depth map corresponding to the virtual camera can be predicted by a pre-trained scene depth map prediction model, wherein the training of the scene depth map prediction model can refer to the relevant methods in the prior art, which will not be repeated here. Then, in the process of projection generation, the target pixel space point can be converted into the projection space of the virtual camera, and then the target pixel space point can be judged whether it is in the shadow of the preset virtual light source according to the depth map corresponding to the virtual camera, so as to determine whether it is necessary to render the projection light for the target original pixel point corresponding to the target pixel space point according to the judgment result.
[0178] Based on this, in an exemplary embodiment, Figure 3 As shown, before performing projection rendering on the original image according to the projection color value corresponding to the target original pixel point under the preset virtual light source in step S111, the method may further include:
[0179] In step S301, the target pixel space point is converted into a camera coordinate system corresponding to the target virtual camera to obtain a virtual camera projection point.
[0180] The target virtual camera refers to a virtual camera that is set at the preset virtual light source and whose shooting direction is consistent with the lighting direction of the preset virtual light source.
[0181] In step S303, the distance between the virtual camera projection point and the preset virtual light source is determined.
[0182] In step S305, depth information corresponding to the projection point of the virtual camera is determined according to the depth map corresponding to the target virtual camera.
[0183] Specifically, the coordinate point matching the projection point of the virtual camera may be searched in the depth map corresponding to the target virtual camera, and then the depth information corresponding to the coordinate point may be determined as the depth information corresponding to the projection point of the virtual camera.
[0184] In step S307, it is determined whether the distance is smaller than the depth information.
[0185] Specifically, if the judgment result is that the distance is less than the depth information, step S111 can be executed to render the original image according to the projection color value corresponding to the target original pixel point under the preset virtual light source; conversely, if the judgment result is that the distance is greater than or equal to the depth information, it indicates that the target pixel space point is in the shadow of the preset virtual light source, and the corresponding original pixel point is not rendered by projection light, that is, step S111 is not executed.
[0186] The embodiment of the present disclosure takes into account the occlusion within the preset projection range before performing projection rendering, so that the projection of the preset virtual light source conforms to the occlusion relationship of real-world objects. When there is an occlusion between the object and the preset virtual light source, no pattern will be projected, thereby improving the realism of the projection effect.
[0187] The disclosed embodiments support defining the projection pattern shape in the original image through a preset projection pattern texture map, so that the projection pattern in the original image is no longer just a circular projection. Customized shape patterns can also be projected through the preset projection pattern texture, thereby achieving diversity in the projection patterns projected into the real scene image and improving the spatial realism.
[0188] In practical applications, when the preset projection range corresponding to the preset virtual light source is regarded as a cone, the range within the cone is the range where the volume light effect may exist. In order to realize the light source effect when the virtual light propagates in the medium and enhance the realism of the projection in the mixed reality application, in an exemplary embodiment, Figure 4 A flowchart of another image rendering method is provided. After the original image is projected and rendered according to the projection color value corresponding to the target original pixel point under the preset virtual light source, the method may further include:
[0189] In step S401, a target line having an intersection with the preset projection range is determined based on a line from a coordinate point of the main camera to each of the pixel space points.
[0190] The main camera refers to a camera that captures the original image.
[0191] Specifically, for each pixel space point corresponding to an original pixel point in the original image, the coordinate point of the main camera is connected to the pixel space point, and a target line having an intersection with a preset projection range is found.
[0192] In step S403, a first distance between an intersection point corresponding to the target line and a coordinate point of the main camera, and a second distance between a pixel space point corresponding to the target line and a coordinate point of the main camera are determined.
[0193] Specifically, p tIndicates the intersection point corresponding to the target line, expressed as p camera represents the coordinate point of the main camera, and p represents the pixel space point corresponding to the target line. Then the first distance t0 = |p t -p camera |, the second distance t = |pp camera |.
[0194] In step S405, it is determined whether the first distance is smaller than the second distance.
[0195] Specifically, if the judgment result is that the first distance is less than the second distance, that is, t0<t, it indicates that the intersection points corresponding to the target are not blocked, and the original pixel points corresponding to the pixel space points on the target line need to add volumetric light effects. At this time, step S407 can be executed.
[0196] On the contrary, if the judgment result is that the first distance is greater than or equal to the second distance, that is, t0≥t, it indicates that the intersection corresponding to the target line is blocked by the original pixel object, and the original pixel object is closer to the main camera than the preset projection range. Then, there is no volumetric light effect for the original pixel points corresponding to the pixel space points corresponding to the target continuously. At this time, there is no need to add volumetric light effects to the original pixel points corresponding to the pixel space points corresponding to the target continuously.
[0197] In step S407, light stepping is performed along the target line from the intersection point to the pixel space point on the target line to obtain the volume light color value of the original pixel point corresponding to the pixel space point on the target line.
[0198] Specifically, starting from the intersection point corresponding to the target line, light stepping may be performed by sampling at intervals on the target line in sequence to calculate the volume light color value of the original pixel point corresponding to the pixel space point on the target line.
[0199] In practical applications, if the light stepping process is too regular, some obvious banded color blocks may be produced in the final volumetric light effect, such as Figure 5 As shown in , in order to improve the final rendered volumetric light effect and eliminate the banded color blocks, the regularity of the light stepping can be reduced. Specifically, an additional disturbance related to the original pixel point can be added at the intersection corresponding to the target line, thereby reducing the number of steps while generating a better volumetric light effect, thereby reducing the amount of calculation.
[0200] Based on this, in an exemplary embodiment, when performing light stepping along the target line from the intersection point to the pixel space point on the target line to obtain the volume light color value of the original pixel point corresponding to the pixel space point on the target line, step S407 can adopt Figure 6 The method comprises the following steps:
[0201] In step S601, a disturbance amplitude value is determined according to the original pixel point corresponding to the pixel space point on the target line and a preset three-dimensional floating point constant vector.
[0202] In a specific implementation, (u, v) represents the coordinates of the original pixel point corresponding to the pixel space point on the target line in the original image in pixels, and magic represents the preset three-dimensional floating-point constant vector. The disturbance amplitude value can be expressed as the following formula (5):
[0203] jitter=frac(magic.z*frac(uv*magic.xy)) (5)
[0204] Among them, jitter represents the disturbance amplitude value; magic.z represents the z-component in the preset three-dimensional floating-point constant vector, magic.xy represents the x-component and y-component in the preset three-dimensional floating-point constant vector; uv represents the normalized coordinates of (u, v), which can be expressed as (u′, v′), where u′=u / w, v′=v / w, and w represents the width of the original image; frac(X) represents returning the decimal part of X; uv*magic.xy=uv.u′*magic.x+uv.v′*magic.y.
[0205] In step S603, the first distance is updated according to the disturbance amplitude value.
[0206] Specifically, the above disturbance amplitude value may be added on the basis of the first distance to obtain an updated first distance.
[0207] In practical applications, in order to improve the flexibility of disturbance, the above disturbance amplitude value can also be adjusted by preset control parameters, and then the adjusted disturbance amplitude value is added to the first distance to obtain the updated first distance, that is, the update of the first distance can be expressed as the following formula (6):
[0208] t0′=t0+C*jitter (6)
[0209] Among them, t0 is the first distance, t0′ is the updated first distance, C represents the preset control parameter, and jitter represents the disturbance amplitude value.
[0210] In step S605, a stepping starting point is determined on the target line according to the updated first distance.
[0211] Specifically, the step starting point can be calculated by the following formula (7):
[0212] p0=p camera +t0*normalize(ppcamera ) (7)
[0213] Among them, p0 is the determined step starting point, P camera is the coordinate point of the main camera, normalize() represents the normalization function, and p is the pixel space point on the target line.
[0214] In step S607, light stepping is performed from the stepping starting point along the target line toward a pixel space point on the target line to obtain a volume light color value of an original pixel point corresponding to the pixel space point on the target line.
[0215] The disclosed embodiment adds an additional disturbance related to the original pixel point at the intersection corresponding to the target line, thereby improving the volumetric light effect while reducing the number of steps, thereby reducing the amount of calculation.
[0216] In an exemplary embodiment, when performing light stepping from the stepping starting point along the target line to the pixel space point on the target line, the volume light color value of the original pixel point corresponding to the pixel space point on the target line can be obtained by using the following method: Figure 7 The method shown comprises the following steps:
[0217] In step S701, the stepping distance is determined, and the current stepping point is determined on the target line according to the previous stepping point and the stepping distance.
[0218] The step distance can be the distance obtained by evenly dividing the line segment between the intersection point and the pixel space point on the corresponding target line. rs represents the step distance, p n-1 represents the previous step point, p n represents the current step point, then the current step point p n It can be expressed as the following formula (8):
[0219] p n =p n-1 +rs*normalize(pp camera ) (8)
[0220] Among them, p is the pixel space point on the target line, and normalize() is the normalization function.
[0221] Considering that during the light stepping process, if a uniform division method is used to perform step sampling between the intersection point and the pixel space point on the corresponding target line, when the line segment between the intersection point and the pixel space point on the corresponding target line is long, the same distance is spaced each time and the distance is too large, which will also produce obvious band-shaped color blocks in the final rendered volume light. In order to further improve the volume light rendering effect and avoid the generation of such band-shaped color blocks, the step distance can be determined by a sampling method of uniform division at the nearest location. This can save computing costs and ensure that the step distance is not too large each time, avoiding the generation of band-shaped color blocks in the rendered volume light. Based on this, in an exemplary embodiment, the step distance can be determined by:
[0222] determining a difference between the second distance and the updated first distance;
[0223] The step distance is determined according to the difference, a preset minimum step distance and a preset number of steps.
[0224] Specifically, the step distance can be expressed as the following formula (9):
[0225]
[0226] Among them, rs represents the step distance; minStep is the preset minimum step distance, which can be set according to actual experience; stepNum is the preset number of steps, which can be set according to actual experience; t0 is the updated first distance; t is the second distance between the pixel space point corresponding to the target line and the coordinate point of the main camera.
[0227] By adopting the above-mentioned nearest segmentation method to determine the step distance, it is avoided that the obvious band-shaped color blocks exist in the rendered volumetric light due to the excessive step distance each time.
[0228] In step S703, the color value of the current step point under the preset virtual light source is determined.
[0229] In an exemplary embodiment, when the preset projection range corresponding to the preset virtual light source is a cone, step S703 may include the following steps when determining the color value of the current step point under the preset virtual light source:
[0230] (1) If the current step point is not in the shadow of the preset virtual light source, determine a third distance from the projection point of the current step point on the central axis of the cone to the preset virtual light source.
[0231] Specifically, the current step point can be converted to the projection space of the target virtual camera (i.e., a virtual camera set at the preset virtual light source position and whose shooting direction is consistent with the illumination direction of the preset virtual light source) to obtain the camera projection space point corresponding to the current step point, and then determine the depth information corresponding to the camera projection space point in the depth map corresponding to the target virtual camera, as well as the distance between the camera projection space point and the preset virtual light source, and then compare the distance and the depth information to determine whether the current step point is in the shadow of the preset virtual light source. Specifically, if the distance is less than the depth information, it indicates that the current step point is not in the shadow of the preset virtual light source; conversely, if the distance is greater than or equal to the depth information, it indicates that the current step point is in the shadow of the preset virtual light source.
[0232] (2) Determine a second target calculation value based on the third distance, the maximum projection distance of the cone center axis and the target angle.
[0233] The target angle refers to the angle between the side surface of the cone and the central axis of the cone.
[0234] Specifically, the second target calculation value can be expressed as the following formula (10):
[0235]
[0236] Among them, r m represents the second target calculation value; α represents the angle between the side surface of the cone and the central axis of the cone; d m represents the maximum projection distance of the axis of the cone; d represents the third distance; lerp() represents the interpolation function.
[0237] (3) Determine a third target calculation value based on a fourth distance from the current step point to the center axis of the cone and the second target calculation value.
[0238] Specifically, r0 represents the fourth distance from the current step point to the center axis of the cone, and cone represents the third target calculation value. Then, the third target calculation value cone can be expressed as the following formula (11):
[0239]
[0240] Wherein, Border represents a preset control parameter related to the peripheral transition of volume light, and the specific value of the preset control parameter can be set according to actual experience; m Indicates the second target calculation value.
[0241] (4) Determine the volume light color coefficient according to the third target calculation value, the fifth distance from the preset virtual light source to the current step point, and the maximum projection distance of the central axis of the cone.
[0242] Specifically, atten represents the volume light color coefficient, and then atten can be calculated by the following formula (12):
[0243]
[0244] Among them, d l Indicates the fifth distance from the preset virtual light source to the current step point; d m Represents the maximum projection distance of the axis of the cone; cone represents the third target calculation value.
[0245] (5) Determine the color value of the current step point under the preset virtual light source according to the volume light color coefficient.
[0246] Specifically, the product of the volume light color coefficient corresponding to the current step point and the color value of the preset virtual light source can be calculated. The product is the color value of the current step point under the preset virtual light source, that is, the color value of the current step point under the preset virtual light source CV′=atten*CV 0 , where CV 0 Indicates the color value of the preset virtual light source.
[0247] The disclosed embodiment accurately calculates the color value of the current step point under the preset virtual light source when the current step point is not in the shadow of the preset virtual light source, thereby facilitating improving the accuracy of subsequent volumetric light rendering and ensuring the rendering effect of volumetric light.
[0248] In step S705, the accumulated color value is updated according to the color value of the current step point under the preset virtual light source and the transparent channel value of the accumulated color value.
[0249] The accumulated color value refers to the sum of the color values of the target step points before the current step point under the preset virtual light source, and the target step point refers to the step point on the target line where the current step point is located.
[0250] Specifically, the update of the accumulated color value can be expressed as the following formula (13):
[0251] S′=S+CV′*(1-Sa) (13)
[0252] Among them, S represents the cumulative color value; S′ represents the updated cumulative color value; CV′ represents the color value of the current step point under the preset virtual light source; Sa represents the transparent channel value of the cumulative color value.
[0253] In step S707, the light stepping is stopped when the preset stepping end condition is met, and the accumulated color value when the light stepping is stopped is used as the volume light color value of the original pixel point corresponding to the pixel space point on the target line.
[0254] Among them, the preset stepping end condition can be any one of the following: the number of light steps on the target line exceeds the stepping number threshold; the current stepping point has exceeded the pixel space point on the target line; the transparent channel value Sa of the cumulative color value exceeds the preset transparent channel threshold, for example, the preset transparent channel threshold can be 0.99.
[0255] The disclosed embodiment accurately determines the volumetric light color value corresponding to the original pixel point with the volumetric light effect through light stepping, thereby ensuring the effect of volumetric light rendering.
[0256] In step S409, volumetric light rendering is performed on the original image according to the volumetric light color values of the original pixel points corresponding to the pixel space points on the target line.
[0257] Specifically, the color value of the original pixel point corresponding to the pixel space point on the target line in the original image after projection rendering can be determined first, and then the sum of the color value after projection rendering and the volume light color value of the original pixel point is calculated, and the sum is used as the color value of the original pixel point to obtain the original image after volume light rendering, such as Figure 8 This is an example of rendering with volumetric light obtained by using the image rendering method of an embodiment of the present disclosure.
[0258] The disclosed embodiment adds a volumetric light effect to a preset virtual light source by means of ray stepping, so that the preset virtual light source is no longer simply adding a projection pattern to the real scene image, and the light and shadow effects produced when the light propagates in the real world are also simulated to a certain extent, thereby increasing the realism of the image lighting rendering.
[0259] Fig. 9 is a block diagram of an image rendering device according to an exemplary embodiment. Fig. 9 The image rendering device 900 includes an original image acquisition unit 910, an illumination intensity coefficient determination unit 920, a projection pattern texture coordinate determination unit 930, a projection light intensity determination unit 940, a projection color value determination unit 950 and a projection rendering unit 960, wherein:
[0260] The original image acquisition unit 910 is configured to acquire the original image, convert the original pixel points in the original image into the world coordinate system, and obtain the pixel space point corresponding to each original pixel point;
[0261] The illumination intensity coefficient determination unit 920 is configured to determine a target pixel space point located within a preset projection range among each pixel space point, and an illumination intensity coefficient corresponding to the target pixel space point; the preset projection range is a projection range of a preset virtual light source;
[0262] The projection pattern texture coordinate determination unit 930 is configured to determine the target coordinate value corresponding to the target pixel space point in a preset projection pattern texture map; the projection light intensity is stored in the transparency channel of the preset projection pattern texture map;
[0263] The projection light intensity determination unit 940 is configured to read the transparency channel value of the preset projection pattern texture map according to the target coordinate value to obtain the target projection light intensity corresponding to the target pixel space point;
[0264] The projection color value determining unit 950 is configured to determine the projection color value corresponding to the target original pixel point corresponding to the target pixel space point under the preset virtual light source according to the illumination intensity coefficient corresponding to the target pixel space point and the target projection light intensity;
[0265] The projection rendering unit 960 is configured to perform projection rendering on the original image according to the projection color value corresponding to the target original pixel point under the preset virtual light source.
[0266] In an exemplary embodiment, the illumination intensity coefficient determination unit 920 includes:
[0267] A first determining unit is configured to determine a cosine value of an angle between a light source direction vector of the preset virtual light source and a first vector; the first vector refers to a vector from the preset virtual light source to a first pixel space point, and the first pixel space point is any pixel space point among the pixel space points;
[0268] A second determining unit is configured to determine a first target calculated value corresponding to the first pixel space point according to the angle cosine value and a preset boundary cosine value; the preset boundary cosine value indicates the preset projection range;
[0269] a target pixel space point determination unit, configured to determine the first pixel space point as a target pixel space point when the first target calculated value satisfies a preset condition;
[0270] The third determining unit is configured to determine the illumination intensity coefficient corresponding to the target pixel space point according to the first target calculated value corresponding to the target pixel space point.
[0271] In an exemplary embodiment, the projection pattern texture coordinate determination unit 930 includes:
[0272] A maximum projection circle range determination unit is configured to obtain a maximum projection circle range corresponding to the target pixel space point according to the illumination intensity coefficient corresponding to the target pixel space point;
[0273] A preset projection pattern texture map determining unit is configured to determine the preset projection pattern texture map corresponding to the target pixel space point according to the maximum projection circle range; the maximum center circle range of the preset projection pattern texture map is the maximum projection circle range;
[0274] The mapping unit is configured to map the target pixel point within the maximum projection circle to the maximum center circle of the preset projection pattern texture map to obtain the target coordinate value corresponding to the target pixel space point in the preset projection pattern texture map.
[0275] In an exemplary embodiment, when the preset projection range is a cone, the mapping unit includes:
[0276] a fourth determining unit configured to determine a first calculation vector according to the product of the unit axis vector of the cone and a second vector; the second vector refers to a vector from the preset virtual light source to the target pixel space point;
[0277] a difference vector determining unit, configured to determine a difference between the first calculation vector and the second vector to obtain a difference vector;
[0278] a quotient determination unit configured to perform the division of the difference vector by the product of the first calculation vector and the tangent value of the target angle to obtain a quotient; the target angle refers to the angle between the side surface of the cone and the central axis of the cone;
[0279] A fifth determining unit is configured to determine a target sine value and a target cosine value according to the difference vector and a target unit direction vector; the target unit direction vector refers to a direction vector perpendicular to the central axis of the cone;
[0280] The sixth determining unit is configured to determine a target coordinate value according to the quotient value, the target sine value and the target cosine value.
[0281] In an exemplary embodiment, the apparatus further comprises:
[0282] A virtual camera projection point determination unit is configured to convert the target pixel space point into a camera coordinate system corresponding to a target virtual camera to obtain a virtual camera projection point; the target virtual camera is a virtual camera that is set at the preset virtual light source and has a shooting direction that is consistent with the illumination direction of the preset virtual light source;
[0283] A seventh determining unit is configured to determine the distance between the virtual camera projection point and the preset virtual light source;
[0284] A depth information determining unit, configured to determine the depth information corresponding to the projection point of the virtual camera according to the depth map corresponding to the target virtual camera;
[0285] Correspondingly, the projection rendering unit 960 is configured to execute the step of rendering the original image according to the projection color value corresponding to the target original pixel point under the preset virtual light source when the distance is less than the depth information.
[0286] In an exemplary embodiment, the apparatus further comprises:
[0287] a target line determination unit, configured to determine a target line having an intersection with the preset projection range according to a line from a coordinate point of a main camera to each of the pixel space points; the main camera refers to a camera that captures the original image;
[0288] a distance determination unit, configured to determine a first distance between an intersection point corresponding to the target line and a coordinate point of the main camera, and a second distance between a pixel space point corresponding to the target line and a coordinate point of the main camera;
[0289] a light stepping unit configured to perform light stepping along the target line from the intersection point to a pixel space point on the target line when the first distance is less than the second distance, so as to obtain a volume light color value of an original pixel point corresponding to the pixel space point on the target line;
[0290] The volume light rendering unit is configured to perform volume light rendering on the original image according to the volume light color value of the original pixel point corresponding to the pixel space point on the target line.
[0291] In an exemplary embodiment, the light stepping unit comprises:
[0292] A disturbance amplitude determination unit is configured to determine a disturbance amplitude value according to an original pixel point corresponding to the pixel space point on the target line and a preset three-dimensional floating point constant vector;
[0293] A first updating unit, configured to update the first distance according to the disturbance amplitude value;
[0294] a stepping starting point determining unit, configured to determine a stepping starting point on the target line according to the updated first distance;
[0295] The light stepping subunit is configured to perform light stepping from the stepping starting point along the target line to the pixel space point on the target line to obtain the volume light color value of the original pixel point corresponding to the pixel space point on the target line.
[0296] In an exemplary embodiment, the light stepping subunit comprises:
[0297] a current step point determination unit, configured to determine a step distance and determine a current step point on the target line according to a previous step point and the step distance;
[0298] An eighth determining unit is configured to determine a color value of the current step point under the preset virtual light source;
[0299] A second updating unit is configured to update the accumulated color value according to the color value of the current step point under the preset virtual light source and the transparent channel value of the accumulated color value; the accumulated color value refers to the sum of the color values of each target step point before the current step point under the preset virtual light source, and the target step point refers to the step point on the target line;
[0300] The volume light color value determination unit is configured to stop light stepping when a preset stepping end condition is met, and use the accumulated color value when the light stepping stops as the volume light color value of the original pixel point corresponding to the pixel space point on the target line.
[0301] In an exemplary embodiment, the current step point determination unit includes:
[0302] a distance difference determination unit, configured to determine a difference between the second distance and the updated first distance;
[0303] The step distance determining unit is configured to determine the step distance according to the difference, a preset minimum step distance and a preset number of steps.
[0304] In an exemplary embodiment, when the preset projection range is a cone, the eighth determining unit includes:
[0305] a ninth determining unit, configured to determine, if the current step point is not in the shadow of the preset virtual light source, a third distance from a projection point of the current step point on the central axis of the cone to the preset virtual light source;
[0306] a tenth determining unit, configured to determine a second target calculated value according to the third distance, the maximum projection distance of the central axis of the cone, and a target angle; the target angle refers to an angle between the side surface of the cone and the central axis of the cone;
[0307] an eleventh determining unit, configured to determine a third target calculated value according to a fourth distance from the current step point to the central axis of the cone and the second target calculated value;
[0308] a volume light color coefficient determination unit, configured to determine the volume light color coefficient according to the third target calculation value, a fifth distance from the preset virtual light source to the current step point, and a maximum projection distance of the central axis of the cone;
[0309] A twelfth determining unit is configured to determine the color value of the current step point under the preset virtual light source according to the volume light color coefficient.
[0310] 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.
[0311] In an exemplary embodiment, an electronic device is also provided, including a processor; a memory for storing processor executable instructions; wherein, when the processor is configured to execute the instructions stored in the memory, it implements any one of the image rendering methods provided in the embodiments of the present disclosure.
[0312] The electronic device may be a terminal, a server or a similar computing device. For example, the computer running on the terminal Fig.10 : is a hardware structure block diagram of a terminal running an image rendering method provided by an embodiment of the present invention, specifically:
[0313] The terminal may include components such as an RF (Radio Frequency) circuit 1010, a memory 1020 including one or more computer-readable storage media, an input unit 1030, a display unit 1040, a sensor 1050, an audio circuit 1060, a WiFi (wireless fidelity) module 1070, a processor 1080 including one or more processing cores, and a power supply 1090. Those skilled in the art will appreciate that Fig.10 The terminal structure shown in the figure does not constitute a limitation on the terminal, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0314] The RF circuit 1010 can be used for receiving and sending signals during information transmission or calls. In particular, after receiving the downlink information of the base station, it is handed over to one or more processors 1080 for processing; in addition, the data related to the uplink is sent to the base station. Generally, the RF circuit 1010 includes but is not limited to an antenna, at least one amplifier, a tuner, one or more oscillators, a user identity module (SIM) card, a transceiver, a coupler, an LNA (Low Noise Amplifier), a duplexer, etc. In addition, the RF circuit 1010 can also communicate with the network and other terminals through wireless communication. The wireless communication can use any communication standard or protocol, including but not limited to GSM (Global System of Mobile communication), GPRS (General Packet Radio Service), CDMA (Code Division Multiple Access), WCDMA (Wideband Code Division Multiple Access), LTE (Long Term Evolution), email, SMS (Short Messaging Service), etc.
[0315] The memory 1020 can be used to store software programs and modules, and the processor 1080 executes various functional applications and data processing by running the software programs and modules stored in the memory 1020. The memory 1020 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, application programs required for functions, etc.; the data storage area may store data created according to the use of the terminal, etc. In addition, the memory 1020 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. Accordingly, the memory 1020 may also include a memory controller to provide the processor 1080 and the input unit 1030 with access to the memory 1020.
[0316] The input unit 1030 can be used to receive input digital or character information, and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control. Specifically, the input unit 1030 may include a touch-sensitive surface 1031 and other input devices 1032. The touch-sensitive surface 1031, also known as a touch display screen or a touch pad, can collect user touch operations on or near it (such as operations performed by the user using any suitable object or accessory such as a finger, stylus, etc. on or near the touch-sensitive surface 1031), and drive the corresponding connection device according to a pre-set program. Optionally, the touch-sensitive surface 1031 may include two parts: a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch direction, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into touch point coordinates, and then sends it to the processor 1080, and can receive and execute commands sent by the processor 1080. In addition, the touch-sensitive surface 1031 may be implemented in various types such as resistive, capacitive, infrared, and surface acoustic wave. In addition to the touch-sensitive surface 1031, the input unit 1030 may further include other input devices 1032. Specifically, the other input devices 1032 may include, but are not limited to, one or more of a physical keyboard, a function key (such as a volume control key, a switch key, etc.), a trackball, a mouse, a joystick, and the like.
[0317] The display unit 1040 can be used to display information input by the user or information provided to the user and various graphical user interfaces of the terminal, which can be composed of graphics, text, icons, videos and any combination thereof. The display unit 1040 may include a display panel 1041, and optionally, the display panel 1041 may be configured in the form of LCD (Liquid Crystal Display), OLED (Organic Light-Emitting Diode), etc. Further, the touch-sensitive surface 1031 may cover the display panel 1041, and when the touch-sensitive surface 1031 detects a touch operation on or near it, it is transmitted to the processor 1080 to determine the type of the touch event, and then the processor 1080 provides corresponding visual output on the display panel 1041 according to the type of the touch event. Among them, the touch-sensitive surface 1031 and the display panel 1041 can be two independent components to realize the input and output functions, but in some embodiments, the touch-sensitive surface 1031 and the display panel 1041 can also be integrated to realize the input and output functions.
[0318] The terminal may also include at least one sensor 1050, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor may include an ambient light sensor and a proximity sensor, wherein the ambient light sensor may adjust the brightness of the display panel 1041 according to the brightness of the ambient light, and the proximity sensor may turn off the display panel 1041 and / or the backlight when the terminal is moved to the ear. As a type of motion sensor, the gravity acceleration sensor can detect the magnitude of acceleration in each direction (generally three axes), and can detect the magnitude and direction of gravity when stationary. It can be used for applications that identify the terminal posture (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, tapping), etc.; as for other sensors such as gyroscopes, barometers, hygrometers, thermometers, infrared sensors, etc. that can be configured in the terminal, they will not be repeated here.
[0319] The audio circuit 1060, the speaker 1061, and the microphone 1062 can provide an audio interface between the user and the terminal. The audio circuit 1060 can transmit the received audio data to the speaker 1061 after converting the received audio data into an electrical signal, which is converted into a sound signal for output by the speaker 1061; on the other hand, the microphone 1062 converts the collected sound signal into an electrical signal, which is received by the audio circuit 1060 and converted into audio data, and then the audio data is output to the processor 1080 for processing, and then sent to another terminal through the RF circuit 1010, or the audio data is output to the memory 1020 for further processing. The audio circuit 1060 may also include an earplug jack to provide communication between an external headset and the terminal.
[0320] WiFi is a short-range wireless transmission technology. The terminal can help users send and receive emails, browse web pages, and access streaming media through the WiFi module 1070, which provides users with wireless broadband Internet access. Fig.10 A WiFi module 1070 is shown, but it is understandable that it is not an essential component of the terminal and can be omitted as needed without changing the essence of the invention.
[0321] The processor 1080 is the control center of the terminal, and uses various interfaces and lines to connect various parts of the entire terminal. By running or executing software programs and / or modules stored in the memory 1020, and calling data stored in the memory 1020, the processor 1080 performs various functions of the terminal and processes data, thereby monitoring the terminal as a whole. Optionally, the processor 1080 may include one or more processing cores; preferably, the processor 1080 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 1080.
[0322] The terminal also includes a power supply 1090 (such as a battery) for supplying power to each component. Preferably, the power supply can be logically connected to the processor 1080 through a power management system, so that the power management system can manage charging, discharging, and power consumption management. The power supply 1090 can also include any components such as one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, and power status indicators.
[0323] Although not shown, the terminal may also include a camera, a Bluetooth module, etc., which will not be described in detail herein. Specifically in this embodiment, the terminal also includes a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by one or more processors. The one or more programs include instructions for executing the image rendering method provided in the above method embodiment.
[0324] In an exemplary embodiment, a computer-readable storage medium including instructions is also provided, such as a memory 1020 including instructions, and the instructions can be executed by a processor 1080 of the device 1000 to complete the above method. Alternatively, the computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0325] In an exemplary embodiment, a computer program product is also provided, including a computer program / instruction, and when the computer program / instruction is executed by a processor, any one of the image rendering methods provided in the embodiments of the present disclosure is implemented.
[0326] 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.
[0327] 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. An image rendering method, characterized in that: include: Acquire an original image, convert original pixel points in the original image into a world coordinate system, and obtain pixel space points corresponding to each original pixel point; Determine a target pixel space point in each pixel space point that is within a preset projection range, and a light intensity coefficient corresponding to the target pixel space point; the preset projection range is a projection range of a preset virtual light source; Determine the target coordinate value corresponding to the target pixel space point in the preset projection pattern texture map; The transparency channel of the preset projection pattern texture map stores projection light intensity; Reading the transparency channel value of the preset projection pattern texture map according to the target coordinate value to obtain the target projection light intensity corresponding to the target pixel space point; Determine, according to the illumination intensity coefficient corresponding to the target pixel space point and the target projection light intensity, a projection color value corresponding to the target original pixel point corresponding to the target pixel space point under the preset virtual light source; The original image is projected and rendered according to the projection color value corresponding to the target original pixel point under the preset virtual light source.
2. The image rendering method according to claim 1, characterized in that: The determining of a target pixel space point located within a preset projection range among the pixel space points, and a light intensity coefficient corresponding to the target pixel space point, includes: Determine the cosine value of the angle between the light source direction vector of the preset virtual light source and a first vector; the first vector refers to a vector from the preset virtual light source to a first pixel space point, and the first pixel space point is any pixel space point among the pixel space points; Determine a first target calculation value corresponding to the first pixel space point according to the angle cosine value and a preset boundary cosine value; the preset boundary cosine value indicates the preset projection range; When the first target calculated value meets a preset condition, determining the first pixel space point as a target pixel space point; Determine the illumination intensity coefficient corresponding to the target pixel space point according to the first target calculated value corresponding to the target pixel space point.
3. The image rendering method according to claim 1, characterized in that: The determining of the target coordinate value corresponding to the target pixel space point in the preset projection pattern texture map includes: According to the illumination intensity coefficient corresponding to the target pixel space point, a maximum projection circle range corresponding to the target pixel space point is obtained; According to the maximum projection circle range, determining a preset projection pattern texture map corresponding to the target pixel space point; the maximum center circle range of the preset projection pattern texture map is the maximum projection circle range; The target pixel point within the maximum projection circle is mapped to the maximum center circle of the preset projection pattern texture map to obtain the target coordinate value corresponding to the target pixel space point in the preset projection pattern texture map.
4. The image rendering method according to claim 3, characterized in that: When the preset projection range is a cone, mapping the target pixel point within the maximum projection circle range to the maximum center circle range of the preset projection pattern texture map to obtain the target coordinate value corresponding to the target pixel space point in the preset projection pattern texture map includes: Determine a first calculation vector according to the product of the unit axis vector of the cone and a second vector; the second vector refers to a vector from the preset virtual light source to the target pixel space point; Determine a difference between the first calculation vector and the second vector to obtain a difference vector; Dividing the difference vector by the product of the first calculation vector and the tangent value of the target angle to obtain a quotient; the target angle refers to the angle between the side surface of the cone and the central axis of the cone; Determine a target sine value and a target cosine value according to the difference vector and a target unit direction vector; the target unit direction vector refers to a direction vector perpendicular to the central axis of the cone; A target coordinate value is determined according to the quotient value, the target sine value, and the target cosine value.
5. The image rendering method according to claim 1, characterized in that: Before performing projection rendering on the original image according to the projection color value corresponding to the target original pixel point under the preset virtual light source, the method further includes: The target pixel space point is converted into a camera coordinate system corresponding to a target virtual camera to obtain a virtual camera projection point; the target virtual camera is a virtual camera that is set at the preset virtual light source and has a shooting direction consistent with the illumination direction of the preset virtual light source; Determining the distance between the virtual camera projection point and the preset virtual light source; Determine the depth information corresponding to the projection point of the virtual camera according to the depth map corresponding to the target virtual camera; When the distance is less than the depth information, the step of rendering the original image according to the projection color value corresponding to the target original pixel point under the preset virtual light source is performed.
6. The image rendering method according to any one of claims 1 to 5, characterized in that: After performing projection rendering on the original image according to the projection color value corresponding to the target original pixel point under the preset virtual light source, the method further includes: Determine a target line having an intersection with the preset projection range according to a line between a coordinate point of a main camera and each of the pixel space points; the main camera is a camera that captures the original image; Determine a first distance between an intersection point corresponding to the target line and a coordinate point of the main camera, and a second distance between a pixel space point corresponding to the target line and a coordinate point of the main camera; When the first distance is less than the second distance, light stepping is performed along the target line from the intersection point to the pixel space point on the target line to obtain the volume light color value of the original pixel point corresponding to the pixel space point on the target line; The original image is rendered with volumetric light according to the volumetric light color value of the original pixel point corresponding to the pixel space point on the target line.
7. The image rendering method according to claim 6, characterized in that: The stepping of light along the target line from the intersection point to the pixel space point on the target line to obtain the volume light color value of the original pixel point corresponding to the pixel space point on the target line includes: Determine a disturbance amplitude value according to an original pixel point corresponding to the pixel space point on the target line and a preset three-dimensional floating-point constant vector; Update the first distance according to the disturbance amplitude value; Determine a stepping starting point on the target line according to the updated first distance; Light stepping is performed from the stepping starting point along the target line toward a pixel space point on the target line to obtain a volume light color value of an original pixel point corresponding to the pixel space point on the target line.
8. The image rendering method according to claim 7, characterized in that: The stepping of light from the stepping starting point along the target line to a pixel space point on the target line to obtain a volume light color value of an original pixel point corresponding to the pixel space point on the target line includes: Determine a step distance, and determine a current step point on the target line according to a previous step point and the step distance; Determine the color value of the current step point under the preset virtual light source; Update the accumulated color value according to the color value of the current step point under the preset virtual light source and the transparent channel value of the accumulated color value; the accumulated color value refers to the sum of the color values of each target step point before the current step point under the preset virtual light source, and the target step point refers to the step point on the target line; When a preset stepping end condition is met, the light stepping is stopped, and the accumulated color value when the light stepping is stopped is used as the volume light color value of the original pixel point corresponding to the pixel space point on the target line.
9. The image rendering method according to claim 8, characterized in that: Determining the step distance includes: determining a difference between the second distance and the updated first distance; The step distance is determined according to the difference, a preset minimum step distance and a preset number of steps.
10. The image rendering method according to claim 8, characterized in that: When the preset projection range is a cone, determining the color value of the current step point under the preset virtual light source includes: If the current step point is not in the shadow of the preset virtual light source, determining a third distance from the projection point of the current step point on the central axis of the cone to the preset virtual light source; Determine a second target calculation value according to the third distance, the maximum projection distance of the cone center axis and a target angle; the target angle refers to the angle between the side surface of the cone and the cone center axis; Determine a third target calculated value according to a fourth distance from the current step point to the central axis of the cone and the second target calculated value; Determine a volume light color coefficient according to the third target calculated value, a fifth distance from the preset virtual light source to the current step point, and a maximum projection distance of the central axis of the cone; According to the volume light color coefficient, the color value of the current step point under the preset virtual light source is determined.
11. An image rendering device, characterized in that: include: The original image acquisition unit is configured to acquire the original image, convert the original pixel points in the original image into the world coordinate system, and obtain the pixel space point corresponding to each original pixel point; The illumination intensity coefficient determination unit is configured to determine a target pixel space point located within a preset projection range among each pixel space point, and an illumination intensity coefficient corresponding to the target pixel space point; the preset projection range is a projection range of a preset virtual light source; A projection pattern texture coordinate determination unit is configured to determine a target coordinate value corresponding to the target pixel space point in a preset projection pattern texture map; The transparency channel of the preset projection pattern texture map stores projection light intensity; A projection light intensity determination unit is configured to read a transparency channel value of the preset projection pattern texture map according to the target coordinate value to obtain a target projection light intensity corresponding to the target pixel space point; a projection color value determining unit, configured to determine a projection color value corresponding to a target original pixel point corresponding to the target pixel space point under the preset virtual light source according to the illumination intensity coefficient corresponding to the target pixel space point and the target projection light intensity; The projection rendering unit is configured to perform projection rendering on the original image according to the projection color value corresponding to the target original pixel point under the preset virtual light source.
12. The image rendering device according to claim 11, characterized in that: The illumination intensity coefficient determination unit comprises: A first determining unit is configured to determine a cosine value of an angle between a light source direction vector of the preset virtual light source and a first vector; the first vector refers to a vector from the preset virtual light source to a first pixel space point, and the first pixel space point is any pixel space point among the pixel space points; A second determining unit is configured to determine a first target calculated value corresponding to the first pixel space point according to the angle cosine value and a preset boundary cosine value; the preset boundary cosine value indicates the preset projection range; a target pixel space point determination unit, configured to determine the first pixel space point as a target pixel space point when the first target calculated value satisfies a preset condition; The third determining unit is configured to determine the illumination intensity coefficient corresponding to the target pixel space point according to the first target calculated value corresponding to the target pixel space point.
13. The image rendering device according to claim 11, characterized in that: The projection pattern texture coordinate determination unit comprises: A maximum projection circle range determination unit is configured to obtain a maximum projection circle range corresponding to the target pixel space point according to the illumination intensity coefficient corresponding to the target pixel space point; A preset projection pattern texture map determining unit is configured to determine the preset projection pattern texture map corresponding to the target pixel space point according to the maximum projection circle range; the maximum center circle range of the preset projection pattern texture map is the maximum projection circle range; The mapping unit is configured to map the target pixel point within the maximum projection circle to the maximum center circle of the preset projection pattern texture map to obtain the target coordinate value corresponding to the target pixel space point in the preset projection pattern texture map.
14. The image rendering device according to claim 13, characterized in that: When the preset projection range is a cone, the mapping unit includes: a fourth determining unit configured to determine a first calculation vector according to the product of the unit axis vector of the cone and a second vector; the second vector refers to a vector from the preset virtual light source to the target pixel space point; a difference vector determining unit, configured to determine a difference between the first calculation vector and the second vector to obtain a difference vector; a quotient determination unit configured to perform the division of the difference vector by the product of the first calculation vector and the tangent value of the target angle to obtain a quotient; the target angle refers to the angle between the side surface of the cone and the central axis of the cone; A fifth determining unit is configured to determine a target sine value and a target cosine value according to the difference vector and a target unit direction vector; the target unit direction vector refers to a direction vector perpendicular to the central axis of the cone; The sixth determining unit is configured to determine a target coordinate value according to the quotient value, the target sine value and the target cosine value.
15. The image rendering device according to claim 11, characterized in that: The device also includes: A virtual camera projection point determination unit is configured to convert the target pixel space point into a camera coordinate system corresponding to a target virtual camera to obtain a virtual camera projection point; the target virtual camera is a virtual camera that is set at the preset virtual light source and has a shooting direction that is consistent with the illumination direction of the preset virtual light source; A seventh determining unit is configured to determine the distance between the virtual camera projection point and the preset virtual light source; A depth information determining unit, configured to determine the depth information corresponding to the projection point of the virtual camera according to the depth map corresponding to the target virtual camera; Correspondingly, the projection rendering unit is configured to execute the step of rendering the original image according to the projection color value corresponding to the target original pixel point under the preset virtual light source when the distance is less than the depth information.
16. The image rendering device according to any one of claims 11 to 15, characterized in that: The device also includes: a target line determination unit, configured to determine a target line having an intersection with the preset projection range according to a line from a coordinate point of a main camera to each of the pixel space points; the main camera refers to a camera that captures the original image; a distance determination unit, configured to determine a first distance between an intersection point corresponding to the target line and a coordinate point of the main camera, and a second distance between a pixel space point corresponding to the target line and a coordinate point of the main camera; a light stepping unit configured to perform light stepping along the target line from the intersection point to a pixel space point on the target line when the first distance is less than the second distance, so as to obtain a volume light color value of an original pixel point corresponding to the pixel space point on the target line; The volume light rendering unit is configured to perform volume light rendering on the original image according to the volume light color value of the original pixel point corresponding to the pixel space point on the target line.
17. The image rendering device according to claim 16, characterized in that: The light stepping unit comprises: A disturbance amplitude determination unit is configured to determine a disturbance amplitude value according to an original pixel point corresponding to the pixel space point on the target line and a preset three-dimensional floating point constant vector; A first updating unit, configured to update the first distance according to the disturbance amplitude value; a stepping starting point determining unit, configured to determine a stepping starting point on the target line according to the updated first distance; The light stepping subunit is configured to perform light stepping from the stepping starting point along the target line to the pixel space point on the target line to obtain the volume light color value of the original pixel point corresponding to the pixel space point on the target line.
18. The image rendering device according to claim 17, characterized in that: The light stepping subunit comprises: a current step point determination unit, configured to determine a step distance and determine a current step point on the target line according to a previous step point and the step distance; An eighth determining unit is configured to determine a color value of the current step point under the preset virtual light source; A second updating unit is configured to update the accumulated color value according to the color value of the current step point under the preset virtual light source and the transparent channel value of the accumulated color value; the accumulated color value refers to the sum of the color values of each target step point before the current step point under the preset virtual light source, and the target step point refers to the step point on the target line; The volume light color value determination unit is configured to stop light stepping when a preset stepping end condition is met, and use the accumulated color value when the light stepping stops as the volume light color value of the original pixel point corresponding to the pixel space point on the target line.
19. The image rendering device according to claim 18, characterized in that: The current step point determination unit comprises: a distance difference determination unit, configured to determine a difference between the second distance and the updated first distance; The step distance determining unit is configured to determine the step distance according to the difference, a preset minimum step distance and a preset number of steps.
20. The image rendering device according to claim 18, characterized in that: When the preset projection range is a cone, the eighth determining unit includes: a ninth determining unit, configured to determine, if the current step point is not in the shadow of the preset virtual light source, a third distance from a projection point of the current step point on the central axis of the cone to the preset virtual light source; a tenth determining unit, configured to determine a second target calculated value according to the third distance, the maximum projection distance of the central axis of the cone, and a target angle; the target angle refers to an angle between the side surface of the cone and the central axis of the cone; an eleventh determining unit, configured to determine a third target calculated value according to a fourth distance from the current step point to the central axis of the cone and the second target calculated value; a volume light color coefficient determination unit, configured to determine the volume light color coefficient according to the third target calculation value, a fifth distance from the preset virtual light source to the current step point, and a maximum projection distance of the central axis of the cone; A twelfth determining unit is configured to determine the color value of the current step point under the preset virtual light source according to the volume light color coefficient.
21. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the image rendering method according to any one of claims 1 to 10.
22. A computer-readable storage medium, when instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the image rendering method according to any one of claims 1 to 10.
23. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the image rendering method according to any one of claims 1 to 10 is implemented.
