Model processing method and device, storage medium and electronic equipment

By obtaining the mirror model in a virtual scene and using its normal direction information for rendering, the problem of difficult to simulate the haha ​​mirror distortion effect in the prior art is solved, and real mirror deformation effect and efficient model processing are achieved.

CN119850845AActive Publication Date: 2025-04-18NETEASE (HANGZHOU) NETWORK CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202411967836.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-30
Publication Date
2025-04-18
Estimated Expiration
2044-12-30

AI Technical Summary

Technical Problem

The existing model processing methods are difficult to truly simulate the distortion deformation effect of Haha mirror, resulting in poor model processing efficiency.

Method used

By obtaining the mirror model in the virtual scene, using the normal direction information of the mirror model to determine the sampling coordinates of the vertex in the rendered texture, and sampling the rendered texture based on these coordinates to obtain the target color value, and finally display the mirror image with deformation effect on the mirror model.

Benefits of technology

It realizes the mirror deformation effect of the Haha mirror in a virtual scene and improves the flexibility and efficiency of model processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119850845A_ABST
    Figure CN119850845A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a model processing method and device, a storage medium and electronic equipment. A mirror surface model in a virtual scene is obtained, the surface of the mirror surface model is uneven, and the normal directions of different vertexes of the mirror surface model are not completely the same; shooting a virtual scene picture needing to be reflected by the mirror surface model through a mirror camera corresponding to the mirror surface model, and taking the virtual scene picture as a rendering texture of the mirror surface model; based on normal direction information of each vertex of the mirror surface model, determining sampling coordinates of the vertexes in the rendering texture; sampling the rendering texture based on the sampling coordinates to obtain a target color value corresponding to the vertex; and rendering the mirror surface model based on the target color value of each vertex so as to display a mirror image with a deformation effect on the mirror surface model. Therefore, the distortion effect of mirror surface model imaging can be flexibly controlled, the mirror surface deformation effect of the distorting mirror can be truly and accurately simulated in a virtual scene, and the processing efficiency of the model is effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a model processing method, device, storage medium and electronic device. Background Art

[0002] With the rapid development of life and technology, people often use game applications for entertainment. In some games, it is often necessary to create some special effects, for example, to achieve the special effects of a funhouse mirror in the game. How to truly restore the distortion effect of a funhouse mirror in reality in the game is a big problem. The existing model processing methods often disturb the image by directly superimposing the disturbance map on the image, or change the image by controlling the local enlargement or reduction of the model UV to achieve the distortion effect of a funhouse mirror.

[0003] However, the existing model processing methods are difficult to control the distortion effect of model imaging and cannot truly simulate the funhouse mirror effect, resulting in poor model processing efficiency. Summary of the invention

[0004] The embodiments of the present application provide a model processing method, device, storage medium and electronic device, which can flexibly control the distortion deformation effect of mirror model imaging, realize a realistic and accurate simulation of the mirror deformation effect of a funhouse mirror in a virtual scene, and effectively improve the processing efficiency of the model.

[0005] The present application embodiment provides a model processing method, including:

[0006] Acquire a mirror model in a virtual scene, wherein the surface of the mirror model is uneven, and normal directions of different vertices of the mirror model are not completely the same;

[0007] Using a mirror camera corresponding to the mirror model, shooting a virtual scene image that the mirror model needs to reflect as a rendering texture of the mirror model;

[0008] Determining the sampling coordinates of each vertex in the rendering texture based on the normal direction information of each vertex of the mirror model;

[0009] Sampling the rendering texture based on the sampling coordinates to obtain a target color value corresponding to the vertex;

[0010] The mirror model is rendered based on the target color value of each of the vertices to display a mirror image with a deformation effect on the mirror model.

[0011] Accordingly, an embodiment of the present application provides a model processing device, including:

[0012] An acquisition unit, used for acquiring a mirror model in a virtual scene, wherein the surface of the mirror model is uneven, and the normal directions of different vertices of the mirror model are not completely the same;

[0013] A shooting unit, used for shooting a virtual scene image to be reflected by the mirror model through a mirror camera corresponding to the mirror model as a rendering texture of the mirror model;

[0014] A determination unit, configured to determine, based on normal direction information of each vertex of the mirror model, a sampling coordinate of the vertex in the rendering texture;

[0015] A sampling unit, used for sampling the rendering texture based on the sampling coordinates to obtain a target color value corresponding to the vertex;

[0016] A rendering unit is used to render the mirror model based on the target color value of each of the vertices to display a mirror image with a deformation effect on the mirror model.

[0017] In addition, an embodiment of the present application also provides a computer-readable storage medium, which stores a computer program, and the computer program is suitable for loading by a processor to execute the steps in any model processing method provided in the embodiment of the present application.

[0018] In addition, an embodiment of the present application also provides an electronic device, including a processor and a memory, wherein the memory stores an application program, and the processor is used to run the application program in the memory to implement the model processing method provided in the embodiment of the present application.

[0019] An embodiment of the present application also provides a computer program product, which includes a computer program, and the computer program is stored in a computer-readable storage medium; when a processor of an electronic device reads the computer program from the computer-readable storage medium, the processor executes the computer program, so that the electronic device performs the steps in the model processing method provided in the embodiment of the present application.

[0020] The embodiment of the present application obtains a mirror model in a virtual scene, where the surface of the mirror model is uneven, and the normal directions of different vertices of the mirror model are not exactly the same; a mirror camera corresponding to the mirror model is used to shoot a virtual scene image that the mirror model needs to reflect, as a rendering texture of the mirror model; based on the normal direction information of each vertex of the mirror model, the sampling coordinates of the vertex in the rendering texture are determined; the rendering texture is sampled based on the sampling coordinates to obtain a target color value corresponding to the vertex; and the mirror model is rendered based on the target color value of each vertex to display a mirror image with a deformation effect on the mirror model. In this way, by adjusting the curvature and normal direction of the mirror model based on the required deformation effect, the sampling coordinates of the vertices in the rendering texture are determined according to the normal direction information of the vertices of the mirror model, and the rendering texture is sampled based on the sampling coordinates, and the mirror model is rendered based on the target color values ​​of each sampled vertex. A mirror image with a deformation effect can be displayed on the mirror model, and the distortion deformation effect of the model imaging can be flexibly controlled, so as to realize a realistic and accurate simulation of the mirror deformation effect of a funhouse mirror in a virtual scene, thereby further improving the processing efficiency of the model. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] 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.

[0022] Figure 1 It is a schematic diagram of an implementation scenario of a model processing method provided in an embodiment of the present application;

[0023] Figure 2 It is a flow chart of a model processing method provided in an embodiment of the present application;

[0024] Figure 3a is a model processing schematic diagram of a model processing method provided in an embodiment of the present application;

[0025] Figure 3b is another model processing schematic diagram of a model processing method provided in an embodiment of the present application;

[0026] Figure 3c is another model processing schematic diagram of a model processing method provided in an embodiment of the present application;

[0027] Figure 3d is another model processing schematic diagram of a model processing method provided in an embodiment of the present application;

[0028] Figure 4aIt is a mirror image schematic diagram of a model processing method provided in an embodiment of the present application;

[0029] Figure 4b is another mirror image schematic diagram of a model processing method provided in an embodiment of the present application;

[0030] Figure 4c is a schematic diagram of mirror imaging of a model processing method provided in an embodiment of the present application;

[0031] Figure 5 is a structural schematic diagram of a model processing device provided in an embodiment of the present application;

[0032] Figure 6 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0033] 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, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application.

[0034] The embodiment of the present application provides a model processing method, device, storage medium and electronic device. The model processing device can be integrated in an electronic device, which can be a server, a terminal or other device.

