Model interior rendering method and device, electronic equipment and medium
By calculating normal maps in the spatial coordinate system of a 3D model, a rendered stereoscopic image with lighting effects and a three-dimensional feel is generated, solving the problems of large number of textures and large memory consumption in existing technologies, and achieving better lighting effects and rendering efficiency.
Patent Information
- Application Number
- CN202111669733.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-30
- Publication Date
- 2026-01-16
- Estimated Expiration
- 2041-12-30
AI Technical Summary
When existing technologies use textures to achieve lighting effects in special scenarios, the number of textures is large, which consumes a lot of memory resources, and the lighting effects cannot be changed with the scene.
By acquiring the textures formed by the 3D model in three directions of the spatial coordinate system, normal map calculation is performed to generate a rendered stereoscopic image with lighting effects and a three-dimensional sense, reducing the number of textures and optimizing memory resource usage.
It enables the rendering of 3D images with better lighting effects in special scenes, reduces the number of textures and memory resource usage, and improves the simplicity and convenience of rendering the interior scenes of the model.
Smart Images

Figure CN114299253B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of image technology, and in particular to a model interior scene rendering method and device, electronic equipment and medium. BACKGROUND
[0002] With the development of science and technology, in order to bring better experience to users, the form of data is developing rapidly from two-dimensional to three-dimensional. The three-dimensional modeling method based on images has become a popular technology, but the three-dimensional model itself only reflects the shape information of the object, and lacks material information, so it is difficult to truly restore the lighting effect of the object.
[0003] At present, in the terminal device, the traditional lighting model is usually used to map and render the scene object, and the lighting effect of the mapping is realized by relying on the scene map. However, in some special scenes, for example, in the scene of day and night change, the lighting effect cannot follow the change. If the way of changing the map is used to change the lighting effect, a large number of maps will be additionally increased, and then a large amount of memory resources will be occupied. SUMMARY
[0004] The embodiment of the present application provides a model interior scene rendering method, device, electronic equipment and medium, which solves the technical problems of too many maps and too much memory resource occupation in the prior art when using maps to realize the lighting effect of mapping in special scenes.
[0005] In one aspect, the present application provides a model interior scene rendering method according to an embodiment of the present application, which comprises:
[0006] Obtaining a first direction map formed by a three-dimensional model in a first direction of a space coordinate system;
[0007] Obtaining a second direction map formed by the three-dimensional model in a second direction of the space coordinate system;
[0008] According to the first direction map and the second direction map, performing normal map calculation on the three-dimensional model to obtain a first direction normal map, a second direction normal map and a third direction normal map corresponding to the three-dimensional model in three directions of the space coordinate system;
[0009] According to the first direction normal map, the second direction normal map and the third direction normal map, rendering the interior scene of the three-dimensional model to the surface of the three-dimensional model to obtain a rendered stereoscopic image, wherein the rendered stereoscopic image is a map with lighting effect and three-dimensional stereoscopic effect.
[0010] Optionally, the normal mapping calculation on the three-dimensional model according to the first direction map and the second direction map comprises:
[0011] The first direction map and the second direction map are determined as target direction maps, respectively;
[0012] The target direction map is subjected to normal mapping calculation according to a preset light viewing angle, to obtain a target direction normal map in a corresponding direction of the target direction map, the target direction normal map being the first direction normal map or the second direction normal map;
[0013] The first direction map and the second direction map are processed by using a ray stepping technique, to obtain the third direction normal map;
[0014] The third direction normal map is a normal map corresponding to the three-dimensional model in a third direction of a space coordinate system.
[0015] Optionally, the preset light viewing angle comprises a first light viewing angle and a second light viewing angle, the slopes of the first light viewing angle and the second light viewing angle corresponding to each other are opposite numbers, and the normal mapping calculation on the target direction map according to the preset light viewing angle to obtain the target direction normal map in the corresponding direction of the target direction map comprises:
[0016] The target direction map is subjected to normal mapping calculation in a viewing angle direction indicated by a target light viewing angle, to obtain a target viewing angle normal map, the target light viewing angle comprising the first light viewing angle and the second light viewing angle, and the target viewing angle normal map comprising a first viewing angle normal map corresponding to the first light viewing angle and a second viewing angle normal map corresponding to the second light viewing angle;
[0017] The target direction normal map is calculated according to the first viewing angle normal map and the second viewing angle normal map.
[0018] Optionally, the normal mapping calculation on the target direction map in the viewing angle direction indicated by the target light viewing angle to obtain the target viewing angle normal map comprises:
[0019] The target direction map is subjected to normal calculation on an effective area according to the target light viewing angle, to obtain a calculation direction map;
[0020] The calculation direction map is subjected to mask processing, to obtain a target mask map;
[0021] The calculation direction map is subjected to mask processing, to obtain a target mask map;
[0022] Fusing the target mask map and the target shading map to obtain the target perspective normal map.
[0023] Optionally, the normal calculation of the effective area of the target directional map according to the target lighting perspective includes:
[0024] Obtaining a third directional map formed by the three-dimensional model in a third direction of a spatial coordinate system;
[0025] Performing a remapping transformation on the third directional map to obtain a transformed directional map;
[0026] According to the target lighting perspective, determining the effective area in the target directional map;
[0027] Performing normal calculation on the transformed directional map and the effective area in the target directional map to obtain the calculated directional map.
[0028] Optionally, the mask processing of the calculated directional map to obtain the target mask map includes:
[0029] According to the calculated directional map and the third directional normal map, an initial mask map is calculated;
[0030] According to the initial mask map, the calculated directional map is interpolated to obtain the target mask map.
[0031] Optionally, the rendering of the interior scene of the three-dimensional model to the surface of the three-dimensional model according to the first directional normal map, the second directional normal map and the third directional normal map to obtain a rendered stereoscopic image includes:
[0032] Respectively, the first directional normal map, the second directional normal map and the third directional normal map are normalized to obtain corresponding first normal map, second normal map and third normal map;
[0033] The first normal map, the second normal map and the third normal map are fused to obtain a fused normal map;
[0034] According to the fused normal map, the interior scene of the three-dimensional model is rendered to the surface of the three-dimensional model to obtain a rendered stereoscopic image.
[0035] In another aspect, the present application provides a model interior rendering device according to an embodiment of the present application, the device comprises an acquisition module, a calculation module and a processing module, wherein:
[0036] The acquisition module is configured to acquire a first direction map formed by the three-dimensional model in a first direction of a space coordinate system.
[0037] The acquisition module is further configured to acquire a second direction map formed by the three-dimensional model in a second direction of the space coordinate system.
[0038] The calculation module is configured to perform normal map calculation on the three-dimensional model according to the first direction map and the second direction map, to obtain a first direction normal map, a second direction normal map and a third direction normal map corresponding to the three-dimensional model in three directions of the space coordinate system.
[0039] The processing module is configured to render an inner view of the three-dimensional model to a surface of the three-dimensional model according to the first direction normal map, the second direction normal map and the third direction normal map, to obtain a rendered stereoscopic image, wherein the rendered stereoscopic image is a map with lighting effects and three-dimensional stereoscopic effects.
[0040] As to the content not introduced or described in the embodiments of the present application, the relevant introduction in the foregoing method embodiments can be referred to, and will not be described here.
[0041] In another aspect, an electronic device is provided by an embodiment of the present application, and the electronic device comprises a processor, a memory, a communication interface and a bus; the processor, the memory and the communication interface are connected through the bus and complete communication with each other; the memory stores executable program codes; the processor runs programs corresponding to the executable program codes by reading the executable program codes stored in the memory, to execute the model inner view rendering method as described above.
[0042] In another aspect, a computer readable storage medium is provided by an embodiment of the present application, and the computer readable storage medium stores programs; when the programs run in an electronic device, the model inner view rendering method as described above is executed.
[0043] The one or more technical solutions provided in the embodiments of the present application have at least the following technical effects or advantages: the present application obtains a first direction map formed by a three-dimensional model in a first direction of a space coordinate system, obtains a second direction map formed by the three-dimensional model in a second direction of the space coordinate system, then performs normal map calculation on the three-dimensional model according to the first direction map and the second direction map, obtains a first direction normal map, a second direction normal map and a third direction normal map corresponding to the three-dimensional model in three directions of the space coordinate system, and finally renders an interior view of the three-dimensional model to a surface of the three-dimensional model according to the first direction normal map, the second direction normal map and the third direction normal map, to obtain a rendered stereoscopic image, wherein the rendered stereoscopic image is a map with lighting effects and three-dimensional stereoscopic effects. In the above solution, the present application calculates the respective direction normal maps of the three-dimensional model in three directions of the space coordinate system, and then renders the interior view of the three-dimensional model to the surface based on the calculated three direction normal maps, to obtain a rendered stereoscopic image with better lighting effects. Compared with the solution of the prior art that uses a map to achieve lighting effects, the present application can not only reduce the number of maps, but also reduce the memory resources occupied by the maps, and further improve the simplicity and convenience of model interior view rendering. BRIEF DESCRIPTION OF DRAWINGS
[0044] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings needed to be used in the embodiment description. Obviously, the drawings in the following description are some embodiments of the present application, and other drawings can also be obtained by those skilled in the art without any creative effort based on these drawings.
[0045] Figure 1 is a flowchart of a model interior view rendering method provided by the embodiments of the present application.
[0046] Figure 2 is a schematic diagram of a first direction map provided by the embodiments of the present application.
[0047] Figure 3 is a schematic diagram of a third direction normal map provided by the embodiments of the present application.
[0048] Figure 4 is a schematic diagram of an effective area in a target direction map provided by the embodiments of the present application.
[0049] Figure 5 is a schematic diagram of a direction map calculation provided by the embodiments of the present application.
[0050] Figure 6 is a schematic diagram of a target mask map provided by the embodiments of the present application.
[0051] Figure 7 is a scene schematic diagram of initial mask map calculation provided by an embodiment of the present application.
[0052] Figure 8 is a scene schematic diagram of target mask map calculation provided by an embodiment of the present application.
[0053] Figure 9 is a scene schematic diagram of target view normal map calculation provided by an embodiment of the present application.
[0054] Figure 10 is a schematic diagram of XY normal map provided by an embodiment of the present application.
[0055] Figure 11 is a schematic diagram of third normal map provided by an embodiment of the present application.
[0056] Figure 12 is a schematic diagram of fusion normal map provided by an embodiment of the present application.
[0057] Figure 13 is a schematic diagram of rendering stereoscopic image provided by an embodiment of the present application.
[0058] Figure 14 is a structural schematic diagram of model interior scene rendering device provided by an embodiment of the present application.
[0059] Figure 15 is a structural schematic diagram of electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0060] In order to better understand the above technical solutions, the above technical solutions will be described in detail below in combination with the drawings of the specification and specific embodiments.
[0061] First, the term "and / or" appearing in this paper is only to describe the association relationship of the associated objects, which means that there can be three relationships, for example, A and / or B, which can represent the existence of A alone, the existence of A and B, and the existence of B alone. In addition, the character " / " in this paper generally represents that the front and rear associated objects are in an "or" relationship.
[0062] Please refer to Figure 1 is a flow schematic diagram of model interior scene rendering method provided by an embodiment of the present application. As shown in the method can be applied to electronic devices, such as smart phones, tablet computers, etc., can also be applied to servers that establish data interaction with electronic devices, and the present application does not make any limitation. The method comprises the following implementation steps: Figure 1
[0063] S101, acquire a first direction map formed by the three-dimensional model in a first direction of a space coordinate system.
[0064] The three-dimensional model in the present application refers to a three-dimensional image with an interior view in a real space coordinate system. The space coordinate system has three coordinate directions, which can be a first direction, a second direction and a third direction, which can correspond to, for example, an X-axis direction, a Y-axis direction and a Z-axis direction. In other words, the first direction in the present application can be the X-axis direction, the second direction can be the Y-axis direction, and the third direction can be the Z-axis direction.
[0065] S102, acquire a second direction map formed by the three-dimensional model in a second direction of a space coordinate system.
[0066] The present application can acquire a first direction map and a second direction map formed by the three-dimensional model in a first direction and a second direction of a space coordinate system, respectively. For example, the present application can acquire an X-direction map and a Y-direction map obtained by projecting the three-dimensional model in the X-axis direction and the Y-axis direction of the space coordinate system, respectively, which correspond to the first direction map and the second direction map. Please refer to Figure 2 An example diagram showing a possible first direction map is shown. As Figure 2 In the above-mentioned embodiment, the first direction map is an X-direction map obtained by projecting the three-dimensional model along the X-axis direction.
[0067] It should be noted that the direction map (such as the first direction map or the second direction map) involved in the present application refers to a normal map formed by projecting the three-dimensional model along the corresponding direction in the space coordinate system. In other words, the first direction normal map refers to a normal map formed by the three-dimensional model along the first direction in the space coordinate system, and the second direction normal map refers to a normal map formed by the three-dimensional model along the second direction in the space coordinate system.
[0068] S103, according to the first direction map and the second direction map, performing normal map calculation on the three-dimensional model to obtain a first direction normal map, a second direction normal map and a third direction normal map corresponding to the three directions of the space coordinate system.
[0069] S104, according to the first direction normal map, the second direction normal map and the third direction normal map, rendering the interior view of the three-dimensional model to the surface of the three-dimensional model to obtain a rendered stereoscopic image, wherein the rendered stereoscopic image is a map with lighting effect and three-dimensional stereoscopic effect.
[0070] Some specific embodiments related to steps S103 and S104 are described below.
[0071] In step S103, the first direction map and the second direction map can be determined as target direction maps, respectively. Then, normal mapping calculation is performed on the target direction maps according to a preset light view angle, to obtain a target direction normal map corresponding to the target direction maps. The target direction normal map can be the first direction normal map corresponding to the first direction map, or the second direction normal map corresponding to the second direction map.
[0072] Specifically, the first direction map can be subjected to normal mapping calculation according to a preset light view angle, to obtain the first direction normal map corresponding thereto, which can also be referred to as an X direction normal map. Similarly, the second direction map can be subjected to normal mapping calculation according to a preset light view angle, to obtain the second direction normal map corresponding thereto, which can also be referred to as a Y direction normal map. The preset light view angle is a direction view angle corresponding to a light direction when the light is generated. It can be understood that the light view angle corresponding to the same light source has positive and negative values, and accordingly, the preset light view angle has positive and negative values. The first light view angle and the second light view angle can be defined as the first light view angle and the second light view angle, respectively. The slopes corresponding to the first light view angle and the second light view angle are opposite to each other, or the view angle directions corresponding to the first light view angle and the second light view angle are opposite to each other, but the absolute values of the view angle values are equal.
[0073] Further, the first direction map and the second direction map can be processed by Ray Marching to obtain the third direction normal map, which is a normal map corresponding to the third direction of the three-dimensional model in the space coordinate system, and can also be referred to as a Z direction normal map.
[0074] Specifically, in Ray Marching, the first direction map and the second direction map (i.e., the X direction map and the Y direction map) can be calculated by using the Min(X, Y) algorithm to obtain the third direction normal map. For example, please refer to Figure 3 a schematic diagram of a possible third direction normal map is shown. As shown in the third direction normal map, Figure 3 each pixel point in the figure has X and Y coordinates in the space coordinate system, which are obtained by calculating and processing the first direction map and the second direction map by using the Min(X, Y) algorithm, and the Z coordinate is not processed. In this example, it can be understood that Z = 1.
[0075] In an example embodiment, the present application can calculate the specific implementation of the target directional normal map as follows: the present application can perform normal map calculation on the target directional map in the view direction indicated by the target lighting view angle to obtain the corresponding target view normal map. The target lighting view angle includes the first lighting view angle and the second lighting view angle described above, and the target view normal map includes the first view normal map corresponding to the first lighting view angle and the second view normal map corresponding to the second lighting view angle.
[0076] Specifically, the present application can perform normal map calculation on the target directional map in the first view direction indicated by the first lighting view angle to obtain the first view normal map. Similarly, the present application can perform normal map calculation on the target directional map in the second view direction indicated by the second lighting view angle to obtain the second view normal map. In actual application, when the first lighting view angle is positive, the first view direction corresponding to the first lighting view angle can be referred to as the positive direction; when the second lighting view angle is negative, the second view direction corresponding to the second lighting view angle can be referred to as the negative direction. In this case, the first view normal map can be referred to as the positive direction normal map, and the second view normal map can be referred to as the negative direction normal map. Conversely, the present application will not be described here.
[0077] Further, the present application can calculate the target directional normal map according to the first view normal map and the second view normal map. Specifically, the present application can obtain the target directional normal map by subtracting the negative direction normal map from the positive direction normal map. For example, when the first view normal map is the positive direction normal map and the second view normal map is the negative direction normal map, the present application can subtract the second view normal map from the first view normal map to obtain the target directional normal map.
[0078] For example, when the target directional map is the first directional map (X directional map), the present application can perform normal map calculation on the X directional map in the positive direction according to the first lighting view angle (positive direction lighting view angle, i.e. the first lighting view angle is positive) to obtain the first view normal map, which can be referred to as the X positive direction normal map. Correspondingly, the present application can perform normal map calculation on the X directional map in the negative direction according to the second lighting view angle (negative direction lighting view angle, i.e. the second lighting view angle is negative) to obtain the second view normal map, which can be referred to as the X negative direction normal map. Further, the present application can subtract the X negative direction normal map from the X positive direction normal map to obtain the target directional normal map between -1 and 1, which is the X directional normal map here. Similarly, the present application can calculate the Y directional normal map between -1 and 1 by using the above principle.
[0079] In a specific embodiment, the specific implementation of the application for calculating the normal map of the target view can be: the application can first calculate the normal of the effective area of the target directional map according to the target light view, to obtain the corresponding calculated directional map.
[0080] In a specific implementation, the application can first obtain a third directional map formed by the three-dimensional model in the third direction of the spatial coordinate system, for example, the application can obtain a Z-directional map obtained by projecting the three-dimensional model in the projection direction corresponding to the Z-axis direction of the spatial coordinate system, that is, the third directional map. Then the application can perform a remap transformation on the third directional map (that is, the Z-directional map) to obtain a corresponding transformed directional map. Specifically, the application can use a remap transformation algorithm to process the Z-axis value (also referred to as the depth of the map / image) of the third directional map from 0 to positive infinity to 0 to 1, that is, the transformed directional map can be obtained. Then the application determines the effective area in the target directional map according to the target light view.
[0081] Specifically, when the target light view is a single-view directional side light view, such as the first light view or the second light view described above, only the map area on the single-view directional side corresponding to the target directional map is correct, and the remaining map area is incorrect. In other words, the effective area is the part of the map area in the target directional map located on the view direction corresponding to the target light view, and the size of the map area can be determined according to the actual situation of the system, for example, half of the map area of the target directional map, and the application does not make any limitation.
[0082] For example, please refer to Figure 4 Fig. 1 shows a schematic diagram of a possible effective area in a target directional map. As Figure 4 In the example shown, the target directional map is an X-directional map, and the target light view is a first light view with a positive view size. Since the target light view is a positive-view directional side light view (that is, the target light view is positive), only the map area on the positive-view directional side in the target directional map is correct, and the map area on the negative-view directional side is incorrect. The all-black area in the diagram is the non-effective area in the target directional map, and the remaining map area (white and gray areas in the diagram) is the effective area in the target directional map.
[0083] Further, the present application can perform normal calculation on the effective area in the transformed directional map and the target directional map to obtain the calculated directional map. It can be understood that in the normal calculation process, the Z-axis value does not directly affect the size of the normal, but affects the range of normal calculation. Therefore, the present application can re-calculate the effective area in the transformed directional map and the target directional map after remap transformation to obtain the calculated directional map. For example, referring to the example shown in Figure 4 , please see Figure 5 , which shows a possible schematic diagram of the calculated directional map. As shown in Figure 5 , the full black area is the non-effective area, i.e. the non-correct area, in the calculated directional map.
[0084] Next, the present application can perform masking processing on the calculated directional map to obtain the corresponding target mask map. Specifically, the present application can perform conversion calculation on the calculated directional map to obtain the target mask map; wherein the specific implementation of the conversion calculation includes but is not limited to any one or a combination of more than one of the following: integer calculation, saturation conversion calculation, minimum value return calculation and other custom configured operation rule calculation, etc. For example, the present application can use the following formula (1) to calculate the target mask map.
[0085]
[0086] wherein x represents the calculated directional map, maskRight represents the target mask map, saturate(), floor() and ceil() all represent some conversion calculation functions, such as floor() being a down rounding function, etc.
[0087] For example, referring to the example shown in Figure 5 , please see Figure 6 , which shows a possible schematic diagram of the target mask map. As shown in Figure 6 , the full black area is the non-effective area, i.e. the non-correct area, in the target mask map.
[0088] Further, the present application can perform masking processing on the calculated directional map to obtain the corresponding target mask map. Specifically, the present application can calculate an initial mask map according to the calculated directional map and the third directional normal map, and specifically, the present application can use the calculated directional map to subtract the third directional normal map to calculate the initial mask map. For example, referring to the example shown in Figure 5 and Figure 3 , please see Figure 7 , which shows a possible schematic diagram of initial mask map calculation. As shown in Figure 7 , the present application uses Figure 5The shown calculation direction map is subtracted Figure 3 The shown third direction normal map, the final initial mask map is obtained.
[0089] After obtaining the initial mask map, the present application can interpolate the calculation direction map according to the initial mask map to obtain the corresponding target mask map. Specifically, the present application can use the following formula (2) to calculate the target mask map.
[0090] X = lerp(x, 1, tempx) formula (2)
[0091] Wherein, x represents the calculation direction map, tempx represents the initial mask map, lerp() represents the interpolation function, and X represents the target mask map.
[0092] For example, refer to Figure 7 The example is shown in Figure 8 A scene diagram for calculating a target mask map is shown. As Figure 8 The present application uses the lerp function to mix / blend the calculation direction map and the initial mask map obtained in Figure 7 to obtain the final target mask map.
[0093] Finally, the present application can blend the target mask map and the target mask map to obtain the corresponding target view normal map. Specifically, the present application can use the interpolation lerp function to blend the target mask map and the target mask map to obtain the target view normal map. For example, refer to Figure 8 and Figure 6 The example is shown in Figure 9 A scene diagram for calculating a target view normal map is shown. As Figure 9 The present application uses the lerp function to mix / blend the target mask map obtained in Figure 8 and the target mask map shown in Figure 6 to obtain the final target view normal map. In this example, Figure 9 The target view normal map shown in
[0094] In step S104, the application can normalize the first directional normal map, the second directional normal map and the third directional normal map respectively to obtain a corresponding first normal map, a second normal map and a third normal map. Specifically, since the values of the three calculated directional normal maps are usually between -1 and 1, the application can normalize the X directional normal map, the Y directional normal map and the Z directional normal map respectively to normalize them to between 0 and 1. It can be understood that the application normalizes the three directional normal maps to between 0 and 1 in order to facilitate viewing the effect. Specifically, when the normal map is converted to a picture display, a negative value will become black. In the normal lighting calculation process, the direction of the normal is still between -1 and 1.
[0095] Then, the application can fuse the first normal map, the second normal map and the third normal map to obtain a corresponding fused normal map. It should be noted that the normalization and fusion of each normal map are not limited to the order of execution.
[0096] For example, the application can first normalize the first directional normal map and the second directional normal map, and then fuse the normalized first normal map and the second normal map to obtain a corresponding XY normal map. Please refer to Figure 10 for a schematic diagram of a possible XY normal map. As Figure 10 shown in the XY normal map, the normal value corresponding to each pixel point in the normal map is between 0 and 1.
[0097] Then, the third directional normal map is normalized to obtain a third normal map. For example, please refer to Figure 11 for a schematic diagram of a possible normalized third normal map. As Figure 11 shown in the third normal map, the Z axis value in the normalized map can be 1.
[0098] Finally, the XY normal map and the third normal map are fused to obtain a final fused normal map. For example, please refer to Figure 12 for a schematic diagram of a possible fused normal map. As Figure 12 shown in the application, the lerp function is used to fuse the Figure 10 obtained XY normal map and the Figure 11 obtained third normal map to obtain the Figure 12 fused normal map shown in .
[0099] After the fusion normal map is obtained, the application can perform corresponding light processing on the three-dimensional model according to the fusion normal map, so as to render the interior scene of the three-dimensional model onto the surface of the three-dimensional model, that is, render the interior scene of the model onto the surface of the model, thereby obtaining a corresponding rendering stereogram. The light processing includes, but is not limited to, diffuse reflection, or other light effect processing, etc. For example, referring to the fusion normal map in the example shown in Figure 12 , see Figure 13 , a schematic diagram of a possible diffuse reflection stereogram is shown. In this example, Lambertian light is used, and the diffuse reflection processing is combined with Figure 12 , the original three-dimensional model is subjected to diffuse reflection processing to render the interior scene of the model onto the surface of the three-dimensional model, thereby obtaining Figure 13 , a rendering stereogram. The rendering stereogram refers to a map with light effect and three-dimensional stereoscopic sense.
[0100] By implementing the application, the application obtains a first-direction map formed by a three-dimensional model in a first direction of a space coordinate system, obtains a second-direction map formed by the three-dimensional model in a second direction of the space coordinate system, then performs normal map calculation on the three-dimensional model according to the first-direction map and the second-direction map, obtains a first-direction normal map, a second-direction normal map and a third-direction normal map corresponding to the three-dimensional model in three directions of the space coordinate system, and finally renders the interior scene of the three-dimensional model onto the surface of the three-dimensional model according to the first-direction normal map, the second-direction normal map and the third-direction normal map, thereby obtaining a rendering stereogram. The rendering stereogram is a map with light effect and three-dimensional stereoscopic sense. In the above scheme, the application calculates the respective direction normal maps of the three-dimensional model in three directions of the space coordinate system, and then renders the interior scene of the three-dimensional model onto the surface of the three-dimensional model based on the calculated three-direction normal maps, so as to obtain a rendering stereogram with better light effect. Compared with the scheme in the prior art that uses a map to achieve light effect, the application can not only reduce the number of maps, but also reduce the memory resources occupied by the maps, and further improve the simplicity and convenience of model interior scene rendering.
[0101] Based on the same inventive concept, another embodiment of the application provides a device and an electronic device for implementing the model interior scene rendering method described in the embodiments of the application.
[0102] Please refer to Figure 14 , which is a structural schematic diagram of a model interior scene rendering device provided by the embodiments of the application. As shown in Figure 14 , the device 14 includes an acquisition module 141, a calculation module 142 and a processing module 143, wherein:
[0103] The acquisition module 141 is configured to acquire a first direction map formed by the three-dimensional model in a first direction of a space coordinate system.
[0104] The acquisition module 141 is further configured to acquire a second direction map formed by the three-dimensional model in a second direction of the space coordinate system.
[0105] The calculation module 142 is configured to perform normal map calculation on the three-dimensional model according to the first direction map and the second direction map, to obtain a first direction normal map, a second direction normal map and a third direction normal map corresponding to the three-dimensional model in three directions of the space coordinate system.
[0106] The processing module 143 is configured to render an interior view of the three-dimensional model to a surface of the three-dimensional model according to the first direction normal map, the second direction normal map and the third direction normal map, to obtain a rendered stereoscopic image, wherein the rendered stereoscopic image is a map with lighting effects and three-dimensional stereoscopic effects.
[0107] Optionally, the calculation module 142 is specifically configured to:
[0108] respectively determine the first direction map and the second direction map as target direction maps;
[0109] perform normal map calculation on the target direction maps according to a preset lighting viewing angle, to obtain a target direction normal map in a direction corresponding to the target direction maps, the target direction normal map being the first direction normal map or the second direction normal map;
[0110] perform processing on the first direction map and the second direction map by using a ray stepping technology, to obtain the third direction normal map;
[0111] The third direction normal map is a normal map corresponding to the three-dimensional model in a third direction of the space coordinate system.
[0112] Optionally, the preset lighting viewing angle includes a first lighting viewing angle and a second lighting viewing angle, and the calculation module 142 is specifically configured to:
[0113] perform normal map calculation on the target direction maps in a viewing angle direction indicated by a target lighting viewing angle, to obtain a target viewing angle normal map, the target lighting viewing angle including the first lighting viewing angle and the second lighting viewing angle, and the target viewing angle normal map including a first viewing angle normal map corresponding to the first lighting viewing angle and a second viewing angle normal map corresponding to the second lighting viewing angle;
[0114] The target direction normal map is calculated according to the first viewing angle normal map and the second viewing angle normal map.
[0115] Optionally, the calculation module 142 is specifically configured to:
[0116] According to the target light view angle, normal calculation is performed on the effective area of the target directional map to obtain a calculation directional map;
[0117] The calculation directional map is subjected to a mask processing to obtain a target mask map;
[0118] The calculation directional map is subjected to a mask processing to obtain a target mask map;
[0119] The target mask map and the target mask map are subjected to a fusion processing to obtain the target view angle normal map.
[0120] Optionally, the calculation module 142 is specifically configured to:
[0121] A third directional map formed by the three-dimensional model in a third direction of a spatial coordinate system is obtained;
[0122] The third directional map is subjected to a remapping transformation to obtain a transformed directional map;
[0123] According to the target light view angle, an effective area in the target directional map is determined;
[0124] The transformed directional map and the effective area in the target directional map are subjected to normal calculation to obtain the calculation directional map.
[0125] Optionally, the calculation module 142 is specifically configured to:
[0126] According to the calculation directional map and the third directional normal map, an initial mask map is calculated;
[0127] According to the initial mask map, the calculation directional map is subjected to an interpolation processing to obtain the target mask map.
[0128] Optionally, the processing module 143 is specifically configured to:
[0129] The first directional normal map, the second directional normal map and the third directional normal map are subjected to a normalization processing respectively to obtain corresponding first normal map, second normal map and third normal map;
[0130] The first normal map, the second normal map and the third normal map are subjected to a fusion processing to obtain a fused normal map;
[0131] According to the fusion normal map, an interior view of the three-dimensional model is rendered to a surface of the three-dimensional model to obtain a rendered stereoscopic image, wherein the rendered stereoscopic image is a map with lighting effects and three-dimensional stereoscopic effects.
[0132] Please see Figure 15 is a structural schematic diagram of an electronic device provided by an embodiment of the present application. As shown in Figure 15 The electronic device 15 shown in the figure includes at least one processor 151, a communication interface 152, a user interface 153, and a memory 154, which can be connected through a bus or other means, and an embodiment of the present application takes the connection through the bus 155 as an example. Among them,
[0133] The processor 151 can be a general-purpose processor, such as a central processing unit (CPU).
[0134] The communication interface 152 can be a wired interface (such as an Ethernet interface) or a wireless interface (such as a cellular network interface or a wireless local area network interface), used for communication with other terminals or websites. In an embodiment of the present application, the communication interface 152 is specifically used to obtain a three-dimensional model or a corresponding directional map formed in each direction in a spatial coordinate system.
[0135] The user interface 153 can specifically be a touch panel, including a touch screen and a touch screen, used to detect operation instructions on the touch panel, and the user interface 153 can also be a physical key or a mouse. The user interface 153 can also be a display screen, used to output and display images or data.
[0136] The memory 154 can include a volatile memory (Volatile Memory), such as a random access memory (RAM); the memory can also include a non-volatile memory (Non-Volatile Memory), such as a read-only memory (ROM), a flash memory, a hard disk (HDD) or a solid-state disk (SSD); the memory 154 can also include a combination of the above types of memories. The memory 154 is used to store a set of program codes, and the processor 151 is used to call the program codes stored in the memory 154 to perform the following operations:
[0137] Obtain a first directional map formed by a three-dimensional model in a first direction of a spatial coordinate system;
[0138] obtaining a second direction map formed by the three-dimensional model in a second direction of the spatial coordinate system;
[0139] performing normal map calculation on the three-dimensional model according to the first direction map and the second direction map to obtain a first direction normal map, a second direction normal map and a third direction normal map corresponding to the three-dimensional model in three directions of the spatial coordinate system;
[0140] rendering an inner view of the three-dimensional model to a surface of the three-dimensional model according to the first direction normal map, the second direction normal map and the third direction normal map to obtain a rendered stereoscopic image, wherein the rendered stereoscopic image is a map with lighting effects and three-dimensional stereoscopic effects.
[0141] Optionally, the performing normal map calculation on the three-dimensional model according to the first direction map and the second direction map to obtain a first direction normal map, a second direction normal map and a third direction normal map corresponding to the three-dimensional model in three directions of the spatial coordinate system comprises:
[0142] determining the first direction map and the second direction map as target direction maps respectively;
[0143] performing normal map calculation on the target direction maps according to a preset lighting viewing angle to obtain a target direction normal map in a corresponding direction of the target direction maps, the target direction normal map being the first direction normal map or the second direction normal map;
[0144] processing the first direction map and the second direction map by using a ray marching technique to obtain the third direction normal map;
[0145] The third direction normal map is a normal map corresponding to the three-dimensional model in a third direction of the spatial coordinate system.
[0146] Optionally, the preset lighting viewing angle comprises a first lighting viewing angle and a second lighting viewing angle, the slopes of the first lighting viewing angle and the second lighting viewing angle corresponding to each other are opposite numbers, and the performing normal map calculation on the target direction maps according to a preset lighting viewing angle to obtain a target direction normal map in a corresponding direction of the target direction maps comprises:
[0147] performing normal map calculation on the target direction maps in a viewing angle direction indicated by a target lighting viewing angle to obtain a target viewing angle normal map, the target lighting viewing angle comprising the first lighting viewing angle and the second lighting viewing angle, and the target viewing angle normal map comprising a first viewing angle normal map corresponding to the first lighting viewing angle and a second viewing angle normal map corresponding to the second lighting viewing angle;
[0148] According to the first view normal map and the second view normal map, the target direction normal map is calculated.
[0149] Optionally, the normal map calculation on the target direction map in the view direction indicated by the target light view is performed to obtain a target view normal map.
[0150] According to the target light view, the normal calculation on the effective area of the target direction map is performed to obtain a calculation direction map.
[0151] The calculation direction map is subjected to a mask processing to obtain a target mask map.
[0152] The calculation direction map is subjected to a mask processing to obtain a target mask map.
[0153] The target mask map and the target mask map are subjected to a fusion processing to obtain the target view normal map.
[0154] Optionally, the normal calculation on the effective area of the target direction map according to the target light view includes:
[0155] A third direction map formed by the three-dimensional model in a third direction of a spatial coordinate system is obtained.
[0156] The third direction map is subjected to a remapping transformation to obtain a transformed direction map.
[0157] According to the target light view, an effective area in the target direction map is determined.
[0158] The transformed direction map and the effective area in the target direction map are subjected to a normal calculation to obtain the calculation direction map.
[0159] Optionally, the mask processing of the calculation direction map includes:
[0160] According to the calculation direction map and the third direction normal map, an initial mask map is calculated.
[0161] According to the initial mask map, the calculation direction map is subjected to an interpolation processing to obtain the target mask map.
[0162] Optionally, the rendering of the interior scene of the three-dimensional model to the surface of the three-dimensional model according to the first direction normal map, the second direction normal map and the third direction normal map includes:
[0163] normalize the first direction normal map, the second direction normal map and the third direction normal map to obtain a first normal map, a second normal map and a third normal map respectively;
[0164] fuse the first normal map, the second normal map and the third normal map to obtain a fused normal map;
[0165] render an interior view of the three-dimensional model to a surface of the three-dimensional model according to the fused normal map to obtain a rendered stereoscopic image.
[0166] By implementing the present application, a first direction map formed by a three-dimensional model in a first direction of a space coordinate system is obtained, a second direction map formed by the three-dimensional model in a second direction of the space coordinate system is obtained, then normal map calculation is performed on the three-dimensional model according to the first direction map and the second direction map to obtain a first direction normal map, a second direction normal map and a third direction normal map corresponding to the three-dimensional model in three directions of the space coordinate system, finally an interior view of the three-dimensional model is rendered to a surface of the three-dimensional model according to the first direction normal map, the second direction normal map and the third direction normal map to obtain a rendered stereoscopic image, wherein the rendered stereoscopic image is a map with lighting effect and three-dimensional stereoscopic sense. In the above scheme, the present application calculates the respective direction normal maps of a three-dimensional model in three directions of a space coordinate system, then renders an interior view of the three-dimensional model to a surface of the three-dimensional model based on the calculated three direction normal maps to obtain a rendered stereoscopic image with better lighting effect. Compared with the scheme of the prior art which uses a map to achieve lighting effect, the present application can not only reduce the number of maps, but also reduce the memory resources occupied by the maps, and further improve the simplicity and convenience of model interior view rendering.
[0167] Those skilled in the art should understand that embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROMs, optical storage, etc.) containing computer-usable program code.
[0168] The embodiments of methods, devices (systems), and computer program products of the application can be described in reference to flowchart illustrations and / or block diagrams of the flowchart and / or block diagrams of the methods, devices (systems), and computer program products according to embodiments of the application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart illustrations and / or block diagrams of the flowchart and / or block diagrams of the methods, devices (systems), and computer program products. Figure 1 one or more functions specified in the flowchart and / or block diagrams of the flowchart and / or block diagrams of the methods, devices (systems), and computer program products. Figure 1 one or more functions specified in the flowchart and / or block diagrams of the flowchart and / or block diagrams of the methods, devices (systems), and computer program products.
[0169] These computer program instructions can also be stored in a computer- readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instructions which implement the flowchart and / or block diagrams of the flowchart and / or block diagrams of the methods, devices (systems), and computer program products. Figure 1 one or more functions specified in the flowchart and / or block diagrams of the flowchart and / or block diagrams of the methods, devices (systems), and computer program products. Figure 1 one or more functions specified in the flowchart and / or block diagrams of the flowchart and / or block diagrams of the methods, devices (systems), and computer program products.
[0170] These computer program instructions can also be loaded into a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the flowchart and / or block diagrams of the flowchart and / or block diagrams of the methods, devices (systems), and computer program products. Figure 1 one or more functions specified in the flowchart and / or block diagrams of the flowchart and / or block diagrams of the methods, devices (systems), and computer program products. Figure 1 one or more functions specified in the flowchart and / or block diagrams of the flowchart and / or block diagrams of the methods, devices (systems), and computer program products.
[0171] While the preferred embodiments of the application have been described, additional variations and modifications can be made to the embodiments by those of skill in the art once they have the benefit of the present disclosure. Therefore, the appended claims are intended to encompass within their scope all such variations and modifications as are within the scope of the application. It should be understood that all the terms used herein are descriptive rather than limiting, and that many changes can be made to the preferred embodiments, while still obtaining the intended results.
[0172] Obviously, numerous modifications and variations of the present application are possible in light of the above teachings. It is therefore to be understood that within the scope of the appended claims and their equivalents, the application can be practiced otherwise than as specifically described.
Claims
1. A method of in-model scene rendering, the method comprising: The method comprises: obtaining a first direction map formed by a three-dimensional model in a first direction of a space coordinate system; obtaining a second direction map formed by the three-dimensional model in a second direction of the space coordinate system; performing normal map calculation on the three-dimensional model according to the first direction map and the second direction map to obtain a first direction normal map, a second direction normal map and a third direction normal map corresponding to the three-dimensional model in three directions of the space coordinate system; rendering an interior view of the three-dimensional model to a surface of the three-dimensional model according to the first direction normal map, the second direction normal map and the third direction normal map to obtain a rendered stereoscopic image, wherein the rendered stereoscopic image is a map with lighting effects and three-dimensional stereoscopic effects; wherein the normal map calculation on the three-dimensional model according to the first direction map and the second direction map to obtain the first direction normal map, the second direction normal map and the third direction normal map corresponding to the three-dimensional model in three directions of the space coordinate system comprises: determining the first direction map and the second direction map as target direction maps respectively; performing normal map calculation on the target direction maps according to a preset lighting viewing angle to obtain a target direction normal map in a direction corresponding to the target direction maps; processing the first direction map and the second direction map by using a ray stepping technique to obtain the third direction normal map; the preset lighting viewing angle comprises a first lighting viewing angle and a second lighting viewing angle, the slopes of the first lighting viewing angle and the second lighting viewing angle are opposite to each other, and the normal map calculation on the target direction maps according to the preset lighting viewing angle to obtain the target direction normal map in a direction corresponding to the target direction maps comprises: performing normal map calculation on the target direction maps in a viewing angle direction indicated by a target lighting viewing angle to obtain a target viewing angle normal map, the target lighting viewing angle comprises the first lighting viewing angle and the second lighting viewing angle, and the target viewing angle normal map comprises a first viewing angle normal map corresponding to the first lighting viewing angle and a second viewing angle normal map corresponding to the second lighting viewing angle; calculating the target direction normal map according to the first viewing angle normal map and the second viewing angle normal map.
2. The method of claim 1, wherein, The target direction normal map is the first direction normal map or the second direction normal map, and the third direction normal map is a normal map corresponding to the three-dimensional model in a third direction of the space coordinate system.
3. The method of claim 1, wherein, The normal map calculation on the target direction maps in a viewing angle direction indicated by a target lighting viewing angle to obtain a target viewing angle normal map comprises: performing normal calculation on an effective area of the target direction maps according to the target lighting viewing angle to obtain a calculation direction map; performing mask processing on the calculation direction map to obtain a target mask map; performing mask processing on the calculation direction map to obtain a target mask map; performing fusion processing on the target mask map and the target mask map to obtain the target viewing angle normal map.
4. The method of claim 3, wherein, The normal calculation of the effective area of the target direction map according to the target light view angle includes: Obtaining a third direction map formed by the three-dimensional model in a third direction of a space coordinate system; Performing a remapping transformation on the third direction map to obtain a transformed direction map; According to the target light view angle, determining the effective area in the target direction map; Performing normal calculation on the transformed direction map and the effective area in the target direction map to obtain the calculated direction map.
5. The method of claim 3, wherein, The mask processing on the calculated direction map to obtain a target mask map includes: According to the calculated direction map and the third direction normal map, an initial mask map is calculated; According to the initial mask map, the calculated direction map is subjected to interpolation processing to obtain the target mask map.
6. The method of claim 1, wherein, The rendering of the interior scene of the three-dimensional model to the surface of the three-dimensional model according to the first direction normal map, the second direction normal map and the third direction normal map to obtain a rendered stereoscopic image includes: The first direction normal map, the second direction normal map and the third direction normal map are subjected to normalization processing respectively to obtain corresponding first normal map, second normal map and third normal map; The first normal map, the second normal map and the third normal map are subjected to fusion processing to obtain a fused normal map; According to the fused normal map, the interior scene of the three-dimensional model is rendered to the surface of the three-dimensional model to obtain a rendered stereoscopic image.
7. An apparatus for in-model rendering, the apparatus comprising: The device includes an acquisition module, a calculation module and a processing module, wherein: The acquisition module is configured to acquire a first direction map formed by a three-dimensional model in a first direction of a space coordinate system; The acquisition module is further configured to acquire a second direction map formed by the three-dimensional model in a second direction of the space coordinate system; The calculation module is configured to perform normal map calculation on the three-dimensional model according to the first direction map and the second direction map to obtain a first direction normal map, a second direction normal map and a third direction normal map corresponding to the three-dimensional model in three directions of the space coordinate system; The processing module is configured to render the interior scene of the three-dimensional model to the surface of the three-dimensional model according to the first direction normal map, the second direction normal map and the third direction normal map to obtain a rendered stereoscopic image, wherein the rendered stereoscopic image is a map with lighting effect and three-dimensional stereoscopic effect; The calculation module includes a determination submodule, a calculation submodule and a processing submodule; The determination submodule is configured to determine the first direction map and the second direction map as target direction maps respectively; The calculation submodule is configured to perform normal map calculation on the target direction maps according to a preset light view angle to obtain a target direction normal map corresponding to the direction of the target direction map, wherein the preset light view angle includes a first light view angle and a second light view angle, and the slopes corresponding to the first light view angle and the second light view angle are opposite numbers. The processing submodule is configured to process the first directional map and the second directional map by using a ray marching technique to obtain the third directional normal map. The computing submodule is specifically configured to perform normal map calculation on the target directional map in a view direction indicated by a target light view angle to obtain a target view normal map, the target light view angle including the first light view angle and the second light view angle, the target view normal map including a first view normal map corresponding to the first light view angle and a second view normal map corresponding to the second light view angle; and the target directional normal map is obtained by calculation based on the first view normal map and the second view normal map.
8. An electronic device, comprising: The electronic device comprises a processor, a memory, a communication interface and a bus; the processor, the memory and the communication interface are connected through the bus and complete communication among each other; the memory stores executable program codes; the processor runs programs corresponding to the executable program codes by reading the executable program codes stored in the memory, so as to execute the in-model scene rendering method according to any one of claims 1-7.
9. A computer-readable storage medium, characterized in that, The computer readable storage medium stores programs, and when the programs run in the electronic device, the in-model scene rendering method according to any one of claims 1-7 is executed.
Citation Information
Patent Citations
Method and device for processing normal map, storage medium, processor and terminal
CN108447111A
method for generating a 3D material map through a picture with multi-angle lighting
CN109523619A