Methods, apparatus, equipment and storage media for model shadow processing
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-30
- Publication Date
- 2026-08-14
AI Technical Summary
[0004]可以看出,该过程通过两个渲染摄像机进行了两次渲染处理,渲染过程需要消耗较大的图形处理器(graphics processing unit,GPU)算力,所以相关技术中的模型阴影生成方案对于GPU的算力要求较高,处理速率较低
[0010]本申请所提供的模型阴影的处理方法、装置、设备、系统及存储介质,包括:获取待生成阴影的目标模型;采用第一渲染摄像机对所述目标模型进行一次渲染,得到第一渲染结果;对所述第一渲染结果进行处理,得到相同的两个纹理图像;所述纹理图像为所述目标模型的显示图像;对第一纹理图像进行镜像处理后得到所述目标模型的阴影图像;所述第一纹理图像为所述两个纹理图像中的任一个纹理图像;在目标显示区域对应显示所述目标模型的所述显示图像和所述阴影图像。
Smart Images

Figure CN117173317B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of vehicle technology, and to, but is not limited to, methods, apparatus, devices, and storage media for processing model shadows. Background Technology
[0002] With the continuous development of modeling technology, the application of model shadows is becoming increasingly widespread. In the field of vehicle technology, shadows are gradually being added to the 3D models of vehicle equipment.
[0003] For generating shadows in a 3D vehicle model, the relevant technical solutions include: first, drawing a 3D model of the vehicle, then rendering the 3D model twice using two rendering cameras, and projecting it onto two rendering textures to obtain the display image and shadow image of the 3D model.
[0004] As can be seen, the process involves two rendering processes using two rendering cameras. The rendering process requires a large amount of graphics processing unit (GPU) computing power. Therefore, the model shadow generation scheme in related technologies has high requirements for GPU computing power and low processing speed. Summary of the Invention
[0005] This application provides a method, apparatus, device, and storage medium for processing model shadows. In the process of generating shadows for a target model, this solution only requires rendering the target model once using a rendering camera, which reduces the computing power requirement of the GPU and improves the processing speed.
[0006] The technical solution of this application is implemented as follows: Firstly, this application provides a method for processing model shadows, the method comprising: Obtain the target model from which the shadow to be generated; The target model is rendered once using a first rendering camera to obtain a first rendering result; The first rendering result is processed to obtain two identical texture images; the texture images are the display images of the target model. The shadow image of the target model is obtained by mirroring the first texture image; the first texture image is either of the two texture images. The display image and the shadow image of the target model are displayed in the target display area.
[0007] Secondly, this application provides a model shadow processing apparatus, the apparatus comprising: The acquisition unit is used to acquire the target model for which the shadow to be generated is located; A rendering unit is used to render the target model once using a first rendering camera to obtain a first rendering result; A processing unit is configured to process the first rendering result to obtain two identical texture images; the texture images are display images of the target model. A mirror unit is used to mirror the first texture image to obtain the shadow image of the target model; the first texture image is either of the two texture images. The display unit is used to display the display image and the shadow image of the target model in the target display area.
[0008] Thirdly, this application provides an electronic device, which includes at least a memory and a processor. The memory stores a computer program, and when the processor executes the computer program in the memory, it implements the model shadow processing method provided in the first aspect.
[0009] Fourthly, this application provides a storage medium storing a computer program thereon, which, when executed by a processor, implements the model shadow processing method provided in the first aspect above.
[0010] The method, apparatus, device, system, and storage medium for processing model shadows provided in this application include: acquiring a target model for which shadows are to be generated; rendering the target model once using a first rendering camera to obtain a first rendering result; processing the first rendering result to obtain two identical texture images; the texture images being the display image of the target model; mirroring the first texture image to obtain a shadow image of the target model; the first texture image being either of the two texture images; and displaying the display image and the shadow image of the target model correspondingly in a target display area.
[0011] In the solution of this application, when obtaining the shadow image of the target model, a single rendering camera is used to render the target model once to obtain a first rendering result. This first rendering result is then processed to obtain two identical texture images. One texture image is then mirrored to obtain the shadow image of the target model. Finally, the display image and shadow image of the target model are displayed accordingly. Compared to related technologies that require rendering the display image once and the shadow image once, this solution obtains both the display image and the shadow image in a single rendering operation, saving one rendering step, reducing the computational demands on the GPU, and improving processing speed. Attached Figure Description
[0012] Figure 1This is a schematic diagram of an optional process for processing model shadows in an embodiment of this application. Figure 2 A schematic diagram of a first optional process for processing model shadows provided in an embodiment of this application; Figure 3 A schematic diagram of a second optional process for processing model shadows provided in an embodiment of this application; Figure 4 A schematic diagram of a third optional method for processing model shadows provided in an embodiment of this application; Figure 5 A schematic diagram of a fourth optional method for processing model shadows provided in the embodiments of this application; Figure 6 A schematic diagram of a fifth optional method for processing model shadows provided in an embodiment of this application; Figure 7 A schematic diagram of a sixth optional method for processing model shadows provided in the embodiments of this application; Figure 8 A schematic diagram of a first optional structure for processing model shadows according to an embodiment of this application; Figure 9 A second optional structural diagram illustrating the model shadow processing procedure provided in this application embodiment. Figure 10 A schematic diagram of a third optional structure for the model shadow processing procedure provided in the embodiments of this application. Figure 11 An optional schematic diagram of a model shadow processing procedure provided in an embodiment of this application; Figure 12 This is an optional schematic diagram illustrating the display effect of model shadows provided in an embodiment of this application. Figure 13 A schematic diagram of an optional structure of the model shadow processing apparatus provided in an embodiment of this application; Figure 14 This is a schematic diagram of an optional structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0013] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the specific technical solutions of the application will be further described in detail below with reference to the accompanying drawings of the embodiments of this application. The following embodiments are used to illustrate this application, but are not intended to limit the scope of this application.
[0014] In the following description, references are made to “some embodiments,” which describe a subset of all possible embodiments. However, it is understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0015] In the following description, the terms "first," "second," and "third" are used only to distinguish different objects and do not represent a specific order of objects, nor are they constituting a chronological order. It is understood that "first," "second," and "third" may be interchanged in a specific order or sequence where permitted, so that the embodiments of this application described herein can be implemented in an order other than that illustrated or described herein.
[0016] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.
[0017] This application provides a method, apparatus, device, system, and storage medium for processing model shadows. In practical applications, the method for processing model shadows can be implemented by a model shadow processing apparatus, wherein each functional entity in the model shadow processing apparatus can be collaboratively implemented by the hardware resources of electronic devices, such as computing resources like processors and communication resources (such as those used to support various communication methods like optical fiber and cellular networks).
[0018] The following describes the model shadow processing scenario provided in the embodiments of this application.
[0019] The scene includes an electronic device used to perform the following actions: acquiring a target model for which a shadow is to be generated; rendering the target model once using a rendering camera to obtain two identical texture images; the texture images being the display images of the target model; mirroring the first texture image to obtain a shadow image of the target model; the first texture image being either of the two texture images; and displaying the display image and the shadow image of the target model in the target display area.
[0020] Electronic devices refer to devices with relevant data processing capabilities. This application does not limit the specific type of electronic device; configuration can be based on actual needs. For example, electronic devices may include, but are not limited to, servers, computers, or tablet computers, etc.
[0021] For example, the scenario for processing model shadows may include an electronic device 10. Model processing software 101 runs on the electronic device 10. The model processing software 101 is used to obtain a display image 103 and a shadow image 104 of the target model 102.
[0022] The present application does not specifically limit the model processing software 101, and it can be configured according to actual needs. For example, the model processing software 101 can be Unity software.
[0023] Target model 102 refers to the model built in model processing software 101. The target model can be a two-dimensional model or a three-dimensional model.
[0024] Here, the number of target model 102, display image 103, and shadow image 104 is not limited and can be configured according to actual needs. Here, one target model 102 corresponds to one display image and one shadow image.
[0025] The following describes various embodiments of the model shadow processing method, apparatus, device, system, and storage medium provided in the embodiments of this application.
[0026] In a first aspect, embodiments of this application provide a method for processing model shadows, which is applied to a model shadow processing apparatus; wherein the model shadow processing apparatus can be deployed on an electronic device. The model shadow processing method will now be described using an electronic device as the executing entity.
[0027] Figure 2 This diagram illustrates a process for processing model shadows. (See reference) Figure 2 The methods for handling shadows in this model, as shown, may include, but are not limited to, those for the following purposes. Figure 2 S201 to S204 are shown.
[0028] The method for processing model shadows is used to determine the shadow image of the target model for display. This application does not specifically limit the number of target models, and the processing procedure for each target model is similar. Below, the processing procedure for the shadow of a single target model is described as an example.
[0029] S201. The electronic device acquires the target model of the shadow to be generated.
[0030] Electronic devices refer to electronic devices with relevant processing capabilities. For example, electronic devices may include, but are not limited to, servers, computers, or tablets. These electronic devices run model processing software to perform relevant processing. For example, the model processing software may be Unity software.
[0031] The target model refers to the model from which the shadow is to be generated. This model can be a two-dimensional or three-dimensional model. This application does not specifically limit the type of model, etc., and can be configured according to actual conditions. For example, the target model can be a three-dimensional model of a vehicle or equipment; or it can be a two-dimensional display model of an application control.
[0032] In one possible implementation, S201 can be implemented as follows: the electronic device draws a model based on actual needs to obtain the target model.
[0033] In another possible implementation, the target model is pre-drawn and stored in a fixed location, and S201 can be implemented as follows: the electronic device acquires the target model at the fixed location.
[0034] S202. The electronic device uses the first rendering camera to render the target model once, and obtains the first rendering result.
[0035] The first rendering camera refers to any camera configured in the rendering engine that performs rendering processing.
[0036] The implementation of S202 may include: an electronic device creating a rendering camera, using the rendering camera to perform a rendering process on the target model (e.g., vertex transformation, primitive assembly, texture computation shading, and rasterization) to obtain a first rendering result.
[0037] There are no restrictions on the rendering colors, etc., and they can be configured according to actual needs. For example, the rendering colors can be based on the actual colors of the target model; or, for virtual target models, they can be rendered in the colors desired to be displayed.
[0038] Here, the type of the first rendering camera may differ for different types of target models.
[0039] For example, when the target model is a two-dimensional model, the corresponding first rendering camera is an orthographic camera; when the target model is a three-dimensional model, the corresponding first rendering camera is a perspective camera.
[0040] S203. The electronic device processes the first rendering result to obtain two identical texture images.
[0041] The texture image is the display image of the target model.
[0042] S203 can be implemented as follows: The electronic device processes the first rendering result and displays the first rendering result on two textures, thereby obtaining two identical texture images. Since only one rendering is performed, only one first rendering result is obtained, so the two displayed texture images are identical.
[0043] The texture image is the display image of the target model.
[0044] The specific method of processing the first rendering result in this embodiment is not limited and can be configured according to the actual situation.
[0045] S204. After the electronic device performs mirroring processing on the first texture image, it obtains the shadow image of the target model.
[0046] The first texture image is either of the two texture images.
[0047] Here, the direction of the mirror is not specifically limited and can be configured according to actual needs.
[0048] For example, it can be mirrored vertically, horizontally, or even around any straight line.
[0049] S204 can be implemented as follows: the electronic device performs mirroring processing on the first texture image to adjust the first texture image to the direction of the shadow image, thereby obtaining the shadow image of the target model.
[0050] S205. The electronic device displays the display image and the shadow image of the target model in the target display area.
[0051] The location of the target display area on the screen is not specifically limited here and can be configured according to the actual situation.
[0052] For example, implementation of S205 may include: the electronic device adjusting the display image and shadow image of the target model to the target display area accordingly, for example, placing the display image in a preset position in the target display area for displaying the display image, and placing the shadow image below the display image to present a shadow effect.
[0053] The method for processing model shadows provided in this application includes: acquiring a target model for which shadows are to be generated; rendering the target model once using a first rendering camera to obtain a first rendering result; processing the first rendering result to obtain two identical texture images; the texture images being the display image of the target model; mirroring the first texture image to obtain a shadow image of the target model; the first texture image being either of the two texture images; and displaying the display image and the shadow image of the target model in a target display area.
[0054] In the solution of this application, when obtaining the shadow image of the target model, a single rendering camera is used to render the target model once to obtain a first rendering result. This first rendering result is then processed to obtain two identical texture images. One texture image is then mirrored to obtain the shadow image of the target model. Finally, the display image and shadow image of the target model are displayed accordingly. Compared to related technologies that require rendering the display image once and the shadow image once, this solution obtains both the display image and the shadow image in a single rendering operation, saving one rendering step, reducing the computational demands on the GPU, and improving processing speed.
[0055] The method for processing model shadows provided in this application embodiment can further process the shadow image, such as blurring the shadow image.
[0056] refer to Figure 3 The process may include, but is not limited to, S301 to S307 described below.
[0057] S301, The electronic device acquires the target model of the shadow to be generated.
[0058] For a detailed description of the implementation, please refer to the electronic device acquiring the target model of the shadow to be generated in S201. It will not be repeated here.
[0059] S302. The electronic device uses the first rendering camera to render the target model once, and obtains the first rendering result.
[0060] For a detailed description of the implementation, please refer to section S202, where the electronic device uses the first rendering camera to render the target model once to obtain the first rendering result. This will not be elaborated upon here.
[0061] S303, The electronic device processes the first rendering result to obtain two identical texture images.
[0062] For a detailed description of how the electronic device processes the first rendering result to obtain two identical texture images, please refer to section S203. This will not be elaborated upon here.
[0063] S304. After the electronic device performs mirroring processing on the first texture image, it obtains the shadow image of the target model.
[0064] For a detailed description of the implementation, please refer to the description of the shadow image of the target model obtained by the electronic device after mirroring the first texture image in S204. It will not be repeated here.
[0065] S305. Electronic devices determine the reference direction for blurring processing.
[0066] The reference direction for blurring is not limited here and can be configured according to actual needs.
[0067] In one possible implementation, the reference direction for the blurring process can be the V-axis direction in the UV coordinate system.
[0068] Understandably, the reference direction for blurring can be perpendicular to the mirror reference line.
[0069] S306. The electronic device adjusts the target parameter values of the shadow image along the reference direction to blur the shadow image.
[0070] In one possible implementation, the target parameter can be α. Here, α is used to adjust the transparency of the image. A larger value of α corresponds to greater opacity.
[0071] This application does not limit the specific method of adjusting the target parameter value, and it can be configured according to the actual situation. For example, the target parameter value can be gradually increased along the reference direction to blur the shadow image.
[0072] S307. The electronic device displays the display image and the shadow image of the target model in the target display area.
[0073] For specific implementation details, please refer to the detailed description of the display image and the shadow image of the target model displayed by the electronic device in the target display area in S205, which will not be repeated here.
[0074] The following describes the process by which the electronic device in S306 adjusts the target parameter values of the shadow image along the reference direction to blur the shadow image.
[0075] In one possible implementation, S306 may include: smoothing and / or blending the target parameter values of the shadow image along the reference direction to blur the shadow image after smoothing and / or blending.
[0076] Specifically, the target parameter values of the shadow image can be smoothed; or the target parameter values of the shadow image can be blended; or the target parameter values of the shadow image can be both smoothed and blended.
[0077] The specific algorithms for smoothing and / or blending are not limited here and can be configured according to actual needs. For example, smoothing filtering algorithms and layer blending algorithms can be used for processing.
[0078] By adjusting the target parameter values for blurring, compared to blurring based on depth values, computational power is further saved and processing efficiency is improved.
[0079] The process by which the electronic device in S203 processes the first rendering result to obtain two identical texture images will be described below.
[0080] This process may include, but is not limited to, method 1 or method 2 below.
[0081] Method 1: Create a rendering texture and obtain two identical texture images by copying them; Method 2: Create two rendering textures and set the target texture of the rendering camera to the two rendering textures to obtain two identical texture images.
[0082] The following describes the process of creating a rendering texture in Method 1 and obtaining two identical texture images by copying them.
[0083] refer to Figure 4 The process may include, but is not limited to, S401 to S404 described below.
[0084] S401, The electronic device creates the first rendering texture.
[0085] For example, the electronic device creates a rendering texture in the Project window and names it the first rendering texture.
[0086] Here you can also set common parameters for the first rendering texture. For example, common parameters for the first rendering texture can include: resolution, filtering mode, etc.
[0087] S402, The electronic device sets the target texture of the first rendering camera to the first rendering texture.
[0088] The electronic device sets the target texture attribute in the first rendering camera as the first rendering texture, so that the rendering result of the rendering camera can be directly presented on the first rendering texture.
[0089] S403. The electronic device displays the first rendering result on the first rendering texture to obtain a texture image.
[0090] The electronic device presents the first rendering result on the first rendering texture, thereby obtaining a texture image.
[0091] Here, a component is rendered, and the corresponding texture image is updated for that component.
[0092] S404. The electronic device copies the texture image to obtain two identical texture images.
[0093] The electronic device copies the texture image using the copy function on the model processing software, thus obtaining two identical texture images.
[0094] It can be seen that method 1 has the advantage of simple implementation logic.
[0095] The following describes the process of creating two rendering textures in Method 2, setting the target texture of the rendering camera as the two rendering textures, and thus obtaining two identical texture images.
[0096] refer to Figure 5 The process may include, but is not limited to, S501 to S503 described below.
[0097] S501, the electronic device creates a first rendering texture and a second rendering texture.
[0098] The implementation of S501 can be found in the detailed description of the creation of the first rendering texture by the electronic device in S401, which will not be repeated here. The difference is that two rendering textures are created here: the first rendering texture and the second rendering texture.
[0099] S502, The electronic device sets the target texture of the first rendering camera to include the first rendering texture and the second rendering texture.
[0100] The implementation of S502 can be referred to in the detailed description of setting the target texture of the first rendering camera to the first rendering texture in S402, which will not be repeated here.
[0101] S503, the electronic device displays the first rendering result on the first rendering texture and the second rendering texture respectively, and obtains the same two texture images.
[0102] The implementation of S503 can refer to the detailed description of the S403 electronic device displaying the first rendering result on the first rendering texture to obtain a texture image, which will not be repeated here.
[0103] The electronic device sets the target texture attributes in the rendering camera to the first rendering texture and the second rendering texture. In this way, after the target model is rendered once using the rendering camera, the rendering result of the rendering camera can be directly presented on the first rendering texture and the second rendering texture, so that the same two texture images can be obtained.
[0104] It can be seen that method 2 is convenient to implement.
[0105] The process of obtaining the shadow image of the target model by mirroring the first texture image in S204 will be described below.
[0106] refer to Figure 6 The process may include, but is not limited to, S601 to S603 described below.
[0107] S601. The electronic device creates a reference line for generating a reflection.
[0108] This application does not impose specific limitations on the position of the reference line for generating the reflection, and it can be configured according to the actual situation.
[0109] In one possible implementation, the reference line for generating the reflection can be configured as a line parallel to the lower boundary of the displayed image and the display area.
[0110] In another possible implementation, the reference line for generating the reflection can be configured as a line parallel to the right boundary of the displayed image and the display area.
[0111] S602. The electronic device flips the first texture image based on the reference line.
[0112] S602 can be implemented as follows: the electronic device flips the first texture image with reference to the reference line, and the flipped image is symmetrical to the first texture image with reference to the reference line.
[0113] S603. The electronic device determines that the shadow image of the target model is the first texture image after flipping.
[0114] The orientation of the first texture image after flipping has been adjusted so that it can be used as the shadow image of the target model.
[0115] The target model is described below.
[0116] In one possible implementation, the target model includes a two-dimensional target model and a three-dimensional target model.
[0117] In the case where the target model includes a three-dimensional target model, refer to Figure 7 The shadow processing of the model shown may include, but is not limited to, the following S701 to S707.
[0118] S701, The electronic device acquires the target model of the shadow to be generated.
[0119] For a detailed description of the implementation, please refer to the electronic device acquiring the target model of the shadow to be generated in S201. It will not be repeated here.
[0120] S702, The electronic device determines the position of the first rendering camera.
[0121] The specific location should be configured according to actual needs.
[0122] In one possible implementation, it is necessary to display the front view of the target model and determine the position of the first rendering camera as the appropriate position in the front view direction of the target model.
[0123] Understandably, the position of the first rendering camera can also be determined to be an appropriate position from other perspectives of the target model.
[0124] S703. The electronic device determines the target rendering surface in the three-dimensional target model based on the position of the first rendering camera.
[0125] The plane formed by the target model captured by the first rendering camera at this position is determined as the target rendering surface.
[0126] S704. The electronic device uses the first rendering camera to render the target rendering surface in the target model once, and obtains the first rendering result.
[0127] For a detailed description of the implementation, please refer to section S202, where the electronic device uses the first rendering camera to render the target model once to obtain the first rendering result. This will not be elaborated upon here.
[0128] The difference is that the rendering object here is the target rendering surface, while other processing remains the same.
[0129] S705 The electronic device processes the first rendering result to obtain two identical texture images.
[0130] For a detailed description of how the electronic device processes the first rendering result to obtain two identical texture images, please refer to section S203. This will not be elaborated upon here.
[0131] S706. After the electronic device performs mirroring processing on the first texture image, it obtains the shadow image of the target model.
[0132] The first texture image is either of the two texture images.
[0133] For a detailed description of the implementation, please refer to the description of the shadow image of the target model obtained by the electronic device after mirroring the first texture image in S204. It will not be repeated here.
[0134] S707. The electronic device displays the display image and the shadow image of the target model in the target display area.
[0135] For specific implementation details, please refer to the detailed description of the display image and the shadow image of the target model displayed by the electronic device in the target display area in S205, which will not be repeated here.
[0136] The following is a complete example illustrating the process of handling model shadows.
[0137] In 3D engine-related projects, it is often necessary to process 3D models in scenarios such as ice or water surfaces to display real-time reflections (equivalent to the shadows mentioned above). Since 3D models constantly change shape and lighting conditions, it is generally necessary to use another camera to render a separate model as a reflection.
[0138] In other words, two cameras are needed to render the same model twice in order to achieve a real-time reflection.
[0139] Then, a depth test is added to the rendering mode of the camera corresponding to the reflection to achieve a reflection effect that is darker at the top and lighter at the bottom.
[0140] For example, refer to Figure 8 The content shown is rendered once by camera 801 to obtain display image 802; and rendered again by camera 803 to obtain shadow image 804.
[0141] The advantages of this solution include: the 3D model can rotate in any direction in real time, and the reflection will rotate accordingly.
[0142] The disadvantages of this approach include: high rendering pressure, requiring the same model to be rendered twice, and each rendering requires going through the GPU rendering process again, that is, the four stages of vertex transformation, primitive assembly, texture calculation shader and rasterization all need to be repeated, and the rendering pressure is twice that of a single camera rendering.
[0143] This embodiment of the application provides a single-camera reflection implementation scheme for a 3D model viewed from the front. In fact, in many cases, 3D objects do not need to rotate in any direction, especially the content presented to the user, which is always facing the user directly. Therefore, in such cases, to avoid unnecessary performance waste, the following scheme is designed to achieve real-time reflection.
[0144] The solution involves rendering a 3D model once, drawing it on two render textures simultaneously, and then inverting the lower render texture to achieve the rendering of the reflection.
[0145] For example, refer to Figure 9 The content shown is rendered by camera 901 simultaneously on the first rendering texture 902 and the second rendering texture 903 to obtain the display image 905 and the shadow image 906.
[0146] The advantages of this approach include: it can greatly reduce rendering pressure and save performance loss, because the same model is rendered only once, and the GPU's rendering process, namely vertex transformation, primitive assembly, texture calculation shader and rasterization, only needs to go through once.
[0147] The drawbacks of this approach include: if arbitrary rotation of the 3D object's viewpoint is required, viewpoint errors may occur. (Reference) Figure 10 The content shown is rendered by camera 1001, simultaneously rendering the target model 1004 on the first rendering texture 1002 and the second rendering texture 1003, resulting in display image 1005 and shadow image 1006. It can be seen that the effect is poor from a top-down viewpoint.
[0148] Therefore, this solution is very suitable for adding reflection effects to 3D user interface (UI) content and can greatly reduce rendering pressure.
[0149] To make reflections more realistic, they typically need a gradient from light to dark. Traditional solutions require an additional, complex shader with depth testing for the second camera, which is very performance-intensive. However, a single-camera solution only needs to perform simple UV calculations on the Render Texture to achieve this effect, further reducing rendering overhead. Code examples are available. Figure 11 The content shown.
[0150] This method consumes very little computing power and achieves good results; the display effect can be referenced. Figure 12 The content shown. In Figure 12 In the image, 1201 is the display image of the two-dimensional target model, and 1202 is the shadow image of the two-dimensional target model.
[0151] Secondly, embodiments of this application provide a model shadow processing apparatus, such as... Figure 13 As shown, the model shadow processing device 130 includes: an acquisition unit 1301, a rendering unit 1302, a processing unit 1303, a mirroring unit 1304, and a display unit 1305.
[0152] in: Acquisition unit 1301 is used to acquire the target model of the shadow to be generated; Rendering unit 1302 is used to render the target model once using a first rendering camera to obtain a first rendering result; The processing unit 1303 is used to process the first rendering result to obtain two identical texture images; the texture images are the display images of the target model; The mirror unit 1304 is used to mirror the first texture image to obtain the shadow image of the target model; the first texture image is either of the two texture images. Display unit 1305 is used to display the display image and the shadow image of the target model in the target display area.
[0153] In some embodiments, the model shadow processing apparatus 130 further includes a blurring unit, which is configured to perform the following before the display unit 1305 performs the display image and the shadow image corresponding to the target model in the target display area: determining a reference direction for blurring processing; and adjusting the target parameter value of the shadow image along the reference direction to blur the shadow image.
[0154] In some embodiments, the blurring unit is further configured to perform: smoothing and / or blending the target parameter values of the shadow image along the reference direction to blur the smoothed and / or blended shadow image.
[0155] In some embodiments, the processing unit 1303 is further configured to perform: creating a first rendering texture; setting the target texture of the first rendering camera to the first rendering texture; displaying the first rendering result on the first rendering texture to obtain a texture image; and copying the texture image to obtain the same two texture images.
[0156] In some embodiments, the processing unit 1303 is further configured to perform: creating a first rendering texture and a second rendering texture; setting the target texture of the first rendering camera to include the first rendering texture and the second rendering texture; and displaying the first rendering result on the first rendering texture and the second rendering texture respectively to obtain two identical texture images.
[0157] In some embodiments, the mirroring unit 1304 is further configured to: create a reference line for generating a reflection; flip the first texture image with respect to the reference line; and determine that the shadow image of the target model is the flipped first texture image.
[0158] In some embodiments, when the target model includes a three-dimensional target model, the model shadow processing device 130 further includes a determining unit, which is configured to perform: determining the position of the rendering camera; and determining a target rendering surface in the three-dimensional target model based on the position of the rendering camera. Correspondingly, the rendering unit 1302 is used to perform: rendering the target rendering surface in the target model once using the first rendering camera to obtain the first rendering result.
[0159] It should be noted that the model shadow processing device provided in this application embodiment includes all the units included, which can be implemented by a processor in an electronic device; of course, it can also be implemented by specific logic circuits; in the implementation process, the processor can be a central processing unit (CPU), a microprocessor (MPU), a digital signal processor (DSP), or a field-programmable gate array (FPGA), etc.
[0160] The descriptions of the above device embodiments are similar to those of the above method embodiments, and have similar beneficial effects. For technical details not disclosed in the device embodiments of this application, please refer to the descriptions of the method embodiments of this application for understanding.
[0161] It should be noted that, in the embodiments of this application, if the above-described model shadow processing method is implemented as a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiments of this application, or the part that contributes to the related technology, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), magnetic disks, or optical disks. Thus, the embodiments of this application are not limited to any specific hardware and software combination.
[0162] Thirdly, this application provides an electronic device, which includes at least a memory and a processor. The memory stores a computer program, and when the processor executes the computer program in the memory, it implements the model shadow processing method provided in the first aspect above.
[0163] The following is combined with Figure 14 The electronic device 140 shown is illustrated with a structural diagram of the electronic device.
[0164] In one example, such as Figure 14As shown, the electronic device 140 includes: a processor 1401, at least one communication bus 1402, at least one external communication interface 1403, and a memory 1404. The communication bus 1403 is configured to enable communication between these components. The external communication interface 1403 may include standard wired and wireless interfaces.
[0165] The memory 1404 is configured to store instructions and applications executable by the processor 1401, and can also cache data to be processed or already processed by the processor 1401 and various modules in the electronic device (e.g., image data, audio data, voice communication data and video communication data), which can be implemented by flash memory or random access memory (RAM).
[0166] Fourthly, this application provides a storage medium storing a computer program thereon, which, when executed by a processor, implements the model shadow processing method provided in the first aspect above.
[0167] It should be noted that the descriptions of the storage medium and device embodiments above are similar to the descriptions of the method embodiments above, and have similar beneficial effects. For technical details not disclosed in the storage medium and device embodiments of this application, please refer to the descriptions of the method embodiments of this application for understanding.
[0168] It should be understood that the phrase "one embodiment" or "an embodiment" throughout the specification means that a specific feature, structure, or characteristic related to the embodiment is included in at least one embodiment of this application. Therefore, "in one embodiment" or "in some embodiments" appearing throughout the specification do not necessarily refer to the same embodiment. Furthermore, these specific features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. It should be understood that in the various embodiments of this application, the sequence numbers of the above-described processes do not imply a sequential order of execution; the execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application. The sequence numbers of the above-described embodiments are merely descriptive and do not represent the superiority or inferiority of the embodiments.
[0169] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0170] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods, such as: multiple units or components can be combined, or integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the various components shown or discussed can be through some interfaces, and the indirect coupling or communication connection between devices or units can be electrical, mechanical, or other forms.
[0171] The units described above as separate components may or may not be physically separate. The components shown as units may or may not be physical units. They may be located in one place or distributed across multiple network units. Some or all of the units may be selected to achieve the purpose of this embodiment according to actual needs.
[0172] In addition, each functional unit in the various embodiments of this application can be integrated into one processing unit, or each unit can be a separate unit, or two or more units can be integrated into one unit; the integrated unit can be implemented in hardware or in the form of hardware plus software functional units.
[0173] Those skilled in the art will understand that all or part of the steps of the above method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it performs the steps of the above method embodiments. The aforementioned storage medium includes various media that can store program code, such as mobile storage devices, read-only memory (ROM), magnetic disks, or optical disks.
[0174] Alternatively, if the integrated units described above are implemented as software functional modules and sold or used as independent products, they can also be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the embodiments of this application, or the parts that contribute to related technologies, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, ROMs, magnetic disks, or optical disks.
[0175] The above description is merely an embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A method for processing model shadows, characterized in that, The processing method includes: Obtain the target model from which the shadow to be generated; The target model is rendered once using a first rendering camera to obtain a first rendering result; The first rendering result is processed to obtain two identical texture images; the texture images are the display images of the target model. The shadow image of the target model is obtained by mirroring the first texture image; the first texture image is either of the two texture images. The display image and the shadow image of the target model are displayed in the target display area.
2. The processing method according to claim 1, characterized in that, Before displaying the display image and the shadow image of the target model corresponding to the target display area, the method further includes: Determine the reference direction for blurring; The target parameter values of the shadow image are adjusted along the reference direction to blur the shadow image.
3. The processing method according to claim 2, characterized in that, The step of adjusting the first parameter value of the shadow image along the reference direction to blur the shadow image includes: The target parameter values of the shadow image are smoothed and / or blended along the reference direction to blur the shadow image after smoothing and / or blending.
4. The processing method according to claim 1, characterized in that, The process of processing the first rendering result to obtain two identical texture images includes: Create the first rendering texture; Set the target texture of the first rendering camera to the first rendering texture; Display the first rendering result on the first rendering texture to obtain a texture image; Copy the texture image to obtain two identical texture images.
5. The processing method according to claim 1, characterized in that, The process of processing the first rendering result to obtain two identical texture images includes: Create the first and second rendering textures; The target texture of the first rendering camera includes the first rendering texture and the second rendering texture; The first rendering result is displayed on the first rendering texture and the second rendering texture respectively, resulting in two identical texture images.
6. The processing method according to claim 1, characterized in that, The process of mirroring the first texture image to obtain the shadow image of the target model includes: Create a reference line for generating the reflection; The first texture image is flipped based on the reference line; The shadow image of the target model is determined to be the first texture image after flipping.
7. The processing method according to claim 1, characterized in that, Before rendering the target model once using the first rendering camera to obtain the first rendering result, the method further includes: Determine the position of the first rendering camera; Based on the position of the first rendering camera, a target rendering surface is determined in the target model; Correspondingly, the step of rendering the target model once using the first rendering camera to obtain a first rendering result includes: The first rendering camera is used to render the target rendering surface in the target model once to obtain the first rendering result.
8. A device for processing model shadows, characterized in that, The device includes: The acquisition unit is used to acquire the target model for which the shadow to be generated is located; A rendering unit is used to render the target model once using a first rendering camera to obtain a first rendering result; A processing unit is configured to process the first rendering result to obtain two identical texture images; the texture images are display images of the target model. A mirror unit is used to mirror the first texture image to obtain the shadow image of the target model; the first texture image is either of the two texture images. The display unit is used to display the display image and the shadow image of the target model in the target display area.
9. An electronic device, characterized in that, The electronic device includes a memory and a processor, the memory storing a computer program, and the processor executing the model shading processing method according to any one of claims 1 to 7 when running the computer program.
10. A computer-readable storage medium storing a computer program, wherein when the computer program on the computer-readable storage medium is executed, it performs the model shading processing method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Shadow rendering method and device based on model pre-baking, and readable storage medium
CN113570697A
Systems and methods for photogrammetric rendering
US20070285420A1