[0035] Among them, the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, network acceleration services (Content Delivery Network, CDN), and basic cloud computing services such as big data and artificial intelligence platforms. Terminals may include but are not limited to mobile phones, computers, intelligent voice interaction devices, smart home appliances, vehicle-mounted terminals, aircraft, etc. Terminals and servers can be directly or indirectly connected via wired or wireless communications, and this application does not limit this.

[0036] See also Figure 1 , taking the integration of the model processing device into an electronic device as an example, Figure 1A schematic diagram of an implementation scenario of the model processing method provided in an embodiment of the present application, wherein the electronic device can be a terminal or a server, and the electronic device can obtain a mirror model in a virtual scene, the surface of the mirror model is uneven, and the normal directions of different vertices of the mirror model are not completely the same; a virtual scene image that the mirror model needs to reflect is photographed by a mirror camera corresponding to the mirror model, as a rendering texture of the mirror model; based on the normal direction information of each vertex of the mirror model, the sampling coordinates of the vertex in the rendering texture are determined; the rendering texture is sampled based on the sampling coordinates to obtain a target color value corresponding to the vertex; the mirror model is rendered based on the target color value of each vertex to display a mirror image with a deformation effect on the mirror model.

[0037] It should be noted that Figure 1 The implementation environment scenario diagram of the model processing method shown is only an example. The implementation environment scenario of the model processing method described in the embodiment of the present application is to more clearly illustrate the technical solution of the embodiment of the present application, and does not constitute a limitation on the technical solution provided by the embodiment of the present application. It is known to those skilled in the art that with the evolution of data processing and the emergence of new business scenarios, the technical solution provided by the present application is also applicable to similar technical problems.

[0038] The solutions provided by the embodiments of the present application are specifically described by the following embodiments. It should be noted that the description order of the following embodiments is not intended to limit the preferred order of the embodiments.

[0039] This embodiment will be described from the perspective of a model processing device. The model processing device may be integrated into an electronic device. The electronic device may be a terminal and / or a server, and this application does not limit this.

[0040] See also Figure 2 , Figure 2 : is a flow chart of the model processing method provided in the embodiment of the present application. The model processing method includes:

[0041] In step 101, a mirror model in a virtual scene is obtained.

[0042] The surface of the mirror model is uneven, and the normal directions of different vertices of the mirror model may not be completely the same.

[0043] The virtual scene may be a scene composed of virtual elements, and the virtual scene may be a simulation environment of the real world, or a semi-simulation and semi-fictitious virtual environment, or a purely fictitious virtual environment, etc. For example, the virtual scene may be a game scene. The mirror model may be a model for realizing the mirror effect of a mirror, and the surface of the mirror model may be bent according to the desired deformation effect, thereby obtaining a mirror model with an uneven surface. At the same time, the normal direction of the vertex of the mirror model may be adjusted according to the desired deformation effect, so that the normal directions of different vertices of the mirror model may not be completely the same.

[0044] Among them, there are many ways to obtain the mirror model in the virtual scene. For example, a single-sided model can be made in advance. For example, various 3D modeling software can be used to make a single-sided model to simulate a flat mirror. Then, the distorted shape of the mirror surface of a funhouse mirror with various deformation effects in reality can be referred to. According to the required deformation effect (convex surface reduction, concave surface enlargement), the surface curvature and normal direction of the single-sided model can be changed in the 3D modeling software. For example, the normal direction of the model can be adjusted by adding lines, subtracting lines, adjusting points, lines and surfaces, expansion, free deformation (Free-Form Deformation, FFD for short), smoothing and other operations to produce a mirror model that realizes different combinations of deformation effects.

[0045] For example, see Figure 3a It is a model processing schematic diagram of a model processing method provided in an embodiment of the present application. The curvature of the mirror model can be changed according to the mirror imaging deformation effect to be achieved, thereby obtaining various uneven mirror models.

[0046] Optionally, there are multiple ways to adjust the normal direction of the vertices of the mirror model. For example, when the curvature of the model is changed according to the desired deformation effect, the normal direction of the model surface of the model can be automatically changed through the three-dimensional modeling software. The normal direction of the mirror model can also be manually adjusted according to the desired deformation effect, thereby achieving a more realistic mirror imaging deformation effect.

[0047] For example, see Figure 3b , Figure 3bIt is another model processing schematic diagram of a model processing method provided by an embodiment of the present application. The normal direction of the surface vertex of the mirror model can be adjusted according to the deformation effect to be achieved, so as to achieve a more realistic mirror imaging deformation effect. Specifically, for the position where the display effect is not satisfactory, the normal direction can be manually modified to control the final imaging effect of the mirror model. For example, the normal direction of the vertex of the mirror model is adjusted downward, so that the color corresponding to the vertex becomes higher in the final imaging performance, and the normal direction of the vertex of the mirror model is adjusted upward, so that the color corresponding to the vertex becomes shorter in the final imaging performance, and the normal direction of the vertex of the mirror model is adjusted to the left, so that the vertex is offset to the right in the final imaging performance, and the normal direction of the vertex of the mirror model is adjusted to the right, so that the vertex is offset to the left in the final imaging performance, etc. In this way, the mirror imaging effect of the mirror model can be corrected or changed by adjusting the normal direction of different vertices of the mirror model, so that various required mirror imaging deformation effects can be achieved, and the distortion deformation effect of the imaging of the mirror model can be flexibly controlled.

[0048] In one embodiment, please refer to Figure 3c , Figure 3c This is another model processing schematic diagram of a model processing method provided in an embodiment of the present application. A mirror model adjusted based on the mirror imaging deformation effect to be achieved can be synthesized with a mirror model, so that a mirror-shaped model can be constructed in a virtual scene to achieve a mirror effect in the virtual scene.

[0049] In step 102, a mirror camera corresponding to the mirror model is used to shoot a virtual scene image that the mirror model needs to reflect as a rendering texture of the mirror model.

[0050] Among them, the mirror camera can be a virtual camera for realizing the mirror reflection effect, the virtual scene picture can be a picture taken by the mirror camera in the virtual scene, the rendering texture can be a texture rendered by the mirror camera, and can be a rendering texture (RenderTexture, RT for short) map of the virtual scene picture, which can be used as the mirror reflection effect of the mirror model.

[0051] Optionally, the position of the mirror camera in the virtual scene can be the position where the mirror model is located, or can be a position around the mirror model. The position setting can be set according to actual needs, and the embodiment of the present application is not limited here.

[0052] Among them, the virtual scene picture that the mirror model needs to reflect is photographed by the mirror camera corresponding to the mirror model. There can be many ways to use it as the rendering texture of the mirror model. For example, the virtual object to be displayed in the mirror image of the mirror model in the virtual scene can be determined; the target distance between the virtual object and the mirror model can be obtained; the virtual object is photographed based on the target distance through the mirror camera corresponding to the mirror model, and the virtual scene picture containing the virtual object is obtained as the rendering texture of the mirror model.

[0053] The virtual object may be an object in a virtual scene, which may be used to be reflected on the mirror model. For example, the virtual object may include game characters, animals, trees, flowers, stones, etc. in the virtual scene. The target distance may be the distance between the virtual object and the mirror model.

[0054] There are many ways to determine the virtual object to be displayed in the mirror image of the mirror model in the virtual scene. For example, object information of the virtual object that can be displayed in the mirror image of the mirror model can be obtained; the position of the candidate virtual object that matches the object information in the virtual scene is obtained; when the position of the candidate virtual object is within the imaging range of the mirror model, the candidate virtual object is determined to be the virtual object to be displayed in the mirror image of the mirror model.

[0055] The object information may be information indicating a virtual object that can be displayed in the mirror image of the mirror model, for example, it may include the name of the virtual object, an identification number (ID), a material, an object type, a label, and other information. The candidate virtual object may be a virtual object that matches the object information in the virtual scene, for example, when the object information is named "Smart Puppy" and "Big Tree Model", the candidate virtual object may be a virtual object named "Smart Puppy" and "Big Tree Model". The imaging range may refer to an area formed by positions that can be reflected by the mirror model, that is, objects within the imaging range may be reflected in the mirror imaging of the mirror model.

