Model rendering method and device, electronic equipment and storage medium
By rendering raindrop texture maps on the target model and adjusting the model pose according to the environment parameters and camera motion parameters to coincide with the virtual camera, the problem of low rendering efficiency in the existing technology is solved, and a more efficient rendering effect is achieved.
Patent Information
- Application Number
- CN202411929619.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-25
- Publication Date
- 2025-04-18
AI Technical Summary
When simulating rainfall effects, the existing technology requires controlling a large number of particles, resulting in an exponential increase in computing resource demand and low rendering efficiency.
By obtaining the target model and raindrop texture map of the raindrop to be rendered, obtaining the environment parameters of the virtual scene and the camera motion parameters of the virtual camera, adjusting the position of the target model, so that its center position coincides with the virtual camera, and rendering raindrops on the target model based on the raindrop texture map.
By using raindrop texture maps to render the model that adapts to the environment, the computing resource pressure caused by multi-particle control is avoided and the efficiency of rendering rainfall effect is improved.
Smart Images

Figure CN119850815A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of rendering technology, and in particular to a model rendering method, device, electronic device and storage medium. Background Art
[0002] Under the wave of the Internet, entertainment projects are becoming more and more important in people's lives. In order to meet the needs of scene effect presentation in some entertainment projects (such as animated movies and games), the natural environment in the scene needs to be simulated, for example, simulating the rainfall effect.
[0003] Currently, a large number of particles can be used to simulate the interaction effect of raindrops in the environment, and different degrees of rainfall effects can be created by changing the number of particles. However, due to the large number of particles that need to be controlled when simulating rainfall effects, each particle needs to calculate its own movement speed and perform collision detection with the scene, which leads to an exponential increase in the demand for computing resources, resulting in low efficiency in rendering rainfall effects. Summary of the invention
[0004] The embodiments of the present application provide a model rendering method, device, electronic device and storage medium, which can improve the efficiency of rendering rainfall effects.
[0005] In a first aspect, an embodiment of the present application provides a model rendering method, the method comprising:
[0006] Get the target model of raindrops to be rendered and the raindrop texture map;
[0007] Obtaining the environment parameters of the virtual scene and the camera motion parameters of the virtual camera;
[0008] The position and posture of the target model are adjusted according to the environmental parameters and the camera motion parameters, so that the center position of the target model coincides with the position of the virtual camera;
[0009] Based on the raindrop texture map, raindrops are rendered on the target model.
[0010] In a second aspect, an embodiment of the present application provides a model rendering device, the device comprising:
[0011] A model acquisition module is used to obtain a target model of raindrops to be rendered and a raindrop texture map;
[0012] A parameter acquisition module is used to obtain the environment parameters of the virtual scene and the camera motion parameters of the virtual camera;
[0013] A posture adjustment module, used to adjust the posture of the target model according to the environmental parameters and the camera motion parameters, so that the center position of the target model coincides with the position of the virtual camera;
[0014] A rendering module is used to render raindrops on the target model based on the raindrop texture map.
[0015] In a third aspect, an embodiment of the present application further provides an electronic device, comprising a memory storing a plurality of instructions; a processor loads instructions from the memory to execute the steps of any one of the model rendering methods provided in the embodiments of the present application.
[0016] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, which stores a plurality of instructions suitable for loading by a processor to execute the steps of any one of the model rendering methods provided in the embodiments of the present application.
[0017] In a fifth aspect, an embodiment of the present application further provides a computer program product, including a computer program or instructions, which, when executed by a processor, implements the steps in any one of the model rendering methods provided in the embodiments of the present application.
[0018] By adopting the scheme of the embodiment of the present application, it is possible to obtain a target model of raindrops to be rendered and a raindrop texture map; obtain environmental parameters of a virtual scene and camera motion parameters of a virtual camera; adjust the posture of the target model according to the environmental parameters and the camera motion parameters, so that the center position of the target model coincides with the position of the virtual camera; render raindrops on the target model based on the raindrop texture map, thereby rendering raindrops on a model whose posture adapts to the environment by utilizing the raindrop texture map, thereby avoiding the pressure on computing resources caused by multi-particle control and improving the efficiency of rendering rainfall effects. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0020] Figure 1 This is a flow chart of an embodiment of the model rendering method provided in the embodiments of the present application;
[0021] Figure 2 is a schematic diagram of a target model provided in an embodiment of the present application;
[0022] Figure 3 is a schematic diagram for comparing rendering results provided in an embodiment of the present application;
[0023] Figure 4 is a schematic diagram of the raindrop change effect provided in an embodiment of the present application;
[0024] Figure 5 is a schematic diagram of the development of a double cone model provided in an embodiment of the present application;
[0025] Figure 6 is the raindrop texture map provided in the embodiment of the present application;
[0026] Figure 7 is a schematic diagram of a multi-level raindrop effect provided in an embodiment of the present application;
[0027] Figure 8 is a schematic diagram of transparency values provided in an embodiment of the present application;
[0028] Fig. 9 This is a schematic diagram of a rainfall effect provided in an embodiment of the present application;
[0029] Fig.10 is a schematic diagram of the density change of raindrops provided in an embodiment of the present application;
[0030] Fig.11 is another schematic diagram of rainfall effect provided in an embodiment of the present application;
[0031] Fig.12 is a schematic diagram of the shielding effect provided in an embodiment of the present application;
[0032] Fig.13 is a structural diagram of a model rendering device provided in an embodiment of the present application;
[0033] Fig.14 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0034] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without making creative work are within the scope of protection of the present application. At the same time, in the description of the embodiments of the present application, the terms "first", "second", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance. Thus, the features defined as "first" and "second" may explicitly or implicitly include one or more features. In the description of the embodiments of the present application, the meaning of "multiple" is two or more, unless otherwise clearly and specifically defined.
[0035] Embodiments of the present application provide a model rendering method, device, electronic device, and computer-readable storage medium.
[0036] Specifically, this embodiment will be described from the perspective of a model rendering device, which can be integrated into an electronic device, that is, the model rendering method of the embodiment of the present application can be executed by an electronic device, and optionally, the electronic device can include: a terminal device. The terminal device can be a mobile phone, a tablet computer, a smart Bluetooth device, a laptop computer, a game console, or a personal computer (PC) and other devices.
[0037] The model rendering method provided in the embodiment of the present application can be applied to a model rendering system. The model rendering system may include a player terminal device and a server, and the terminal may be a device including both receiving and transmitting hardware, that is, a device having receiving and transmitting hardware capable of performing two-way communication on a two-way communication link. The player terminal device and the server may perform two-way communication via a network.
[0038] Optionally, the server may be an independent server, or a server network or server cluster composed of servers, including but not limited to a computer, a network host, a single network server, a plurality of network server sets or a cloud server composed of multiple servers. The cloud server is composed of a large number of computers or network servers based on cloud computing.
[0039] The following is a detailed description in conjunction with the accompanying drawings. In this embodiment, the execution subject is a terminal device as an example. It should be noted that the description order of the following embodiments is not intended to limit the preferred order of the embodiments. Although the logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in an order different from that shown in the accompanying drawings.
[0040] The model rendering method of this embodiment obtains a target model of raindrops to be rendered and a raindrop texture map; obtains environmental parameters of a virtual scene and camera motion parameters of a virtual camera; adjusts the pose of the target model according to the environmental parameters and the camera motion parameters, so that the center position of the target model coincides with the position of the virtual camera; and renders raindrops on the target model based on the raindrop texture map, thereby improving the efficiency of rendering rainfall effects.
[0041] Please refer to Figure 1 Taking a terminal as an example, this embodiment provides a model rendering method. The specific process of the model rendering method can be as follows: Steps 101 to 104, wherein:
[0042] Step 101: Obtain a target model of raindrops to be rendered and a raindrop texture map.
[0043] Among them, the above-mentioned target model refers to a model that needs to render a rainfall effect. The target model is in a virtual scene. Raindrops can be rendered on the target model to simulate the rainfall effect scene of rain falling from the sky, thereby enhancing the realism and atmosphere of the scene.
[0044] The raindrop texture map is used to describe the material properties of raindrops on the surface of the target model. Through the raindrop texture map, raindrops can be rendered on the target model to simulate the rainfall effect on the target model.
[0045] In this embodiment, the terminal acquires the target model and the raindrop texture map to render the target model, thereby rendering raindrops on the target model to create a rainfall effect.
[0046] In some embodiments, the target model may include a model of a specific geometric shape such as a double cone model and a single cone model, which may be set according to the requirements and is not limited here.
[0047] It is understandable that a double-cone model for rendering can be designed according to the characteristics of raindrops to utilize the geometric characteristics of the double cone, so that the rainfall effect rendered on the double-cone model can be more consistent with the perspective performance of raindrops in real scenes, that is, when viewed from the side, the raindrops conform to the performance of naturally falling, and when viewed from the top, the raindrops conform to the performance of spreading from the center.
[0048] For example, Figure 2 As shown, Figure 2 The screen shown in the left area is used to indicate that the target model is a double-cone model, and it is set that there is a virtual camera in the virtual scene, and the virtual camera is in the central area of the double-cone model. Figure 2 The picture shown in the upper figure in the right area is an illustration of the effect when the virtual camera shoots a part of the double cone model from the side, that is, the raindrops appear to fall naturally, and the picture shown in the lower figure is an illustration of the effect when the virtual camera shoots a part of the double cone model upward, that is, the raindrops appear to spread outward from the center, which is more in line with the effect of human eyes looking up at rainfall in a real scene.
[0049] Step 102: Obtain environmental parameters of the virtual scene and camera motion parameters of the virtual camera.
[0050] The above-mentioned environmental parameters are parameters of the virtual environment in the virtual scene, such as parameters related to wind force, parameters related to weather, parameters related to environmental terrain, etc., which can be set according to specific needs and are not limited here.
[0051] The camera motion parameters are parameters related to the movement of the virtual camera in the virtual scene, such as the camera speed, camera acceleration vector, and movement direction during camera movement. They can be set according to requirements and are not limited here.
[0052] It should be noted that a virtual camera is provided in the above-mentioned virtual scene, and the above-mentioned target model can be mounted on the virtual camera so that the virtual camera can shoot the target model, wherein the position of the above-mentioned virtual camera can be set at the center position of the target model, and the position of the above-mentioned virtual camera can have a preset mapping relationship with the center position of the target model.
[0053] Specifically, the above-mentioned environmental parameters and the above-mentioned camera motion parameters can be obtained by: the terminal obtaining information input by the user; or, the terminal can pre-establish an association relationship between the time parameter and the environmental parameters and the camera motion parameters, so as to obtain the corresponding environmental parameters and camera motion parameters based on the time parameter.
[0054] Step 103: adjusting the position and posture of the target model according to the environmental parameters and the camera motion parameters, so that the center position of the target model coincides with the position of the virtual camera.
[0055] The position and posture of the target model may include the position and / or posture of the target model.
[0056] It is understandable that in order to ensure the shooting effect of the virtual camera on the target model, the center position of the target model and the position of the virtual camera may be overlapped, that is, in the virtual scene, the virtual camera is located at the center position of the target model.
[0057] In this embodiment, the terminal obtains environmental parameters and camera motion parameters to adjust the pose of the target model based on the two, thereby simulating the change in direction of raindrops moving in the environment through the pose adjustment of the target model. For example, the target model can be rotated to simulate the change in the movement direction of raindrops in the environment, thereby greatly reducing the CPU rendering overhead and avoiding the waste of resources caused by a large number of particles in traditional means, such as resource loss caused by the OverDraw phenomenon.
[0058] In computer graphics, OverDraw refers to the phenomenon of repeatedly drawing the same pixel multiple times. OverDraw will waste GPU resources and reduce rendering performance. Figure 3 The following is a schematic diagram comparing the rendering results of the two schemes. Figure 3 The left picture shows the OverDraw phenomenon corresponding to the particle solution. Figure 3The figure on the right shows the OverDraw phenomenon corresponding to the solution of this embodiment, and the information in the bar at the bottom is used to indicate the degree of OverDraw.
[0059] In some embodiments, in real scenes, raindrops are affected by gravity, causing the raindrops to move in free fall. However, when there are external factors (e.g., wind) interfering, the raindrops will appear to move "tilted". Therefore, when simulating rainfall effects, external factors that may affect the falling direction of raindrops must be considered. For example, when the virtual camera moves and / or the wind in the virtual scene changes, the raindrops will appear to move "tilted".
[0060] For this phenomenon, in order to simulate the rainfall effect more realistically, the terminal needs to control the position of the target model based on environmental parameters and camera motion parameters to affect the target model due to the influence of wind and / or camera movement, so as to simulate the influence of wind and / or camera movement on the direction of raindrop movement through position change of the target model.
[0061] For example, Figure 4 As shown in FIG. 1 , when the target model is a double cone model, if the double cone model rotates, the corresponding raindrop change effect will change, such as causing the raindrop movement direction to tilt. Figure 4 In the left and right figures of the figure, when the double cone model is rotated through different rotation angles, the corresponding raindrops move in different directions. Figure 4 The rotated double cone model is shown in the lower right corner of the screen shown in the left and right figures.
[0062] Specifically, the above-mentioned environmental parameters include a wind vector, and the above-mentioned camera motion parameters include a camera acceleration vector. In order to be able to achieve the change of the movement direction of raindrops under the camera motion and wind changes, the above-mentioned adjustment of the posture of the target model according to the above-mentioned environmental parameters and the above-mentioned camera motion parameters may include: the terminal may determine the rotation angle of the above-mentioned target model based on the above-mentioned wind vector and the above-mentioned camera acceleration vector, and then, the terminal may rotate the above-mentioned target model based on the rotation angle of the above-mentioned target model, so as to achieve the raindrop change effect with the camera motion and wind changes by rotating the target model.
[0063] The terminal may superimpose the camera acceleration vector and the wind vector to obtain a superimposed vector, and then apply the superimposed vector to the rotation angle of the target model so that the target model is tilted and rotated based on the rotation angle.
[0064] Optionally, in order to better control the camera acceleration vector and wind vector, weighted processing can be performed using the camera weight coefficient and wind weight coefficient corresponding to the camera acceleration vector and wind vector respectively. In addition, the terminal can also limit the camera acceleration vector and wind vector within the corresponding range respectively to more realistically simulate the effect of raindrop changes.
[0065] For example, if the target model is set to a double-cone model, the rotation angle R of the double-cone model is 双锥体旋转角度 The processing formula corresponding to the acquisition process is as follows:
[0066] V=a*Clamp(V 相机加速度矢量 , 0, Max 加速度 )+b*Clamp(V 风力矢量 , 0, Max 风力 )
[0067] R 双锥体旋转角度 =(Vx, Vy, 0)
[0068] Among them, a is the camera weight coefficient, b is the wind weight coefficient, V 相机加速度矢量 is the camera acceleration vector, V 风力矢量 For the wind vector, you can limit the camera acceleration vector to 0 to Max 加速度 Range, limits the wind vector to 0 to Max 风力 In the range, V is the superimposed vector, Vx is the component of the superimposed vector on the x-axis, and Vy is the component of the superimposed vector on the y-axis. Based on V, R is obtained. 双锥体旋转角度 .
[0069] Step 104: Render raindrops on the target model based on the raindrop texture map.
[0070] In this embodiment, the pose of the target model is adjusted and raindrops are rendered on the pose-adjusted target model based on the raindrop texture map, so that a low-overhead rendering method is adopted while achieving rich and realistic rain effect simulation, thereby improving the efficiency of rendering rainfall effects.
[0071] Specifically, the step of rendering raindrops on the target model based on the raindrop texture map may be: the terminal may obtain the target sampling position of each sampling point of the target model in the raindrop texture map, and then, the terminal may perform sampling in the raindrop texture map based on the target sampling position of each sampling point to obtain the texture sampling results of each sampling point, and finally, the terminal may render raindrops on the target model based on the texture sampling results of each sampling point.
[0072] The above-mentioned sampling points include but are not limited to model vertices of the target model and / or points between model vertices.
[0073] The texture sampling result may be a grayscale value for indicating raindrops, and different grayscale values may result in raindrops with different visual effects when the raindrops are rendered on the model.
[0074] In this embodiment, the terminal maps each sampling point of the target model to the target sampling position in the raindrop texture map, and then samples the texture sampling result at the position in the raindrop texture map based on the target sampling position, thereby applying the sampled texture sampling result to the corresponding sampling point of the target model to achieve rendering of raindrops on the target model.
[0075] In some embodiments, in order to better map the surface of the target model to the raindrop texture map, so that the raindrop texture map can be normally applied to the target model and achieve a more refined texture effect, in this embodiment, the terminal can perform UV development on the target model, that is, determine the corresponding UV layout according to the shape of the target model to unfold the surface of the target model into a plane. This process will rearrange the vertices and faces of the target model in the UV space to ensure that the texture map can be correctly mapped to the model.
[0076] Specifically, the terminal may perform UV development processing on the target model to obtain a model plane, and then the terminal may obtain each sampling point from the model plane to determine the target sampling position of each sampling point in the raindrop texture map.
[0077] For example, Figure 5 As shown in Figure 5 For the double-cone model shown in the left figure, each column of triangles in the double-cone model can be grouped together and laid out flatly in the UV space to obtain Figure 5 The middle figure in the figure shows the two-dimensional model plane after the model is unfolded. Figure 5 The horizontal coordinate of the middle image is U, and the vertical coordinate is V. Therefore, through the plane UV coordinate system, any pixel on the image can be located, and then a point on the surface of the three-dimensional model mapped by the model plane can be located.
[0078] In addition, in order to obtain better rendering effects, weight information can also be recorded on each vertex of the target model. The weight information is used to indicate the transparency in the range of 0 to 1, such as Figure 5 As shown in the figure on the right, the weight information of each vertex of the double-cone model is used to describe transparency, so as to present a fading effect between the upper and lower ends on the double-cone model.
[0079] Specifically, each model vertex of the above-mentioned target model is set with weight information, and the above-mentioned rendering of raindrops on the above-mentioned target model based on the texture sampling results of the above-mentioned sampling points may include: rendering raindrops on the above-mentioned target model based on the texture sampling results of the above-mentioned sampling points and the weight information of the above-mentioned model vertices.
[0080] Exemplarily, if the above texture sampling result is a grayscale value, then when the transparency indicated by the weight information is opaque, rendering is performed completely based on the sampled grayscale value, and when the transparency indicated by the weight information is completely transparent, the raindrop texture is not displayed at the corresponding position.
[0081] In some embodiments, since raindrops appear to drip continuously in real scenes, in order to simulate the motion effect of raindrops dripping down along the target model, the sampling positions of each sampling point of the target model in the raindrop texture map need to be continuously updated during rendering.
[0082] Specifically, the above-mentioned acquisition of the target sampling position of each sampling point of the above-mentioned target model in the above-mentioned raindrop texture map may include: the terminal may obtain a time parameter, determine the position offset of each of the above-mentioned sampling points based on the above-mentioned time parameter, and then, the terminal obtains the historical sampling position of each of the above-mentioned sampling points in the above-mentioned raindrop texture map, so as to determine the target sampling position of each of the above-mentioned sampling points based on the above-mentioned historical sampling positions of each of the above-mentioned sampling points and the above-mentioned position offset.
[0083] The above time parameter is the current moment corresponding to rendering the current frame.
[0084] It can be understood that since the same sampling point samples different positions in the raindrop texture map at different times, the terminal needs to clarify the position offset of the sampling position corresponding to each sampling point based on the acquired time parameters, that is, how much offset is required to sample the raindrop texture. The position offset includes the offset distance and offset direction.
[0085] Furthermore, since raindrops continue to fall downward, the offset direction can be sampled from top to bottom. After sampling the bottom of the raindrop texture map, it can jump back to the top of the raindrop texture map to continue sampling from top to bottom, thereby creating the effect of the texture shifting downward in the plane after the target model is unfolded.
[0086] Among them, the above-mentioned historical sampling position can be the last sampling position or the first sampling position. The first sampling position can be understood as the position where the sampling point on the model is mapped in the raindrop texture map without introducing a time parameter. The specific setting can be based on demand and is not limited here.
[0087] For example, if the historical sampling position is the previous sampling position, then the position offset corresponding to each time parameter update is fixed, and if the historical sampling position is the first sampling position, then the position offset corresponding to each time parameter update will be further accumulated.
[0088] In some embodiments, in order to simulate the rainfall effect more realistically, a plurality of raindrop texture information with different densities may be set to present multi-level rainfall effects with different densities on the target model.
[0089] Furthermore, in order to reduce the amount of computation required for texture sampling and improve rendering efficiency, the terminal may pre-prepare raindrop texture sub-maps of different densities for different texture channels of the raindrop texture map, that is, the above-mentioned raindrop texture map includes at least two texture channels, and different texture channels store raindrop texture information of different densities, and the raindrop texture information is the information in the raindrop texture sub-map. Thus, by merging raindrop texture sub-maps of different densities into a raindrop texture map, it is possible to separate multiple groups of raindrop texture information of different densities by sampling the raindrop texture map only once at runtime, which can be used for multi-level rainfall effect simulation of different densities. While improving the rainfall effect, the number of map sampling required at runtime can be greatly reduced.
[0090] The at least two texture channels include but are not limited to at least two channels of an R channel, a G channel, a B channel and a transparency channel. Figure 6 As shown, Figure 6 The picture shown in the upper side of the figure is a raindrop texture map. In the raindrop texture map, four texture channels are set to store raindrop texture information of different densities respectively. Figure 6 The four images in the lower area correspond to different texture channels, and the density of raindrop texture information in different texture channels is different.
[0091] Specifically, the step of rendering raindrops on the target model based on the texture sampling results of the sampling points may be: the terminal may render the texture sampling results in each texture channel on the target model based on the texture sampling results of the sampling points in the texture channel, so as to render raindrops on the target model, thereby creating a multi-level rainfall effect with rich visual levels.
[0092] In some embodiments, in order to make the multi-level rainfall effect more realistic, the terminal may set a scene depth for each level of rainfall effect, so as to visually present different levels of rainfall effects at different scene depths.
[0093] The scene depth in rendering technology refers to the distance information from each object in the scene to the camera (or observer). The scene depth value is usually stored in a separate texture or buffer called a depth buffer or a Z-Buffer.
[0094] It should be noted that, since in the embodiment, the terminal needs to render the rainfall effect on the target model, therefore, for the target model, in order to be able to visually create a sense of depth, the terminal can introduce transparency, that is, use transparency to represent sampling points of different depths. For example, the closer the distance between the sampling points, that is, the smaller the scene depth, the higher the transparency of the raindrops corresponding to the sampling points can be.
[0095] Specifically, each texture channel may correspond to a scene depth value, and then, the step of rendering raindrops on the target model based on the texture sampling results of the sampling points in the texture channel may be: the terminal may determine the target transparency of the sampling points based on the scene depth value of the texture channel, and finally, the terminal may render raindrops on the target model based on the texture sampling results of the sampling points in the texture channel and the target transparency of the sampling points, thereby visually utilizing the scene depth to achieve a more realistic and delicate multi-layered rainfall effect.
[0096] The scene depth value can be set according to the required effect, and different scene depths can limit the range of target transparency of each sampling point.
[0097] Among them, the step of determining the target transparency of each sampling point based on the scene depth value of the texture channel may be: a first processing method may directly use the transparency corresponding to the scene depth value as the target transparency of each sampling point; or a second processing method may optimize the scene depth value corresponding to each sampling point based on the characteristics of the texture sampled by each sampling point, so as to use the transparency corresponding to the optimized scene depth value as the target transparency. The specific setting may be based on the demand and is not limited here.
[0098] It is understandable that if Figure 7 As shown, if a transparency is determined only according to the scene depth value, as the required transparency of the texture sampling result of each sampling point under a texture channel, the result will be Figure 7 The schematic diagram of the multi-layered raindrop effect shown in the left area shows that the transparency of each sampling point under different texture channels is inconsistent, while the transparency of each sampling point under the same texture channel is consistent, so as to present a consistent depth effect visually. If the characteristics of the texture sampled by each sampling point are further introduced to optimize the depth corresponding to each sampling point, the following can be obtained: Figure 7 The schematic diagram of the multi-level raindrop effect shown in the right area. Figure 7 In the right area of , the raindrops will shift according to their characteristics, so the transparency of each sampling point under the corresponding texture channel is inconsistent, so as to visually present an inconsistent depth effect.
[0099] For example, Figure 8 As shown, if it is set that there are 4 texture channels, namely channel A, channel B, channel C and channel D, the scene depth values corresponding to channel A, channel B, channel C and channel D are threshold A, threshold B, threshold C and threshold D respectively.
[0100] in, Figure 8 The grayscale bar shown is used to indicate transparency information. It can be seen that in the first processing method, the transparency corresponding to each scene depth value is unique, that is, the target transparency of each sampling point in a texture channel is consistent, such as threshold A takes transparency A, threshold B takes transparency B, threshold C takes transparency C, and threshold D takes transparency D.
[0101] If the characteristics of each sampling point are further introduced, then in this second processing method, the transparency corresponding to each scene depth value is not unique, that is, the target transparency of each sampling point in a texture channel is inconsistent. For example, the transparency corresponding to different sampling points in threshold A takes values in transparency range A, the transparency corresponding to different sampling points in threshold B takes values in transparency range B, the transparency corresponding to different sampling points in threshold C takes values in transparency range C, and the transparency corresponding to different sampling points in threshold D takes values in transparency range D.
[0102] Specifically, the above-mentioned raindrop texture information includes grayscale values of multiple raindrops, and the grayscale values of at least two raindrops are different, that is, the characteristic of the texture sampled by the above-mentioned sampling point can be a grayscale value. The above-mentioned determination of the target transparency of each of the above-mentioned sampling points based on the scene depth value of the above-mentioned texture channel may include: the terminal may determine the depth indication parameter of each of the above-mentioned sampling points based on the scene depth value of the above-mentioned texture channel and / or the grayscale value of each of the above-mentioned sampling points in the above-mentioned texture channel, and the above-mentioned depth indication parameter is used to indicate the depth of the above-mentioned sampling point. Then, the terminal may determine the target transparency of each of the above-mentioned sampling points based on the depth indication parameter of each of the above-mentioned sampling points.
[0103] It can be understood that different raindrops have different grayscale values in the same texture channel. The terminal obtains the grayscale value of the raindrop to offset the depth of the raindrop sampled by the sampling point based on the grayscale value sampled by the sampling point, that is, changes the transparency of the raindrop sampled by the sampling point, thereby causing the raindrop rendered by the sampling point to visually present a certain depth.
[0104] Specifically, the above-mentioned determination of the target transparency of each sampling point based on the depth indication parameter of each sampling point may include: the terminal may use the grayscale value of the sampling point as the transparency, and multiply it by the scene depth value to obtain the depth indication parameter indicating the depth of the sampling point in terms of transparency, and directly use the transparency to which the depth indication parameter belongs as the target transparency, thereby simulating raindrops of different density levels before and after visually.
[0105] Specifically, the above-mentioned determination of the target transparency of each sampling point based on the depth indication parameters of the above-mentioned sampling points may include: the terminal may determine the initial transparency corresponding to the scene depth of the above-mentioned texture channel, and then the terminal may update the above-mentioned initial transparency respectively based on the depth indication parameters of the above-mentioned sampling points to obtain the target transparency of the above-mentioned sampling points.
[0106] Among them, the method for updating the above-mentioned initial transparency can be to determine the transparency corresponding to the depth indication parameter, and then superimpose the initial transparency to obtain the target transparency; or, calculate the product of the transparency corresponding to the depth indication parameter and the initial transparency to obtain the target transparency, etc. The specific setting can be based on needs and is not limited here.
[0107] For example, Fig. 9 As shown, based on Figure 8 The second processing example shown is rendered to obtain Fig. 9 The screen shown, Fig. 9 The upper picture in the figure is a combined diagram of four levels of rainfall effects with different densities. Fig. 9 The four figures in the lower area are diagrams of rainfall effects corresponding to the density at each level.
[0108] In some embodiments, since the raindrop texture information includes the grayscale values of multiple raindrops, and the grayscale values of at least two raindrops among the multiple raindrops are different, before rendering the raindrops on the target model based on the texture sampling results of the sampling points, the grayscale value of the raindrops may be limited in range, so that the user can further control the raindrop density, such as Fig.10 As shown in Figure 10, it can be seen that the density of raindrops increases from the left image to the right image. In order to achieve this effect, the terminal can limit the range of the grayscale value of the raindrops, that is, limit the raindrops with grayscale values within the corresponding range to be rendered on the target model, or remap the grayscale value by limiting the range.
[0109] Specifically, the terminal can obtain a preset raindrop density parameter, determine the first difference between the grayscale value of each sampling point and the raindrop density parameter, and map the first difference to a preset range to obtain the mapped parameters of each sampling point. Finally, the terminal can determine the target grayscale value of each sampling point based on the mapped parameters of each sampling point and the raindrop density parameter.
[0110] In this embodiment, a channel is provided for the user to adjust the preset range so that the grayscale value of each sampling point is mapped within a specific range, and then the grayscale value mapped within the specific range is remapped based on the raindrop density parameter, so that the processed target grayscale value can better meet the user's expectations.
[0111] Exemplarily, the preset range may include 0 to 1, and the step of determining the target grayscale value of each sampling point based on the mapped parameters of each sampling point and the raindrop density parameter may be: first, the terminal may calculate the second difference between 1 and the raindrop density parameter, and then, the terminal may calculate the ratio between the mapped parameters of each sampling point and the second difference, and use the ratio corresponding to each sampling point as the target grayscale value of each sampling point.
[0112] Among them, the saturate function can be used to map the first difference to limit the first difference within a preset range. The saturate function can limit the first difference within the range of 0 to 1, that is, if the first difference is less than 0, the saturate function outputs 0, that is, the mapped parameter is 0; if the first difference is greater than 1, the saturate function outputs 1, that is, the mapped parameter is 1.
[0113] For example, the above formula processed by the saturate function is as follows:
[0114]
[0115] The Density is the raindrop density parameter, which can be set according to user needs and is not limited here.
[0116] It can be understood that if the preset range is set to 0 to 1, then when the mapped parameter is 0, the target grayscale value of the corresponding sampling point is 0, which is equivalent to not rendering the raindrops corresponding to the sampling point. Alternatively, it can be understood that after the sampling point is rendered, no raindrops are displayed, thereby controlling the density of raindrops.
[0117] In some embodiments, since the rainfall effect has some associated special effects, such as fog in the rain, the disturbance effect of wind turbulence on the movement of raindrops, etc., in order to better render the rainfall effect on the target model and expand to obtain a more refined rendering effect, the terminal can obtain an associated special effect texture map, such as a fog texture map, to render the target model based on the associated special effect texture map and the raindrop texture map, and render the pattern corresponding to the raindrops and the associated special effects on the above target model, such as Fig.11 As shown, the terminal can be used for Fig.11 The schematic diagram of the rain effect in the left figure further renders the target model, such as using a fog texture map to further render the target model to obtain Fig.11 The picture on the right shows a schematic diagram of the rainfall effect after superimposing the fog effect, which is more in line with the real scene.
[0118] In some embodiments, in order to simulate the rainfall effect more realistically, the terminal may perform occlusion calculation on raindrops and scenes, that is, the terminal may calculate the occlusion relationship between raindrops and virtual objects in the virtual scene through the GPU.
[0119] Specifically, the terminal can obtain the shooting direction and camera position of the above-mentioned virtual camera, and then the terminal can determine the sampling point height of the above-mentioned sampling points in the above-mentioned virtual scene based on the depth indication parameters of the above-mentioned sampling points, the above-mentioned shooting direction and the above-mentioned camera position, and the terminal can obtain the object height of the virtual object in the above-mentioned virtual scene, and the object height of the virtual object is used to indicate the occlusion front in the virtual scene. Finally, the terminal can perform occlusion culling operations on some of the above-mentioned sampling points based on the sampling point height of the above-mentioned sampling points and the above-mentioned object height by comparing the sampling point height and the object height, so that the occlusion effect only needs to be calculated once on the GPU to compare the world position, and the parallelism of the GPU is fully utilized to achieve the occlusion effect of raindrops and scenes at a lower cost.
[0120] It can be understood that in order to calculate the occlusion effect of raindrops and scenes, the highest height of each virtual object can be recorded from top to bottom in the virtual scene to compare the world height of the raindrops with the object height of the virtual objects that are occluded in the virtual scene. Therefore, it is necessary to calculate the virtual world position of each sampling point. Since the sampling point is a point on the target model, its actual world position is unchanged. Therefore, the terminal can clarify the virtual world position of each sampling point based on the depth indication information of each sampling point, that is, the distance between each sampling point and the virtual camera, and then determine the visually presented height of the sampling point based on the virtual world position of the sampling point. Then, by subtracting the height of the sampling point from the height of the object, the occlusion effect of the raindrop corresponding to each sampling point can be obtained. That is, if the object height corresponding to the roof is 100m, then the raindrop will not be blocked above 100m, and will be blocked below 100m and need to be eliminated, such as Fig.12 shown.
[0121] The calculation process of the virtual world position P of the above sampling point is as follows:
[0122] P=V Cam *Depth+P Cam
[0123] Among them, the above V Cam is the shooting direction, the above Depth is the depth indication parameter, and the above P Cam is the camera position.
[0124] From the above content, it can be seen that by obtaining the target model of raindrops to be rendered and the raindrop texture map; obtaining the environmental parameters of the virtual scene and the camera motion parameters of the virtual camera; adjusting the pose of the target model according to the environmental parameters and the camera motion parameters, the center position of the target model coincides with the position of the virtual camera; based on the raindrop texture map, raindrops are rendered on the target model, so that the raindrop texture map is used to render raindrops on the model whose pose adapts to the environment, thereby avoiding the pressure of computing resources brought by multi-particle control and improving the efficiency of rendering rainfall effects.
[0125] This embodiment also provides a model rendering device, which can be integrated into a terminal device. Fig.13 As shown, the model rendering device may include:
[0126] Model acquisition module 1301, used to acquire the target model of raindrops to be rendered and the raindrop texture map;
[0127] A parameter acquisition module 1302 is used to acquire the environment parameters of the virtual scene and the camera motion parameters of the virtual camera;
[0128] A posture adjustment module 1303, used to adjust the posture of the target model according to the environmental parameters and the camera motion parameters, so that the center position of the target model coincides with the position of the virtual camera;
[0129] The rendering module 1304 is used to render raindrops on the target model based on the raindrop texture map.
[0130] In some embodiments, the rendering module 1304 is specifically used for:
[0131] Obtaining target sampling positions of each sampling point of the target model in the raindrop texture map;
[0132] Based on the target sampling positions of the sampling points, sampling is performed in the raindrop texture map to obtain texture sampling results of the sampling points;
[0133] Based on the texture sampling results of the above sampling points, raindrops are rendered on the above target model.
[0134] In some embodiments, the rendering module 1304 is specifically used for:
[0135] Obtaining a time parameter, and determining a position offset of each of the sampling points based on the time parameter;
[0136] Obtain the historical sampling positions of the above sampling points in the above raindrop texture map;
[0137] Based on the historical sampling positions of the sampling points and the position offsets, target sampling positions of the sampling points are determined.
[0138] In some embodiments, the raindrop texture map includes at least two texture channels, and different texture channels store raindrop texture information of different densities. The rendering module 1304 is specifically used for:
[0139] Based on the texture sampling results of the above sampling points in the above texture channel, raindrops are rendered on the above target model.
[0140] In some embodiments, each texture channel corresponds to a scene depth value, and the rendering module 1304 is specifically used for:
[0141] Based on the scene depth value of the texture channel, determine the target transparency of each sampling point;
[0142] Based on the texture sampling results of the above sampling points in the above texture channel and the target transparency of the above sampling points, raindrops are rendered on the above target model.
[0143] In some embodiments, the raindrop texture information includes grayscale values of multiple raindrops, and the grayscale values of at least two raindrops are different. The rendering module 1304 is specifically used for:
[0144] Determine a depth indication parameter of each sampling point based on the scene depth value of the texture channel and / or the grayscale value of each sampling point in the texture channel, wherein the depth indication parameter is used to indicate the depth of the sampling point;
[0145] Based on the depth indication parameters of the above sampling points, the target transparency of the above sampling points is determined.
[0146] In some embodiments, the rendering module 1304 is specifically used for:
[0147] Determine the initial transparency corresponding to the scene depth of the above texture channel;
[0148] Based on the depth indication parameters of the above sampling points, the above initial transparency is updated respectively to obtain the target transparency of the above sampling points.
[0149] In some embodiments, the model rendering device further includes an occlusion culling module, and the occlusion culling module is specifically used to:
[0150] Obtain the shooting direction and camera position of the above virtual camera;
[0151] Determine the sampling point height of each sampling point in the virtual scene based on the depth indication parameter of each sampling point, the shooting direction and the camera position;
[0152] Obtaining the object height of the virtual object in the virtual scene;
[0153] Based on the sampling point height of each sampling point and the object height, an occlusion culling operation is performed on some of the sampling points.
[0154] In some embodiments, the model rendering device further includes a mapping module, and the mapping module is specifically used to:
[0155] Get the preset raindrop density parameters;
[0156] Determine a first difference between the grayscale value of each sampling point and the raindrop density parameter, and map the first difference into a preset range to obtain a mapped parameter of each sampling point;
[0157] Based on the mapped parameters of the sampling points and the raindrop density parameters, the target grayscale value of the sampling points is determined.
[0158] In some embodiments, the preset range includes 0 to 1, and the mapping module is specifically used for:
[0159] Calculate a second difference between 1 and the above raindrop density parameter;
[0160] The ratio between the mapped parameter of each sampling point and the second difference is calculated, and the ratio corresponding to each sampling point is used as the target grayscale value of each sampling point.
[0161] In some embodiments, the environmental parameter includes a wind vector, the camera motion parameter includes a camera acceleration vector, and the posture adjustment module 1303 is specifically used for:
[0162] Based on the wind vector and the camera acceleration vector, determining a rotation angle of the target model;
[0163] The target model is rotated based on the rotation angle of the target model.
[0164] From the above content, it can be seen that by obtaining the target model of raindrops to be rendered and the raindrop texture map; obtaining the environmental parameters of the virtual scene and the camera motion parameters of the virtual camera; adjusting the pose of the target model according to the environmental parameters and the camera motion parameters, the center position of the target model coincides with the position of the virtual camera; based on the raindrop texture map, raindrops are rendered on the target model, so that the raindrop texture map is used to render raindrops on the model whose pose adapts to the environment, thereby avoiding the pressure of computing resources brought by multi-particle control and improving the efficiency of rendering rainfall effects.
[0165] Accordingly, an embodiment of the present application further provides an electronic device, which may be a terminal, and the terminal may be a smart phone, a tablet computer, a laptop computer, a touch screen, a game console, a personal computer (PC, Personal Computer), a personal digital assistant (Personal Digital Assistant, PDA) and other terminal devices. Alternatively, the electronic device may be a server.
[0166] like Fig.14 As shown, Fig.14 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. The electronic device 1400 includes a processor 1401 having one or more processing cores, a memory 1402 having one or more computer-readable storage media, and a computer program stored in the memory 1402 and executable on the processor. The processor 1401 is electrically connected to the memory 1402. It will be understood by those skilled in the art that the electronic device structure shown in the figure does not constitute a limitation on the electronic device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0167] The processor 1401 is the control center of the electronic device 1400, and uses various interfaces and lines to connect various parts of the entire electronic device 1400. By running or loading software programs and / or units stored in the memory 1402, and calling data stored in the memory 1402, the processor 1401 executes various functions of the electronic device 1400 and processes data, thereby monitoring the electronic device 1400 as a whole. The processor 1401 can be a central processing unit CPU, a graphics processing unit GPU, a network processor (Network Processor, NP), etc., and can implement or execute the various methods, steps and logic block diagrams disclosed in the embodiments of the present application.
[0168] In the embodiment of the present application, the processor 1401 in the electronic device 1400 will load instructions corresponding to the processes of one or more application programs into the memory 1402 according to the following steps, and the processor 1401 will run the application programs stored in the memory 1402 to implement various functions, such as:
[0169] Get the target model of raindrops to be rendered and the raindrop texture map;
[0170] Obtaining the environment parameters of the virtual scene and the camera motion parameters of the virtual camera;
[0171] The position and posture of the target model are adjusted according to the environmental parameters and the camera motion parameters, so that the center position of the target model coincides with the position of the virtual camera;
[0172] Based on the raindrop texture map, raindrops are rendered on the target model.
[0173] Therefore, the electronic device 1400 provided in this embodiment can bring the following technical effects: improving the efficiency of rendering rainfall effects.
[0174] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0175] Optional, such as Fig.14 As shown, the electronic device 1400 further includes: a touch screen 1403, a radio frequency circuit 1404, an audio circuit 1405, an input unit 1406, and a power supply 1407. The processor 1401 is electrically connected to the touch screen 1403, the radio frequency circuit 1404, the audio circuit 1405, the input unit 1406, and the power supply 1407, respectively. Those skilled in the art can understand that Fig.14 The electronic device structure shown in the figure does not constitute a limitation of the electronic device, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.
[0176] The touch display screen 1403 can be used to display a graphical user interface and receive operation instructions generated by the user acting on the graphical user interface. The touch display screen 1403 may include a display panel and a touch panel. Among them, the display panel may be used to display information input by the user or information provided to the user and various graphical user interfaces of the electronic device, and these graphical user interfaces may be composed of graphics, text, icons, videos and any combination thereof. Optionally, the display panel may be configured in the form of a liquid crystal display (LCD, Liquid Crystal Display), an organic light emitting diode (OLED, Organic Light-EmittingDiode) and the like. The touch panel may be used to collect the user's touch operation on or near it (such as the user using any suitable object or attachment such as a finger, a stylus, etc. on the touch panel or near the touch panel), and generate corresponding operation instructions, and the operation instructions execute corresponding programs. Optionally, the touch panel may include two parts, a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch orientation, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into the touch point coordinates, and then sends it to the processor 1401, and can receive the command sent by the processor 1401 and execute it. The touch panel can cover the display panel. When the touch panel detects a touch operation on or near it, it is transmitted to the processor 1401 to determine the type of touch event, and then the processor 1401 provides a corresponding visual output on the display panel according to the type of touch event. In an embodiment of the present application, the touch panel and the display panel can be integrated into the touch display screen 1403 to realize the input and output functions. However, in some embodiments, the touch panel and the touch panel can be used as two independent components to realize the input and output functions. That is, the touch display screen 1403 can also be used as a part of the input unit 1406 to realize the input function.
[0177] The radio frequency circuit 1404 may be used to send and receive radio frequency signals, so as to establish wireless communication with a network device or other electronic devices through wireless communication, and to send and receive signals between the network device or other electronic devices.
[0178] The audio circuit 1405 can be used to provide an audio interface between the user and the electronic device through a speaker and a microphone. The audio circuit 1405 can transmit the electrical signal converted from the received audio data to the speaker, which is converted into a sound signal for output; on the other hand, the microphone converts the collected sound signal into an electrical signal, which is received by the audio circuit 1405 and converted into audio data, and then the audio data is output to the processor 1401 for processing, and then sent to another electronic device through the radio frequency circuit 1404, or the audio data is output to the memory 1402 for further processing. The audio circuit 1405 may also include an earplug jack to provide communication between an external headset and an electronic device.
[0179] The input unit 1406 may be used to receive input numbers, character information or user feature information (such as fingerprint, iris, facial information, etc.), and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.
[0180] The power supply 1407 is used to supply power to various components of the electronic device 1400. Optionally, the power supply 1407 can be logically connected to the processor 1401 through a power management system, so that the power management system can manage charging, discharging, and power consumption. The power supply 1407 can also include one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, power status indicators, and other arbitrary components.
[0181] although Fig.14 Not shown, the electronic device 1400 may also include a camera, a sensor, a wireless fidelity module, a Bluetooth module, etc., which will not be described in detail here.
[0182] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0183] A person of ordinary skill in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.
[0184] To this end, an embodiment of the present application provides a computer-readable storage medium, in which multiple computer programs are stored, and the computer program can be loaded by a processor to execute any model rendering method provided in the embodiment of the present application. The computer program can execute the following steps of the model rendering method:
[0185] Get the target model of raindrops to be rendered and the raindrop texture map;
[0186] Obtaining the environment parameters of the virtual scene and the camera motion parameters of the virtual camera;
[0187] Adjusting the position and posture of the target model according to the environmental parameters and the camera motion parameters, so that the center position of the target model coincides with the position of the virtual camera;
[0188] Based on the raindrop texture map, raindrops are rendered on the target model.
[0189] It can be seen that the computer program can be loaded by the processor to execute any model rendering method provided in the embodiments of the present application, thereby bringing the following technical effects: improving the efficiency of rendering rainfall effects.
[0190] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0191] The computer-readable storage medium may include: a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0192] Since the computer program stored in the computer-readable storage medium can execute any one of the model rendering methods provided in the embodiments of the present application, the beneficial effects that can be achieved by any one of the model rendering methods provided in the embodiments of the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.
[0193] According to one aspect of the present application, a computer program product or a computer program is also provided, the computer program product or the computer program including computer instructions, the computer instructions being stored in a computer-readable storage medium. A processor of an electronic device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the electronic device executes the methods provided in various optional implementations of the above embodiments.
[0194] In the above-mentioned model rendering device, computer-readable storage medium, electronic device, and computer program product embodiments, the description of each embodiment has its own emphasis. For parts not described in detail in a certain embodiment, reference can be made to the relevant description of other embodiments. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working process and beneficial effects of the above-described model rendering device, computer-readable storage medium, computer program product, electronic device, and its corresponding units can refer to the description of the model rendering method in the above embodiment, and will not be repeated here.
[0195] The above is a detailed introduction to a model rendering method, device, electronic device, computer-readable storage medium and computer program product provided in the embodiments of the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for technical personnel in this field, according to the ideas of the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A model rendering method, characterized in that: The method comprises: Get the target model of raindrops to be rendered and the raindrop texture map; Obtaining the environment parameters of the virtual scene and the camera motion parameters of the virtual camera; Adjusting the position and posture of the target model according to the environmental parameters and the camera motion parameters, so that the center position of the target model coincides with the position of the virtual camera; Raindrops are rendered on the target model based on the raindrop texture map.
2. The model rendering method according to claim 1, characterized in that: The step of rendering raindrops on the target model based on the raindrop texture map comprises: Obtaining target sampling positions of each sampling point of the target model in the raindrop texture map; Based on the target sampling position of each sampling point, sampling is performed in the raindrop texture map to obtain a texture sampling result of each sampling point; Based on the texture sampling results of each sampling point, raindrops are rendered on the target model.
3. The model rendering method according to claim 2, characterized in that: The step of obtaining target sampling positions of sampling points of the target model in the raindrop texture map includes: Acquire a time parameter, and determine a position offset of each sampling point based on the time parameter; Obtain the historical sampling position of each sampling point in the raindrop texture map; Based on the historical sampling positions of the sampling points and the position offsets, a target sampling position of each sampling point is determined.
4. The model rendering method according to claim 2, characterized in that: The raindrop texture map includes at least two texture channels, and different texture channels store raindrop texture information of different densities. The raindrops are rendered on the target model based on the texture sampling results of each sampling point, including: Based on the texture sampling results of each sampling point in the texture channel, raindrops are rendered on the target model.
5. The model rendering method according to claim 4, characterized in that: Each texture channel corresponds to a scene depth value, and the method of rendering raindrops on the target model based on the texture sampling results of each sampling point in the texture channel includes: Determining the target transparency of each sampling point based on the scene depth value of the texture channel; Raindrops are rendered on the target model based on the texture sampling results of the sampling points in the texture channel and the target transparency of the sampling points.
6. The model rendering method according to claim 5, characterized in that: The raindrop texture information includes grayscale values of a plurality of raindrops, and the grayscale values of at least two raindrops are different. The determining the target transparency of each sampling point based on the scene depth value of the texture channel includes: Determine a depth indication parameter of each sampling point based on the scene depth value of the texture channel and / or the grayscale value of each sampling point in the texture channel, wherein the depth indication parameter is used to indicate the depth of the sampling point; The object transparency of each sampling point is determined based on the depth indication parameter of each sampling point.
7. The model rendering method according to claim 6, characterized in that: The determining the target transparency of each sampling point based on the depth indication parameter of each sampling point includes: Determining an initial transparency corresponding to the scene depth of the texture channel; Based on the depth indication parameters of each sampling point, the initial transparency is updated respectively to obtain the target transparency of each sampling point.
8. The model rendering method according to claim 6, characterized in that: Also includes: Obtaining the shooting direction and camera position of the virtual camera; Determining the sampling point height of each sampling point in the virtual scene based on the depth indication parameter of each sampling point, the shooting direction and the camera position; Obtaining an object height of a virtual object in the virtual scene; Based on the sampling point height of each sampling point and the object height, an occlusion culling operation is performed on some of the sampling points.
9. The model rendering method according to claim 6, characterized in that: Before rendering raindrops on the target model based on the texture sampling results of each sampling point, the method further includes: Get the preset raindrop density parameters; Determine a first difference between the grayscale value of each sampling point and the raindrop density parameter, and map the first difference into a preset range to obtain a mapped parameter of each sampling point; Based on the mapped parameters of each sampling point and the raindrop density parameter, a target grayscale value of each sampling point is determined.
10. The model rendering method according to claim 9, characterized in that: The preset range includes 0 to 1, and the determining the target grayscale value of each sampling point based on the mapped parameters of each sampling point and the raindrop density parameter includes: Calculate a second difference between 1 and the raindrop density parameter; The ratio between the mapped parameter of each sampling point and the second difference is calculated, and the ratio corresponding to each sampling point is used as the target grayscale value of each sampling point.
11. The model rendering method according to claim 1, characterized in that: The environmental parameter includes a wind vector, the camera motion parameter includes a camera acceleration vector, and adjusting the position and posture of the target model according to the environmental parameter and the camera motion parameter includes: Determining a rotation angle of the target model based on the wind vector and the camera acceleration vector; The target model is rotated based on the rotation angle of the target model.
12. The model rendering method according to any one of claims 1 to 11, characterized in that: The target model includes a double cone model.
13. A model rendering device, characterized in that: The device comprises: A model acquisition module is used to obtain a target model of raindrops to be rendered and a raindrop texture map; A parameter acquisition module is used to obtain the environment parameters of the virtual scene and the camera motion parameters of the virtual camera; A posture adjustment module, used to adjust the posture of the target model according to the environmental parameters and the camera motion parameters, so that the center position of the target model coincides with the position of the virtual camera; A rendering module is used to render raindrops on the target model based on the raindrop texture map.
14. An electronic device, characterized in that: It comprises a processor and a memory, wherein the memory stores a plurality of instructions; the processor loads instructions from the memory to execute the steps of the model rendering method according to any one of claims 1 to 12.
15. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor to execute the steps of the model rendering method according to any one of claims 1 to 12.
Citation Information
Cited By
Flood discharge atomization rainfall distribution calculation method using nappe parameters
CN121186892A