Special effect rendering method and device of virtual model, electronic equipment and storage medium
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- NETEASE (HANGZHOU) NETWORK CO LTD
- Filing Date
- 2023-06-15
- Publication Date
- 2026-07-10
Smart Images

Figure CN116688492B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of rendering technology, and in particular to a method, apparatus, electronic device, and storage medium for rendering special effects of virtual models. Background Technology
[0002] In game scenes, adding special effects to virtual models can enrich their expressiveness, such as rendering ink wash effects on appearance-related virtual models. Currently, a common method for creating ink wash effects is to use a single ink wash texture and add a flow map. The flow map makes the ink wash texture flow, thus creating the ink wash effect. However, this method only creates an effect patch and attaches it to the appearance surface. When the player's virtual character moves, the effect patch easily intersects with the appearance surface, resulting in poor visual effects and a bad gaming experience for the player. Summary of the Invention
[0003] In view of this, the purpose of the present invention is to provide a method, apparatus, electronic device and storage medium for rendering special effects of virtual models, which can better realize the artistic effect of dynamic disappearance of special effects on virtual models, and does not require additional special effects patches on virtual models, thus effectively avoiding the risk of clipping caused by special effects patches.
[0004] In a first aspect, embodiments of the present invention provide a method for rendering special effects of a virtual model, including:
[0005] Obtain the initial virtual model and the initial effect texture to be rendered on the initial virtual model;
[0006] Based on preset dithering parameters and initial texture sampling coordinates for the initial effect map, the initial effect map is sampled to obtain an effect sampling result; and the color map of the initial virtual model is sampled to obtain a color sampling result; and the dynamic cyclic hidden surface removal sampling result is determined based on preset dissolve parameters and the initial texture sampling coordinates.
[0007] The initial virtual model is rendered based on the special effects sampling results, the color sampling results, and the dynamic loop closing sampling results to obtain the target virtual model.
[0008] Secondly, embodiments of the present invention also provide a special effects rendering device for a virtual model, comprising:
[0009] The acquisition module is used to acquire the initial virtual model and the initial effect texture to be rendered on the initial virtual model;
[0010] The texture determination module is used to sample the initial effect texture to obtain an effect sampling result based on preset dithering parameters and initial texture sampling coordinates for the initial effect texture; and to sample the color texture of the initial virtual model to obtain a color sampling result; and to determine the dynamic cyclic hidden surface removal sampling result based on preset dissolution parameters and the initial texture sampling coordinates.
[0011] The rendering module is used to render the initial virtual model based on the special effects sampling results, the color sampling results, and the dynamic loop closing sampling results to obtain the target virtual model.
[0012] Thirdly, embodiments of the present invention also provide an electronic device, including a processor and a memory, the memory storing computer-executable instructions executable by the processor, the processor executing the computer-executable instructions to implement the method described in any of the first aspects.
[0013] Fourthly, embodiments of the present invention also provide a computer-readable storage medium storing computer-executable instructions, which, when invoked and executed by a processor, cause the processor to implement the method described in any of the first aspects.
[0014] The virtual model special effects rendering method, apparatus, electronic device, and storage medium provided in this invention first acquire an initial virtual model and an initial special effects texture to be rendered on the initial virtual model. Then, the initial special effects texture is sampled according to preset dithering parameters and the initial texture sampling coordinates of the initial special effects texture to obtain special effects sampling results. The color texture of the initial virtual model is sampled to obtain color sampling results. Dynamic cyclic culling sampling results are determined according to preset dissolve parameters and the initial texture sampling coordinates. Finally, the initial virtual model is rendered based on the special effects sampling results, color sampling results, and dynamic cyclic culling sampling results to obtain the target virtual model. The above method can determine the special effects sampling results, color sampling results, and dynamic cyclic culling sampling results separately, thereby controlling the dithering and dynamic cyclic culling effects of the special effects texture on the virtual model. It can better achieve the artistic effect of dynamic culling changes on the virtual model, and it does not require adding additional special effects patches to the virtual model, thus effectively avoiding the risk of clipping caused by special effects patches.
[0015] Other features and advantages of the invention will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the invention. The objects and other advantages of the invention are realized and obtained in accordance with the structures particularly pointed out in the description, claims and drawings.
[0016] 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
[0017] 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.
[0018] Figure 1 A flowchart illustrating a special effects rendering method for a virtual model provided in an embodiment of the present invention;
[0019] Figure 2 This is a schematic diagram of a preset noise map provided in an embodiment of the present invention;
[0020] Figure 3 A schematic diagram of an ink-wash texture provided in an embodiment of the present invention;
[0021] Figure 4 This is a schematic diagram of the A channel of a watercolor texture provided in an embodiment of the present invention;
[0022] Figure 5 A schematic diagram of a color sampling result provided in an embodiment of the present invention;
[0023] Figure 6 This is a schematic diagram illustrating the superposition effect of color sampling results and special effects sampling results provided in an embodiment of the present invention;
[0024] Figure 7 This is a schematic diagram of a mask texture provided in an embodiment of the present invention;
[0025] Figure 8 A schematic diagram of the structure of a special effects rendering device for a virtual model provided in an embodiment of the present invention;
[0026] Figure 9 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0027] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below in conjunction with the embodiments. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0028] Currently, existing special effects rendering methods can only create special effects patches and attach them to the appearance surface. When the player's corresponding virtual character moves, the special effects patches can easily intersect with the appearance surface, resulting in poor visual effects and a bad gaming experience for the player. Based on this, the present invention provides a special effects rendering method, device, electronic device, and storage medium for virtual models, which can better achieve the artistic effect of dynamic disappearance of special effects on virtual models, and does not require adding extra special effects patches to the virtual models. Therefore, it can effectively avoid the risk of clipping caused by special effects patches.
[0029] To facilitate understanding of this embodiment, a method for rendering special effects of a virtual model disclosed in this invention will first be described in detail. (See [link to relevant documentation]). Figure 1 The diagram shows a flowchart of a special effects rendering method for a virtual model. The method mainly includes the following steps S102 to S106:
[0030] Step S102: Obtain the initial virtual model and the initial effect texture to be rendered on the initial virtual model. The initial virtual model is the virtual model that has not yet been rendered with effects. For example, the virtual model can be a model of appearance, weapon, or character. The effect texture is used to represent the relevant attributes of the effects, such as color and texture coordinates (UV). For example, the effect texture can be an ink painting texture or a light flow texture.
[0031] Step S104: Based on preset dithering parameters and initial texture sampling coordinates for the initial effect map, sample the initial effect map to obtain effect sampling results; sample the color map of the initial virtual model to obtain color sampling results; and determine dynamic cyclic hidden surface removal sampling results based on preset dissolve parameters and initial texture sampling coordinates.
[0032] The jitter parameters can include jitter speed parameters, jitter intensity parameters, and jitter offset coordinates; the dissolution parameters can include dissolution shape scaling factor, dissolution time interval parameters, dissolution speed parameters, special effect solubility range, and edge softness / hardness parameters; the special effect sampling results are also the special effect maps affected by noise; the color map is used to describe the color information of the initial virtual model; the dynamic loop hidden surface removal sampling results are used to control the special effect solubility, special effect dissolution time, and special effect edge softness / hardness. Optionally, it can be divided into multiple dissolution groups, and the special effect solubility, special effect dissolution time, and special effect edge softness / hardness of each dissolution group can be different, thereby further enriching the performance of the special effects.
[0033] In one implementation, the initial effect map can be sampled based on dithering parameters, initial texture sampling coordinates of the initial effect map, and a preset noise map to obtain the effect sampling result. In another implementation, the color map can be sampled using the UVs of the initial virtual model itself to obtain the color sampling result. In yet another implementation, multiple dissolution groups can be determined for each color region, thereby determining the target dissolution cycle threshold and target dissolution edge hardness for each dissolution group. The target dissolution cycle threshold is used to describe the effect solubility and effect dissolution time of the dissolution group, and the hardness of the mask map edge is adjusted using the target dissolution edge hardness. Finally, the adjusted mask map is determined as the dynamic cyclic hidden surface removal sampling result.
[0034] Step S106: Render the initial virtual model based on the special effects sampling results, color sampling results, and dynamic loop hidden surface removal sampling results to obtain the target virtual model. In one implementation, the fill color values of different pixels in the initial virtual model can be determined based on the dynamic loop hidden surface removal sampling results. For example, fill the pixels with the color values from the special effects sampling results, or fill the pixels with the color values from the color sampling results, or fill the pixels with a mixture of the color values from the special effects sampling results and the color sampling results. The virtual model filled with color values is then determined as the target virtual model.
[0035] The virtual model special effects rendering method provided in this embodiment of the invention can determine the special effects sampling results, color sampling results and dynamic cyclic cloning sampling results respectively, thereby controlling the jitter and dynamic cyclic cloning effect of the special effects texture on the virtual model. It can better achieve the artistic effect of dynamic cloning changes of special effects on the virtual model, and there is no need to add extra special effects patches on the virtual model. Therefore, it can effectively avoid the risk of clipping caused by special effects patches.
[0036] To facilitate understanding of the above embodiments, this invention provides a specific implementation method for a special effects rendering method for virtual models.
[0037] This embodiment of the invention provides an implementation of step S104. When performing the step of sampling the initial effect map according to preset jitter parameters and initial texture sampling coordinates for the initial effect map to obtain the effect sampling result, see the following (1) to (3):
[0038] (1) Based on the current time, the dithering speed parameter, and the initial texture sampling coordinates, determine the first texture sampling coordinates for the initial effect texture at the current time, and use the first texture sampling coordinates to sample the preset noise texture to obtain the noise contour sampling result. The dithering speed parameter includes the dithering speed in the U direction (diffuse_noise_u_speed) and the dithering speed in the V direction (diffuse_noise_v_speed).
[0039] In one implementation, the first texture sampling coordinates UV1 can be determined according to the following formula:
[0040] UV1=UV+(diffuse_noise_u_speed,diffuse_noise_v_speed)*t;
[0041] Where UV is the initial texture sampling coordinate, t is the current time, and UV1 is the first texture sampling coordinate, representing the offset of UV as the current time progresses.
[0042] In one implementation, a preset noise map is sampled using the first texture sampling coordinates UV1, such as... Figure 2 The diagram shows a preset noise map, and the obtained noise contour sampling result is denoted as shape_noise.
[0043] (2) Adjusting the noise contour sampling result based on the diffusivity intensity parameter. The diffusivity intensity parameter, denoted as diffuse_noise_intensity, represents the intensity of diffusivity caused by noise affecting the initial effect texture. In practice, the diffusivity intensity parameter diffuse_noise_intensity can be multiplied by the noise contour sampling result shape_noise to adjust the shape_noise.
[0044] (3) Based on the initial texture sampling coordinates, the diff offset coordinates, and the adjusted noise contour sampling result, a second texture coordinate is obtained, and the initial effect map is sampled using the second texture coordinates to obtain the effect sampling result. The diff offset coordinate is denoted as `diffuse_offset`, representing the positional offset of the effect map in the U and V directions. For example, taking an initial effect map as an ink wash texture as an example, see [link to example]. Figure 3 A schematic diagram of a watercolor texture is shown, and Figure 4 The diagram shown illustrates the A channel of a watercolor-style texture, wherein... Figure 3 The gray-white grid areas represent transparent areas, and the texture placement is determined by the model's texture coordinates (UV). Figure 4The black parts represent transparent areas, and the white parts represent opaque areas.
[0045] In one implementation, the sum of the initial texture sampling coordinates UV, the dithering offset coordinates diffuse_offset, and the adjusted noise contour sampling result can be used as the second texture coordinates UV2, as shown in the following formula:
[0046] UV2=UV+diffuse_offset+shape_noise*diffuse_noise_intensity.
[0047] In one implementation, the initial effect map can be sampled using the second texture coordinates UV2. The initial effect map is then affected by noise, resulting in a jittery visual effect, denoted as the effect sampling result ink. In practical applications, the sampled UV values can be changed to influence the texture sampling result (i.e., the effect sampling result ink).
[0048] This embodiment of the invention also provides an implementation of step S104. When performing the step of sampling the color texture of the initial virtual model to obtain a color sampling result, the color texture of the initial virtual model itself can be sampled based on its own texture coordinates (UV). The sampling result is denoted as the color sampling result albedo. Taking the initial virtual model as the appearance model and the special effects texture as a watercolor texture as an example, see [link to example]. Figure 5 The diagram shown illustrates a color sampling result, and see also... Figure 6 The diagram shows an example of the overlay effect of color sampling results and special effects sampling results (this is an intermediate result, and it has not actually been overlaid or output yet). The difference between the color sampling results and the ink map is that the color sampling results provide color information other than ink, while the ink map only provides ink information.
[0049] This embodiment of the invention also provides an implementation of step S104. When performing the step of determining the dynamic cyclic blanking sampling result based on preset dissolution parameters and initial texture sampling coordinates, see steps 1 to 4 below:
[0050] Step 1: Determine multiple dissolve groups according to each color region in the preset mask texture. In practice, the mask texture is divided into multiple dissolve groups based on different color regions, so that each dissolve group dissolves in a cycle. Regions of the same color will dissolve simultaneously, while different color regions will have time intervals between dissolution, thus creating a dynamic masking effect.
[0051] Step 2: Based on preset dissolution parameters, initial texture sampling coordinates, and color sampling results, determine the target effect dissolution area. The dissolution parameters also include the dissolution shape scaling factor InkDissolveNoiseScale, which represents the scaling of the effect's dissolution shape. For specific implementation details, please refer to steps 2.1 to 2.2 below:
[0052] Step 2.1: The ratio of the initial texture sampling coordinates to the dissolve shape scaling factor is used as the third texture coordinates. The third texture coordinates are then used to sample the preset noise map to obtain the initial special effect dissolve region. The initial special effect dissolve region is the result of scaling the preset noise map onto the initial virtual model.
[0053] In one implementation, the third texture coordinates UV3 can be calculated according to the following formula:
[0054] UV3=UV / InkDissolveNoiseScale.
[0055] In one implementation, the preset noise map is resampled using the third texture coordinates UV3 to obtain the result of scaling the preset noise map on the initial virtual model (i.e., the initial special effects dissolve area), denoted as clip_tex1.
[0056] Step 2.2: Adjust the contrast value of the initial special effect dissolution region using the contrast value of the color sampling result to adjust the range of the dissolution region, and determine the adjusted initial special effect dissolution region as the target special effect dissolution region. In one implementation, the parameter InkDissolveNoiseContrast can be introduced to represent the color contrast value of the color sampling result. Calculate lerp(0.5f, clip_tex, InkDissolveNoiseContrast). By adjusting InkDissolveNoiseContrast, the contrast value of the initial special effect dissolution region clip_tex1 can be changed, thereby changing the size of the dissolution region, and the adjusted initial special effect dissolution region clip_tex1 can be determined as the target special effect dissolution region clip_tex2. Here, Lerp(a,b,x) means: x is a number ranging from 0 to 1. When x = 0, the value a is used; when x = 1, the value b is used.
[0057] Step 3: Based on the dissolution parameters and the target special effect dissolution area, determine the target dissolution cycle threshold and target dissolution edge hardness for each dissolution group. The target dissolution cycle threshold describes the special effect solubility and dissolution time of the dissolution group, while the target dissolution edge hardness adjusts the softness of the mask texture edge. Specifically, see steps 3.1 to 3.3 below:
[0058] Step 3.1: Determine the specific dissolution time for each dissolution group based on the dissolution parameters. These parameters include the dissolution time interval parameter InkDissolveTimeGap and the dissolution speed parameter InkDissolveSpeed. Based on this, when determining the specific dissolution time for each dissolution group, refer to steps a1 to a3 below:
[0059] Step a1: Sample the mask map to obtain the initial noise mask corresponding to each dissolve group. For example, see... Figure 7 The diagram shows a schematic of a mask texture. In practical applications, the sampled mask texture uses an initial noise mask, representing the part of the initial virtual model that needs the special effect jitter, denoted as noise_mask1. The initial noise mask, noise_mask1, is a black and white image, where white portions are denoted as 1, black portions as 0, and gray portions are between 0 and 1.
[0060] Step a2: For each dissolution group, map the initial noise mask corresponding to the dissolution group to the interval of the dissolution time interval parameter to obtain the target noise mask. In one embodiment, the remap function is used to map the interval of the initial noise mask noise_mask1 from 0 to 1 to the interval from 0 to the dissolution time interval parameter InkDissolveTimeGap, and the mapped initial noise mask is determined as the target noise mask noise_mask2.
[0061] Step a3: Adjust the target noise mask using the current time, and calculate the product of the adjusted target noise mask and the dissolution rate parameter as the specific dissolution time corresponding to the dissolution group. In one embodiment, the current time t can be added to the target noise mask noise_mask2 to adjust the target noise mask noise_mask2. Based on this, the product with the dissolution rate parameter InkDissolveSpeed is calculated to obtain the specific dissolution time dissolve_time, which is a value that continuously increases with the current time t. Specifically, the specific dissolution time dissolve_time can be determined according to the following formula:
[0062] dissolve_time=(t+noise_mask2)*InkDissolveSpeed.
[0063] If they are in the same color region, since their target noise mask noise_mask2 values are the same, the calculated dissolve_time value will also be the same.
[0064] Step 3.2: Determine the target dissolution cycle threshold for each dissolution group based on the specific dissolution time. When performing the step of determining the target dissolution cycle threshold for each dissolution group, please refer to steps b1 to b3 below:
[0065] Step b1: For each dissolution group, the initial dissolution cycle threshold is obtained by taking the remainder of the effective dissolution time corresponding to that group. In one implementation, the initial dissolution cycle threshold dissove_threshold1 can be obtained by taking the remainder of the effective dissolution time dissolve_time using the remainder function fmod(). The initial dissolution cycle threshold dissove_threshold1 is a cyclic threshold that increases with the current time, its value ranging from 0 to 1, then abruptly returning to 0, and then decreasing from 0 to 1 again. The specific calculation process is as follows:
[0066] dissove_threshold1=fmod(dissolve_time,1.0).
[0067] Step b2 involves rounding down the effective dissolution time corresponding to the dissolution group to obtain an integer dissolution time, and then taking the remainder of the rounded dissolution time to obtain a threshold adjustment coefficient. This threshold adjustment coefficient is a value that increases with the current time, ranging from 0 to 1, then abruptly returning to 0, and then decreasing from 0 to 1 again. In one implementation, the threshold adjustment coefficient number can be determined according to the following formula:
[0068] number = fmod(floor(dissolve_time), 2.0), the function floor(x) is to round down to the nearest integer, that is, to get the largest integer not greater than x.
[0069] Step b3 involves adjusting the initial dissolution cycle threshold based on a threshold adjustment coefficient to obtain the target dissolution cycle threshold corresponding to the dissolution group. In one implementation, the target dissolution cycle threshold dissove_threshold2 can be determined using the following formula:
[0070] dissove_threshold2=dissove_threshold1-number*(fmod(dissolve_time,1.0f)+dissove_threshold1).
[0071] Step 3.3: Determine the target dissolution edge softness (InkDissolveEdgeSoftness) for each dissolution group based on dissolution parameters, the target dissolution cycle threshold, and the target special dissolution region. The dissolution parameters include the special solubility range and edge softness parameters. The special solubility range includes the maximum dissolution value (dissove_max) and the minimum dissolution value (dissove_min), which control the maximum and minimum values of the special solubility. Based on this, when determining the target dissolution edge softness value for each dissolution group, refer to steps c1 to c3 below:
[0072] Step c1: For each dissolution group, map the target dissolution cycle threshold corresponding to that dissolution group to the special effect solubility range. In one implementation, the target dissolution cycle threshold dissove_threshold2 can be mapped from a value range of 0-1 to dissove_min to dissove_max, and the mapped target dissolution cycle threshold is denoted as dissove_threshold3. By controlling dissove_min and dissove_max, it is possible to control the maximum amount of the special effect that can be dissolved in each dissolution cycle, and the maximum amount that can be displayed when it is not dissolved / restored.
[0073] Step c2 involves adjusting the target special effect dissolution region using the mapped target dissolution cycle threshold to obtain the adjusted special effect dissolution region. In one implementation, the adjusted special effect dissolution region, denoted as clip_tex3, can be obtained by subtracting the target special effect dissolution region clip_tex2 from the target dissolution cycle threshold dissove_threshold3. The specific formula is shown below:
[0074] clip_tex 3=dissove_threshold 3-clip_tex2.
[0075] Step c3 involves smoothing the transition of the adjusted special effect dissolution region based on the edge hardness parameter to obtain the target dissolution edge hardness corresponding to the dissolution group. In one embodiment, the value of clip_tex3 of the adjusted special effect dissolution region can be limited to between 0 and 1. Then, the edge hardness parameter InkDissolveEdgeSoftness is introduced, which represents the hardness of the dissolution edge, and the dynamic cyclic blanking sampling result mask is obtained according to the following formula:
[0076] The function `mask = smoothstep(InkDissolveEdgeSoftness, 1, clip_tex3)` smoothly transitions the value of `clip_tex3` from `InkDissolveEdgeSoftness` to 1. Adjusting the value of `InkDissolveEdgeSoftness` changes the softness or hardness of the mask edges, i.e., the softness or hardness of the dissolved edges.
[0077] Step 4: Determine the adjusted mask texture as the result of dynamic cyclic hidden surface removal sampling. In practice, the purpose of steps 1 to 3 above is to group the same color portion of the mask texture together. The number of groups to be dissolved varies depending on the fineness of the texture color. For example, taking an ink wash texture, assuming one dissolution cycle is 10 seconds, the ink wash texture is divided into 4 groups according to different colors (from white to black). Group 1 dissolves first, taking 2 seconds; then group 2 dissolves, group 1 recovers, taking 3 seconds; then group 3 dissolves, group 2 recovers, and so on. Many parameters are introduced to control the shape of the ink wash dissolution, the dissolution speed, the softness or hardness of the dissolved edges, the maximum and minimum values of dissolution, and the time interval between each dissolution cycle. It should be noted that the dissolution time mentioned above is only an example; the actual time is calculated based on the color, dissolution speed, and number of groups.
[0078] This embodiment of the invention also provides an implementation method for step S106. When performing the step of rendering the initial virtual model based on the special effects sampling results, color sampling results, and dynamic loop hidden surface removal sampling results to obtain the target virtual model, please refer to the following (I) to (V):
[0079] (i) The product of the transparency of the special effects sampling result and the dynamic loop hidden-cancellation sampling result is determined to obtain the numerical value corresponding to each pixel in the initial virtual model. In one implementation, the color value for filling each pixel can be determined according to the following formula:
[0080] albedo.rgb=lerp(albedo.rgb, ink.rgb, ink.a*mask);
[0081] Here, `albedo` is the color sampling result, `ink` is the effect sampling result, `ink.a` is the transparency of the effect sampling result, and `mask` is the dynamic looping hidden surface sampling result. The `lerp` function calculates `ink.a * mask`, resulting in a value between 0 and 1. The 0 portion is filled with `albedo.rgb`, the 1 portion is filled with `ink.rgb`, and the middle portion is blended. In other words, it blends the ink wash effect with the model's original color.
[0082] (ii) For each pixel in the initial virtual model, if the corresponding value of the pixel is 0, then the pixel in the initial virtual model is filled with the color value of the color sampling result. Please continue to refer to the above formula. When the value of ink.a*mask is 0, albedo.rgb will be used for filling.
[0083] (iii) If the value corresponding to the pixel is 1, then the color value of the special effects sampling result will be used to fill the pixel in the initial virtual model. Please continue to refer to the above formula. When the value of ink.a*mask is 1, ink.rgb will be used for filling.
[0084] (iv) If the value corresponding to the pixel is greater than 0 and less than 1, then the pixel in the initial virtual model will be filled with a blend of the color values from the color sampling result and the effect sampling result. Please refer to the above formula. When the value of ink.a*mask is 0, albedo.rgb and ink.rgb will be used for filling.
[0085] (v) The initial virtual model after filling is determined as the target virtual model.
[0086] In summary, the special effects rendering method for virtual models provided by the embodiments of the present invention can effectively achieve the artistic effect of dynamic disappearance of special effects on virtual models, and does not require additional special effects patches on virtual models, thus effectively avoiding the risk of clipping caused by special effects patches.
[0087] To facilitate understanding of the above embodiments, this invention provides an application example of a virtual model special effects rendering method, using a virtual model as the appearance model and an ink wash texture as the special effects map. This method can be executed in a shader, which is a technology specifically used to render graphics. By modifying the shader, the algorithm for rendering the image on the graphics card can be customized to achieve the desired effect. The shader includes vertex shaders, fragment shaders, etc.
[0088] The specific process of rendering special effects for virtual models includes the following (A) to (H):
[0089] (A) Introduce the parameters diffuse_noise_u_speed and diffuse_noise_v_speed, representing the u-axis and v-axis velocities of the ink map jitter, respectively. Calculate UV1 = uv + (diffuse_noise_u_speed, diffuse_noise_v_speed) * time, representing the UV offset over time. Sample the noise map using the calculated UV1, and denote the result as shape_noise.
[0090] The parameter InkDissolveNoiseScale is introduced to represent the scaling size of the ink dissolve shape. UV3 = uv / InkDissolveNoiseScale is calculated, and the noise map is resampled using UV3 to obtain the result of scaling the noise map on the model, denoted as clip_tex1.
[0091] (B) Introducing the parameter diffuse_offset, which represents the positional offset of the ink map in the u and v directions. Introducing the parameter diffuse_noise_intensity, which represents the intensity of the jitter caused by noise affecting the ink map.
[0092] Calculate UV2 = UV + diffuse_offset + shape_noise * diffuse_noise_intensity. Use UV2 to sample the ink map, obtaining the jittery artistic effect caused by noise affecting the ink map, denoted as ink. In the actual implementation, the sampling UV value is changed to affect the result of texture sampling.
[0093] (C) The color map of the sampled appearance model itself is denoted as albedo. The difference between it and ink map is that color map provides color information other than ink, while ink map only provides ink information.
[0094] (D) Introduce the parameter InkDissolveNoiseContrast, which represents the color contrast of the sampling result. Calculate lerp(0.5f, clip_tex1, InkDissolveNoiseContrast). By adjusting InkDissolveNoiseContrast, the contrast of clip_tex1 can be changed, thereby changing the size of the ablation area. The clip_tex1 after the contrast is changed is denoted as clip_tex2.
[0095] (E) Sample the mask map, which represents the part of the model that needs to be splashed with ink, denoted as noise_mask1. noise_mask1 is a black and white image, where white parts are denoted as 1, black parts as 0, and gray parts in between. Introduce the parameters InkDissolveTimeGap to represent the dissolution time interval and InkDissolveSpeed to represent the dissolution speed. Map the interval from 0 to 1 in noise_mask1 to the interval from 0 to InkDissolveTimeGap, and denote the mapped noise_mask1 as noise_mask2. Calculate dissolve_time = (time + noise_mask2) * InkDissolveSpeed. In this step, we can see that regions of the same color will have the same dissolve_time value after calculation because their noise_mask2 values are the same.
[0096] (F) Dissolve the mask texture in a separate loop according to the different color regions. Regions of the same color will be calculated and dissolved together, while different colored blocks will dissolve at intervals, thus creating a dynamic ink wash effect. Calculate dissove_threshold1 = fmod(dissolve_time, 1.0), where fmod is the modulo operator.
[0097] Calculate number = fmod(floor(dissolve_time1), 2.0). The function floor(x) rounds down to the nearest integer, i.e., it takes the largest integer not greater than x.
[0098] Based on dissove_threshold1, calculate dissove_threshold2 = dissove_threshold1 - number * (fmod(dissolve_time, 1.0f) + dissove_threshold1).
[0099] (G) Introduce the parameters dissove_min and dissove_max, representing the maximum and minimum values of dissolution, respectively. Map dissove_threshold2 from the range of 0-1 to dissove_min to dissove_max, and denote the mapped dissove_threshold2 as dissove_threshold3. By controlling dissove_min and dissove_max, you can control the maximum amount of ink that can be dissolved in each dissolution cycle, and the maximum amount that can be displayed when it is not dissolved / restored.
[0100] Calculate `clip_tex3 = dissove_threshold 3 - clip_tex2`, and then limit the value of `clip_tex3` to between 0 and 1. Introduce the parameter `InkDissolveEdgeSoftness` to represent the softness or hardness of the dissolve edge. Calculate `mask = smoothstep(InkDissolveEdgeSoftness, 1, clip_tex3)`, where the `smoothstep` function represents smoothly transitioning the value of `clip_tex3` from `InkDissolveEdgeSoftness` to 1. The softness or hardness of the mask edge, i.e., the softness or hardness of the dissolve edge, can be changed by adjusting the value of `InkDissolveEdgeSoftness`.
[0101] (H) Calculate `albedo.rgb = lerp(albedo.rgb, ink.rgb, ink.a * mask)`, where `albedo` is the result of color map sampling (i.e., color sampling result), `ink` is the result of ink map sampling (i.e., effect sampling result), `ink.a` is the transparency of the ink map sampling, and `mask` is the dynamic dissolve. The `lerp` function calculates `ink.a * mask`, resulting in a value between 0 and 1. The 0 portion is filled with `albedo.rgb`, the 1 portion is filled with `ink.rgb`, and the middle portion is blended. In other words, it blends the ink effect with the model's original color.
[0102] The virtual model special effects rendering method provided in this embodiment of the invention uses shaders and adjusts parameters to control the jittering and dynamic cyclical disappearance effects of ink wash textures on the model, creating a flowing ink wash painting feel on the appearance model, and without adding additional special effects patches, so there is no risk of clipping.
[0103] Regarding the special effects rendering method for virtual models provided in the foregoing embodiments, this embodiment of the invention provides a special effects rendering apparatus for virtual models, see [link to relevant documentation]. Figure 8 The diagram shows the structure of a special effects rendering device for a virtual model. The device includes the following parts:
[0104] The acquisition module 802 is used to acquire the initial virtual model and the initial effect texture to be rendered on the initial virtual model;
[0105] The texture determination module 804 is used to sample the initial effect texture to obtain an effect sampling result based on preset dithering parameters and initial texture sampling coordinates for the initial effect texture; and to sample the color texture of the initial virtual model to obtain a color sampling result; and to determine the dynamic cyclic hidden surface removal sampling result based on preset dissolution parameters and the initial texture sampling coordinates.
[0106] The rendering module 806 is used to render the initial virtual model based on the special effects sampling results, color sampling results, and dynamic loop hidden surface removal sampling results to obtain the target virtual model.
[0107] The virtual model special effects rendering device provided in this embodiment of the invention can determine the special effects sampling results, color sampling results and dynamic cyclic cloning sampling results respectively, thereby controlling the dizziness and dynamic cyclic cloning effect of the special effects texture on the virtual model. It can better achieve the artistic effect of dynamic cloning changes of special effects on the virtual model, and there is no need to add extra special effects patches on the virtual model. Therefore, it can effectively avoid the risk of clipping caused by special effects patches.
[0108] In one embodiment, the jitter parameters include jitter speed parameters, jitter intensity parameters, and jitter offset coordinates; the texture determination module 804 is further configured to:
[0109] Based on the current time, the jitter speed parameter, and the initial texture sampling coordinates, the first texture sampling coordinates for the initial effect texture at the current time are determined, and the first texture sampling coordinates are used to sample the preset noise texture to obtain the noise contour sampling result;
[0110] The noise profile sampling result is adjusted based on the jitter intensity parameter;
[0111] The second texture coordinates are obtained based on the initial texture sampling coordinates, the jitter offset coordinates, and the adjusted noise contour sampling results. The second texture coordinates are then used to sample the initial effect map to obtain the effect sampling results.
[0112] In one implementation, the texture determination module 804 is further configured to:
[0113] Multiple dissolve groups are determined for each color area in the preset mask texture;
[0114] Based on preset dissolution parameters, initial texture sampling coordinates, and color sampling results, the target special effect dissolution area is determined;
[0115] Based on the dissolution parameters and the target special effect dissolution area, the target dissolution cycle threshold and the target dissolution edge softness / hardness are determined for each dissolution group; where the target dissolution cycle threshold is used to describe the special effect solubility and special effect dissolution time of the dissolution group, and the target dissolution edge softness / hardness is used to adjust the softness / hardness of the mask texture edge;
[0116] The adjusted mask texture is determined as the result of dynamic cyclic hidden surface removal sampling.
[0117] In one embodiment, the dissolution parameters include a dissolution shape scaling factor; the texture determination module 804 is further configured to:
[0118] The ratio of the initial texture sampling coordinates to the dissolve shape scaling factor is used as the third texture coordinates, and the third texture coordinates are used to sample the preset noise map to obtain the initial special effect dissolve area.
[0119] The contrast value of the initial special effects dissolution area is adjusted by using the contrast value of the color sampling results to adjust the range of the dissolution area, and the adjusted initial special effects dissolution area is determined as the target special effects dissolution area.
[0120] In one implementation, the texture determination module 804 is further configured to:
[0121] The specific dissolution time for each dissolution group is determined based on the dissolution parameters.
[0122] The target dissolution cycle threshold for each dissolution group is determined based on the special dissolution time.
[0123] The hardness or softness of the target dissolution edge for each dissolution group is determined based on dissolution parameters, target dissolution cycle threshold, and target special effect dissolution region.
[0124] In one embodiment, the dissolution parameters further include a dissolution time interval parameter and a dissolution rate parameter; the texture determination module 804 is also used for:
[0125] The initial noise mask for each dissolution group is obtained by sampling the mask texture.
[0126] For each dissolution group, the initial noise mask corresponding to the dissolution group is mapped to the range of the dissolution time interval parameter to obtain the target noise mask;
[0127] The target noise mask is adjusted using the current time, and the product of the adjusted target noise mask and the dissolution rate parameter is calculated as the special dissolution time corresponding to the dissolution group.
[0128] In one implementation, the texture determination module 804 is further configured to:
[0129] For each dissolution group, the initial dissolution cycle threshold is obtained by taking the remainder of the corresponding effective dissolution time.
[0130] The specific dissolution time corresponding to the dissolution group is rounded down to obtain an integer dissolution time, and the remainder of the rounded dissolution time is then processed to obtain a threshold adjustment coefficient.
[0131] The initial dissolution cycle threshold is adjusted based on the threshold adjustment coefficient to obtain the target dissolution cycle threshold corresponding to the dissolution group.
[0132] In one embodiment, the dissolution parameters further include an effective solubility range and an edge softness / hardness parameter, wherein the effective solubility range is used to control the maximum and minimum values of the effective solubility; the texture determination module 804 is also used for:
[0133] For each dissolution group, the target dissolution cycle threshold corresponding to that dissolution group is mapped to the effective solubility range;
[0134] The target special effect dissolution region is adjusted using the mapped target dissolution cycle threshold to obtain the adjusted special effect dissolution region;
[0135] The adjusted special effect dissolution area is smoothed based on the edge hardness parameter to obtain the target dissolution edge hardness corresponding to the dissolution group.
[0136] In one implementation, the rendering module 806 is further configured to:
[0137] The product of the transparency of the special effects sampling result and the dynamic loop blanking sampling result is determined to obtain the value corresponding to each pixel in the initial virtual model;
[0138] For each pixel in the initial virtual model, if the value corresponding to the pixel is 0, then the pixel in the initial virtual model is filled with the color value of the color sampling result;
[0139] Alternatively, if the value corresponding to the pixel is 1, then the color value of the special effect sampling result is used to fill the pixel in the initial virtual model;
[0140] Alternatively, if the value corresponding to the pixel is greater than 0 and less than 1, then the color values of the color sampling result and the effect sampling result are used to blend and fill the pixel in the initial virtual model.
[0141] The initial virtual model after filling is determined as the target virtual model.
[0142] The device 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 device embodiment can be referred to the corresponding content in the aforementioned method embodiment.
[0143] This invention provides an electronic device, specifically, the electronic device includes a processor and a storage device; the storage device stores a computer program, which is executed by the processor when it runs:
[0144] A method for rendering special effects on a virtual model, comprising:
[0145] Obtain the initial virtual model and the initial effect textures to be rendered on the initial virtual model;
[0146] Based on preset dithering parameters and initial texture sampling coordinates for the initial effect map, the initial effect map is sampled to obtain effect sampling results; and the color map of the initial virtual model is sampled to obtain color sampling results; and the dynamic cyclic hidden surface removal sampling results are determined based on preset dissolve parameters and initial texture sampling coordinates.
[0147] The initial virtual model is rendered based on the special effects sampling results, color sampling results, and dynamic looping hidden surface removal sampling results to obtain the target virtual model.
[0148] In one embodiment, the jitter parameters include jitter speed parameters, jitter intensity parameters, and jitter offset coordinates;
[0149] Based on the preset dithering parameters and the initial texture sampling coordinates for the initial effect map:
[0150] Based on the current time, the jitter speed parameter, and the initial texture sampling coordinates, the first texture sampling coordinates for the initial effect texture at the current time are determined, and the first texture sampling coordinates are used to sample the preset noise texture to obtain the noise contour sampling result;
[0151] The noise profile sampling result is adjusted based on the jitter intensity parameter;
[0152] The second texture coordinates are obtained based on the initial texture sampling coordinates, the jitter offset coordinates, and the adjusted noise contour sampling results. The second texture coordinates are then used to sample the initial effect map to obtain the effect sampling results.
[0153] In one implementation, determining the dynamic cyclic hidden surface removal sampling result based on preset dissolution parameters and initial texture sampling coordinates includes:
[0154] Multiple dissolve groups are determined for each color area in the preset mask texture;
[0155] Based on preset dissolution parameters, initial texture sampling coordinates, and color sampling results, the target special effect dissolution area is determined;
[0156] Based on the dissolution parameters and the target special effect dissolution area, the target dissolution cycle threshold and the target dissolution edge softness / hardness are determined for each dissolution group; where the target dissolution cycle threshold is used to describe the special effect solubility and special effect dissolution time of the dissolution group, and the target dissolution edge softness / hardness is used to adjust the softness / hardness of the mask texture edge;
[0157] The adjusted mask texture is determined as the result of dynamic cyclic hidden surface removal sampling.
[0158] In one implementation, the dissolution parameters include a dissolution shape scaling factor;
[0159] Based on preset dissolution parameters, initial texture sampling coordinates, and color sampling results, the target special effects dissolution region is determined, including:
[0160] The ratio of the initial texture sampling coordinates to the dissolve shape scaling factor is used as the third texture coordinates, and the third texture coordinates are used to sample the preset noise map to obtain the initial special effect dissolve area.
[0161] The contrast value of the initial special effects dissolution area is adjusted by using the contrast value of the color sampling results to adjust the range of the dissolution area, and the adjusted initial special effects dissolution area is determined as the target special effects dissolution area.
[0162] In one implementation, the target dissolution cycle threshold and target dissolution edge hardness are determined for each dissolution group based on dissolution parameters and the target specific dissolution region, including:
[0163] The specific dissolution time for each dissolution group is determined based on the dissolution parameters.
[0164] The target dissolution cycle threshold for each dissolution group is determined based on the special dissolution time.
[0165] The hardness or softness of the target dissolution edge for each dissolution group is determined based on dissolution parameters, target dissolution cycle threshold, and target special effect dissolution region.
[0166] In one embodiment, the dissolution parameters further include a dissolution time interval parameter and a dissolution rate parameter;
[0167] The specific dissolution time for each dissolution group is determined based on dissolution parameters, including:
[0168] The initial noise mask for each dissolution group is obtained by sampling the mask texture.
[0169] For each dissolution group, the initial noise mask corresponding to the dissolution group is mapped to the range of the dissolution time interval parameter to obtain the target noise mask;
[0170] The target noise mask is adjusted using the current time, and the product of the adjusted target noise mask and the dissolution rate parameter is calculated as the special dissolution time corresponding to the dissolution group.
[0171] In one implementation, determining the target dissolution cycle threshold for each dissolution group based on the specific dissolution time includes:
[0172] For each dissolution group, the initial dissolution cycle threshold is obtained by taking the remainder of the corresponding effective dissolution time.
[0173] The specific dissolution time corresponding to the dissolution group is rounded down to obtain an integer dissolution time, and the remainder of the rounded dissolution time is then processed to obtain a threshold adjustment coefficient.
[0174] The initial dissolution cycle threshold is adjusted based on the threshold adjustment coefficient to obtain the target dissolution cycle threshold corresponding to the dissolution group.
[0175] In one embodiment, the dissolution parameters further include an effective solubility range and an edge softness / hardness parameter, wherein the effective solubility range is used to control the maximum and minimum values of the effective solubility.
[0176] The target dissolution edge hardness is determined for each dissolution group based on dissolution parameters, target dissolution cycle threshold, and target specific dissolution region, including:
[0177] For each dissolution group, the target dissolution cycle threshold corresponding to that dissolution group is mapped to the effective solubility range;
[0178] The target special effect dissolution region is adjusted using the mapped target dissolution cycle threshold to obtain the adjusted special effect dissolution region;
[0179] The adjusted special effect dissolution area is smoothed based on the edge hardness parameter to obtain the target dissolution edge hardness corresponding to the dissolution group.
[0180] In one implementation, an initial virtual model is rendered based on special effects sampling results, color sampling results, and dynamic cyclic hidden surface removal sampling results to obtain a target virtual model, including:
[0181] The product of the transparency of the special effects sampling result and the dynamic loop blanking sampling result is determined to obtain the value corresponding to each pixel in the initial virtual model;
[0182] For each pixel in the initial virtual model, if the value corresponding to the pixel is 0, then the pixel in the initial virtual model is filled with the color value of the color sampling result;
[0183] Alternatively, if the value corresponding to the pixel is 1, then the color value of the special effect sampling result is used to fill the pixel in the initial virtual model;
[0184] Alternatively, if the value corresponding to the pixel is greater than 0 and less than 1, then the color values of the color sampling result and the effect sampling result are used to blend and fill the pixel in the initial virtual model.
[0185] The initial virtual model after filling is determined as the target virtual model.
[0186] The electronic device provided in this invention can determine the special effects sampling results, color sampling results, and dynamic cyclic hidden removal sampling results respectively, thereby controlling the jitter and dynamic cyclic hidden removal effect of the special effects texture on the virtual model. It can better achieve the artistic effect of dynamic hidden removal changes of special effects on the virtual model, and there is no need to add extra special effects patches on the virtual model. Therefore, it can effectively avoid the risk of clipping caused by special effects patches.
[0187] Figure 9 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. The electronic device 100 includes: a processor 90, a memory 91, a bus 92, and a communication interface 93. The processor 90, the communication interface 93, and the memory 91 are connected through the bus 92. The processor 90 is used to execute executable modules, such as computer programs, stored in the memory 91.
[0188] The memory 91 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 93 (which can be wired or wireless), such as the Internet, wide area network, local area network, metropolitan area network, etc.
[0189] Bus 92 can 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 9 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.
[0190] The memory 91 is used to store programs. After receiving an execution instruction, the processor 90 executes the programs. The method executed by the device for defining the flow process disclosed in any of the foregoing embodiments of the present invention can be applied to the processor 90 or implemented by the processor 90.
[0191] The processor 90 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 the processor 90 or by instructions in software form. The processor 90 may be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it may 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 may be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this invention can be directly embodied in the execution of a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor. The software modules may reside in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. The storage medium is located in memory 91. Processor 90 reads the information in memory 91 and, in conjunction with its hardware, completes the steps of the above method.
[0192] The computer program product of the readable storage medium provided in the embodiments of the present invention includes a computer-readable storage medium storing program code, wherein the program code includes instructions that can be executed:
[0193] A method for rendering special effects on a virtual model, comprising:
[0194] Obtain the initial virtual model and the initial effect textures to be rendered on the initial virtual model;
[0195] Based on preset dithering parameters and initial texture sampling coordinates for the initial effect map, the initial effect map is sampled to obtain effect sampling results; and the color map of the initial virtual model is sampled to obtain color sampling results; and the dynamic cyclic hidden surface removal sampling results are determined based on preset dissolve parameters and initial texture sampling coordinates.
[0196] The initial virtual model is rendered based on the special effects sampling results, color sampling results, and dynamic looping hidden surface removal sampling results to obtain the target virtual model.
[0197] In one embodiment, the jitter parameters include jitter speed parameters, jitter intensity parameters, and jitter offset coordinates;
[0198] Based on preset dithering parameters and initial texture sampling coordinates for the initial effect map, including:
[0199] Based on the current time, the jitter speed parameter, and the initial texture sampling coordinates, the first texture sampling coordinates for the initial effect texture at the current time are determined, and the first texture sampling coordinates are used to sample the preset noise texture to obtain the noise contour sampling result;
[0200] The noise profile sampling result is adjusted based on the jitter intensity parameter;
[0201] The second texture coordinates are obtained based on the initial texture sampling coordinates, the jitter offset coordinates, and the adjusted noise contour sampling results. The second texture coordinates are then used to sample the initial effect map to obtain the effect sampling results.
[0202] In one implementation, determining the dynamic cyclic hidden surface removal sampling result based on preset dissolution parameters and initial texture sampling coordinates includes:
[0203] Multiple dissolve groups are determined for each color area in the preset mask texture;
[0204] Based on preset dissolution parameters, initial texture sampling coordinates, and color sampling results, the target special effect dissolution area is determined;
[0205] Based on the dissolution parameters and the target special effect dissolution area, the target dissolution cycle threshold and the target dissolution edge softness / hardness are determined for each dissolution group; where the target dissolution cycle threshold is used to describe the special effect solubility and special effect dissolution time of the dissolution group, and the target dissolution edge softness / hardness is used to adjust the softness / hardness of the mask texture edge;
[0206] The adjusted mask texture is determined as the result of dynamic cyclic hidden surface removal sampling.
[0207] In one implementation, the dissolution parameters include a dissolution shape scaling factor;
[0208] Based on preset dissolution parameters, initial texture sampling coordinates, and color sampling results, the target special effects dissolution region is determined, including:
[0209] The ratio of the initial texture sampling coordinates to the dissolve shape scaling factor is used as the third texture coordinates, and the third texture coordinates are used to sample the preset noise map to obtain the initial special effect dissolve area.
[0210] The contrast value of the initial special effects dissolution area is adjusted by using the contrast value of the color sampling results to adjust the range of the dissolution area, and the adjusted initial special effects dissolution area is determined as the target special effects dissolution area.
[0211] In one implementation, the target dissolution cycle threshold and target dissolution edge hardness are determined for each dissolution group based on dissolution parameters and the target specific dissolution region, including:
[0212] The specific dissolution time for each dissolution group is determined based on the dissolution parameters.
[0213] The target dissolution cycle threshold for each dissolution group is determined based on the special dissolution time.
[0214] The hardness or softness of the target dissolution edge for each dissolution group is determined based on dissolution parameters, target dissolution cycle threshold, and target special effect dissolution region.
[0215] In one embodiment, the dissolution parameters further include a dissolution time interval parameter and a dissolution rate parameter;
[0216] The specific dissolution time for each dissolution group is determined based on dissolution parameters, including:
[0217] The initial noise mask for each dissolution group is obtained by sampling the mask texture.
[0218] For each dissolution group, the initial noise mask corresponding to the dissolution group is mapped to the range of the dissolution time interval parameter to obtain the target noise mask;
[0219] The target noise mask is adjusted using the current time, and the product of the adjusted target noise mask and the dissolution rate parameter is calculated as the special dissolution time corresponding to the dissolution group.
[0220] In one implementation, determining the target dissolution cycle threshold for each dissolution group based on the specific dissolution time includes:
[0221] For each dissolution group, the initial dissolution cycle threshold is obtained by taking the remainder of the corresponding effective dissolution time.
[0222] The specific dissolution time corresponding to the dissolution group is rounded down to obtain an integer dissolution time, and the remainder of the rounded dissolution time is then processed to obtain a threshold adjustment coefficient.
[0223] The initial dissolution cycle threshold is adjusted based on the threshold adjustment coefficient to obtain the target dissolution cycle threshold corresponding to the dissolution group.
[0224] In one embodiment, the dissolution parameters further include an effective solubility range and an edge softness / hardness parameter, wherein the effective solubility range is used to control the maximum and minimum values of the effective solubility.
[0225] The target dissolution edge hardness is determined for each dissolution group based on dissolution parameters, target dissolution cycle threshold, and target specific dissolution region, including:
[0226] For each dissolution group, the target dissolution cycle threshold corresponding to that dissolution group is mapped to the effective solubility range;
[0227] The target special effect dissolution region is adjusted using the mapped target dissolution cycle threshold to obtain the adjusted special effect dissolution region;
[0228] The adjusted special effect dissolution area is smoothed based on the edge hardness parameter to obtain the target dissolution edge hardness corresponding to the dissolution group.
[0229] In one implementation, an initial virtual model is rendered based on special effects sampling results, color sampling results, and dynamic cyclic hidden surface removal sampling results to obtain a target virtual model, including:
[0230] The product of the transparency of the special effects sampling result and the dynamic loop blanking sampling result is determined to obtain the value corresponding to each pixel in the initial virtual model;
[0231] For each pixel in the initial virtual model, if the value corresponding to the pixel is 0, then the pixel in the initial virtual model is filled with the color value of the color sampling result;
[0232] Alternatively, if the value corresponding to the pixel is 1, then the color value of the special effect sampling result is used to fill the pixel in the initial virtual model;
[0233] Alternatively, if the value corresponding to the pixel is greater than 0 and less than 1, then the color values of the color sampling result and the effect sampling result are used to blend and fill the pixel in the initial virtual model.
[0234] The initial virtual model after filling is determined as the target virtual model.
[0235] The readable storage medium provided in this embodiment of the invention can determine the special effects sampling results, color sampling results, and dynamic cyclic cloning sampling results respectively, thereby controlling the jitter and dynamic cyclic cloning effect of the special effects texture on the virtual model. It can better achieve the artistic effect of dynamic cloning changes of special effects on the virtual model, and there is no need to add extra special effects patches on the virtual model. Therefore, it can effectively avoid the risk of clipping caused by special effects patches.
[0236] 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, server, or 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.
[0237] 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 method for rendering special effects of a virtual model, characterized in that, include: Obtain the initial virtual model and the initial effect texture to be rendered on the initial virtual model; Based on preset dithering parameters and initial texture sampling coordinates for the initial effect map, the initial effect map is sampled to obtain an effect sampling result; and the color map of the initial virtual model is sampled to obtain a color sampling result; and the dynamic cyclic hidden surface removal sampling result is determined based on preset dissolve parameters and the initial texture sampling coordinates. The initial virtual model is rendered based on the special effects sampling results, the color sampling results, and the dynamic loop closing sampling results to obtain the target virtual model.
2. The special effects rendering method for virtual models according to claim 1, characterized in that, The jitter parameters include jitter speed parameters, jitter intensity parameters, and jitter offset coordinates; Based on preset dithering parameters and initial texture sampling coordinates for the initial effect texture, the initial effect texture is sampled to obtain effect sampling results, including: Based on the current time, the jitter speed parameter, and the initial texture sampling coordinates, the first texture sampling coordinates for the initial effect texture at the current time are determined, and the first texture sampling coordinates are used to sample the preset noise texture to obtain the noise contour sampling result; The noise profile sampling result is adjusted based on the jitter intensity parameter; The second texture coordinates are obtained based on the initial texture sampling coordinates, the jitter offset coordinates, and the adjusted noise contour sampling results. The second texture coordinates are then used to sample the initial effect map to obtain the effect sampling results.
3. The special effects rendering method for virtual models according to claim 1, characterized in that, The dynamic cyclic hidden surface removal sampling result is determined based on the preset dissolution parameters and the initial texture sampling coordinates, including: Multiple dissolve groups are determined for each color area in the preset mask texture; Based on the preset dissolution parameters, the initial texture sampling coordinates, and the color sampling results, the target special effect dissolution area is determined; Based on the dissolution parameters and the target special effect dissolution area, the target dissolution cycle threshold and the target dissolution edge softness / hardness are determined for each dissolution group; wherein, the target dissolution cycle threshold is used to describe the special effect solubility and special effect dissolution time of the dissolution group, and the target dissolution edge softness / hardness is used to adjust the softness / hardness of the mask texture edge; The adjusted mask map is determined as the result of dynamic cyclic hidden surface removal sampling.
4. The special effects rendering method for virtual models according to claim 3, characterized in that, The dissolution parameters include the dissolution shape scaling factor; Based on preset dissolution parameters, the initial texture sampling coordinates, and the color sampling results, the target special effect dissolution region is determined, including: The ratio of the initial texture sampling coordinates to the dissolve shape scaling factor is used as the third texture coordinates, and the third texture coordinates are used to sample the preset noise map to obtain the initial special effect dissolve region. The contrast value of the initial special effects dissolving region is adjusted by using the contrast value of the color sampling result to adjust the range of the dissolving region, and the adjusted initial special effects dissolving region is determined as the target special effects dissolving region.
5. The special effects rendering method for virtual models according to claim 3, characterized in that, Based on the dissolution parameters and the target special effect dissolution region, the target dissolution cycle threshold and target dissolution edge hardness are determined for each dissolution group, including: The specific dissolution time corresponding to each dissolution group is determined based on the dissolution parameters; The target dissolution cycle threshold corresponding to each dissolution group is determined based on the special effect dissolution time. The target dissolution edge hardness is determined for each dissolution group based on the dissolution parameters, the target dissolution cycle threshold, and the target special effect dissolution region.
6. The special effects rendering method for virtual models according to claim 5, characterized in that, The dissolution parameters also include dissolution time interval parameters and dissolution rate parameters; Determining the specific dissolution time for each dissolution group based on the dissolution parameters includes: The initial noise mask corresponding to each of the dissolution groups is obtained by sampling the mask texture; For each of the dissolution groups, the initial noise mask corresponding to the dissolution group is mapped to the range of the dissolution time interval parameter to obtain the target noise mask; The target noise mask is adjusted using the current time, and the product of the adjusted target noise mask and the dissolution rate parameter is calculated as the special dissolution time corresponding to the dissolution group.
7. The special effects rendering method for virtual models according to claim 5, characterized in that, Determining the target dissolution cycle threshold for each dissolution group based on the aforementioned special dissolution time includes: For each of the dissolution groups, the initial dissolution cycle threshold is obtained by taking the remainder of the special dissolution time corresponding to the dissolution group. The special dissolution time corresponding to the dissolution group is rounded down to obtain an integer dissolution time, and the remainder of the rounded dissolution time is processed to obtain a threshold adjustment coefficient; The initial dissolution cycle threshold is adjusted based on the threshold adjustment coefficient to obtain the target dissolution cycle threshold corresponding to the dissolution group.
8. The special effects rendering method for virtual models according to claim 5, characterized in that, The dissolution parameters also include a specific solubility range and an edge softness / hardness parameter, wherein the specific solubility range is used to control the maximum and minimum values of the specific solubility; Determining the target dissolution edge hardness for each dissolution group based on the dissolution parameters, the target dissolution cycle threshold, and the target special effect dissolution region includes: For each of the dissolution groups, the target dissolution cycle threshold corresponding to the dissolution group is mapped to the special solubility range; The target special effect dissolution region is adjusted using the mapped target dissolution cycle threshold to obtain the adjusted special effect dissolution region; Based on the edge hardness parameter, the adjusted special effect dissolution region is subjected to smooth transition processing to obtain the target dissolution edge hardness corresponding to the dissolution group.
9. The special effects rendering method for virtual models according to claim 1, characterized in that, The initial virtual model is rendered based on the special effects sampling results, the color sampling results, and the dynamic looping hidden surface removal sampling results to obtain the target virtual model, including: The product of the transparency of the special effect sampling result and the dynamic loop blanking sampling result is determined to obtain the value corresponding to each pixel in the initial virtual model; For each pixel in the initial virtual model, if the value corresponding to the pixel is 0, then the pixel in the initial virtual model is filled with the color value of the color sampling result; Alternatively, if the value corresponding to the pixel is 1, then the color value of the special effect sampling result is used to fill the pixel in the initial virtual model; Alternatively, if the value corresponding to the pixel is greater than 0 and less than 1, then the pixel in the initial virtual model is mixed and filled using the color values of the color sampling result and the special effect sampling result; The initial virtual model after filling is determined as the target virtual model.
10. A special effects rendering device for a virtual model, characterized in that, include: The acquisition module is used to acquire the initial virtual model and the initial effect texture to be rendered on the initial virtual model; The texture determination module is used to sample the initial effect texture to obtain an effect sampling result based on preset dithering parameters and the initial texture sampling coordinates of the initial effect texture; and to sample the color texture of the initial virtual model to obtain a color sampling result; and to determine the dynamic cyclic hidden surface removal sampling result based on preset dissolution parameters and the initial texture sampling coordinates. The rendering module is used to render the initial virtual model based on the special effects sampling results, the color sampling results, and the dynamic loop closing sampling results to obtain the target virtual model.
11. An electronic device, characterized in that, The method includes a processor and a memory, the memory storing computer-executable instructions executable by the processor, the processor executing the computer-executable instructions to implement the method of any one of claims 1 to 9.
12. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions that, when invoked and executed by a processor, cause the processor to perform the method according to any one of claims 1 to 9.