[0056] In one embodiment, a mirror component can be set through a game engine according to the position and orientation of a mirror model in a virtual scene. The function of the mirror component can be to create a mirror camera. Through the mirror camera, based on the position and the configured orientation, a virtual scene image in the virtual scene can be captured in real time, so that the captured virtual scene image can be stored in an RT map to obtain a rendering texture corresponding to the mirror model. Then, the RT map, that is, the rendering texture corresponding to the mirror model, can be obtained through the corresponding keyword variable (uniform) semantics in the shader.

[0057] In step 103, based on the normal direction information of each vertex of the mirror model, the sampling coordinates of the vertex in the rendering texture are determined.

[0058] Among them, the normal direction information can be information indicating the normal direction of the vertex of the mirror model, and the sampling coordinates can be UV coordinates used for texture sampling, which can be used to sample the rendering texture of the mirror model, thereby mapping a mirror image with a deformation effect corresponding to the virtual scene picture.

[0059] The UV coordinates may be coordinates in a two-dimensional coordinate system, and are used to map the texture map to the surface of the three-dimensional model, and U and V may represent the horizontal and vertical coordinate axes, respectively. The UV coordinates may define the position information of each point on the texture map, and these points are interconnected with the three-dimensional model to achieve the correspondence of each point on the texture map to the surface of the model, so that sampling can be performed in the texture map according to the UV coordinates, and the sampled pixel values ​​can be mapped to the corresponding positions on the surface of the model to achieve tiling the texture map on the surface of the three-dimensional model.

[0060] Among them, there are many ways to determine the sampling coordinates of the vertex in the rendered texture based on the normal direction information of each vertex of the mirror model. For example, the screen space coordinates corresponding to the vertex in the mirror model can be calculated; based on the screen space coordinates, the initial sampling coordinates corresponding to the vertex in the rendered texture are calculated; based on the normal direction information of the vertex on the mirror model, the first sampling offset value corresponding to the vertex is determined; based on the first sampling offset value, the initial sampling coordinates of the vertex are offset to obtain the sampling coordinates corresponding to the vertex in the rendered texture.

[0061] Among them, the screen space coordinates can be the coordinates of the vertices of the mirror model in the screen space, and the initial sampling coordinates can be the UV coordinates for sampling the rendering texture when the deformation effect is not considered. At this time, if the rendering texture is sampled and mapped according to the initial sampling coordinates, the obtained mirror effect is the effect of plane reflection, that is, the virtual scene screen is not deformed. The first sampling offset value can be an offset value for offsetting the initial sampling coordinates. If the rendering texture is texture mapped using the sampling coordinates offset based on the first sampling offset value, a mirror effect corresponding to the virtual scene screen can be obtained after deformation based on the normal direction of each vertex in the mirror model.

[0062] There are many ways to calculate the initial sampling coordinates of the vertex in the rendering texture based on the screen space coordinates. For example, the screen space coordinates of the vertex of the mirror model can be converted to texture coordinates (UV) to obtain the initial sampling coordinates of the vertex in the rendering texture. Since the range of screen space coordinates is [-1,1], and the range of texture coordinates is [0,1], scaling and offset are required to convert the screen space coordinates of the vertex of the mirror model to the initial sampling coordinates corresponding to the rendering texture.

[0063] Optionally, the screen space coordinates of the vertices of the mirror model can be converted to the initial sampling coordinates corresponding to the rendering texture using the following formula:

[0064] screen_uv=pscreen.xy*0.5f+float2(0.5f)

[0065] Among them, screen_uv can be expressed as the initial sampling coordinates, and pscreen.xy can be expressed as the screen space coordinates of the vertices of the mirror model. This formula is used to convert the screen space coordinates of the vertices into texture coordinates. The screen space coordinates are usually the normalized device coordinates (NDC) obtained by perspective division of the clip space coordinates of the vertices. Since the range of the x and y coordinates of the screen space coordinates are both [-1,1], and in NDC, [-1,-1] represents the lower left corner of the screen, and [1,1] represents the upper right corner of the screen. pscreen.xy*0.5f can be used to scale the range of the screen space coordinates of the vertex from [-1,1] to [-0.5,0.5]. Then, by adding float2(0.5f), the range of [-0.5,0.5] can be translated to [0,1]. In this way, the screen space coordinates of the vertices of the mirror model can be converted to the initial sampling coordinates corresponding to the rendered texture.

[0066] Among them, there can be multiple ways to determine the first sampling offset value corresponding to the vertex based on the normal direction information of the vertex on the mirror model. For example, based on the normal direction information of the vertex on the mirror model, the projection component of the normal vector of the vertex on the xy plane in the virtual scene can be calculated as the first sampling offset value corresponding to the vertex.

[0067] Among them, based on the first sampling offset value, the initial sampling coordinates of the vertex are offset, and there are many ways to obtain the sampling coordinates corresponding to the vertex in the rendering texture. For example, the initial sampling coordinates corresponding to the vertex can be added to the projection component of the normal vector of the vertex on the xy plane in the virtual scene to obtain the sampling coordinates corresponding to the vertex in the rendering texture.

[0068] Optionally, the distortion degree of the deformation effect based on the normal direction of the mirror model can be further adjusted by setting a first distortion parameter (turb_slide). The first distortion parameter can be a parameter opened by the shader, which can be used to change the distortion degree of the imaging caused by the normal direction of the model. The distortion degree is the size of the offset of the rendering texture. The greater the distortion degree, the greater the sampling offset value, and the more exaggerated the deformation effect of the imaging of the mirror model. The smaller the distortion degree, the smaller the sampling offset value of the rendering texture, so that the imaging of the mirror model is closer to an ordinary plane mirror.

[0069] Optionally, before determining the first sampling offset value corresponding to the vertex based on the normal direction information of the vertex on the mirror model, a first distortion parameter corresponding to the mirror model may be determined;

[0070] Correspondingly, the step of determining the first sampling offset value corresponding to the vertex based on the normal direction information of the vertex on the mirror model may include: determining the basic sampling offset value based on the normal direction information of the vertex on the mirror model; calculating the product of the first distortion parameter and the basic sampling offset value of the vertex to obtain the first sampling offset value corresponding to the vertex.

[0071] The basic sampling offset value may be a sampling offset value determined according to normal direction information of the vertex in the mirror model.

[0072] There are many ways to determine the basic sampling offset value based on the normal direction information of the vertex in the mirror model. For example, the projection component of the normal vector of the vertex on the plane parallel to the orientation of the mirror model in the virtual scene can be calculated according to the orientation of the mirror model to obtain the basic sampling offset value. For example, assuming that the mirror model is placed vertically in the virtual scene and the orientation of the mirror model is horizontal, the projection component of the normal vector of the vertex on the xy plane in the virtual scene can be calculated based on the normal direction information of the vertex on the mirror model to obtain the basic sampling offset value of the vertex.

[0073] In one embodiment, the following pseudo code may be used to calculate the screen space coordinates corresponding to the vertex in the mirror model, calculate the initial sampling coordinates corresponding to the vertex in the rendering texture based on the screen space coordinates, determine the first distortion parameter corresponding to the mirror model, determine the basic sampling offset value based on the normal direction information of the vertex in the mirror model, calculate the product of the first distortion parameter and the basic sampling offset value of the vertex to obtain the first sampling offset value corresponding to the vertex, and offset the initial sampling coordinates of the vertex based on the first sampling offset value to obtain the sampling coordinates corresponding to the vertex in the rendering texture:

[0074]

[0075] Optionally, in order to more accurately obtain a mirror image with a deformation effect based on the normal direction and concave-convex shape of the mirror model, a sampling offset value can be determined according to the concave-convex shape of the mirror model, so as to obtain a more accurate sampling coordinate, in order to obtain a mirror image that is more in line with the deformation effect brought about by the curvature of the mirror model.

