Model rendering method, apparatus, and electronic device
Patent Information
- Application Number
- CN202211440430.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-17
- Publication Date
- 2026-10-30
- Estimated Expiration
- 2042-11-17
AI Technical Summary
但是顶点动画的流畅度和效果,与顶点动画复杂度、模型顶点数成正相关;同时顶点动画需要消耗大量的模型材质性能,导致手游无法通过顶点动画实现模型全息错位效果
[0009]本发明提供的一种模型渲染方法、装置和电子设备,首先获取待渲染模型;进而对待渲染模型进行遮罩处理,得到遮罩模型,该遮罩模型用于模拟所述待渲染模型的全息错位效果;然后基于预设的偏移参数,将遮罩模型嵌套在待渲染模型上,并控制遮罩模型在待渲染模型上移动,得到具有全息错位效果的目标模型。该方式中,使用两层模型嵌套来制作出一种假的单个模型全息错位效果,可让待渲染模型拥有全息错位效果,且由于是遮罩模型是立体的,则全息错位效果也是立体的,而非单薄的面片错位,从而提高了模型全息错位效果的质量;同时,该方式相对顶点动画的方式性能消耗较少,可在手游端实现模型全息错位效果。
Smart Images

Figure CN115937362B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of model processing technology, and in particular to a model rendering method, apparatus, and electronic device. Background Technology
[0002] In related technologies, vertex animation is commonly used to achieve holographic misalignment effects on models. This vertex animation is a per-vertex model stretching and displacement animation, causing each vertex of the model to move according to a pattern or an input distance, thus creating a concave-convex motion on the model's surface. However, the smoothness and effect of vertex animation are positively correlated with the complexity of the vertex animation and the number of vertices in the model; at the same time, vertex animation consumes a lot of model material performance, making it impossible for mobile games to achieve holographic misalignment effects on models through vertex animation. Summary of the Invention
[0003] The purpose of this invention is to provide a model rendering method, apparatus, and electronic device that achieves model holographic misalignment effects with lower performance consumption and improves the quality of model holographic misalignment effects.
[0004] In a first aspect, the present invention provides a model rendering method, the method comprising: obtaining a model to be rendered; performing a masking process on the model to be rendered to obtain a masked model; wherein the masked model is used to simulate the holographic misalignment effect of the model to be rendered; based on a preset offset parameter, nesting the masked model on the model to be rendered, and controlling the masked model to move on the model to be rendered to obtain a target model with a holographic misalignment effect.
[0005] Secondly, the present invention provides a model rendering apparatus, the apparatus comprising: a model acquisition module for acquiring a model to be rendered; a masking processing module for performing masking processing on the model to be rendered to obtain a masked model; wherein the masked model is used to simulate the holographic misalignment effect of the model to be rendered; and a model nesting module for nesting the masked model on the model to be rendered based on preset offset parameters, and controlling the masked model to move on the model to be rendered to obtain a target model with a holographic misalignment effect.
[0006] Thirdly, the present invention provides an electronic device including a processor and a memory, the memory storing machine-executable instructions that can be executed by the processor, the processor executing the machine-executable instructions to implement the above-described model rendering method.
[0007] Fourthly, the present invention provides a computer-readable storage medium storing computer-executable instructions, which, when invoked and executed by a processor, cause the processor to implement the above-described model rendering method.
[0008] The embodiments of the present invention bring the following beneficial effects:
[0009] This invention provides a model rendering method, apparatus, and electronic device. First, a model to be rendered is acquired. Then, a masking process is performed on the model to be rendered to obtain a masked model, which is used to simulate the holographic misalignment effect of the model to be rendered. Next, based on preset offset parameters, the masked model is nested on the model to be rendered, and the movement of the masked model on the model to be rendered is controlled to obtain a target model with a holographic misalignment effect. In this method, two layers of nested models are used to create a fake single-model holographic misalignment effect, allowing the model to be rendered to have a holographic misalignment effect. Since the masked model is three-dimensional, the holographic misalignment effect is also three-dimensional, rather than a thin, flat misalignment, thus improving the quality of the model's holographic misalignment effect. At the same time, this method consumes less performance compared to vertex animation, and can implement the model holographic misalignment effect on mobile games.
[0010] Other features and advantages of the invention will be set forth in the following description, or some features and advantages may be inferred from the description or determined without doubt, or may be learned by practicing the techniques described above.
[0011] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description
[0012] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0013] Figure 1 A flowchart of a model rendering method provided in an embodiment of the present invention;
[0014] Figure 2 A schematic diagram of model rendering provided in an embodiment of the present invention;
[0015] Figure 3 A flowchart of another model rendering method provided in an embodiment of the present invention;
[0016] Figure 4 A flowchart for determining offset parameters is provided in an embodiment of the present invention;
[0017] Figure 5 A flowchart of another model rendering method provided in an embodiment of the present invention;
[0018] Figure 6This is a schematic diagram illustrating a misalignment fault effect provided in an embodiment of the present invention;
[0019] Figure 7 This is a schematic diagram of the structure of a model rendering device provided in an embodiment of the present invention;
[0020] Figure 8 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0021] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. The components of the embodiments of the present invention described and shown in the accompanying drawings can generally be arranged and designed in various different configurations.
[0022] Therefore, the following detailed description of the embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the invention without inventive effort are within the scope of protection of the invention.
[0023] The related technologies provide three methods for achieving the model misalignment and screen flickering effect:
[0024] The first method involves outputting a sequence of frames using frame-by-frame animation. Then, a general algorithm is used to play the sequence of frames using a flip-book effect. During playback, a billboard effect (a material where the model's facets always face the camera) and a misaligned offset masking effect are added to generate a misaligned splash screen effect. This method essentially achieves the desired effect, but it cannot be based on a model. It's essentially still an image-based splash screen mode, but played through a sequence of frames (typically representing video as individual image files) and featuring the billboard effect to create the illusion of a holographic model. If the number of model frames is large, the resulting textures will be very blurry, and the overall art quality will not meet expectations.
[0025] The second type is a single-image misaligned splash screen effect. The difference between this and the first type, the sequence frame animation misaligned splash screen effect, is that it does not use a sequence of frames; it only uses a single image. However, the single-image misaligned splash screen effect can also be understood as a single-frame image (one frame in the first type). It also uses the billboard effect, but when the viewpoint is moved, it becomes clear that it is a single image, rather than a model effect.
[0026] The second method involves achieving a holographic misalignment effect through vertex animation. This vertex animation is a per-vertex model stretching and displacement animation, causing each vertex of the model to move according to a pattern or an input distance, thus creating a bumpy or concave surface on the model. However, the smoothness and effect of vertex animation are directly proportional to its complexity and the number of vertices in the model. Furthermore, vertex animation consumes significant amounts of model material performance, making it impossible to achieve a holographic misalignment effect on mobile games using vertex animation.
[0027] To address the aforementioned issues, embodiments of the present invention provide a model rendering method, apparatus, and electronic device. This technology can be applied to various model rendering scenarios, especially in scenarios where holographic misalignment effects are rendered.
[0028] To facilitate understanding of the embodiments of the present invention, a model rendering method disclosed in the embodiments of the present invention will first be described in detail, such as... Figure 1 As shown, the method includes the following specific steps:
[0029] Step S102: Obtain the model to be rendered.
[0030] The model to be rendered can be any model drawn using model-making software, or it can be a model transferred from a preset model storage file. This model is typically a three-dimensional model, and its color and material can be set according to development needs. In practical applications, to save performance and ensure that the model rendering method can be implemented on mobile devices, the model can be set to a self-illuminating material model. This self-illuminating material model is usually a lighting model that only displays the image and does not have any lighting or shadow effects; it is the most performance-efficient basic material model.
[0031] Step S104: Perform masking processing on the above-mentioned model to be rendered to obtain a masked model; wherein, the masked model is used to simulate the holographic misalignment effect of the model to be rendered.
[0032] In practical implementation, the above masking process can be implemented by using a preset mask image to mask the model to be rendered, or by using a stripe image to mask the model to be rendered, or by using a preset masking mode set in the game engine, or other masking methods, which are not specifically limited here. Specifically, the above preset masking mode can be: the transparent parts of the output model are cut like a masking effect, rather than a semi-transparent transition effect.
[0033] The aforementioned holographic misalignment effect refers to the misalignment effect of three-dimensional, non-thin surfaces in a 3D model. Here, misalignment means that the shape of the 3D model appears somewhat displaced in 3D space. It should be noted that the holographic misalignment effect referred to in this invention is based on a performance effect implemented in a game. For example... Figure 2 The image on the left is a model with a holographic misalignment effect.
[0034] Step S106: Based on preset offset parameters, the mask model is nested on the model to be rendered, and the mask model is controlled to move on the model to be rendered to obtain a target model with holographic misalignment effect.
[0035] The aforementioned offset parameters can be user-defined or determined based on a preset loop curve and preset offset values. These offset parameters indicate the offset movement pattern of the mask model as it moves on the model to be rendered after the mask model is nested on top of it. When the mask model moves on the model to be rendered according to the offset movement pattern indicated by the offset parameters, a holographic misalignment effect can be achieved. For example... Figure 2 The diagram shown is a schematic representation of a model rendering method provided in an embodiment of the present invention. Figure 2 The candy model in the middle is the model to be rendered. Figure 2 The image on the right is a mask model, which is the model after a portion of the model to be rendered has been masked. Figure 2 The image on the left is the target model with a holographic misalignment effect. This target model is the effect of a mask model nested on the model to be rendered. The mask model can move irregularly up, down, left, and right on the outer layer of the model to be rendered, thereby achieving the holographic misalignment effect of the model.
[0036] This invention provides a model rendering method. First, a model to be rendered is obtained. Then, a masking process is performed on the model to be rendered to obtain a masked model, which is used to simulate the holographic misalignment effect of the model to be rendered. Next, based on preset offset parameters, the masked model is nested on the model to be rendered, and the masked model is controlled to move on the model to be rendered, resulting in a target model with a holographic misalignment effect. In this method, two layers of nested models are used to create a fake single-model holographic misalignment effect, allowing the model to be rendered to have a holographic misalignment effect. Since the masked model is three-dimensional, the holographic misalignment effect is also three-dimensional, rather than a thin, flat misalignment, thus improving the quality of the model's holographic misalignment effect. Simultaneously, this method consumes less performance compared to vertex animation and can implement the model holographic misalignment effect on mobile games.
[0037] This invention also provides another model rendering method, which is implemented based on the above embodiments. This method focuses on describing the specific process of nesting a mask model on the model to be rendered based on preset offset parameters, and controlling the movement of the mask model on the model to be rendered to obtain a target model with a holographic misalignment effect (specifically implemented through steps S306-S308 below); such as Figure 3 As shown, the method includes the following specific steps:
[0038] Step S302: Obtain the model to be rendered.
[0039] Step S304: Perform masking processing on the above-mentioned model to be rendered to obtain a masked model; wherein, the masked model is used to simulate the holographic misalignment effect of the model to be rendered.
[0040] Step S306: Link the preset offset parameters to the material panel of the model to be rendered.
[0041] In practical implementation, the above offset parameters can be determined through the following steps 10-12:
[0042] Step 10: The preset cycle curve is cyclically adjusted using preset time parameters to obtain the processing result.
[0043] The aforementioned preset time parameter is set according to user requirements. This preset time parameter is used to control the flow rate of the preset circulation curve; the aforementioned preset circulation curve can be a sin curve or a cos curve, etc. Specifically, step 10 can be achieved through the following steps 20-22:
[0044] Step 20: Call the preset loop curve using preset time parameters.
[0045] Step 21: Perform trigonometric operations on the preset cycle curve to obtain a trigonometric curve. This trigonometric operation can be a sine operation, a cosine operation, or a tangent operation, etc. Specifically, perform a sine operation on the preset cycle curve to obtain a sine curve; perform a pre-calculation on the preset cycle curve to obtain a cosine curve; and perform a tangent operation on the preset cycle curve to obtain a tangent curve.
[0046] Step 22: Determine the absolute value of the sine curve as the processing result.
[0047] For ease of understanding of the embodiments of the present invention, such as Figure 4 The diagram shown is a flowchart of an offset parameter determination method provided by an embodiment of the present invention. Figure 4 The Time node continuously calculates time, causing it to flow. The Time-trans node controls the flow rate of time, thus controlling the speed of the loop curve. Multiplying the outputs of the Time and Time-trans nodes (equivalent to inputting their outputs into the Multiply node) yields a preset time parameter. Then, the preset loop curve is invoked using this parameter, and a sine calculation is performed on it. This is equivalent to inputting the preset loop curve into the Sine node, which outputs a sine curve. Finally, the sine curve is input into the Abs node to obtain its absolute value. This absolute value is used as the processing result, which can be 0-1, 1-0, 0-1, etc.
[0048] Step 11: Map the above processing results to the preset curve spectrum to obtain the curve regularity parameters.
[0049] In practice, the processing result is input into a Curve node containing a preset curve graph to map the processing result to the preset curve graph, thus obtaining curve pattern parameters. This preset curve graph can be custom-edited by artists within the game engine; artists can create any curve using the curve graph tool. During mapping, the preset curve graph can be input as 0-1 from the processing result, outputting the corresponding curve value. This curve value is the artist-defined pattern offset value, also known as the curve pattern parameter.
[0050] In practical applications, after obtaining the curve pattern parameters, these parameters can be converted to a specified numerical range to obtain the final curve pattern parameters. The specified numerical range can be set according to research and development needs; for example, it can be a range of 0-1, or a range of 0-2, etc. Figure 4 As shown, after obtaining the curve pattern parameters, the curve pattern parameters can be input into the Saturate node. The Saturate node will convert the curve pattern parameters to the range of 0-1 to ensure that the final curve pattern parameters are all positive values.
[0051] Step 12: Multiply the above curve pattern parameters by the preset offset value to obtain the offset parameters.
[0052] In practical implementation, the above-mentioned preset offset values are custom vertical and horizontal offset values provided by the artists. These preset offset values can be determined through the following steps 30-32:
[0053] Step 30: Based on the preset axial offset parameter, the axial direction of the coordinate axis of the model to be rendered is transformed into the target axial direction that matches the camera's viewpoint, and the offset value under the target axial direction is obtained.
[0054] Artists adjust the axial offset parameter to obtain the preset offset value. Specifically, the axial offset parameter can be used... Figure 4 The output of the Move_Vertex_Trans node is a 3-channel color value, which controls the overall offset value through the RGB three-channel color control. Based on the axial offset parameter, the model's axis can be transformed to match the target axis that matches the camera's viewpoint, which is also the viewpoint of the viewer. This axial transformation can better represent the offset effect according to the viewer's perspective.
[0055] For example, an axial offset parameter of 1,0,0 means R=1, G=0, B=0. Converting this value to the camera's viewpoint allows control of the axial direction based on the camera's vertical and horizontal orientation. Specifically, an axial offset parameter of 1,0,0 means the model will only cyclically shift to the left and right sides of the camera's viewpoint; 0,1,0 means the model will only cyclically shift to the vertical direction of the camera's viewpoint; and 0,0,1 means the model will only cyclically shift to the front and back directions of the camera's viewpoint.
[0056] Step 31: Invert the downward offset value of the target axis to obtain the first offset value.
[0057] exist Figure 4 In the process, the downward offset value of the target axis is inverted, that is, the downward offset value of the target axis is input into the 1-x node and the inverted result is output. This inverted result is equivalent to the first offset value mentioned above.
[0058] Step 32: Perform linear interpolation on the first offset value and the downward offset value of the target axis to obtain the preset offset value.
[0059] In the specific implementation, the first offset value and the offset value downwards along the target axis are input to the linear interpolation node Lerp, and the preset offset value is output. The Lerp node is designed to allow the model's offset to be randomly inverted after the curve input, making the model misalignment algorithm more natural. The Lerp node takes Alpha0 as input and outputs A, takes Alpha1 as input and outputs B, and takes an intermediate Alpha value (0-1) as input and outputs a mixed AB result. Here, A and B represent the first offset value and the offset value downwards along the target axis input to the Lerp node, respectively.
[0060] Step S308: Using the material panel, the mask model is nested on the model to be rendered, and the movement position of the mask model on the model to be rendered is controlled according to the offset parameter to obtain a target model with holographic misalignment effect.
[0061] The offset parameters in the material panel control the movement of the mask model over time on the model to be rendered, thus creating a target model with a holographic misalignment effect. Specifically, the target model contains the model to be rendered and a mask model nested on the outer layer of the model to be rendered.
[0062] In the actual implementation, since the model to be rendered and the mask model use the same parent material (i.e., a self-illuminating material), and the user wants the mask material to have vertex animation functions such as left and right movement, while the self-illuminating material does not have vertex animation functions, this part adds a Trans switch (Trans is a custom name) to distinguish the desired effects. The Trans switch is used to enable vertex animation displacement effects on one of the two models and disable vertex animation displacement effects on the other. (switch, Trans is the switch parameter; when Trans is true, it removes the True link content; when it is false, it removes 0, no vertex animation displacement parameters.)
[0063] The above model rendering method first obtains the model to be rendered; then, it performs a masking process on the model to be rendered to obtain a masked model; next, it links preset offset parameters to the material panel of the model to be rendered; then, through the material panel, it nests the masked model on the model to be rendered, and controls the movement position of the masked model on the model to be rendered according to the offset parameters, resulting in a target model with a holographic misalignment effect. This method uses two basic models and a mask rendering mode. The mask misalignment shifts the masked part of the model to the left or right to simulate the holographic misalignment effect of the model. At the same time, this method uses the simplest left and right movement algorithm, which is made random by using curves, and the misalignment effect is made more natural according to the camera perspective, so as to maximize the effect and performance of this solution.
[0064] This invention also provides another model rendering method, which is implemented based on the above embodiments. This method focuses on describing the specific process of performing masking processing on the model to be rendered to obtain a masked model (specifically implemented through steps S504-S508 below); such as Figure 5 As shown, the method includes the following specific steps:
[0065] Step S502: Obtain the model to be rendered.
[0066] Step S504: Obtain a preset stripe pattern, and increase the brightness of the preset stripe pattern by a specified value to obtain the first stripe pattern.
[0067] The specific value specified above can be set according to R&D needs; for example, the specified value can be 0.2 or 0.3, etc. The preset stripe pattern can be customized by the artist or obtained based on preset time parameters. In specific implementation, the preset stripe pattern can be achieved through the following steps 40-41:
[0068] Step 40: The screen texture map is moved cyclically by a preset time curve to generate a target texture map with a texture flow effect.
[0069] The aforementioned preset time curve is obtained through the Time node, moving the screen texture map in a cyclical pattern to obtain a target texture map with a texture flow effect. The aforementioned screen texture map typically refers to the screen UVs, that is, the UVs of the screen used to display the model to be rendered. Texture coordinates usually have two axes, U and V, hence the name UV coordinates. U represents the distribution on the horizontal axis, and V represents the distribution on the vertical axis. In 3D modeling, UVs can be understood as the "skin" of a 3D model. The "skin" is unfolded and then drawn on a 2D plane and assigned to the object. The color of an image can be divided into RGB, which stands for Red, Blue, and Green. A colored image can also be divided into three channels: RGB, representing the proportion of red, blue, and green colors. In the engine, UVs only have two channels: red and green. U is the R channel of the UV map, and V is the G channel of the UV map.
[0070] By incorporating a preset time curve into the stripe effect, the masking effect can correspond to the subsequent offset of the masking model, making the masking effect more closely match the custom misalignment effect.
[0071] Step 41: Combine the target texture map above with the preset black and white stripe map to obtain a preset stripe map with a stripe flow effect.
[0072] The black and white striped image above was input by the artists according to their needs. By sampling the black and white striped image using a target texture image with a texture flow effect, the stripes in the black and white striped image can be made to move.
[0073] Step S506: Perform linear interpolation between the preset stripe pattern and the first stripe pattern to obtain the masking pattern.
[0074] In the specific implementation, the preset stripe pattern and the first stripe pattern are input to the linear interpolation node Lerp, and the output is a mask image. Specifically, the Lerp node takes Alpha0 as input and outputs A, takes Alpha1 as input and outputs B, and takes an intermediate value of Alpha (0-1) as input and outputs the AB mixture result, where A and B represent the preset stripe pattern and the first stripe pattern input to the Lerp node, respectively.
[0075] Step S508: Perform masking processing on the model to be rendered using the masking image to obtain the masked model.
[0076] By applying the mask image onto the model to be rendered, a masked model can be obtained.
[0077] Step S510: Based on the preset offset parameters, the mask model is nested on the model to be rendered, and the mask model is controlled to move on the model to be rendered to obtain a target model with holographic misalignment effect.
[0078] Step S512: Perform a dot product operation between the vertex normal direction of the target model and the preset lighting direction to obtain a target model with lighting effects.
[0079] To minimize performance overhead, when using a self-illuminating lighting model for the model to be rendered, it's necessary to add lighting and shadow details, i.e., add lighting and shadow effects. In practice, the Lambert lighting formula can be used to add lighting and shadow effects to the target model. This formula is: vertex normal direction * dot* lighting direction, where *dot* represents the dot product, typically used to calculate the directional difference between two vectors.
[0080] Step S514: Set one or more of the following effects for the target model: specular highlight effect, Fresnel outer layer effect, and misalignment fault effect.
[0081] In practical implementation, to achieve better rendering of the target model, specular effects, Fresnel outer layer effects, and misalignment / fault effects can be applied. The specular effect is achieved by setting the specular effect based on a preset micro-surface distribution function. This micro-surface distribution function is also known as the GGX formula or GGX model. The GGX model is a micro-surface reflection lighting model, which can better represent the dissipation (trailing) effect of metallic specular edges.
[0082] The Fresnel outer layer effect of the above target model can be achieved through the following steps 50-53:
[0083] Step 50: Perform a dot product operation between the vertex normal direction of the target model and the camera direction to obtain the dot product result.
[0084] In practical implementation, the game engine automatically indexes the vertex normal direction and camera direction of the target model. The normal direction refers to a straight line that is always perpendicular to a plane. In geometry, a normal is a line on a plane that is perpendicular to the tangent to a curve at a point; the normal direction is a vector that records the orientation of the normal.
[0085] Step 51: Invert the dot product result to get the inverted result.
[0086] Step 52: Adjust the Fresnel intensity of the inverted result to obtain the adjusted result.
[0087] The magnitude of the Fresnel strength can be set according to research and development needs, and no specific limit is made here.
[0088] Step 53: Multiply the adjustment result by the preset color to obtain the target model with Fresnel outer layer effect.
[0089] The preset colors mentioned above can be colors customized by the artists or the default colors used in the game during the pandemic.
[0090] In practical applications, the above-mentioned misalignment fault effect can be achieved through the following steps 60-62:
[0091] Step 60: Based on the preset displacement parameters, the values corresponding to the three RGB channels of the target model are shifted in different directions.
[0092] In computer graphics, color is composed of RGB (red, green, and blue). Therefore, by sequentially merging the RGB channels (R, G, and B channels) of a normal image (also known as append merging), you can obtain an image that is similar to the original. Figure 1 The same effect can be achieved by misaligning an image vertically, horizontally, and vertically, and then merging them according to their RGB channels. This will create a cyberpunk-style RGB misalignment effect (equivalent to the aforementioned misalignment effect).
[0093] In practice, the above displacement parameters can be set according to the needs of the artists. This unique parameter is used to indicate the displacement offset direction of the three RGB channels respectively.
[0094] Step 61: Multiply the directions of the three RGB channels after displacement by the displacement magnitude parameter to obtain the displacement results for the three RGB channels.
[0095] In practice, the displacement magnitude parameter can be set according to the research and development needs, or it can be set to the default value. This displacement magnitude parameter can also be referred to as the total RGB displacement magnitude parameter.
[0096] Step 62: Merge the displacement results corresponding to the three RGB channels to obtain the target model with misalignment fault effect.
[0097] In practical implementation, merging the displacement results corresponding to the three RGB channels yields a misaligned color effect, a common misalignment / fault effect in holography. For example... Figure 6 The diagram shown illustrates the effect of a misalignment fault.
[0098] The above model rendering method uses two base models and a mask rendering mode. Mask misalignment shifts the masked portion of the model to the left or right to simulate a holographic misalignment effect. To save performance, both layers use self-illuminating lighting models, and then Lambert's formula is used to add lighting and shadow details to the self-illuminating lighting model's materials. This solution achieves the holographic effect desired by designers and artists, while maintaining reasonable performance for mobile games. It is applicable to various holographic effects scenarios, and the two-layer model approach is both innovative and expands the possibilities for material creation.
[0099] Corresponding to the above method embodiments, this invention also provides a model rendering apparatus, such as... Figure 7 As shown, the device includes:
[0100] Model acquisition module 70 is used to acquire the model to be rendered.
[0101] The masking module 71 is used to perform masking processing on the model to be rendered to obtain a masked model; wherein, the masked model is used to simulate the holographic misalignment effect of the model to be rendered.
[0102] The model nesting module 72 is used to nest the mask model on the model to be rendered based on preset offset parameters, and control the mask model to move on the model to be rendered to obtain a target model with holographic misalignment effect.
[0103] The aforementioned model rendering device first acquires the model to be rendered; then, it performs a masking process on the model to be rendered to obtain a masked model, which is used to simulate the holographic misalignment effect of the model to be rendered; then, based on preset offset parameters, the masked model is nested on the model to be rendered, and the movement of the masked model on the model to be rendered is controlled to obtain a target model with a holographic misalignment effect. In this method, two layers of nested models are used to create a fake single-model holographic misalignment effect, allowing the model to be rendered to have a holographic misalignment effect. Since the masked model is three-dimensional, the holographic misalignment effect is also three-dimensional, rather than a thin sheet misalignment, thereby improving the quality of the model holographic misalignment effect; at the same time, this method consumes less performance compared to vertex animation, and can implement the model holographic misalignment effect on mobile games.
[0104] Specifically, the masking processing module 71 is used to: obtain a preset stripe pattern, increase the brightness of the preset stripe pattern by a specified value to obtain a first stripe pattern; perform linear interpolation between the preset stripe pattern and the first stripe pattern to obtain a masking pattern; and perform masking processing on the model to be rendered using the masking pattern to obtain a masked model.
[0105] In a specific implementation, the above device also includes a preset stripe pattern determination module, which is used to: cyclically move the screen texture pattern through a preset time curve to generate a target texture pattern with a texture flow effect; and combine the target texture pattern with a preset black and white stripe pattern to obtain a preset stripe pattern with a stripe flow effect.
[0106] Furthermore, the above-mentioned device also includes an offset parameter determination module, which is used to: cyclically adjust the preset cyclic curve through a preset time parameter to obtain a processing result; map the processing result with a preset curve spectrum to obtain a curve regularity parameter; and multiply the curve regularity parameter with a preset offset value to obtain an offset parameter.
[0107] In a specific implementation, the aforementioned offset parameter determination module is also used to: call a preset circulation curve through a preset time parameter; wherein the preset time parameter is used to control the flow rate of the preset circulation curve; perform trigonometric operations on the preset circulation curve to obtain a sine curve; and determine the absolute value of the trigonometric curve as the processing result.
[0108] Furthermore, the aforementioned offset parameter determination module is also used to: after mapping the processing result with the preset curve spectrum to obtain the curve regularity parameter, convert the curve regularity parameter to a specified numerical range to obtain the final curve regularity parameter.
[0109] Furthermore, the above-mentioned device also includes a preset offset value determination module, used to: transform the axis of the coordinate axis of the model to be rendered into the target axis that matches the camera's viewpoint based on a preset axial offset magnitude parameter, and obtain an offset value under the target axis; invert the offset value under the target axis to obtain a first offset value; and perform linear interpolation on the first offset value and the offset value under the target axis to obtain a preset offset value.
[0110] In the specific implementation, the above-mentioned model nesting module 72 is used to: link the offset parameter to the material panel of the model to be rendered; nest the mask model on the model to be rendered through the material panel, and control the movement position of the mask model on the model to be rendered according to the offset parameter to obtain a target model with holographic misalignment effect.
[0111] Furthermore, the aforementioned device also includes a lighting and shadow setting module, used for: after nesting the mask model on the model to be rendered based on preset offset parameters, and controlling the mask model to move on the model to be rendered to obtain a target model with holographic misalignment effect, performing a dot product operation between the vertex normal direction of the target model and the preset lighting direction to obtain a target model with lighting and shadow effects.
[0112] Furthermore, the aforementioned device also includes a specular effect setting module, used to: after nesting the mask model on the model to be rendered based on preset offset parameters, and controlling the mask model to move on the model to be rendered to obtain a target model with a holographic misalignment effect, set the specular effect of the target model based on a preset micro-surface distribution function.
[0113] Furthermore, the aforementioned device also includes a Fresnel effect setting module, used for: after nesting a mask model on a model to be rendered based on preset offset parameters, and controlling the mask model to move on the model to be rendered to obtain a target model with a holographic misalignment effect, performing a dot product operation between the vertex normal direction of the target model and the camera direction to obtain a dot product result; inverting the dot product result to obtain an inverted result; adjusting the Fresnel intensity of the inverted result to obtain an adjusted result; and multiplying the adjusted result by a preset color to obtain a target model with a Fresnel outer layer effect.
[0114] In its specific implementation, the aforementioned device also includes a misalignment fault effect setting module, which is used to: after nesting the mask model on the model to be rendered based on preset offset parameters, and controlling the mask model to move on the model to be rendered to obtain a target model with a holographic misalignment effect, shift the values corresponding to the three RGB channels of the target model in different directions based on preset displacement parameters; multiply the directions of the three RGB channels after displacement by the displacement magnitude parameter to obtain the displacement results corresponding to the three RGB channels; and merge the displacement results corresponding to the three RGB channels to obtain a target model with a misalignment fault effect.
[0115] The model rendering apparatus provided in this embodiment of the invention has the same implementation principle and technical effects as the model rendering method embodiment. For the sake of brevity, any parts not mentioned in the apparatus embodiment can be referred to the corresponding content in the foregoing method embodiment.
[0116] This invention also provides an electronic device, such as... Figure 8 As shown, the electronic device includes a processor and a memory, the memory storing machine-executable instructions that can be executed by the processor, which executes the machine-executable instructions to implement the above-described model rendering method.
[0117] Furthermore, Figure 8 The electronic device shown also includes a bus 102 and a communication interface 103, with the processor 101, the communication interface 103 and the memory 100 connected via the bus 102.
[0118] The memory 100 may include high-speed random access memory (RAM) or non-volatile memory, such as at least one disk storage device. Communication between this system network element and at least one other network element is achieved through at least one communication interface 103 (which can be wired or wireless), such as the Internet, wide area network, local area network, or metropolitan area network. The bus 102 may be an ISA bus, PCI bus, or EISA bus, etc. The bus can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 8 The symbol is represented by a single double-headed arrow, but this does not mean that there is only one bus or one type of bus.
[0119] Processor 101 may be an integrated circuit chip with signal processing capabilities. In implementation, each step of the above method can be completed by the integrated logic circuitry in the hardware of processor 101 or by instructions in software form. The processor 101 can be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it can also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this invention. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this invention can be directly manifested as execution by a hardware decoding processor, or execution by a combination of hardware and software modules in the decoding processor. The software module can reside in a readily available storage medium in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, or registers. This storage medium is located in memory 100, and processor 101 reads information from memory 100 and, in conjunction with its hardware, completes the steps of the method described in the foregoing embodiments.
[0120] This invention also provides a computer-readable storage medium storing computer-executable instructions. When these computer-executable instructions are called and executed by a processor, they cause the processor to implement the above-described model rendering method. For specific implementation details, please refer to the method embodiments, which will not be repeated here.
[0121] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, essentially, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, a terminal device, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0122] In the description of this invention, it should be noted that the terms "center," "upper," "lower," "left," "right," "vertical," "horizontal," "inner," and "outer," etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are used only for the convenience of describing the invention and for simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on the invention. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and should not be construed as indicating or implying relative importance.
[0123] Finally, it should be noted that the above-described embodiments are merely specific implementations of the present invention, used to illustrate the technical solutions of the present invention, and not to limit it. The scope of protection of the present invention is not limited thereto. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments within the technical scope disclosed in the present invention, or make equivalent substitutions for some of the technical features; and these modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be covered within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A model rendering method, characterized in that, The method includes: Get the model to be rendered; The model to be rendered is masked to obtain a masked model; wherein the masked model is used to simulate the holographic misalignment effect of the model to be rendered. Based on preset offset parameters, the mask model is nested on the model to be rendered, and the mask model is controlled to move on the model to be rendered to obtain a target model with holographic misalignment effect. The offset parameter is determined as follows: a preset cyclic curve is cyclically adjusted using a preset time parameter to obtain a processing result; the processing result is mapped to a preset curve graph to obtain a curve regularity parameter; the curve regularity parameter is multiplied by a preset offset value to obtain the offset parameter.
2. The method according to claim 1, characterized in that, The step of performing masking processing on the model to be rendered to obtain a masked model includes: Obtain a preset stripe pattern, and increase the brightness of the preset stripe pattern by a specified value to obtain a first stripe pattern; A masking image is obtained by performing linear interpolation between the preset stripe pattern and the first stripe pattern. The model to be rendered is masked using the mask image to obtain the masked model.
3. The method according to claim 2, characterized in that, The preset stripe pattern is determined in the following manner: By cyclically moving the screen texture map using a preset time curve, a target texture map with a texture flow effect is generated. The target texture image is combined with a preset black and white stripe image to obtain the preset stripe image with a stripe flow effect.
4. The method according to claim 1, characterized in that, The step of cyclically adjusting a preset cyclic curve using preset time parameters to obtain a processing result includes: The preset time parameter is used to call the preset circulation curve; wherein, the preset time parameter is used to control the flow rate of the preset circulation curve; Perform trigonometric operations on the preset cyclic curve to obtain a trigonometric curve; The absolute value of the triangular curve is determined as the processing result.
5. The method according to claim 1, characterized in that, After the step of mapping the processing result to a preset curve spectrum to obtain curve regularity parameters, the method further includes: The curve pattern parameters are converted to a specified numerical range to obtain the final curve pattern parameters.
6. The method according to claim 1, characterized in that, The preset offset value is determined in the following manner: Based on the preset axial offset parameter, the axial direction of the coordinate axis of the model to be rendered is transformed into the target axial direction that matches the camera's viewpoint, and the offset value under the target axial direction is obtained. Invert the downward offset value of the target axis to obtain the first offset value; The preset offset value is obtained by performing linear interpolation on the first offset value and the offset value downward along the target axis.
7. The method according to claim 1, characterized in that, The step of nesting the mask model on the model to be rendered based on preset offset parameters, and controlling the movement of the mask model on the model to be rendered to obtain a target model with a holographic misalignment effect, includes: Link the offset parameter to the material panel of the model to be rendered; Using the material panel, the mask model is nested on the model to be rendered, and the movement position of the mask model on the model to be rendered is controlled according to the offset parameter to obtain a target model with a holographic misalignment effect.
8. The method according to claim 1, characterized in that, After the step of nesting the mask model on the model to be rendered based on a preset offset parameter and controlling the movement of the mask model on the model to be rendered to obtain a target model with a holographic misalignment effect, the method further includes: The vertex normal direction of the target model is multiplied by a preset lighting direction to obtain the target model with lighting effects.
9. The method according to claim 1, characterized in that, After the step of nesting the mask model on the model to be rendered based on a preset offset parameter and controlling the movement of the mask model on the model to be rendered to obtain a target model with a holographic misalignment effect, the method further includes: Based on a preset micro-surface distribution function, the specular effect of the target model is set.
10. The method according to claim 1, characterized in that, After the step of nesting the mask model on the model to be rendered based on a preset offset parameter and controlling the movement of the mask model on the model to be rendered to obtain a target model with a holographic misalignment effect, the method further includes: The vertex normal direction of the target model is multiplied by the camera direction to obtain the dot product result; Invert the dot product result to obtain the inverted result; Adjust the Fresnel intensity of the inverted result to obtain the adjusted result; The adjustment result is multiplied by the preset color to obtain the target model with a Fresnel outer layer effect.
11. The method according to claim 1, characterized in that, After the step of nesting the mask model on the model to be rendered based on a preset offset parameter and controlling the movement of the mask model on the model to be rendered to obtain a target model with a holographic misalignment effect, the method further includes: Based on preset displacement parameters, the values corresponding to the three RGB channels of the target model are shifted in different directions respectively; Multiply the directions of the three RGB channels after displacement by the displacement magnitude parameter to obtain the displacement results for the three RGB channels; The displacement results corresponding to the three RGB channels are merged to obtain the target model with the effect of misalignment fault.
12. A model rendering apparatus, characterized in that, The device includes: The model acquisition module is used to acquire the model to be rendered; A masking module is used to perform masking processing on the model to be rendered to obtain a masked model; wherein, the masked model is used to simulate the holographic misalignment effect of the model to be rendered. The model nesting module is used to nest the mask model on the model to be rendered based on preset offset parameters, and control the mask model to move on the model to be rendered to obtain a target model with holographic misalignment effect. The offset parameter determination module is used to: perform cyclic adjustment processing on a preset cyclic curve using a preset time parameter to obtain a processing result; map the processing result with a preset curve spectrum to obtain a curve regularity parameter; and multiply the curve regularity parameter by a preset offset value to obtain the offset parameter.
13. An electronic device, characterized in that, The electronic device includes a processor and a memory, the memory storing machine-executable instructions that can be executed by the processor, the processor executing the machine-executable instructions to implement the model rendering method according to any one of claims 1 to 11.
14. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when invoked and executed by a processor, cause the processor to implement the model rendering method according to any one of claims 1 to 11.