Model rendering method, apparatus, and electronic device
Patent Information
- Application Number
- CN202310034324.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-01-10
- Publication Date
- 2026-09-25
- Estimated Expiration
- 2043-01-10
AI Technical Summary
但是该方式中,美术人员在贴图绘制软件绘制贴图时,无法直接查看角色模型的最终效果,只能在游戏引擎中查看,如果角色模型的最终效果美术人员不满意,只能返回贴图绘制软件中修改贴图,以改变角色模型的渲染效果,因而调整渲染效果的操作便捷性较差
[0010]本发明提供的一种模型渲染方法、装置和电子设备,首先将目标模型导入贴图绘制软件中;进而通过贴图绘制软件中创建的着色器获取预设的平行光方向和目标模型的法线方向,并基于平行光方向和法线方向,确定目标模型的光照结果;然后响应于绘图指令,在着色器中设定的贴图通道中,基于目标模型绘制目标贴图,并根据目标贴图和光照结果渲染目标模型,将渲染后的目标模型显示在贴图绘制软件中。该方式中,美术人员在贴图绘制软件绘制贴图时,能够直接在贴图绘制软件中显示目标模型的渲染效果,从而可根据渲染效果直接修改贴图,提高了调整渲染效果的操作便捷性,也可快速得到满意的模型渲染效果。
Smart Images