[0076] The model processing method provided in the embodiment of the present application is to offset the sampling coordinates of the rendering texture captured by the camera according to the concave-convex shape and normal direction of the mirror model, so as to distort the rendering texture based on the offset sampling coordinates, thereby producing a mirror deformation effect such as a funhouse mirror. In order to more accurately offset the sampling coordinates of the rendering texture captured by the camera according to the concave-convex shape of the mirror model, it is necessary to calculate how much and how to distort the rendering texture according to the concave-convex shape of the mirror model. Specifically, a basis for judging the degree of distortion of the rendering texture can be generated according to the concave-convex shape of the model, the distance from each vertex (or pixel) of the mirror model to the observation camera, and the distance between the position of the object in the reflected mirror on the mirror model and the observation camera when the mirror model is assumed to be a plane. According to the laws of the physical world, a funhouse mirror will only produce horizontal distortion (for example, the character is stretched) or vertical distortion (for example, the character becomes taller), so it can be divided into horizontal and vertical directions for calculation to obtain the sampling offset value in the corresponding direction, so as to more accurately distort the rendering texture in accordance with the concave-convex shape of the mirror model, thereby producing a more realistic mirror deformation effect.

[0077] Specifically, the virtual scene screen may include virtual objects, so that the first distance between the vertex of the mirror model and the observation camera corresponding to the mirror model in the target direction can be obtained; the corresponding position of the virtual object on the plane in the mirror model is determined, and the second distance between the virtual object and the observation camera in the target direction is calculated based on the position; based on the first distance and the second distance of the vertex in the target direction, the second distortion parameter corresponding to the vertex in the target direction is determined; based on the second distortion parameter corresponding to the vertex in each target direction and the first distance, the second sampling offset value of the vertex is determined.

[0078] Correspondingly, for the normal direction information of each vertex of the mirror model, the step of determining the sampling coordinates of the vertex in the rendered texture may include: determining the sampling coordinates of the vertex in the rendered texture based on the normal direction information of each vertex of the mirror model and the second sampling offset value.

[0079] Among them, the observation camera can be a camera corresponding to the player's perspective, for example, it can be a main camera. The target direction can include a horizontal direction and a vertical direction, and the first distance can be the distance between the vertex of the mirror model and the observation camera in the target direction, or it can be the distance between the pixel on the mirror model and the observation camera in the target direction. The position corresponding to the virtual object on the plane in the mirror model can be the position of the virtual object horizontally mapped to the plane of the mirror model, that is, the plane in the mirror model is the plane where the mirror model is located when it is a plane. The second distance can be the distance between the virtual object and the observation camera in the target direction. The second distortion parameter can be a parameter indicating the degree of mirror distortion of the mirror model, and the second sampling offset value can be an offset value for offsetting the sampling coordinates determined based on the second distortion parameter.

[0080] For example, see Figure 3d , Figure 3d This is another model processing schematic diagram of a model processing method provided in an embodiment of the present application. Taking the target direction as the horizontal direction as an example, the first distance is the horizontal distance between the position C of the observation camera and the vertex P of the mirror model in the horizontal direction, that is, the first distance Dis=(CP).rg, and the second distance is the position of the virtual object on the plane of the mirror model and the horizontal distance of the observation camera in the horizontal direction, that is, the second distance Dis2=(C-Obj).rg. For the first distance and the second distance in the vertical direction, a similar sampling method can be used for calculation to obtain the first distance Disb=(CP).b between the position C of the observation camera and the vertex P of the mirror model in the vertical direction, and the second distance Dis2b=(C-Obj).b between the position of the virtual object on the plane of the mirror model and the observation camera in the vertical direction. Among them, r, g, and b can be three channels in the RGB color channel, which can be used to store the second sampling offset value corresponding to the vertex, r can correspond to the x-axis, g can correspond to the y-axis, and b can correspond to the z-axis.

[0081] There are multiple ways to determine the second distortion parameter corresponding to the vertex in the target direction based on the first distance and the second distance of the vertex in the target direction. For example, the difference between the first distance and the second distance in the same target direction can be calculated, and the absolute value of the difference can be normalized to obtain the second distortion parameter corresponding to the vertex in the target direction.

[0082] For example, taking the target direction as the horizontal direction, the second distortion parameter corresponding to the vertex in the horizontal direction can be calculated using the following formula:

[0083] Normalize(Abs(Dis-Dis2))=Mh

[0084] Among them, Mh is the second distortion parameter of the vertex in the horizontal direction, Abs is to find the absolute value, and Normalize is the normalization function. Specifically, by calculating the absolute value of the difference between the two distances corresponding to the vertex, the concave and convex conditions of the mirror model at the vertex position can be obtained, so there is no need to consider the influence of the camera distance. Then, through normalization, the width of the funhouse mirror can be changed from 1 to 0. For example, please continue to refer to Figure 3d The more convex the vertex in the mirror model, the closer the second distortion parameter is to 1, which is closer to white, and the more concave the vertex is, the closer it is to 0, corresponding to black. In this way, the horizontal convex information of the mirror model can be obtained. It can be understood in the refraction environment that the whiter part is farther away from the final image, so the distortion is greater, and the darker part is closer, so the distortion is small. In this way, the absolute distance of each vertex relative to the observation camera can be obtained, so that the influence of the distance between the observation camera and the mirror model can be eliminated, so that the interference of the camera distance can be eliminated first, and the distortion of the mirror itself can be calculated.

[0085] Correspondingly, taking the target direction as the vertical direction as an example, the second distortion parameter corresponding to the vertex in the vertical direction can be calculated using the following formula:

[0086] Normalize(Abs(disb-dis2b))=Mv

[0087] Wherein, Mv is the second distortion parameter of the vertex in the vertical direction.

[0088] There are multiple ways to determine the second sampling offset value of the vertex based on the second distortion parameter and the first distance corresponding to the vertex in each target direction. For example, the second distortion parameter corresponding to each target direction can be mapped into a preset numerical range to obtain the mapped distortion parameter; the distortion adjustment coefficient corresponding to each target direction is obtained; based on the mapped distortion parameter, the first distance and the distortion adjustment coefficient of the vertex in each target direction, the second sampling offset value corresponding to the vertex in each target direction is calculated.

[0089] The preset value range may be a value range from -1 to 1. The distortion adjustment coefficient may be a parameter for controlling the degree of distortion based on the first distance. Since the first distance may affect the distortion of the mirror, a distortion adjustment coefficient (warp_factor) that can adjust the distortion effect of the mirror may be added to improve the presentation of the artistic effect. Physically, the closer the distance corresponding to the first distance is, the more distorted the mirror effect should be, and the farther the distance is, the smoother the mirror effect should be. Therefore, the distortion adjustment coefficient may be set in a linear decreasing manner.

[0090] In a specific embodiment, the following formula may be used to map the second distortion parameter corresponding to each target direction into a preset value range to obtain the mapped distortion parameter:

[0091] UVraw=({Mh,Mv}*2)-1

[0092] Among them, UVraw can be the mapped distortion parameters corresponding to each target direction. In order to obtain different distortion modes in the horizontal and vertical directions, the calculation is divided into two channels. Channel R corresponds to the information in the horizontal direction, and channel G corresponds to the information in the vertical direction. The reason for multiplying by 2 and then -1 here is that the range of the normalized second distortion parameter is 0-1. In order to make the coordinates of the offset coordinates become standard normal coordinates, that is, the range from -1 to 1, because the funhouse mirror may be positively distorted or negatively distorted, that is, getting fatter or thinner, 0 is definitely unchanged, so the coordinates must be changed to -1 to 1. In this way, the distortion parameters after mapping in the horizontal direction can be put into the R channel, and the distortion parameters after mapping in the vertical direction can be put into the G channel, and the offset information used to distort the UV coordinates can be obtained. In order to bring in the uv information, it is sufficient to sample the RG channel here, and there is no need for the B channel.

