Model processing method and apparatus, storage medium, and electronic device
By determining the specified position and vertex color information of the target model in the model processing method, calculating the texture tiling rate, and adjusting the texture UV information, the problem of low model scaling efficiency in the prior art is solved, and the effect of adaptive scaling without texture stretching is achieved.
Patent Information
- Application Number
- CN202411944684.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-25
- Publication Date
- 2025-11-04
- Estimated Expiration
- 2044-12-25
AI Technical Summary
Existing model processing methods based on TriPlanar texture mapping technology require multiple renderings, resulting in poor model scaling efficiency.
By responding to scaling operations, the system determines the specified location information of the target model, obtains the vertex color information of the vertices, calculates the texture tiling rate of the vertices, and adjusts the texture UV information based on the texture tiling rate for rendering, thus avoiding texture stretching.
It achieves adaptive scaling of models without stretching textures, improving model scaling efficiency and avoiding performance issues caused by multiple renderings.
Smart Images

Figure CN119963723B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer, in particular to a model processing method and device, a storage medium and an electronic device. BACKGROUND
[0002] With the rapid development of life and technology, people often entertain through game applications. In some games, players can independently adjust and create virtual models in the game. For example, in a racing game, a player can create a race track and customize the length and width of the race track. When scaling the race track or guardrail model, the model and texture need to be reasonably scaled according to the size of the scaling. In the existing model processing method, the texture stretching change after the model size change is often performed through the TriPlanar texture mapping technology.
[0003] However, the existing model processing method based on the TriPlanar texture mapping technology needs to perform rendering in multiple directions, and multiple renderings cause performance problems, resulting in poor model scaling efficiency. SUMMARY
[0004] The embodiments of the present application provide a model processing method, device, storage medium and electronic device, which can generate a model that is adaptively scaled based on a scaling operation and whose texture is not stretched, effectively improving the model scaling efficiency.
[0005] The embodiments of the present application provide a model processing method, comprising:
[0006] In response to a scaling operation on a target model, determining first position information to which a specified position of the target model needs to be scaled;
[0007] Obtaining vertex color information of a vertex in the target model, the vertex color information comprising a first channel value and a second channel value, the first channel value indicating a same first distance that the vertex and the specified position need to maintain before and after scaling, and the second channel value indicating a tiling mode configured for the vertex;
[0008] Based on the first distance and the first position information, calculating second position information to which the vertex in the target model needs to be scaled based on the scaling operation;
[0009] If the second channel value indicates that the vertex is configured as a first tiling mode, determining a texture tiling rate of the vertex based on initial position information of the vertex before scaling, the second position information and the second channel value, otherwise determining the texture tiling rate of the vertex as 1;
[0010] adjust texture UV information of the vertex of the target model based on the texture tiling rate, to obtain first target texture UV information;
[0011] render the target model based on the first target texture UV information and the second position information, to obtain a scaled target model.
[0012] Correspondingly, an embodiment of the present application provides a model processing apparatus, comprising:
[0013] a first determination unit configured to determine, in response to a scaling operation on a target model, first position information to which a specified position of the target model needs to be scaled;
[0014] a obtaining unit configured to obtain vertex color information of a vertex in the target model, the vertex color information comprising a first channel value and a second channel value, the first channel value indicating a same first distance that the vertex needs to maintain before and after scaling of the specified position, and the second channel value indicating a tiling mode configured for the vertex;
[0015] a calculation unit configured to calculate, based on the first distance and the first position information, second position information to which the vertex in the target model needs to be scaled based on the scaling operation;
[0016] a second determination unit configured to determine, if the second channel value indicates that the vertex is configured as a first tiling mode, a texture tiling rate of the vertex based on initial position information of the vertex before scaling, the second position information, and the second channel value, and otherwise determine the texture tiling rate of the vertex as 1;
[0017] an adjustment unit configured to adjust texture UV information of the vertex of the target model based on the texture tiling rate, to obtain first target texture UV information;
[0018] a rendering unit configured to render the target model based on the first target texture UV information and the second position information, to obtain a scaled target model.
[0019] Further, an embodiment of the present application further provides a computer readable storage medium, which stores a computer program, and the computer program is adapted to be loaded by a processor to execute steps in any model processing method provided by the embodiments of the present application.
[0020] Further, an embodiment of the present application further provides an electronic device, comprising a processor and a memory, wherein the memory stores an application program, and the processor is configured to run the application program in the memory to implement a model processing method provided by the embodiments of the present application.
[0021] The embodiment of the present application further provides a computer program product, which comprises a computer program 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 steps in the model processing method provided by the embodiment of the present application.
[0022] The embodiment of the present application determines the first position information to which the specified position of the target model needs to be scaled in response to the scaling operation for the target model; obtains the vertex color information of the vertex in the target model, the vertex color information comprising a first channel value and a second channel value, the first channel value indicating a same first distance that the vertex and the specified position need to maintain before and after scaling, and the second channel value indicating a tiling mode configured for the vertex; calculates the second position information to which the vertex in the target model needs to be scaled based on the scaling operation based on the first distance and the first position information; determines a texture tiling rate of the vertex based on the initial position information of the vertex before scaling, the second position information and the second channel value if the second channel value indicates that the vertex is configured in the first tiling mode, and otherwise determines the texture tiling rate of the vertex as 1; adjusts the texture UV information of the vertex of the target model based on the texture tiling rate to obtain first target texture UV information; and renders the target model based on the first target texture UV information and the second position information to obtain the scaled target model. In this way, by determining the first distance that the vertex in the target model and the specified position need to maintain before and after scaling and the tiling mode configured for the vertex according to the vertex color information of the vertex in the target model, the second position information to which the vertex in the target model needs to be scaled is calculated according to the first distance and the position to which the specified position of the target model needs to be scaled after scaling, and the texture tiling rate of the vertex is determined according to the tiling mode configured for the vertex, and the original texture UV information is adjusted to obtain the first target texture UV information, so that the position to which the vertex in the target model needs to be moved based on the scaling operation can be determined based on the second position information of the vertex, the region that needs to be scaled can be adaptively tiled based on the texture tiling rate based on the first target texture UV information, so as to avoid stretching the texture of the model during scaling, and the scaled target model that is adaptively scaled and whose texture is not stretched can be obtained by rendering the target model based on the first target texture UV information and the second position information, so as to avoid the performance problem caused by implementing the model scaling effect through multiple renderings, and thus the model scaling efficiency is effectively improved. BRIEF DESCRIPTION OF DRAWINGS
[0023] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the embodiments description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative effort based on these drawings.
[0024] Figure 1 is a model processing method implementation scenario provided by an embodiment of the present application;
[0025] Figure 2 is a flowchart of a model processing method provided by an embodiment of the present application;
[0026] Figure 3a is a model diagram of a model processing method provided by an embodiment of the present application;
[0027] Figure 3b is a vertex color configuration diagram of a model processing method provided by an embodiment of the present application;
[0028] Figure 4 is a model scaling effect diagram of a model processing method provided by an embodiment of the present application;
[0029] Figure 5 is a structural diagram of a model processing apparatus provided by an embodiment of the present application;
[0030] Figure 6 is a structural diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0031] The technical solutions in the embodiments of the present application will be described clearly and completely with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some embodiments of the present application, not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present application.
[0032] The present application provides a model processing method, apparatus, storage medium and electronic device. The model processing apparatus can be integrated in an electronic device, which can be a server, a terminal or other devices.
[0033] The server can be a standalone physical server, a server cluster composed of multiple physical servers, or a distributed system, and can also be a cloud server providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery network (CDN), and basic cloud computing services such as big data and artificial intelligence platforms. The terminal can include but is not limited to a mobile phone, a computer, a smart voice interaction device, a smart home appliance, a vehicle-mounted terminal, an aircraft, and the like. The terminal and the server can be connected directly or indirectly through wired or wireless communication, which is not limited in the present application.
[0034] Please refer to Figure 1 For example, the model processing device is integrated in an electronic device, Figure 1 The implementation scenario of the model processing method provided by the embodiment of the present application is shown in the figure, wherein the electronic device can be a terminal, and the electronic device can determine first position information to which a specified position of a target model needs to be scaled in response to a scaling operation on the target model; obtain vertex color information of a vertex in the target model, the vertex color information including a first channel value and a second channel value, the first channel value indicating a same first distance that the vertex needs to maintain before and after scaling with the specified position, and the second channel value indicating a tiling mode configured for the vertex; based on the first distance and the first position information, calculate second position information of the vertex in the target model that needs to be scaled based on the scaling operation; if the second channel value indicates that the vertex is configured in a first tiling mode, determine a texture tiling rate of the vertex based on initial position information of the vertex before scaling, the second position information, and the second channel value, otherwise determine the texture tiling rate of the vertex as 1; adjust texture UV information of the vertex of the target model based on the texture tiling rate to obtain first target texture UV information; and render the target model based on the first target texture UV information and the second position information to obtain a scaled target model.
[0035] It should be noted that Figure 1 The implementation environment scenario of the model processing method shown in the figure is only an example, and the implementation environment scenario of the model processing method described in the embodiments of the present application is to more clearly illustrate the technical solutions of the embodiments of the present application, and does not constitute a limitation on the technical solutions provided by the embodiments 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 solutions provided by the present application are also applicable to similar technical problems.
[0036] The scheme provided by the embodiments of the present application is specifically described by the following embodiments. It should be noted that the order of the following embodiments is not limited as the preferred order of the embodiments.
[0037] The embodiment will be described from the perspective of a model processing apparatus, which can be integrated in an electronic device, which can be a terminal and / or a server, without limitation.
[0038] Please refer to Figure 2 , Figure 2 is a flowchart of a model processing method provided by an embodiment of the present application. The model processing method comprises:
[0039] In step 101, in response to a scaling operation on a target model, first position information to which a specified position of the target model needs to be scaled is determined.
[0040] The target model can be a scalable model, for example, a guardrail model, a race track model, a bench model, a table model, etc., such as a guardrail model on both sides of a race track. The scaling operation can be an operation of scaling the target model. The specified position can be a specified position in the target model, which can be used as a reference position for scaling the target model to control scaling of the target model. The first position information can indicate a position to which the specified position of the target model needs to be moved based on scaling of the scaling operation.
[0041] Optionally, the specified position can include an edge position or a center position of the target model. The edge position can be a most edge position on both sides of the target model, and the center position can be a position of the center of the target model. Whether the specified position is an edge position or a center position of the target model can be set according to actual scaling of the model, for example, when it is needed to keep areas on both sides of the target model after scaling from being scaled, the specified position can be set as an edge position of the target model, when it is needed to keep a middle area of the target model after scaling from being scaled, the specified position can be set as a center position of the target model, etc.
[0042] For example, taking the target model as a guardrail model as an example, please refer to Figure 3a , Figure 3a is a model diagram of a model processing method provided by an embodiment of the present application. It is assumed that a length of the target model is 1 meter (meter, abbreviated as m), and it is assumed that a center position of the target model is located on a world coordinate origin (0, 0, 0), then a distance between the edge position and the center position of the target model is 0.5 m.
[0043] The first position information to which the specified position of the target model needs to be scaled can be determined in various ways in response to the scaling operation on the target model. For example, if the scaling operation is an operation of scaling the target model by dragging one side of the target model by the player, the position to which the specified position of the target model needs to be scaled can be determined according to the end position of the scaling operation. The scaling operation can also be an operation of scaling the track or other model by the player, and triggering the scaling operation on the target model associated with the other model, so that the position to which the specified position of the target model needs to be scaled can be determined based on the scaling of the other model. Alternatively, the scaling operation can also be an operation of adjusting the distribution density of the target model by the player, triggering the scaling operation on the target model, so that the position to which the specified position of the target model needs to be scaled can be determined according to the distribution density of the target model, and the first position information is obtained.
[0044] In step 102, vertex color information of a vertex in the target model is obtained.
[0045] The vertex color information can include a first channel value and a second channel value. The first channel value can indicate a same first distance that the vertex needs to maintain before and after scaling with the specified position. The second channel value can indicate a tiling mode configured for the vertex.
[0046] The vertex color information can be information indicating a vertex color attribute of the vertex. The vertex color attribute can be a material attribute of a vertex color of the vertex. The vertex color can include channel values of three channels (RGB). The first channel value can be a channel value of an R channel. The second channel value can be a channel value of a G channel. The third channel value can be a channel value of a B channel. The first channel value can be a value of a first distance. The first distance can be a distance between the vertex and the specified position in the target model. The vertex and the specified position always maintain the distance when the target model is scaled. The second channel value can be a value indicating a tiling mode configured for the current vertex. For example, a value 255 can be used to indicate that the current vertex is configured in a first tiling mode, and a value 0 can be used to indicate that the current vertex is configured in a second tiling mode. When the second channel value of the vertex is 255, it can indicate that the vertex is configured in the first tiling mode. When the second channel value of the vertex is 0, it can indicate that the vertex is configured in the second tiling mode. The first tiling mode can be a mode of tiling a texture according to a texture tiling rate calculated based on the scaling operation. The second tiling mode can be a mode of tiling the texture according to a texture tiling rate of 1. The texture tiling rate can refer to the number of times a texture image is repeated on a material surface of a model in a texture mapping process. It can determine the size of the area covered by the texture image on the material surface. When the texture tiling rate is 1, it can mean that the texture image is repeated only once.
[0047] For the configuration of the first channel value, taking the guardrail model as the target model and the edge position as the specified position as an example, it is assumed that the distance from the center position of the guardrail model to the edge position is 0.5 m, and the first channel value of the guardrail model is calculated based on the edge positions on the left and right sides of the guardrail model. Specifically, the length range 0-0.5 on each side can be mapped to the calculation range 0-255 of the color, so that the difference between the vertex and the specified position, that is, the first distance, can be mapped to 0-255 as the vertex color of the vertex, so that when the first distance corresponding to the vertex is obtained based on the first channel value, the first channel value is 255, and the first distance corresponding to the vertex is obtained.
[0048] Optionally, there can be various ways to configure the vertex color information of the vertex in the target model, for example, refer to Figure 3b , Figure 3b is a vertex color configuration diagram of a model processing method provided by an embodiment of the present application. The vertex color information of the vertex of the target model can be configured by using the vertex color tool provided by a three-dimensional graphics software, which can be a digital content generation application (DCC). For example, the first distance between the vertex in the target model and the specified position in the target model can be calculated, the first distance is set as the value of the R channel of the vertex color of the vertex, to obtain the first channel value. According to the scaling requirement of the target model, it can be determined that each vertex in the target model belongs to a scaling region, so that the texture tiling mode of the vertex can be determined, the value of the G channel of the vertex color of the vertex is set as the value corresponding to the texture tiling mode corresponding to the vertex, to obtain the second channel value. Whether the texture corresponding to the vertex needs to be configured to have a scrolling effect, the value of the B channel of the vertex color of the vertex can be set. For example, if the texture corresponding to the vertex needs to be configured to have a scrolling effect, the value of the B channel of the vertex color of the vertex can be set as 255, and if the texture corresponding to the vertex does not need to be configured to have a scrolling effect, the value of the B channel of the vertex color of the vertex can be set as 0, to obtain the third channel value.
[0049] In an embodiment, please continue to refer to Figure 3a , it is assumed that there is a vertex at a position 0.35 m away from the center position of the target model, and it is assumed that the specified position is the edge position of the target model, so the first distance between the vertex and the specified position is 0.5-0.35=0.15 m, and the value corresponding to the first distance is assigned to the first channel corresponding to the vertex, to obtain the first channel value.
[0050] In step 103, based on the first distance and the first position information, the second position information of the vertex in the target model that needs to be scaled based on the scaling operation is calculated.
[0051] The second position information can be a position to which a vertex in the target model needs to be scaled based on the scaling operation.
[0052] The second position information to which the vertex in the target model needs to be scaled based on the scaling operation can be calculated in various ways based on the first distance and the first position information. For example, a coordinate value corresponding to the scaling direction of the scaling operation in the first position information can be obtained; a scaling coordinate value can be calculated based on the coordinate value and the first distance; and the second position information to which the vertex needs to be scaled based on the scaling operation can be obtained based on the scaling coordinate value and the initial position information of the vertex.
[0053] The scaling direction can be a direction in which the target model is scaled. For example, please continue to refer to Figure 3a When the target model is scaled in the horizontal direction, the scaling direction can be the x direction. The coordinate value can be a value corresponding to the scaling direction of the scaling operation in the first position information. For example, assuming that the first position information is (1, 0, 0), and the target model is scaled in the horizontal direction, the coordinate value is the x component of (1, 0, 0), that is, 1. The scaling coordinate value can be a position to which the vertex should be scaled in the scaling direction. For example, assuming that the specified position is an edge position, when the coordinate value is positive, the scaling coordinate value can be the difference between the coordinate value and the first distance, and when the coordinate value is negative, the scaling coordinate value can be the sum of the coordinate value and the first distance. It should be noted that the calculation of the scaling coordinate value is used to make the distance between the scaled position of the vertex and the specified position of the target model remain the first distance, and the specific calculation method can be adjusted according to actual conditions, which is not limited in the embodiments of the present application. The initial position information can be the position information of the vertex before scaling.
[0054] The second position information to which the vertex needs to be scaled based on the scaling operation can be obtained in various ways based on the scaling coordinate value and the initial position information of the vertex. For example, the coordinate value corresponding to the scaling direction in the initial position information of the vertex can be replaced by the scaling coordinate value, so as to obtain the second position information to which the vertex needs to be scaled based on the scaling operation. For example, assuming that the initial position information of a vertex a in the target model is (0.3, 1, 1), the scaling direction is the horizontal direction, and the scaling coordinate value is 0.8, the second position information of the vertex a is (0.8, 1, 1).
[0055] In step 104, if the second channel value indicates that the vertex is configured in the first tiling mode, the texture tiling rate of the vertex is determined based on the initial position information of the vertex before scaling, the second position information, and the second channel value, otherwise the texture tiling rate of the vertex is determined to be 1.
[0056] The first tiling mode can be a mode of texture tiling according to a texture tiling rate calculated based on the scaling operation. The texture tiling rate can refer to the number of times a texture image is repeatedly laid on the material surface of a model in the texture mapping process. It can determine the size of the area covered by the texture image on the material surface. When the texture tiling rate is 1, it can mean that the texture image is only repeated once. The texture image can be an image including a texture. Therefore, if the texture tiling rate is 1 when the target model is scaled, the texture tiled on the target model after scaling will have a stretching effect, for example, the texture in the positive direction will be stretched into a rectangle, etc., resulting in poor model scaling effect. To this end, based on the model scaling effect, the embodiments of the present application configure the corresponding texture tiling mode for each vertex through vertex color information configuration, so that based on the scaling effect corresponding to each vertex, the vertex configured with the scaling effect can be tiled with the texture based on the calculated texture tiling rate, and the adaptive texture tiling based on the scaling operation is performed, thereby avoiding the stretching of the texture. For the vertex not configured with the scaling effect, the preset texture tiling rate of 1 can be used for texture tiling, so that the target model can be adaptively scaled and adaptively tiled with the texture based on the scaling operation, effectively improving the model scaling effect.
[0057] If the second channel value indicates that the vertex is configured with the first tiling mode, the texture tiling rate of the vertex is determined based on the initial position information of the vertex before scaling, the second position information, and the second channel value. Otherwise, the texture tiling rate of the vertex is determined to be 1. There can be multiple ways to determine the texture tiling rate of the vertex, for example, the initial position information of the vertex before scaling of the target model can be obtained; based on the second position information and the initial position information corresponding to the vertex, the scaling multiple corresponding to the scaling operation is calculated; and based on the second channel value and the scaling multiple, the texture tiling rate corresponding to the vertex is determined. If the second channel value indicates that the vertex is configured with the first tiling mode, the texture tiling rate of the vertex is determined to be the scaling multiple. Otherwise, the texture tiling rate of the vertex is determined to be 1.
[0058] The scaling multiple can be a multiple of scaling the scalable region in the target model. The edge of the scalable region in the target model is configured with a vertex, and the interior of the scalable region is generally not provided with a vertex. Therefore, when the target model is scaled, the target model can be scaled while the distance between the vertex and the specified position remains unchanged.
[0059] There can be multiple ways to calculate the scaling multiple corresponding to the scaling operation based on the second position information and the initial position information corresponding to the vertex, for example, the coordinate values corresponding to the scaling direction in the second position information and the initial position information of the vertex can be obtained, and the coordinate value corresponding to the second position information is divided by the coordinate value corresponding to the initial position information to obtain the scaling multiple corresponding to the scaling operation.
[0060] The manner of determining the texture tiling rate corresponding to the vertex based on the second channel value and the scaling multiple can be various, for example, the second channel value in the vertex color information of the vertex can include a first value or a second value, the first value can indicate that the vertex is configured in the first tiling mode, and the second value can indicate that the vertex is configured in the second tiling mode, and in this way, a texture tiling rate determination function can be obtained; the texture tiling rate corresponding to the vertex is determined based on the second channel value and the scaling multiple through the texture tiling rate determination function, wherein if the second channel value is the first value, the texture tiling rate corresponding to the vertex is determined as the scaling multiple, and if the second channel value is the second value, the texture tiling rate corresponding to the vertex is determined as 1.
[0061] The first tiling mode can be a mode of tiling the texture according to the texture tiling rate calculated by the scaling operation, and the second tiling mode can be a mode of tiling the texture with the texture tiling rate being 1. The texture tiling rate determination function can be a function for determining the texture tiling rate corresponding to the vertex, for example, can be an interpolation function (Lerp), the first value can be 255, and the second value can be 0, or the first value can be 1, and the second value can be 0, etc., which can be set according to actual conditions.
[0062] The manner of determining the texture tiling rate corresponding to the vertex based on the second channel value and the scaling multiple through the texture tiling rate determination function can be various, for example, the following formula can be used to determine the texture tiling rate corresponding to the vertex through the texture tiling rate determination function:
[0063] uvScale.x=lerp(1,calcuTiling,vertexcolor.g)
[0064] wherein lerp() is an interpolation function, i.e., a texture tiling rate determination function, uvScale.x represents the texture tiling rate of the vertex, calcuTiling is the scaling multiple, and vertexcolor.g is the value of the vertex in the G channel of the vertex color, i.e., the second channel value.
[0065] In step 105, the texture UV information of the vertex of the target model is adjusted based on the texture tiling rate to obtain first target texture UV information.
[0066] The texture UV information can be a texture map coordinate of the target model, also referred to as a UV of the model, which can define the position of each point on a texture image, and the points are associated with the three-dimensional model to determine the position of the surface texture map. The UV is to accurately correspond each point on the texture image to the surface of the three-dimensional model, and the image is smoothly interpolated between the points. The first target texture UV information can be texture UV information adjusted based on the texture tiling rate.
[0067] The method of adjusting the texture UV information of the vertex of the target model based on the texture tiling rate to obtain the first target texture UV information can be various, for example, the texture UV information corresponding to the vertex of the target model can be obtained; the product of the texture UV information corresponding to the vertex and the texture tiling rate is calculated to obtain the first target texture UV information corresponding to the vertex.
[0068] The method of calculating the product of the texture UV information corresponding to the vertex and the texture tiling rate to obtain the first target texture UV information corresponding to the vertex can be various, for example, the first target texture UV information corresponding to the vertex can be calculated by using the following formula:
[0069] OUT.TexCoord.xy=(IN.TexCoord.xy)*(uvScale)
[0070] Wherein, OUT.TexCoord.xy represents the first target texture UV information of the vertex, IN.TexCoord.xy represents the texture UV information corresponding to the vertex, and uvScale represents the texture tiling rate corresponding to the vertex.
[0071] In step 106, the target model is rendered based on the first target texture UV information and the second position information to obtain a scaled target model.
[0072] The scaled target model can be a target model scaled based on a scaling operation. In the scaled target model, the target model is scaled in at least a partial region based on the scaling operation, and in the scaled region, the texture of the model is adapted to the size of the model, so that there is no stretching effect. For example, please refer to Figure 4 , Figure 4 is a model scaling effect schematic diagram of a model processing method provided by the embodiment of the present application. In the scaled target model, only the middle region of the target model can be scaled, and the texture laid in the scaled region of the target model is adaptively tiled with the model scaling, so that there is no stretching effect, effectively improving the model scaling effect.
[0073] Optionally, the texture laid on the target model can also be scrolled to achieve a specific effect. Specifically, an offset parameter can be obtained, the value of the offset parameter changes over time, and based on the first target texture UV information and the offset parameter, the second target texture UV information of the vertex is determined.
[0074] Correspondingly, for the step of rendering the target model based on the first target texture UV information and the second position information to obtain the scaled target model, the step can include: rendering the target model based on the second target texture UV information and the second position information to obtain the scaled target model, and the texture on the target model changes in scrolling.
[0075] Among them, the offset parameter can be a parameter for offsetting the first target texture UV information corresponding to the vertex, that is, a parameter for realizing UV scrolling, and the second target texture UV information can be texture UV information for controlling the texture in the target model to have a texture scrolling effect.
[0076] Among them, the way to obtain the offset parameter can be various, for example, a time function and a scrolling rate control parameter can be obtained, the time function can be used to obtain the game time, and the scrolling rate control parameter can be used to control the texture scrolling rate, for example, the offset parameter can be represented as GameTime*T, wherein GameTime can represent the time function, and T can represent the scrolling rate control parameter. The specific value of T can be set according to actual needs, for example, it can be 0.02, 0.01, etc.
[0077] Among them, the way to determine the second target texture UV information of the vertex based on the first target texture UV information and the offset parameter can be various, for example, the second target texture UV information of the vertex can be determined by using the following formula:
[0078] OUT2.TexCoord.xy=OUT1.TexCoord.xy+GameTime*T
[0079] Among them, OUT2.TexCoord.xy can represent the second target texture UV information corresponding to the vertex, OUT1.TexCoord.xy can represent the first target texture UV information corresponding to the vertex, and GameTime*T can represent the offset parameter.
[0080] Optionally, the manner of determining the second target texture UV information of the vertex based on the first target texture UV information and the offset parameter can also be various, for example, the vertex color information of the vertex can further include a third channel value, which can indicate whether the vertex is configured with a texture scrolling effect, for example, when the third channel value of the vertex is a third numerical value, it can indicate that the vertex is configured with a texture scrolling effect, and when the third channel value of the vertex is a fourth numerical value, it can indicate that the vertex is configured without a texture scrolling effect, the third numerical value and the fourth numerical value are different, for example, the third numerical value can be 255, and the fourth numerical value can be 0, and specific numerical values can be set according to actual conditions, which are not limited in the embodiment of the present application. In this way, the texture scrolling effect of at least part of the region of the target model can be controlled according to the third channel value of the vertex, and the texture scrolling effect is improved.
[0081] Specifically, whether the vertex is configured with a texture scrolling effect can be determined based on the third channel value of the vertex; if the vertex is configured with a texture scrolling effect, the first target texture UV information and the offset parameter of the vertex are summed to obtain the second target texture UV information of the vertex; if the vertex is not configured with a texture scrolling effect, the first target texture UV information of the vertex is determined as the second target texture UV information of the vertex.
[0082] In this way, when the vertex is configured with a texture scrolling effect, the first target texture UV information and the offset parameter of the vertex are summed, so that the second target texture UV information of the vertex is texture UV information that changes based on time, that is, the texture UV information corresponding to the vertex is UV scrolled with time, so that different texture pixels can be sampled based on the changed second target texture UV information, and thus the texture scrolling effect can be constructed, and the texture scrolling of the target model is realized.
[0083] In some racing games, there is a user-generated content (UGC) based subdivision gameplay, players can create track models by themselves, customize length, width and other attributes to give players higher creative freedom in track design, and the track's guardrail model and other decoration models also need to adapt to the change of track size, therefore, when scaling the track or guardrail model, the model and texture need to be reasonably scaled according to the size of the scaling. In the existing model processing method, the texture stretching change after the model size change is often realized through the tri-planar texture mapping technology. However, this method needs to perform rendering in multiple directions, which means that color and lighting calculation will be repeatedly calculated, and multiple rendering brings performance problems, making the model scaling efficiency poor. Therefore, the embodiment of the present application provides a model processing method based on adaptive algorithm of UGC scaling model, by configuring the vertex color information of the vertex based on the model scaling effect, the corresponding texture tiling mode and the first distance from the specified position are configured for each vertex, so that the position to which each vertex needs to be scaled can be determined based on the first distance, and based on the scaling effect corresponding to each vertex, for the vertex configured with the scaling effect, texture tiling can be performed based on the calculated texture tiling rate, adaptive texture tiling based on scaling operation, so as to avoid the situation that the texture is stretched, and for the vertex not configured with the scaling effect, the preset texture tiling rate of 1 can be used for texture tiling, so that the target model can be adaptively scaled and texture adaptively tiled based on the scaling operation, so that the player can dynamically change the size of the model in the UGC mode of the game, while the corresponding texture and model edge locking structure remain unchanged, effectively improving the model scaling effect.
[0084] From the above, the embodiment of the present application determines the first position information to which the specified position of the target model needs to be scaled in response to the scaling operation for the target model; obtains the vertex color information of the vertex in the target model, the vertex color information including a first channel value and a second channel value, the first channel value indicating that the vertex needs to maintain the same first distance with the specified position before and after scaling, and the second channel value indicating the tiling mode configured for the vertex; calculates the second position information to which the vertex in the target model needs to be scaled based on the scaling operation based on the first distance and the first position information; if the second channel value indicates that the vertex is configured in the first tiling mode, determines the texture tiling rate of the vertex based on the initial position information of the vertex before scaling, the second position information and the second channel value, otherwise determines the texture tiling rate of the vertex as 1; adjusts the texture UV information of the vertex of the target model based on the texture tiling rate to obtain first target texture UV information; and renders the target model based on the first target texture UV information and the second position information to obtain the scaled target model. In this way, by determining the first distance that the vertex in the target model needs to maintain with the specified position before and after scaling and the tiling mode configured for the vertex according to the vertex color information of the vertex in the target model, the second position information to which the vertex in the target model needs to be scaled is calculated according to the first distance and the position to which the specified position of the target model needs to be scaled after scaling, and the texture tiling rate of the vertex is determined according to the tiling mode configured for the vertex, and the original texture UV information is adjusted to obtain the first target texture UV information. In this way, based on the second position information of the vertex, the position to which the vertex in the target model needs to be moved based on the scaling operation can be determined, based on the first target texture UV information, adaptive texture tiling can be performed on the region that needs to be scaled based on the texture tiling rate, so as to avoid stretching the texture of the model in the scaling process. In this way, based on the first target texture UV information and the second position information, the target model can be rendered to obtain the scaled target model that is adaptively scaled and the texture of which is not stretched, thereby avoiding the performance problem caused by implementing the model scaling effect through multiple rendering, and effectively improving the model scaling efficiency.
[0085] To better implement the above method, the embodiment of the present application further provides a model processing apparatus, which can be integrated in an electronic device, which can be a terminal and / or a server.
[0086] For example, as shown in Figure 5 Fig. 1 is a structural schematic diagram of a model processing apparatus provided by the embodiment of the present application, which can include a first determination unit 201, an acquisition unit 202, a calculation unit 203, a second determination unit 204, an adjustment unit 205 and a rendering unit 206, as follows:
[0087] The first determining unit 201 is configured to determine first position information to which a specified position of the target model needs to be scaled in response to a scaling operation on the target model.
[0088] The obtaining unit 202 is configured to obtain vertex color information of a vertex in the target model, the vertex color information comprising a first channel value and a second channel value, the first channel value indicating a same first distance that the vertex needs to maintain before and after scaling with the specified position, and the second channel value indicating a tiling mode configured for the vertex.
[0089] The calculating unit 203 is configured to calculate second position information to which the vertex in the target model needs to be scaled based on the scaling operation based on the first distance and the first position information.
[0090] The second determining unit 204 is configured to determine a texture tiling rate of the vertex based on initial position information of the vertex before scaling, the second position information, and the second channel value if the second channel value indicates that the vertex is configured in a first tiling mode, and otherwise determine the texture tiling rate of the vertex as 1.
[0091] The adjusting unit 205 is configured to adjust texture UV information of the vertex of the target model based on the texture tiling rate to obtain first target texture UV information.
[0092] The rendering unit 206 is configured to render the target model based on the first target texture UV information and the second position information to obtain a scaled target model.
[0093] In some embodiments, the adjusting unit 205 is configured to:
[0094] obtain texture UV information corresponding to the vertex of the target model;
[0095] calculate a product of the texture UV information corresponding to the vertex and the texture tiling rate to obtain first target texture UV information corresponding to the vertex.
[0096] In some embodiments, the second determining unit 204 comprises:
[0097] a position obtaining sub-unit configured to obtain initial position information of the vertex before scaling of the target model;
[0098] a scaling multiple calculating sub-unit configured to calculate a scaling multiple corresponding to the scaling operation based on the second position information corresponding to the vertex and the initial position information;
[0099] a texture tiling rate determining sub-unit configured to determine the texture tiling rate corresponding to the vertex based on the second channel value and the scaling multiple, wherein the texture tiling rate of the vertex is determined as the scaling multiple if the second channel value indicates that the vertex is configured in the first tiling mode, and otherwise the texture tiling rate of the vertex is determined as 1.
[0100] In some embodiments, the second channel value comprises a first value or a second value, the first value indicating that the vertex is configured as the first tiling mode, and the second value indicating that the vertex is configured as the second tiling mode, the texture tiling rate determination subunit is configured to:
[0101] obtain a texture tiling rate determination function;
[0102] determine, based on the second channel value and the scaling multiple, the texture tiling rate corresponding to the vertex by using the texture tiling rate determination function, wherein if the second channel value is the first value, the texture tiling rate corresponding to the vertex is determined as the scaling multiple, and if the second channel value is the second value, the texture tiling rate corresponding to the vertex is determined as 1.
[0103] In some embodiments, the calculation unit 203 is configured to:
[0104] obtain a coordinate value in the first position information corresponding to a scaling direction of the scaling operation;
[0105] calculate a scaling coordinate value based on the coordinate value and the first distance;
[0106] obtain, based on the scaling coordinate value and initial position information of the vertex, second position information of the vertex to which the vertex needs to be scaled based on the scaling operation.
[0107] In some embodiments, the specified position comprises an edge position or a center position of the target model.
[0108] In some embodiments, the model processing apparatus further comprises:
[0109] a parameter obtaining unit configured to obtain an offset parameter, a value of the offset parameter changing over time;
[0110] a UV determination unit configured to determine, based on the first target texture UV information and the offset parameter, second target texture UV information of the vertex;
[0111] the rendering unit 206 is configured to:
[0112] render the target model based on the second target texture UV information and the second position information to obtain a scaled target model, and the texture of the target model changes in a scrolling manner.
[0113] In some embodiments, the vertex color information of the vertex further comprises a third channel value, the third channel value indicating whether the vertex is configured with a texture scrolling effect, and the UV determination unit is configured to:
[0114] determine, based on the third channel value of the vertex, whether the vertex is configured with the texture scrolling effect;
[0115] If the vertex is configured with the texture scrolling effect, the first target texture UV information and the offset parameter of the vertex are summed to obtain the second target texture UV information of the vertex.
[0116] If the vertex is not configured with the texture scrolling effect, the first target texture UV information of the vertex is determined as the second target texture UV information of the vertex.
[0117] In the implementation, each of the units can be implemented as an independent entity, or can be combined as the same or several entities, and the specific implementation of each of the units can refer to the method embodiments above, which will not be described here again.
[0118] From the above, the embodiment of the application determines, by the first determining unit 201, the first position information to which the specified position of the target model needs to be scaled in response to the scaling operation on the target model; the obtaining unit 202 obtains the vertex color information of the vertex in the target model, the vertex color information including a first channel value and a second channel value, the first channel value indicating a same first distance that the vertex and the specified position need to maintain before and after scaling, and the second channel value indicating a tiling mode configured for the vertex; the calculating unit 203 calculates, based on the first distance and the first position information, the second position information to which the vertex in the target model needs to be scaled based on the scaling operation; the second determining unit 204 determines, if the second channel value indicates that the vertex is configured as the first tiling mode, a texture tiling rate of the vertex based on the initial position information of the vertex before scaling, the second position information, and the second channel value, and otherwise determines the texture tiling rate of the vertex as 1; the adjusting unit 205 adjusts the texture UV information of the vertex of the target model based on the texture tiling rate to obtain first target texture UV information; and the rendering unit 206 renders the target model based on the first target texture UV information and the second position information to obtain the scaled target model. In this way, by determining, according to the vertex color information of the vertex in the target model, the first distance that the vertex and the specified position need to maintain before and after scaling and the tiling mode configured for the vertex, the second position information to which the vertex in the target model needs to be scaled is calculated according to the first distance and the position to which the specified position of the target model needs to be scaled after scaling, and the texture tiling rate of the vertex is determined according to the tiling mode configured for the vertex, and the original texture UV information is adjusted to obtain the first target texture UV information, so that the position to which the vertex in the target model needs to be moved based on the scaling operation can be determined based on the second position information of the vertex, the region that needs to be scaled can be adaptively tiled based on the texture tiling rate based on the first target texture UV information, stretching of the texture of the model in the scaling process is avoided, the target model that is adaptively scaled and whose texture is not stretched based on the scaling operation can be obtained based on the first target texture UV information and the second position information, performance problems caused by implementation of the model scaling effect through multiple rendering are avoided, and the model scaling efficiency is effectively improved.
[0119] The embodiment of the application also provides an electronic device, as shown in the accompanying drawings, which shows a structural schematic diagram of the electronic device related to the embodiment of the application. The electronic device can be a terminal or a server, and specifically: Figure 6
[0120] 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 on the memory 302 and executable on the processor. The processor 301 is electrically connected to the memory 302. Those skilled in the art can understand that the electronic device structure shown in the figure does not constitute a limitation on the electronic device, and can include more or fewer components than shown, or combine certain components, or different component arrangements.
[0121] The processor 301 is the control center of the electronic device 300, and connects various parts of the entire electronic device 300 through various interfaces and lines, executes various functions and processes data of the electronic device 300 by running or loading software programs and / or modules stored in the memory 302, and calling data stored in the memory 302, thereby overall monitoring the electronic device 300.
[0122] In the embodiments of the present application, the processor 301 in the electronic device 300 will load the instructions corresponding to the processes of one or more application programs into the memory 302, and run the application programs stored in the memory 302 by the processor 301, thereby realizing various functions according to the following steps:
[0123] In response to the scaling operation on the target model, the first position information to which the specified position of the target model needs to be scaled is determined;
[0124] The vertex color information of the vertex in the target model is obtained, and the vertex color information includes a first channel value and a second channel value. The first channel value indicates that the vertex needs to maintain the same first distance before and after scaling with the specified position, and the second channel value indicates the tiling mode configured for the vertex;
[0125] Based on the first distance and the first position information, the second position information to which the vertex in the target model needs to be scaled based on the scaling operation is calculated;
[0126] If the second channel value indicates that the vertex is configured in the first tiling mode, the texture tiling rate of the vertex is determined based on the initial position information of the vertex before scaling, the second position information, and the second channel value, otherwise the texture tiling rate of the vertex is determined as 1;
[0127] The texture UV information of the vertex of the target model is adjusted based on the texture tiling rate to obtain first target texture UV information;
[0128] The target model is rendered based on the first target texture UV information and the second position information to obtain the scaled target model.
[0129] This solution can determine the first position information to which a specified position of the target model needs to be scaled in response to a scaling operation on the target model; obtain the vertex color information of the vertices in the target model, which includes a first channel value and a second channel value. The first channel value indicates the same first distance that the vertex and the specified position need to maintain before and after scaling, and the second channel value indicates the tiling mode configured for the vertex; calculate the second position information to which the vertices in the target model need to be scaled based on the first distance and the first position information; if the second channel value indicates that the vertex is configured in the first tiling mode, determine the texture tiling rate of the vertex based on the initial position information of the vertex before scaling, the second position information, and the second channel value; otherwise, determine the texture tiling rate of the vertex to be 1; adjust the texture UV information of the vertices of the target model based on the texture tiling rate to obtain the first target texture UV information; render the target model based on the first target texture UV information and the second position information to obtain the scaled target model. Therefore, by determining the first distance that the vertex in the target model needs to maintain before and after scaling, and the tiling mode configured for the vertex, based on the vertex color information of the vertex in the target model, the second position information that the vertex in the target model needs to be scaled to is calculated based on the first distance and the position that the specified position in the target model needs to be scaled to after scaling. Based on the tiling mode configured for the vertex, the texture tiling rate of the vertex is determined and the original texture UV information is adjusted to obtain the first target texture UV information. Based on the second position information of the vertex, the position that the vertex in the target model needs to move to based on the scaling operation can be determined. Based on the first target texture UV information, the texture tiling of the area to be scaled can be adaptively performed based on the texture tiling rate, avoiding stretching of the model texture during scaling. Rendering the target model based on the first target texture UV information and the second position information can obtain a scaled target model that is adaptively scaled based on the scaling operation and whose texture is not stretched, avoiding the performance problems caused by achieving the model scaling effect through multiple renderings, and thus effectively improving the model scaling efficiency.
[0130] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.
[0131] Optional, such as Figure 6 As shown, the electronic device 300 also includes: a touch display 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 display screen 303, the radio frequency circuit 304, the audio circuit 305, the input unit 306, and the power supply 307. Those skilled in the art will understand that... Figure 6 The electronic device structure shown does not constitute a limitation on the electronic device and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0132] The touch display screen 303 can be used to display a graphical user interface and receive operation instructions generated by user acting on the graphical user interface. The touch display screen 303 can include a display panel and a touch panel. 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, which can be composed of graphics, text, icons, video and any combination thereof. Optionally, the display panel can be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), etc. The touch panel can be used to collect touch operations (such as user operations on or near the touch panel using a finger, a stylus or any suitable object or accessory) of the user thereon or therearound, and generate corresponding operation instructions, and the operation instructions execute corresponding programs. Optionally, the touch panel can include two parts of a touch detection device and a touch controller. The touch detection device detects the touch position of the user and detects signals caused by the touch operation, and transmits the signals to the touch controller; the touch controller receives the touch information from the touch detection device, and converts it into touch coordinates, and then sends it to the processor 301, and can also receive commands from the processor 301 and execute them. The touch panel can cover the display panel, and when the touch panel detects a touch operation thereon or therearound, it transmits to the processor 301 to determine the type of touch event, and then the processor 301 provides corresponding visual output on the display panel according to the type of touch event. In the embodiments 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 realize the input and output functions as two independent components. That is, the touch display screen 303 can also realize the input function as part of the input unit 306.
[0133] The radio frequency circuit 304 can be used to transceive radio frequency signals to establish wireless communication with network devices or other electronic devices, and transceive signals between network devices or other electronic devices.
[0134] 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 convert the received audio data into an electrical signal and transmit the electrical signal to the speaker for conversion into an audible signal output by the speaker. On the other hand, the microphone collects a sound signal and converts the sound signal into an electrical signal, which is received by the audio circuit 305 and converted into audio data. The audio data is output to the processor 301 for processing, and then transmitted to another electronic device via the radio frequency circuit 304, or output to the memory 302 for further processing. The audio circuit 305 can also include a headphone jack to provide communication between an external device and the electronic device.
[0135] The input unit 306 can be used to receive input digital, character information or user feature information (such as fingerprint, iris, face information, etc.), and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.
[0136] 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 be used to manage charging, discharging and power consumption management, etc. The power supply 307 can also include one or more direct current or alternating current power supplies, recharging systems, power failure detection circuits, power converters or inverters, power status indicators, etc.
[0137] Although Figure 6 The electronic device 300 can also include a camera, a sensor, a wireless fidelity module, a Bluetooth module, etc., which are not shown in the embodiment.
[0138] In the above embodiments, the description of each embodiment has its own focus, and the parts not described in detail in a certain embodiment can be referred to the related description of other embodiments. It should be noted that the electronic device provided by the embodiments of the present application and the model processing method suitable for the above embodiments belong to the same concept, and the specific implementation process is described in detail in the above method embodiments, which will not be repeated here.
[0139] As can be seen from the above, the electronic device provided in this application embodiment can, in response to a scaling operation on a target model, determine the first position information to which a specified position of the target model needs to be scaled; obtain the vertex color information of the vertices in the target model, the vertex color information including a first channel value and a second channel value, the first channel value indicating the same first distance that the vertex and the specified position need to maintain before and after scaling, and the second channel value indicating the tiling mode configured for the vertex; calculate the second position information to which the vertices in the target model need to be scaled based on the first distance and the first position information; if the second channel value indicates that the vertex is configured in the first tiling mode, determine the texture tiling rate of the vertex based on the initial position information of the vertex before scaling, the second position information, and the second channel value; otherwise, determine that the texture tiling rate of the vertex is 1; adjust the texture UV information of the vertices of the target model based on the texture tiling rate to obtain the first target texture UV information; and render the target model based on the first target texture UV information and the second position information to obtain the scaled target model. Therefore, by determining the first distance that the vertex in the target model needs to maintain before and after scaling, and the tiling mode configured for the vertex, based on the vertex color information of the vertex in the target model, the second position information that the vertex in the target model needs to be scaled to is calculated based on the first distance and the position that the specified position in the target model needs to be scaled to after scaling. Based on the tiling mode configured for the vertex, the texture tiling rate of the vertex is determined and the original texture UV information is adjusted to obtain the first target texture UV information. Based on the second position information of the vertex, the position that the vertex in the target model needs to move to based on the scaling operation can be determined. Based on the first target texture UV information, the texture tiling of the area to be scaled can be adaptively performed based on the texture tiling rate, avoiding stretching of the model texture during scaling. Rendering the target model based on the first target texture UV information and the second position information can obtain a scaled target model that is adaptively scaled based on the scaling operation and whose texture is not stretched, avoiding the performance problems caused by achieving the model scaling effect through multiple renderings, and thus effectively improving the model scaling efficiency.
[0140] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be performed by a computer program, or by a computer program controlling related hardware. The computer program can be stored in a computer-readable storage medium and loaded and executed by a processor.
[0141] Therefore, embodiments of this application provide a computer-readable storage medium storing a computer program that can be loaded by a processor to execute the steps in any of the model processing methods provided in embodiments of this application. For example, the computer program can execute the following steps:
[0142] In response to the scaling operation on the target model, first position information to which a specified position of the target model needs to be scaled is determined;
[0143] Vertex color information of a vertex in the target model is acquired, the vertex color information comprising a first channel value and a second channel value, the first channel value indicating a same first distance that the vertex needs to maintain before and after scaling with the specified position, and the second channel value indicating a tiling mode configured for the vertex;
[0144] Based on the first distance and the first position information, second position information to which the vertex in the target model needs to be scaled based on the scaling operation is calculated;
[0145] If the second channel value indicates that the vertex is configured in the first tiling mode, a texture tiling rate of the vertex is determined based on initial position information of the vertex before scaling, the second position information, and the second channel value, otherwise the texture tiling rate of the vertex is determined as 1;
[0146] Texture UV information of the vertex of the target model is adjusted based on the texture tiling rate to obtain first target texture UV information;
[0147] The target model is rendered based on the first target texture UV information and the second position information to obtain a scaled target model.
[0148] The scheme can determine first position information to which a specified position of a target model needs to be scaled in response to a scaling operation on the target model; obtain vertex color information of a vertex in the target model, the vertex color information including a first channel value and a second channel value, the first channel value indicating a same first distance that the vertex and the specified position need to maintain before and after scaling, and the second channel value indicating a tiling mode configured for the vertex; calculate second position information to which the vertex in the target model needs to be scaled based on the scaling operation based on the first distance and the first position information; if the second channel value indicates that the vertex is configured in a first tiling mode, determine a texture tiling rate of the vertex based on initial position information of the vertex before scaling, the second position information, and the second channel value, or otherwise determine the texture tiling rate of the vertex as 1; adjust texture UV information of the vertex of the target model based on the texture tiling rate to obtain first target texture UV information; and render the target model based on the first target texture UV information and the second position information to obtain a scaled target model. In this way, by determining the first distance that the vertex in the target model and the specified position need to maintain before and after scaling and the tiling mode configured for the vertex according to the vertex color information of the vertex in the target model, the second position information to which the vertex in the target model needs to be scaled is calculated according to the first distance and the position to which the specified position of the target model needs to be scaled after scaling, and the texture tiling rate of the vertex is determined according to the tiling mode configured for the vertex, and the original texture UV information is adjusted to obtain the first target texture UV information. In this way, the position to which the vertex in the target model needs to be moved based on the scaling operation can be determined based on the second position information of the vertex, adaptive texture tiling can be performed on the region that needs to be scaled based on the first target texture UV information based on the texture tiling rate, stretching of the texture of the model in the scaling process is avoided, the target model that is adaptively scaled and whose texture is not stretched based on the scaling operation can be obtained based on the rendering of the target model based on the first target texture UV information and the second position information, performance problems caused by the implementation of the model scaling effect through multiple renderings are avoided, and the model scaling efficiency is effectively improved.
[0149] The specific implementation of each operation can be referred to the foregoing embodiments, which will not be described herein.
[0150] The computer readable storage medium can include a read only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0151] The computer program stored in the computer readable storage medium can execute the steps of any model processing method provided in the embodiments of the present application, and thus can achieve the beneficial effects of any model processing method provided in the embodiments of the present application. Details are described in the foregoing embodiments, which will not be described herein.
[0152] According to an aspect of the present application, there is provided a computer program product comprising a computer program 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 method provided in various optional implementation manners provided by the above embodiments.
[0153] The above describes in detail the model processing method, device, storage medium and electronic device provided by the embodiments of the present application. The principles and implementation manners of the present application are described by applying specific examples. The above embodiment descriptions are only used to help understand the method of the present application and its core idea. Meanwhile, for those skilled in the art, the specific implementation manners and application ranges can be changed according to the idea of the present application. In summary, the content of the specification should not be understood as limiting the present application.
Claims
1. A model processing method characterized by comprising: The method comprises: in response to a scaling operation on a target model, determining first position information to which a specified position of the target model needs to be scaled; obtaining vertex color information of a vertex in the target model, the vertex color information comprising a first channel value and a second channel value, the first channel value indicating that the vertex needs to maintain a same first distance with the specified position before and after scaling, and the second channel value indicating a tiling mode configured for the vertex; based on the first distance and the first position information, calculating second position information to which the vertex in the target model needs to be scaled based on the scaling operation; if the second channel value indicates that the vertex is configured in a first tiling mode, determining a texture tiling rate of the vertex based on initial position information of the vertex before scaling, the second position information, and the second channel value, otherwise determining the texture tiling rate of the vertex as 1; adjusting texture UV information of the vertex of the target model based on the texture tiling rate to obtain first target texture UV information; rendering the target model based on the first target texture UV information and the second position information to obtain a scaled target model.
2. The model processing method of claim 1, wherein, The adjusting of the texture UV information of the vertex of the target model based on the texture tiling rate to obtain first target texture UV information comprises: obtaining texture UV information corresponding to the vertex of the target model; calculating a product of the texture UV information corresponding to the vertex and the texture tiling rate to obtain first target texture UV information corresponding to the vertex.
3. The model processing method of claim 1, wherein, The determining of the texture tiling rate of the vertex based on the initial position information of the vertex before scaling, the second position information, and the second channel value if the second channel value indicates that the vertex is configured in a first tiling mode, otherwise determining the texture tiling rate of the vertex as 1, comprises: obtaining initial position information of the vertex before scaling of the target model; based on the second position information corresponding to the vertex and the initial position information, calculating a scaling multiple corresponding to the scaling operation; based on the second channel value and the scaling multiple, determining the texture tiling rate corresponding to the vertex, wherein if the second channel value indicates that the vertex is configured in a first tiling mode, determining the texture tiling rate of the vertex as the scaling multiple, otherwise determining the texture tiling rate of the vertex as 1.
4. The model processing method of claim 3, wherein, The second channel value comprises a first numerical value or a second numerical value, the first numerical value indicating that the vertex is configured in a first tiling mode, and the second numerical value indicating that the vertex is configured in a second tiling mode, and the determining of the texture tiling rate corresponding to the vertex based on the second channel value and the scaling multiple comprises: obtaining a texture tiling rate determination function; based on the second channel value and the scaling multiple, determining the texture tiling rate corresponding to the vertex through the texture tiling rate determination function, wherein if the second channel value is the first numerical value, determining the texture tiling rate corresponding to the vertex as the scaling multiple, and if the second channel value is the second numerical value, determining the texture tiling rate corresponding to the vertex as 1.
5. The model processing method of claim 1, wherein, The calculating, based on the first distance and the first position information, of second position information to which the vertex in the target model needs to be scaled based on the scaling operation comprises: obtaining a coordinate value corresponding to a scaling direction of the scaling operation in the first position information; calculating a scaling coordinate value based on the coordinate value and the first distance; obtaining the second position information to which the vertex needs to be scaled based on the scaling operation based on the scaling coordinate value and initial position information of the vertex.
6. The model processing method of claim 1, wherein, The specified position comprises an edge position or a center position of the target model.
7. The model processing method according to any one of claims 1 to 6, wherein Before the rendering of the target model based on the first target texture UV information and the second position information to obtain a scaled target model, the method further comprises: obtaining an offset parameter, a value of the offset parameter changing over time; determining second target texture UV information of the vertex based on the first target texture UV information and the offset parameter; The rendering of the target model based on the first target texture UV information and the second position information to obtain a scaled target model comprises: rendering the target model based on the second target texture UV information and the second position information to obtain a scaled target model, texture scrolling changing on the target model.
8. The model processing method of claim 7, wherein, The vertex color information of the vertex further comprises a third channel value, the third channel value indicating whether the vertex is configured with a texture scrolling effect, and the determining of the second target texture UV information of the vertex based on the first target texture UV information and the offset parameter comprises: determining, based on the third channel value of the vertex, whether the vertex is configured with a texture scrolling effect; if the vertex is configured with a texture scrolling effect, summing the first target texture UV information of the vertex and the offset parameter to obtain the second target texture UV information of the vertex; if the vertex is not configured with a texture scrolling effect, determining the first target texture UV information of the vertex as the second target texture UV information of the vertex.
9. A model processing apparatus characterized by comprising: comprise: a first determining unit configured to determine, in response to a scaling operation on a target model, first position information to which a specified position of the target model needs to be scaled; an obtaining unit configured to obtain vertex color information of a vertex in the target model, the vertex color information comprising a first channel value and a second channel value, the first channel value indicating a same first distance that the vertex and the specified position need to maintain before and after scaling, and the second channel value indicating a tiling mode configured for the vertex; a calculating unit configured to calculate, based on the first distance and the first position information, second position information to which the vertex in the target model needs to be scaled based on the scaling operation; a second determining unit configured to determine, based on initial position information of the vertex before scaling, the second position information, and the second channel value, a texture tiling rate of the vertex if the second channel value indicates that the vertex is configured as a first tiling mode, and otherwise determine the texture tiling rate of the vertex as 1. An adjusting unit is configured to adjust texture UV information of a vertex of the target model based on the texture tiling rate, to obtain first target texture UV information. A rendering unit is configured to render the target model based on the first target texture UV information and the second position information, to obtain a scaled target model.
10. An electronic device, comprising: The device 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 is caused to execute the steps of the method in any one of claims 1-8.
11. A computer readable storage medium, characterized in that, The device comprises a computer program, and when the computer program is executed on an electronic device, the computer program is used to cause the electronic device to execute the steps of the method in any one of claims 1-8.
Citation Information
Patent Citations
Target model rendering method and device, equipment and storage medium
CN113947657A
Decorative effect rendering method and device and electronic equipment
CN116245991A