Figure CN116051715B_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] Anime-style character models generally have a more pronounced and distinct line between light and shadow compared to realistic character models. In game engines, this strong and distinct line between light and shadow is usually achieved by using specific shaders to color anime-style character models.
[0003] In related technologies, color maps for highlights and shadows are typically drawn separately in texture painting software. These color maps are then imported into the game engine, allowing the engine to adjust the directional lighting values and color maps to create a clear distinction between light and shadow on the character model. The game engine then uses a shading map to add detail to the character model, resulting in the final rendered model. However, in this method, artists cannot directly view the final effect of the character model while painting textures in the software; they can only view it within the game engine. If the artists are not satisfied with the final effect, they must return to the texture painting software to modify the textures and change the rendering effect, thus making the adjustment of rendering effects inconvenient. Summary of the Invention
[0004] The purpose of this invention is to provide a model rendering method, apparatus, and electronic device, so as to display the rendering effect of the model under the drawn texture in the texture drawing software while drawing the texture, thereby facilitating the real-time adjustment of the rendering effect by modifying the texture.
[0005] In a first aspect, the present invention provides a model rendering method applied to an electronic device, the electronic device having texture drawing software, the texture drawing software having a texture channel in its shader; wherein the texture channel is used to: draw a texture based on drawing instructions, and render a model based on the drawn texture; the method includes: importing a target model into the texture drawing software; obtaining a preset parallel light direction and a normal direction of the target model through the shader, and determining the lighting result of the target model based on the parallel light direction and the normal direction; responding to the drawing instructions, drawing a target texture based on the target model in the texture channel, rendering the target model based on the target texture and the lighting result, and displaying the rendered target model in the texture drawing software.
[0006] Secondly, the present invention provides a model rendering apparatus, which is disposed in an electronic device. The electronic device is equipped with texture drawing software, and the shader of the texture drawing software is configured with a texture channel. The texture channel is used to: draw textures based on drawing instructions, and render the model according to the drawn textures. The apparatus includes: a model import module for importing a target model into the texture drawing software; a lighting result determination module for obtaining a preset parallel light direction and the normal direction of the target model through the shader, and determining the lighting result of the target model based on the parallel light direction and the normal direction; and a model rendering module for responding to drawing instructions, drawing a target texture based on the target model in the texture channel, rendering the target model according to the target texture and the lighting result, and displaying the rendered target model in the texture drawing software.
[0007] 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.
[0008] 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.
[0009] The embodiments of the present invention bring the following beneficial effects:
[0010] This invention provides a model rendering method, apparatus, and electronic device. First, the target model is imported into texture mapping software. Then, a shader created in the texture mapping software is used to obtain a preset parallel light direction and the normal direction of the target model. Based on the parallel light direction and the normal direction, the lighting result of the target model is determined. Next, in response to drawing instructions, a target texture is drawn based on the target model in the texture channel set in the shader. The target model is then rendered according to the target texture and the lighting result, and the rendered target model is displayed in the texture mapping software. In this method, artists can directly display the rendering effect of the target model in the texture mapping software while drawing textures, thus allowing them to directly modify the texture based on the rendering effect. This improves the ease of operation for adjusting the rendering effect and allows for the rapid acquisition of satisfactory model rendering results.
[0011] 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.
[0012] 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
[0013] 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.
[0014] Figure 1 A flowchart of a model rendering method provided in an embodiment of the present invention;
[0015] Figure 2 A flowchart of another model rendering method provided in an embodiment of the present invention;
[0016] Figure 3 A schematic diagram of a tonemapping curve provided in an embodiment of the present invention;
[0017] Figure 4 A flowchart of another model rendering method provided in an embodiment of the present invention;
[0018] Figure 5 This is a schematic diagram of the structure of a model rendering device provided in an embodiment of the present invention;
[0019] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0020] 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.
[0021] 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.
[0022] Anime-style character models, compared to realistic ones, generally have a more pronounced and distinct boundary between light and shadow. This boundary typically refers to the line where the lit and shadowed sides of an object meet. In game engines, this strong and distinct boundary is usually achieved by using specific shaders to color the anime-style character models. Shaders can assign colors and lighting effects to the models within the game engine, and even implement special effects such as outlines and vertex animations.
[0023] Among the related technologies, two solutions are provided for achieving a two-dimensional stylized rendering effect:
[0024] Option 1 involves drawing color maps for the bright areas (lit surfaces) and dark areas (backlit surfaces) separately in a texture painting software. Then, the drawn color maps are imported into the shader of the game engine. This allows the shader to make the light and shadow boundaries of the character model more distinct based on the modified parallel light values and color maps. Finally, the shader uses a light and shadow map to add light and shadow details to the character model to obtain the final rendered model.
[0025] Option 2 involves creating a base color map in texture painting software, then importing the base color map into the shader of the game engine. The shader then samples a gradient ramp map using parallel light values (the ramp map controls the light and shadow boundary). Based on the sampling results and the base color map, the final lighting effect is obtained. This final lighting effect is then applied to the character model to obtain the final rendered model.
[0026] However, in both of the above methods, artists cannot directly view the final effect of the character model while creating textures in the texture painting software; they can only view it in the game engine. If the artists are not satisfied with the final effect of the character model, they can only return to the texture painting software to modify the textures and change the rendering effect of the character model. Therefore, the operation of adjusting the rendering effect is not very convenient. In addition, when the game engine enables tonemapping post-processing, there is a discrepancy between the texture painting software and the game engine. That is, color A seen in the texture painting software is color B seen in the game engine, thus affecting the rendering effect of the character model.
[0027] Tonemapping refers to the mapping of light intensity. In game engines, to ensure realistic illumination of models, the lighting intensity used during rendering often simulates the intensity of real-world light sources; this is HDR (High Dynamic Range) rendering. However, most display devices today, such as mobile phone and computer monitors, are LDR (Low Dynamic Range) displays, which have limited brightness. Therefore, tone mapping curves are needed to remap the 0-1000 brightness range in the rendering to the 0-1 brightness range of the LDR display, thus preventing overexposure in the game image.
[0028] 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 rendering scenarios for any character model, especially for rendering scenarios for two-dimensional character models.
[0029] 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. This method is applied to an electronic device, such as a computer or a mobile phone. The electronic device is equipped with texture drawing software, and the shader of the texture drawing software has a texture channel; wherein, the texture channel is used for: drawing textures based on drawing instructions, and rendering the model according to the drawn textures; such as... Figure 1 As shown, the method includes the following specific steps:
[0030] Step S102: Import the target model into the texture painting software.
[0031] The aforementioned texture painting software can be any existing software used for texture painting, such as Substance Painter (SP). This invention customizes the texture painting software to synchronously implement the calculations in the game engine's shaders within the texture painting software. Specifically, before model rendering, a custom Toon shader needs to be created in the texture painting software, with texture channels set up for artists to paint textures. Artists can paint textures in these texture channels, which then render the model based on the painted textures.
[0032] In practical implementation, the target model mentioned above is usually the model to be rendered. The target model can be a character model or a decorative model required by the character model, such as a clothing model, a shoe model, etc.
[0033] Step S104: Obtain the preset parallel light direction and the normal direction of the target model through the shader, and determine the lighting result of the target model based on the parallel light direction and the normal direction.
[0034] The aforementioned parallel light direction is also the preset sunlight direction. The normal direction of the target model can be obtained by calculating the normal of each vertex of the target model. By specifying the parallel light direction and the normal direction, the lighting result of the target model can be obtained. The specific processing method can be determined according to the research and development needs. For example, the specified processing can be to perform an inner product or dot product operation between the parallel light direction and the normal direction.
[0035] In step S106, in response to the drawing command, a target texture is drawn based on the target model in the texture channel, and the target model is rendered according to the target texture and lighting results. The rendered target model is then displayed in the texture drawing software.
[0036] Artists can send drawing instructions to the shader to draw textures in the texture channel. These instructions include information such as the lines to be drawn, their positions, and their colors. In practice, the target texture drawn by the artist in the texture channel is based on the target model; that is, color or lighting information is added to the target model to obtain the target texture. This method allows the rendering effect of the target model based on the target texture and lighting results to be displayed in the texture drawing software while the artist is drawing the target texture in the texture channel (i.e., every stroke the artist makes in the texture channel will display the corresponding model rendering effect in the texture drawing software). This allows the artist to see the rendering effect of the model while drawing the texture, making it convenient for them to modify the texture based on the rendering effect and quickly obtain a satisfactory and compliant rendering result.
[0037] This invention provides a model rendering method. First, the target model is imported into texture mapping software. Then, a shader created in the texture mapping software is used to obtain a preset parallel light direction and the normal direction of the target model. Based on the parallel light direction and the normal direction, the lighting result of the target model is determined. Next, in response to drawing instructions, a target texture is drawn based on the target model in the texture channel set in the shader. The target model is then rendered according to the target texture and the lighting result, and the rendered target model is displayed in the texture mapping software. In this method, artists can directly display the rendering effect of the target model in the texture mapping software while drawing textures, thus allowing them to directly modify the texture based on the rendering effect. This improves the ease of adjusting the rendering effect and allows for quick and satisfactory model rendering results.
[0038] 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 determining the lighting results of the target model based on the parallel light direction and the normal direction (implemented through steps S206-S210 below); as... Figure 2 As shown, the method includes the following specific steps:
[0039] Step S202: Import the target model into the texture painting software.
[0040] Step S204: Obtain the preset parallel light direction and the normal direction of the target model through the shader.
[0041] Step S206: Perform a dot product operation on the parallel light direction and the normal direction using a shader to obtain the first result.
[0042] In practical implementation, the shader in the texture painting software can obtain the preset parallel light direction and the normal direction of the target model, and then perform a dot product operation on the parallel light direction and the normal direction to obtain the Lambert model (a kind of lighting model), which is the first result mentioned above.
[0043] Step S208: Multiply the first result by the first value, and add the multiplication result to the second value to obtain the second result.
[0044] The specific values of the first and second values mentioned above can be set according to research and development needs. The first and second values can be the same or different. For example, the first value can be set to 0.5 or 0.6, and the second value can be set to 0.5 or 0.7.
[0045] In practical implementation, in order to make the color of the backlit side in the Lambert model lighter and more in line with the real lighting conditions, the Lambert model can be transformed into a semi-Lambert model. That is, the Lambert model is multiplied by 0.5, and then the result of the multiplication is added to 0.5 to obtain the semi-Lambert model (equivalent to the second result mentioned above).
[0046] Step S210: Smooth the edges of the second result to obtain the lighting result of the target model.
[0047] The smoothing process described above can be performed using existing methods without specific limitations. For example, a preset minimum threshold, a preset maximum threshold, and a second result can be input into a preset smoothing step function to output the lighting result of the target model. This smoothing step function can also be called the SmoothStep function, which allows interpolation between 0 and 1 and allows setting minimum and maximum thresholds.
[0048] The SmoothStep function accepts three parameters: Min (minimum threshold), Max (maximum threshold), and Value. Min defines the lower boundary of the interpolation; for values less than or equal to Min, SmoothStep returns 0 (black). Max defines the upper boundary of the interpolation; for values greater than or equal to Max, SmoothStep returns 1 (white). Value defines the source of the interpolation; in this invention, it is the second result, which is a texture image.
[0049] In step S212, in response to the drawing command, a target texture is drawn based on the target model in the texture channel, and the target model is rendered according to the target texture and lighting results. The rendered target model is then displayed in the texture drawing software.
[0050] In practical implementation, to address the effect deviation caused by enabling tone mapping (equivalent to tone mapping function effect) in the game engine, the tone mapping of the game engine can be directly synchronized to the shader of the texture mapping software to eliminate the effect deviation.
[0051] In related technologies, Unity's Universal Render Pipeline (URP) only supports two modes of tonemapping. However, enabling either mode significantly impacts the rendering of the target model. For example, the target model may appear grayish or whitish, greatly affecting skin tone and making it appear less rosy. Because the URP pipeline does not support custom tonemapping curves, this invention allows programmers to migrate the source code for custom tonemapping curves from the Unity BuildIn pipeline and implement the functionality of custom tonemapping in the game project.
[0052] In the underlying setup of this invention, after the artists debug a suitable custom tonemapping curve in the game engine, they synchronize the custom tonemapping curve's calculation process in the game engine to the shader of the texture painting software, thereby enabling the shader to achieve tone mapping effects. Specifically, the tone mapping effect in the shader set by the texture painting software is achieved through the following steps 10-11:
[0053] Step 10: Determine multiple tone mapping position coordinates based on preset tone mapping parameters.
[0054] In practical implementation, the preset tone mapping parameters include at least:
[0055] Toe Strength: The height of the Toe segment;
[0056] Toe Length: The length of the Toe segment;
[0057] Shoulder Strength: The height of the shoulder segment;
[0058] Shoulder Length: The length of the shoulder segment line;
[0059] Shoulder Angle: The angle of the shoulder segment line;
[0060] Gamma: The entire line will be given an exponential operation. The entire tonemapping curve is the base, and the Gamma value is the exponent. If Gamma is 1, the result is still the entire tonemapping curve.
[0061] By calculating the parameter values corresponding to the six tone mapping parameters mentioned above, the coordinates of the three tone mapping positions can be obtained. For example... Figure 3 The image shows a schematic diagram of the tonemapping curve. Figure 3 The curve contains four circular points corresponding to four position coordinates. Among them, the (0,0) point is a preset known point, and the other three position coordinates are calculated tone mapping position coordinates.
[0062] Step 11: Determine the tone mapping curve based on the preset curve calculation function and multiple tone mapping position coordinates, so as to obtain the tone mapping effect based on the tone mapping curve.
[0063] The aforementioned preset curve calculation function can be set according to R&D needs. By substituting multiple tone mapping position coordinates into the curve calculation function, a tone mapping curve can be output. In specific implementation, the connection... Figure 3 By taking the four dots, we can obtain three line segments: Toe, Linear Section, and Shoulder. After calculating these three line segments, we get the final custom tone mapping curve. Applying this custom tone mapping curve to the output color of the shader in the texture painting software will give us the final output color. It can also be understood as a tone mapping curve that can remap the colors in the rendering process to get the final color output.
[0064] While achieving synchronization between the texture painting software and the game engine, this introduced new problems. When artists used the texture painting software to create textures, they would directly use the software's color picker to sample colors from the character's original artwork. That is, they would sample color A from the original artwork and then paint color A in the texture painting software. However, after adding custom tonemapping, the color picker would sample color A from the original artwork, but due to the influence of the custom tonemapping, color A would become color B in the texture painting software. In other words, they would sample color A from the original artwork and then paint color B in the texture painting software.
[0065] To address the issue of color picker inaccuracies, a custom inverse tone mapping function (equivalent to an inverse tone mapping function) is written into the shader of the texture mapping software. The curve obtained from the inverse tone mapping function is then applied to the output color of the shader in the texture mapping software to obtain the inverse function output color. Specifically, the effect of the inverse tone mapping function in the shader is determined as follows: based on preset tone mapping parameters, multiple tone mapping position coordinates are determined; based on the inverse function of the curve calculation function and the multiple tone mapping position coordinates, an inverse tone mapping curve is determined, and the effect of the inverse tone mapping function is obtained from the inverse tone mapping curve.
[0066] Based on the above description, the process of color drawing the model in the texture drawing software of the present invention can be implemented through the following steps S214-S218.
[0067] Step S214: Import the preset patch model into the shader and paste the preset model concept art onto the patch model to obtain the initial concept art model; wherein, the model concept art is used to indicate the initial color of the target model after rendering.
[0068] The aforementioned patch model can be drawn in 3D modeling software, and its size is the same as the size of the original model texture. The drawn patch model is then imported into a shader created by the texture painting software, and the original model texture is applied to it to obtain the initial original model. This initial original model will then be displayed in the texture painting software.
[0069] Step S216: In response to enabling the tone mapping inverse function effect in the shader, the inverse function original model of the initial original model is obtained and saved.
[0070] In the shader settings of the texture painting software, enable the automatic tone mapping inverse function effect (equivalent to the tone mapping inverse function effect mentioned above) to obtain the inverse function original model of the initial original model; and save a screenshot of the inverse function original model.
[0071] Step S218: In response to the inverse function effect of tone mapping being turned off in the shader and the color drawing instruction for the inverse function original model being turned on with tone mapping effect enabled, the target color indicated by the color drawing instruction is sampled from the color picker of the texture drawing software and drawn on the inverse function original model; and the inverse function original model after color drawing is displayed.
[0072] In the shader settings of the texture painting software, enable the custom tonemapping effect and disable the custom tonemapping inverse function effect. This allows artists to simply sample colors from the inverse function concept art model when painting textures in the software. With the custom tonemapping effect enabled, the texture painting software will use the color picker to sample color 1 from the inverse function concept art model and paint color 2, which will be essentially the same as the color in the initial concept art model.
[0073] The above-mentioned model rendering method, by customizing a new shader for the texture painting software, synchronizing the artist's custom tone mapping curve in the shader, and changing the process of color picking and texture painting from the original artwork, can greatly save artists' time in painting textures, while also avoiding the trouble of repeatedly adjusting colors, thus greatly improving the efficiency of texture painting for stylized character models.
[0074] This invention also provides another model rendering method, which is implemented based on the above embodiments. This method focuses on describing the following process: when the texture channels include a highlight texture channel, a shadow texture channel, and a shading texture channel, and the target texture includes a highlight texture, a shadow texture, and a shading texture, in response to drawing instructions, a target texture is drawn based on the target model in the texture channels, and the target model is rendered according to the target texture and lighting results. The rendered target model is then displayed in the texture drawing software (implemented through steps S406-S410 below); Figure 4 As shown, the method includes the following specific steps:
[0075] Step S402: Import the target model into the texture painting software.
[0076] Step S404: Obtain the preset parallel light direction and the normal direction of the target model through the shader, and determine the lighting result of the target model based on the parallel light direction and the normal direction.
[0077] Step S406: In response to the drawing command, draw a highlight map in the highlight map channel, draw a shadow map channel in the shadow map channel, and draw a light and shadow map in the light and shadow map channel.
[0078] In practical implementation, the above-mentioned highlight map indicates the color of the illuminated side of the model, and the shadow map is used to indicate the color of the shaded side of the model. The light and shadow map is equivalent to a controllable parameter. Artists can choose to input this parameter in the light and shadow map channel to obtain light and shadow details. If no parameter is input, the light and shadow map is set to a value of 1 in the shader by default, which is white.
[0079] Step S408: Render the target model based on the dark area map, bright area map, light and shadow map, and lighting results to obtain the rendered target model.
[0080] In a practical implementation, step S408 above can be achieved through the following steps 20-22:
[0081] Step 20: Multiply the lighting result with the light and shadow map to obtain the third result.
[0082] Step 21: Perform linear interpolation on the third result, the dark area map, and the bright area map to obtain the fourth result.
[0083] In practical applications, the third result, the shadow map, and the highlight map can be input into a preset linear interpolation function (also known as the Lerp function) to output a fourth result. The Lerp function uses the third input value as the mask parameter and then interpolates between the two input values. The strength of the mask alpha determines the weight of the contributions of the two input values. If the alpha is 0.0, the first input value is used; if the alpha is 1.0, the second input value is used. If the alpha is between 0.0 and 1.0, the output is the interpolation between the two inputs. The Lerp function includes three input values: the first input is the shadow map, the second input is the highlight map, and the third input is the third result.
[0084] Step 22: Assign the fourth result to the target model to obtain the rendered target model.
[0085] Step S410: Display the rendered target model in the texture painting software.
[0086] The above-mentioned model rendering method uses a custom shader in the texture painting software to synchronize the calculations of the shader in the game engine. This allows artists to see the final lighting and shadow effects of the model directly in the texture painting software while painting textures.
[0087] Corresponding to the above method embodiments, this invention also provides a model rendering apparatus, which is disposed in an electronic device. The electronic device includes texture drawing software, and the shader of the texture drawing software has a texture channel. The texture channel is used for: drawing textures based on drawing instructions, and rendering the model according to the drawn textures; such as... Figure 5 As shown, the device includes:
[0088] The model import module 50 is used to import the target model into the texture painting software.
[0089] The lighting result determination module 51 is used to obtain the preset parallel light direction and the normal direction of the target model through the shader, and determine the lighting result of the target model based on the parallel light direction and the normal direction.
[0090] The model rendering module 52 is used to respond to drawing instructions, draw target textures based on the target model in the texture channel, render the target model according to the target texture and lighting results, and display the rendered target model in the texture drawing software.
[0091] The aforementioned model rendering device first imports the target model into the texture painting software. Then, it obtains the preset parallel light direction and the normal direction of the target model through a shader created in the texture painting software, and determines the lighting result of the target model based on the parallel light direction and the normal direction. Next, in response to drawing instructions, it draws a target texture based on the target model in the texture channel set in the shader, and renders the target model according to the target texture and lighting result. The rendered target model is then displayed in the texture painting software. In this method, artists can directly display the rendering effect of the target model in the texture painting software while creating textures, thus allowing them to directly modify the texture based on the rendering effect. This improves the ease of operation for adjusting the rendering effect and allows for the rapid acquisition of satisfactory model rendering results.
[0092] Specifically, the above-mentioned illumination result determination module 51 is used to: perform a dot product operation on the parallel light direction and the normal direction to obtain a first result; multiply the first result by a first value and add the multiplication result to a second value to obtain a second result; and smooth the edges of the second result to obtain the illumination result.
[0093] Furthermore, the aforementioned illumination result determination module 51 is also used to: input the preset minimum threshold, the preset maximum threshold, and the second result into a preset smooth step function, and output the illumination result.
[0094] In specific implementation, the aforementioned texture channels include: a highlight texture channel, a shadow texture channel, and a shading texture channel; the aforementioned target texture includes a highlight texture, a shadow texture, and a shading texture; wherein, the highlight texture indicates the color of the illuminated surface of the model, and the shadow texture is used to indicate the color of the shaded surface of the model. The aforementioned model rendering module 52 is used to: respond to drawing instructions to draw a highlight texture in the highlight texture channel, draw a shadow texture in the shadow channel, and draw a shading texture in the shading texture channel; render the target model based on the shadow texture, highlight texture, shading texture, and lighting results to obtain the rendered target model; and display the rendered target model in the texture drawing software.
[0095] Furthermore, the aforementioned model rendering module 52 is also used to: multiply the lighting result with the light and shadow map to obtain a third result; perform linear interpolation on the third result, the dark map, and the bright map to obtain a fourth result; and assign the fourth result to the target model to obtain the rendered target model.
[0096] In practical applications, the aforementioned device further includes a color setting module, used for: after responding to drawing instructions, drawing a target texture based on the target model in the texture channel, rendering the target model according to the target texture and lighting results, and displaying the rendered target model in the texture painting software, the method further includes: importing a preset patch model into the shader, and pasting a preset model concept art onto the patch model to obtain an initial concept art model; wherein the model concept art is used to indicate the initial color of the rendered target model; responding to enabling the tone mapping inverse function effect in the shader, obtaining the inverse function concept art model of the initial concept art model, and saving the inverse function concept art model; responding to disabling the tone mapping inverse function effect in the shader, and enabling the tone mapping effect, for the color drawing instructions of the inverse function concept art model, sampling the target color indicated by the color drawing instructions from the color picker of the texture painting software, drawing the target color in the inverse function concept art model; and displaying the inverse function concept art model after color drawing.
[0097] Furthermore, the tone mapping effect in the shader is determined as follows: based on preset tone mapping parameters, multiple tone mapping position coordinates are determined; according to a preset curve calculation function and multiple tone mapping position coordinates, a tone mapping curve is determined, so as to obtain the tone mapping effect based on the tone mapping curve.
[0098] Furthermore, the effect of the inverse tone mapping function in the shader is determined as follows: based on preset tone mapping parameters, multiple tone mapping position coordinates are determined; based on the inverse function of the curve calculation function and the multiple tone mapping position coordinates, the inverse tone mapping curve is determined, so as to obtain the effect of the inverse tone mapping function based on the inverse tone mapping curve.
[0099] The model rendering apparatus provided in this embodiment of the invention has the same implementation principle and technical effect as the aforementioned method embodiment. For the sake of brevity, any parts not mentioned in the apparatus embodiment can be referred to the corresponding content in the aforementioned method embodiment.
[0100] This invention also provides an electronic device, such as... Figure 6 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.
[0101] Specifically, the above-mentioned model rendering method is applied to an electronic device equipped with texture drawing software. The shader of the texture drawing software has a texture channel. The texture channel is used to: draw textures based on drawing instructions and render the model based on the drawn textures. The method includes: importing the target model into the texture drawing software; obtaining the preset parallel light direction and the normal direction of the target model through the shader, and determining the lighting result of the target model based on the parallel light direction and the normal direction; responding to the drawing instructions, drawing a target texture based on the target model in the texture channel, rendering the target model based on the target texture and the lighting result, and displaying the rendered target model in the texture drawing software.
[0102] In the above model rendering method, when artists draw textures in texture drawing software, they can directly display the rendering effect of the target model in the texture drawing software. This allows them to directly modify the textures based on the rendering effect, improving the ease of operation for adjusting the rendering effect and quickly obtaining satisfactory model rendering results.
[0103] In an optional embodiment, the step of determining the illumination result of the target model based on the parallel light direction and the normal direction includes: performing a dot product operation on the parallel light direction and the normal direction to obtain a first result; multiplying the first result by a first value and adding the multiplied result to a second value to obtain a second result; and smoothing the edges of the second result to obtain the illumination result.
[0104] In an optional embodiment, the step of smoothing the edges of the second result to obtain the illumination result includes: inputting a preset minimum threshold, a preset maximum threshold, and the second result into a preset smoothing step function, and outputting the illumination result.
[0105] In an optional embodiment, the above-mentioned texture channels include: a highlight texture channel, a shadow texture channel, and a shading texture channel; the target texture includes a highlight texture, a shadow texture, and a shading texture; wherein, the highlight texture indicates the color of the illuminated surface of the model, and the shadow texture indicates the color of the shaded surface of the model; the above-mentioned steps of drawing a target texture based on the target model in the texture channels in response to drawing instructions, rendering the target model according to the target texture and lighting results, and displaying the rendered target model in the texture drawing software include: drawing a highlight texture in the highlight texture channel, drawing a shadow texture channel in the shadow channel, and drawing a shading texture in the shading texture channel in response to drawing instructions; rendering the target model according to the shadow texture, highlight texture, shading texture, and lighting results to obtain the rendered target model; and displaying the rendered target model in the texture drawing software.
[0106] In an optional embodiment, the step of rendering the target model based on the dark area map, the bright area map, the shading map, and the lighting results to obtain the rendered target model includes: multiplying the lighting results with the shading map to obtain a third result; performing linear interpolation on the third result, the dark area map, and the bright area map to obtain a fourth result; and assigning the fourth result to the target model to obtain the rendered target model.
[0107] In an optional embodiment, after the steps of responding to drawing instructions, drawing a target texture based on the target model in the texture channel, rendering the target model according to the target texture and lighting results, and displaying the rendered target model in the texture drawing software, the method further includes: importing a preset patch model into the shader, and pasting a preset model concept art onto the patch model to obtain an initial concept art model; wherein the model concept art is used to indicate the initial color of the rendered target model; responding to enabling the tone mapping inverse function effect in the shader, obtaining the inverse function concept art model of the initial concept art model, and saving the inverse function concept art model; responding to disabling the tone mapping inverse function effect in the shader, and enabling the tone mapping effect, for the color drawing instructions of the inverse function concept art model, sampling the target color indicated by the color drawing instructions from the color picker of the texture drawing software, drawing the target color in the inverse function concept art model; and displaying the inverse function concept art model after color drawing.
[0108] In an optional embodiment, the tone mapping effect in the shader is determined by: determining multiple tone mapping position coordinates based on preset tone mapping parameters; determining a tone mapping curve according to a preset curve calculation function and multiple tone mapping position coordinates, so as to obtain the tone mapping effect according to the tone mapping curve.
[0109] In an optional embodiment, the effect of the inverse tone mapping function in the shader is determined in the following way: based on preset tone mapping parameters, multiple tone mapping position coordinates are determined; based on the inverse function of the curve calculation function and the multiple tone mapping position coordinates, the inverse tone mapping curve is determined, so as to obtain the effect of the inverse tone mapping function based on the inverse tone mapping curve.
[0110] Furthermore, Figure 6 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.
[0111] 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 6 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.
[0112] 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. 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.
[0113] 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.
[0114] Specifically, the above-mentioned model rendering method is applied to an electronic device equipped with texture drawing software. The shader of the texture drawing software has a texture channel. The texture channel is used to: draw textures based on drawing instructions and render the model based on the drawn textures. The method includes: importing the target model into the texture drawing software; obtaining the preset parallel light direction and the normal direction of the target model through the shader, and determining the lighting result of the target model based on the parallel light direction and the normal direction; responding to the drawing instructions, drawing a target texture based on the target model in the texture channel, rendering the target model based on the target texture and the lighting result, and displaying the rendered target model in the texture drawing software.
[0115] In the above model rendering method, when artists draw textures in texture drawing software, they can directly display the rendering effect of the target model in the texture drawing software. This allows them to directly modify the textures based on the rendering effect, improving the ease of operation for adjusting the rendering effect and quickly obtaining satisfactory model rendering results.
[0116] In an optional embodiment, the step of determining the illumination result of the target model based on the parallel light direction and the normal direction includes: performing a dot product operation on the parallel light direction and the normal direction to obtain a first result; multiplying the first result by a first value and adding the multiplied result to a second value to obtain a second result; and smoothing the edges of the second result to obtain the illumination result.
[0117] In an optional embodiment, the step of smoothing the edges of the second result to obtain the illumination result includes: inputting a preset minimum threshold, a preset maximum threshold, and the second result into a preset smoothing step function, and outputting the illumination result.
[0118] In an optional embodiment, the above-mentioned texture channels include: a highlight texture channel, a shadow texture channel, and a shading texture channel; the target texture includes a highlight texture, a shadow texture, and a shading texture; wherein, the highlight texture indicates the color of the illuminated surface of the model, and the shadow texture indicates the color of the shaded surface of the model; the above-mentioned steps of drawing a target texture based on the target model in the texture channels in response to drawing instructions, rendering the target model according to the target texture and lighting results, and displaying the rendered target model in the texture drawing software include: drawing a highlight texture in the highlight texture channel, drawing a shadow texture channel in the shadow channel, and drawing a shading texture in the shading texture channel in response to drawing instructions; rendering the target model according to the shadow texture, highlight texture, shading texture, and lighting results to obtain the rendered target model; and displaying the rendered target model in the texture drawing software.
[0119] In an optional embodiment, the step of rendering the target model based on the dark area map, the bright area map, the shading map, and the lighting results to obtain the rendered target model includes: multiplying the lighting results with the shading map to obtain a third result; performing linear interpolation on the third result, the dark area map, and the bright area map to obtain a fourth result; and assigning the fourth result to the target model to obtain the rendered target model.
[0120] In an optional embodiment, after the steps of responding to drawing instructions, drawing a target texture based on the target model in the texture channel, rendering the target model according to the target texture and lighting results, and displaying the rendered target model in the texture drawing software, the method further includes: importing a preset patch model into the shader, and pasting a preset model concept art onto the patch model to obtain an initial concept art model; wherein the model concept art is used to indicate the initial color of the rendered target model; responding to enabling the tone mapping inverse function effect in the shader, obtaining the inverse function concept art model of the initial concept art model, and saving the inverse function concept art model; responding to disabling the tone mapping inverse function effect in the shader, and enabling the tone mapping effect, for the color drawing instructions of the inverse function concept art model, sampling the target color indicated by the color drawing instructions from the color picker of the texture drawing software, drawing the target color in the inverse function concept art model; and displaying the inverse function concept art model after color drawing.
[0121] In an optional embodiment, the tone mapping effect in the shader is determined by: determining multiple tone mapping position coordinates based on preset tone mapping parameters; determining a tone mapping curve according to a preset curve calculation function and multiple tone mapping position coordinates, so as to obtain the tone mapping effect according to the tone mapping curve.
[0122] In an optional embodiment, the effect of the inverse tone mapping function in the shader is determined in the following way: based on preset tone mapping parameters, multiple tone mapping position coordinates are determined; based on the inverse function of the curve calculation function and the multiple tone mapping position coordinates, the inverse tone mapping curve is determined, so as to obtain the effect of the inverse tone mapping function based on the inverse tone mapping curve.
[0123] 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.
[0124] 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.
[0125] 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 is applied to an electronic device, which is equipped with texture drawing software. The shader of the texture drawing software has a texture channel. The texture channel is used to: draw textures based on drawing instructions, and render the model based on the drawn textures. The method includes: Import the target model into the texture painting software; The shader obtains the preset parallel light direction and the normal direction of the target model, and determines the lighting result of the target model based on the parallel light direction and the normal direction. In response to drawing instructions, a target texture is drawn based on the target model in the texture channel, and the target model is rendered according to the target texture and the lighting results, and the rendered target model is displayed in the texture drawing software; The preset patch model is imported into the shader, and the preset model concept art is pasted onto the patch model to obtain the initial concept art model; wherein, the model concept art is used to indicate the initial color of the rendered target model; In response to enabling the tone mapping inverse function effect in the shader, the inverse function original model of the initial original model is obtained and the inverse function original model is saved. In response to the color drawing instruction for the inverse function model of the inverse function, which is turned off in the shader and turned on with the tone mapping effect, the target color indicated by the color drawing instruction is extracted from the color picker of the texture drawing software and drawn in the inverse function model. Display the original model of the inverse function after color rendering.
2. The method according to claim 1, characterized in that, The step of determining the illumination result of the target model based on the parallel light direction and the normal direction includes: Perform a dot product operation on the parallel light direction and the normal direction to obtain a first result; Multiply the first result by the first value, and add the result of the multiplication to the second value to obtain the second result; The edges of the second result are smoothed to obtain the lighting result.
3. The method according to claim 2, characterized in that, The step of smoothing the edges of the second result to obtain the illumination result includes: The preset minimum threshold, the preset maximum threshold, and the second result are input into a preset smooth step function to output the illumination result.
4. The method according to claim 1, characterized in that, The texture channels include: a highlight texture channel, a shadow texture channel, and a shading texture channel; the target texture includes a highlight texture, a shadow texture, and a shading texture; wherein, the highlight texture indicates the color of the illuminated side of the model, and the shadow texture is used to indicate the color of the shaded side of the model; The steps of responding to a drawing command, drawing a target texture based on the target model in the texture channel, rendering the target model according to the target texture and the lighting results, and displaying the rendered target model in the texture drawing software include: In response to a drawing command, the highlight map is drawn in the highlight map channel, the shadow map channel is drawn in the shadow map channel, and the light and shadow map is drawn in the light and shadow map channel; The target model is rendered based on the dark area map, the bright area map, the light and shadow map, and the lighting results to obtain the rendered target model. The rendered target model is then displayed in the texture painting software.
5. The method according to claim 4, characterized in that, The steps of rendering the target model based on the dark area map, the bright area map, the shading map, and the lighting results to obtain the rendered target model include: Multiply the lighting result by the light and shadow map to obtain the third result; A fourth result is obtained by performing linear interpolation on the third result, the dark area map, and the bright area map; The fourth result is applied to the target model to obtain the rendered target model.
6. The method according to claim 1, characterized in that, The tone mapping effect in the shader is determined in the following manner: Based on preset tone mapping parameters, determine the coordinates of multiple tone mapping positions; Based on the preset curve calculation function and the multiple tone mapping position coordinates, a tone mapping curve is determined so as to obtain the tone mapping effect according to the tone mapping curve.
7. The method according to claim 6, characterized in that, The effect of the inverse tone mapping function in the shader is determined in the following manner: Based on preset tone mapping parameters, determine the coordinates of multiple tone mapping positions; Based on the inverse function of the curve calculation function and the multiple tone mapping position coordinates, a tone mapping inverse curve is determined so as to obtain the tone mapping inverse function effect based on the tone mapping inverse curve.
8. A model rendering apparatus, characterized in that, The device is installed in an electronic device, which includes texture drawing software. The texture drawing software's shader has a texture channel. The texture channel is used to: draw textures based on drawing instructions, and render the model based on the drawn textures. The device includes: The model import module is used to import the target model into the texture painting software; The lighting result determination module is used to obtain a preset parallel light direction and the normal direction of the target model through the shader, and determine the lighting result of the target model based on the parallel light direction and the normal direction. The model rendering module is used to respond to drawing instructions, draw a target texture based on the target model in the texture channel, render the target model according to the target texture and the lighting results, and display the rendered target model in the texture drawing software; The color setting module is used for: importing a preset patch model into the shader and pasting a preset model concept art onto the patch model to obtain an initial concept art model; wherein the model concept art is used to indicate the initial color of the rendered target model; in response to enabling the tone mapping inverse function effect in the shader, obtaining the inverse function concept art model of the initial concept art model and saving the inverse function concept art model; in response to disabling the tone mapping inverse function effect in the shader and enabling the tone mapping effect, for the color drawing instruction of the inverse function concept art model, sampling the target color indicated by the color drawing instruction from the color picker of the texture drawing software, drawing the target color in the inverse function concept art model; and displaying the inverse function concept art model after color drawing.
9. 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 7.
10. 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 7.
Citation Information
Patent Citations
Model rendering method and device, storage medium and electronic equipment
CN113936083A
Model map drawing method and device and electronic equipment
CN115311401A