[0093] Correspondingly, the following formula can be used to calculate the second sampling offset value corresponding to the vertex in each target direction based on the mapped distortion parameter of the vertex in each target direction, the first distance, and the distortion adjustment coefficient:

[0094] UVwarp={UVraw.r*(Dis / warp_factor),UVraw.g*(Disb / warp_factor)}

[0095] Among them, UVwarp can be expressed as the sampling offset value in the horizontal and vertical directions, that is, the second sampling offset value in the U and V directions, warp_factor is the distortion adjustment coefficient, UVraw.r is the distortion parameter after mapping in the horizontal direction, and UVraw.g is the distortion parameter after mapping in the vertical direction. Since the distance between the observation camera and the mirror model will affect the distortion of the mirror, an adjustable distortion adjustment coefficient warp_factor can be added to improve the presentation of the artistic effect. After all, even if it is physically correct, it may not look good in reality. Physically speaking, the closer the distance, the more distorted the mirror imaging should be, and the farther the distance, the smoother the mirror imaging should be. Therefore, the specific value of the distortion adjustment coefficient warp_factor can be directly set by linear decrement. In this way, based on the influence of distance on distortion, the distance calculation between the camera and the vertex on the mirror model is considered back into the obtained mirror distortion information, and the accurate distortion of the virtual object can be obtained.

[0096] Among them, based on the normal direction information and the second sampling offset value of each vertex of the mirror model, there can be multiple ways to determine the sampling coordinates of the vertex in the rendered texture. For example, the first sampling offset value and the second sampling offset value corresponding to the normal direction information of each vertex of the mirror model and the initial sampling coordinates can be added to obtain the sampling coordinates of the vertex in the rendered texture.

[0097] For example, the following formula can be used to determine the sampling coordinates of the vertex in the rendering texture based on the normal direction information of each vertex of the mirror model and the second sampling offset value:

[0098] Output=RT sample(t_RT,UV.rg+texcoord.uv0+Normal.rg)

[0099] Among them, Output can be the target color value corresponding to the vertex obtained by sampling based on the final sampling coordinates, RTsample() can be a texture sampling function, t_RT can be represented as a rendering texture, UV.rg can be the second sampling offset value corresponding to the vertex, texcoord.uv0 can be represented as the initial sampling coordinates, and Normal.rg can be represented as the first sampling offset value. Optionally, texcoord.uv0+Normal.rg can also be the above-mentioned mirror_uv, so that the initial sampling coordinates can be offset according to the first sampling offset value and the second sampling offset value to obtain the final sampling coordinates of the vertex in the rendering texture.

[0100] In step 104, the rendering texture is sampled based on the sampling coordinates to obtain a target color value corresponding to the vertex.

[0101] The target color value may be a pixel value sampled in the rendering texture based on the sampling coordinates.

[0102] Optionally, parameters such as smoothness may be used to artistically process the color values ​​corresponding to the vertices of the mirror model to enhance the display effect of the mirror image corresponding to the mirror model.

[0103] In step 105, the mirror model is rendered based on the target color value of each vertex to display a mirror image with a deformation effect on the mirror model.

[0104] The deformation effect may include deformation effects such as stretching, compression, distortion, enlargement and reduction. The mirror image may be an image obtained by texture mapping based on sampling coordinates and rendering textures, that is, an image showing a mirror effect corresponding to the mirror model.

[0105] For example, see Figure 4a , Figure 4aThis is a mirror image schematic diagram of a model processing method provided in an embodiment of the present application. When a game character in a virtual scene is within the imaging range of a mirror model, a mirror image based on the reflection of the game character can be displayed in the mirror model. At the same time, the mirror image based on the reflection of the game character has a distorted mirror deformation effect based on the curvature and normal of the mirror model, thereby realizing a simulation of a funhouse mirror effect in a virtual scene.

[0106] For another example, please refer to Figure 4b , Figure 4b This is another mirror image schematic diagram of a model processing method provided by an embodiment of the present application. By adjusting the curvature and normal direction of the mirror model based on the different deformation effects to be achieved, the mirror image with different imaging deformation effects of the game character can be reflected on the mirror model. In this way, a physics-based algorithm can be implemented to achieve the display effect of a funhouse mirror, and the effects seen at different angles are different, with high playability, controllable and realistic mirror deformation effects, and effectively improving the efficiency of model processing.

[0107] In one embodiment, please refer to Figure 4c , Figure 4c This is a mirror imaging schematic diagram of a model processing method provided by an embodiment of the present application. According to the normal direction of the mirror model, the corresponding sampling offset value can be calculated, so that the sampling coordinates of the rendered texture can be offset according to the sampling offset value, so that texture mapping can be performed based on the offset sampling coordinates, and a mirror image of the game character after being stretched and deformed can be obtained, thereby realizing a funhouse mirror effect in a virtual scene. Among them, the camera position is the position of the observation camera, and the virtual object "little girl" can stand in front of the mirror model, so that the distorted and deformed mirror image corresponding to the little girl can be displayed in the mirror model. For example, by adjusting the normal direction of the lower vertex of the mirror model downward, the mirror image of the little girl's foot area can achieve a downward stretching effect, and by adjusting the normal direction of the upper vertex of the mirror model upward, the mirror image corresponding to the head area of ​​the little girl can achieve an upward stretching effect, thereby displaying the stretched and deformed mirror image corresponding to the little girl in the mirror model.

[0108] In some games, it is necessary to realize the funhouse mirror effect in the virtual scene to enhance the game experience of the players. How to truly restore the distortion and deformation effect of the funhouse mirror in reality in the game is a major problem. In the existing model processing methods, the imaging is often disturbed by directly superimposing the disturbance map on the imaging, or the imaging is changed by controlling the local enlargement or reduction of the model UV to realize the distortion and deformation effect of the funhouse mirror. However, the method of disturbing the imaging by directly superimposing the disturbance map on the imaging will also uniformly disturb the image when the virtual object is stationary, and the effect is uncontrollable, which is inconsistent with the performance of the funhouse mirror in reality, and it is impossible to perform complex imaging. The method of changing the imaging by controlling the local enlargement or reduction of the model UV is difficult to control the imaging stretching, and the adjustment effect needs to be repeatedly derived. The performance of the complex funhouse mirror effect is also unsatisfactory, and the real funhouse mirror performance cannot be simulated. The presented effect is also relatively fixed and lacks dynamic changes. It can be seen that the existing model processing method is difficult to control the distortion and deformation effect of the model imaging, and cannot truly simulate the displayed funhouse mirror effect, which makes the model processing efficiency poor.

[0109] To this end, the embodiment of the present application proposes a model processing method based on the realization principle of a funhouse mirror, which controls the normal direction of the mirror model surface to express different corresponding funhouse mirror performance effects, thereby realizing the deformation and distortion effect of the funhouse mirror based on a physical method, and basically realizing all funhouse mirror effects. Among them, the realization principle of the funhouse mirror mainly relies on the irregular light reflection and focusing of the curved mirror. The mirror surface of the funhouse mirror is not flat, some parts are convex mirrors, and some parts are concave mirrors, so some images are magnified and some are reduced. When the light passes through the curved surface, due to the different curvatures, different light rays will be scattered or focused, and an enlarged and distorted image will be presented at a place in the opposite direction of the mirror surface at an equal distance from the object and the mirror surface, thereby deforming or distorting the image of the object reflected by the curved mirror surface. Thus, the embodiment of the present application is based on the imaging principle of a simulated funhouse mirror based on physics, and adjusts the curvature and normal direction of the mirror model based on the desired deformation effect, thereby determining the sampling coordinates of the vertex in the rendered texture according to the normal direction information of the vertex of the mirror model, thereby sampling the rendered texture based on the sampling coordinates, and rendering the mirror model based on the target color values ​​of each vertex sampled, and a mirror image with a deformation effect can be displayed on the mirror model. Compared with the existing model processing method, the embodiment of the present application realizes a completely physically based simulated funhouse mirror imaging performance, without the need to use a disturbance map or change the UV stretch, and the effect is controllable, the performance method, and the playability are strong, and the different mirror deformation effects seen by the human eye at different positions can be simulated according to the camera viewing angle. In this way, the distortion deformation effect of the model imaging can be flexibly controlled, and the mirror deformation effect of the funhouse mirror can be realistically and accurately simulated in the virtual scene.

[0110] From the above, it can be seen that the embodiment of the present application obtains a mirror model in a virtual scene, the surface of the mirror model is uneven, and the normal directions of different vertices of the mirror model are not exactly the same; the virtual scene image that the mirror model needs to reflect is photographed by a mirror camera corresponding to the mirror model, as a rendering texture of the mirror model; based on the normal direction information of each vertex of the mirror model, the sampling coordinates of the vertex in the rendering texture are determined; the rendering texture is sampled based on the sampling coordinates to obtain the target color value corresponding to the vertex; the mirror model is rendered based on the target color value of each vertex to display a mirror image with a deformation effect on the mirror model. In this way, by adjusting the curvature and normal direction of the mirror model based on the required deformation effect, the sampling coordinates of the vertices in the rendering texture are determined according to the normal direction information of the vertices of the mirror model, and the rendering texture is sampled based on the sampling coordinates, and the mirror model is rendered based on the target color values ​​of each sampled vertex. A mirror image with a deformation effect can be displayed on the mirror model, and the distortion deformation effect of the model imaging can be flexibly controlled, so as to realize a realistic and accurate simulation of the mirror deformation effect of a funhouse mirror in a virtual scene, thereby further improving the processing efficiency of the model.

[0111] In order to better implement the above method, an embodiment of the present invention further provides a model processing device, which can be integrated in an electronic device, and the electronic device can be a terminal or a server.

[0112] For example, Figure 5 As shown, it is a schematic diagram of the structure of the model processing device provided in an embodiment of the present application. The model processing device may include an acquisition unit 201, a shooting unit 202, a determination unit 203, a sampling unit 204 and a rendering unit 205, as follows:

[0113] An acquisition unit 201 is used to acquire a mirror model in a virtual scene, wherein the surface of the mirror model is uneven, and the normal directions of different vertices of the mirror model are not completely the same;

[0114] A shooting unit 202 is used to shoot a virtual scene image that needs to be reflected by the mirror model through a mirror camera corresponding to the mirror model as a rendering texture of the mirror model;

[0115] A determination unit 203, configured to determine a sampling coordinate of a vertex in a rendering texture based on normal direction information of each vertex of the mirror model;

[0116] A sampling unit 204 is used to sample the rendering texture based on the sampling coordinates to obtain a target color value corresponding to the vertex;

[0117] The rendering unit 205 is used to render the mirror model based on the target color value of each vertex, so as to display a mirror image with a deformation effect on the mirror model.

[0118] In some embodiments, the determining unit 203 includes:

[0119] A first calculation subunit, used to calculate the screen space coordinates corresponding to the vertices in the mirror model;

[0120] A second calculation subunit is used to calculate the initial sampling coordinates of the vertex corresponding to the rendering texture based on the screen space coordinates;

[0121] An offset value determination subunit, used to determine a first sampling offset value corresponding to a vertex based on normal direction information of the vertex on the mirror model;

[0122] The coordinate offset subunit is used to offset the initial sampling coordinates of the vertex based on the first sampling offset value to obtain the sampling coordinates corresponding to the vertex in the rendering texture.

[0123] In some embodiments, the model processing device further comprises:

[0124] A first distortion parameter determining unit, used to determine a first distortion parameter corresponding to the mirror model;

[0125] The first offset value determining subunit is configured to:

[0126] Based on the normal direction information of the vertex in the mirror model, determine the basic sampling offset value;

[0127] The product of the first distortion parameter and the basic sampling offset value of the vertex is calculated to obtain the first sampling offset value corresponding to the vertex.

[0128] In some embodiments, the photographing unit 202 includes:

[0129] An object determination subunit, used to determine a virtual object in a virtual scene to be displayed in the mirror image of the mirror model;

[0130] A distance acquisition subunit, used to acquire a target distance between a virtual object and a mirror model;

[0131] The texture rendering subunit is used to shoot the virtual object based on the target distance through the mirror camera corresponding to the mirror model to obtain a virtual scene image containing the virtual object as the rendering texture of the mirror model.

[0132] In some embodiments, the object determination subunit is configured to:

[0133] Obtaining object information of a virtual object that can be displayed in a mirror image of a mirror model;

[0134] Obtaining the position of the candidate virtual object matching the object information in the virtual scene;

[0135] When the position of the candidate virtual object is within the imaging range of the mirror model, the candidate virtual object is determined to be a virtual object to be displayed in the mirror image of the mirror model.

[0136] In some embodiments, the virtual scene picture includes a virtual object, and the model processing device further includes a second distortion parameter determination unit, including:

[0137] A first distance acquisition subunit is used to acquire a first distance between a vertex of the mirror model and an observation camera corresponding to the mirror model in a target direction, where the target direction includes a horizontal direction and a vertical direction;

[0138] A second distance acquisition subunit is used to determine the corresponding position of the virtual object on the plane in the mirror model, and calculate a second distance between the virtual object and the observation camera in the target direction based on the position;

[0139] A second distortion parameter determination subunit, configured to determine a second distortion parameter corresponding to the vertex in the target direction based on the first distance and the second distance of the vertex in the target direction;

[0140] A second offset value determining subunit, used to determine a second sampling offset value of the vertex based on a second distortion parameter corresponding to the vertex in each target direction and the first distance;

[0141] The determining unit 203 is used for:

[0142] Based on the normal direction information of each vertex of the mirror model and the second sampling offset value, the sampling coordinates of the vertex in the rendering texture are determined.

[0143] In some embodiments, the second distortion parameter determination subunit is configured to:

[0144] Calculate the difference between the first distance and the second distance in the same target direction,

[0145] The absolute value of the difference is normalized to obtain the second distortion parameter corresponding to the vertex in the target direction.

[0146] In some embodiments, the second offset value determining subunit is configured to:

[0147] Mapping the second distortion parameter corresponding to each target direction into a preset value range to obtain a mapped distortion parameter;

[0148] Obtain the distortion adjustment coefficient corresponding to each target direction;

[0149] Based on the mapped distortion parameter of the vertex in each target direction, the first distance, and the distortion adjustment coefficient, a second sampling offset value corresponding to the vertex in each target direction is calculated.

[0150] In specific implementation, the above units can be implemented as independent entities, or can be arbitrarily combined to be implemented as the same or several entities. The specific implementation of the above units can refer to the previous method embodiments, which will not be repeated here.

[0151] As can be seen from the above, the embodiment of the present application obtains the mirror model in the virtual scene through the acquisition unit 201, the surface of the mirror model is uneven, and the normal directions of different vertices of the mirror model are not exactly the same; the shooting unit 202 shoots the virtual scene picture that the mirror model needs to reflect through the mirror camera corresponding to the mirror model, as the rendering texture of the mirror model; the determination unit 203 determines the sampling coordinates of the vertex in the rendering texture based on the normal direction information of each vertex of the mirror model; the sampling unit 204 samples the rendering texture based on the sampling coordinates to obtain the target color value corresponding to the vertex; the rendering unit 205 renders the mirror model based on the target color value of each vertex to display a mirror image with a deformation effect on the mirror model. In this way, by adjusting the curvature and normal direction of the mirror model based on the required deformation effect, the sampling coordinates of the vertices in the rendering texture are determined according to the normal direction information of the vertices of the mirror model, and the rendering texture is sampled based on the sampling coordinates, and the mirror model is rendered based on the target color values ​​of each sampled vertex. A mirror image with a deformation effect can be displayed on the mirror model, and the distortion deformation effect of the model imaging can be flexibly controlled, so as to realize a realistic and accurate simulation of the mirror deformation effect of a funhouse mirror in a virtual scene, thereby further improving the processing efficiency of the model.

[0152] The present application also provides an electronic device, such as Figure 6 As shown, it shows a schematic diagram of the structure of an electronic device involved in an embodiment of the present application, and the electronic device may be a terminal or a server. Specifically:

[0153] The electronic device 300 includes a processor 301 having one or more processing cores, a memory 302 having one or more computer-readable storage media, and a computer program stored in the memory 302 and executable on the processor. The processor 301 is electrically connected to the memory 302. Those skilled in the art will appreciate 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.

[0154] The processor 301 is the control center of the electronic device 300. It uses various interfaces and lines to connect various parts of the entire electronic device 300, executes various functions of the electronic device 300 and processes data by running or loading software programs and / or modules stored in the memory 302, and calling data stored in the memory 302, thereby monitoring the electronic device 300 as a whole.

[0155] In the embodiment of the present application, the processor 301 in the electronic device 300 will load instructions corresponding to the processes of one or more application programs into the memory 302 according to the following steps, and the processor 301 will run the application programs stored in the memory 302 to implement various functions:

[0156] A mirror model in a virtual scene is obtained, the surface of the mirror model is uneven, and the normal directions of different vertices of the mirror model are not completely the same;

[0157] The mirror camera corresponding to the mirror model is used to shoot the virtual scene image that the mirror model needs to reflect as the rendering texture of the mirror model;

[0158] Based on the normal direction information of each vertex of the mirror model, determine the sampling coordinates of the vertex in the rendering texture;

[0159] Sample the rendering texture based on the sampling coordinates to obtain the target color value corresponding to the vertex;

[0160] The mirror model is rendered based on the target color value of each vertex to display a mirror image with a deformation effect on the mirror model.

[0161] This solution can be achieved by obtaining a mirror model in a virtual scene, where the surface of the mirror model is uneven, and the normal directions of different vertices of the mirror model are not exactly the same; using a mirror camera corresponding to the mirror model to shoot the virtual scene image that the mirror model needs to reflect, as a rendering texture of the mirror model; based on the normal direction information of each vertex of the mirror model, determining the sampling coordinates of the vertex in the rendering texture; sampling the rendering texture based on the sampling coordinates to obtain the target color value corresponding to the vertex; rendering the mirror model based on the target color value of each vertex to display a mirror image with a deformation effect on the mirror model. In this way, by adjusting the curvature and normal direction of the mirror model based on the required deformation effect, the sampling coordinates of the vertices in the rendering texture are determined according to the normal direction information of the vertices of the mirror model, and the rendering texture is sampled based on the sampling coordinates, and the mirror model is rendered based on the target color values ​​of each sampled vertex. A mirror image with a deformation effect can be displayed on the mirror model, and the distortion deformation effect of the model imaging can be flexibly controlled, so as to realize a realistic and accurate simulation of the mirror deformation effect of a funhouse mirror in a virtual scene, thereby further improving the processing efficiency of the model.

[0162] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.

[0163] Optional, such as Figure 6As shown, the electronic device 300 further includes: a touch screen 303, a radio frequency circuit 304, an audio circuit 305, an input unit 306, and a power supply 307. The processor 301 is electrically connected to the touch screen 303, the radio frequency circuit 304, the audio circuit 305, the input unit 306, and the power supply 307, respectively. Those skilled in the art can understand that Figure 6 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.

[0164] The touch display screen 303 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 303 may include a display panel and a touch panel. Among them, the display panel can 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 can be composed of graphics, text, icons, videos and any combination thereof. Optionally, the display panel can be configured in the form of a liquid crystal display (LCD, Liquid Crystal Display), an organic light-emitting diode (OLED, Organic Light-Emitting Diode) and the like. The touch panel can be used to collect the user's touch operation on or near it (such as the user uses 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 direction, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into the touch point coordinates, and then sends it to the processor 301, and can receive the command sent by the processor 301 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 301 to determine the type of touch event, and then the processor 301 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 303 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 303 can also be used as a part of the input unit 306 to realize the input function.

[0165] The radio frequency circuit 304 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 with the network device or other electronic devices.

[0166] The audio circuit 305 can be used to provide an audio interface between the user and the electronic device through a speaker and a microphone. The audio circuit 305 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 305 and converted into audio data, and then the audio data is output to the processor 301 for processing, and then sent to another electronic device through the radio frequency circuit 304, or the audio data is output to the memory 302 for further processing. The audio circuit 305 may also include an earplug jack to provide communication between an external headset and the electronic device.

[0167] The input unit 306 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.

[0168] The power supply 307 is used to supply power to various components of the electronic device 300. Optionally, the power supply 307 can be logically connected to the processor 301 through a power management system, so that the power management system can manage charging, discharging, and power consumption. The power supply 307 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.

[0169] although Figure 6 Not shown, the electronic device 300 may also include a camera, a sensor, a wireless fidelity module, a Bluetooth module, etc., which will not be described in detail here.

[0170] In the above embodiments, the description of each embodiment has its own emphasis. For parts not described in detail in a certain embodiment, please refer to the relevant description of other embodiments. It should be noted that the electronic device provided in the embodiment of the present application and the model processing method in the above embodiment belong to the same concept. The specific implementation process is detailed in the above method embodiment, which will not be repeated here.

[0171] As can be seen from the above, the electronic device provided in the embodiment of the present application can obtain a mirror model in a virtual scene, where the surface of the mirror model is uneven, and the normal directions of different vertices of the mirror model are not exactly the same; the virtual scene image that the mirror model needs to reflect is photographed by a mirror camera corresponding to the mirror model, as a rendering texture of the mirror model; based on the normal direction information of each vertex of the mirror model, the sampling coordinates of the vertex in the rendering texture are determined; the rendering texture is sampled based on the sampling coordinates to obtain the target color value corresponding to the vertex; the mirror model is rendered based on the target color value of each vertex to display a mirror image with a deformation effect on the mirror model. In this way, by adjusting the curvature and normal direction of the mirror model based on the required deformation effect, the sampling coordinates of the vertices in the rendering texture are determined according to the normal direction information of the vertices of the mirror model, and the rendering texture is sampled based on the sampling coordinates, and the mirror model is rendered based on the target color values ​​of each sampled vertex. A mirror image with a deformation effect can be displayed on the mirror model, and the distortion deformation effect of the model imaging can be flexibly controlled, so as to realize a realistic and accurate simulation of the mirror deformation effect of a funhouse mirror in a virtual scene, thereby further improving the processing efficiency of the model.

[0172] Those skilled in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by a computer program, or by controlling related hardware through a computer program. The computer program may be stored in a computer-readable storage medium and loaded and executed by a processor.

[0173] To this end, an embodiment of the present application provides a computer-readable storage medium, in which a computer program is stored, and the computer program can be loaded by a processor to execute the steps in any model processing method provided in the embodiment of the present application. For example, the computer program can execute the following steps:

[0174] A mirror model in a virtual scene is obtained, the surface of the mirror model is uneven, and the normal directions of different vertices of the mirror model are not completely the same;

[0175] The mirror camera corresponding to the mirror model is used to shoot the virtual scene image that the mirror model needs to reflect as the rendering texture of the mirror model;

[0176] Based on the normal direction information of each vertex of the mirror model, determine the sampling coordinates of the vertex in the rendering texture;

[0177] Sample the rendering texture based on the sampling coordinates to obtain the target color value corresponding to the vertex;

[0178] The mirror model is rendered based on the target color value of each vertex to display a mirror image with a deformation effect on the mirror model.

[0179] This solution can be achieved by obtaining a mirror model in a virtual scene, where the surface of the mirror model is uneven, and the normal directions of different vertices of the mirror model are not exactly the same; using a mirror camera corresponding to the mirror model to shoot the virtual scene image that the mirror model needs to reflect, as a rendering texture of the mirror model; based on the normal direction information of each vertex of the mirror model, determining the sampling coordinates of the vertex in the rendering texture; sampling the rendering texture based on the sampling coordinates to obtain the target color value corresponding to the vertex; rendering the mirror model based on the target color value of each vertex to display a mirror image with a deformation effect on the mirror model. In this way, by adjusting the curvature and normal direction of the mirror model based on the required deformation effect, the sampling coordinates of the vertices in the rendering texture are determined according to the normal direction information of the vertices of the mirror model, and the rendering texture is sampled based on the sampling coordinates, and the mirror model is rendered based on the target color values ​​of each sampled vertex. A mirror image with a deformation effect can be displayed on the mirror model, and the distortion deformation effect of the model imaging can be flexibly controlled, so as to realize a realistic and accurate simulation of the mirror deformation effect of a funhouse mirror in a virtual scene, thereby further improving the processing efficiency of the model.

[0180] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.

[0181] 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.

[0182] Since the computer program stored in the computer-readable storage medium can execute the steps in any one of the model processing methods provided in the embodiments of the present application, the beneficial effects that can be achieved by any one of the model processing 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.

[0183] Among them, according to one aspect of the present application, a computer program product is provided, which includes a computer program, and the computer program is stored in a computer-readable storage medium; when a processor of an electronic device reads the computer program from the computer-readable storage medium, the processor executes the computer program, so that the electronic device executes the methods provided in the various optional implementations provided in the above embodiments.

[0184] The above is a detailed introduction to a model processing method, device, storage medium and electronic device 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 idea of ​​the present application, there will be changes in the specific implementation method 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 processing method, characterized in that: include: Acquire a mirror model in a virtual scene, wherein the surface of the mirror model is uneven, and normal directions of different vertices of the mirror model are not completely the same; Using a mirror camera corresponding to the mirror model, shooting a virtual scene image that the mirror model needs to reflect as a rendering texture of the mirror model; Determining the sampling coordinates of each vertex in the rendering texture based on the normal direction information of each vertex of the mirror model; Sampling the rendering texture based on the sampling coordinates to obtain a target color value corresponding to the vertex; The mirror model is rendered based on the target color value of each of the vertices to display a mirror image with a deformation effect on the mirror model.

2. The model processing method according to claim 1, characterized in that: The step of determining the sampling coordinates of the vertices in the rendering texture based on the normal direction information of each vertex of the mirror model includes: Calculating the screen space coordinates corresponding to the vertices in the mirror model; Based on the screen space coordinates, calculate the initial sampling coordinates of the vertex corresponding to the rendering texture; Determine a first sampling offset value corresponding to the vertex based on normal direction information of the vertex on the mirror model; The initial sampling coordinates of the vertex are offset based on the first sampling offset value to obtain the sampling coordinates of the vertex corresponding to the rendering texture.

3. The model processing method according to claim 2, characterized in that: Before determining the first sampling offset value corresponding to the vertex based on the normal direction information of the vertex on the mirror model, the method further includes: Determining a first distortion parameter corresponding to the mirror model; The determining, based on the normal direction information of the vertex on the mirror model, a first sampling offset value corresponding to the vertex includes: Determine a basic sampling offset value based on normal direction information of the vertex in the mirror model; The product of the first distortion parameter and the basic sampling offset value of the vertex is calculated to obtain a first sampling offset value corresponding to the vertex.

4. The model processing method according to claim 1, characterized in that: The step of shooting a virtual scene image that needs to be reflected by the mirror model through a mirror camera corresponding to the mirror model as a rendering texture of the mirror model includes: Determining a virtual object in the virtual scene to be displayed in the mirror image of the mirror model; Acquire a target distance between the virtual object and the mirror model; The virtual object is photographed based on the target distance by a mirror camera corresponding to the mirror model to obtain a virtual scene image including the virtual object as a rendering texture of the mirror model.

5. The model processing method according to claim 4, characterized in that: The determining of a virtual object in the virtual scene to be displayed in the mirror image of the mirror model comprises: Acquire object information of a virtual object that can be displayed in the mirror image of the mirror model; Acquire the position of the candidate virtual object matching the object information in the virtual scene; When the position of the candidate virtual object is within the imaging range of the mirror model, the candidate virtual object is determined to be a virtual object to be displayed in the mirror image of the mirror model.

6. The model processing method according to any one of claims 1 to 5, characterized in that: The virtual scene screen includes a virtual object, and before determining the sampling coordinates of the vertex in the rendering texture based on the normal direction information of each vertex of the mirror model, the method further includes: Acquire a first distance between a vertex of the mirror model and an observation camera corresponding to the mirror model in a target direction, where the target direction includes a horizontal direction and a vertical direction; Determine a position corresponding to the virtual object on the plane in the mirror model, and calculate a second distance between the virtual object and the observation camera in the target direction based on the position; Determine a second distortion parameter corresponding to the vertex in the target direction based on the first distance and the second distance of the vertex in the target direction; Determine a second sampling offset value of the vertex based on the second distortion parameter corresponding to the vertex in each of the target directions and the first distance; The step of determining the sampling coordinates of the vertices in the rendering texture based on the normal direction information of each vertex of the mirror model includes: Based on the normal direction information of each vertex of the mirror model and the second sampling offset value, the sampling coordinates of the vertex in the rendering texture are determined.

7. The model processing method according to claim 6, characterized in that: The determining, based on the first distance and the second distance of the vertex in the target direction, a second distortion parameter corresponding to the vertex in the target direction includes: calculating the difference between the first distance and the second distance in the same target direction, The absolute value of the difference is normalized to obtain a second distortion parameter corresponding to the vertex in the target direction.

8. The model processing method according to claim 7, characterized in that: The determining, based on the second distortion parameter corresponding to the vertex in each of the target directions and the first distance, a second sampling offset value of the vertex includes: Mapping the second distortion parameter corresponding to each of the target directions into a preset value range to obtain a mapped distortion parameter; Obtaining a distortion adjustment coefficient corresponding to each of the target directions; Based on the mapped distortion parameter of the vertex in each of the target directions, the first distance, and the distortion adjustment coefficient, a second sampling offset value corresponding to the vertex in each of the target directions is calculated.

9. A model processing device, characterized in that: include: An acquisition unit, used for acquiring a mirror model in a virtual scene, wherein the surface of the mirror model is uneven, and the normal directions of different vertices of the mirror model are not completely the same; A shooting unit, used for shooting a virtual scene image to be reflected by the mirror model through a mirror camera corresponding to the mirror model as a rendering texture of the mirror model; A determination unit, configured to determine, based on normal direction information of each vertex of the mirror model, a sampling coordinate of the vertex in the rendering texture; A sampling unit, used for sampling the rendering texture based on the sampling coordinates to obtain a target color value corresponding to the vertex; A rendering unit is used to render the mirror model based on the target color value of each of the vertices to display a mirror image with a deformation effect on the mirror model.

10. An electronic device, characterized in that: It comprises a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of any one of the methods of claims 1 to 8.

11. A computer-readable storage medium, characterized in that: It comprises a computer program. When the computer program is run on an electronic device, the computer program is used to make the electronic device execute the steps of any one of the methods of claims 1 to 8.

Citation Information

Patent Citations

  • Tri-dimensional application program convex mirror effect simulation method

    CN101149841A

  • Material attribute generation method and device of virtual three-dimensional model and storage medium

    CN117252982A

  • Model rendering method and device, storage medium and electronic device

    CN117671114A

  • Image rendering method and device, storage medium and computer equipment

    CN117710559A

  • A rendering process and system

    US20190272626A1